Classes | Namespaces | Enumerations | Functions | Variables
draw_plots_util.h File Reference
#include "CAFAna/Analysis/Exposures.h"
#include "CAFAna/Analysis/Plots.h"
#include "CAFAna/Analysis/Calcs.h"
#include "3FlavorAna/Plotting/NuePlotStyle.h"
#include "CAFAna/Analysis/Style.h"
#include "CAFAna/Core/Binning.h"
#include "CAFAna/Core/HistAxis.h"
#include "CAFAna/Core/LoadFromFile.h"
#include "CAFAna/Prediction/IPrediction.h"
#include "CAFAna/Prediction/PredictionExtrap.h"
#include "CAFAna/Prediction/PredictionNoExtrap.h"
#include "3FlavorAna/Prediction/PredictionExtendToPeripheral.h"
#include "CAFAna/Vars/FitVars.h"
#include "3FlavorAna/Vars/Binnings.h"
#include "OscLib/OscCalcDumb.h"
#include "OscLib/IOscCalc.h"
#include "TStyle.h"
#include "TFile.h"
#include "TH1.h"
#include "TCanvas.h"
#include "TGraph.h"
#include "TGraphAsymmErrors.h"
#include "TGaxis.h"
#include "TLatex.h"
#include "TPaveText.h"
#include "TLegend.h"
#include "TLine.h"
#include "TSystem.h"
#include <iostream>
#include <fstream>
#include <iomanip>
#include "tex_tables_util.h"

Go to the source code of this file.

Classes

struct  ana::DataMCComponets
 

Namespaces

 ana
 Cuts and Vars for the 2020 FD DiF Study.
 

Enumerations

enum  AxisType {
  kNue1bin, kNue3bin, kNue4bin, kNumuOpt,
  kNumuOther, kNue1bin, kNue3bin, kNumuOpt,
  kNumuOther, kNue1bin, kNue3bin, kNumuOpt,
  kNumuOther, kNue1bin, kNue3bin, kNueNDbin,
  kNumuOpt, kNumuOther
}
 

Functions

osc::IOscCalcGetCalculator (bool usingdumb)
 
TH1 * PrettyRatio (TH1 *shi, TH1 *nom, int color, double alpha=1., TString titley="Shift / Nom")
 
double FindLimitY (std::vector< TH1 * > histos, bool doMax=true)
 
void FormatErrorBand (TH1 *hplus, TH1 *hminus, bool signal=false, bool fixbins=false)
 
TH1 * HistNumuOpt (TH1 *orig)
 
void PrettyTag (TString pid, int color, double xndc, double yndc)
 
void PIDTag (TString pid)
 
void HTag (TString hie)
 
TLegend * CustomLegend (std::vector< TH1 * >h, std::vector< TString > title, std::vector< TString > option, double x1=kLegendDefaultX1, double y1=kLegendDefaultY1, double x2=kLegendDefaultX2, double y2=kLegendDefaultY2)
 
void FixLegend (TLegend *leg, TString opt="default")
 
TGraph * DummyGraph (int color=kBlack, int style=1, int linewidth=2, int markerstyle=kFullCircle)
 
TLegend * DefaultNueLegend (bool sig=true, bool tot=true, bool data=false, double x1=kLegendDefaultX1, double y1=kLegendDefaultY1, double x2=kLegendDefaultX2, double y2=kLegendDefaultY2)
 
TLegend * DefaultNumuLegend (bool sig=true, bool tot=true, bool data=false, double x1=kLegendDefaultX1, double y1=kLegendDefaultY1, double x2=kLegendDefaultX2, double y2=kLegendDefaultY2)
 
void PrintCanvasAll (TCanvas *c, const TString outname, const TString outdir="plots/", const std::vector< TString > exts={"pdf","png","root"})
 
TH1 * RebinToShortAxis (TH1 *h)
 
void PIDDivisions (bool shortaxis=false)
 
void PIDBinLabels (std::string pid="CVN", bool shortaxis=false, double yNDC=0.955, double textsize=0.028)
 
void FourBinDivisions ()
 
void FourBinLabels (double yNDC=0.98, double textsize=0.028)
 
void FourBinAxis (TH1 *axes, bool third=false, bool shortaxis=false)
 
void PID2DAxis (TH1 *axes, bool third=false, bool shortaxis=false)
 
void NuePID4bin (TH1 *h, TString pidtag, bool binlabels=true)
 
void NuePID3bin (TH1 *h, TString pidtag, bool binlabels=true)
 
TCanvas * ExPIDPlot (std::vector< TH1 * > topHistos, std::vector< TString > topOption)
 
TCanvas * RatioPlot (std::vector< TH1 * > topHistos, std::vector< TString > topOption, std::vector< TH1 * > bottomHistos, std::vector< TString > bottomOption, TString pidtag, AxisType pidaxis=kNue1bin)
 
void PlotDataMC (std::vector< TH1 * >vnom, std::vector< bool >isdata, TLegend *leg, TString pidtag="", TString htag="", TString out_name="plot_FD", bool ratioplot=false, bool ratioerrors=false, AxisType pidaxis=kNue1bin)
 
void PlotNDDataTotalMCComparison (TH1 *hdata, std::vector< TH1 * > htots, TLegend *leg, TString pidtag="", TString out_name="plot_nd", bool ratioplot=false, AxisType pidaxis=kNue1bin)
 
void PlotMCComponentsComparison (std::vector< TH1 * >vnom, std::vector< TH1 * >vshi, TLegend *leg, TString pidtag="", TString out_name="plot_nd", bool ratioplot=false, bool ratioerrors=false, AxisType pidaxis=kNue1bin)
 
void PlotMCComponentsErrorBand (std::vector< TH1 * >vnom, std::vector< TH1 * >vshi, TLegend *leg, TString pidtag="", TString out_name="plot_nd", bool ratioplot=false, bool ratioerrors=false, AxisType pidaxis=kNue1bin)
 
void ana::DefaultFormatNue (DataMCComponets &comp, int linestyle=1)
 
struct DataMCComponets ana::GetNDComponents (TDirectory *d_no, double kNDPOT, int linestyle=1)
 
struct DataMCComponets ana::GetFDMCComponents (osc::IOscCalc *calc, IPrediction *pred_no, TString output_name="nue", int linestyle=1, bool bkgdetails=false)
 
void ana::CompareNDDataOneMC (TDirectory *d_no, TDirectory *d_sh, TString plottitle, TString out_name, TString pidtag, bool printtable=true, AxisType pidaxis=kNue1bin)
 
void ana::CompareNDDataTwoMC (TDirectory *d_no, TDirectory *d_pl, TDirectory *d_mi, TString plottitle, TString out_name, TString pidtag, bool printtable=true, AxisType pidaxis=kNue1bin)
 
void ana::CompareNDDataMCFromVector (TDirectory *d_no, std::vector< TDirectory * > d_sh, TString plottitle, TString out_name, TString tag, bool printtable=true, AxisType pidaxis=kNue1bin)
 
void ana::CompareOneShiftPred (IPrediction *pred_no, IPrediction *pred_sh, TString plottitle, TString out_name, TString pidtag, bool printtable=true, AxisType pidaxis=kNue1bin, bool PrintParams=false)
 
void ana::CompareTwoShiftPred (IPrediction *pred_no, IPrediction *pred_pl, IPrediction *pred_mi, TString plottitle, TString out_name, TString pidtag, bool printtable=true, AxisType pidaxis=kNue1bin, bool PrintParams=false)
 
void ana::ComparePredictionsFromVector (TDirectory *dpred_no, std::vector< TDirectory * > dpred_sh, TString plottitle, TString out_name, bool printtable=true, AxisType pidaxis=kNue1bin)
 
void ana::ComparePredictionsPeripheralFromVector (TDirectory *dpred_no_xp, TDirectory *dpred_no_nxp, std::vector< TDirectory * > dpred_sh_xp, std::vector< TDirectory * > dpred_sh_nxp, TString plottitle, TString out_name, bool printtable=true, AxisType pidaxis=kNue4bin)
 

Variables

static const double kFDPOT = ana::kAna2017POT
 
const bool printratioplots =true
 
bool usedumb = false
 
bool mergePeripheral =false
 
