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/PredictionInterp.h"
#include "CAFAna/Prediction/PredictionExtrap.h"
#include "CAFAna/Prediction/PredictionNoExtrap.h"
#include "3FlavorAna/Prediction/PredictionExtendToPeripheral.h"
#include "3FlavorAna/Prediction/PredictionSystJoint2018.h"
#include "CAFAna/Vars/FitVars.h"
#include "CAFAna/Decomp/IDecomp.h"
#include "CAFAna/Extrap/IExtrap.h"
#include "CAFAna/Extrap/ModularExtrap.h"
#include "CAFAna/Extrap/ModularExtrapComponent.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 "TError.h"
#include <iostream>
#include <fstream>
#include <iomanip>
#include <cxxabi.h>
#include "tex_tables_util.h"

Go to the source code of this file.

Classes

struct  ana::DataMCComponents
 

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
}
 
enum  ana::EModExtrapComps {
  ana::kEEextrap, ana::kEEAntiextrap, ana::kMMextrap, ana::kMMAntiextrap,
  ana::kMEextrap, ana::kMEAntiextrap, ana::kEMextrap, ana::kEMAntiextrap,
  ana::kNCTotalextrap, ana::kNCextrap, ana::kNCAntiextrap, ana::kMTextrap,
  ana::kMTAntiextrap, ana::kETextrap, ana::kETAntiextrap, ana::kEEextrap,
  ana::kEEAntiextrap, ana::kMMextrap, ana::kMMAntiextrap, ana::kMEextrap,
  ana::kMEAntiextrap, ana::kEMextrap, ana::kEMAntiextrap, ana::kNCTotalextrap,
  ana::kNCextrap, ana::kNCAntiextrap, ana::kMTextrap, ana::kMTAntiextrap,
  ana::kETextrap, ana::kETAntiextrap, ana::kEEextrap, ana::kEEAntiextrap,
  ana::kMMextrap, ana::kMMAntiextrap, ana::kMEextrap, ana::kMEAntiextrap,
  ana::kEMextrap, ana::kEMAntiextrap, ana::kNCTotalextrap, ana::kNCextrap,
  ana::kNCAntiextrap, ana::kMTextrap, ana::kMTAntiextrap, ana::kETextrap,
  ana::kETAntiextrap
}
 

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 > titles, 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"})
 
void NuePID3bin (TH1 *h, bool coreOnlyND=false, bool binLabels=true, const double textSize=0.04, const int textColor=kGray+3, const int lineColor=kBlack, const int lineStyle=3, const double yNDC=0.96)
 
TCanvas * RatioPlot (std::vector< TH1 * > topHistos, std::vector< TString > topOption, std::vector< TH1 * > bottomHistos, std::vector< TString > bottomOption, TString pidtag, AxisType pidaxis=kNue1bin, const bool nearDet=false)
 
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 (DataMCComponents &comp, int linestyle=1)
 
const DataMCComponents ana::GetNDCompsFromDecomp (const IDecomp *decomp)
 
struct DataMCComponets ana::GetFDMCComponents (osc::IOscCalc *calc, IPrediction *pred_no, TString output_name="nue", int linestyle=1, bool bkgdetails=false)
 
void ana::CompareNDDataOneMC (DataMCComponents h_no, DataMCComponents h_sh, TString plottitle, TString out_name, TString pidtag, AxisType pidaxis, bool printtable=true)
 
void ana::CompareNDDataTwoMC (DataMCComponents hnom, DataMCComponents hplu, DataMCComponents hmin, TString plottitle, TString out_name, TString pidtag, AxisType pidaxis, bool printtable=true)
 
const IDecomp * ana::GetDecomp (IPrediction *prediction, EModExtrapComps modExtrapComp)
 
void ana::CompareNDDataMCFromVector (PredictionSystJoint2018 *predictionSyst, const ISyst *syst, EModExtrapComps modExtrapComp, TString plottitle, TString out_name, TString tag, AxisType pidaxis, bool printtable=true)
 
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 (PredictionSystJoint2018 *predictionSyst, const ISyst *syst, TString plottitle, TString out_name, bool printtable=true, AxisType pidaxis=kNue3bin)
 

