PlotSpectra.C
Go to the documentation of this file.
2 
3 void PlotSpectra(TString spectraFileName, TString opt){
4 
5  TFile* spectraFile = new TFile(spectraFileName, "read");
6 
8 
9  if (opt.Contains("nd", TString::kIgnoreCase))
10  LoopHistograms(spectraFile, kNear);
11  if (opt.Contains("fd", TString::kIgnoreCase))
12  LoopHistograms(spectraFile, kFar);
13 
14 }
15 
16 void LoopHistograms(TFile* spectraFile, Detector thisDet){
17 
18  // load
19  TFile* covmx = new TFile("/pnfs/nova/persistent/analysis/nux/nus20/selection/covmx.root", "read");
20  TMatrixD* cov = (TMatrixD*)covmx->Get("fraccovmx");
21 
24 
25  int ndBins = 20;
26  int fdBins = 13;
27  std::vector<double> fulldecorrelatedunc =
29  ndBins,
30  fdBins);
31 
32  // separate into nd and fd
33  for (size_t i = 0; i < fulldecorrelatedunc.size(); ++i){
34  if ((int)i < ndBins)
35  ndFractionalUncertainties.push_back(fulldecorrelatedunc[i]);
36  else
37  fdFractionalUncertainties.push_back(fulldecorrelatedunc[i]);
38  }
39 
40  if ((int)ndFractionalUncertainties.size() != ndBins ||
41  (int)fdFractionalUncertainties.size() != fdBins)
42  throw std::logic_error("FractionalUncertainties vector is incorrect size");
43 
44  if (thisDet == kNear){
45  dirName = "ND";
46  vars = varsND;
47  cuts = cutsND;
49  }
50  else if (thisDet == kFar){
51  dirName = "FD";
52  vars = varsFD;
53  cuts = cutsFD;
55  }
56  else {
57  throw std::logic_error("options for detector are nd or fd");
58  }
59 
60  histMCTotal ->Sumw2();
61  histMCSignal ->Sumw2();
62  histMCSignalNoCut->Sumw2();
63  histCosmic ->Sumw2();
64 
65  // loop over every cut level and variable we want to plot
66  for (size_t iCut = 0; iCut < cuts.size(); ++iCut){
67 
68  for (size_t iVar = 0; iVar < vars.size(); ++iVar){
69 
70  std::cout << dirName << " " << vars.at(iVar).name << " " << cuts.at(iCut).name << std::endl;
71  std::string histPathPre = dirName + "/" + vars.at(iVar).name;
72  std::string histPath = histPathPre + cuts.at(iCut).name;
73 
74  // figure out whether we want to plot data for this histogram
75  bool isPlotData = PlotData(histPath);
76 
77  InitialiseHistograms(spectraFile, thisDet, iCut, iVar, dirName, histPathPre, histPath);
78 
79  // print POT-normalised simulation information
80  PrintSelectedEvents(iCut, iVar);
81 
82  // define boxes
83  InitialiseFOMHists(thisDet, iCut, iVar);
84  DrawFOM(std::set<FomType>(), iVar); // need a vector of FomTypes if you want to draw these
85 
86  std::cout << "isPlotData: " << isPlotData << std::endl;
87  // plot histograms
88  if (isPlotData)
89  DrawDataMC(thisDet, iCut, iVar, false, false, true); // area normalised right now
90  DrawMCOnly(thisDet, iCut, iVar, false, false);
91  if (thisDet == kFar){
92  DrawMCOnly(thisDet, iCut, iVar, false, true);
93  DrawMCOnly(thisDet, iCut, iVar, true, true);
94  DrawIndependentSpectra(thisDet, iCut, iVar);
95  }
96  }
97  }
98 }
99 
100 //-----------------------------------------------------------------------------
102  bool isBeamData, bool isCosmic, bool isTotal){
103 
104  if (isBeamData){
105  h->SetMarkerStyle(20);
106  h->SetMarkerSize(0.6);
107  }
108  else {
109  if (det == kNear){
110  if (isTotal){
111  h->SetLineColor(kBlack);
112  h->SetLineWidth(2);
113  }
114  else {
115  h->SetFillColor(kAzure+2);
116  h->SetLineColor(kAzure+2);
117  }
118  }
119  if (det == kFar){
120  if (isTotal){
121  h->SetLineColor(kBlack);
122  h->SetLineWidth(2);
123  }
124  else if(isCosmic){
125  h->SetFillColor(kOrange-3);
126  h->SetLineColor(kOrange-3);
127  }
128  else {
129  h->SetFillColor(kAzure+2);
130  h->SetLineColor(kAzure+2);
131  }
132  }
133  if (det == kNear){
134  h->GetYaxis()->SetTitle("10^{4} Events");
135  }
136  }
137 
138  h->GetXaxis()->CenterTitle();
139  h->GetXaxis()->SetTitleFont(43);
140  h->GetXaxis()->SetTitleSize(28);
141  h->GetYaxis()->CenterTitle();
142  h->GetYaxis()->SetTitleFont(43);
143  h->GetYaxis()->SetTitleSize(28);
144 
145  h->GetXaxis()->SetLabelFont(43);
146  h->GetXaxis()->SetLabelSize(28);
147  h->GetYaxis()->SetLabelFont(43);
148  h->GetYaxis()->SetLabelSize(28);
149 
150  h->GetYaxis()->SetMaxDigits(3);
151  h->GetYaxis()->SetTitleOffset(1.3);
152  h->GetYaxis()->SetNdivisions(515);
153 
154  NOvACornerLabel("Neutrino Beam");
155  NOvAPreliminarySide();
156  if (det == kNear)
157  NOvADetector("Near Detector");
158  else
159  NOvADetector("Far Detector");
160  NOvAPOT("14.23");
161 
162  // Thicker lines
163  gStyle->SetHistLineWidth(2);
164  gStyle->SetFrameLineWidth(2);
165  gStyle->SetFuncWidth(2);
166 
167  // Set the number of tick marks to show
168  gStyle->SetNdivisions(506, "xyz");
169 
170  // Set the tick mark style
171  gStyle->SetPadTickX(1);
172  gStyle->SetPadTickY(1);
173 
174  // Fonts
175  const int kNovaFont = 42;
176  gStyle->SetStatFont(kNovaFont);
177  gStyle->SetLabelFont(kNovaFont, "xyz");
178  gStyle->SetTitleFont(kNovaFont, "xyz");
179  gStyle->SetTitleFont(kNovaFont, ""); // Apply same setting to plot titles
180  gStyle->SetTextFont(kNovaFont);
181  gStyle->SetLegendFont(kNovaFont);
182 
183 }
184 
185 //-----------------------------------------------------------------------------
186 void SetupCanvas(TPad* topPad, TPad* botPad, TPad* thisPad){
187  cRatio->cd();
188  topPad->SetTopMargin(0.1);
189  topPad->SetBottomMargin(0.005);
190  topPad->SetLeftMargin(0.12);
191  botPad->SetTopMargin(0.005);
192  botPad->SetBottomMargin(0.35);
193  botPad->SetLeftMargin(0.12);
194  topPad->Draw();
195  botPad->Draw();
196 
197  cNoRatio->cd();
198  thisPad->SetTopMargin(0.1);
199  thisPad->SetBottomMargin(0.15);
200  thisPad->SetLeftMargin(0.12);
201  thisPad->Draw();
202 }
203 
204 
205 
206 //-----------------------------------------------------------------------------
208 
209  if (name.find("FD") != std::string::npos)
210  return false;
211  else if (
212  (name.find("CVN") == std::string::npos &&
213  name.find("CaloE") == std::string::npos) ||
214  (name.find("CVN") != std::string::npos &&
215  name.find("Fiducial") != std::string::npos) ||
216  (name.find("CVN") != std::string::npos &&
217  name.find("FullSelection") != std::string::npos) ||
218  (name.find("CaloE") != std::string::npos &&
219  name.find("FullSelection") != std::string::npos))
220  return true;
221  else return false;
222 }
223 
224 //-----------------------------------------------------------------------------
225 void StyleLegend(TLegend* leg){
226  leg->SetLineWidth(0);
227  leg->SetFillStyle(0);
228  leg->SetTextFont(43);
229  leg->SetTextSize(28*0.75);
230 }
231 
232 //-----------------------------------------------------------------------------
233 void DrawBoxes(TH1D* histMCTotal, std::vector<double> theseCuts, CutSide thisCutSide){
234 
235  TBox* box = new TBox(-5000, -5000, -5000, -5000);
236  TBox* box2 = new TBox(-5000, -5000, -5000, -5000);
237 
238  box->SetY1(0);
239  box->SetY2(histMCTotal->GetMaximum());
240  if (thisCutSide == kLow){
241  box->SetX1(histMCTotal->GetBinLowEdge(1));
242  box->SetX2(theseCuts.at(0));
243  }
244  if (thisCutSide == kHigh){
245  box->SetX1(theseCuts.at(0));
246  box->SetX2(histMCTotal->GetBinLowEdge(histMCTotal->GetNbinsX()+1));
247  }
248  if (thisCutSide == kBoth){
249  box->SetX1(histMCTotal->GetBinLowEdge(1));
250  box->SetX2(theseCuts.at(0));
251  box2->SetX1(theseCuts.at(1));
252  box2->SetX2(histMCTotal->GetBinLowEdge(histMCTotal->GetNbinsX()+1));
253  box2->SetLineWidth(0);
254  box2->SetFillColorAlpha(kGray, 0.4);
255  box2->SetY1(0);
256  box2->SetY2(histMCTotal->GetMaximum());
257  box2->Draw("same");
258  }
259  box->SetLineWidth(0);
260  box->SetFillColorAlpha(kGray, 0.4);
261  if (theseCuts.at(0) != 0 || theseCuts.size() > 1)
262  box->Draw("same");
263 
264  gPad->RedrawAxis();
265  gPad->Modified();
266 
267 }
268 
269 //-----------------------------------------------------------------------------
270 void DrawRatio(TPad* thisPad, TH1D* mc, TH1D* data){
271 
272  thisPad->cd();
273  thisPad->SetGridy();
274  TH1D* rat = (TH1D*)data->Clone("rat");
275  rat->Divide(mc);
276  rat->GetYaxis()->SetRangeUser(0.7, 1.29);
277  rat->GetYaxis()->SetNdivisions(505);
278  rat->GetYaxis()->SetTitle("Data/Sim");
279  rat->GetYaxis()->SetTitleOffset(1.3);
280  rat->GetXaxis()->SetTitleOffset(3.0);
281 
282  rat->Draw("p");
283 
284 }
285 
286 //-----------------------------------------------------------------------------
287 void GetFractionalUncertainties(TFile* covmx,
288  std::vector<float>* nd,
289  std::vector<float>* fd){
290 
291  int ndBins = 20;
292  int fdBins = 13;
293 
294  TMatrixD* cov = (TMatrixD*)covmx->Get("fraccovmx");
295  //TMatrixD* cov = (TMatrixD*)covmx->Get("decorrerr");
296 
297  for (int i =0; i < cov->GetNrows(); ++i){
298  if (i < ndBins){
299  nd->push_back(std::sqrt((*cov)(i,i)));
300  }
301  else {
302  fd->push_back(std::sqrt((*cov)(i,i)));
303  }
304  }
305 }
306 
307 //-----------------------------------------------------------------------------
308 void InitialiseFOMHists(Detector thisDet, int iVar, int iCut){
309  // setup FOM histograms
310  EffTimesPurHist = (TH1D*)getFOMHist("EffTimesPur"+dirName+vars.at(iVar).name+cuts.at(iCut).name,
311  vars.at(iVar).cutside,
313  histMCTotal,
314  histMCSignal,
316 
317  SOverSBHist = (TH1D*)getFOMHist("SOverSB"+dirName+vars.at(iVar).name+cuts.at(iCut).name,
318  vars.at(iVar).cutside,
320  histMCTotal,
321  histMCSignal,
323 
324 
325  BinnedSOverSSBSystHist = (TH1D*)getFOMHist("BinnedSOverSSBSyst"+dirName+vars.at(iVar).name+cuts.at(iCut).name,
326  vars.at(iVar).cutside,
328  histMCTotal,
329  histMCSignal,
334 
335  SOverSSBHist = (TH1D*)getFOMHist("SOverSSB"+dirName+vars.at(iVar).name+cuts.at(iCut).name,
336  vars.at(iVar).cutside,
338  vars.at(iVar).name.find("CosRej") != std::string::npos ? histTotal : histMCTotal,
339  histMCSignal,
343  {});
344 
345  // style histograms
347  vars.at(iVar).name.find("CosRej") != std::string::npos ? histTotal->GetMaximum(): histMCTotal->GetMaximum());
348 
349 }
350 
351 //-----------------------------------------------------------------------------
352 void DrawFOM(std::set<FomType> fomTypes, int iVar){
353 
354  if (fomTypes.size() == 0) return;
355 
356  if ((vars.at(iVar).name.find("CVN") != std::string::npos) ||
357  vars.at(iVar).name.find("HitsPerPlane") != std::string::npos ||
358  vars.at(iVar).name.find("NSliceHits") != std::string::npos ||
359  vars.at(iVar).name.find("PartPtp") != std::string::npos){
360 
361  TLegend* fomleg = new TLegend(0.5, 0.7, 0.85, 0.89);
362  if (fomTypes.count(kEffTimesPurity)){
363  EffTimesPurHist->Draw("same hist");
364  fomleg->AddEntry(EffTimesPurHist , "Eff. #times Pur.");
365  }
366  if (fomTypes.count(kSOverSB)){
367  SOverSBHist->Draw("same hist");
368  fomleg->AddEntry(SOverSBHist , "S / #sqrt{B}" );
369  }
370  if (fomTypes.count(kSOverSSB)){
371  SOverSSBHist->Draw("same hist");
372  fomleg->AddEntry(SOverSSBHist , "S / #sqrt{S+B+#sigma^{2}}");
373  }
374 
375  StyleLegend(fomleg);
376 
377  fomleg->Draw("same");
378  }
379 }
380 
381 //-----------------------------------------------------------------------------
382 void PrintSelectedEvents(int iCut, int iVar)
383 {
384  std::cout << "---------------------------------" << std::endl;
385  std::cout << " Printing selected events" << std::endl;
386  std::cout << " Stage/Var: " << cuts.at(iCut).name << "/" << vars.at(iVar).name << std::endl;
387  std::cout << " -- Total Events selected: " << histTotal ->Integral(0, histTotal->GetNbinsX()+1) << std::endl;
388  std::cout << " -- Total Signal selected: " << histMCSignal->Integral(0, histTotal->GetNbinsX()+1) << std::endl;
389  std::cout << " -- Total mc bgs selected: " << histMCBg ->Integral(0, histTotal->GetNbinsX()+1) << std::endl;
390  if (histCosmic != nullptr)
391  std::cout << " -- Total Cosmic selected: " << histCosmic->Integral(0, histTotal->GetNbinsX()+1) << std::endl;
392  std::cout << "---------------------------------" << std::endl;
393 }
394 
395 //-----------------------------------------------------------------------------
396 void InitialiseHistograms(TFile* spectraFile, Detector thisDet, int iCut, int iVar,
397  std::string dirName, std::string histPathPre, std::string histPath){
398  // get histograms
399  histMCTotal = (TH1D*)spectraFile->Get((histPath+"TotalMC" ).c_str());
400  histMCSignal = (TH1D*)spectraFile->Get((histPath+"SignalMC" ).c_str());
401  histMCSignalNoCut = (TH1D*)spectraFile->Get((histPathPre+"PreselSignalMC").c_str());
402  histCosmic = (TH1D*)spectraFile->Get((histPath+"TotalCosmic" ).c_str());
403  histData = (TH1D*)spectraFile->Get((histPath+"TotalData").c_str());
404 
405  histMCBg = (TH1D*)histMCTotal->Clone("histMCBg");
406  histMCBg->Add(histMCSignal, -1);
407 
408  histTotal = (TH1D*)histMCTotal->Clone("histTotal");
409  if (histCosmic != nullptr)
410  histTotal->Add(histCosmic);
411 
412  // this pulls out TH2 of variables correlated with calorimetric energy
413  std::string simEnergyString = "kCaloE" +
414  vars.at(iVar).name +
415  cuts.at(iCut).name;
416 
417  histMCTotalEnergy = nullptr;
418  TDirectoryFile* thisDir = (TDirectoryFile*)spectraFile->Get(dirName.c_str());
419  if (thisDir->GetListOfKeys()->Contains((simEnergyString+"TotalMC").c_str())){
420  histMCTotalEnergy = (TH2D*)spectraFile->Get((dirName+"/"+simEnergyString+"TotalMC").c_str());
421  }
422  histMCSignalEnergy = nullptr;
423  if (thisDir->GetListOfKeys()->Contains((simEnergyString+"SignalMC").c_str())){
424  histMCSignalEnergy = (TH2D*)spectraFile->Get((dirName+"/"+simEnergyString+"SignalMC").c_str());
425  }
426 
427  StyleHistograms(histTotal , thisDet, false, false, true );
428  StyleHistograms(histMCTotal , thisDet, false, false, true );
429  StyleHistograms(histMCSignal, thisDet, false, false, false);
430  if (histCosmic != nullptr)
431  StyleHistograms(histCosmic, thisDet, false, true, false);
432  if (histData != nullptr)
433  StyleHistograms(histData, thisDet, true, false, false);
434 }
435 
436 //-----------------------------------------------------------------------------
437 void DrawDataMC(Detector thisDet, int iCut, int iVar,
438  bool isLogPlot, bool isCosmic, bool isAreaNormalised){
439 
440  // need to define this inside function. THStacks are awkward
441  THStack* histSigandBgStack = new THStack("histSigandBgStack", "histSigandBgStack");
442  histSigandBgStack->Add(histMCSignal);
443  if (histCosmic != nullptr)
444  histSigandBgStack->Add(histCosmic);
445  histSigandBgStack->Add(histMCBg);
446 
447  TCanvas* thisCanvas = cRatio;
448  topPad->cd();
449 
450  std::vector<double> theseCuts = vars.at(iVar).cuts;
451  CutSide thisCutSide = vars.at(iVar).cutside;
452 
453  double maxVal;
454  std::string plotType = "";
455  if (isLogPlot){
456  topPad->SetLogy();
457  plotType += "Log";
458  maxVal = 10000;
459  }
460  else{
461  topPad->SetLogy(0);
462  maxVal=1.4;
463  }
464  if (isAreaNormalised){
465  plotType += "AreaNorm";
466  }
467 
468  histMCTotal->GetYaxis()->SetRangeUser(0.0001, histMCTotal->GetMaximum()*maxVal);
469  histTotal ->GetYaxis()->SetRangeUser(0.0001, histTotal->GetMaximum()*maxVal);
470 
471  // if area normalised, we don't want to scale the data, but scale the mc to same integral
472  int tB = histData->GetNbinsX()+1;
473  double scale = isAreaNormalised ? histData->Integral(0,tB)/histMCTotal->Integral(0,tB) : 1./1e4;
474  if (thisDet == kNear) {
475  histMCTotal -> Scale(scale);
476  histMCSignal -> Scale(scale);
477  //histSigandBgStack -> Scale(scale); // no Scale function for THStack, but
478  // probably ok since don't want to
479  // area norm, and only exist in FD
480  histTotal -> Scale(scale);
481  if (!isAreaNormalised)
482  histData ->Scale(scale);
483  }
484 
485  if (isCosmic){
486  histTotal ->GetYaxis()->SetRangeUser(0.0001, histTotal->GetMaximum()*maxVal);
487  histTotal->Draw("hist");
488  histSigandBgStack->Draw("hist same");
489  histTotal->Draw("hist same");
490  DrawBoxes(histTotal, theseCuts, thisCutSide);
491  }
492  else{
493  histMCTotal->GetYaxis()->SetRangeUser(0.0001, histMCTotal->GetMaximum()*maxVal);
494  histMCTotal ->Draw("hist");
495  histMCSignal ->Draw("hist same");
496  histMCTotal ->Draw("hist same");
497  DrawBoxes(histMCTotal, theseCuts, thisCutSide);
498  }
499 
500  histData->Draw("p same");
501 
502  TLegend* leg = GetStandardLegend();
503  leg->Draw("same");
504 
506 
507  thisCanvas->SaveAs((dirName+vars.at(iVar).name+cuts.at(iCut).name+plotType+"DataMC.pdf").c_str());
508  thisCanvas->SaveAs((dirName+vars.at(iVar).name+cuts.at(iCut).name+plotType+"DataMC.png").c_str());
509 
510 }
511 
512 //-----------------------------------------------------------------------------
513 void DrawMCOnly(Detector thisDet, int iCut, int iVar,
514  bool isLogPlot, bool isCosmic){
515 
516  // need to define this inside function. THStacks are awkward
517  THStack* histSigandBgStack = new THStack("histSigandBgStack", "histSigandBgStack");
518  histSigandBgStack->Add(histMCSignal);
519  if (histCosmic != nullptr)
520  histSigandBgStack->Add(histCosmic);
521  histSigandBgStack->Add(histMCBg);
522 
523  TCanvas* thisCanvas = cNoRatio;
524  thisPad->cd();
525 
526  std::vector<double> theseCuts = vars.at(iVar).cuts;
527  CutSide thisCutSide = vars.at(iVar).cutside;
528 
529  // annoyingly the standard offsets don't work
530  histTotal->GetYaxis()->SetTitleOffset(1.1);
531  histMCTotal->GetYaxis()->SetTitleOffset(1.1);
532  histMCSignal->GetYaxis()->SetTitleOffset(1.1);
533 
534  double maxVal;
535  std::string plotType = "";
536  if (isLogPlot){
537  thisPad->SetLogy();
538  plotType += "Log";
539  maxVal = 10000;
540  }
541  else{
542  thisPad->SetLogy(0);
543  maxVal=1.4;
544  }
545  if (!isCosmic){
546  plotType += "NoCosmics";
547  }
548 
549  // if area normalised, we don't want to scale the data, but scale the mc to same integral
550  double scale = 1./1e4;
551  if (thisDet == kNear) {
552  histMCTotal ->Scale(scale);
553  histMCSignal->Scale(scale);
554  histTotal ->Scale(scale);
555  }
556 
557  if (isCosmic){
558  histTotal ->GetYaxis()->SetRangeUser(0.0001, histTotal->GetMaximum()*maxVal);
559  histTotal->Draw("hist");
560  histSigandBgStack->Draw("hist same");
561  histTotal->Draw("hist same");
562  DrawBoxes(histTotal, theseCuts, thisCutSide);
563  }
564  else{
565  histMCTotal->GetYaxis()->SetRangeUser(0.0001, histMCTotal->GetMaximum()*maxVal);
566  histMCTotal ->Draw("hist");
567  histMCSignal ->Draw("hist same");
568  histMCTotal ->Draw("hist same");
569  DrawBoxes(histMCTotal, theseCuts, thisCutSide);
570  }
571 
572  TLegend* leg = GetStandardLegend();
573  if (isCosmic)
574  leg->AddEntry(histCosmic, "Cosmic Events", "f");
575  leg->Draw("same");
576 
577  thisCanvas->SaveAs((dirName+vars.at(iVar).name+cuts.at(iCut).name+plotType+"MCSpectra.pdf").c_str());
578  thisCanvas->SaveAs((dirName+vars.at(iVar).name+cuts.at(iCut).name+plotType+"MCSpectra.png").c_str());
579 
580 }
581 
582 //-----------------------------------------------------------------------------
583 void DrawIndependentSpectra(Detector thisDet, int iCut, int iVar)
584 {
585  TCanvas* thisCanvas = cNoRatio;
586  thisPad->cd();
587  thisPad->SetLogy(0);
588 
589  std::vector<double> theseCuts = vars.at(iVar).cuts;
590  CutSide thisCutSide = vars.at(iVar).cutside;
591 
592  // annoyingly the standard offsets don't work
593  histTotal->GetYaxis()->SetTitleOffset(1.1);
594  histMCTotal->GetYaxis()->SetTitleOffset(1.1);
595  histMCSignal->GetYaxis()->SetTitleOffset(1.1);
596 
597  histMCSignal->SetFillStyle(0);
598  histMCBg ->SetFillStyle(0);
599  histCosmic ->SetFillStyle(0);
600  histMCSignal->Scale(1./histMCSignal->Integral());
601  histMCBg ->Scale(1./histMCBg->Integral());
602  histMCBg ->SetLineColor(kRed+1);
603  histCosmic ->Scale(1./histCosmic->Integral());
604  histMCSignal->GetYaxis()->SetRangeUser(0.0001, std::max({histMCSignal->GetMaximum(), histCosmic->GetMaximum(), histMCBg->GetMaximum()})*1.4);
605  histMCSignal->Draw("hist");
606  histMCBg ->Draw("hist same");
607  histCosmic ->Draw("hist same");
608 
609  DrawBoxes(histMCSignal, theseCuts, thisCutSide);
610 
611  TLegend *areaLeg = new TLegend(0.15, 0.70, 0.5, 0.85);
612  StyleLegend(areaLeg);
613  areaLeg->AddEntry(histMCSignal, "True NC Events", "l");
614  areaLeg->AddEntry(histMCBg , "MC Background" , "l");
615  if (histCosmic != nullptr)
616  areaLeg->AddEntry(histCosmic , "Cosmic Events" , "l");
617  areaLeg->Draw("same");
618 
619  thisCanvas->SaveAs((dirName+vars.at(iVar).name+cuts.at(iCut).name+"IndependentSpectra.pdf").c_str());
620  thisCanvas->SaveAs((dirName+vars.at(iVar).name+cuts.at(iCut).name+"IndependentSpectra.png").c_str());
621 }
622 
623 TLegend* GetStandardLegend(){
624  TLegend* leg = new TLegend(0.15, 0.7, 0.5, 0.89);
625  leg->AddEntry(histTotal , "All Events", "l");
626  leg->AddEntry(histMCSignal, "True NC Events", "f");
627  if (histData != nullptr)
628  leg->AddEntry(histData, "Data", "p");
629  StyleLegend(leg);
630  return leg;
631 }
632 
T max(const caf::Proxy< T > &a, T b)
void DrawDataMC(Detector thisDet, int iCut, int iVar, bool isLogPlot, bool isCosmic, bool isAreaNormalised)
Definition: PlotSpectra.C:437
const XML_Char * name
Definition: expat.h:151
void StyleHistograms(TH1D *h, Detector det, bool isBeamData, bool isCosmic, bool isTotal)
Definition: PlotSpectra.C:101
void StyleFOMs(TH1D *EffTimesPur=nullptr, TH1D *SOverSB=nullptr, TH1D *SOverSSBSyst=nullptr, TH1D *SOverSSB=nullptr, double scalef=1)
Definition: FOMUtilities.h:102
TH1D * histMCSignal
total mc only
Definition: PlotSpectra.h:55
std::vector< float > ndFractionalUncertainties
Definition: PlotSpectra.h:44
std::vector< CutContainer > cutsFD
Definition: CutFlow.h:23
std::vector< CutContainer > subCutsND
Definition: CutFlow.h:46
TCanvas * cNoRatio
Definition: PlotSpectra.h:77
TH1D * SOverSSBHist
Definition: PlotSpectra.h:65
void DrawBoxes(TH1D *histMCTotal, std::vector< double > theseCuts, CutSide thisCutSide)
Definition: PlotSpectra.C:233
T sqrt(T number)
Definition: d0nt_math.hpp:156
TPad * botPad
Definition: PlotSpectra.h:75
TH2D * histMCSignalEnergy
Definition: PlotSpectra.h:69
TH1D * BinnedSOverSSBSystHist
Definition: PlotSpectra.h:66
TPad * topPad
Definition: PlotSpectra.h:74
bool PlotData(std::string name)
Definition: PlotSpectra.C:207
void StyleLegend(TLegend *leg)
Definition: PlotSpectra.C:225
std::vector< CutContainer > subCutsFD
Definition: CutFlow.h:40
void InitialiseFOMHists(Detector thisDet, int iVar, int iCut)
Definition: PlotSpectra.C:308
std::vector< CutContainer > cutsND
Definition: CutFlow.h:32
const XML_Char const XML_Char * data
Definition: expat.h:268
TLegend * GetStandardLegend()
Definition: PlotSpectra.C:623
Double_t scale
Definition: plot.C:25
void PrintSelectedEvents(int iCut, int iVar)
Definition: PlotSpectra.C:382
TH1D * getFOMHist(std::string fomName, CutSide thisCutSide, FomType thisFomType, TH1D *all, TH1D *sig, TH1D *trueSig, TH2D *energyCorrTotal=nullptr, TH2D *energyCorrSignal=nullptr, std::vector< float > systUncertainty={})
Definition: FOMUtilities.h:260
std::vector< float > fdFractionalUncertainties
Definition: PlotSpectra.h:45
TH1D * EffTimesPurHist
total data
Definition: PlotSpectra.h:63
TH1D * histTotal
Definition: PlotSpectra.h:53
TPad * thisPad
Definition: PlotSpectra.h:78
void DrawFOM(std::set< FomType > fomTypes, int iVar)
Definition: PlotSpectra.C:352
const std::map< std::pair< std::string, std::string >, Variable > vars
TH1D * histMCTotal
total sig + bg
Definition: PlotSpectra.h:54
void DrawIndependentSpectra(Detector thisDet, int iCut, int iVar)
Definition: PlotSpectra.C:583
std::vector< VarContainer > varsND
Definition: CutVariables.h:82
OStream cout
Definition: OStream.cxx:6
TH1D * histData
mc-only bg (no cosmic)
Definition: PlotSpectra.h:59
void DrawMCOnly(Detector thisDet, int iCut, int iVar, bool isLogPlot, bool isCosmic)
Definition: PlotSpectra.C:513
void LoopHistograms(TFile *spectraFile, Detector thisDet)
Definition: PlotSpectra.C:16
std::vector< CutContainer > subcuts
Definition: PlotSpectra.h:50
TH1D * histMCBg
total cosmic
Definition: PlotSpectra.h:58
::xsd::cxx::tree::string< char, simple_type > string
Definition: Database.h:154
std::string dirName
Definition: PlotSpectra.h:47
TH1D * SOverSBHist
Definition: PlotSpectra.h:64
void SetupCanvas(TPad *topPad, TPad *botPad, TPad *thisPad)
Definition: PlotSpectra.C:186
void InitialiseHistograms(TFile *spectraFile, Detector thisDet, int iCut, int iVar, std::string dirName, std::string histPathPre, std::string histPath)
Definition: PlotSpectra.C:396
TH1D * histMCSignalNoCut
total mc signal
Definition: PlotSpectra.h:56
std::vector< VarContainer > varsFD
Definition: CutVariables.h:28
void DrawRatio(TPad *thisPad, TH1D *mc, TH1D *data)
Definition: PlotSpectra.C:270
TCanvas * cRatio
Definition: PlotSpectra.h:73
simulatedPeak Scale(1/simulationNormalisationFactor)
void GetFractionalUncertainties(TFile *covmx, std::vector< float > *nd, std::vector< float > *fd)
Definition: PlotSpectra.C:287
void PlotSpectra(TString spectraFileName, TString opt)
Definition: PlotSpectra.C:3
TH2D * histMCTotalEnergy
Definition: PlotSpectra.h:68
int kNovaFont
Definition: rootlogon.py:68
std::vector< double > GetDecorrelatedUncertainty(TMatrixD *inmat, int ndbins, int fdbins)
TH1D * histCosmic
total mc signal (no cut)
Definition: PlotSpectra.h:57