fd_plot.C
Go to the documentation of this file.
1 
2 #include <fstream>
8 #include "CAFAna/Core/Ratio.h"
11 #include "CAFAna/Core/Spectrum.h"
12 #include "CAFAna/Vars/Vars.h"
13 #include "CAFAna/Analysis/Style.h"
14 #include "CAFAna/Analysis/Plots.h"
15 #include "CAFAna/Analysis/Calcs.h"
19 //#include "3FlavorAna/Ana2017/nue/sidebands/vars.h"
20 #include "./vars.h"
21 
22 using namespace ana;
23 
24 #include "OscLib/IOscCalc.h"
25 #include "OscLib/OscCalcDumb.h"
26 #include "OscLib/OscCalcPMNSOpt.h"
27 
28 #include "TCanvas.h"
29 #include "TColor.h"
30 #include "TFile.h"
31 #include "TH1.h"
32 #include "TGraphAsymmErrors.h"
33 #include "TLegend.h"
34 #include "TPad.h"
35 #include "TLatex.h"
36 
37 #include <iostream>
38 #include <iomanip>
39 //std::ofstream tables;
40 
41 TLegend* Legend(double x0, double y0, double x1, double y1, bool useData, bool smartLeg=false, bool mc=false)
42 { TLegend* leg;
43  if (!smartLeg) {leg = new TLegend(x0, y0, x1, y1);}
44  if (smartLeg) {leg = AutoPlaceLegend(x1-x0,y1-y0,0.6); }
45  // leg->SetFillStyle(0); //for transparent leg bkg
46  leg->SetFillStyle(1001);
47  leg->SetFillColor(kWhite);
48 
49  TH1* dummy = new TH1F("", "", 1, 0, 1);
50  TH1* dummyFill = new TH1F("", "", 1, 0, 1);
51  if(!mc){
52  dummyFill->SetFillColor(kTotalMCErrorBandColor);
53  dummy->SetMarkerStyle(kFullCircle);
54  if( useData) leg->AddEntry(dummy->Clone(), "FD data", "lep");
55  if(!useData) leg->AddEntry(dummy->Clone(), "FD mock data", "lep");
56  dummy->SetLineColor(kViolet-1);
57  leg->AddEntry(dummy->Clone(), "Best Fit prediction", "l");
58  dummy->SetLineColor(kGray+1);
59  FillWithDimColor(dummy);
60  leg->AddEntry(dummy->Clone(), "Total Background", "bf");
61  dummy->SetLineColor(kAzure+1);
62  FillWithDimColor(dummy);
63  leg->AddEntry(dummy->Clone(), "Cosmic Background", "bf");}
64 
65  if(mc){
66  dummy->SetLineColor(kViolet-5);
67  FillWithDimColor(dummy);
68  leg->AddEntry(dummy->Clone(), "signal #nu_{e} CC", "bf");
69  dummy->SetLineColor(kPink+9);
70  FillWithDimColor(dummy);
71  leg->AddEntry(dummy->Clone(), "beam #nu_{e} CC", "bf");
72  dummy->SetLineColor(kAzure);
73  FillWithDimColor(dummy);
74  leg->AddEntry(dummy->Clone(), "NC", "bf");
75  TColor *color4 = new TColor(232, 0.85, 0.75, 0.58);
76  dummy->SetLineColor(kGreen+2);
77  FillWithDimColor(dummy);
78  leg->AddEntry(dummy->Clone(), "#nu_{#mu} CC", "bf");
79  dummy->SetLineColor(kMagenta-9);
80  FillWithDimColor(dummy);
81  leg->AddEntry(dummy->Clone(), "#nu_{#tau} CC", "bf");
82  dummy->SetLineColor(kMagenta+3);
83  FillWithDimColor(dummy);
84  leg->AddEntry(dummy->Clone(), "#bar{#nu}_{e} CC", "bf");
85  dummy->SetLineColor(kAzure+1);
86  FillWithDimColor(dummy);
87  leg->AddEntry(dummy->Clone(), "cosmic", "bf");
88  }
89 
90  return leg;
91 }
92 
93 /*void Preliminary()
94 {
95  TLatex* prelim = new TLatex(.935, .95, "NOvA Preliminary");
96  prelim->SetTextColor(kBlue);
97  prelim->SetNDC();
98  prelim->SetTextSize(2/30.);
99  prelim->SetTextAlign(32);
100  prelim->Draw();
101 }
102 */
103 
104 void fd_plot(std::string fnameMC, std::string fnameCo, std::string fnameDa, std::string fnameRo, bool useData=false)
105 {
106 
107  //tables.open(((TString)"plots/tables_"+(useData?"data":"fake") +".txt").Data(), std::ofstream::out);
108 
109 
110  int start = 0; int end = kNumSels;
111  bool mc = 0; // is it MC or data
112  bool sideband = 0; // is it sideband study or analysis region
113  if(sideband) {end = 6;}
114  if(!sideband) {start = 6;}
115  bool useExtrap = 1; // is it extrapolation with combo decomp or just prediction with no extrap
116 
117 
121  PredictionExtrap* extrapCombo[kNumSels][kNumVars];
123 
124  //osc::OscCalcDumb calc; //don't forget about it
125  auto calc = DefaultOscCalc();
126  calc->SetdCP(1.21*M_PI);
127  calc->SetTh23(asin(sqrt(0.556)));
128  calc->SetDmsq32(2.44e-3);
129  for(int selIdx = 0; selIdx < kNumSels; ++selIdx){
130  const char* selName = selNames[selIdx].c_str();
131  for(int varIdx = 0; varIdx < kNumVars; ++varIdx){
132  const char* varName = defs[varIdx].name.c_str();
133  spectMC[selIdx][varIdx] = LoadFromFile<PredictionNoExtrap>(fnameMC, TString::Format("%s/%s", selName, varName).Data()).release();
134  cosmic[selIdx][varIdx] = LoadFromFile<Spectrum>(fnameCo, TString::Format("%s/cosm_%s", selName, varName).Data()).release();
135  data[selIdx][varIdx] = LoadFromFile<Spectrum>(fnameDa, TString::Format("%s/spect_%s", selName, varName).Data()).release();
136  rock[selIdx][varIdx] = LoadFromFile<PredictionNoExtrap>(fnameRo, TString::Format("%s/rock_%s", selName, varName).Data()).release();
137  extrapCombo[selIdx][varIdx]=LoadFromFile<PredictionExtrap>(fnameMC, TString::Format("%s/%s_extrap_combo", selName, varName).Data()).release();
138  }
139  }
140  TH1* hNue; //signal
141  TH1* hMC; //total MC
142  TH1* hTotbkg; //total sum of all bkg
143  TH1* hbkg; // all bkg except cosmics
144 
145  TH1* hNC; //1
146  TH1* hCC; //2
147  TH1* hBeam; //3
148  TH1* hTau; //4
149  TH1* hCos; //5
150  TH1* hRock; //6 rock events
151  TH1* hNue_bg; //7 wrong sign nue
152 
153  TH1* hData; //data
154  TH1* hFakeData;
155 
156  for(int selIdx = start; selIdx < end; ++selIdx){
157  const std::string selName = selNames[selIdx];
158  for(int varIdx = 0; varIdx < kNumVars; ++varIdx){
159  const char* varName = defs[varIdx].name.c_str();
160  double nonsScale = 1./10.45;
161  double swapScale = 1./12.91;
162  IPrediction* spectMC2 = spectMC[selIdx][varIdx]; // just FD MC
163  auto data1 = data[selIdx][varIdx];
164  auto cosmic1 = cosmic[selIdx][varIdx];
165  auto rock1 = rock[selIdx][varIdx];
166  const double POT=data[selIdx][varIdx]->POT();
167  double Livetime = data[selIdx][varIdx]->Livetime();
168 
169  if(useExtrap) {
170  if(varIdx==0){
171  auto noextrap = spectMC[selIdx][varIdx];
172  spectMC2 = new PredictionExtendToPeripheral(extrapCombo[selIdx][varIdx],noextrap);
173  rock1 = rock[selIdx][21];
174  data1 = data[selIdx][21];
175  cosmic1 = cosmic[selIdx][21];
176  }
177  else {auto spectMC2 = extrapCombo[selIdx][varIdx]; cout<<"hi"<<endl;}
178  }
179  auto spectMC1 = new PredictionAddRock(spectMC2, rock1, nonsScale, swapScale); //with rock events
180  hNue = spectMC1->PredictComponent(calc, Flavors::kNuMuToNuE, Current::kCC, Sign::kNu).ToTH1(POT); //signal
181  hNue_bg = spectMC1->PredictComponent(calc, Flavors::kNuMuToNuE, Current::kCC, Sign::kAntiNu).ToTH1(POT); //wrong sign bkg (1)
182  hTau = spectMC1->PredictComponent(calc, Flavors::kAllNuTau, Current::kCC, Sign::kBoth).ToTH1(POT); // tau CC bkg (2)
183  hBeam = spectMC1->PredictComponent(calc, Flavors::kNuEToNuE, Current::kCC, Sign::kBoth).ToTH1(POT); // beam bkg (3)
184  hNC = spectMC1->PredictComponent(calc, Flavors::kAll, Current::kNC, Sign::kBoth).ToTH1(POT); // NC bkg (4)
185  hCC = spectMC1->PredictComponent(calc, Flavors::kAllNuMu, Current::kCC, Sign::kBoth).ToTH1(POT); // numu CC bkg (5)
186  hMC = spectMC1->Predict(calc).ToTH1(POT);
187 
188  bool useScales = !useExtrap && true; //flat scaling to mimic the extrap
189  if(useScales){
190  std::cout << "Rescaling MC components to Extrap/No Extrap TODO";
191  hMC->Scale(57.5/57.1);
192  hNue->Scale(42.2/43.1);
193  hBeam->Scale(7.09/7.03);
194  hNC->Scale(6.62/5.52);
195  hCC->Scale(1.1/1.0);
196  hTau->Scale(0.446/0.446);
197  hNue_bg->Scale(1.0/1.0);
198  }
199  hTotbkg = (TH1*)hNue_bg->Clone(UniqueName().c_str());
200  hTotbkg->Add(hTau);
201  hTotbkg->Add(hBeam);
202  hTotbkg->Add(hNC);
203  hTotbkg->Add(hCC);
204 
205  hTotbkg->SetLineColor(kGray+1);
206  FillWithDimColor(hTotbkg);
207  hMC->SetLineColor(kViolet-1);
208  hRock = spectMC1->Predict(calc).ToTH1(POT);
209  TH1* hJustMC = spectMC2->Predict(calc).ToTH1(POT);
210  hRock->Add(hJustMC, -1); // just rock events (bkg?)
211  cout<<Livetime<<endl;
212  hCos = cosmic1->ToTH1(Livetime, kGray+1, kSolid, ana::EExposureType::kLivetime); //cosmic bkg (6)
213  cout<<hCos->Integral()<<endl;
214  hbkg = (TH1D*) hTotbkg->Clone(UniqueName().c_str());
215  hTotbkg->Add(hCos);
216  hMC->Add(hCos);
217  hCos->SetLineColor(kAzure+1);
218  FillWithDimColor(hCos);
219  if(!mc) {hData = data1->ToTH1(Livetime, kBlack, kSolid, ana::EExposureType::kLivetime);
220  if(!useData) {
221  std::cout << "\n\nWARNING useData=false; plotting mock data\n\n";
222  hData = spectMC1->Predict(calc).ToTH1(POT,kBlack,kSolid);
223  hData->Add(hCos);
224  Spectrum temp (hData,POT,0);
225  hData = temp.MockData(POT).ToTH1(POT);
226  }}
227 
228 /* for (auto &h:{hData, hMC, hNue, hbkg, hCos}){
229  std::cout<<" 1 bin " << h->Integral(1,9) << std::endl;
230  std::cout<<" 2 bin " << h->Integral(10,18) << std::endl;
231  std::cout<<" 3 bin " << h->Integral(19,27) << std::endl;
232  std::cout<<" periph " << h->Integral(28, 36) << std::endl;
233  std::cout<<" all " << h->Integral() << std::endl;
234  }
235 */
236  //HACK HACK HACK
237  if((varIdx==2 || varIdx==20 )&& selIdx==4){
238  for(auto &h:{hNue,hbkg,hTotbkg,hCos,hMC}){
239  if(varIdx==2) h->Rebin(10);
240  if(varIdx==20) h->Rebin(15);
241  }
242  if(!mc) {if(varIdx==2) hData->Rebin(10);
243  if(varIdx==20) hData->Rebin(15);}
244  }
245 
246  if(!mc) {hData->SetMarkerStyle(kFullCircle);}
247 
248  int rebin = 1;
249  if (selIdx == 6 && varIdx == 2) {rebin = 2;}
250  if (varIdx==20) {rebin = 3;}
251  if (varIdx==19 || varIdx==6 || varIdx==7 || varIdx==8) {rebin = 4;}
252  if (varIdx==11 || varIdx==12 || varIdx==13 || varIdx==14 || varIdx==15 || varIdx==16 || varIdx==17) {rebin = 10;}
253  if (!mc) {hData->Rebin(rebin);}
254  for (auto &h:{hMC, hNue, hbkg, hTotbkg, hNue_bg, hNC, hCC, hBeam, hTau, hRock, hCos}){
255  h->Rebin(rebin);
256  }
257  // if(varIdx==0) {cout<<"MC "<<hMC->Integral()<< " signal "<<hNue->Integral()<<" total beam "<<hbkg->Integral()<<" cosmic "<<hCos->Integral()<<endl;}
258  cout<<"MC "<<hMC->Integral()<< " signal "<<hNue->Integral()<<" total beam "<<hbkg->Integral()<<" cosmic "<<hCos->Integral()<<"rock "<<hRock->Integral()<<endl;
259  //Print results
260 /*
261  std::cout <<"============== Information =============="<<std::endl;
262  std::cout << "\nSelection " << selName << "; Variable " << varName
263  << (useExtrap?"; Extrap.":";No Extrap.\n")
264  << "Compare data to prediction - dumb oscillations"
265  << std::endl;
266  std::cout << "Components including rock\n"
267  << "Nue Antinue Beam NC Numu NuTau Total Rock-only\n";
268  for (auto &h:{hNue,hNue_bg,hBeam,hNC,hCC,hTau,hbkg,hRock}){
269  std::cout << h->Integral() << "\t";
270  }
271  TString ltxcommand = selName+varName; ltxcommand.ReplaceAll("_","");
272  TString shname = selName+" " + varName; shname.ReplaceAll("_"," ");
273  shname.ReplaceAll (" custom","");
274  if(varIdx==2 || varIdx==3 || varIdx==4 || varIdx==20 || varIdx==0 || varIdx==1 || varIdx==21 || varIdx==22){
275  tables << "\n\\newcommand{\\" << ltxcommand << (useData?"data":"fake")
276  << "}\n{\\centerline{";
277  tables << "\n\\begin{tabular}{p{7em}|rrr|rr}\n";
278  tables << "& \t Signal \t & \t " << "Bkg. \t & \t" << "Cosmic \t & \t"
279  << "Total \t & \t" << (useData?"Data":"FakeData") << "\t \\\\ \\hline \n";
280  tables <<shname;
281  for (auto &h:{hNue,hbkg,hCos,hMC,hData}){
282  tables << std::setprecision(3);
283  tables << "\t & \t" <<h->Integral();
284  }
285  tables << "\\end{tabular}\n}\n}\n"<<std::endl;
286  }
287  std::cout <<"============== And that's it =============="<<std::endl;
288 */
289  hMC->SetMaximum(1.1*hMC->GetMaximum());
290  if(!mc) {int n = hData->GetNbinsX();
291  for (int i=1; i<= n; i++) {if(hMC->GetBinContent(i) == 0) hData->SetBinContent(i,-1);}
292  double mult = 1.2;
293  if (varIdx==0) {mult = 1.13;}
294  if ( varIdx==7 || varIdx==8) {mult = 1.6;}
295  if (varIdx==6) {mult = 1.8;}
296  hMC->SetMaximum(mult*max(hMC->GetMaximum(),(hData->GetMaximum()+sqrt(hData->GetMaximum()))));}
297  hMC->GetXaxis()->CenterTitle();
298  if (varIdx==1) {hMC->GetXaxis()->SetRange(1,12);}
299  if (varIdx==5) {hMC->GetXaxis()->SetRange(1,20);}
300  if (selIdx==6 && varIdx==2) {hMC->GetXaxis()->SetRange(50.0/rebin+1,100.0/rebin);}
301  hMC->GetYaxis()->CenterTitle();
302  hMC->GetYaxis()->SetTitleOffset(1.15);
303  hMC->GetYaxis()->SetTitle("Events / 8.85 #times 10^{20} POT-equiv");
304  if(varIdx == 6){hMC->GetXaxis()->SetTitle("Vertex X (cm)");}
305  if(varIdx == 7){hMC->GetXaxis()->SetTitle("Vertex Y (cm)");}
306  if(varIdx == 8){hMC->GetXaxis()->SetTitle("Vertex Z (cm)");}
307  if(varIdx == 19){hMC->GetXaxis()->SetTitle("p_{T}/p");}
308  if(varIdx == 20){hMC->GetXaxis()->SetRange(1,80/rebin);}
309  //if (varIdx==0) cout<<hCos->GetBinContent(30)<<" "<<hNue->GetBinContent(30)<<" "<<hMC->GetBinContent(30)<<" "<<hTotbkg->GetBinContent(30)<<endl;
310  //if (varIdx==0) cout<<hCos->GetBinContent(30)<<" "<<hNue->GetBinContent(30)<<" "<<hMC->GetBinContent(30)<<" "<<hTotbkg->GetBinContent(30)<<endl;
311  //if (varIdx==2) cout<<hCos->GetBinContent(38,50)<<" "<<hNue->GetBinContent(38,50)<<" "<<hMC->Integral(38,50)<<" "<<hTotbkg->Integral(38,50)<<endl;
312  TCanvas *c =new TCanvas("c","c",1000,800);
313  c->SetLeftMargin(0.15);
314  c->SetRightMargin(0.05);
315 
316  gPad->SetFillStyle(0);
317  if(mc){
318 /* hMC->SetLineColor(kPink-3);
319  FillWithDimColor(hMC);
320  hMC->Draw("hist");
321  hTotbkg->SetLineColor(kMagenta+3);
322  FillWithDimColor(hTotbkg);
323  hTotbkg->Draw("hist same");//beam
324  TH1* wobeam = (TH1*)hTotbkg->Clone(UniqueName().c_str());
325  wobeam->SetLineColor(kYellow-9);
326  FillWithDimColor(wobeam);
327  wobeam->Add(hBeam,-1);
328  wobeam->Draw("hist same");//nc
329  TH1* wonc = (TH1*)wobeam->Clone(UniqueName().c_str());
330  wonc->SetLineColor(kRed+1);
331  FillWithDimColor(wonc);
332  wonc->Add(hNC,-1);
333  wonc->Draw("hist same");//cc
334  TH1* wocc = (TH1*)wonc->Clone(UniqueName().c_str());
335  wocc->SetLineColor(kGreen+3);
336  FillWithDimColor(wocc);
337  wocc->Add(hCC,-1);
338  wocc->Draw("hist same");//tau
339  TH1* wotau = (TH1*)wocc->Clone(UniqueName().c_str());
340  wotau->SetLineColor(kMagenta);
341  FillWithDimColor(wotau);
342  wotau->Add(hTau,-1);
343  wotau->Draw("hist same");//nue wrong sign
344  TH1* wown = (TH1*)wotau->Clone(UniqueName().c_str());
345  wown->SetLineColor(kGray);
346  FillWithDimColor(wown);
347  wown->Add(hNue_bg,-1);
348  wown->Draw("hist same");//rock
349  TH1* worock = (TH1*)wown->Clone(UniqueName().c_str());
350  worock->SetLineColor(kAzure+1);
351  FillWithDimColor(worock);
352  wown->Add(hRock,-1);
353  worock->Draw("hist same");//cosmic
354 */
355  hMC->SetLineColor(kViolet-5);//kNueSignalColor = kViolet-5 violet-1 - norm
356  FillWithDimColor(hMC);
357  hMC->Draw("hist");
358  hTotbkg->SetLineColor(kAzure);//kNCBackgroundColor=kAzure +2
359  FillWithDimColor(hTotbkg);
360  hTotbkg->Draw("hist same");//nc
361  TH1* wonc = (TH1*)hTotbkg->Clone(UniqueName().c_str());
362  wonc->SetLineColor(kPink+9);//kBeamNueBackgroundColor = kPink+9
363  FillWithDimColor(wonc);
364  wonc->Add(hNC,-1);
365  wonc->Draw("hist same");//beam nue
366  TH1* wobeam = (TH1*)wonc->Clone(UniqueName().c_str());
367  wobeam->SetLineColor(kGreen+2);//kNumuBackgroundColor = kGreen+2
368  FillWithDimColor(wobeam);
369  wobeam->Add(hBeam,-1);
370  wobeam->Draw("hist same");//numucc
371  TH1* wocc = (TH1*)wobeam->Clone(UniqueName().c_str());
372  wocc->SetLineColor(kMagenta-9);
373  FillWithDimColor(wocc);
374  wocc->Add(hCC,-1);
375  wocc->Draw("hist same");//tau
376  TH1* wotau = (TH1*)wocc->Clone(UniqueName().c_str());
377  wotau->SetLineColor(kMagenta+3);
378  FillWithDimColor(wotau);
379  wotau->Add(hTau,-1);
380  wotau->Draw("hist same");//nue wrong sign
381  TH1* wown = (TH1*)wotau->Clone(UniqueName().c_str());
382  wown->SetLineColor(kGray);
383  FillWithDimColor(wown);
384  wown->Add(hNue_bg,-1);
385  wown->Draw("hist same");//rock
386  TH1* worock = (TH1*)wown->Clone(UniqueName().c_str());
387  worock->SetLineColor(kAzure+1);
388  FillWithDimColor(worock);
389  wown->Add(hRock,-1);
390  worock->Draw("hist same");//cosmic
391  }
392  if(!mc) {
393  hMC->Draw("hist");
394  hTotbkg->Draw("hist same");
395  hCos->Draw("hist same");
396  hMC->Draw("hist same");
397  TGraphAsymmErrors* gr = GraphWithPoissonErrors(hData, false, true);
398  gr->SetMarkerStyle(kFullCircle);
399  gr->SetLineWidth(2);
400  gr->Draw("ep same");}
401 
402  //Preliminary();
403 
404  double legendxlow=0.2;
405  double legendxhigh=0.5;
406  double legendylow=0.5;
407  double legendyhigh=0.7;
408  bool marker = true;
409 
410  if (varIdx==0) { marker = false; legendxlow=0.2; legendxhigh=0.55; legendylow=0.6; legendyhigh=0.8; }
411  if (selIdx == 5 && varIdx == 4 || selIdx == 4 && varIdx == 20 || selIdx == 4 && varIdx == 2 || selIdx == 0 && varIdx == 3 || selIdx == 0 && varIdx == 4 ||
412  selIdx == 2 && varIdx == 3) { marker = false; legendxlow=0.17; legendxhigh=0.465; legendylow=0.6; legendyhigh=0.8; }
413  if (varIdx==20) { marker = false; legendxlow=0.2; legendxhigh=0.5; legendylow=0.6; legendyhigh=0.8; }
414  if (varIdx==21) { marker = false; legendxlow=0.2; legendxhigh=0.5; legendylow=0.5; legendyhigh=0.7; }
415  if (mc) {legendylow=0.5; legendyhigh=0.8;}
416  gPad->Update();
417  auto leg = Legend(legendxlow, legendylow, legendxhigh, legendyhigh, useData, marker, mc);
418  leg->SetTextSize(hMC->GetXaxis()->GetLabelSize());
419  leg->Draw();
420 
421  if(varIdx == 0){
422  Nue2017FourBinDivisions(kBlack, 3);
423  Nue2017FourBinLabels(0.98, 0.04, kGray+3, true);
424  Nue2017FourBinAxis(hMC,true, true);
425  }
426  leg->Draw();
427 
428  if (selName=="Peripheral") {auto *tt = new TText(gPad->GetUxmin(), gPad->GetUymax() * 1.05,"Peripheral Sample");
429  tt->Draw();}
430  if (selName=="Core") {auto *tt = new TText(gPad->GetUxmin(), gPad->GetUymax() * 1.05 ,"Core Sample");
431  tt->Draw();}
432  if (selName=="Presel") {auto *tt = new TText(gPad->GetUxmin(), gPad->GetUymax() * 1.05 ,"Preselection cut tier");
433  tt->Draw();}
434  c->Update();
435  if (selIdx == 5) { auto *tt = new TText(gPad->GetUxmin(), gPad->GetUymax() * 1.02 ,"High Energy Sideband (Core)"); tt->SetTextSize(0.03); tt->Draw();}
436  if (selIdx == 4) { auto *tt = new TText(gPad->GetUxmin(), gPad->GetUymax() * 1.02 ,"Low PID Sideband (Core)"); tt->SetTextSize(0.03); tt->Draw();}
437  if (selIdx == 0) { auto *tt = new TText(gPad->GetUxmin(), gPad->GetUymax() * 1.01 ,"High Energy, low PID Sideband (Peripheral)"); tt->SetTextSize(0.03); tt->Draw(); }
438  if (selIdx == 2) { auto *tt = new TText(gPad->GetUxmin(), gPad->GetUymax() * 1.02 ,"Low PID Sideband (Peripheral)"); tt->SetTextSize(0.03); tt->Draw();}
439 
440  gPad->RedrawAxis();
441  c->Update();
442 
443  if(sideband){
444  ofstream caption(("plots/sideband/" + selName + "_" + varName + ".txt").c_str());
445  caption<<selName<<" cut applied, sideband data/prediction study, with extrapolation from the ND and combo decomposition, 2017 Best Fit oscillation parameters.";
446  c->Print(("plots/sideband/" + selName + "_" + varName + ".pdf").c_str());}
447  if(mc) {
448  ofstream caption(("plots/fdmc/fdmc_" + selName + "_" + varName + ".txt").c_str());
449  caption<<selName<<" cut applied, FDMC with extrapolation from the ND and combo decomposition, 2017 Best Fit oscillation parameters.";
450  c->Print(("plots/fdmc/fdmc_" + selName + "_" + varName + ".pdf").c_str());}
451  if(useExtrap & !mc & !sideband) {
452  ofstream caption(("plots/extrap/decomp_" + selName + "_" + varName + (useData?"_data":"_fake") + ".txt").c_str());
453  caption<<selName<<" cut applied, data/prediction comparisons, with extrapolation from the ND and combo decomposition, 2017 Best Fit oscillation parameters.";
454  c->Print(("plots/extrap/decomp_" + selName + "_" + varName + (useData?"_data":"_fake") + ".pdf").c_str());}
455  // else c->Print(("plots/" + selName + "_" + varName + (useData?"_data":"_fake") + ".pdf").c_str());
456 
457  }//end var
458  }//end selection
459 }
void Nue2017FourBinLabels(const double yNDC, const double textsize, const int color, const bool merged)
void Nue2017FourBinAxis(TH1 *axes, bool drawLabels, bool merged)
const int kNumVars
Definition: vars.h:14
Cuts and Vars for the 2020 FD DiF Study.
Definition: vars.h:6
Antineutrinos-only.
Definition: IPrediction.h:50
Float_t y1[n_points_granero]
Definition: compare.C:5
(&#39; appearance&#39;)
Definition: IPrediction.h:18
TH1D * ToTH1(double exposure, Color_t col=kBlack, Style_t style=kSolid, EExposureType expotype=kPOT, EBinType bintype=kBinContent) const
Histogram made from this Spectrum, scaled to some exposure.
Definition: Spectrum.cxx:148
virtual Spectrum Predict(osc::IOscCalc *calc) const =0
Float_t x1[n_points_granero]
Definition: compare.C:5
(&#39;beam &#39;)
Definition: IPrediction.h:15
TLegend * Legend(double x0, double y0, double x1, double y1, bool useData, bool smartLeg=false, bool mc=false)
Definition: fd_plot.C:41
T sqrt(T number)
Definition: d0nt_math.hpp:156
std::string name
Definition: NuePlotLists.h:12
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
#define M_PI
Definition: SbMath.h:34
Spectrum MockData(double pot, int seed=0) const
Mock data is FakeData with Poisson fluctuations applied.
Definition: Spectrum.cxx:300
Representation of a spectrum in any variable, with associated POT.
Definition: Spectrum.h:40
const XML_Char const XML_Char * data
Definition: expat.h:268
Definition: type_traits.h:56
Charged-current interactions.
Definition: IPrediction.h:39
Sum up livetimes from individual cosmic triggers.
const HistDef defs[kNumVars]
Definition: vars.h:15
const int kNumSels
Definition: vars.h:43
double POT() const
Definition: Spectrum.h:227
void fd_plot(std::string fnameMC, std::string fnameCo, std::string fnameDa, std::string fnameRo, bool useData=false)
Definition: fd_plot.C:104
Neutrinos-only.
Definition: IPrediction.h:49
OStream cout
Definition: OStream.cxx:6
std::vector< double > POT
enum BeamMode kViolet
Neutral-current interactions.
Definition: IPrediction.h:40
Both neutrinos and antineutrinos.
Definition: IPrediction.h:52
Standard interface to all prediction techniques.
Definition: IPrediction.h:57
TLegend * AutoPlaceLegend(double dx, double dy, double yPin)
Create a legend, maximizing distance from all histograms.
Definition: Plots.cxx:715
void Format(TGraph *gr, int lcol, int lsty, int lwid, int mcol, int msty, double msiz)
Definition: Style.cxx:154
void Nue2017FourBinDivisions(const int color, const int style)
Prediction that just uses FD MC, with no extrapolation.
Take the output of an extrapolation and oscillate it as required.
All neutrinos, any flavor.
Definition: IPrediction.h:26
const std::string selNames[kNumSels]
Definition: vars.h:46
Float_t e
Definition: plot.C:35
T max(sqlite3 *const db, std::string const &table_name, std::string const &column_name)
Definition: statistics.h:68
enum BeamMode kGreen
double Livetime() const
Seconds. For informational purposes only. No calculations use this.
Definition: Spectrum.h:230
std::string UniqueName()
Return a different string each time, for creating histograms.
Definition: Utilities.cxx:29
void FillWithDimColor(TH1 *h, bool usealpha, float dim)
void rock(std::string suffix="full")
Definition: rock.C:28
T asin(T number)
Definition: d0nt_math.hpp:60
TH1F * hbkg
Definition: Xdiff_gwt.C:58
enum BeamMode string