Variables

static bool isFHC =true
 
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 51 of file draw_plots_util.h.

Function Documentation

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

Definition at line 173 of file draw_plots_util.h.

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

177 {
178  TLegend* leg = new TLegend(x1, y1, x2, y2);
179  leg->SetFillStyle(0);
180  for (unsigned int v = 0; v < h.size(); ++v)
181  leg->AddEntry(h[v], titles[v], option[v]);
182  leg->SetBit(kCanDelete);
183  return leg;
184 }
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 231 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.

235 {
236  TLegend* leg = new TLegend(x1,y1,x2,y2);
237  leg->SetFillStyle(0);
238  if(sig) leg->AddEntry( DummyGraph(kNueSignalColor), "#nu_{e} Signal","l");
239  if(data) leg->AddEntry( DummyGraph(), "ND Data","epl");
240  if(tot) leg->AddEntry( DummyGraph(kTotalMCColor), "Total Bkg","l");
241  leg->AddEntry( DummyGraph(kBeamNueBackgroundColor), "Beam #nu_{e}","l");
242  leg->AddEntry( DummyGraph(kNCBackgroundColor), "NC","l");
243  leg->AddEntry( DummyGraph(kNumuBackgroundColor), "#nu_{#mu} CC","l");
244  leg->SetBit(kCanDelete);
245  return leg;
246 
247 }
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 250 of file draw_plots_util.h.

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

254 {
255  TLegend* leg = new TLegend(x1,y1,x2,y2);
256  leg->SetFillStyle(0);
257  if(sig)
258  leg->AddEntry(DummyGraph(kNueSignalColor), "#nu_{#mu} Signal", "l");
259  if(data)
260  leg->AddEntry(DummyGraph(), "ND Data", "epl");
261  if(tot)
262  leg->AddEntry(DummyGraph(kTotalMCColor), "Total Bkg", "l");
263  if(isNumuAna)
264  leg->AddEntry(DummyGraph(kNumuBackgroundColor), "#nu_{#mu} app", "l");
265  else
266  leg->AddEntry(DummyGraph(kNumuBackgroundColor), "#nu_{#mu} CC", "l");
267  leg->AddEntry(DummyGraph(kNCBackgroundColor), "NC","l");
268  leg->AddEntry(DummyGraph(kBeamNueBackgroundColor), "#nu_{e} CC","l");
269  leg->AddEntry(DummyGraph(kNuTauBackgroundColor), "#nu_{#tau} CC","l");
270  leg->SetBit(kCanDelete);
271  return leg;
272 }
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 kNuTauBackgroundColor
Definition: Style.h:26
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 219 of file draw_plots_util.h.

References plot_validation_datamc_2018::color.

220 {
221  auto gr = new TGraph();
222  gr->SetLineColor(color);
223  gr->SetLineStyle(style);
224  gr->SetLineWidth(linewidth);
225  gr->SetMarkerStyle(markerstyle);
226  gr->SetMarkerColor(color);
227  return gr;
228 }
double FindLimitY ( std::vector< TH1 * >  histos,
bool  doMax = true 
)

Definition at line 96 of file draw_plots_util.h.

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

97 {
98  double max = histos[0]->GetMaximum();
99  double min = histos[0]->GetMinimum();
100 
101  for(unsigned int i=0; i<histos.size(); i++){
102  if ( histos[i]->GetMaximum() > max ) max = histos[i]->GetMaximum();
103  if ( histos[i]->GetMinimum() < min ) min = histos[i]->GetMinimum();
104  }
105 
106  if ( doMax ) return max;
107  else return min;
108 }
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 188 of file draw_plots_util.h.

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

