draw_plots_util.h
Go to the documentation of this file.
6 #include "CAFAna/Core/Binning.h"
7 #include "CAFAna/Core/HistAxis.h"
13 #include "CAFAna/Vars/FitVars.h"
15 
16 #include "OscLib/OscCalcDumb.h"
17 #include "OscLib/IOscCalc.h"
18 
19 #include "TStyle.h"
20 #include "TFile.h"
21 #include "TH1.h"
22 #include "TCanvas.h"
23 #include "TGraph.h"
24 #include "TGraphAsymmErrors.h"
25 #include "TGaxis.h"
26 #include "TLatex.h"
27 #include "TPaveText.h"
28 #include "TLegend.h"
29 #include "TLine.h"
30 #include "TSystem.h"
31 
32 #include <iostream>
33 #include <fstream>
34 #include <iomanip>
35 
36 #include "tex_tables_util.h"
37 
38 static const double kFDPOT= ana::kAna2017POT;
39 const bool printratioplots=true;
40 
42 
43 bool usedumb = false;
44 bool mergePeripheral=false;
45 
46 osc::IOscCalc * GetCalculator (bool usingdumb){
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 }
65 
66 
67 //////////////////////////////////////////////////////////////////////
68 // Histogram
69 //////////////////////////////////////////////////////////////////////
70 
71 TH1* PrettyRatio( TH1* shi, TH1* nom, int color, double alpha = 1.,TString titley = "Shift / Nom"){
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 }
81 
82 //////////////////////////////////////////////////////////////////////
83 
84 double FindLimitY (std::vector<TH1*> histos, bool doMax = true)
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 }
97 
98 //////////////////////////////////////////////////////////////////////
99 void FormatErrorBand(TH1* hplus, TH1* hminus, bool signal=false, bool fixbins=false){
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 }
118 
119 //////////////////////////////////////////////////////////////////////
120 TH1* HistNumuOpt (TH1* orig){
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 }
128 
129 //////////////////////////////////////////////////////////////////////
130 // Adornments
131 //////////////////////////////////////////////////////////////////////
132 
133 void PrettyTag(TString pid, int color, double xndc, double yndc){
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 }
143 
144 void PIDTag(TString pid) { PrettyTag (pid, kAzure+3, .83, .92); }
145 void HTag (TString hie) { PrettyTag (hie, (hie=="NH")?kAzure+3:kOrange+2, .18, .825);}
146 
147 //////////////////////////////////////////////////////////////////////
148 // Legends
149 //////////////////////////////////////////////////////////////////////
150 
151 const double kLegendDefaultX1 = 0.63;
152 const double kLegendDefaultX2 = 0.85;
153 const double kLegendDefaultY1 = 0.68;
154 const double kLegendDefaultY2 = 0.88;
155 
156 TLegend * CustomLegend (std::vector<TH1*>h, std::vector<TString> title,
157  std::vector<TString> option,
158  double x1=kLegendDefaultX1, double y1=kLegendDefaultY1,
159  double x2=kLegendDefaultX2, double y2=kLegendDefaultY2)
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 }
169 
170 //////////////////////////////////////////////////////////////////////
171 
172 void FixLegend(TLegend * leg, TString opt="default"){
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 }
194 //////////////////////////////////////////////////////////////////////
195 
196 TGraph * DummyGraph(int color=kBlack, int style =1, int linewidth=2, int markerstyle = kFullCircle)
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 }
206 //////////////////////////////////////////////////////////////////////
207 
208 TLegend * DefaultNueLegend (bool sig=true, bool tot=true,bool data=false,
209  double x1=kLegendDefaultX1, double y1=kLegendDefaultY1,
210  double x2=kLegendDefaultX2, double y2=kLegendDefaultY2)
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 }
224 //////////////////////////////////////////////////////////////////////
225 
226 TLegend * DefaultNumuLegend (bool sig=true, bool tot=true,bool data=false,
227  double x1=kLegendDefaultX1, double y1=kLegendDefaultY1,
228  double x2=kLegendDefaultX2, double y2=kLegendDefaultY2)
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 }
243 //////////////////////////////////////////////////////////////////////
244 
245 void PrintCanvasAll (TCanvas * c, const TString outname, const TString outdir = "plots/",
246  const std::vector <TString> exts = {"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 }
257 
258 //////////////////////////////////////////////////////////////////////
259 // Nue 3 bins functions
260 //////////////////////////////////////////////////////////////////////
261 
262 // NB, loses all the style info, so call early
263 TH1* RebinToShortAxis(TH1* h)
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 }
287 //////////////////////////////////////////////////////////////////////
288 
289 void PIDDivisions(bool shortaxis = false){
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 }
306 //////////////////////////////////////////////////////////////////////
307 
308 void PIDBinLabels(std::string pid = "CVN", bool shortaxis = false,
309  double yNDC = 0.955, double textsize = 0.028){
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 }
333 
334 //////////////////////////////////////////////////////////////////////
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 }
350 
351 
352 void FourBinLabels(double yNDC = 0.98, double textsize = 0.028){
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 }
377 
378 void FourBinAxis(TH1* axes, bool third = false, bool shortaxis = false)
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("");
393  CenterTitles(axes);
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 }
404 
405 //////////////////////////////////////////////////////////////////////
406 
407 void PID2DAxis(TH1* axes, bool third = false, bool shortaxis = false)
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("");
424  CenterTitles(axes);
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 }
451 
452 //////////////////////////////////////////////////////////////////////
453 void NuePID4bin(TH1* h, TString pidtag, bool binlabels = true)
454 {
456  if(binlabels) FourBinLabels();
457  if(h) FourBinAxis(h);
458 }
459 
460 void NuePID3bin(TH1* h, TString pidtag, bool binlabels = true)
461 {
462  PIDDivisions();
463  if(binlabels) PIDBinLabels((std::string)pidtag);
464  if(h) PID2DAxis(h);
465 }
466 //////////////////////////////////////////////////////////////////////
467 TCanvas * ExPIDPlot (std::vector<TH1*> topHistos,
468  std::vector<TString> topOption)
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 }
527 
528 //////////////////////////////////////////////////////////////////////
529 // Pretty Canvas
530 //////////////////////////////////////////////////////////////////////
531 TCanvas * RatioPlot (std::vector<TH1*> topHistos,
532  std::vector<TString> topOption,
533  std::vector<TH1*> bottomHistos,
534  std::vector<TString> bottomOption,
535  TString pidtag,
536  AxisType pidaxis = kNue1bin)
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 }
621 //////////////////////////////////////////////////////////////////////
622 // Pretty plot styles: Data MC, MC components, error bands
623 //////////////////////////////////////////////////////////////////////
624 
625 void PlotDataMC(std::vector<TH1*>vnom, std::vector<bool>isdata,
626  TLegend * leg, TString pidtag="",TString htag="",
627  TString out_name="plot_FD",bool ratioplot=false,
628  bool ratioerrors=false, AxisType pidaxis = kNue1bin)
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 }
706 
707 //////////////////////////////////////////////////////////////////////
708 
709 void PlotNDDataTotalMCComparison(TH1* hdata,std::vector<TH1*> htots,
710  TLegend * leg,TString pidtag="",
711  TString out_name="plot_nd",
712  bool ratioplot=false, AxisType pidaxis = kNue1bin)
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 }
763 //////////////////////////////////////////////////////////////////////
764 void PlotMCComponentsComparison(std::vector<TH1*>vnom,std::vector<TH1*>vshi,
765  TLegend * leg, TString pidtag="",
766  TString out_name="plot_nd",bool ratioplot=false,
767  bool ratioerrors=false, AxisType pidaxis = kNue1bin)
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 }
813 
814 //////////////////////////////////////////////////////////////////////
815 
816 void PlotMCComponentsErrorBand(std::vector<TH1*>vnom,std::vector<TH1*>vshi,
817  TLegend * leg, TString pidtag="",
818  TString out_name="plot_nd",bool ratioplot=false,
819  bool ratioerrors=false,AxisType pidaxis = kNue1bin)
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 }
861 
862 //////////////////////////////////////////////////////////////////////
863 
864 
865 
866 //////////////////////////////////////////////////////////////////////
867 // Define container for histograms + format
868 //////////////////////////////////////////////////////////////////////
869 
870 namespace ana
871 {
872 
874  TH1* data;
875  TH1* sig, *bkg,*beam,*numu,*nc,*tau;
877  };
878 
879  void DefaultFormatNue (DataMCComponets & comp, int linestyle = 1){
880  std::vector <std::pair <TH1*, int>> pairs = {
881  {comp.sig, kNueSignalColor},
883  {comp.nc, kNCBackgroundColor},
884  {comp.numu, kNumuBackgroundColor},
885  {comp.bkg, kTotalMCColor},
888  {comp.nuetonutau, kGray},
889  {comp.numutonutau, kGray}
890  };
891  for (auto const & mypair:pairs){
892  if(!mypair.first) continue;
893  mypair.first->SetLineColor(mypair.second);
894  mypair.first->SetLineStyle(linestyle);
895  CenterTitles(mypair.first);
896  }
897  if(comp.data) comp.data->SetMarkerStyle(kFullCircle);
898  return;
899  }
900 //////////////////////////////////////////////////////////////////////
901 
902  struct DataMCComponets GetNDComponents(TDirectory * d_no, double kNDPOT,int linestyle =1){
904  ret.beam = (*Spectrum::LoadFrom(d_no, "nue_comp") +
905  *Spectrum::LoadFrom(d_no, "antinue_comp")).ToTH1(kNDPOT);
906  ret.numu = (*Spectrum::LoadFrom(d_no, "numu_comp") +
907  *Spectrum::LoadFrom(d_no, "antinumu_comp")).ToTH1(kNDPOT);
908  ret.nc = (*Spectrum::LoadFrom(d_no, "nc_tot_comp")).ToTH1(kNDPOT);
909  ret.data = (*Spectrum::LoadFrom(d_no, "data_comp")).ToTH1(kNDPOT);
910  ret.bkg = (TH1*)ret.beam->Clone();
911  ret.bkg->Add(ret.numu);ret.bkg->Add(ret.nc);
912  ret.sig=0; ret.tau=0;
913  ret.nuetonumu=0; ret.nuetonutau=0;
914  ret.numutonumu=0; ret.numutonutau=0;
915 
916  DefaultFormatNue(ret,linestyle);
917 
918  return ret;
919  }
920 //////////////////////////////////////////////////////////////////////
921 
922  struct DataMCComponets GetFDMCComponents(osc::IOscCalc * calc, IPrediction * pred_no, TString output_name="nue", int linestyle=1, bool bkgdetails = false){
924  // Set some defaults for the components.
925  Flavors::Flavors_t MySig, MyBeam, MyNuMu, MyNC, MyTau;
926  MySig = MyBeam = MyNuMu = MyNC = MyTau = Flavors::kAll;
927  // Change the components depending on what I'm looking at.
928  if ( !isNumuAna ) { // Nu e
929  MySig = Flavors::kNuMuToNuE;
930  MyBeam = Flavors::kNuEToNuE;
931  MyNuMu = Flavors::kAllNuMu;
932  MyNC = Flavors::kAll;
933  MyTau = Flavors::kAllNuTau;
934  } else { // Nu mu
935  MySig = Flavors::kNuMuToNuMu;
936  MyBeam = Flavors::kAllNuE;
937  MyNuMu = Flavors::kNuEToNuMu;
938  MyNC = Flavors::kAll;
939  MyTau = Flavors::kAllNuTau;
940  }
941 
942  ret.sig = pred_no->PredictComponent(calc, MySig, Current::kCC, Sign::kBoth).ToTH1(kFDPOT);
943  ret.beam = pred_no->PredictComponent(calc, MyBeam, Current::kCC, Sign::kBoth).ToTH1(kFDPOT);
944  ret.numu = pred_no->PredictComponent(calc, MyNuMu, Current::kCC, Sign::kBoth).ToTH1(kFDPOT);
945  ret.nc = pred_no->PredictComponent(calc, MyNC, Current::kNC, Sign::kBoth).ToTH1(kFDPOT);
946  ret.tau = pred_no->PredictComponent(calc, MyTau, Current::kCC, Sign::kBoth).ToTH1(kFDPOT);
947 
948  ret.bkg = (pred_no->Predict(calc) -
949  pred_no->PredictComponent(calc, MySig, Current::kCC, Sign::kBoth)).ToTH1(kFDPOT);
950 
951  if(bkgdetails){
952  ret.nuetonumu = pred_no->PredictComponent(calc, Flavors::kNuEToNuMu, Current::kCC, Sign::kBoth).ToTH1(kFDPOT);
953  ret.numutonumu = pred_no->PredictComponent(calc, Flavors::kNuMuToNuMu, Current::kCC, Sign::kBoth).ToTH1(kFDPOT);
954  ret.nuetonutau = pred_no->PredictComponent(calc, Flavors::kNuEToNuTau, Current::kCC, Sign::kBoth).ToTH1(kFDPOT);
955  ret.numutonutau = pred_no->PredictComponent(calc, Flavors::kNuMuToNuTau, Current::kCC, Sign::kBoth).ToTH1(kFDPOT);
956  }
957  else {
958  ret.nuetonumu = 0; ret.numutonumu = 0; ret.nuetonutau = 0; ret.numutonutau = 0;
959  }
960  ret.data = 0;
961  DefaultFormatNue(ret,linestyle);
962  return ret;
963  }
964 
965 //////////////////////////////////////////////////////////////////////
966 // Compare ND Data MC
967 //////////////////////////////////////////////////////////////////////
968 
969  void CompareNDDataOneMC(TDirectory * d_no, TDirectory* d_sh,
970  TString plottitle,TString out_name,
971  TString pidtag, bool printtable=true, AxisType pidaxis = kNue1bin){
972 
973  auto kNDPOT = Spectrum::LoadFrom(d_no, "data_comp")->POT();
974 
975  auto h_no = GetNDComponents(d_no, kNDPOT,1);
976  auto h_sh = GetNDComponents(d_sh, kNDPOT,7);
977 
978  h_sh.bkg->SetLineColor(kTotalMCErrorBandColor);
979  h_sh.bkg->SetLineStyle(1);
980 
981  h_no.bkg->SetMaximum(FindLimitY({h_no.bkg,h_no.data}));
982  h_no.bkg->SetTitle(plottitle);
983 
984  TGaxis::SetMaxDigits(3);
985  h_no.bkg->GetXaxis()->SetDecimals();
986 
987  auto leg1 = CustomLegend({h_no.data, h_no.bkg, h_sh.bkg},{"ND Data","Nominal","Shift"},{"epl","l","l"});
988 
989  auto leg2 = DefaultNueLegend(false,true,false);
990 
991  TH1 * mydata = h_no.data;
992  std::vector <TH1*> comp_plot = {h_no.bkg, h_sh.bkg};
993  std::vector <TH1*> vnom_plot = {h_no.bkg, h_no.beam,h_no.nc,h_no.numu};
994  std::vector <TH1*> vshi_plot = {h_sh.bkg, h_sh.beam,h_sh.nc,h_sh.numu};
995 
996  std::vector <TH1*> vnom = {h_no.bkg,h_no.beam,h_no.nc,h_no.numu};
997  std::vector <TH1*> vshi = {h_sh.bkg,h_sh.beam,h_sh.nc,h_sh.numu};
998  std::vector<TString> labels = {"Total MC","Beam $\\nu_{e}$","NC", "$\\nu_{\\mu}$ CC"};
999 
1000  if(pidaxis == kNumuOpt){
1001  leg2 = DefaultNumuLegend(false,true,false);
1002  mydata = HistNumuOpt(h_no.data);
1003  comp_plot = { HistNumuOpt(h_no.bkg), HistNumuOpt(h_sh.bkg) };
1004  vnom_plot = { HistNumuOpt(h_no.bkg), HistNumuOpt(h_no.numu), HistNumuOpt(h_no.nc)};
1005  vshi_plot = { HistNumuOpt(h_sh.bkg), HistNumuOpt(h_sh.numu), HistNumuOpt(h_sh.nc)};
1006 
1007  vnom = {h_no.bkg,h_no.numu,h_no.nc,h_no.beam};
1008  vshi = {h_sh.bkg,h_sh.numu,h_sh.nc,h_sh.beam};
1009  labels = {"Total MC","$\\nu_{\\mu}$ CC","NC", "$\\nu_{e}$ CC"};
1010  }
1011 
1012  PlotNDDataTotalMCComparison(mydata, comp_plot,
1013  leg1, pidtag, out_name, printratioplots, pidaxis);
1014 
1015  h_sh.bkg->SetLineColor(kTotalMCColor+1);
1016  h_sh.bkg->SetLineStyle(7);
1017 
1018  leg2->AddEntry(DummyGraph(kGray+1,2),"Shifted","l");
1019 
1020  PlotMCComponentsComparison(vnom_plot, vshi_plot,
1021  leg2, pidtag, out_name, printratioplots, false, pidaxis);
1022 
1023  if(printtable){
1024 
1025  ComparisonTableOne (vnom, vshi, labels, out_name);
1026 
1027  int nbins = 1;
1028  if (pidaxis== kNue3bin) nbins = 3;
1029  if (pidaxis== kNue4bin) {nbins = 4; std::cerr << "4 bins\n";}
1030  ComparisonTableOneNbins({h_no.bkg,h_no.beam,h_no.nc,h_no.numu},
1031  {h_sh.bkg,h_sh.beam,h_sh.nc,h_sh.numu},
1032  labels,
1033  out_name,
1034  nbins);
1035  }
1036 
1037  }
1038 //////////////////////////////////////////////////////////////////////
1039 
1040  void CompareNDDataTwoMC(TDirectory * d_no, TDirectory* d_pl,TDirectory*d_mi,
1041  TString plottitle,TString out_name, TString pidtag,
1042  bool printtable=true,AxisType pidaxis = kNue1bin){
1043 
1044  auto kNDPOT = Spectrum::LoadFrom(d_no, "data_comp")->POT();
1045 
1046  auto hnom = GetNDComponents(d_no,kNDPOT);
1047  auto hplu = GetNDComponents(d_pl,kNDPOT);
1048  auto hmin = GetNDComponents(d_mi,kNDPOT);
1049 
1050  FormatErrorBand(hplu.bkg,hmin.bkg);
1051 
1052  hnom.bkg->SetMaximum(FindLimitY({hnom.bkg,hnom.data,hplu.bkg,hmin.bkg}));
1053  hnom.bkg->SetTitle(plottitle);
1054 
1055  TGaxis::SetMaxDigits(3);
1056  hnom.bkg->GetXaxis()->SetDecimals();
1057 
1058  auto leg1 = CustomLegend ({hnom.data, hnom.bkg, hplu.bkg},{"ND Data","Nominal","Syst."},{"epl","l","f"});
1059  auto leg2 = DefaultNueLegend(false,true,false);
1060 
1061 
1062  TH1 * mydata = hnom.data;
1063  std::vector <TH1*> comp_plot = {hnom.bkg, hplu.bkg, hmin.bkg};
1064  std::vector <TH1*> vnom_plot = {hnom.bkg, hnom.beam,hnom.nc,hnom.numu};
1065  std::vector <TH1*> vshi_plot = {hplu.bkg, hmin.bkg};
1066 
1067  std::vector <TH1*> vnom = {hnom.bkg,hnom.beam,hnom.nc,hnom.numu};
1068  std::vector <TH1*> vplu = {hplu.bkg,hplu.beam,hplu.nc,hplu.numu};
1069  std::vector <TH1*> vmin = {hmin.bkg,hmin.beam,hmin.nc,hmin.numu};
1070  std::vector<TString> labels = {"Total MC","Beam $\\nu_{e}$","NC", "$\\nu_{\\mu}$ CC"};
1071 
1072  if(pidaxis == kNumuOpt){
1073  leg2 = DefaultNumuLegend(false,true,false);
1074  mydata = HistNumuOpt(hnom.data);
1075  comp_plot = { HistNumuOpt(hnom.bkg), HistNumuOpt(hplu.bkg), HistNumuOpt(hmin.bkg) };
1076 
1077  vnom_plot = { HistNumuOpt(hnom.bkg), HistNumuOpt(hnom.numu), HistNumuOpt(hnom.nc)};
1078  vshi_plot = { HistNumuOpt(hplu.bkg), HistNumuOpt(hmin.bkg)};
1079 
1080  vnom = {hnom.bkg,hnom.numu,hnom.nc,hnom.beam};
1081  vplu = {hplu.bkg,hplu.numu,hplu.nc,hplu.beam};
1082  vmin = {hmin.bkg,hmin.numu,hmin.nc,hmin.beam};
1083  labels = {"Total MC","$\\nu_{\\mu}$ CC","NC", "$\\nu_{e}$ CC"};
1084  }
1085 
1086  PlotNDDataTotalMCComparison(mydata, comp_plot,
1087  leg1, pidtag, out_name, printratioplots, pidaxis);
1088 
1089  leg2->AddEntry(hplu.bkg,"Syst.","f");
1090  PlotMCComponentsErrorBand(vnom_plot, vshi_plot,
1091  leg2, pidtag, out_name, printratioplots, false, pidaxis);
1092 
1093  if(printtable){
1094  ComparisonTable (vnom, vplu, vmin, labels,
1095  out_name);
1096  int nbins = 1;
1097  if (pidaxis== kNue3bin) nbins = 3;
1098  if (pidaxis== kNue4bin) {nbins = 4; std::cerr << "4 bins\n";}
1099  ComparisonTableNbins(vnom, vplu, vmin, labels,
1100  out_name, nbins);
1101  }
1102  }
1103 
1104 //////////////////////////////////////////////////////////////////////
1105 
1106  void CompareNDDataMCFromVector(TDirectory * d_no, std::vector<TDirectory*> d_sh,
1107  TString plottitle, TString out_name, TString tag,
1108  bool printtable=true, AxisType pidaxis = kNue1bin){
1109 
1110  int numSh = d_sh.size();
1111  if ( numSh == 2 ) {
1112  if (out_name.Contains("RelativeCalib") ) {
1113  CompareNDDataTwoMC(d_no, d_sh[0], d_sh[1], plottitle, out_name + "_2sigma", tag+" #pm2#sigma", printtable, pidaxis);
1114  } else {
1115  CompareNDDataTwoMC(d_no, d_sh[0], d_sh[1], plottitle, out_name + "_1sigma", tag+" #pm1#sigma", printtable, pidaxis);
1116  }
1117  } else if ( numSh == 4 ){
1118  CompareNDDataTwoMC(d_no, d_sh[0], d_sh[1], plottitle, out_name + "_1sigma", tag+" #pm1#sigma", printtable, pidaxis);
1119  } else if ( numSh == 1 ) {
1120  CompareNDDataOneMC(d_no, d_sh[0], plottitle, out_name + "_1sigma", tag + " #plus1#sigma", printtable, pidaxis);
1121  }
1122  }
1123 
1124 //////////////////////////////////////////////////////////////////////
1125 // Compare FD Predictions
1126 //////////////////////////////////////////////////////////////////////
1127 
1128  void CompareOneShiftPred(IPrediction * pred_no, IPrediction * pred_sh,
1129  TString plottitle, TString out_name, TString pidtag,
1130  bool printtable=true, AxisType pidaxis = kNue1bin, bool PrintParams=false){
1131  auto calc = GetCalculator (usedumb);
1132  auto h_no = GetFDMCComponents (calc, pred_no, out_name);
1133  auto h_sh = GetFDMCComponents (calc, pred_sh, out_name, 2);
1134 
1135  h_no.sig->SetMaximum(FindLimitY({h_no.sig,h_sh.sig}));
1136  h_no.bkg->SetMaximum(FindLimitY({h_no.bkg,h_sh.bkg}));
1137  h_no.sig->SetTitle(plottitle);
1138  h_no.bkg->SetTitle(plottitle);
1139  TGaxis::SetMaxDigits(3);
1140 
1141  auto leg = DefaultNueLegend(false,true,false);
1142  if (isNumuAna) leg = DefaultNumuLegend(false,true,false);
1143  leg->AddEntry(DummyGraph(kGray+1,2),"Shifted","l");
1144 
1145  std::vector<TString> legnames = {"#nu_{e} Signal","Shifted"};
1146  if (isNumuAna) legnames = {"#nu_{#mu} Signal","Shifted"};
1147  auto leg2 = CustomLegend({h_no.sig, h_sh.sig},legnames,{"l","l"});
1148 
1149  if(pidaxis == kNumuOpt){ //fix the plot but don't mess up the tables
1150 
1151  PlotMCComponentsComparison({ HistNumuOpt(h_no.bkg), HistNumuOpt(h_no.beam), HistNumuOpt(h_no.nc), HistNumuOpt(h_no.numu) },
1152  { HistNumuOpt(h_sh.bkg), HistNumuOpt(h_sh.beam), HistNumuOpt(h_sh.nc), HistNumuOpt(h_sh.numu) },
1153  leg,pidtag,out_name+"_bkg",printratioplots,false,pidaxis);
1155  { HistNumuOpt(h_sh.sig) },
1156  leg2,pidtag,out_name+"_sig",printratioplots,false,pidaxis);
1157  }
1158  else{
1159  PlotMCComponentsComparison({ h_no.bkg, h_no.beam, h_no.nc, h_no.numu },
1160  { h_sh.bkg, h_sh.beam, h_sh.nc, h_sh.numu },
1161  leg,pidtag, out_name+"_bkg", printratioplots, false, pidaxis);
1162  PlotMCComponentsComparison({ h_no.sig },
1163  { h_sh.sig },
1164  leg2,pidtag,out_name+"_sig",printratioplots,false,pidaxis);
1165  }
1166 
1167  if(PrintParams) PrintOscilationParameters (calc, usedumb);
1168 
1169  if(printtable){
1170  std::vector<TString> labels = {"$\\nu_e$ signal","Tot beam bkg","Beam $\\nu_{e}$ CC","NC", "$\\nu_{\\mu}$ CC", "$\\nu_{\\tau}$ CC"};
1171 
1172  if (isNumuAna) {
1173  labels = {"$\\nu_{\\mu}$ signal","Tot beam bkg","$\\nu_{e}$ CC","NC", "$\\nu_{\\mu} $App", "$\\nu_{\\tau}$ CC"};
1174  }
1175  ComparisonTableOne ({h_no.sig, h_no.bkg, h_no.beam, h_no.nc, h_no.numu, h_no.tau},
1176  {h_sh.sig, h_sh.bkg, h_sh.beam, h_sh.nc, h_sh.numu, h_sh.tau},
1177  labels,
1178  out_name
1179  );
1180  int nbins = 1;
1181  if (pidaxis== kNue3bin) nbins = 3;
1182  if (pidaxis== kNue4bin) {nbins = 4; std::cerr << "4 bins\n";}
1183  ComparisonTableOneNbins({h_no.sig, h_no.bkg, h_no.beam,h_no.nc,h_no.numu,h_no.tau},
1184  {h_sh.sig, h_sh.bkg, h_sh.beam,h_sh.nc,h_sh.numu,h_sh.tau},
1185  labels,
1186  out_name,
1187  nbins);
1188  }//end if table
1189  }
1190 //////////////////////////////////////////////////////////////////////
1191 
1192  void CompareTwoShiftPred(IPrediction * pred_no, IPrediction * pred_pl, IPrediction * pred_mi,
1193  TString plottitle, TString out_name, TString pidtag,
1194  bool printtable=true, AxisType pidaxis = kNue1bin, bool PrintParams=false){
1195 
1196  auto calc = GetCalculator(usedumb);
1197 
1198  auto hnom = GetFDMCComponents(calc, pred_no, out_name);
1199  auto hplu = GetFDMCComponents(calc, pred_pl, out_name);
1200  auto hmin = GetFDMCComponents(calc, pred_mi, out_name);
1201 
1202  FormatErrorBand(hplu.bkg,hmin.bkg,false);
1203  hnom.bkg->SetMaximum(FindLimitY({hnom.bkg,hplu.bkg,hmin.bkg}));
1204  hnom.bkg->SetTitle(plottitle);
1205 
1206  FormatErrorBand(hplu.sig,hmin.sig,true);
1207  hnom.sig->SetMaximum(FindLimitY({hnom.sig,hplu.sig,hmin.sig}));
1208  hnom.sig->SetTitle(plottitle);
1209 
1210  TGaxis::SetMaxDigits(3);
1211 
1212  TLegend * leg, *leg2;
1213  if( pidaxis == kNumuOpt || pidaxis == kNumuOther){
1214  leg = DefaultNumuLegend(false,true,false);
1215  leg2 = CustomLegend({hnom.sig, hplu.sig},{"#nu_{#mu} Signal","Shifted"},{"l","f"});
1216  }
1217  else{
1218  leg = DefaultNueLegend(false,true,false);
1219  leg2 = CustomLegend({hnom.sig, hplu.sig},{"#nu_{e} Signal","Shifted"},{"l","f"});
1220  }
1221  leg->AddEntry(hplu.bkg,"Syst.","f");
1222 
1223  std::vector <TH1*> nom_bkg_plot = {hnom.bkg,hnom.beam,hnom.nc,hnom.numu};
1224  std::vector <TH1*> shi_bkg_plot = {hplu.bkg,hmin.bkg};
1225  std::vector <TH1*> nom_sig_plot = {hnom.sig};
1226  std::vector <TH1*> shi_sig_plot = {hplu.sig,hmin.sig};
1227 
1228  std::vector <TH1*> vnom = {hnom.sig, hnom.bkg, hnom.beam, hnom.nc, hnom.numu, hnom.tau};
1229  std::vector <TH1*> vplu = {hplu.sig, hplu.bkg, hplu.beam, hplu.nc, hplu.numu, hplu.tau};
1230  std::vector <TH1*> vmin = {hmin.sig, hmin.bkg, hmin.beam, hmin.nc, hmin.numu, hmin.tau};
1231 
1232  std::vector <TString> labels = {"$\\nu_e$ signal","Tot beam bkg","Beam $\\nu_{e}$ CC","NC", "$\\nu_{\\mu}$ CC", "$\\nu_{\\tau}$ CC"};
1233  if(pidaxis == kNumuOpt || pidaxis == kNumuOther){
1234  labels = {"$\\nu_{\\mu}$ signal","Tot beam bkg","NC", "$\\nu_{\\mu}$ App", "$\\nu_{e}$ CC","$\\nu_{\\tau}$ CC"};
1235  vnom = {hnom.sig, hnom.bkg, hnom.nc, hnom.numu, hnom.beam, hnom.tau};
1236  vplu = {hplu.sig, hplu.bkg, hplu.nc, hplu.numu, hnom.beam, hplu.tau};
1237  vmin = {hmin.sig, hmin.bkg, hmin.nc, hmin.numu, hnom.beam, hmin.tau};
1238  }
1239  if(pidaxis == kNumuOpt){
1240  nom_bkg_plot = { HistNumuOpt(hnom.bkg),HistNumuOpt(hnom.beam),HistNumuOpt(hnom.nc),HistNumuOpt(hnom.numu)};
1241  shi_bkg_plot = {HistNumuOpt(hplu.bkg),HistNumuOpt(hmin.bkg)};
1242  nom_sig_plot = {HistNumuOpt(hnom.sig)};
1243  shi_sig_plot = {HistNumuOpt(hplu.sig),HistNumuOpt(hmin.sig)};
1244  }
1245 
1246  PlotMCComponentsErrorBand(nom_bkg_plot, shi_bkg_plot,
1247  leg, pidtag, out_name + "_bkg", printratioplots, false, pidaxis);
1248  PlotMCComponentsErrorBand(nom_sig_plot, shi_sig_plot,
1249  leg2, pidtag, out_name + "_sig", printratioplots, false, pidaxis);
1250 
1251  if(PrintParams) PrintOscilationParameters (calc, usedumb);
1252 
1253  if(printtable){
1254 
1255  ComparisonTable (vnom, vplu, vmin, labels, out_name);
1256 
1257  int nbins = 1;
1258  if (pidaxis== kNue3bin) nbins = 3;
1259  if (pidaxis== kNue4bin) {nbins = 4; std::cerr << "4 bins\n";}
1260  ComparisonTableNbins (vnom, vplu, vmin, labels, out_name, nbins);
1261  }
1262  }
1263 
1264 //////////////////////////////////////////////////////////////////////
1265 
1266  void ComparePredictionsFromVector(TDirectory * dpred_no,
1267  std::vector<TDirectory *> dpred_sh,
1268  TString plottitle, TString out_name,
1269  bool printtable=true,AxisType pidaxis = kNue1bin){
1270  int numSh = dpred_sh.size();
1271 
1272  std::unique_ptr<IPrediction> pred_no = ana::LoadFrom<IPrediction>(dpred_no);
1273 
1274  std::vector< std::unique_ptr<IPrediction> > pred_sh;
1275  for ( int sh = 0; sh < numSh; ++sh )
1276  pred_sh.push_back( ana::LoadFrom<IPrediction>(dpred_sh[sh]) );
1277 
1278  if ( numSh == 2 ) {
1279  if (out_name.Contains("RelativeCalib") ) {
1280  CompareTwoShiftPred(pred_no.get(), pred_sh[0].get(), pred_sh[1].get(), plottitle, out_name+"_2sigma", "#pm2#sigma", printtable, pidaxis);
1281  } else {
1282  CompareTwoShiftPred(pred_no.get(), pred_sh[0].get(), pred_sh[1].get(), plottitle, out_name+"_1sigma", "#pm1#sigma", printtable, pidaxis);
1283  }
1284  } else if ( numSh == 4 ){
1285  CompareTwoShiftPred(pred_no.get(), pred_sh[0].get(), pred_sh[1].get(), plottitle, out_name+"_1sigma", "#pm1#sigma", printtable, pidaxis);
1286  } else if ( numSh == 1 )
1287  CompareOneShiftPred(pred_no.get(), pred_sh[0].get(), plottitle, out_name+"_1sigma", "#plus1#sigma", printtable, pidaxis);
1288  }
1289 
1290 //////////////////////////////////////////////////////////////////////
1291  void ComparePredictionsPeripheralFromVector(TDirectory * dpred_no_xp, TDirectory * dpred_no_nxp,
1292  std::vector<TDirectory *> dpred_sh_xp,std::vector<TDirectory *> dpred_sh_nxp,
1293  TString plottitle, TString out_name,
1294  bool printtable=true, AxisType pidaxis = kNue4bin){
1295  int numSh = dpred_sh_xp.size();
1296  assert (dpred_sh_xp.size() == dpred_sh_nxp.size());
1297  assert (pidaxis == kNue4bin);
1298 
1299  auto pred_nom_xp = PredictionExtrap::LoadFrom(dpred_no_xp);
1300  auto pred_nom_nxp = PredictionNoExtrap::LoadFrom(dpred_no_nxp);
1301  auto pred_no = new PredictionExtendToPeripheral(pred_nom_xp.get(), pred_nom_nxp.get(), mergePeripheral);
1302 
1303  std::vector< IPrediction *> pred_sh;
1304  for ( int sh = 0; sh < numSh; ++sh ){
1305  auto temp_nxp = PredictionNoExtrap::LoadFrom(dpred_sh_nxp[sh]);
1306  auto temp_xp = PredictionExtrap::LoadFrom(dpred_sh_xp[sh]);
1307  pred_sh.push_back(new PredictionExtendToPeripheral(temp_xp.release(), temp_nxp.release(), mergePeripheral));
1308  }
1309 
1310  if ( numSh == 2 )
1311  CompareTwoShiftPred(pred_no, pred_sh[0], pred_sh[1], plottitle, out_name+"_1sigma", "#pm1#sigma", printtable, pidaxis);
1312  if ( numSh == 4 ){
1313  CompareTwoShiftPred(pred_no, pred_sh[0], pred_sh[1], plottitle, out_name+"_1sigma", "#pm1#sigma", printtable, pidaxis);
1314 // CompareTwoShiftPred(pred_no, pred_sh[2], pred_sh[3], plottitle, out_name+"_2sigma", "#pm2#sigma", printtable, pidaxis);
1315  }
1316  if ( numSh == 1 )
1317  CompareOneShiftPred(pred_no, pred_sh[0], plottitle, out_name+"_1sigma", "#plus1#sigma", printtable, pidaxis);
1318  }
1319 
1320 }
struct DataMCComponets GetFDMCComponents(osc::IOscCalc *calc, IPrediction *pred_no, TString output_name="nue", int linestyle=1, bool bkgdetails=false)
const double kLegendDefaultY2
enum BeamMode kOrange
const double kLegendDefaultY1
const int pidBins
enum BeamMode kRed
string output_name
Pickle.
Represent the binning of a Spectrum&#39;s x-axis.
Definition: Binning.h:16
Cuts and Vars for the 2020 FD DiF Study.
Definition: vars.h:6
void ComparisonTableOneNbins(const std::vector< TH1 * > &mcnom, const std::vector< TH1 * > &mcshift, const std::vector< TString > &labels, TString ltxcommand, int N=3)
double ssth23
set< int >::iterator it
osc::IOscCalc * GetCalculator(bool usingdumb)
bool mergePeripheral
Float_t y1[n_points_granero]
Definition: compare.C:5
(&#39; appearance&#39;)
Definition: IPrediction.h:18
void CompareOneShiftPred(IPrediction *pred_no, IPrediction *pred_sh, TString plottitle, TString out_name, TString pidtag, bool printtable=true, AxisType pidaxis=kNue1bin, bool PrintParams=false)
const FitDmSq32 kFitDmSq32
Definition: FitVars.cxx:18
const double kLegendDefaultX2
const Binning kCVNNLBinning
Definition: Binnings.cxx:20
Float_t x1[n_points_granero]
Definition: compare.C:5
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, bool pidaxis=0)
TH1F * h3
Definition: berger.C:36
void SetValue(osc::IOscCalcAdjustable *osc, double val) const override
Definition: FitVars.cxx:177
(&#39;beam &#39;)
Definition: IPrediction.h:15
const char * p
Definition: xmltok.h:285
TH1 * ratio(TH1 *h1, TH1 *h2)
General interface to oscillation calculators.
Definition: StanTypedefs.h:22
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)
OStream cerr
Definition: OStream.cxx:7
void ComparisonTableOne(const std::vector< TH1 * > &mcnom, const std::vector< TH1 * > &mcshift, const std::vector< TString > &labels, const TString ltxcommand="")
const double kAna2017POT
Definition: Exposures.h:174
void 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)
void SetValue(osc::IOscCalcAdjustable *osc, double val) const override
Forward to wrapped Var&#39;s SetValue()
TLegend * leg1
Definition: plot_hist.C:105
void 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)
TH1F * hplus
Definition: Xsec_final.C:75
void CenterTitles(TH1 *histo)
Definition: Plots.cxx:1481
TGraphAsymmErrors * GraphWithPoissonErrors(const TH1 *h, bool noErrorsXaxis, bool drawEmptyBins)
Calculate statistical errors appropriate for small Poisson numbers.
Definition: Plots.cxx:910
const Color_t kTotalMCErrorBandColor
Definition: Style.h:17
osc::OscCalcDumb calc
osc::IOscCalcAdjustable * DefaultOscCalc()
Create a new calculator with default assumptions for all parameters.
Definition: Calcs.cxx:49
void PrettyTag(TString pid, int color, double xndc, double yndc)
const Color_t kNumuBackgroundColor
Definition: Style.h:30
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, bool pidaxis=0)
_IOscCalc< double > IOscCalc
Definition: IOscCalc.h:41
double FindLimitY(std::vector< TH1 * > histos, bool doMax=true)
struct DataMCComponets GetNDComponents(TDirectory *d_no, double kNDPOT, int linestyle=1)
const Color_t kNueSignalColor
Definition: Style.h:19
void PlotNDDataTotalMCComparison(TH1 *hdata, std::vector< TH1 * > htots, TLegend *leg, TString pidtag="", TString out_name="plot_nd", bool ratioplot=false, bool pidaxis=false)
TLegend * DefaultNueLegend(bool sig=true, bool tot=true, bool data=false, double x1=kLegendDefaultX1, double y1=kLegendDefaultY1, double x2=kLegendDefaultX2, double y2=kLegendDefaultY2)
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)
const XML_Char const XML_Char * data
Definition: expat.h:268
static const double kFDPOT
c2
Definition: demo5.py:33
void PIDBinLabels(std::string pid="CVN", bool shortaxis=false, double yNDC=0.955, double textsize=0.028)
const int nbins
Definition: cellShifts.C:15
Charged-current interactions.
Definition: IPrediction.h:39
TLegend * DefaultNumuLegend(bool sig=true, bool tot=true, bool data=false, double x1=kLegendDefaultX1, double y1=kLegendDefaultY1, double x2=kLegendDefaultX2, double y2=kLegendDefaultY2)
void CompareNDDataMCFromVector(TDirectory *d_no, std::vector< TDirectory * > d_sh, TString plottitle, TString out_name, TString tag, bool printtable=true, AxisType pidaxis=kNue1bin)
const bool printratioplots
bool isNumuAna
void PIDTag(TString pid)
void FourBinDivisions()
static std::unique_ptr< Spectrum > LoadFrom(TDirectory *dir, const std::string &name)
Definition: Spectrum.cxx:535
void ComparisonTable(const std::vector< TH1 * > &mcnom, const std::vector< TH1 * > &mcplus, const std::vector< TH1 * > &mcminus, std::vector< TString > labels, TString ltxcommand="")
void CenterTitles(TH1 *h)
void PIDDivisions(bool shortaxis=false)
void FormatErrorBand(TH1 *hplus, TH1 *hminus, bool signal=false, bool fixbins=false)
void SetValue(osc::IOscCalcAdjustable *osc, double val) const override
void NuePID3bin(TH1 *h, TString pidtag, bool binlabels=true)
const Color_t kBeamNueBackgroundColor
Definition: Style.h:24
double Ebins[11]
Definition: Xdiff_gwt.C:8
TGraph * DummyGraph(int color=kBlack, int style=1, int linewidth=2, int markerstyle=kFullCircle)
Simple oscillation probability calculator that has no solar term or mass hierarchy or delta so it&#39;s s...
Definition: OscCalcDumb.h:16
const double kLegendDefaultX1
void FourBinLabels(double yNDC=0.98, double textsize=0.028)
const double j
Definition: BetheBloch.cxx:29
double he
Definition: runWimpSim.h:113
const Binning bins
void HTag(TString hie)
static std::unique_ptr< PredictionExtrap > LoadFrom(TDirectory *dir, const std::string &name)
std::unique_ptr< IPrediction > LoadFrom< IPrediction >(TDirectory *dir, const std::string &label)
Definition: IPrediction.cxx:18
void FormatErrorBand(TH1 *hplus, TH1 *hminus, bool signal=false, bool fixbins=false)
void ComparePredictionsFromVector(TDirectory *dpred_no, std::vector< TDirectory * > dpred_sh, TString plottitle, TString out_name, bool printtable=true, AxisType pidaxis=kNue1bin)
float bin[41]
Definition: plottest35.C:14
void CompareNDDataOneMC(TDirectory *d_no, TDirectory *d_sh, TString plottitle, TString out_name, TString pidtag, bool printtable=true, AxisType pidaxis=kNue1bin)
Oscillation probability calculators.
Definition: Calcs.h:5
void PrintLatexFigure(TString name, TString plotdir="plots/")
const std::vector< double > & Edges() const
Definition: Binning.h:34
(&#39; survival&#39;)
Definition: IPrediction.h:19
virtual _IOscCalc * Copy() const =0
void CompareNDDataTwoMC(TDirectory *d_no, TDirectory *d_pl, TDirectory *d_mi, TString plottitle, TString out_name, TString pidtag, bool printtable=true, AxisType pidaxis=kNue1bin)
static float min(const float a, const float b, const float c)
Definition: absgeo.cxx:45
TH1F * h1
void FourBinAxis(TH1 *axes, bool third=false, bool shortaxis=false)
TLegend * CustomLegend(std::vector< TH1 * >h, std::vector< bool >isdata, std::vector< TString >title, double x1=kLegendDefaultX1, double y1=kLegendDefaultY1, double x2=kLegendDefaultX2, double y2=kLegendDefaultY2)
TH1 * PrettyRatio(TH1 *shi, TH1 *nom, int color, double alpha=1., TString titley="Shift / Nom")
AxisType
double dmsq32
TCanvas * ExPIDPlot(std::vector< TH1 * > topHistos, std::vector< TString > topOption)
TH1F * hminus
Definition: Xsec_final.C:76
void PrintOscilationParameters(osc::IOscCalc *calc, bool usingdumb)
TH1 * HistNumuOpt(TH1 *orig)
enum BeamMode kViolet
void ComparisonTableNbins(const std::vector< TH1 * > &mcnom, const std::vector< TH1 * > &mcplus, const std::vector< TH1 * > &mcminus, std::vector< TString > labels, TString ltxcommand="", int N=3)
TH1 * RebinToShortAxis(TH1 *h)
const ConstrainedFitVarWithPrior fitSsqTh23_UniformPriorSsqTh23 & kFitSinSqTheta23
Neutral-current interactions.
Definition: IPrediction.h:40
assert(nhit_max >=nhit_nbins)
void PlotNDDataTotalMCComparison(TH1 *hdata, std::vector< TH1 * > htots, TLegend *leg, TString pidtag="", TString out_name="plot_nd", bool ratioplot=false, AxisType pidaxis=kNue1bin)
Both neutrinos and antineutrinos.
Definition: IPrediction.h:52
c1
Definition: demo5.py:24
Standard interface to all prediction techniques.
Definition: IPrediction.h:57
Double_t ymin
Definition: plot.C:24
void Format(TGraph *gr, int lcol, int lsty, int lwid, int mcol, int msty, double msiz)
Definition: Style.cxx:154
const Color_t kTotalMCColor
Definition: Style.h:16
void DefaultFormatNue(DataMCComponets &comp, int linestyle=1)
All neutrinos, any flavor.
Definition: IPrediction.h:26
(&#39; appearance&#39;)
Definition: IPrediction.h:16
TLegend * DefaultNueLegend(bool sig=true, bool tot=true, bool data=false, double x1=kLegendDefaultX1, double y1=kLegendDefaultY1, double x2=kLegendDefaultX2, double y2=kLegendDefaultY2)
bool usedumb
static std::unique_ptr< PredictionNoExtrap > LoadFrom(TDirectory *dir, const std::string &name)
T max(sqlite3 *const db, std::string const &table_name, std::string const &column_name)
Definition: statistics.h:68
const FitVarWithPrior fitDeltaInPiUnits_UniformPriordCP & kFitDeltaInPiUnits
const Color_t kNCBackgroundColor
Definition: Style.h:22
enum BeamMode kBlue
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)
virtual IOscCalc * Copy() const override
Definition: OscCalcDumb.h:19
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)
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"})
const std::string outdir
void PID2DAxis(TH1 *axes, bool third=false, bool shortaxis=false)
void NuePID4bin(TH1 *h, TString pidtag, bool binlabels=true)
enum BeamMode string
unsigned int uint