const double kLegendDefaultX1 = 0.63
 
const double kLegendDefaultX2 = 0.85
 
const double kLegendDefaultY1 = 0.68
 
const double kLegendDefaultY2 = 0.88
 

Enumeration Type Documentation

enum AxisType
Enumerator
kNue1bin 
kNue3bin 
kNue4bin 
kNumuOpt 
kNumuOther 
kNue1bin 
kNue3bin 
kNumuOpt 
kNumuOther 
kNue1bin 
kNue3bin 
kNumuOpt 
kNumuOther 
kNue1bin 
kNue3bin 
kNueNDbin 
kNumuOpt 
kNumuOther 

Definition at line 41 of file draw_plots_util.h.

Function Documentation

TLegend* CustomLegend ( std::vector< TH1 * >  h,
std::vector< TString >  title,
std::vector< TString >  option,
double  x1 = kLegendDefaultX1,
double  y1 = kLegendDefaultY1,
double  x2 = kLegendDefaultX2,
double  y2 = kLegendDefaultY2 
)

Definition at line 156 of file draw_plots_util.h.

References MECModelEnuComparisons::leg, registry_explorer::v, x1, submit_syst::x2, y1, and submit_syst::y2.

Referenced by RatioPlot().

160 {
161  TLegend* leg = new TLegend(x1,y1,x2,y2);
162  leg->SetFillStyle(0);
163  for ( unsigned int v = 0; v<h.size(); ++v){
164  leg->AddEntry(h[v],title[v],option[v]);
165  }
166  leg->SetBit(kCanDelete);
167  return leg;
168 }
Float_t y1[n_points_granero]
Definition: compare.C:5
Float_t x1[n_points_granero]
Definition: compare.C:5
TLegend* DefaultNueLegend ( bool  sig = true,
bool  tot = true,
bool  data = false,
double  x1 = kLegendDefaultX1,
double  y1 = kLegendDefaultY1,
double  x2 = kLegendDefaultX2,
double  y2 = kLegendDefaultY2 
)

Definition at line 208 of file draw_plots_util.h.

References DummyGraph(), ana::kBeamNueBackgroundColor, ana::kNCBackgroundColor, ana::kNueSignalColor, ana::kNumuBackgroundColor, ana::kTotalMCColor, MECModelEnuComparisons::leg, PandAna.Demos.pi0_spectra::tot, x1, submit_syst::x2, y1, and submit_syst::y2.

211 {
212  TLegend* leg = new TLegend(x1,y1,x2,y2);
213  leg->SetFillStyle(0);
214  if(sig) leg->AddEntry( DummyGraph(kNueSignalColor), "#nu_{e} Signal","l");
215  if(data) leg->AddEntry( DummyGraph(), "ND Data","epl");
216  if(tot) leg->AddEntry( DummyGraph(kTotalMCColor), "Total Bkg","l");
217  leg->AddEntry( DummyGraph(kBeamNueBackgroundColor), "Beam #nu_{e}","l");
218  leg->AddEntry( DummyGraph(kNCBackgroundColor), "NC","l");
219  leg->AddEntry( DummyGraph(kNumuBackgroundColor), "#nu_{#mu} CC","l");
220  leg->SetBit(kCanDelete);
221  return leg;
222 
223 }
Float_t y1[n_points_granero]
Definition: compare.C:5
Float_t x1[n_points_granero]
Definition: compare.C:5
const Color_t kNumuBackgroundColor
Definition: Style.h:30
const Color_t kNueSignalColor
Definition: Style.h:19
const XML_Char const XML_Char * data
Definition: expat.h:268
const Color_t kBeamNueBackgroundColor
Definition: Style.h:24
TGraph * DummyGraph(int color=kBlack, int style=1, int linewidth=2, int markerstyle=kFullCircle)
const Color_t kTotalMCColor
Definition: Style.h:16
const Color_t kNCBackgroundColor
Definition: Style.h:22
TLegend* DefaultNumuLegend ( bool  sig = true,
bool  tot = true,
bool  data = false,
double  x1 = kLegendDefaultX1,
double  y1 = kLegendDefaultY1,
double  x2 = kLegendDefaultX2,
double  y2 = kLegendDefaultY2 
)

Definition at line 226 of file draw_plots_util.h.

References DummyGraph(), isNumuAna, ana::kBeamNueBackgroundColor, ana::kNCBackgroundColor, ana::kNueSignalColor, ana::kNumuBackgroundColor, ana::kTotalMCColor, MECModelEnuComparisons::leg, PandAna.Demos.pi0_spectra::tot, x1, submit_syst::x2, y1, and submit_syst::y2.

Referenced by ana::CompareNDDataMCFromVector(), ana::CompareNDDataOneMC(), ana::CompareNDDataTwoMC(), ana::CompareOneShiftPred(), ana::CompareTwoShiftPred(), ana::GetNDComponents(), and ana::GetNDDecompsFromDecomp().

229 {
230  TLegend* leg = new TLegend(x1,y1,x2,y2);
231  leg->SetFillStyle(0);
232  if(sig) leg->AddEntry( DummyGraph(kNueSignalColor), "#nu_{#mu} Signal","l");
233  if(data) leg->AddEntry( DummyGraph(), "ND Data","epl");
234  if(tot) leg->AddEntry( DummyGraph(kTotalMCColor), "Total Bkg","l");
235  if(isNumuAna) leg->AddEntry( DummyGraph(kNumuBackgroundColor), "#nu_{#mu} app","l");
236  else leg->AddEntry( DummyGraph(kNumuBackgroundColor), "#nu_{#mu} CC" ,"l");
237  leg->AddEntry( DummyGraph(kNCBackgroundColor), "NC","l");
238  leg->AddEntry( DummyGraph(kBeamNueBackgroundColor), "#nu_{e} CC","l");
239  leg->SetBit(kCanDelete);
240  return leg;
241 
242 }
Float_t y1[n_points_granero]
Definition: compare.C:5
Float_t x1[n_points_granero]
Definition: compare.C:5
const Color_t kNumuBackgroundColor
Definition: Style.h:30
const Color_t kNueSignalColor
Definition: Style.h:19
const XML_Char const XML_Char * data
Definition: expat.h:268
bool isNumuAna
const Color_t kBeamNueBackgroundColor
Definition: Style.h:24
TGraph * DummyGraph(int color=kBlack, int style=1, int linewidth=2, int markerstyle=kFullCircle)
const Color_t kTotalMCColor
Definition: Style.h:16
const Color_t kNCBackgroundColor
Definition: Style.h:22
TGraph* DummyGraph ( int  color = kBlack,
int  style = 1,
int  linewidth = 2,
int  markerstyle = kFullCircle 
)

Definition at line 196 of file draw_plots_util.h.

References plot_validation_datamc_2018::color.

Referenced by ana::CompareNDDataMCFromVector(), ana::CompareNDDataOneMC(), ana::CompareOneShiftPred(), DefaultNueLegend(), DefaultNumuLegend(), and ana::GetNDComponents().

197 {
198  auto gr = new TGraph();
199  gr->SetLineColor(color);
200  gr->SetLineStyle(style);
201  gr->SetLineWidth(linewidth);
202  gr->SetMarkerStyle(markerstyle);
203  gr->SetMarkerColor(color);
204  return gr;
205 }
TCanvas* ExPIDPlot ( std::vector< TH1 * >  topHistos,
std::vector< TString >  topOption 
)

Definition at line 467 of file draw_plots_util.h.

References plot_validation_datamc::Clone(), Ebins, FindLimitY(), make_syst_table_plots::h, he, calib::j, and pidBins.

Referenced by PlotMCComponentsComparison(), and PlotNDDataTotalMCComparison().