189 {
190  leg->SetFillStyle(0);
191  if(opt=="default")
192  {
193  leg->SetX1(kLegendDefaultX1); leg->SetX2(kLegendDefaultX2);
194  leg->SetY1(kLegendDefaultY1); leg->SetY2(kLegendDefaultY2);
195  }
196  if(opt=="ExPID")
197  {
198  leg->SetX1(0.355); leg->SetX2(0.515);
199  leg->SetY1(0.65); leg->SetY2(0.82);
200  leg->SetBorderSize(0);
201  leg->SetTextSize(0.03);
202  }
203  if(opt=="ExPIDNearDet")
204  {
205  leg->SetX1(0.695); leg->SetX2(0.855);
206  leg->SetY1(0.65); leg->SetY2(0.82);
207  leg->SetBorderSize(0);
208  leg->SetTextSize(0.03);
209  }
210  if(opt=="ExPIDPads")
211  {
212  leg->SetX1(0.55); leg->SetX2(0.89);
213  leg->SetY1(0.75); leg->SetY2(0.89);
214  leg->SetTextSize(0.045);
215  }
216 }
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 111 of file draw_plots_util.h.

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

113 {
114  int mccolor = signal ? kViolet -9 : kTotalMCErrorBandColor;
115  std::cout << "hplus: " << hplus->Integral() << std::endl;
116  std::cout << "hminus: " << hminus->Integral() << std::endl;
117  hplus ->SetLineColor(mccolor);
118  hminus->SetLineColor(mccolor);
119  hplus ->SetFillColor(mccolor);
120  hminus->SetFillColor(10);
121  hplus ->SetMarkerColor(kRed-7);
122  hminus->SetMarkerColor(kBlue-7);
123 
124  if (fixbins)
125  {
126  for(int i=1; i <= hplus->GetNbinsX(); i++)
127  {
128  double tplus = hplus->GetBinContent(i);
129  double tminus = hminus->GetBinContent(i);
130  hplus->SetBinContent(i,max(tplus, tminus));
131  hminus->SetBinContent(i,min(tplus,tminus));
132  }
133  }
134 }
enum BeamMode kRed
TH1F * hplus
Definition: Xsec_final.C:75
const Color_t kTotalMCErrorBandColor
Definition: Style.h:17
OStream cout
Definition: OStream.cxx:6
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
osc::IOscCalc* GetCalculator ( bool  usingdumb)

Definition at line 56 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.

56  {
57  double dCP_Pi = 1.48;
58  double ssth23 = 0.558;
59  double dmsq32 = 2.44e-3;
60 
62  if(usingdumb){
63  osc::OscCalcDumb dumb;
64  calc = dumb.Copy();
65  }
66  else{
67  auto calc2 = DefaultOscCalc();
68  kFitDeltaInPiUnits.SetValue(calc2, dCP_Pi);
69  kFitSinSqTheta23.SetValue(calc2, ssth23);
70  kFitDmSq32.SetValue(calc2, dmsq32);
71  calc = calc2->Copy();
72  }
73  return calc;
74 }
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 137 of file draw_plots_util.h.

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

137  {
138  auto ret = (TH1*) orig->Clone(UniqueName().c_str());
139  ret->Scale(0.1,"width");
140  ret->GetYaxis()->SetTitle("Events / 0.1 GeV");
141  ret->SetBit(kCanDelete);
142  ret->SetDirectory(gROOT);
143  return ret;
144 }
std::string UniqueName()
Return a different string each time, for creating histograms.
Definition: Utilities.cxx:29
void HTag ( TString  hie)

Definition at line 162 of file draw_plots_util.h.

References kOrange, and PrettyTag().

162 { 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,
bool  coreOnlyND = false,
bool  binLabels = true,
const double  textSize = 0.04,
const int  textColor = kGray+3,
const int  lineColor = kBlack,
const int  lineStyle = 3,
const double  yNDC = 0.96 
)

Definition at line 319 of file draw_plots_util.h.

References plot_validation_datamc_2018::lineStyle, ana::Nue2018ThreeBinDivisions(), and ana::Nue2018ThreeBinLabels().

