Nus18SystMaker.C
Go to the documentation of this file.
1 // Based on results from individual systematic studies,
2 // create a file containing histograms of shift/nominal ratios.
3 // These histograms are used by NusSystFromHist
4 // to create Nus group ISyst objects.
5 // There are three types of syst groups:
6 // Errors added in quadrature -- these have a std::vector of labels
7 // On/off errors -- these have a single label
8 // An up/down systematic -- these have a std::pair of labels
9 
14 
15 using namespace ana;
16 
17 /// Fill a second map with clones of histograms in the first map
18 void CloneMap(std::map<std::string, std::map<std::string, TH1*> >& noms,
19  std::map<std::string, std::map<std::string, TH1*> >& clone);
20 
21 /// Open the file systfile
22 /// Fill the predND, predFD maps from the file
23 /// Put the nominal spectra from the maps into noms
24 void FillMaps(std::string folder, std::string systfile, std::string sample,
25  std::map<std::string, std::map<std::string, TH1*> >& noms,
26  std::map<std::string, NDPredictionSterile*>& predsND_nominal,
27  std::map<std::string, std::map<std::string, std::map<int, NDPredictionSterile*> > >& predsND_shifted,
28  std::map<std::string, FDPredictionSterile*>& predsFD_nominal,
29  std::map<std::string, std::map<std::string, std::map<int, FDPredictionSterile*> > >& predsFD_shifted,
30  std::map<std::string, PredictionSterile*>& predsExtrap_nominal,
31  std::map<std::string, std::map<std::string, std::map<int, PredictionSterile*> > >& predsExtrap_shifted,
32  double kNCNDScale, double kNCFDScale);
33 void FillMaps(std::string folder, std::string systfile1, std::string systfile2, std::string sample,
34  std::map<std::string, std::map<std::string, TH1*> >& noms,
35  std::map<std::string, NDPredictionSterile*>& predsND1_nominal,
36  std::map<std::string, std::map<std::string, std::map<int, NDPredictionSterile*> > >& predsND1_shifted,
37  std::map<std::string, NDPredictionSterile*>& predsND2_nominal,
38  std::map<std::string, std::map<std::string, std::map<int, NDPredictionSterile*> > >& predsND2_shifted,
39  double kNCNDScale, double kNCFDScale);
40 void FillMaps(std::string folder, std::string systfile, std::string sample,
41  std::map<std::string, std::map<std::string, TH1*> >& noms,
42  std::map<std::string, FDPredictionSterile*>& predsFD_nominal,
43  std::map<std::string, std::map<std::string, std::map<int, FDPredictionSterile*> > >& predsFD_shifted,
44  double kNCNDScale, double kNCFDScale);
45 void FillMaps(std::string folder, std::string systfile, std::string sample,
46  std::map<std::string, std::map<std::string, TH1*> >& noms,
47  std::map<std::string, PredictionSterile*>& predsExtrap_nominal,
48  std::map<std::string, std::map<std::string, std::map<int, PredictionSterile*> > >& predsExtrap_shifted,
49  double kNCNDScale, double kNCFDScale);
50 void FillMaps(std::string folder, std::string systfile, std::string sample,
51  std::map<std::string, std::map<std::string, TH1*> >& noms,
52  std::map<std::string, NDPredictionSterile*>& predsND_nominal,
53  std::map<std::string, std::map<std::string, std::map<int, NDPredictionSterile*> > >& predsND_shifted,
54  double kNCNDScale, double kNCFDScale);
55 void FillMaps(std::string folder, std::string systfile, std::string sample,
56  std::map<std::string, std::map<std::string, TH1*> >& noms,
57  std::map<std::string, PredictionSterile*>& predsExtrap_nominal,
58  std::map<std::string, std::map<std::string, std::map<int, PredictionSterile*> > >& predsExtrap_shifted,
59  double kNCNDScale, double kNCFDScale);
60 
61 /// Make a standardized name for the syst ratio histogram
64 
65 /// Make a standardized title for the syst ratio histogram
68 
69 /// Make nominal ratio histograms, a line at 1 corresponding to 0 sigma
70 void NominalRat(std::map<std::string, std::map<std::string, TH1*> >& noms,
71  std::map<std::string, std::map<std::string, TH1*> >& line);
72 
73 /// Add errors in quadrature for all systs in the shiftlabels vector
74 /// Set the errors for the hists in noms to these errors
75 void QuadErrors(const std::vector<std::string>& shiftlabels, std::string sample,
76  std::map<std::string, std::map<std::string, TH1*> >& noms,
77  std::map<std::string, std::map<std::string, std::map<int, NDPredictionSterile*> > >& predsND_shifted,
78  std::map<std::string, std::map<std::string, std::map<int, FDPredictionSterile*> > >& predsFD_shifted,
79  std::map<std::string, std::map<std::string, std::map<int, PredictionSterile*> > >& predsExtrap_shifted,
80  double kNCNDScale, double kNCFDScale);
81 void QuadErrors(const std::vector<std::string>& shiftlabels, std::string sample,
82  std::map<std::string, std::map<std::string, TH1*> >& noms,
83  std::map<std::string, std::map<std::string, std::map<int, FDPredictionSterile*> > >& predsFD_shifted,
84  double kNCNDScale, double kNCFDScale);
85 void QuadErrors(const std::vector<std::string>& shiftlabels, std::string sample,
86  std::map<std::string, std::map<std::string, TH1*> >& noms,
87  std::map<std::string, std::map<std::string, std::map<int, NDPredictionSterile*> > >& predsND_shifted,
88  double kNCNDScale, double kNCFDScale);
89 void QuadErrors(const std::vector<std::string>& shiftlabels, std::string sample,
90  std::map<std::string, std::map<std::string, TH1*> >& noms,
91  std::map<std::string, std::map<std::string, std::map<int, PredictionSterile*> > >& predsExtrap_shifted,
92  double kNCNDScale, double kNCFDScale);
93 void QuadErrors(const std::vector<std::string>& shiftlabels, std::string sample,
94  std::map<std::string, std::map<std::string, TH1*> >& noms,
95  std::map<std::string, std::map<std::string, std::map<int, NDPredictionSterile*> > >& predsND1_shifted,
96  std::map<std::string, std::map<std::string, std::map<int, NDPredictionSterile*> > >& predsND2_shifted,
97  double kNCNDScale, double kNCFDScale);
98 
99 /// Save the histograms in hists to out
100 void SaveMaps(std::map<std::string, std::map<std::string, TH1*> >& hists,
101  TDirectory* out, std::string syst, std::string sigma);
102 
103 /// Set bins in shft to shift/nominal using the shiftlabel syst
104 void SetBinsOnOffShift(std::string shiftlabel, std::string sample,
105  std::map<std::string, std::map<std::string, TH1*> >& noms,
106  std::map<std::string, std::map<std::string, TH1*> >& shft,
107  std::map<std::string, std::map<std::string, std::map<int, NDPredictionSterile*> > >& predsND_shifted,
108  std::map<std::string, std::map<std::string, std::map<int, FDPredictionSterile*> > >& predsFD_shifted,
109  std::map<std::string, std::map<std::string, std::map<int, PredictionSterile*> > >& predsExtrap_shifted,
110  double kNCNDScale, double kNCFDScale);
111 
112 /// Perform the on/off syst type method for a syst that has an up and down
113 /// These are shifts that are not added in quadrature
114 /// The +1 sigma shift should be the first parameter in shiftlabels
115 void SetBinsPlusMinusOne(std::pair<std::string, std::string> shiftlabels, std::string sample,
116  std::map<std::string, std::map<std::string, TH1*> >& noms,
117  std::map<std::string, std::map<std::string, TH1*> >& sfp1,
118  std::map<std::string, std::map<std::string, TH1*> >& sfm1,
119  std::map<std::string, std::map<std::string, std::map<int, NDPredictionSterile*> > >& predsND_shifted,
120  std::map<std::string, std::map<std::string, std::map<int, FDPredictionSterile*> > >& predsFD_shifted,
121  std::map<std::string, std::map<std::string, std::map<int, PredictionSterile*> > >& predsExtrap_shifted,
122  double kNCNDScale, double kNCFDScale);
123 
124 /// Set bins in sfp1 and sfm1 to (nominal +/- error)/nominal
125 /// Errors should have been calculated by QuadErrors
126 void SetBinsPlusMinusOne(std::map<std::string, std::map<std::string, TH1*> >& noms,
127  std::map<std::string, std::map<std::string, TH1*> >& sfp1,
128  std::map<std::string, std::map<std::string, TH1*> >& sfm1,
129  double kNCNDScale, double kNCFDScale);
130 
131 //------------------------------------------------------------------------------
132 void Nus18SystMaker(bool rhc = false)
133 {
134  TH1::AddDirectory(0);
135 
136  // Define parameters (could be temporary way of doing this...)
137  // ------------------------------------------------------------------------------------------------------
138  // Scaling --------
139  double kNCNDScale, kNCFDScale;
140  // Folder and names of all syst files ---------
141  std::string kSystFolder;
142  std::string kSystBeamT;
143  std::string kSystCalibAbs;
144  std::string kSystCalibRel;
145  std::string kSystLL;
146  std::string kSystGENIE;
147  std::string kSystGENIE_ND;
148  std::string kSystGENIE_ND1;
149  std::string kSystGENIE_ND2;
150  std::string kSystGENIE_FD;
151  std::string kSystGENIE_FD1;
152  std::string kSystGENIE_FD2;
153  std::string kSystGENIE_Extrap;
154  std::string kSystGENIE_Extrap1;
155  std::string kSystGENIE_Extrap2;
156  std::string kSystKaon;
157  std::string kSystNeutron;
158  std::string kSystTau;
159  std::string kSystXSecOnOff;
160  if (rhc) {
161  kNCNDScale = kAna2018RHCNDPOT;
162  kNCFDScale = kAna2018RHCPOT;
163  kSystFolder = "/nova/ana/users/wallbank/Nus18/Systematics/";
164  kSystBeamT = "SystsBeam18";
165  kSystCalibAbs = "SystsCalibAbs18";
166  kSystCalibRel = "SystsCalibRel18";
167  kSystLL = "SystsLightLevel18";
168  kSystGENIE = "SystsGENIE";
169  kSystGENIE_ND = "SystsGENIEND";
170  kSystGENIE_ND1 = "SystsGENIEND1";
171  kSystGENIE_ND2 = "SystsGENIEND2";
172  kSystGENIE_FD = "SystsGENIEFD";
173  kSystGENIE_FD1 = "SystsGENIEFD1";
174  kSystGENIE_FD2 = "SystsGENIEFD2";
175  kSystGENIE_Extrap = "SystsGENIEExtrap";
176  kSystGENIE_Extrap1 = "SystsGENIEExtrap1";
177  kSystGENIE_Extrap2 = "SystsGENIEExtrap2";
178  kSystKaon = "SystsKaon18";
179  kSystNeutron = "SystsNeutron18";
180  kSystTau = "SystsTau18";
181  kSystXSecOnOff = "SystsXSecOnOff18";
182  } else {
183  kNCNDScale = kAna2018FHCNDPOT;
184  kNCFDScale = kAna2018FHCPOT;
185  kSystFolder = "/nova/ana/users/sedayath/CAFAna_work_place/job/NUS18/Syst18/Prod4_temp/";
186  kSystBeamT = "SystBeamT";
187  kSystCalibAbs = "SystCalibAbs";
188  kSystLL = "SystLL";
189  kSystGENIE = "SystGENIE";
190  kSystGENIE_ND1 = "SystGENIE_ND1";
191  kSystGENIE_ND2 = "SystGENIE_ND2";
192  kSystGENIE_FD1 = "GENIE_FD1";
193  kSystGENIE_FD2 = "GENIE_FD2";
194  }
195  // ------------------------------------------------------------------------------------------------------
196 
197  // Choose token for systematic samples
198  std::string sample = "Nus18";
199 
200  // Lists of labels to use from each syst group
201  std::vector<std::string> labelsBeam;
202  labelsBeam.push_back("BeamHornCurrent");
203  labelsBeam.push_back("BeamSpotSize");
204  labelsBeam.push_back("BeamposX");
205  labelsBeam.push_back("BeamposY");
206  labelsBeam.push_back("BeamH1PosX");
207  labelsBeam.push_back("BeamH1PosY");
208  labelsBeam.push_back("BeamH2PosX");
209  labelsBeam.push_back("BeamH2PosY");
210  labelsBeam.push_back("TargetPosZ");
211  labelsBeam.push_back("BeamExp");
212  labelsBeam.push_back("HornWater");
213 
214  // std::string labelBirks = "BirksC";
215 
216  std::pair<std::string, std::string> labelsFlat =
217  std::make_pair("CalFlatUp", "CalFlatDown");
218  std::string labelShape = "CalShape";
219  // std::string labelSlopeY = "CalSlopeY";
220  std::string labelCherenkov_m = "Noshift";
221 
222  std::pair<std::string, std::string> labelLight =
223  std::make_pair("ULLevel", "DLLevel");
224  std::string labelCherenkov = "Cherenkov";
225 
226  std::pair<std::string, std::string> labelsCalibRelFD =
227  std::make_pair("CalFlatUpFD", "CalFlatDownFD");
228 
229  std::pair<std::string, std::string> labelsCalibRelND =
230  std::make_pair("CalFlatUpND", "CalFlatDownND");
231 
232  std::pair<std::string, std::string> labelsCalibRelEX =
233  std::make_pair("CalFlatUpEX", "CalFlatDownEX");
234 
235  std::vector<std::string> labelsKaon;
236  labelsKaon.push_back("Kaon");
237 
238  std::string labelsXsec = "NoXSec";
239 
240  std::vector<std::string> labelsTau;
241  labelsTau.push_back("Tau");
242 
243  std::vector<std::string> labelsNeutron;
244  labelsNeutron.push_back("NeutronPrimaries");
245 
246  // std::vector<std::string> labelsflux;
247  // for (int i = 0; i < 100; ++i)
248  // labelsflux.push_back(std::to_string(i));
249 
250  // Commented systs are >1% effect on NC signal (None!)
251  std::vector<std::string> labelsGENIE;
252  std::vector<std::string> labelsGENIE_NOvA;
253  labelsGENIE_NOvA.push_back("ReweightMaNCEL");
254  labelsGENIE_NOvA.push_back("ReweightEtaNCEL");
255  labelsGENIE_NOvA.push_back("ReweightVecCCQEshape");
256  labelsGENIE_NOvA.push_back("ReweightMaCCRES");
257  labelsGENIE_NOvA.push_back("ReweightMvCCRES");
258  labelsGENIE_NOvA.push_back("ReweightMaNCRES");
259  labelsGENIE_NOvA.push_back("ReweightMvNCRES");
260  labelsGENIE_NOvA.push_back("ReweightMaCOHpi");
261  labelsGENIE_NOvA.push_back("ReweightR0COHpi");
262  labelsGENIE_NOvA.push_back("ReweightAhtBY");
263  labelsGENIE_NOvA.push_back("ReweightBhtBY");
264  labelsGENIE_NOvA.push_back("ReweightCV1uBY");
265  labelsGENIE_NOvA.push_back("ReweightCV2uBY");
266  labelsGENIE_NOvA.push_back("ReweightNormDISCC");
267  labelsGENIE_NOvA.push_back("ReweightRnubarnuCC");
268  labelsGENIE_NOvA.push_back("ReweightDISNuclMod");
269  labelsGENIE_NOvA.push_back("ReweightNC");
270  labelsGENIE_NOvA.push_back("ReweightAGKY_xF1pi");
271  labelsGENIE_NOvA.push_back("ReweightAGKY_pT1pi");
272  labelsGENIE_NOvA.push_back("ReweightFormZone");
273  labelsGENIE_NOvA.push_back("ReweightMFP_pi");
274  labelsGENIE_NOvA.push_back("ReweightMFP_N");
275  labelsGENIE_NOvA.push_back("ReweightFrCEx_pi");
276  labelsGENIE_NOvA.push_back("ReweightFrElas_pi");
277  labelsGENIE_NOvA.push_back("ReweightFrInel_pi");
278  labelsGENIE_NOvA.push_back("ReweightFrAbs_pi");
279  labelsGENIE_NOvA.push_back("ReweightFrPiProd_pi");
280  labelsGENIE_NOvA.push_back("ReweightFrCEx_N");
281  labelsGENIE_NOvA.push_back("ReweightFrElas_N");
282  labelsGENIE_NOvA.push_back("ReweightFrInel_N");
283  labelsGENIE_NOvA.push_back("ReweightFrAbs_N");
284  labelsGENIE_NOvA.push_back("ReweightFrPiProd_N");
285  labelsGENIE_NOvA.push_back("ReweightCCQEPauliSupViaKF");
286  labelsGENIE_NOvA.push_back("ReweightCCQEMomDistroFGtoSF");
287  labelsGENIE_NOvA.push_back("ReweightBR1gamma");
288  labelsGENIE_NOvA.push_back("ReweightBR1eta");
289  labelsGENIE_NOvA.push_back("ReweightTheta_Delta2Npi");
290  labelsGENIE.push_back("PD3_MAQAGenieReducedSyst2018");
291  labelsGENIE.push_back("PD3_RPACCQEEnhSyst2018");
292  labelsGENIE.push_back("PD3_RPACCQESuppSyst2018");
293  labelsGENIE.push_back("PD3_RPARESSyst2018");
294  labelsGENIE.push_back("PD3_MECEShapeSyst2018Nu");
295  labelsGENIE.push_back("PD3_MECEShapeSyst2018AntiNu");
296  labelsGENIE.push_back("PD3_MECEnuShapeSyst2018Nu");
297  labelsGENIE.push_back("PD3_MECEnuShapeSyst2018AntiNu");
298  labelsGENIE.push_back("PD3_MECInitStateNPFracSyst2018Nu");
299 
300  // labelsGENIE.push_back("ReweightMaNCEL");
301  // labelsGENIE.push_back("ReweightEtaNCEL");
302  // labelsGENIE.push_back("ReweightVecCCQEshape");
303  // labelsGENIE.push_back("ReweightCCQEPauliSupViaKF");
304  // labelsGENIE.push_back("ReweightCCQEMomDistroFGtoSF");
305  // labelsGENIE.push_back("ReweightMaCCRES");
306  // labelsGENIE.push_back("ReweightMvCCRES");
307  // labelsGENIE.push_back("ReweightMaNCRES");
308  // labelsGENIE.push_back("ReweightMvNCRES");
309  // labelsGENIE.push_back("ReweightMaCOHpi");
310  // labelsGENIE.push_back("ReweightR0COHpi");
311  // labelsGENIE.push_back("ReweightAhtBY");
312  // labelsGENIE.push_back("ReweightBhtBY");
313  // labelsGENIE.push_back("ReweightCV1uBY");
314  // labelsGENIE.push_back("ReweightCV2uBY");
315  // labelsGENIE.push_back("ReweightAhtBYshape");
316  // labelsGENIE.push_back("ReweightBhtBYshape");
317  // labelsGENIE.push_back("ReweightCV1uBYshape");
318  // labelsGENIE.push_back("ReweightCV2uBYshape");
319  // labelsGENIE.push_back("ReweightNormDISCC");
320  // labelsGENIE.push_back("ReweightRnubarnuCC");
321  // labelsGENIE.push_back("ReweightDISNuclMod");
322  // labelsGENIE.push_back("ReweightNC");
323  // labelsGENIE.push_back("ReweightAGKY_xF1pi");
324  // labelsGENIE.push_back("ReweightAGKY_pT1pi");
325  // labelsGENIE.push_back("ReweightFormZone");
326  // labelsGENIE.push_back("ReweightTheta_Delta2Npi");
327  // labelsGENIE.push_back("ReweightBR1gamma");
328  // labelsGENIE.push_back("ReweightBR1eta");
329  // labelsGENIE.push_back("ReweightMFP_N");
330  // labelsGENIE.push_back("ReweightFrCEx_N");
331  // labelsGENIE.push_back("ReweightFrElas_N");
332  // labelsGENIE.push_back("ReweightFrInel_N");
333  // labelsGENIE.push_back("ReweightFrAbs_N");
334  // labelsGENIE.push_back("ReweightFrPiProd_N");
335  // labelsGENIE.push_back("ReweightMFP_pi");
336  // labelsGENIE.push_back("ReweightFrCEx_pi");
337  // labelsGENIE.push_back("ReweightFrElas_pi");
338  // labelsGENIE.push_back("ReweightFrInel_pi");
339  // labelsGENIE.push_back("ReweightFrAbs_pi");
340  // labelsGENIE.push_back("ReweightFrPiProd_pi");
341  // labelsGENIE.push_back("PD3_MAQAGenieReducedSyst2018");
342  // labelsGENIE.push_back("PD3_RPACCQEEnhSyst2018");
343  // labelsGENIE.push_back("PD3_RPACCQESuppSyst2018");
344  // labelsGENIE.push_back("PD3_RPARESSyst2018");
345  // labelsGENIE.push_back("PD3_MECq0ShapeSyst2018");
346  // labelsGENIE.push_back("PD3_MECInitStateNPFracSyst2018");
347  // labelsGENIE.push_back("PD3_MECEnuShapeSyst2018");
348 
349  labelsGENIE.push_back("PD3_DISvpCC0pi");
350  labelsGENIE.push_back("PD3_DISvpCC1pi");
351  labelsGENIE.push_back("PD3_DISvpCC2pi");
352  labelsGENIE.push_back("PD3_DISvpCC3pi");
353  labelsGENIE.push_back("PD3_DISvpNC0pi");
354  labelsGENIE.push_back("PD3_DISvpNC1pi");
355  labelsGENIE.push_back("PD3_DISvpNC2pi");
356  labelsGENIE.push_back("PD3_DISvpNC3pi");
357  labelsGENIE.push_back("PD3_DISvnCC0pi");
358  labelsGENIE.push_back("PD3_DISvnCC1pi");
359  labelsGENIE.push_back("PD3_DISvnCC2pi");
360  labelsGENIE.push_back("PD3_DISvnCC3pi");
361  labelsGENIE.push_back("PD3_DISvnNC0pi");
362  labelsGENIE.push_back("PD3_DISvnNC1pi");
363  labelsGENIE.push_back("PD3_DISvnNC2pi");
364  labelsGENIE.push_back("PD3_DISvnNC3pi");
365  labelsGENIE.push_back("PD3_DISvbarpCC0pi");
366  labelsGENIE.push_back("PD3_DISvbarpCC1pi");
367  labelsGENIE.push_back("PD3_DISvbarpCC2pi");
368  labelsGENIE.push_back("PD3_DISvbarpCC3pi");
369  labelsGENIE.push_back("PD3_DISvbarpNC0pi");
370  labelsGENIE.push_back("PD3_DISvbarpNC1pi");
371  labelsGENIE.push_back("PD3_DISvbarpNC2pi");
372  labelsGENIE.push_back("PD3_DISvbarpNC3pi");
373  labelsGENIE.push_back("PD3_DISvbarnCC0pi");
374  labelsGENIE.push_back("PD3_DISvbarnCC1pi");
375  labelsGENIE.push_back("PD3_DISvbarnCC2pi");
376  labelsGENIE.push_back("PD3_DISvbarnCC3pi");
377  labelsGENIE.push_back("PD3_DISvbarnNC0pi");
378  labelsGENIE.push_back("PD3_DISvbarnNC1pi");
379  labelsGENIE.push_back("PD3_DISvbarnNC2pi");
380  labelsGENIE.push_back("PD3_DISvbarnNC3pi");
381  labelsGENIE.push_back("PD3_RadCorrNue");
382  labelsGENIE.push_back("PD3_RadCorrNuebar");
383  labelsGENIE.push_back("PD3_k2ndClassCurr");
384 
385  // Set up maps to the decompositions/predictions (each flavor component)
386  // Nominal maps are indexed purely by sample label
387  // Shifted maps are indexed by sample label, systematic label, then sigma of the shift
388  std::map<std::string, NDPredictionSterile*> predsND_nominal;
389  std::map<std::string, FDPredictionSterile*> predsFD_nominal;
390  std::map<std::string, PredictionSterile*> predsExtrap_nominal;
391  std::map<std::string, std::map<std::string, std::map<int, NDPredictionSterile*> > > predsND_shifted;
392  std::map<std::string, std::map<std::string, std::map<int, FDPredictionSterile*> > > predsFD_shifted;
393  std::map<std::string, std::map<std::string, std::map<int, PredictionSterile*> > > predsExtrap_shifted;
394 
395  // Output file name that will contain histograms for ISyst objects
396  std::string folderout = "";
397  std::string saveLocation = folderout + "Nus18SystRatios.root";
398  TFile* rootF = new TFile(saveLocation.c_str(), "RECREATE");
399 
400  //......................................................................................................
401  std::cout << "Beam" << std::endl; // Inform the user of progress
402  // Create maps to contain nominal spectra,
403  // -1, 0, +1 sigma ratio histograms
404  // First index is channel (NC/BG), second is det (ND/FD/EX)
405  std::map<std::string, std::map<std::string, TH1*> > nomsBeam;
406  std::map<std::string, std::map<std::string, TH1*> > sfp1Beam;
407  std::map<std::string, std::map<std::string, TH1*> > sfm1Beam;
408  std::map<std::string, std::map<std::string, TH1*> > lineBeam;
409 
410  // Open Beam systematic file, fill maps that are ready
411  // Second input is base file name without extension
412  FillMaps(kSystFolder, kSystBeamT, sample, nomsBeam,
413  predsND_nominal, predsND_shifted,
414  predsFD_nominal, predsFD_shifted,
415  predsExtrap_nominal, predsExtrap_shifted,
416  kNCNDScale, kNCFDScale);
417 
418  // Add beam errors in quadrature
419  QuadErrors(labelsBeam, sample, nomsBeam,
420  predsND_shifted, predsFD_shifted, predsExtrap_shifted,
421  kNCNDScale, kNCFDScale);
422 
423  // Populate +/-1 sigma maps, make sure they have the correct axis
424  CloneMap(nomsBeam, sfp1Beam);
425  CloneMap(nomsBeam, sfm1Beam);
426  // Populate 0 sigma map, set these histograms to be lines at 1
427  NominalRat(nomsBeam, lineBeam);
428  // Set the +/-1 sigma histogram bins to appropiate ratio values
429  SetBinsPlusMinusOne(nomsBeam, sfp1Beam, sfm1Beam,
430  kNCNDScale, kNCFDScale);
431 
432  // Save the histograms to file
433  SaveMaps(sfp1Beam, rootF, "Beam18", "+1");
434  SaveMaps(sfm1Beam, rootF, "Beam18", "-1");
435  SaveMaps(lineBeam, rootF, "Beam18", "0");
436 
437  // Reset these maps as they are reused
438  predsND_nominal.clear();
439  predsND_shifted.clear();
440  predsFD_nominal.clear();
441  predsFD_shifted.clear();
442  predsExtrap_nominal.clear();
443  predsExtrap_shifted.clear();
444 
445  std::cout << "Beam done" << std::endl;
446 
447  //......................................................................................................
448  std::cout << "Calib, Both detectror ==>>> Flat up and down, and shape" << std::endl;
449  std::map<std::string, std::map<std::string, TH1*> > nomsCalAbs;
450  std::map<std::string, std::map<std::string, TH1*> > sfp1CalFlat;
451  std::map<std::string, std::map<std::string, TH1*> > sfm1CalFlat;
452  std::map<std::string, std::map<std::string, TH1*> > lineCalFlat;
453  std::map<std::string, std::map<std::string, TH1*> > shftCalShape;
454  std::map<std::string, std::map<std::string, TH1*> > lineCalShape;
455 
456  FillMaps(kSystFolder, kSystCalibAbs, sample, nomsCalAbs,
457  predsND_nominal, predsND_shifted,
458  predsFD_nominal, predsFD_shifted,
459  predsExtrap_nominal, predsExtrap_shifted,
460  kNCNDScale, kNCFDScale);
461 
462  CloneMap(nomsCalAbs, sfp1CalFlat);
463  CloneMap(nomsCalAbs, sfm1CalFlat);
464  NominalRat(nomsCalAbs, lineCalFlat);
465  CloneMap(nomsCalAbs, shftCalShape);
466  NominalRat(nomsCalAbs, lineCalShape);
467 
468  SetBinsPlusMinusOne(labelsFlat, sample, nomsCalAbs, sfp1CalFlat, sfm1CalFlat,
469  predsND_shifted, predsFD_shifted, predsExtrap_shifted,
470  kNCNDScale, kNCFDScale);
471  SetBinsOnOffShift(labelShape, sample, nomsCalAbs, shftCalShape,
472  predsND_shifted, predsFD_shifted, predsExtrap_shifted,
473  kNCNDScale, kNCFDScale);
474 
475  SaveMaps(sfp1CalFlat, rootF, "CalFlat18", "+1");
476  SaveMaps(sfm1CalFlat, rootF, "CalFlat18", "-1");
477  SaveMaps(lineCalFlat, rootF, "CalFlat18", "0");
478  SaveMaps(shftCalShape, rootF, "CalShape18", "+1");
479  SaveMaps(shftCalShape, rootF, "CalShape18", "-1");
480  SaveMaps(lineCalShape, rootF, "CalShape18", "0");
481 
482  predsND_nominal.clear();
483  predsND_shifted.clear();
484  predsFD_nominal.clear();
485  predsFD_shifted.clear();
486  predsExtrap_nominal.clear();
487  predsExtrap_shifted.clear();
488 
489  //......................................................................................................
490  std::cout << "Calib, Both detector ==>>> Light up down and Cherenkov ==>>>Nonshifted to shifted." << std::endl;
491  std::map<std::string, std::map<std::string, TH1*> > nomsCalAbs1;
492  std::map<std::string, std::map<std::string, TH1*> > sfp1Light;
493  std::map<std::string, std::map<std::string, TH1*> > sfm1Light;
494  std::map<std::string, std::map<std::string, TH1*> > lineLight;
495  std::map<std::string, std::map<std::string, TH1*> > shftCherenkov;
496  std::map<std::string, std::map<std::string, TH1*> > lineCherenkov;
497  // std::map<std::string, std::map<std::string, TH1*> > nomsCalAbs_m;
498 
499  FillMaps(kSystFolder, kSystLL, sample, nomsCalAbs1,
500  predsND_nominal, predsND_shifted,
501  predsFD_nominal, predsFD_shifted,
502  predsExtrap_nominal, predsExtrap_shifted,
503  kNCNDScale, kNCFDScale);
504 
505  CloneMap(nomsCalAbs1, sfp1Light);
506  CloneMap(nomsCalAbs1, sfm1Light);
507  NominalRat(nomsCalAbs1, lineLight);
508  CloneMap(nomsCalAbs1, shftCherenkov);
509  NominalRat(nomsCalAbs1, lineCherenkov);
510 
511  SetBinsPlusMinusOne(labelLight, sample, nomsCalAbs1, sfp1Light, sfm1Light,
512  predsND_shifted, predsFD_shifted, predsExtrap_shifted,
513  kNCNDScale, kNCFDScale);
514  SetBinsOnOffShift(labelCherenkov, sample, nomsCalAbs1, shftCherenkov,
515  predsND_shifted, predsFD_shifted, predsExtrap_shifted,
516  kNCNDScale, kNCFDScale);
517 
518  SaveMaps(sfp1Light, rootF, "CalLight18", "+1");
519  SaveMaps(sfm1Light, rootF, "CalLight18", "-1");
520  SaveMaps(lineLight, rootF, "CalLight18", "0");
521  SaveMaps(shftCherenkov, rootF, "Cherenkov18", "+1");
522  SaveMaps(shftCherenkov, rootF, "Cherenkov18", "-1");
523  SaveMaps(lineCherenkov, rootF, "Cherenkov18", "0");
524 
525  predsND_nominal.clear();
526  predsND_shifted.clear();
527  predsFD_nominal.clear();
528  predsFD_shifted.clear();
529  predsExtrap_nominal.clear();
530  predsExtrap_shifted.clear();
531 
532  std::cout << "Calib done" << std::endl;
533 
534  // //......................................................................................................
535  // std::cout << "Calib, Single detector" << std::endl;
536  // std::map<std::string, std::map<std::string, TH1*> > nomsCalRel;
537  // std::map<std::string, std::map<std::string, TH1*> > sfp1CalRelFD;
538  // std::map<std::string, std::map<std::string, TH1*> > sfm1CalRelFD;
539  // std::map<std::string, std::map<std::string, TH1*> > sfp1CalRelND;
540  // std::map<std::string, std::map<std::string, TH1*> > sfm1CalRelND;
541  // // std::map<std::string, std::map<std::string, TH1*> > sfp1CalRelEX;
542  // // std::map<std::string, std::map<std::string, TH1*> > sfm1CalRelEX;
543  // std::map<std::string, std::map<std::string, TH1*> > lineCalRel;
544 
545  // FillMaps(kSystFolder, kSystCalibRel, sample, nomsCalRel,
546  // predsND_nominal, predsND_shifted,
547  // predsFD_nominal, predsFD_shifted,
548  // predsExtrap_nominal, predsExtrap_shifted,
549  // kNCNDScale, kNCFDScale);
550 
551  // CloneMap(nomsCalRel, sfp1CalRelFD);
552  // CloneMap(nomsCalRel, sfm1CalRelFD);
553  // CloneMap(nomsCalRel, sfp1CalRelND);
554  // CloneMap(nomsCalRel, sfm1CalRelND);
555  // // CloneMap(nomsCalRel, sfp1CalRelEX);
556  // // CloneMap(nomsCalRel, sfm1CalRelEX);
557  // NominalRat(nomsCalRel, lineCalRel);
558 
559  // SetBinsPlusMinusOne(labelsCalibRelFD, sample, nomsCalRel, sfp1CalRelFD, sfm1CalRelFD,
560  // predsND_shifted, predsFD_shifted, predsExtrap_shifted,
561  // kNCNDScale, kNCFDScale);
562  // SetBinsPlusMinusOne(labelsCalibRelND, sample, nomsCalRel, sfp1CalRelND, sfm1CalRelND,
563  // predsND_shifted, predsFD_shifted, predsExtrap_shifted,
564  // kNCNDScale, kNCFDScale);
565  // // SetBinsPlusMinusOne(labelsCalibRelEX, sample, nomsCalRel, sfp1CalRelEX, sfm1CalRelEX,
566  // // predsND_shifted, predsFD_shifted, predsExtrap_shifted,
567  // // kNCNDScale, kNCFDScale);
568 
569  // SaveMaps(sfp1CalRelFD, rootF, "CalRelFD", "+1");
570  // SaveMaps(sfm1CalRelFD, rootF, "CalRelFD", "-1");
571  // SaveMaps(lineCalRel, rootF, "CalRelFD", "0");
572  // SaveMaps(sfp1CalRelND, rootF, "CalRelND", "+1");
573  // SaveMaps(sfm1CalRelND, rootF, "CalRelND", "-1");
574  // SaveMaps(lineCalRel, rootF, "CalRelND", "0");
575  // // SaveMaps(sfp1CalRelEX, rootF, "CalRelEX", "+1");
576  // // SaveMaps(sfm1CalRelEX, rootF, "CalRelEX", "-1");
577  // // SaveMaps(lineCalRel, rootF, "CalRelEX", "0");
578 
579  // predsND_nominal.clear();
580  // predsND_shifted.clear();
581  // predsFD_nominal.clear();
582  // predsFD_shifted.clear();
583  // predsExtrap_nominal.clear();
584  // predsExtrap_shifted.clear();
585 
586  //......................................................................................................
587  std::cout << "Kaon" << std::endl;
588  std::map<std::string, std::map<std::string, TH1*> > nomsKaon;
589  std::map<std::string, std::map<std::string, TH1*> > sfp1Kaon;
590  std::map<std::string, std::map<std::string, TH1*> > sfm1Kaon;
591  std::map<std::string, std::map<std::string, TH1*> > lineKaon;
592 
593  FillMaps(kSystFolder, kSystKaon, sample, nomsKaon,
594  predsND_nominal, predsND_shifted,
595  predsFD_nominal, predsFD_shifted,
596  predsExtrap_nominal, predsExtrap_shifted,
597  kNCNDScale, kNCFDScale);
598 
599  QuadErrors(labelsKaon, sample, nomsKaon,
600  predsND_shifted, predsFD_shifted, predsExtrap_shifted,
601  kNCNDScale, kNCFDScale);
602 
603  CloneMap(nomsKaon, sfp1Kaon);
604  CloneMap(nomsKaon, sfm1Kaon);
605  NominalRat(nomsKaon, lineKaon);
606 
607  SetBinsPlusMinusOne(nomsKaon, sfp1Kaon, sfm1Kaon,
608  kNCNDScale, kNCFDScale);
609 
610  SaveMaps(sfp1Kaon, rootF, "Kaon18", "+1");
611  SaveMaps(sfm1Kaon, rootF, "Kaon18", "-1");
612  SaveMaps(lineKaon, rootF, "Kaon18", "0");
613 
614  predsND_nominal.clear();
615  predsND_shifted.clear();
616  predsFD_nominal.clear();
617  predsFD_shifted.clear();
618  predsExtrap_shifted.clear();
619  predsExtrap_shifted.clear();
620 
621  //......................................................................................................
622  std::cout << "Neutron" << std::endl;
623  std::map<std::string, std::map<std::string, TH1*> > nomsNeutron;
624  std::map<std::string, std::map<std::string, TH1*> > sfp1Neutron;
625  std::map<std::string, std::map<std::string, TH1*> > sfm1Neutron;
626  std::map<std::string, std::map<std::string, TH1*> > lineNeutron;
627 
628  FillMaps(kSystFolder, kSystNeutron, sample, nomsNeutron,
629  predsND_nominal, predsND_shifted,
630  predsFD_nominal, predsFD_shifted,
631  predsExtrap_nominal, predsExtrap_shifted,
632  kNCNDScale, kNCFDScale);
633 
634  QuadErrors(labelsNeutron, sample, nomsNeutron,
635  predsND_shifted, predsFD_shifted, predsExtrap_shifted,
636  kNCNDScale, kNCFDScale);
637 
638  CloneMap(nomsNeutron, sfp1Neutron);
639  CloneMap(nomsNeutron, sfm1Neutron);
640  NominalRat(nomsNeutron, lineNeutron);
641 
642  SetBinsPlusMinusOne(nomsNeutron, sfp1Neutron, sfm1Neutron,
643  kNCNDScale, kNCFDScale);
644 
645  SaveMaps(sfp1Neutron, rootF, "Neutron18", "+1");
646  SaveMaps(sfm1Neutron, rootF, "Neutron18", "-1");
647  SaveMaps(lineNeutron, rootF, "Neutron18", "0");
648 
649  predsND_nominal.clear();
650  predsND_shifted.clear();
651  predsFD_nominal.clear();
652  predsFD_shifted.clear();
653  predsExtrap_nominal.clear();
654  predsExtrap_shifted.clear();
655 
656  //......................................................................................................
657  std::cout << "Cross-section on/off" << std::endl;
658  std::map<std::string, std::map<std::string, TH1*> > nomsXsec;
659  std::map<std::string, std::map<std::string, TH1*> > shftXsec;
660  std::map<std::string, std::map<std::string, TH1*> > lineXsec;
661 
662  FillMaps(kSystFolder, kSystXSecOnOff, sample, nomsXsec,
663  predsND_nominal, predsND_shifted,
664  predsFD_nominal, predsFD_shifted,
665  predsExtrap_nominal, predsExtrap_shifted,
666  kNCNDScale, kNCFDScale);
667 
668  CloneMap(nomsXsec, shftXsec);
669  NominalRat(nomsXsec, lineXsec);
670 
671  SetBinsOnOffShift(labelsXsec, sample, nomsXsec, shftXsec,
672  predsND_shifted, predsFD_shifted, predsExtrap_shifted,
673  kNCNDScale, kNCFDScale);
674 
675  SaveMaps(shftXsec, rootF, "XSecOnOff18", "+1");
676  SaveMaps(shftXsec, rootF, "XSecOnOff18", "-1");
677  SaveMaps(lineXsec, rootF, "XSecOnOff18", "0");
678 
679  predsND_nominal.clear();
680  predsND_shifted.clear();
681  predsFD_nominal.clear();
682  predsFD_shifted.clear();
683  predsExtrap_nominal.clear();
684  predsExtrap_shifted.clear();
685 
686  //......................................................................................................
687  std::cout << "Tau" << std::endl;
688  std::map<std::string, std::map<std::string, TH1*> > nomsTau;
689  std::map<std::string, std::map<std::string, TH1*> > sfp1Tau;
690  std::map<std::string, std::map<std::string, TH1*> > sfm1Tau;
691  std::map<std::string, std::map<std::string, TH1*> > lineTau;
692 
693  FillMaps(kSystFolder, kSystTau, sample, nomsTau,
694  // predsND_nominal, predsND_shifted,
695  // predsFD_nominal, predsFD_shifted,
696  predsExtrap_nominal, predsExtrap_shifted,
697  kNCNDScale, kNCFDScale);
698 
699  QuadErrors(labelsTau, sample, nomsTau,
700  // predsND_shifted, predsFD_shifted,
701  predsExtrap_shifted,
702  kNCNDScale, kNCFDScale);
703 
704  CloneMap(nomsTau, sfp1Tau);
705  CloneMap(nomsTau, sfm1Tau);
706  NominalRat(nomsTau, lineTau);
707 
708  SetBinsPlusMinusOne(nomsTau, sfp1Tau, sfm1Tau,
709  kNCNDScale, kNCFDScale);
710  // SetBinsPlusMinusOne(labelsTau, sample, nomsTau, sfp1Tau, sfm1Tau,
711  // predsND_shifted, predsFD_shifted,
712  // kNCNDScale, kNCFDScale);
713 
714  SaveMaps(sfp1Tau, rootF, "TauScale18", "+1");
715  SaveMaps(sfm1Tau, rootF, "TauScale18", "-1");
716  SaveMaps(lineTau, rootF, "TauScale18", "0");
717 
718  predsND_nominal.clear();
719  predsND_shifted.clear();
720  predsFD_nominal.clear();
721  predsFD_shifted.clear();
722  predsExtrap_nominal.clear();
723  predsExtrap_shifted.clear();
724 
725  //................................................................................................
726  std::cout << "Small GENIE ND1" << std::endl;
727  std::map<std::string, std::map<std::string, TH1*> > nomsGENIEND1;
728  std::map<std::string, std::map<std::string, TH1*> > sfp1GENIEND1;
729  std::map<std::string, std::map<std::string, TH1*> > sfm1GENIEND1;
730  std::map<std::string, std::map<std::string, TH1*> > lineGENIEND1;
731 
732  FillMaps(kSystFolder, kSystGENIE_ND1, sample, nomsGENIEND1,
733  predsND_nominal, predsND_shifted,
734  kNCNDScale, kNCFDScale);
735  QuadErrors(labelsGENIE_NOvA, sample, nomsGENIEND1,
736  predsND_shifted,
737  kNCNDScale, kNCFDScale);
738 
739  CloneMap(nomsGENIEND1, sfp1GENIEND1);
740  CloneMap(nomsGENIEND1, sfm1GENIEND1);
741  NominalRat(nomsGENIEND1, lineGENIEND1);
742 
743  SetBinsPlusMinusOne(nomsGENIEND1, sfp1GENIEND1, sfm1GENIEND1,
744  kNCNDScale, kNCFDScale);
745 
746  SaveMaps(sfp1GENIEND1, rootF, "GENIEn18", "+1");
747  SaveMaps(sfm1GENIEND1, rootF, "GENIEn18", "-1");
748  SaveMaps(lineGENIEND1, rootF, "GENIEn18", "0");
749 
750  predsND_nominal.clear();
751  predsND_shifted.clear();
752 
753  std::cout << "Genie ND1 done" << std::endl;
754 
755  //......................................................................................................
756  std::cout << "Small GENIE ND2" << std::endl;
757  std::map<std::string, std::map<std::string, TH1*> > nomsGENIEND2;
758  std::map<std::string, std::map<std::string, TH1*> > sfp1GENIEND2;
759  std::map<std::string, std::map<std::string, TH1*> > sfm1GENIEND2;
760  std::map<std::string, std::map<std::string, TH1*> > lineGENIEND2;
761 
762  FillMaps(kSystFolder, kSystGENIE_ND2, sample, nomsGENIEND2,
763  predsND_nominal, predsND_shifted,
764  kNCNDScale, kNCFDScale);
765  QuadErrors(labelsGENIE, sample, nomsGENIEND2,
766  predsND_shifted,
767  kNCNDScale, kNCFDScale);
768 
769  CloneMap(nomsGENIEND2, sfp1GENIEND2);
770  CloneMap(nomsGENIEND2, sfm1GENIEND2);
771  NominalRat(nomsGENIEND2, lineGENIEND2);
772 
773  SetBinsPlusMinusOne(nomsGENIEND2, sfp1GENIEND2, sfm1GENIEND2,
774  kNCNDScale, kNCFDScale);
775 
776  SaveMaps(sfp1GENIEND2, rootF, "GENIEg18", "+1");
777  SaveMaps(sfm1GENIEND2, rootF, "GENIEg18", "-1");
778  SaveMaps(lineGENIEND2, rootF, "GENIEg18", "0");
779 
780  predsND_nominal.clear();
781  predsND_shifted.clear();
782 
783  std::cout << "Genie ND2 done" << std::endl;
784 
785  //......................................................................................................
786  std::cout << "Small GENIE FD1" << std::endl;
787  std::map<std::string, std::map<std::string, TH1*> > nomsGENIEFD1;
788  std::map<std::string, std::map<std::string, TH1*> > sfp1GENIEFD1;
789  std::map<std::string, std::map<std::string, TH1*> > sfm1GENIEFD1;
790  std::map<std::string, std::map<std::string, TH1*> > lineGENIEFD1;
791 
792  FillMaps(kSystFolder, kSystGENIE_FD1, sample, nomsGENIEFD1,
793  predsFD_nominal, predsFD_shifted,
794  kNCNDScale, kNCFDScale);
795  QuadErrors(labelsGENIE_NOvA, sample, nomsGENIEFD1,
796  predsFD_shifted,
797  kNCNDScale, kNCFDScale);
798 
799  CloneMap(nomsGENIEFD1, sfp1GENIEFD1);
800  CloneMap(nomsGENIEFD1, sfm1GENIEFD1);
801  NominalRat(nomsGENIEFD1, lineGENIEFD1);
802 
803  SetBinsPlusMinusOne(nomsGENIEFD1, sfp1GENIEFD1, sfm1GENIEFD1,
804  kNCNDScale, kNCFDScale);
805 
806  SaveMaps(sfp1GENIEFD1, rootF, "GENIEn18", "+1");
807  SaveMaps(sfm1GENIEFD1, rootF, "GENIEn18", "-1");
808  SaveMaps(lineGENIEFD1, rootF, "GENIEn18", "0");
809 
810  predsFD_nominal.clear();
811  predsFD_shifted.clear();
812 
813  std::cout << "Genie FD1 done" << std::endl;
814 
815  //......................................................................................................
816  std::cout << "Small GENIE FD2" << std::endl;
817  std::map<std::string, std::map<std::string, TH1*> > nomsGENIEFD2;
818  std::map<std::string, std::map<std::string, TH1*> > sfp1GENIEFD2;
819  std::map<std::string, std::map<std::string, TH1*> > sfm1GENIEFD2;
820  std::map<std::string, std::map<std::string, TH1*> > lineGENIEFD2;
821 
822  FillMaps(kSystFolder, kSystGENIE_FD2, sample, nomsGENIEFD2,
823  predsFD_nominal, predsFD_shifted,
824  kNCNDScale, kNCFDScale);
825  QuadErrors(labelsGENIE, sample, nomsGENIEFD2,
826  predsFD_shifted,
827  kNCNDScale, kNCFDScale);
828 
829  CloneMap(nomsGENIEFD2, sfp1GENIEFD2);
830  CloneMap(nomsGENIEFD2, sfm1GENIEFD2);
831  NominalRat(nomsGENIEFD2, lineGENIEFD2);
832 
833  SetBinsPlusMinusOne(nomsGENIEFD2, sfp1GENIEFD2, sfm1GENIEFD2,
834  kNCNDScale, kNCFDScale);
835 
836  SaveMaps(sfp1GENIEFD2, rootF, "GENIEg18", "+1");
837  SaveMaps(sfm1GENIEFD2, rootF, "GENIEg18", "-1");
838  SaveMaps(lineGENIEFD2, rootF, "GENIEg18", "0");
839 
840  predsFD_nominal.clear();
841  predsFD_shifted.clear();
842 
843  std::cout << "Genie FD2 done" << std::endl;
844 
845  //................................................................................................
846  std::cout << "GENIE Extrap1" << std::endl;
847  std::map<std::string, std::map<std::string, TH1*> > nomsGENIEExtrap1;
848  std::map<std::string, std::map<std::string, TH1*> > sfp1GENIEExtrap1;
849  std::map<std::string, std::map<std::string, TH1*> > sfm1GENIEExtrap1;
850  std::map<std::string, std::map<std::string, TH1*> > lineGENIEExtrap1;
851 
852  FillMaps(kSystFolder, kSystGENIE_Extrap1, sample, nomsGENIEExtrap1,
853  predsExtrap_nominal, predsExtrap_shifted,
854  kNCNDScale, kNCFDScale);
855  QuadErrors(labelsGENIE_NOvA, sample, nomsGENIEExtrap1,
856  predsExtrap_shifted,
857  kNCNDScale, kNCFDScale);
858 
859  CloneMap(nomsGENIEExtrap1, sfp1GENIEExtrap1);
860  CloneMap(nomsGENIEExtrap1, sfm1GENIEExtrap1);
861  NominalRat(nomsGENIEExtrap1, lineGENIEExtrap1);
862 
863  SetBinsPlusMinusOne(nomsGENIEExtrap1, sfp1GENIEExtrap1, sfm1GENIEExtrap1,
864  kNCNDScale, kNCFDScale);
865 
866  SaveMaps(sfp1GENIEExtrap1, rootF, "GENIEn18", "+1");
867  SaveMaps(sfm1GENIEExtrap1, rootF, "GENIEn18", "-1");
868  SaveMaps(lineGENIEExtrap1, rootF, "GENIEn18", "0");
869 
870  predsExtrap_nominal.clear();
871  predsExtrap_shifted.clear();
872 
873  std::cout << "Genie Extrap1 done" << std::endl;
874 
875  //................................................................................................
876  std::cout << "GENIE Extrap2" << std::endl;
877  std::map<std::string, std::map<std::string, TH1*> > nomsGENIEExtrap2;
878  std::map<std::string, std::map<std::string, TH1*> > sfp1GENIEExtrap2;
879  std::map<std::string, std::map<std::string, TH1*> > sfm1GENIEExtrap2;
880  std::map<std::string, std::map<std::string, TH1*> > lineGENIEExtrap2;
881 
882  FillMaps(kSystFolder, kSystGENIE_Extrap2, sample, nomsGENIEExtrap2,
883  predsExtrap_nominal, predsExtrap_shifted,
884  kNCNDScale, kNCFDScale);
885  QuadErrors(labelsGENIE, sample, nomsGENIEExtrap2,
886  predsExtrap_shifted,
887  kNCNDScale, kNCFDScale);
888 
889  CloneMap(nomsGENIEExtrap2, sfp1GENIEExtrap2);
890  CloneMap(nomsGENIEExtrap2, sfm1GENIEExtrap2);
891  NominalRat(nomsGENIEExtrap2, lineGENIEExtrap2);
892 
893  SetBinsPlusMinusOne(nomsGENIEExtrap2, sfp1GENIEExtrap2, sfm1GENIEExtrap2,
894  kNCNDScale, kNCFDScale);
895 
896  SaveMaps(sfp1GENIEExtrap2, rootF, "GENIEg18", "+1");
897  SaveMaps(sfm1GENIEExtrap2, rootF, "GENIEg18", "-1");
898  SaveMaps(lineGENIEExtrap2, rootF, "GENIEg18", "0");
899 
900  predsExtrap_nominal.clear();
901  predsExtrap_shifted.clear();
902 
903  std::cout << "Genie Extrap2 done" << std::endl;
904 
905  //......................................................................................................
906  rootF->Close();
907 
908  std::cout << "Finished. Ctrl+Z should be safe if the macro didn't quit." << std::endl;
909 }
910 
911 //------------------------------------------------------------------------------
912 void CloneMap(std::map<std::string, std::map<std::string, TH1*> >& noms,
913  std::map<std::string, std::map<std::string, TH1*> >& clone) {
914  for(const auto& stringmap : noms) {
915  for(const auto& stringhist: stringmap.second) {
916  clone[stringmap.first][stringhist.first] = (TH1*)stringhist.second->Clone();
917  }
918  }
919 
920  return;
921 }
922 
923 //------------------------------------------------------------------------------
925  std::map<std::string, std::map<std::string, TH1*> >& noms,
926  std::map<std::string, NDPredictionSterile*>& predsND_nominal,
927  std::map<std::string, std::map<std::string, std::map<int, NDPredictionSterile*> > >& predsND_shifted,
928  std::map<std::string, FDPredictionSterile*>& predsFD_nominal,
929  std::map<std::string, std::map<std::string, std::map<int, FDPredictionSterile*> > >& predsFD_shifted,
930  std::map<std::string, PredictionSterile*>& predsExtrap_nominal,
931  std::map<std::string, std::map<std::string, std::map<int, PredictionSterile*> > >& predsExtrap_shifted,
932  double kNCNDScale, double kNCFDScale) {
933 
934  std::string loadLocation = folder + systfile + ".root";
935  TFile* rootL = new TFile(loadLocation.c_str(), "READ");
936  LoadMaps(rootL, &predsFD_nominal, &predsFD_shifted);
937  LoadMaps(rootL, &predsND_nominal, &predsND_shifted);
938  LoadMaps(rootL, &predsExtrap_nominal, &predsExtrap_shifted);
939  rootL->Close();
940  noms["NC"]["ND"] = GetNC(predsND_nominal[sample], kNCNDScale);
941  noms["BG"]["ND"] = GetBG(predsND_nominal[sample], kNCNDScale);
942  noms["NC"]["FD"] = GetNC(predsFD_nominal[sample], kNCFDScale);
943  noms["BG"]["FD"] = GetBG(predsFD_nominal[sample], kNCFDScale);
944  noms["NC"]["EX"] = GetNC(predsExtrap_nominal[sample], kNCFDScale);
945  noms["BG"]["EX"] = GetBG(predsExtrap_nominal[sample], kNCFDScale);
946 
947  return;
948 }
949 
950 //------------------------------------------------------------------------------
952  std::map<std::string, std::map<std::string, TH1*> >& noms,
953  std::map<std::string, FDPredictionSterile*>& predsFD_nominal,
954  std::map<std::string, std::map<std::string, std::map<int, FDPredictionSterile*> > >& predsFD_shifted,
955  double kNCNDScale, double kNCFDScale) {
956 
957  std::string loadLocation = folder + systfile + ".root";
958  TFile* rootL = new TFile(loadLocation.c_str(), "READ");
959  LoadMaps(rootL, &predsFD_nominal, &predsFD_shifted);
960  rootL->Close();
961 
962  noms["NC"]["FD"] = GetNC(predsFD_nominal[sample], kNCFDScale);
963  noms["BG"]["FD"] = GetBG(predsFD_nominal[sample], kNCFDScale);
964 
965  return;
966 }
967 
968 //------------------------------------------------------------------------------
970  std::map<std::string, std::map<std::string, TH1*> >& noms,
971  std::map<std::string, NDPredictionSterile*>& predsND_nominal,
972  std::map<std::string, std::map<std::string, std::map<int, NDPredictionSterile*> > >& predsND_shifted,
973  double kNCNDScale, double kNCFDScale) {
974 
975  std::string loadLocation = folder + systfile + ".root";
976  TFile* rootL = new TFile(loadLocation.c_str(), "READ");
977  LoadMaps(rootL, &predsND_nominal, &predsND_shifted);
978  rootL->Close();
979 
980  noms["NC"]["ND"] = GetNC(predsND_nominal[sample], kNCNDScale);
981  noms["BG"]["ND"] = GetBG(predsND_nominal[sample], kNCNDScale);
982 
983  return;
984 }
985 
986 //------------------------------------------------------------------------------
988  std::map<std::string, std::map<std::string, TH1*> >& noms,
989  std::map<std::string, PredictionSterile*>& predsExtrap_nominal,
990  std::map<std::string, std::map<std::string, std::map<int, PredictionSterile*> > >& predsExtrap_shifted,
991  double kNCNDScale, double kNCFDScale) {
992 
993  std::string loadLocation = folder + systfile + ".root";
994  TFile* rootL = new TFile(loadLocation.c_str(), "READ");
995  LoadMaps(rootL, &predsExtrap_nominal, &predsExtrap_shifted);
996  rootL->Close();
997 
998  noms["NC"]["EX"] = GetNC(predsExtrap_nominal[sample], kNCFDScale);
999  noms["BG"]["EX"] = GetBG(predsExtrap_nominal[sample], kNCFDScale);
1000 
1001  return;
1002 }
1003 
1004 //------------------------------------------------------------------------------
1005 void FillMaps(std::string folder, std::string systfile1,std::string systfile2, std::string sample,
1006  std::map<std::string, std::map<std::string, TH1*> >& noms,
1007  std::map<std::string, NDPredictionSterile*>& predsND1_nominal,
1008  std::map<std::string, std::map<std::string, std::map<int, NDPredictionSterile*> > >& predsND1_shifted,
1009  std::map<std::string, NDPredictionSterile*>& predsND2_nominal,
1010  std::map<std::string, std::map<std::string, std::map<int, NDPredictionSterile*> > >& predsND2_shifted,
1011  double kNCNDScale, double kNCFDScale) {
1012 
1013  std::string folder1=folder;
1014  std::string loadLocation1 = folder + systfile1 + ".root";
1015  TFile* rootL1 = new TFile(loadLocation1.c_str(), "READ");
1016  LoadMaps(rootL1, &predsND1_nominal, &predsND1_shifted);
1017  rootL1->Close();
1018  noms["NC"]["ND"] = GetNC(predsND1_nominal[sample], kNCNDScale);
1019  noms["NC"]["BG"] = GetBG(predsND1_nominal[sample], kNCNDScale);
1020 
1021  std::string loadLocation2 = folder1 + systfile2 + ".root";
1022  TFile* rootL2 = new TFile(loadLocation2.c_str(), "READ");
1023  LoadMaps(rootL2, &predsND2_nominal, &predsND2_shifted);
1024  rootL2->Close();
1025  noms["NC"]["ND"] = GetNC(predsND2_nominal[sample], kNCNDScale);
1026  noms["BG"]["ND"] = GetBG(predsND2_nominal[sample], kNCNDScale);
1027 
1028  return;
1029 }
1030 
1031 //------------------------------------------------------------------------------
1033  std::string syst, std::string sigma) {
1034  // This pattern must match that in NusSystFromHist::LoadHists
1035  std::string ret = "h" + chan + "_" + det + "_" + syst + "_" + sigma;
1036  return ret;
1037 }
1038 
1039 //------------------------------------------------------------------------------
1041  std::string syst, std::string sigma) {
1042  std::string ret = chan + " " + det + " " + syst + " Systematic, "
1043  + sigma + "#sigma";
1044  return ret;
1045 }
1046 
1047 //------------------------------------------------------------------------------
1048 void NominalRat(std::map<std::string, std::map<std::string, TH1*> >& noms,
1049  std::map<std::string, std::map<std::string, TH1*> >& line) {
1050  CloneMap(noms, line); // Make sure axis matches
1051 
1053  for(int i = 0; i <= nbins; ++i) {
1054  for(const auto& stringmap : line) {
1055  std::string chan = stringmap.first;
1056  for(const auto& stringhist : stringmap.second) {
1057  std::string det = stringhist.first;
1058  line[chan][det]->SetBinContent(i, 1.);
1059  }
1060  }
1061  }
1062 }
1063 
1064 //------------------------------------------------------------------------------
1065 void QuadErrors(const std::vector<std::string>& shiftlabels, std::string sample,
1066  std::map<std::string, std::map<std::string, TH1*> >& noms,
1067  std::map<std::string, std::map<std::string, std::map<int, NDPredictionSterile*> > >& predsND_shifted,
1068  std::map<std::string, std::map<std::string, std::map<int, FDPredictionSterile*> > >& predsFD_shifted,
1069  std::map<std::string, std::map<std::string, std::map<int, PredictionSterile*> > >& predsExtrap_shifted,
1070  double kNCNDScale, double kNCFDScale) {
1071 
1072  for(const auto& shift : shiftlabels) {
1073  AddErrorInQuadrature(noms["NC"]["ND"],
1074  GetNC(predsND_shifted[sample][shift][+1], kNCNDScale),
1075  GetNC(predsND_shifted[sample][shift][-1], kNCNDScale));
1076  AddErrorInQuadrature(noms["BG"]["ND"],
1077  GetBG(predsND_shifted[sample][shift][+1], kNCNDScale),
1078  GetBG(predsND_shifted[sample][shift][-1], kNCNDScale));
1079  AddErrorInQuadrature(noms["NC"]["FD"],
1080  GetNC(predsFD_shifted[sample][shift][+1], kNCFDScale),
1081  GetNC(predsFD_shifted[sample][shift][-1], kNCFDScale));
1082  AddErrorInQuadrature(noms["BG"]["FD"],
1083  GetBG(predsFD_shifted[sample][shift][+1], kNCFDScale),
1084  GetBG(predsFD_shifted[sample][shift][-1], kNCFDScale));
1085  AddErrorInQuadrature(noms["NC"]["EX"],
1086  GetNC(predsExtrap_shifted[sample][shift][+1], kNCFDScale),
1087  GetNC(predsExtrap_shifted[sample][shift][-1], kNCFDScale));
1088  AddErrorInQuadrature(noms["BG"]["EX"],
1089  GetBG(predsExtrap_shifted[sample][shift][+1], kNCFDScale),
1090  GetBG(predsExtrap_shifted[sample][shift][-1], kNCFDScale));
1091  }
1092 
1093  SqrtError(noms["NC"]["ND"]);
1094  SqrtError(noms["BG"]["ND"]);
1095  SqrtError(noms["NC"]["FD"]);
1096  SqrtError(noms["BG"]["FD"]);
1097  SqrtError(noms["NC"]["EX"]);
1098  SqrtError(noms["BG"]["EX"]);
1099 
1100  return;
1101 
1102 }
1103 
1104 //------------------------------------------------------------------------------
1105 void QuadErrors(const std::vector<std::string>& shiftlabels, std::string sample,
1106  std::map<std::string, std::map<std::string, TH1*> >& noms,
1107  std::map<std::string, std::map<std::string, std::map<int, FDPredictionSterile*> > >& predsFD_shifted,
1108  double kNCNDScale, double kNCFDScale) {
1109 
1110  for(const auto& shift : shiftlabels) {
1111  AddErrorInQuadrature(noms["NC"]["FD"],
1112  GetNC(predsFD_shifted[sample][shift][+1], kNCFDScale),
1113  GetNC(predsFD_shifted[sample][shift][-1], kNCFDScale));
1114  AddErrorInQuadrature(noms["BG"]["FD"],
1115  GetBG(predsFD_shifted[sample][shift][+1], kNCFDScale),
1116  GetBG(predsFD_shifted[sample][shift][-1], kNCFDScale));
1117  }
1118 
1119  SqrtError(noms["NC"]["FD"]);
1120  SqrtError(noms["BG"]["FD"]);
1121 
1122  return;
1123 
1124 }
1125 
1126 //------------------------------------------------------------------------------
1127 void QuadErrors(const std::vector<std::string>& shiftlabels, std::string sample,
1128  std::map<std::string, std::map<std::string, TH1*> >& noms,
1129  std::map<std::string, std::map<std::string, std::map<int, NDPredictionSterile*> > >& predsND_shifted,
1130  double kNCNDScale, double kNCFDScale) {
1131 
1132  for(const auto& shift : shiftlabels) {
1133  AddErrorInQuadrature(noms["NC"]["ND"],
1134  GetNC(predsND_shifted[sample][shift][+1], kNCNDScale),
1135  GetNC(predsND_shifted[sample][shift][-1], kNCNDScale));
1136  AddErrorInQuadrature(noms["BG"]["ND"],
1137  GetBG(predsND_shifted[sample][shift][+1], kNCNDScale),
1138  GetBG(predsND_shifted[sample][shift][-1], kNCNDScale));
1139  }
1140 
1141  SqrtError(noms["NC"]["ND"]);
1142  SqrtError(noms["BG"]["ND"]);
1143 
1144  return;
1145 
1146 }
1147 
1148 //------------------------------------------------------------------------------
1149 void QuadErrors(const std::vector<std::string>& shiftlabels, std::string sample,
1150  std::map<std::string, std::map<std::string, TH1*> >& noms,
1151  std::map<std::string, std::map<std::string, std::map<int, PredictionSterile*> > >& predsExtrap_shifted,
1152  double kNCNDScale, double kNCFDScale) {
1153 
1154  for(const auto& shift : shiftlabels) {
1155  AddErrorInQuadrature(noms["NC"]["EX"],
1156  GetNC(predsExtrap_shifted[sample][shift][+1], kNCFDScale),
1157  GetNC(predsExtrap_shifted[sample][shift][-1], kNCFDScale));
1158  AddErrorInQuadrature(noms["BG"]["EX"],
1159  GetBG(predsExtrap_shifted[sample][shift][+1], kNCFDScale),
1160  GetBG(predsExtrap_shifted[sample][shift][-1], kNCFDScale));
1161  }
1162 
1163  SqrtError(noms["NC"]["EX"]);
1164  SqrtError(noms["BG"]["EX"]);
1165 
1166  return;
1167 
1168 }
1169 
1170 
1171 //------------------------------------------------------------------------------
1172 void QuadErrors(const std::vector<std::string>& shiftlabels, std::string sample,
1173  std::map<std::string, std::map<std::string, TH1*> >& noms,
1174  std::map<std::string, std::map<std::string, std::map<int, NDPredictionSterile*> > >& predsND1_shifted,
1175  std::map<std::string, std::map<std::string, std::map<int, NDPredictionSterile*> > >& predsND2_shifted,
1176  double kNCNDScale, double kNCFDScale) {
1177 
1178  for(const auto& shift : shiftlabels) {
1179  AddErrorInQuadrature(noms["NC"]["ND"],
1180  GetNC(predsND1_shifted[sample][shift][+1], kNCNDScale),
1181  GetNC(predsND1_shifted[sample][shift][-1], kNCNDScale),
1182  GetNC(predsND2_shifted[sample][shift][+1], kNCNDScale),
1183  GetNC(predsND2_shifted[sample][shift][-1], kNCNDScale));
1184  AddErrorInQuadrature(noms["BG"]["ND"],
1185  GetBG(predsND1_shifted[sample][shift][+1], kNCNDScale),
1186  GetBG(predsND1_shifted[sample][shift][-1], kNCNDScale),
1187  GetBG(predsND2_shifted[sample][shift][+1], kNCNDScale),
1188  GetBG(predsND2_shifted[sample][shift][-1], kNCNDScale));
1189  }
1190 
1191  SqrtError(noms["NC"]["ND"]);
1192  SqrtError(noms["BG"]["ND"]);
1193 
1194  return;
1195 
1196 }
1197 
1198 //------------------------------------------------------------------------------
1199 void SaveMaps(std::map<std::string, std::map<std::string, TH1*> >& hists,
1200  TDirectory* out, std::string syst, std::string sigma)
1201 {
1202  for (const auto& stringmap : hists) {
1203  for (const auto& stringhist: stringmap.second) {
1204  std::string chan = stringmap.first;
1205  std::string det = stringhist.first;
1206  hists[chan][det]->SetName(MakeName(chan, det, syst, sigma).c_str());
1207  hists[chan][det]->SetTitle(MakeTitle(chan, det, syst, sigma).c_str());
1208  ZeroError(hists[chan][det]);
1209  out->WriteTObject(hists[chan][det]);
1210  }
1211  }
1212 
1213  return;
1214 
1215 }
1216 
1217 //------------------------------------------------------------------------------
1219  std::map<std::string, std::map<std::string, TH1*> >& noms,
1220  std::map<std::string, std::map<std::string, TH1*> >& shft,
1221  std::map<std::string, std::map<std::string, std::map<int, NDPredictionSterile*> > >& predsND_shifted,
1222  std::map<std::string, std::map<std::string, std::map<int, FDPredictionSterile*> > >& predsFD_shifted,
1223  std::map<std::string, std::map<std::string, std::map<int, PredictionSterile*> > >& predsExtrap_shifted,
1224  double kNCNDScale, double kNCFDScale) {
1225 
1227  double nom = 0., sft = 0.;
1228  std::string chan = "", det = "";
1229 
1230  std::map<std::string, std::map<std::string, TH1*> > sfts;
1231  sfts["NC"]["ND"] = GetNC(predsND_shifted[sample][shiftlabel][1], kNCNDScale);
1232  sfts["BG"]["ND"] = GetBG(predsND_shifted[sample][shiftlabel][1], kNCNDScale);
1233  sfts["NC"]["FD"] = GetNC(predsFD_shifted[sample][shiftlabel][1], kNCFDScale);
1234  sfts["BG"]["FD"] = GetBG(predsFD_shifted[sample][shiftlabel][1], kNCFDScale);
1235  sfts["NC"]["EX"] = GetNC(predsExtrap_shifted[sample][shiftlabel][1], kNCFDScale);
1236  sfts["BG"]["EX"] = GetBG(predsExtrap_shifted[sample][shiftlabel][1], kNCFDScale);
1237 
1238  for(int i = 0; i <= nbins; ++i) {
1239  for(const auto& stringmap : noms) {
1240  chan = stringmap.first;
1241  for(const auto& stringhist : stringmap.second) {
1242  det = stringhist.first;
1243 
1244  // std::cout << " The bin content of Channel = " << stringmap.first
1245  // << " and detector = " << stringhist.first
1246  // << " is " << noms[chan][det]->GetBinContent(i)
1247  // << " with an error " << noms[chan][det]->GetBinError(i) << std::endl;
1248 
1249  nom = noms[chan][det]->GetBinContent(i);
1250  sft = sfts[chan][det]->GetBinContent(i);
1251 
1252  shft[chan][det]->SetBinContent(i, std::max(0., sft/nom));
1253  }
1254  }
1255  }
1256 
1257  return;
1258 
1259 }
1260 
1261 //------------------------------------------------------------------------------
1262 void SetBinsPlusMinusOne(std::pair<std::string, std::string> shiftlabels, std::string sample,
1263  std::map<std::string, std::map<std::string, TH1*> >& noms,
1264  std::map<std::string, std::map<std::string, TH1*> >& sfp1,
1265  std::map<std::string, std::map<std::string, TH1*> >& sfm1,
1266  std::map<std::string, std::map<std::string, std::map<int, NDPredictionSterile*> > >& predsND_shifted,
1267  std::map<std::string, std::map<std::string, std::map<int, FDPredictionSterile*> > >& predsFD_shifted,
1268  std::map<std::string, std::map<std::string, std::map<int, PredictionSterile*> > >& predsExtrap_shifted,
1269  double kNCNDScale, double kNCFDScale) {
1270 
1271  // This syst type essentially consists of two on/off systematics,
1272  // where one is +1 sigma and the other -1 sigma
1273  SetBinsOnOffShift(shiftlabels.first, sample, noms, sfp1,
1274  predsND_shifted, predsFD_shifted, predsExtrap_shifted,
1275  kNCNDScale, kNCFDScale);
1276  SetBinsOnOffShift(shiftlabels.second, sample, noms, sfm1,
1277  predsND_shifted, predsFD_shifted, predsExtrap_shifted,
1278  kNCNDScale, kNCFDScale);
1279 
1280 }
1281 
1282 //------------------------------------------------------------------------------
1283 void SetBinsPlusMinusOne(std::map<std::string, std::map<std::string, TH1*> >& noms,
1284  std::map<std::string, std::map<std::string, TH1*> >& sfp1,
1285  std::map<std::string, std::map<std::string, TH1*> >& sfm1,
1286  double kNCNDScale, double kNCFDScale) {
1287 
1289  double nom = 0., err = 0.;
1290  std::string chan = "", det = "";
1291 
1292  for(int i = 0; i <= nbins; ++i) {
1293  for(const auto& stringmap : noms) {
1294  chan = stringmap.first;
1295  for(const auto& stringhist : stringmap.second) {
1296  det = stringhist.first;
1297  nom = noms[chan][det]->GetBinContent(i);
1298  err = noms[chan][det]->GetBinError(i);
1299 
1300  // std::cout << " The bin content of Channel = " << stringmap.first
1301  // << " and detector = " << stringhist.first
1302  // << " is " << noms[chan][det]->GetBinContent(i)
1303  // << " with an error " << noms[chan][det]->GetBinError(i) << std::endl;
1304 
1305  // This type of systematic has been added in quadrature
1306  // The expected format is that the relative shift is the bin error
1307  sfp1[chan][det]->SetBinContent(i, std::max(0., (nom+err)/nom));
1308  sfm1[chan][det]->SetBinContent(i, std::max(0., (nom-err)/nom));
1309  }
1310  }
1311  }
1312 
1313  return;
1314 
1315 }
1316 
1317 
1318 // Combined GENIE
1319 
1320  // //......................................................................................................
1321  // std::cout << "Small GENIE" << std::endl;
1322  // std::map<std::string, std::map<std::string, TH1*> > nomsGENIE;
1323  // std::map<std::string, std::map<std::string, TH1*> > sfp1GENIE;
1324  // std::map<std::string, std::map<std::string, TH1*> > sfm1GENIE;
1325  // std::map<std::string, std::map<std::string, TH1*> > lineGENIE;
1326 
1327  // FillMaps(kSystFolder, kSystGENIE, sample, nomsGENIE,
1328  // predsND_nominal, predsND_shifted,
1329  // predsFD_nominal, predsFD_shifted,
1330  // kNCNDScale, kNCFDScale);
1331  // QuadErrors(labelsGENIE, sample, nomsGENIE,
1332  // predsND_shifted,predsFD_shifted,
1333  // kNCNDScale, kNCFDScale);
1334 
1335  // CloneMap(nomsGENIE, sfp1GENIE);
1336  // CloneMap(nomsGENIE, sfm1GENIE);
1337  // NominalRat(nomsGENIE, lineGENIE);
1338 
1339  // SetBinsPlusMinusOne(nomsGENIE, sfp1GENIE, sfm1GENIE,
1340  // kNCNDScale, kNCFDScale);
1341 
1342  // SaveMaps(sfp1GENIE, rootF, "GENIESm18", "+1");
1343  // SaveMaps(sfm1GENIE, rootF, "GENIESm18", "-1");
1344  // SaveMaps(lineGENIE, rootF, "GENIESm18", "0");
1345 
1346  // predsND_nominal.clear();
1347  // predsND_shifted.clear();
1348  // predsFD_nominal.clear();
1349  // predsFD_shifted.clear();
1350  // std::cout << "Genie done" << std::endl;
1351 
1352  // //......................................................................................................
1353  // std::cout << "Small ND GENIE start" << std::endl;
1354  // std::map<std::string, std::map<std::string, TH1*> > nomsGENIE1;
1355  // std::map<std::string, std::map<std::string, TH1*> > sfp1GENIE1;
1356  // std::map<std::string, std::map<std::string, TH1*> > sfm1GENIE1;
1357  // std::map<std::string, std::map<std::string, TH1*> > lineGENIE1;
1358 
1359  // FillMaps(kSystFolder, kSystGENIE_ND1, kSystGENIE_ND2, sample,nomsGENIE1,
1360  // predsND1_nominal, predsND1_shifted,
1361  // predsND2_nominal, predsND2_shifted,
1362  // kNCNDScale, kNCFDScale);
1363 
1364  // QuadErrors(labelsGENIE, sample, nomsGENIE1,
1365  // predsND1_shifted, predsND2_shifted,
1366  // kNCNDScale, kNCFDScale);
1367 
1368  // CloneMap(nomsGENIE1, sfp1GENIE1);
1369  // CloneMap(nomsGENIE1, sfm1GENIE1);
1370  // NominalRat(nomsGENIE1, lineGENIE1);
1371 
1372  // SetBinsPlusMinusOne(nomsGENIE1, sfp1GENIE1, sfm1GENIE1,
1373  // kNCNDScale, kNCFDScale);
1374 
1375  // SaveMaps(sfp1GENIE1, rootF, "GENIESm18", "+1");
1376  // SaveMaps(sfm1GENIE1, rootF, "GENIESm18", "-1");
1377  // SaveMaps(lineGENIE1, rootF, "GENIESm18", "0");
1378 
1379  // predsND1_nominal.clear();
1380  // predsND2_nominal.clear();
1381  // predsND1_shifted.clear();
1382  // predsND2_shifted.clear();
1383 
1384  // std::cout << "Small GENIE ND done" << std::endl;
1385 
1386  // //......................................................................................................
1387  // std::cout << "Small GENIE FD" << std::endl;
1388  // std::map<std::string, std::map<std::string, TH1*> > nomsGENIEs;
1389  // std::map<std::string, std::map<std::string, TH1*> > sfp1GENIEs;
1390  // std::map<std::string, std::map<std::string, TH1*> > sfm1GENIEs;
1391  // std::map<std::string, std::map<std::string, TH1*> > lineGENIEs;
1392 
1393  // FillMaps(kSystFolder, kSystGENIE_FD, sample, nomsGENIEs,
1394  // predsFD_nominal, predsFD_shifted,
1395  // kNCNDScale, kNCFDScale);
1396  // QuadErrors(labelsGENIE_NOvA, sample, nomsGENIEs,
1397  // predsFD_shifted,
1398  // kNCNDScale, kNCFDScale);
1399 
1400  // CloneMap(nomsGENIEs, sfp1GENIEs);
1401  // CloneMap(nomsGENIEs, sfm1GENIEs);
1402  // NominalRat(nomsGENIEs, lineGENIEs);
1403 
1404  // SetBinsPlusMinusOne(nomsGENIEs, sfp1GENIEs, sfm1GENIEs,
1405  // kNCNDScale, kNCFDScale);
1406 
1407  // SaveMaps(sfp1GENIEs, rootF, "GENIE18", "+1");
1408  // SaveMaps(sfm1GENIEs, rootF, "GENIE18", "-1");
1409  // SaveMaps(lineGENIEs, rootF, "GENIE18", "0");
1410 
1411  // predsFD_nominal.clear();
1412  // predsFD_shifted.clear();
1413 
1414  // std::cout << "Genie FD done" << std::endl;
T max(const caf::Proxy< T > &a, T b)
Cuts and Vars for the 2020 FD DiF Study.
Definition: vars.h:6
void SetBinsOnOffShift(std::string shiftlabel, std::string sample, std::map< std::string, std::map< std::string, TH1 * > > &noms, std::map< std::string, std::map< std::string, TH1 * > > &shft, std::map< std::string, std::map< std::string, std::map< int, NDPredictionSterile * > > > &predsND_shifted, std::map< std::string, std::map< std::string, std::map< int, FDPredictionSterile * > > > &predsFD_shifted, std::map< std::string, std::map< std::string, std::map< int, PredictionSterile * > > > &predsExtrap_shifted, double kNCNDScale, double kNCFDScale)
Set bins in shft to shift/nominal using the shiftlabel syst.
void SqrtError(TH1 *nom)
Set the errors of the input histogram to be their square roots.
Definition: PPFXHelper.h:139
void SaveMaps(TDirectory *out, std::map< std::string, IDecomp * > decomps_nominal, std::map< std::string, std::map< std::string, std::map< int, IDecomp * > > > decomps_shifted, std::map< std::string, PredictionNoExtrap * > predsNE_nominal, std::map< std::string, std::map< std::string, std::map< int, PredictionNoExtrap * > > > predsNE_shifted, std::map< std::string, PredictionSterile * > predsSt_nominal, std::map< std::string, std::map< std::string, std::map< int, PredictionSterile * > > > predsSt_shifted)
Save all of the objects in the input maps to the out directory/file.
Definition: PPFXHelper.h:1077
void FillMaps(std::string folder, std::string systfile, std::string sample, std::map< std::string, std::map< std::string, TH1 * > > &noms, std::map< std::string, NDPredictionSterile * > &predsND_nominal, std::map< std::string, std::map< std::string, std::map< int, NDPredictionSterile * > > > &predsND_shifted, std::map< std::string, FDPredictionSterile * > &predsFD_nominal, std::map< std::string, std::map< std::string, std::map< int, FDPredictionSterile * > > > &predsFD_shifted, std::map< std::string, PredictionSterile * > &predsExtrap_nominal, std::map< std::string, std::map< std::string, std::map< int, PredictionSterile * > > > &predsExtrap_shifted, double kNCNDScale, double kNCFDScale)
void ZeroError(TH1 *nom)
Set the errors of the input histogram to 0.
Definition: PPFXHelper.h:149
std::pair< Spectrum *, CheatDecomp * > make_pair(SpectrumLoaderBase &loader_data, SpectrumLoaderBase &loader_mc, HistAxis *axis, Cut *cut, const SystShifts &shift, const Var &wei)
Definition: DataMCLoad.C:336
std::string MakeTitle(std::string chan, std::string det, std::string syst, std::string sigma)
Make a standardized title for the syst ratio histogram.
TString hists[nhists]
Definition: bdt_com.C:3
std::string MakeName(std::string chan, std::string det, std::string syst, std::string sigma)
Make a standardized name for the syst ratio histogram.
const double kAna2018RHCPOT
Definition: Exposures.h:208
TH1 * GetNC(IDecomp *specs, double POT)
Definition: PPFXHelper.h:211
void QuadErrors(const std::vector< std::string > &shiftlabels, std::string sample, std::map< std::string, std::map< std::string, TH1 * > > &noms, std::map< std::string, std::map< std::string, std::map< int, NDPredictionSterile * > > > &predsND_shifted, std::map< std::string, std::map< std::string, std::map< int, FDPredictionSterile * > > > &predsFD_shifted, std::map< std::string, std::map< std::string, std::map< int, PredictionSterile * > > > &predsExtrap_shifted, double kNCNDScale, double kNCFDScale)
const int nbins
Definition: cellShifts.C:15
const Binning kNus18EnergyBinning
Energy binnings for Nus18 for nus analysis.
Definition: Binning.cxx:74
void AddErrorInQuadrature(TH1 *nom, TH1 *up, bool use_max)
Definition: PPFXHelper.h:163
void CloneMap(std::map< std::string, std::map< std::string, TH1 * > > &noms, std::map< std::string, std::map< std::string, TH1 * > > &clone)
Fill a second map with clones of histograms in the first map.
void NominalRat(std::map< std::string, std::map< std::string, TH1 * > > &noms, std::map< std::string, std::map< std::string, TH1 * > > &line)
Make nominal ratio histograms, a line at 1 corresponding to 0 sigma.
double sigma(TH1F *hist, double percentile)
OStream cout
Definition: OStream.cxx:6
void SetBinsPlusMinusOne(std::pair< std::string, std::string > shiftlabels, std::string sample, std::map< std::string, std::map< std::string, TH1 * > > &noms, std::map< std::string, std::map< std::string, TH1 * > > &sfp1, std::map< std::string, std::map< std::string, TH1 * > > &sfm1, std::map< std::string, std::map< std::string, std::map< int, NDPredictionSterile * > > > &predsND_shifted, std::map< std::string, std::map< std::string, std::map< int, FDPredictionSterile * > > > &predsFD_shifted, std::map< std::string, std::map< std::string, std::map< int, PredictionSterile * > > > &predsExtrap_shifted, double kNCNDScale, double kNCFDScale)
int NBins() const
Definition: Binning.h:29
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
const double kAna2018FHCPOT
Definition: Exposures.h:207
TH1 * GetBG(IDecomp *specs, double POT)
Definition: PPFXHelper.h:236
void Nus18SystMaker(bool rhc=false)
enum BeamMode string