469 {
470  TCanvas *cpid = new TCanvas("cpid", "cpid", 410, 850);
471  float Ebins = 10;
472  int pidBins = 3;
473 
474  TPad* p[pidBins];
475  p[0] = new TPad("", "", 0, 0, 1, 1);
476  p[1] = new TPad("", "", 0, 0, 1, 1);
477  p[2] = new TPad("", "", 0, 0, 1, 1);
478  p[0]->SetTopMargin(0.1);
479  p[0]->SetBottomMargin(.634);
480  p[1]->SetTopMargin(.369);
481  p[1]->SetBottomMargin(.369);
482  p[2]->SetTopMargin(.634);
483  p[2]->SetBottomMargin(0.1);
484  p[0]->SetFillStyle(0);
485  p[1]->SetFillStyle(0);
486  p[2]->SetFillStyle(0);
487  p[0]->Draw();
488  p[1]->Draw();
489  p[2]->Draw();
490 
491  TH1* he[pidBins];
492  TH1* h[topHistos.size()][pidBins];
493  for(int k=pidBins-1; k>=0; --k){
494  he[k] = (TH1*) topHistos[0]->Clone();
495  he[k]->GetYaxis()->SetRangeUser(FindLimitY(topHistos,0) ,1.2*FindLimitY(topHistos,1));
496  he[k]->GetXaxis()->SetRangeUser(Ebins*k,Ebins*(k+1));
497  if ( k>0 ) he[k]->GetXaxis()->SetLabelSize(0);
498  p[pidBins-1-k]->cd();
499  he[k]->Draw(topOption[0]);
500  he[k]->GetYaxis()->SetTitleSize(24);
501  he[k]->GetYaxis()->SetTitleFont(43);
502  he[k]->GetYaxis()->SetTitleOffset(1.25);
503  he[k]->GetYaxis()->SetLabelFont(43);
504  he[k]->GetYaxis()->SetLabelSize(14);
505  he[k]->GetXaxis()->SetLabelOffset(-0.008);
506  he[k]->GetXaxis()->SetTitleOffset(0.5);
507  p[pidBins-1-k]->SetGridy();
508  }
509  for(unsigned int ii=0;ii<topHistos.size();ii++){
510  for(int j=pidBins-1; j>=0; --j){
511  h[ii][j] = (TH1*) topHistos[ii]->Clone();
512  h[ii][j]->GetXaxis()->SetRangeUser(Ebins*j,Ebins*(j+1));
513  p[pidBins-1-j]->cd();
514  h[ii][j]->Draw("same "+topOption[ii]);
515  }
516  }
517  for(int h=pidBins-1; h>=0; --h){
518  he[h]->SetStats(0);
519  p[pidBins-1-h]->cd();
520  he[h]->Draw("same "+topOption[0]);
521  }
522  p[0]->RedrawAxis(); //needed for white histograms e.g. beam
523  p[1]->RedrawAxis();
524  p[2]->RedrawAxis();
525  return cpid;
526 }
const int pidBins
const char * p
Definition: xmltok.h:285
double FindLimitY(std::vector< TH1 * > histos, bool doMax=true)
double Ebins[11]
Definition: Xdiff_gwt.C:8
const double j
Definition: BetheBloch.cxx:29
double he
Definition: runWimpSim.h:113
double FindLimitY ( std::vector< TH1 * >  histos,
bool  doMax = true 
)

Definition at line 84 of file draw_plots_util.h.

References make_mec_shifts_plots::GetMaximum(), MECModelEnuComparisons::i, cet::sqlite::max(), and min().

Referenced by ana::CompareNDDataMCFromVector(), ana::CompareNDDataOneMC(), ana::CompareNDDataTwoMC(), ana::CompareOneShiftPred(), ana::CompareTwoShiftPred(), ExPIDPlot(), ana::GetNDComponents(), ana::GetNDDecompsFromDecomp(), and RatioPlot().

85 {
86  double max = histos[0]->GetMaximum();
87  double min = histos[0]->GetMinimum();
88 
89  for(unsigned int i=0; i<histos.size(); i++){
90  if ( histos[i]->GetMaximum() > max ) max = histos[i]->GetMaximum();
91  if ( histos[i]->GetMinimum() < min ) min = histos[i]->GetMinimum();
92  }
93 
94  if ( doMax ) return max;
95  else return min;
96 }
static float min(const float a, const float b, const float c)
Definition: absgeo.cxx:45
T max(sqlite3 *const db, std::string const &table_name, std::string const &column_name)
Definition: statistics.h:68
void FixLegend ( TLegend *  leg,
TString  opt = "default" 
)

Definition at line 172 of file draw_plots_util.h.

References kLegendDefaultX1, kLegendDefaultX2, kLegendDefaultY1, kLegendDefaultY2, and MECModelEnuComparisons::opt.

Referenced by PlotDataMC(), PlotMCComponentsComparison(), PlotMCComponentsErrorBand(), PlotNDDataTotalMCComparison(), and RatioPlot().

172  {
173  leg->SetFillStyle(0);
174  if(opt=="default"){
175  leg->SetX1(kLegendDefaultX1); leg->SetX2(kLegendDefaultX2);
176  leg->SetY1(kLegendDefaultY1); leg->SetY2(kLegendDefaultY2);
177  }
178  if(opt=="ExPID"){
179  leg->SetX1(0.405); leg->SetX2(0.565);
180  leg->SetY1(0.63); leg->SetY2(0.82);
181  leg->SetBorderSize(0);
182  leg->SetTextSize(0.033);
183  }
184  if(opt=="4bins"){
185  leg->SetX1(0.7); leg->SetX2(0.89);
186  leg->SetY1(0.6); leg->SetY2(0.79);
187  }
188  if(opt=="ExPIDPads"){
189  leg->SetX1(0.55); leg->SetX2(0.89);
190  leg->SetY1(0.75); leg->SetY2(0.89);
191  leg->SetTextSize(0.045);
192  }
193 }
const double kLegendDefaultY2
const double kLegendDefaultY1
const double kLegendDefaultX2
const double kLegendDefaultX1
void FormatErrorBand ( TH1 *  hplus,
TH1 *  hminus,
bool  signal = false,
bool  fixbins = false 
)

Definition at line 99 of file draw_plots_util.h.

References MECModelEnuComparisons::i, kBlue, kRed, ana::kTotalMCErrorBandColor, kViolet, cet::sqlite::max(), and min().

Referenced by PlotMCComponentsErrorBand().

99  {
100 
101  int mccolor = signal ? kViolet -9 : kTotalMCErrorBandColor;
102  hplus ->SetLineColor(mccolor);
103  hminus->SetLineColor(mccolor);
104  hplus ->SetFillColor(mccolor);
105  hminus->SetFillColor(10);
106  hplus ->SetMarkerColor(kRed-7);
107  hminus->SetMarkerColor(kBlue-7);
108 
109  if (fixbins){
110  for(int i=1;i<=hplus->GetNbinsX();i++){
111  double tplus = hplus->GetBinContent(i);
112  double tminus = hminus->GetBinContent(i);
113  hplus->SetBinContent(i,max(tplus, tminus));
114  hminus->SetBinContent(i,min(tplus,tminus));
115  }
116  }
117 }
enum BeamMode kRed
TH1F * hplus
Definition: Xsec_final.C:75
const Color_t kTotalMCErrorBandColor
Definition: Style.h:17
static float min(const float a, const float b, const float c)
Definition: absgeo.cxx:45
TH1F * hminus
Definition: Xsec_final.C:76
enum BeamMode kViolet
T max(sqlite3 *const db, std::string const &table_name, std::string const &column_name)
Definition: statistics.h:68
enum BeamMode kBlue
void FourBinAxis ( TH1 *  axes,
bool  third = false,
bool  shortaxis = false 
)

Definition at line 378 of file draw_plots_util.h.

References visualisationForPaperMasterPlot::ax, CenterTitles(), gen_hdf5record::size, and ymin.

Referenced by NuePID4bin().

379 {
380  double ymin = axes->GetMinimum();
381  TGaxis* gax1 = new TGaxis(0.001, ymin, 9, ymin, 0.001, 4.5, 205, "S L");
382  TGaxis* gax2 = new TGaxis(9.001, ymin, 18, ymin, 0.001, 4.5, 205, "S L");
383  TGaxis* gax3 = new TGaxis(18.001, ymin, 27, ymin, 0.001, 4.5, 205, "S L");
384  TGaxis* gax4 = new TGaxis(27.001, ymin, 36, ymin, 0.001, 4.5, 205, "S L");
385 
386  float size = axes->GetXaxis()->GetLabelSize();
387  float offs = axes->GetXaxis()->GetLabelOffset();
388  int font = axes->GetXaxis()->GetLabelFont();
389 
390  axes->GetXaxis()->SetLabelSize(0);
391  axes->GetXaxis()->SetTitle("Reconstructed Neutrino Energy (GeV)");
392  axes->SetTitle("");
394 
395  for(TGaxis* ax: {gax1, gax2, gax3, gax4}){
396  ax->SetTickLength(0);
397  ax->SetLabelSize(size);
398  ax->SetLabelOffset(offs);
399  ax->SetLabelFont(font);
400  ax->Draw();
401  }
402  gPad->RedrawAxis();
403 }
void CenterTitles(TH1 *h)
Double_t ymin
Definition: plot.C:24
void FourBinDivisions ( )