323 {
324  if (coreOnlyND)
325  Info("NuePID3bin", "specified core only/ND.");
326 
327  Nue2018ThreeBinDivisions(coreOnlyND, lineColor, lineStyle);
328  if (binLabels)
329  {
330  Nue2018ThreeBinLabels(yNDC, textSize, textColor, coreOnlyND);
331  }
332  else
333  {
334  if (textSize != 0.04)
335  Warning("NuePID3bin",
336  "binLabels == false --> specified text size has no effect");
337  if (textColor != kGray+3)
338  Warning("NuePID3bin",
339  "binLabels == false --> specified text color has no effect");
340  if (yNDC != 0.96)
341  Warning("NuePID3bin",
342  "binLabels == false --> specified yNDC has no effect");
343  }
344 }
void Nue2018ThreeBinDivisions(bool coreOnly, const int color, const int style)
void Nue2018ThreeBinLabels(const double yNDC, const double textsize, const int color, const bool nd)
void PIDTag ( TString  pid)

Definition at line 161 of file draw_plots_util.h.

References PrettyTag().

161 { PrettyTag (pid, kAzure+3, .83, .92); }
void PrettyTag(TString pid, int color, double xndc, double yndc)
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 643 of file draw_plots_util.h.

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

648 {
649  // Is it NearDet?
650  Info("PlotMCComponentsErrorBand", "out_name = " + out_name);
651  const auto isNearDet = out_name.Contains("ND", TString::kIgnoreCase);
652  if (isNearDet)
653  Info("PlotMCComponentsErrorBand", "isNearDet = true");
654  else
655  Info("PlotMCComponentsErrorBand", "isNearDet = false");
656 
657  if(pidaxis==kNue3bin)
658  {
659  if (isNearDet)
660  FixLegend(leg, "ExPIDNearDet");
661  else
662  FixLegend(leg, "ExPID");
663  }
664 
665 
666  if(!ratioplot)
667  {
668  auto c2 = new TCanvas(UniqueName().c_str(), "c2");
669  for(auto const & v:vnom)
670  v->Draw("hist same");
671  for(auto const & v:vshi)
672  v->Draw("hist same");
673  if(pidaxis==kNue3bin)
674  NuePID3bin(vnom[0], isNearDet);
675  PIDTag(pidtag);
676  leg->Draw("same");
677  PrintCanvasAll(c2, out_name+"_mccomp");
678  PrintLatexFigure("/png_"+out_name+"_mccomp");
679  c2->Close();
680  }
681  else
682  {
683  std::vector<TH1*> vratio;
684  for(unsigned int ii=0; ii<vshi.size();ii++)
685  {
686  auto htemp = PrettyRatio(vshi[ii], vnom[ii],
687  vnom[ii]->GetLineColor(), ii>0 ? 0.4:1.);
688  htemp->GetYaxis()->SetRangeUser(0.5, 1.5);
689  vratio.push_back (htemp);
690  }
691  vnom.insert(vnom.end(), vshi.begin(), vshi.end());
692  std::vector<TString>topOption(vnom.size(), "hist");
693  std::vector<TString>bottomOption(vratio.size(),
694  ratioerrors ? "p":"hist p");
695  auto cratio2 = RatioPlot(
696  vnom, topOption, vratio, bottomOption, pidtag, pidaxis, isNearDet);
697  cratio2->cd();
698  leg->Draw("same");
699  PIDTag(pidtag);
700  PrintCanvasAll(cratio2, out_name+"_mccomp_ratio");
701  PrintLatexFigure("/png_"+out_name+"_mccomp_ratio");
702  }
703 }
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")
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 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 707 of file draw_plots_util.h.

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

