SystsBeamTranspAna.C
Go to the documentation of this file.
4 
5 using namespace ana;
6 
8 {
9  TH1::AddDirectory(0);
10  double NCSCALE=8.85e20;
11  // A map of systematic labels
12  std::map<std::string, std::string> shiftlabels;
13  shiftlabels["BeamHornCurrent"] ="2kA";
14  shiftlabels["BeamHornCurrent"]="Horn Current";
15  shiftlabels["BeamSpotSize"] ="Spot Size";
16  shiftlabels["BeamposX"] ="Beam Position X";
17  shiftlabels["BeamposY"] ="Beam Position Y";
18  shiftlabels["BeamH1PosX"] ="Horn 1 X Position";
19  shiftlabels["BeamH1PosY"] ="Horn 1 Y Position";
20  shiftlabels["BeamH2PosX"] ="Horn 2 X Position";
21  shiftlabels["BeamH2PosY"] ="Horn 2 Y Position";
22  shiftlabels["TargetPosZ"] ="Target Z position";
23  shiftlabels["BeamExp"] ="Magnet Field in Decay Pipe";
24  shiftlabels["HornWater"] ="New Horn Geometry and 1mm water";
25  shiftlabels["totErr"] ="Combined Beam Transport Systematics";
26 
27 
28 
29 
30  std::string labelRecoE = "Energy Deposited in Scintillator (GeV)";
31  std::vector<std::string> cut_samples;
32  cut_samples.push_back("Ana17");
33 
34  // Set up maps to the decompositions/predictions (each flavor component)
35  // Nominal maps are indexed purely by sample label
36  // Shifted maps are indexed by sample label, systematic label, then sigma of the shift
37  std::map<std::string, IDecomp*> decomps_nominal;
38  std::map<std::string, std::map<std::string, std::map<int, IDecomp*> > > decomps_shifted;
39  std::map<std::string, PredictionNoExtrap*> predsNE_nominal;
40  std::map<std::string, std::map<std::string, std::map<int, PredictionNoExtrap*> > > predsNE_shifted;
41  std::map<std::string, PredictionSterile*> predsSt_nominal;
42  std::map<std::string, std::map<std::string, std::map<int, PredictionSterile*> > > predsSt_shifted;
43  std::string folderout="";
44  std::string folder = "/nova/ana/users/sedayath/CAFAna_work_place/job/NUS17/Syst/";
45  std::string filenm = "SystBeam";
46 
47  std::string loadLocation = folder + filenm + ".root";
48  std::string saveLocation = folderout + filenm + "Ana.root";
49  std::string textLocation = folderout + filenm + "Ana.txt";
50 
51  TFile* rootL = new TFile(loadLocation.c_str(), "READ");
52  LoadMaps(rootL, &decomps_nominal, &decomps_shifted);
53  LoadMaps(rootL, &predsNE_nominal, &predsNE_shifted);
54  LoadMaps(rootL, &predsSt_nominal, &predsSt_shifted);
55  rootL->Close();
56 
57  TFile* rootF = new TFile(saveLocation.c_str(), "RECREATE");
58  FILE* textF;
59  textF = fopen(textLocation.c_str(), "w");
60 
61  for(const auto& sample : cut_samples) {
62  strings strs;
63  strs.fComponent = "NC";
64  strs.fDet = "ND";
65  strs.fPOT = StringFromDouble(NCSCALE);
66  strs.fSample = sample;
67  strs.fSystType = "Beam";
68  strs.fXLabel = labelRecoE;
69 
70  InitializeSystText(textF, strs);
71 
72  TH1* hNomNC_decomp = GetNC(decomps_nominal[sample], NCSCALE);
73  TH1* hNomBG_decomp = GetBG(decomps_nominal[sample], NCSCALE);
74 
75  TH1* hNomNC_predNE = GetNC(predsNE_nominal[sample], NCSCALE);
76  TH1* hNomBG_predNE = GetBG(predsNE_nominal[sample], NCSCALE);
77 
78  TH1* hNomNC_predSt = GetNC(predsSt_nominal[sample], NCSCALE);
79  TH1* hNomBG_predSt = GetBG(predsSt_nominal[sample], NCSCALE);
80 
81  for(const auto& shifts : shiftlabels) {
82  strs.fSystS = shifts.first;
83  strs.fSystL = shifts.second;
84 
85  strs.fComponent = "NC";
86  strs.fDet = "ND";
87  PlotSyst(hNomNC_decomp,
88  decomps_shifted[sample][shifts.first],
89  rootF, textF, strs, NCSCALE, true, false);
90 
91  strs.fComponent = "BG";
92  PlotSyst(hNomBG_decomp,
93  decomps_shifted[sample][shifts.first],
94  rootF, textF, strs, NCSCALE, false, false);
95 
96  strs.fComponent = "NC";
97  strs.fDet = "FD";
98  PlotSyst(hNomNC_predNE,
99  predsNE_shifted[sample][shifts.first],
100  rootF, textF, strs, NCSCALE, true, false);
101 
102  strs.fComponent = "BG";
103  PlotSyst(hNomBG_predNE,
104  predsNE_shifted[sample][shifts.first],
105  rootF, textF, strs, NCSCALE, false, false);
106 
107  strs.fComponent = "NC";
108  strs.fDet = "EX";
109  PlotSyst(hNomNC_predSt,
110  predsSt_shifted[sample][shifts.first],
111  rootF, textF, strs, NCSCALE, true, false);
112 
113  strs.fComponent = "BG";
114  PlotSyst(hNomBG_predSt,
115  predsSt_shifted[sample][shifts.first],
116  rootF, textF, strs, NCSCALE, false, false);
117  }
118 
119  strs.fComponent = "NC";
120  strs.fDet = "ND";
121  PlotSystBand(hNomNC_decomp, rootF, textF, strs);
122 
123  strs.fComponent = "BG";
124  PlotSystBand(hNomBG_decomp, rootF, textF, strs);
125 
126  strs.fComponent = "NC";
127  strs.fDet = "FD";
128  PlotSystBand(hNomNC_predNE, rootF, textF, strs);
129 
130  strs.fComponent = "BG";
131  PlotSystBand(hNomBG_predNE, rootF, textF, strs);
132 
133  strs.fComponent = "NC";
134  strs.fDet = "EX";
135  PlotSystBand(hNomNC_predSt, rootF, textF, strs);
136 
137  strs.fComponent = "BG";
138  PlotSystBand(hNomBG_predSt, rootF, textF, strs);
139  }
140 
141  fclose(textF);
142  rootF->Close();
143 
144  std::cout << "Finished. Ctrl+Z should be safe if the macro didn't quit." << std::endl;
145 }
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
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
void SystsBeamTranspAna()
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