Definition at line 335 of file draw_plots_util.h.

References submit_hadd::l, and registry_explorer::v.

Referenced by NuePID4bin().

335  {
336  // Separators between the different PID ranges
337  // TGraph not TLine because TGraph is properly clipped by frame
338 
339  for (int v:{9,18,27}){
340  TGraph* l = new TGraph;
341  l->SetPoint(0, v, 0);
342  l->SetPoint(1, v, 50000);
343  l->SetLineWidth(1);
344  l->SetLineStyle(3);
345  l->SetLineColor(kGray+3);
346  l->DrawClone("l same");
347  delete l;
348  }
349 }
void FourBinLabels ( double  yNDC = 0.98,
double  textsize = 0.028 
)

Definition at line 352 of file draw_plots_util.h.

References MECModelEnuComparisons::i, moon_position_table_new3::second, y1, and submit_syst::y2.

Referenced by NuePID4bin().

352  {
353  // Put the labels near the top of the plot
354  gPad->Update();
355  const double y1 = gPad->GetUymax() * (yNDC - 0.1);
356  const double y2 = gPad->GetUymax() * yNDC;
357 
358  std::vector < std::pair <TString, TString> > binlabels = {
359  {"Core","0.75 - 0.87"},
360  {"Core","0.87 - 0.95"},
361  {"Core","0.95 - 1"},
362  {"Peripheral","0.95 - 1"}
363  };
364 
365  for(int i = 0; i < 4; ++i){
366  auto ltx = new TPaveText(i * 9, y1, (i+1)*9, y2, "NB");
367  ltx->SetFillStyle(0);
368  ltx->SetLineColorAlpha(kWhite,0);
369  ltx->AddText(binlabels[i].first);
370  ltx->AddText(binlabels[i].second);
371  ltx->SetTextSize(textsize);
372  ltx->SetTextColor(kGray+3);
373  ltx->SetTextAlign(23);
374  ltx->Draw();
375  }
376 }
Float_t y1[n_points_granero]
Definition: compare.C:5
osc::IOscCalc* GetCalculator ( bool  usingdumb)

Definition at line 46 of file draw_plots_util.h.

References calc, osc::OscCalcDumb::Copy(), osc::_IOscCalc< T >::Copy(), ana::DefaultOscCalc(), dmsq32, ana::kFitDeltaInPiUnits, ana::kFitDmSq32, ana::kFitSinSqTheta23, ana::FitVarWithPrior::SetValue(), ana::ConstrainedFitVarWithPrior::SetValue(), ana::FitDmSq32::SetValue(), and ssth23.

Referenced by ana::CompareNDDataMCFromVector(), ana::CompareOneShiftPred(), ana::CompareTwoShiftPred(), and plot_prediction_systs().

46  {
47  double dCP_Pi = 1.48;
48  double ssth23 = 0.404;
49  double dmsq32 = 2.67e-3;
50 
52  if(usingdumb){
53  osc::OscCalcDumb dumb;
54  calc = dumb.Copy();
55  }
56  else{
57  auto calc2 = DefaultOscCalc();
58  kFitDeltaInPiUnits.SetValue(calc2, dCP_Pi);
59  kFitSinSqTheta23.SetValue(calc2, ssth23);
60  kFitDmSq32.SetValue(calc2, dmsq32);
61  calc = calc2->Copy();
62  }
63  return calc;
64 }
double ssth23
const FitDmSq32 kFitDmSq32
Definition: FitVars.cxx:18
void SetValue(osc::IOscCalcAdjustable *osc, double val) const override
Definition: FitVars.cxx:177
General interface to oscillation calculators.
Definition: StanTypedefs.h:22
void SetValue(osc::IOscCalcAdjustable *osc, double val) const override
Forward to wrapped Var&#39;s SetValue()
osc::OscCalcDumb calc
osc::IOscCalcAdjustable * DefaultOscCalc()
Create a new calculator with default assumptions for all parameters.
Definition: Calcs.cxx:49
void SetValue(osc::IOscCalcAdjustable *osc, double val) const override
Simple oscillation probability calculator that has no solar term or mass hierarchy or delta so it&#39;s s...
Definition: OscCalcDumb.h:16
virtual _IOscCalc * Copy() const =0
double dmsq32
const ConstrainedFitVarWithPrior fitSsqTh23_UniformPriorSsqTh23 & kFitSinSqTheta23
const FitVarWithPrior fitDeltaInPiUnits_UniformPriordCP & kFitDeltaInPiUnits
virtual IOscCalc * Copy() const override
Definition: OscCalcDumb.h:19
TH1* HistNumuOpt ( TH1 *  orig)

Definition at line 120 of file draw_plots_util.h.

References runNovaSAM::ret, and ana::UniqueName().

Referenced by ana::CompareNDDataMCFromVector(), ana::CompareNDDataOneMC(), ana::CompareNDDataTwoMC(), ana::CompareOneShiftPred(), ana::CompareTwoShiftPred(), ana::GetNDComponents(), and ana::GetNDDecompsFromDecomp().

120  {
121  auto ret = (TH1*) orig->Clone(UniqueName().c_str());
122  ret->Scale(0.1,"width");
123  ret->GetYaxis()->SetTitle("Events / 0.1 GeV");
124  ret->SetBit(kCanDelete);
125  ret->SetDirectory(gROOT);
126  return ret;
127 }
std::string UniqueName()
Return a different string each time, for creating histograms.
Definition: Utilities.cxx:29
void HTag ( TString  hie)

Definition at line 145 of file draw_plots_util.h.

References kOrange, and PrettyTag().

Referenced by PlotDataMC().

145 { PrettyTag (hie, (hie=="NH")?kAzure+3:kOrange+2, .18, .825);}
enum BeamMode kOrange
void PrettyTag(TString pid, int color, double xndc, double yndc)
void NuePID3bin ( TH1 *  h,
TString  pidtag,
bool  binlabels = true 
)

Definition at line 460 of file draw_plots_util.h.

References PID2DAxis(), PIDBinLabels(), PIDDivisions(), and string.

Referenced by PlotMCComponentsComparison(), PlotMCComponentsErrorBand(), PlotNDDataTotalMCComparison(), and RatioPlot().

461 {
462  PIDDivisions();
463  if(binlabels) PIDBinLabels((std::string)pidtag);
464  if(h) PID2DAxis(h);
465 }
void PIDBinLabels(std::string pid="CVN", bool shortaxis=false, double yNDC=0.955, double textsize=0.028)
void PIDDivisions(bool shortaxis=false)
void PID2DAxis(TH1 *axes, bool third=false, bool shortaxis=false)
enum BeamMode string
void NuePID4bin ( TH1 *  h,
TString  pidtag,
bool  binlabels = true 
)

Definition at line 453 of file draw_plots_util.h.

References FourBinAxis(), FourBinDivisions(), and FourBinLabels().

Referenced by PlotMCComponentsComparison(), PlotMCComponentsErrorBand(), PlotNDDataTotalMCComparison(), and RatioPlot().

454 {
456  if(binlabels) FourBinLabels();
457  if(h) FourBinAxis(h);
458 }
void FourBinDivisions()
void FourBinLabels(double yNDC=0.98, double textsize=0.028)
void FourBinAxis(TH1 *axes, bool third=false, bool shortaxis=false)
void PID2DAxis ( TH1 *  axes,
bool  third = false,
bool  shortaxis = false 
)

Definition at line 407 of file draw_plots_util.h.

References visualisationForPaperMasterPlot::ax, CenterTitles(), gen_hdf5record::size, and ymin.

Referenced by NuePID3bin().