711 {
712  // Is it NearDet?
713  Info("PlotMCComponentsErrorBand", "out_name = " + out_name);
714  const auto isNearDet = out_name.Contains("ND", TString::kIgnoreCase);
715  if (isNearDet)
716  Info("PlotMCComponentsErrorBand", "isNearDet = true");
717  else
718  Info("PlotMCComponentsErrorBand", "isNearDet = false");
719 
720  auto hplu_plot = reinterpret_cast<TH1*>(vshi[0]->Clone());
721  auto hmin_plot = reinterpret_cast<TH1*>(vshi[1]->Clone());
722 
723  FormatErrorBand(hplu_plot, hmin_plot, out_name.Contains("_sig"), true);
724  std::vector<TH1*>vshi_plot={hplu_plot,hmin_plot};
725 
726  if(pidaxis==kNue3bin)
727  {
728  if (isNearDet)
729  FixLegend(leg, "ExPIDNearDet");
730  else
731  FixLegend(leg, "ExPID");
732  }
733 
734  if(!ratioplot)
735  {
736  auto c2 = new TCanvas ("c2","c2");
737  vnom[0]->SetMaximum(1.2*vnom[0]->GetMaximum());
738  vnom[0]->Draw("hist");
739  for(auto v:vshi_plot) v->Draw("hist same");
740  for(auto v:vnom) v->Draw("hist same");
741  if(pidaxis==kNue3bin)
742  NuePID3bin(vnom[0], isNearDet);
743  PIDTag(pidtag);
744  leg->Draw("same");
745  PrintCanvasAll(c2, out_name+"_mccomp");
746  PrintLatexFigure("/png_"+out_name+"_mccomp");
747  c2->Close();
748  }
749  else
750  {
751  std::vector<TH1*> vratio;
752  for(unsigned int ii=0; ii<vshi.size(); ii++)
753  {
754  auto htemp = PrettyRatio(vshi[ii], vnom[0], vshi[ii]->GetMarkerColor());
755  vratio.push_back(htemp);
756  }
757  vratio[0]->GetYaxis()->SetRangeUser(0.5,1.5);
758  vnom.insert(vnom.begin()+1,vshi_plot.begin(),vshi_plot.end());
759  std::vector<TString> topOption (vnom.size(), "hist");
760  std::vector<TString> bottomOption (vratio.size(),ratioerrors ?"p":"hist p");
761  auto cratio2= RatioPlot(
762  vnom, topOption, vratio, bottomOption, pidtag, pidaxis, isNearDet);
763  cratio2->cd();
764  leg->Draw("same");
765  PIDTag(pidtag);
766  PrintCanvasAll(cratio2, out_name+"_mccomp_ratio");
767  PrintLatexFigure("/png_"+out_name+"_mccomp_ratio");
768  }
769 }
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 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 589 of file draw_plots_util.h.

References demo5::c1, FixLegend(), genie::utils::style::Format(), make_mec_shifts_plots::GetMaximum(), make_syst_table_plots::h, compare_h5_caf::idx, kNue3bin, NuePID3bin(), submit_concat_project::out_name, PIDTag(), PrettyRatio(), PrintCanvasAll(), ana::PrintLatexFigure(), PandAna.reco_validation.prod5_pid_validation::ratio(), and RatioPlot().

