SystsBeamAna.C
Go to the documentation of this file.
4 
5 using namespace ana;
6 
8 {
9  TH1::AddDirectory(0);
10 
11  // A map of systematic labels
12  std::map<std::string, std::string> shiftlabels;
13  shiftlabels["BeamHornCurrent"] = "Horn Current";
14  shiftlabels["BeamSpotSize"] = "Spot Size";
15  shiftlabels["BeamPosX"] = "Beam Position X";
16  shiftlabels["BeamPosY"] = "Beam Position Y";
17  shiftlabels["BeamH1PosXY"] = "Horn 1 Position";
18  shiftlabels["BeamH2PosXY"] = "Horn 2 Position";
19  shiftlabels["BeamTarget"] = "Target Position";
20  shiftlabels["BeamExp"] = "Exponential B Field";
21  shiftlabels["BeamGeomWater"] = "New Horn Geometry and 1mm water";
22  shiftlabels["BeamFlukaVersion"] = "Fluka version";
23  shiftlabels["BeamG4"] = "G4NuMI";
24  shiftlabels["BeamNA49"] = "NA49";
25 
26  std::string labelRecoE = "Calorimetric Energy (GeV)";
27  std::vector<std::string> cut_samples;
28  cut_samples.push_back("Ana01");
29 
30  // Set up maps to the decompositions/predictions (each flavor component)
31  // Nominal maps are indexed purely by sample label
32  // Shifted maps are indexed by sample label, systematic label, then sigma of the shift
33  std::map<std::string, IDecomp*> decomps_nominal;
34  std::map<std::string, std::map<std::string, std::map<int, IDecomp*> > > decomps_shifted;
35  std::map<std::string, PredictionNoExtrap*> predsNE_nominal;
36  std::map<std::string, std::map<std::string, std::map<int, PredictionNoExtrap*> > > predsNE_shifted;
37  std::map<std::string, PredictionSterile*> predsSt_nominal;
38  std::map<std::string, std::map<std::string, std::map<int, PredictionSterile*> > > predsSt_shifted;
39 
40  std::string folder = "/nova/ana/steriles/Ana01/Systematics/";
41  std::string filenm = "SystsBeam";
42 
43  std::string loadLocation = folder + filenm + ".root";
44  std::string saveLocation = folder + filenm + "Ana.root";
45  std::string textLocation = folder + filenm + "Ana.txt";
46 
47  TFile* rootL = new TFile(loadLocation.c_str(), "READ");
48  LoadMaps(rootL, &decomps_nominal, &decomps_shifted);
49  LoadMaps(rootL, &predsNE_nominal, &predsNE_shifted);
50  LoadMaps(rootL, &predsSt_nominal, &predsSt_shifted);
51  rootL->Close();
52 
53  TFile* rootF = new TFile(saveLocation.c_str(), "RECREATE");
54  FILE* textF;
55  textF = fopen(textLocation.c_str(), "w");
56 
57  for(const auto& sample : cut_samples) {
58  strings strs;
59  strs.fComponent = "NC";
60  strs.fDet = "ND";
62  strs.fSample = sample;
63  strs.fSystType = "Beam";
64  strs.fXLabel = labelRecoE;
65 
66  InitializeSystText(textF, strs);
67 
68  TH1* hNomNC_decomp = GetNC(decomps_nominal[sample], NCSCALE);
69  TH1* hNomBG_decomp = GetBG(decomps_nominal[sample], NCSCALE);
70 
71  TH1* hNomNC_predNE = GetNC(predsNE_nominal[sample], NCSCALE);
72  TH1* hNomBG_predNE = GetBG(predsNE_nominal[sample], NCSCALE);
73 
74  TH1* hNomNC_predSt = GetNC(predsSt_nominal[sample], NCSCALE);
75  TH1* hNomBG_predSt = GetBG(predsSt_nominal[sample], NCSCALE);
76 
77  for(const auto& shifts : shiftlabels) {
78  strs.fSystS = shifts.first;
79  strs.fSystL = shifts.second;
80 
81  strs.fComponent = "NC";
82  strs.fDet = "ND";
83  PlotSyst(hNomNC_decomp,
84  decomps_shifted[sample][shifts.first],
85  rootF, textF, strs, NCSCALE, true, false);
86 
87  strs.fComponent = "BG";
88  PlotSyst(hNomBG_decomp,
89  decomps_shifted[sample][shifts.first],
90  rootF, textF, strs, NCSCALE, false, false);
91 
92  strs.fComponent = "NC";
93  strs.fDet = "FD";
94  PlotSyst(hNomNC_predNE,
95  predsNE_shifted[sample][shifts.first],
96  rootF, textF, strs, NCSCALE, true, false);
97 
98  strs.fComponent = "BG";
99  PlotSyst(hNomBG_predNE,
100  predsNE_shifted[sample][shifts.first],
101  rootF, textF, strs, NCSCALE, false, false);
102 
103  strs.fComponent = "NC";
104  strs.fDet = "EX";
105  PlotSyst(hNomNC_predSt,
106  predsSt_shifted[sample][shifts.first],
107  rootF, textF, strs, NCSCALE, true, false);
108 
109  strs.fComponent = "BG";
110  PlotSyst(hNomBG_predSt,
111  predsSt_shifted[sample][shifts.first],
112  rootF, textF, strs, NCSCALE, false, false);
113  }
114 
115  strs.fComponent = "NC";
116  strs.fDet = "ND";
117  PlotSystBand(hNomNC_decomp, rootF, textF, strs);
118 
119  strs.fComponent = "BG";
120  PlotSystBand(hNomBG_decomp, rootF, textF, strs);
121 
122  strs.fComponent = "NC";
123  strs.fDet = "FD";
124  PlotSystBand(hNomNC_predNE, rootF, textF, strs);
125 
126  strs.fComponent = "BG";
127  PlotSystBand(hNomBG_predNE, rootF, textF, strs);
128 
129  strs.fComponent = "NC";
130  strs.fDet = "EX";
131  PlotSystBand(hNomNC_predSt, rootF, textF, strs);
132 
133  strs.fComponent = "BG";
134  PlotSystBand(hNomBG_predSt, rootF, textF, strs);
135  }
136 
137  fclose(textF);
138  rootF->Close();
139 
140  std::cout << "Finished. Ctrl+Z should be safe if the macro didn't quit." << std::endl;
141 }
std::string fDet
Definition: PPFXHelper.h:104
Cuts and Vars for the 2020 FD DiF Study.
Definition: vars.h:6
std::string fComponent
Definition: PPFXHelper.h:103
void PlotSyst(TH1 *h, TH1 *hp1, TH1 *hm1, TH1 *hp2, TH1 *hm2, TDirectory *out, FILE *text, strings strs)
Definition: PPFXHelper.h:662
TH1 * GetNC(IDecomp *specs, double POT)
Definition: PPFXHelper.h:211
fclose(fg1)
void InitializeSystText(FILE *text, strings strs)
Print some initial text about a systematic – the systematic type and sample.
Definition: PPFXHelper.h:263
std::string fSystL
Definition: PPFXHelper.h:109
void SystsBeamAna()
Definition: SystsBeamAna.C:7
std::string fPOT
Definition: PPFXHelper.h:105
OStream cout
Definition: OStream.cxx:6
void PlotSystBand(TH1 *h, TDirectory *out, FILE *text, strings strs)
Definition: PPFXHelper.h:968
std::string fXLabel
Definition: PPFXHelper.h:110
std::string fSystType
Definition: PPFXHelper.h:107
std::string fSystS
Definition: PPFXHelper.h:108
void LoadMaps(TDirectory *dir, std::map< std::string, IDecomp * > *nominal, std::map< std::string, std::map< std::string, std::map< int, IDecomp * > > > *shifted)
Definition: PPFXHelper.h:273
static double NCSCALE
TH1 * GetBG(IDecomp *specs, double POT)
Definition: PPFXHelper.h:236
std::string StringFromDouble(double pot)
Definition: PPFXHelper.h:128
A helper structure to contain a group of string for plotting.
Definition: PPFXHelper.h:101
std::string fSample
Definition: PPFXHelper.h:106
enum BeamMode string