408 {
409  double ymin = axes->GetMinimum();
410  TGaxis* gax1 = new TGaxis(0, ymin, 8, ymin, 0, 4, 4, "");
411  TGaxis* gax2 = new TGaxis(10, ymin, 18, ymin, 0, 4, 4, "");
412  TGaxis* gax3 = new TGaxis(20, ymin, 30, ymin, 0, 5, 5, "");
413 
414  float size = axes->GetXaxis()->GetLabelSize();
415  float offs = axes->GetXaxis()->GetLabelOffset();
416  int font = axes->GetXaxis()->GetLabelFont();
417  float tick = axes->GetXaxis()->GetTickLength();
418 
419  axes->GetXaxis()->SetLabelSize(0);
420  axes->GetXaxis()->SetNdivisions(3000);
421  axes->GetXaxis()->SetTitle("Reconstructed Neutrino Energy (GeV)");
422  axes->GetYaxis()->SetTitleOffset(0.8);
423  axes->SetTitle("");
425 
426  if (shortaxis ){
427  axes->GetXaxis()->SetNdivisions(1800);
428  axes->GetYaxis()->SetTitle("Events / 0.5 GeV Bin");
429  gax1 = new TGaxis(1, ymin, 5, ymin, 1, 3, 3, "");
430  gax2 = new TGaxis(7, ymin, 11, ymin, 1, 3, 3, "");
431  gax3 = new TGaxis(13, ymin, 17, ymin, 1, 3, 3, "");
432  }
433  if ( third ){
434  gax1->SetTickSize(tick);
435  gax1->SetLabelSize(size);
436  gax1->SetLabelOffset(offs);
437  gax1->SetLabelFont(font);
438  gax1->Draw();
439  }
440  else
441  for(TGaxis* ax: {gax1, gax2, gax3}){
442  // Copy settings from pre-existing axis
443  gax1->SetTickSize(tick);
444  ax->SetLabelSize(size-0.001);
445  ax->SetLabelOffset(offs);
446  ax->SetLabelFont(font);
447  ax->Draw();
448  }
449  gPad->RedrawAxis();
450 }
void CenterTitles(TH1 *h)
Double_t ymin
Definition: plot.C:24
void PIDBinLabels ( std::string  pid = "CVN",
bool  shortaxis = false,
double  yNDC = 0.955,
double  textsize = 0.028 
)

Definition at line 308 of file draw_plots_util.h.

References ana::assert(), bins, ana::Binning::Edges(), genie::utils::style::Format(), MECModelEnuComparisons::i, ana::kCVNNLBinning, and submit_syst::y.

Referenced by NuePID3bin().

309  {
310  // Put the labels near the top of the plot
311  // pid not doing anything
312  // if short axis recommended 0.94 0.04
313  gPad->Update();
314  const double y = gPad->GetUymax() * yNDC;
315 
317  assert(bins);
318 
319  int v1 = (shortaxis) ? 3 : 5;
320  int v2 = (shortaxis) ? 6 : 10;
321 
322  for(int i = 0; i < 3; ++i){
323  TLatex* ltx = new TLatex(v1+v2*i, y,
324  TString::Format("%g < CVN < %g",
325  bins->Edges()[i],
326  bins->Edges()[i+1]));
327  ltx->SetTextSize(textsize);
328  ltx->SetTextColor(kGray+3);
329  ltx->SetTextAlign(22);
330  ltx->Draw();
331  }
332 }
Represent the binning of a Spectrum&#39;s x-axis.
Definition: Binning.h:16
const Binning kCVNNLBinning
Definition: Binnings.cxx:20
const Binning bins
const std::vector< double > & Edges() const
Definition: Binning.h:34
assert(nhit_max >=nhit_nbins)
void Format(TGraph *gr, int lcol, int lsty, int lwid, int mcol, int msty, double msiz)
Definition: Style.cxx:154
void PIDDivisions ( bool  shortaxis = false)

Definition at line 289 of file draw_plots_util.h.

References submit_hadd::l, and central_limit::l1.

Referenced by NuePID3bin().

289  {
290  // Separators between the different PID ranges
291  // TGraph not TLine because TGraph is properly clipped by frame
292  int v1 = (shortaxis? 6:10);
293  int v2 = (shortaxis? 12:20);
294  TGraph* l1 = new TGraph;
295  l1->SetPoint(0, v1, 0);
296  l1->SetPoint(1, v1, 50000);
297  TGraph* l2 = new TGraph;
298  l2->SetPoint(0, v2, 0);
299  l2->SetPoint(1, v2, 50000);
300  for(TGraph* l: {l1, l2}){
301  l->SetLineWidth(1);
302  l->SetLineColor(kGray+3);
303  l->Draw("l same");
304  }
305 }
void PIDTag ( TString  pid)

Definition at line 144 of file draw_plots_util.h.

References PrettyTag().

Referenced by PlotMCComponentsComparison(), PlotMCComponentsErrorBand(), and PlotNDDataTotalMCComparison().

144 { PrettyTag (pid, kAzure+3, .83, .92); }
void PrettyTag(TString pid, int color, double xndc, double yndc)
void PlotDataMC ( std::vector< TH1 * >  vnom,
std::vector< bool >  isdata,
TLegend *  leg,
TString  pidtag = "",
TString  htag = "",
TString  out_name = "plot_FD",
bool  ratioplot = false,
bool  ratioerrors = false,
AxisType  pidaxis = kNue1bin 
)

Definition at line 625 of file draw_plots_util.h.

References bin, demo5::c2, FixLegend(), genie::utils::style::Format(), ana::GraphWithPoissonErrors(), HTag(), kNue3bin, submit_concat_project::out_name, PrettyRatio(), PrettyTag(), PrintCanvasAll(), ana::PrintLatexFigure(), RatioPlot(), and registry_explorer::v.