593 {
594  Info("PlotNDDataTotalMCComparison",
595  TString::Format("pidaxis = %d", pidaxis));
596 
597  if(pidaxis==kNue3bin)
598  FixLegend(leg, "ExPIDNearDet");
599  std::vector<TString> h_opt;
600  for(auto const & h:htots) h_opt.push_back("hist");
601  h_opt.push_back("p");
602 
603  if(!ratioplot)
604  {
605  auto c1 = new TCanvas ("c1","c1");
606  htots[0]->SetMaximum(1.3*htots[0]->GetMaximum());
607  for(auto const & h:htots) h->Draw("hist same");
608  htots[0]->Draw("hist same"); //need to redraw for error bands
609  hdata->Draw("p same");
610  PIDTag(pidtag);
611  if(pidaxis==kNue3bin)
612  NuePID3bin(htots[0], true); // hist, coreOnlyND, binLabels
613  leg->Draw("same");
614  PrintCanvasAll(c1, out_name+"_datamc");
615  PrintLatexFigure("/png_"+out_name+"_datamc");
616  }
617  else
618  {
619  std::vector<TH1*> ratios;
620  std::vector<TString> r_opt;
621  auto idx = 0;
622  for(auto const & h:htots)
623  {
624  auto ratio = PrettyRatio(hdata, h, h->GetLineColor(),
625  idx>0 ? 0.4:1., "Data / MC");
626  ratio->GetYaxis()->SetRangeUser(0.5,1.5);
627  ratios.push_back(ratio);
628  r_opt.push_back("e");
629  idx++;
630  }
631  htots.push_back(hdata);
632  auto cratio1 = RatioPlot(htots, h_opt, ratios,
633  r_opt, pidtag, pidaxis, true);
634  cratio1->cd();
635  leg->Draw("same");
636  PIDTag(pidtag);
637 
638  PrintCanvasAll(cratio1,out_name+"_datamc_ratio");
639  PrintLatexFigure("/png_"+out_name+"_datamc_ratio");
640  }
641 }
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")
c1
Definition: demo5.py:24
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"})
TH1* PrettyRatio ( TH1 *  shi,
TH1 *  nom,
int  color,
double  alpha = 1.,
TString  titley = "Shift / Nom" 
)

Definition at line 81 of file draw_plots_util.h.

References ana::UniqueName().

83 {
84  auto htemp = reinterpret_cast<TH1*>(nom->Clone(ana::UniqueName().c_str()));
85  htemp->Divide(shi,nom);
86  htemp->SetMarkerColorAlpha(color,alpha);
87  htemp->SetLineColorAlpha(color,alpha);
88  htemp->SetMarkerStyle(34);
89  htemp->SetMarkerSize(1.4);
90  htemp->GetYaxis()->SetTitle(titley);
91  return htemp;
92 }
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 150 of file draw_plots_util.h.

References getGoodRuns4SAM::tag.

150  {
151  TLatex* tag = new TLatex(xndc, yndc, pid);
152  tag->SetTextColor(color);
153  tag->SetNDC();
154  tag->SetTextSize(0.04);
155  tag->SetTextFont(42);
156  tag->SetTextAlign(22);
157  tag->Draw();
158  tag->SetBit(kCanDelete);
159 }
void PrintCanvasAll ( TCanvas *  c,
const TString  outname,
const TString  outdir = "plots/",
const std::vector< TString >  exts = {"pdf","png","root"} 
)

Definition at line 275 of file draw_plots_util.h.

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

276  {"pdf","png","root"} )
277 {
278  for(auto const & ext:exts){
279  gSystem -> MakeDirectory( outdir );
280  gSystem -> MakeDirectory( outdir+"rootfiles/" );
281  if(ext=="png") c->SaveAs(outdir+"png_"+outname + "." + ext);
282  else if(ext=="root") c->SaveAs(outdir+"rootfiles/"+outname + "." + ext);
283  else c->SaveAs(outdir+outname + "." + ext);
284  }
285  delete c;
286 }
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,
const bool  nearDet = false 
)

Definition at line 410 of file draw_plots_util.h.

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

