PlotSpectra.h
Go to the documentation of this file.
1 #pragma once
2 
4 #include "CAFAna/Core/Binning.h"
5 #include "CAFAna/Core/Spectrum.h"
9 #include "CAFAna/Cuts/Cuts.h"
10 #include "CAFAna/Vars/Vars.h"
11 
16 
17 #include "NuXAna/Vars/NusVars.h"
18 #include "NuXAna/Cuts/NusCuts20.h"
19 #include "NuXAna/Cuts/NusCuts.h"
24 
25 #include "TFile.h"
26 #include "TString.h"
27 #include "TH1.h"
28 #include "TCanvas.h"
29 #include "TPad.h"
30 #include "THStack.h"
31 #include "TLegend.h"
32 #include "TBox.h"
33 #include "TLatex.h"
34 #include "TStyle.h"
35 
36 /// helper plotting scripts
37 #include "/nashome/a/alister1/NOvAPlotting.h"
38 
39 enum Detector {
42 };
43 
44 std::vector<float> ndFractionalUncertainties = {};
45 std::vector<float> fdFractionalUncertainties = {};
46 
48 std::vector<VarContainer> vars;
49 std::vector<CutContainer> cuts;
50 std::vector<CutContainer> subcuts;
51 
52 // base histograms we use
53 TH1D* histTotal = new TH1D(); /// total sig + bg
54 TH1D* histMCTotal = new TH1D(); /// total mc only
55 TH1D* histMCSignal = new TH1D(); /// total mc signal
56 TH1D* histMCSignalNoCut = new TH1D(); /// total mc signal (no cut)
57 TH1D* histCosmic = new TH1D(); /// total cosmic
58 TH1D* histMCBg = new TH1D(); /// mc-only bg (no cosmic)
59 TH1D* histData = new TH1D(); /// total data
60 
61 
62 // histograms for FOMs
63 TH1D* EffTimesPurHist = new TH1D();
64 TH1D* SOverSBHist = new TH1D();
65 TH1D* SOverSSBHist = new TH1D();
66 TH1D* BinnedSOverSSBSystHist = new TH1D();
67 
68 TH2D* histMCTotalEnergy = nullptr;
69 TH2D* histMCSignalEnergy = nullptr;
70 
71 bool isAreaNorm = true;
72 
73 TCanvas* cRatio = new TCanvas("cRatio", "cRatio", 600, 600);
74 TPad* topPad = new TPad("topPad", "", 0.005, 0.3, 0.995, 0.995);
75 TPad* botPad = new TPad("botPad", "", 0.005, 0.005, 0.995, 0.3);
76 
77 TCanvas* cNoRatio = new TCanvas("cNoRatio", "cNoRatio", 600, 500);
78 TPad* thisPad = new TPad("thisPad", "", 0.005, 0.005, 0.995, 0.995);
79 
80 // loops histograms from file
81 void LoopHistograms(TFile* spectraFile, Detector thisDet);
82 
83 // style histograms from file
84 void StyleHistograms(TH1D* h, Detector det,
85  bool isBeamData, bool isCosmic, bool isTotal);
86 
87 // set margins of pads
88 void SetupCanvas(TPad* topPad, TPad* botPad, TPad* thisPad);
89 
90 // determine whether to plot data for a given spectra
92 
93 // stle legends
94 void StyleLegend(TLegend* leg);
95 
96 // draw boxes to show cuts
97 void DrawBoxes(TH1D* histMCTotal, std::vector<double> cutValues, CutSide thisCutSide);
98 
99 // draw ratio plot
100 void DrawRatio(TPad* thisPad, TH1D* mc, TH1D* dat);
101 
102 // get fractional uncertainties from covariance matrix
103 void GetFractionalUncertainties(TFile* covmx,
104  std::vector<float>* nd,
105  std::vector<float>* fd);
106 
107 // initialise histograms we're going to use
108 void InitialiseHistograms(TFile* spectraFile, Detector thisDet, int iCut, int iVar,
109  std::string dirName, std::string histPathPre, std::string histPath);
110 
111 // set up FOMs to draw
112 void InitialiseFOMHists(Detector thisDet, int iCut, int iVar);
113 
114 // ...and then draw them
115 void DrawFOM(std::set<FomType>, int iVar);
116 
117 // print selected events
118 void PrintSelectedEvents(int iCut, int iVar);
119 
120 // draw functions
121 void DrawDataMC(Detector thisDet, int iCut, int iVar,
122  bool isLogPlot, bool isCosmic, bool isAreaNormalised);
123 void DrawMCOnly(Detector thisDet, int iCut, int iVar,
124  bool isLogPlot, bool isCosmic);
125 void DrawIndependentSpectra(Detector thisDet, int iCut, int iVar);
126 
127 // get standard legend setup
128 TLegend* GetStandardLegend();
std::vector< VarContainer > vars
Definition: PlotSpectra.h:48
void SetupCanvas(TPad *topPad, TPad *botPad, TPad *thisPad)
Definition: PlotSpectra.C:186
const XML_Char * name
Definition: expat.h:151
void InitialiseFOMHists(Detector thisDet, int iCut, int iVar)
Definition: PlotSpectra.C:308
void GetFractionalUncertainties(TFile *covmx, std::vector< float > *nd, std::vector< float > *fd)
Definition: PlotSpectra.C:287
TH1D * histMCSignal
total mc only
Definition: PlotSpectra.h:55
std::vector< float > ndFractionalUncertainties
Definition: PlotSpectra.h:44
void InitialiseHistograms(TFile *spectraFile, Detector thisDet, int iCut, int iVar, std::string dirName, std::string histPathPre, std::string histPath)
Definition: PlotSpectra.C:396
bool PlotData(std::string name)
Definition: PlotSpectra.C:207
void StyleHistograms(TH1D *h, Detector det, bool isBeamData, bool isCosmic, bool isTotal)
Definition: PlotSpectra.C:101
TCanvas * cNoRatio
Definition: PlotSpectra.h:77
TH1D * SOverSSBHist
Definition: PlotSpectra.h:65
TPad * botPad
Definition: PlotSpectra.h:75
TH2D * histMCSignalEnergy
Definition: PlotSpectra.h:69
TH1D * BinnedSOverSSBSystHist
Definition: PlotSpectra.h:66
TPad * topPad
Definition: PlotSpectra.h:74
void DrawDataMC(Detector thisDet, int iCut, int iVar, bool isLogPlot, bool isCosmic, bool isAreaNormalised)
Definition: PlotSpectra.C:437
void DrawIndependentSpectra(Detector thisDet, int iCut, int iVar)
Definition: PlotSpectra.C:583
void DrawBoxes(TH1D *histMCTotal, std::vector< double > cutValues, CutSide thisCutSide)
Definition: PlotSpectra.C:233
void DrawRatio(TPad *thisPad, TH1D *mc, TH1D *dat)
Definition: PlotSpectra.C:270
void LoopHistograms(TFile *spectraFile, Detector thisDet)
Definition: PlotSpectra.C:16
void PrintSelectedEvents(int iCut, int iVar)
Definition: PlotSpectra.C:382
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
std::vector< CutContainer > cuts
Definition: PlotSpectra.h:49
TH1D * histMCTotal
total sig + bg
Definition: PlotSpectra.h:54
void StyleLegend(TLegend *leg)
Definition: PlotSpectra.C:225
void DrawFOM(std::set< FomType >, int iVar)
Definition: PlotSpectra.C:352
TH1D * histData
mc-only bg (no cosmic)
Definition: PlotSpectra.h:59
std::vector< CutContainer > subcuts
Definition: PlotSpectra.h:50
TH1D * histMCBg
total cosmic
Definition: PlotSpectra.h:58
TLegend * GetStandardLegend()
Definition: PlotSpectra.C:623
std::string dirName
Definition: PlotSpectra.h:47
TH1D * SOverSBHist
Definition: PlotSpectra.h:64
TH1D * histMCSignalNoCut
total mc signal
Definition: PlotSpectra.h:56
TCanvas * cRatio
Definition: PlotSpectra.h:73
void DrawMCOnly(Detector thisDet, int iCut, int iVar, bool isLogPlot, bool isCosmic)
Definition: PlotSpectra.C:513
bool isAreaNorm
Definition: PlotSpectra.h:71
TH2D * histMCTotalEnergy
Definition: PlotSpectra.h:68
TH1D * histCosmic
total mc signal (no cut)
Definition: PlotSpectra.h:57
enum BeamMode string