629 {
630  gStyle->SetPadLeftMargin(0.15);
631  gStyle->SetPadTopMargin(0.08);
632 
633  // Fill empty bins with 0 if in range and <0 if out of range
634  for ( int bin = 1; bin<=vnom[0]->GetNbinsX(); ++bin){
635  bool filledbin=false;
636  for ( unsigned int v = 0; v<vnom.size(); ++v){
637  if ( !isdata[v] )
638  if (vnom[v]->GetBinContent(bin) > 0 ) filledbin=true;
639  }
640  for ( uint v = 0; v<vnom.size(); ++v){
641  if (vnom[v]->GetBinContent(bin) == 0 ){
642  if ( !filledbin ) vnom[v]->SetBinContent(bin,-0.01);
643  else vnom[v]->SetBinContent(bin,0.001);
644  }
645  vnom[v]->GetYaxis()->SetTitleOffset(1.05);
646  }
647  }
648 
649  // Draw marker w/error or line when appropriate
650  int datahist=-1;
651  for ( unsigned int v = 0; v<vnom.size(); ++v)
652  if (vnom[v]->GetLineColor() == kBlack ) datahist=v;
653 
654  // Option to make a ratio plot given
655  if(!ratioplot){
656  auto c2 = new TCanvas ("c2","c2",715,500);
657  for ( unsigned int v = 0; v<vnom.size(); ++v){
658  TGraphAsymmErrors* gr = GraphWithPoissonErrors(vnom[v], 0, 1);
659  if ( isdata[v] ){
660  if (v == datahist ) gr->Draw("ep same");
661  else vnom[v]->Draw("p same");
662  }
663  else vnom[v]->Draw("hist same");
664  }
665  gPad->RedrawAxis();
666 
667  // Adjust for ExPID axis
668  if(pidaxis==kNue3bin) {
669  FixLegend(leg,"ExPID");
670  NuePlotStyle style(pidtag,0);
671  style.PIDDivisions(true);
672  style.PID2DAxis(vnom[0],true);
673  style.PIDBinLabels(true);
674  }
675 
676  // pot label
677  PrettyTag(TString::Format("%g#times10^{20} POT equiv.", 8.85).Data(),
678  kBlack, .175, .74);
679  HTag(htag);
680  leg->Draw("same");
681 
682  gPad->SetFillStyle(0);
683  c2->SetFillStyle(0);
684  PrintCanvasAll (c2,out_name+"_datamc","plots/",{"pdf","eps","png","C","root"});
685  PrintLatexFigure(out_name+"_datamc");
686  //removed: prelim tag
687  }
688  else{
689  std::vector<TH1*> vratio;
690  for(unsigned int ii=1;ii<vnom.size();ii++){
691  auto htemp = PrettyRatio (vnom[datahist], vnom[ii], vnom[ii]->GetLineColor(), 1.,
692  "Data / MC");
693  htemp->GetYaxis()->SetRangeUser(0.5,1.5);
694  vratio.push_back(htemp);
695  }
696  std::vector<TString> topOption = {" ","hist"};
697  std::vector<TString> bottomOption (vratio.size(),ratioerrors ?"p":"hist p");
698  auto cratio2= RatioPlot(vnom, topOption,vratio,bottomOption,pidtag,pidaxis);
699  cratio2->cd();
700  leg->Draw("same");
701  HTag(pidtag);
702  PrintCanvasAll(cratio2,out_name+"_datamc_ratio");
703  PrintLatexFigure("/png_"+out_name+"_datamc_ratio");
704  }
705 }
TGraphAsymmErrors * GraphWithPoissonErrors(const TH1 *h, bool noErrorsXaxis, bool drawEmptyBins)
Calculate statistical errors appropriate for small Poisson numbers.
Definition: Plots.cxx:912
void PrettyTag(TString pid, int color, double xndc, double yndc)
c2
Definition: demo5.py:33
void HTag(TString hie)
float bin[41]
Definition: plottest35.C:14
void PrintLatexFigure(TString name, TString plotdir="plots/")
TH1 * PrettyRatio(TH1 *shi, TH1 *nom, int color, double alpha=1., TString titley="Shift / Nom")
void Format(TGraph *gr, int lcol, int lsty, int lwid, int mcol, int msty, double msiz)
Definition: Style.cxx:154
TCanvas * RatioPlot(std::vector< TH1 * > topHistos, std::vector< TString > topOption, std::vector< TH1 * > bottomHistos, std::vector< TString > bottomOption, TString pidtag, AxisType pidaxis=kNue1bin)
void FixLegend(TLegend *leg, TString opt="default")
void PrintCanvasAll(TCanvas *c, const TString outname, const TString outdir="plots/", const std::vector< TString > exts={"pdf","png","root"})
unsigned int uint
void PlotMCComponentsComparison ( std::vector< TH1 * >  vnom,
std::vector< TH1 * >  vshi,
TLegend *  leg,
TString  pidtag = "",
TString  out_name = "plot_nd",
bool  ratioplot = false,
bool  ratioerrors = false,
AxisType  pidaxis = kNue1bin 
)

Definition at line 764 of file draw_plots_util.h.

References demo5::c2, ExPIDPlot(), FixLegend(), kNue3bin, kNue4bin, NuePID3bin(), NuePID4bin(), submit_concat_project::out_name, PIDTag(), PrettyRatio(), PrintCanvasAll(), ana::PrintLatexFigure(), RatioPlot(), ana::UniqueName(), and registry_explorer::v.

768 {
769  if(pidaxis==kNue3bin) FixLegend(leg,"ExPID");
770  if(pidaxis==kNue4bin) FixLegend(leg,"4bins");
771 
772  if(!ratioplot){
773  auto c2 = new TCanvas (UniqueName().c_str(),"c2");
774  for(auto const & v:vnom) v->Draw("hist same");
775  for(auto const & v:vshi) v->Draw("hist same");
776  if(pidaxis==kNue3bin) NuePID3bin (vnom[0],pidtag,true);
777  if(pidaxis==kNue4bin) NuePID4bin (vnom[0],pidtag,true);
778  PIDTag(pidtag);
779  leg->Draw("same");
780  PrintCanvasAll(c2, out_name+"_mccomp");
781  PrintLatexFigure("/png_"+out_name+"_mccomp");
782  c2->Close();
783  }
784  else{
785  std::vector<TH1*> vratio;
786  for(unsigned int ii=0;ii<vshi.size();ii++){
787  auto htemp = PrettyRatio (vshi[ii],vnom[ii], vnom[ii]->GetLineColor(), ii>0?0.4:1.);
788  htemp->GetYaxis()->SetRangeUser(0.5,1.5);
789  vratio.push_back (htemp);
790  }
791  vnom.insert(vnom.end(),vshi.begin(),vshi.end());
792  std::vector<TString> topOption (vnom.size(),"hist");
793  std::vector<TString> bottomOption (vratio.size(),ratioerrors ?"p":"hist p");
794  auto cratio2= RatioPlot(vnom, topOption,vratio,bottomOption,pidtag,pidaxis);
795  cratio2->cd();
796  leg->Draw("same");
797  PIDTag(pidtag);
798  PrintCanvasAll(cratio2, out_name+"_mccomp_ratio");
799  PrintLatexFigure("/png_"+out_name+"_mccomp_ratio");
800  }
801  if(pidaxis==kNue3bin) {
802  vnom.insert(vnom.end(),vshi.begin(),vshi.end());
803  std::vector<TString> topOption (vnom.size(),"hist");
804  auto cpads =ExPIDPlot(vnom,topOption);
805  cpads->cd();
806  FixLegend(leg,"ExPIDPads");
807  leg->Draw("same");
808  PIDTag(pidtag);
809  PrintCanvasAll(cpads, out_name+"_mccomp_pads");
810  // PrintLatexFigure("/png_"+out_name+"_mccomp_pads");
811  }
812 }
c2
Definition: demo5.py:33
void PIDTag(TString pid)
void NuePID3bin(TH1 *h, TString pidtag, bool binlabels=true)
void PrintLatexFigure(TString name, TString plotdir="plots/")
TH1 * PrettyRatio(TH1 *shi, TH1 *nom, int color, double alpha=1., TString titley="Shift / Nom")
TCanvas * ExPIDPlot(std::vector< TH1 * > topHistos, std::vector< TString > topOption)
std::string UniqueName()
Return a different string each time, for creating histograms.
Definition: Utilities.cxx:29
TCanvas * RatioPlot(std::vector< TH1 * > topHistos, std::vector< TString > topOption, std::vector< TH1 * > bottomHistos, std::vector< TString > bottomOption, TString pidtag, AxisType pidaxis=kNue1bin)
void FixLegend(TLegend *leg, TString opt="default")
void PrintCanvasAll(TCanvas *c, const TString outname, const TString outdir="plots/", const std::vector< TString > exts={"pdf","png","root"})
void NuePID4bin(TH1 *h, TString pidtag, bool binlabels=true)
void PlotMCComponentsErrorBand ( std::vector< TH1 * >  vnom,
std::vector< TH1 * >  vshi,
TLegend *  leg,
TString  pidtag = "",
TString  out_name = "plot_nd",
bool  ratioplot = false,
bool  ratioerrors = false,
AxisType  pidaxis = kNue1bin 
)

Definition at line 816 of file draw_plots_util.h.

References demo5::c2, plot_validation_datamc::Clone(), FixLegend(), FormatErrorBand(), make_mec_shifts_plots::GetMaximum(), kNue3bin, kNue4bin, NuePID3bin(), NuePID4bin(), submit_concat_project::out_name, PIDTag(), PrettyRatio(), PrintCanvasAll(), ana::PrintLatexFigure(), RatioPlot(), and registry_explorer::v.