414 {
415  gStyle->SetTitleStyle(0);
416  TCanvas *c = new TCanvas("c", "canvas", 600, 700);
417  // if(pidaxis == kNue3bin) c->SetCanvasSize(750,650);
418  //define top and bottom pads
419  TPad* p1 = new TPad("", "", 0, 0, 1, 1);
420  TPad* p2 = new TPad("", "", 0, 0, 1, 1);
421  p1->SetBottomMargin(.3);
422  p2->SetTopMargin(.7);
423 
424  for(auto p:{p1,p2}){
425  p->SetFillStyle(0);
426  p->Draw();
427  }
428 
429  // format histograms
430  auto h1 = (TH1*) topHistos[0]->Clone();
431  auto h3 = (TH1*) bottomHistos[0]->Clone();
432 
433  for(auto & h:{h1,h3}){
434  h->SetStats(0);
435 
436  h->GetYaxis()->SetTitleSize(26);
437  h->GetYaxis()->SetTitleFont(43);
438  h->GetYaxis()->SetTitleOffset(1.3);
439  h->GetYaxis()->SetLabelFont(43);
440 
441  h->GetXaxis()->SetTitleOffset(1.2);
442  h->GetXaxis()->SetTitleSize(28);
443  h->GetXaxis()->SetTitleFont(43);
444  h->GetXaxis()->SetLabelFont(43);
445  }
446 
447  if (pidaxis == kNue3bin)
448  h1->GetYaxis()->SetRangeUser(
449  FindLimitY(topHistos,0), 1.5*FindLimitY(topHistos, 1));
450  else
451  h1->GetYaxis()->SetRangeUser(
452  FindLimitY(topHistos,0), 1.2*FindLimitY(topHistos, 1));
453  h1->GetYaxis()->SetLabelSize(18);
454 
455  h1->GetXaxis()->SetLabelSize(0);
456  h1->GetXaxis()->SetTitleSize(0);
457 
458  h3->SetTitle("");
459  h3->GetYaxis()->SetRangeUser(max(0.,2-FindLimitY(bottomHistos,1)),
460  1.01*FindLimitY(bottomHistos,1));
461  h3->GetYaxis()->SetLabelSize(15);
462  h3->GetYaxis()->SetDecimals();
463 
464  h3->GetXaxis()->SetTitle(h1->GetXaxis()->GetTitle());
465  h3->GetXaxis()->SetLabelSize(18);
466  h3->GetXaxis()->SetLabelOffset(0.005);
467 
468  p1->cd();
469 
470  h1->Draw(topOption[0]);
471 
472  for(unsigned int ii = 1; ii < topHistos.size(); ++ii) {
473  topHistos[ii]->Draw("same "+topOption[ii]);}
474  h1->Draw("same "+topOption[0]);
475 
476  p1->RedrawAxis(); //white histograms cover axes
477 
478  if(pidaxis==kNue3bin)
479  NuePID3bin(h1, nearDet);
480 
481  p2->cd();
482  h3->Draw(bottomOption[0]);
483  for(unsigned int ii = 1; ii < bottomHistos.size(); ++ii){
484  bottomHistos[ii]->Draw("same " + bottomOption[ii]);}
485  h3->Draw("same " + bottomOption[0]);
486 
487  auto lone = new TLine();
488  lone->SetLineStyle(3);
489  lone->SetLineColor(kGray+3);
490  p2->Update();
491  lone->DrawLine(p2->GetUxmin(),1.0,p2->GetUxmax(),1.0);
492  lone->DrawLine(p2->GetUxmin(),1.2,p2->GetUxmax(),1.2);
493  lone->DrawLine(p2->GetUxmin(),0.8,p2->GetUxmax(),0.8);
494  float p2Y = p2->GetUymax()-p2->GetUymin();
495  h3->GetYaxis()->SetRangeUser(p2->GetUymin()-(0.01*p2Y),p2->GetUymax()+(0.01*p2Y));
496  p2->RedrawAxis();
497  if(pidaxis==kNue3bin)
498  NuePID3bin(h3, nearDet, false); // hist, coreOnlyND, binLabels
499 
500  return c;
501 }
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

Variable Documentation

bool isFHC =true
static
const double kLegendDefaultX1 = 0.63

Definition at line 168 of file draw_plots_util.h.

const double kLegendDefaultX2 = 0.85

Definition at line 169 of file draw_plots_util.h.

const double kLegendDefaultY1 = 0.68

Definition at line 170 of file draw_plots_util.h.

const double kLegendDefaultY2 = 0.88

Definition at line 171 of file draw_plots_util.h.

bool mergePeripheral =false

Definition at line 54 of file draw_plots_util.h.

const bool printratioplots =true

Definition at line 49 of file draw_plots_util.h.

bool usedumb = false

Definition at line 53 of file draw_plots_util.h.