820 {
821  auto hplu_plot = (TH1*) vshi[0]->Clone();
822  auto hmin_plot = (TH1*) vshi[1]->Clone();
823  FormatErrorBand(hplu_plot,hmin_plot,out_name.Contains("_sig"),true);
824  std::vector<TH1*>vshi_plot={hplu_plot,hmin_plot};
825 
826  if(pidaxis==kNue3bin) FixLegend(leg,"ExPID");
827  if(pidaxis==kNue4bin) FixLegend(leg,"4bins");
828 
829  if(!ratioplot){
830  auto c2 = new TCanvas ("c2","c2");
831  vnom[0]->SetMaximum(1.2*vnom[0]->GetMaximum());
832  vnom[0]->Draw("hist");
833  for(auto v:vshi_plot) v->Draw("hist same");
834  for(auto v:vnom) v->Draw("hist same");
835  if(pidaxis==kNue3bin) NuePID3bin (vnom[0],pidtag,true);
836  if(pidaxis==kNue4bin) NuePID4bin (vnom[0],pidtag,true);
837  PIDTag(pidtag);
838  leg->Draw("same");
839  PrintCanvasAll(c2, out_name+"_mccomp");
840  PrintLatexFigure("/png_"+out_name+"_mccomp");
841  c2->Close();
842  }
843  else{
844  std::vector<TH1*> vratio;
845  for(unsigned int ii=0;ii<vshi.size();ii++){
846  auto htemp = PrettyRatio(vshi[ii],vnom[0],vshi[ii]->GetMarkerColor());
847  vratio.push_back(htemp);
848  }
849  vratio[0]->GetYaxis()->SetRangeUser(0.5,1.5);
850  vnom.insert(vnom.begin()+1,vshi_plot.begin(),vshi_plot.end());
851  std::vector<TString> topOption (vnom.size(),"hist");
852  std::vector<TString> bottomOption (vratio.size(),ratioerrors ?"p":"hist p");
853  auto cratio2= RatioPlot(vnom, topOption,vratio,bottomOption,pidtag,pidaxis);
854  cratio2->cd();
855  leg->Draw("same");
856  PIDTag(pidtag);
857  PrintCanvasAll(cratio2, out_name+"_mccomp_ratio");
858  PrintLatexFigure("/png_"+out_name+"_mccomp_ratio");
859  }
860 }
c2
Definition: demo5.py:33
void PIDTag(TString pid)
void FormatErrorBand(TH1 *hplus, TH1 *hminus, bool signal=false, bool fixbins=false)
void NuePID3bin(TH1 *h, TString pidtag, bool binlabels=true)
void PrintLatexFigure(TString name, TString plotdir="plots/")
TH1 * PrettyRatio(TH1 *shi, TH1 *nom, int color, double alpha=1., TString titley="Shift / Nom")
TCanvas * RatioPlot(std::vector< TH1 * > topHistos, std::vector< TString > topOption, std::vector< TH1 * > bottomHistos, std::vector< TString > bottomOption, TString pidtag, AxisType pidaxis=kNue1bin)
void FixLegend(TLegend *leg, TString opt="default")
void PrintCanvasAll(TCanvas *c, const TString outname, const TString outdir="plots/", const std::vector< TString > exts={"pdf","png","root"})
void NuePID4bin(TH1 *h, TString pidtag, bool binlabels=true)
void PlotNDDataTotalMCComparison ( TH1 *  hdata,
std::vector< TH1 * >  htots,
TLegend *  leg,
TString  pidtag = "",
TString  out_name = "plot_nd",
bool  ratioplot = false,
AxisType  pidaxis = kNue1bin 
)

Definition at line 709 of file draw_plots_util.h.

References demo5::c1, ExPIDPlot(), FixLegend(), make_mec_shifts_plots::GetMaximum(), make_syst_table_plots::h, kNue3bin, kNue4bin, NuePID3bin(), NuePID4bin(), submit_concat_project::out_name, PIDTag(), PrettyRatio(), PrintCanvasAll(), ana::PrintLatexFigure(), PandAna.reco_validation.prod5_pid_validation::ratio(), and RatioPlot().

713 {
714  if(pidaxis==kNue3bin) FixLegend(leg,"ExPID");
715  if(pidaxis==kNue4bin) FixLegend(leg,"4bins");
716  std::vector<TString> h_opt;
717  for(auto const & h:htots) h_opt.push_back("hist");
718  h_opt.push_back("p");
719 
720  if(!ratioplot){
721  auto c1 = new TCanvas ("c1","c1");
722  htots[0]->SetMaximum(1.3*htots[0]->GetMaximum());
723  for(auto const & h:htots) h->Draw("hist same");
724  htots[0]->Draw("hist same"); //need to redraw for error bands
725  hdata->Draw("p same");
726  PIDTag(pidtag);
727  if(pidaxis==kNue3bin) NuePID3bin (htots[0],pidtag,true);
728  if(pidaxis==kNue4bin) NuePID4bin (htots[0],pidtag,true);
729  leg->Draw("same");
730  PrintCanvasAll(c1, out_name+"_datamc");
731  PrintLatexFigure("/png_"+out_name+"_datamc");
732  }
733  else{
734  std::vector<TH1*> ratios;
735  std::vector<TString> r_opt;
736  for(auto const & h:htots){
737  auto ratio = PrettyRatio(hdata,h, h->GetLineColor(), 1., "Data / MC");
738  ratio->GetYaxis()->SetRangeUser(0.5,1.5);
739  ratios.push_back(ratio);
740  r_opt.push_back("e1");
741  }
742  htots.push_back(hdata);
743  auto cratio1 = RatioPlot(htots,h_opt,ratios,r_opt,pidtag,pidaxis);
744  cratio1->cd();
745  leg->Draw("same");
746  PIDTag(pidtag);
747 
748  PrintCanvasAll(cratio1,out_name+"_datamc_ratio");
749  PrintLatexFigure("/png_"+out_name+"_datamc_ratio");
750  }
751  if(pidaxis==kNue3bin) {
752  htots.push_back(hdata);
753  auto cpads =ExPIDPlot(htots,h_opt);
754  cpads->cd();
755  FixLegend(leg,"ExPIDPads");
756  leg->Draw("same");
757  PIDTag(pidtag);
758 
759  PrintCanvasAll(cpads, out_name+"_datamc_pads");
760  // PrintLatexFigure("/png_"+out_name+"_datamc_pads");
761  }
762 }
def ratio(spec1, spec2, nbins, pot, binrange=(0, 1))
void PIDTag(TString pid)
void NuePID3bin(TH1 *h, TString pidtag, bool binlabels=true)
void PrintLatexFigure(TString name, TString plotdir="plots/")
TH1 * PrettyRatio(TH1 *shi, TH1 *nom, int color, double alpha=1., TString titley="Shift / Nom")
TCanvas * ExPIDPlot(std::vector< TH1 * > topHistos, std::vector< TString > topOption)
c1
Definition: demo5.py:24
TCanvas * RatioPlot(std::vector< TH1 * > topHistos, std::vector< TString > topOption, std::vector< TH1 * > bottomHistos, std::vector< TString > bottomOption, TString pidtag, AxisType pidaxis=kNue1bin)
void FixLegend(TLegend *leg, TString opt="default")
void PrintCanvasAll(TCanvas *c, const TString outname, const TString outdir="plots/", const std::vector< TString > exts={"pdf","png","root"})
void NuePID4bin(TH1 *h, TString pidtag, bool binlabels=true)
TH1* PrettyRatio ( TH1 *  shi,
TH1 *  nom,
int  color,
double  alpha = 1.,
TString  titley = "Shift / Nom" 
)

Definition at line 71 of file draw_plots_util.h.

References ana::UniqueName().

Referenced by PlotDataMC(), PlotMCComponentsComparison(), PlotMCComponentsErrorBand(), and PlotNDDataTotalMCComparison().

71  {
72  auto htemp = (TH1*) nom->Clone(ana::UniqueName().c_str());
73  htemp->Divide(shi,nom);
74  htemp->SetMarkerColorAlpha(color,alpha);
75  htemp->SetLineColorAlpha(color,alpha);
76  htemp->SetMarkerStyle(34);
77  htemp->SetMarkerSize(1.4);
78  htemp->GetYaxis()->SetTitle(titley);
79  return htemp;
80 }
std::string UniqueName()
Return a different string each time, for creating histograms.
Definition: Utilities.cxx:29
void PrettyTag ( TString  pid,
int  color,
double  xndc,
double  yndc 
)

Definition at line 133 of file draw_plots_util.h.

References getGoodRuns4SAM::tag.

Referenced by HTag(), PIDTag(), and PlotDataMC().

133  {
134  TLatex* tag = new TLatex(xndc, yndc, pid);
135  tag->SetTextColor(color);
136  tag->SetNDC();
137  tag->SetTextSize(0.04);
138  tag->SetTextFont(42);
139  tag->SetTextAlign(22);
140  tag->Draw();
141  tag->SetBit(kCanDelete);
142 }
void PrintCanvasAll ( TCanvas *  c,
const TString  outname,
const TString  outdir = "plots/",
const std::vector< TString >  exts = {"pdf","png","root"} 
)

Definition at line 245 of file draw_plots_util.h.

References plot_validation_datamc::c, galleryMaker::ext, and outdir.

Referenced by PlotDataMC(), PlotMCComponentsComparison(), PlotMCComponentsErrorBand(), and PlotNDDataTotalMCComparison().

246  {"pdf","png","root"} )
247 {
248  for(auto const & ext:exts){
249  gSystem -> MakeDirectory( outdir );
250  gSystem -> MakeDirectory( outdir+"rootfiles/" );
251  if(ext=="png") c->SaveAs(outdir+"png_"+outname + "." + ext);
252  else if(ext=="root") c->SaveAs(outdir+"rootfiles/"+outname + "." + ext);
253  else c->SaveAs(outdir+outname + "." + ext);
254  }
255  delete c;
256 }
const std::string outdir
TCanvas* RatioPlot ( std::vector< TH1 * >  topHistos,
std::vector< TString >  topOption,
std::vector< TH1 * >  bottomHistos,
std::vector< TString >  bottomOption,
TString  pidtag,
AxisType  pidaxis = kNue1bin 
)

Definition at line 531 of file draw_plots_util.h.

References plot_validation_datamc::c, plot_validation_datamc::Clone(), FindLimitY(), make_syst_table_plots::h, h1, h3, kNue3bin, kNue4bin, cet::sqlite::max(), NuePID3bin(), NuePID4bin(), plot_validation_datamc::p1, and plot_validation_datamc::p2.

Referenced by draw_fn_coverage(), PlotDataMC(), PlotMCComponentsComparison(), PlotMCComponentsErrorBand(), and PlotNDDataTotalMCComparison().

537 {
538  gStyle->SetTitleStyle(0);
539  TCanvas *c = new TCanvas("c", "canvas", 600, 700);
540  if(pidaxis == kNue3bin) c->SetCanvasSize(750,650);
541  //define top and bottom pads
542  TPad* p1 = new TPad("", "", 0, 0, 1, 1);
543  TPad* p2 = new TPad("", "", 0, 0, 1, 1);
544  p1->SetBottomMargin(.3);
545  p2->SetTopMargin(.7);
546 
547  for(auto p:{p1,p2}){
548  p->SetFillStyle(0);
549  p->Draw();
550  }
551 
552  // format histograms
553  auto h1 = (TH1*) topHistos[0]->Clone();
554  auto h3 = (TH1*) bottomHistos[0]->Clone();
555 
556  for(auto & h:{h1,h3}){
557  h->SetStats(0);
558 
559  h->GetYaxis()->SetTitleSize(26);
560  h->GetYaxis()->SetTitleFont(43);
561  h->GetYaxis()->SetTitleOffset(1.3);
562  h->GetYaxis()->SetLabelFont(43);
563 
564  h->GetXaxis()->SetTitleOffset(1.2);
565  h->GetXaxis()->SetTitleSize(28);
566  h->GetXaxis()->SetTitleFont(43);
567  h->GetXaxis()->SetLabelFont(43);
568  if(pidaxis==kNue4bin) h->GetXaxis()->SetNdivisions(904,kFALSE);
569  }
570 
571  h1->GetYaxis()->SetRangeUser(FindLimitY(topHistos,0), 1.2*FindLimitY(topHistos,1));
572  h1->GetYaxis()->SetLabelSize(18);
573 
574  h1->GetXaxis()->SetLabelSize(0);
575  h1->GetXaxis()->SetTitleSize(0);
576 
577  h3->SetTitle("");
578  h3->GetYaxis()->SetRangeUser(max(0.,2-FindLimitY(bottomHistos,1)),
579  1.01*FindLimitY(bottomHistos,1));
580  h3->GetYaxis()->SetLabelSize(15);
581  h3->GetYaxis()->SetDecimals();
582 
583  h3->GetXaxis()->SetTitle(h1->GetXaxis()->GetTitle());
584  h3->GetXaxis()->SetLabelSize(18);
585  h3->GetXaxis()->SetLabelOffset(0.005);
586 
587  p1->cd();
588 
589  h1->Draw(topOption[0]);
590 
591  for(unsigned int ii = 1; ii < topHistos.size(); ++ii) {
592  topHistos[ii]->Draw("same "+topOption[ii]);}
593  h1->Draw("same "+topOption[0]);
594 
595  p1->RedrawAxis(); //white histograms cover axes
596 
597  if(pidaxis==kNue3bin) NuePID3bin(0,pidtag);
598  if(pidaxis==kNue4bin) NuePID4bin(0,pidtag);
599 
600  p2->cd();
601  h3->Draw(bottomOption[0]);
602  for(unsigned int ii = 1; ii < bottomHistos.size(); ++ii){
603  bottomHistos[ii]->Draw("same " + bottomOption[ii]);}
604  h3->Draw("same " + bottomOption[0]);
605 
606  auto lone = new TLine();
607  lone->SetLineStyle(3);
608  lone->SetLineColor(kGray+3);
609  p2->Update();
610  lone->DrawLine(p2->GetUxmin(),1.0,p2->GetUxmax(),1.0);
611  lone->DrawLine(p2->GetUxmin(),1.2,p2->GetUxmax(),1.2);
612  lone->DrawLine(p2->GetUxmin(),0.8,p2->GetUxmax(),0.8);
613  float p2Y = p2->GetUymax()-p2->GetUymin();
614  h3->GetYaxis()->SetRangeUser(p2->GetUymin()-(0.01*p2Y),p2->GetUymax()+(0.01*p2Y));
615  p2->RedrawAxis();
616  if(pidaxis==kNue3bin) NuePID3bin(h3,pidtag, false);
617  if(pidaxis==kNue4bin) NuePID4bin(h3,pidtag, false);
618 
619  return c;
620 }
TH1F * h3
Definition: berger.C:36
const char * p
Definition: xmltok.h:285
double FindLimitY(std::vector< TH1 * > histos, bool doMax=true)
void NuePID3bin(TH1 *h, TString pidtag, bool binlabels=true)
TH1F * h1
T max(sqlite3 *const db, std::string const &table_name, std::string const &column_name)
Definition: statistics.h:68
void NuePID4bin(TH1 *h, TString pidtag, bool binlabels=true)
TH1* RebinToShortAxis ( TH1 *  h)

Definition at line 263 of file draw_plots_util.h.

References it, runNovaSAM::ret, and ana::UniqueName().

264 {
265  TH1* ret = new TH1D(UniqueName().c_str(), h->GetTitle(),
266  18, 0, 18);
267  ret->GetXaxis()->SetTitle(h->GetXaxis()->GetTitle());
268  ret->GetYaxis()->SetTitle(h->GetYaxis()->GetTitle());
269 
270  std::vector<std::pair<int, int>> binMap = {{3, 2},
271  {4, 3},
272  {5, 4},
273  {6, 5}, // end of 1st spectrum
274  {13, 8},
275  {14, 9},
276  {15, 10},
277  {16, 11}, // end of 2nd
278  {23, 14},
279  {24, 15},
280  {25, 16},
281  {26, 17}};
282 
283  for(auto it: binMap) ret->SetBinContent(it.second, h->GetBinContent(it.first));
284 
285  return ret;
286 }
set< int >::iterator it
std::string UniqueName()
Return a different string each time, for creating histograms.
Definition: Utilities.cxx:29

Variable Documentation

const double kFDPOT = ana::kAna2017POT
static

Definition at line 38 of file draw_plots_util.h.

Referenced by ana::GetFDMCComponents(), and plot_NDvsFD_weights_FHC().

const double kLegendDefaultX1 = 0.63

Definition at line 151 of file draw_plots_util.h.

Referenced by FixLegend().

const double kLegendDefaultX2 = 0.85

Definition at line 152 of file draw_plots_util.h.

Referenced by FixLegend().

const double kLegendDefaultY1 = 0.68

Definition at line 153 of file draw_plots_util.h.

Referenced by FixLegend().

const double kLegendDefaultY2 = 0.88

Definition at line 154 of file draw_plots_util.h.

Referenced by FixLegend().

bool mergePeripheral =false
const bool printratioplots =true
bool usedumb = false