SystsAcceptanceAna17.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["ND1"] = "ND1";
14  shiftlabels["ND2"] = "ND2";
15  shiftlabels["ND3"] = "ND3";
16  shiftlabels["ND4"] = "ND4";
17 
18  std::string labelRecoE = "Energy Deposited in Scintillator (GeV)";
19  std::vector<std::string> cut_samples;
20  cut_samples.push_back("Ana01");
21  double NCSCALE=8.85e20;
22 
23 
24  // Set up maps to the decompositions/predictions (each flavor component)
25  // Nominal maps are indexed purely by sample label
26  // Shifted maps are indexed by sample label, systematic label, then sigma of the shift
27  std::map<std::string, IDecomp*> decomps_nominal;
28  std::map<std::string, std::map<std::string, std::map<int, IDecomp*> > > decomps_shifted;
29  std::map<std::string, PredictionNoExtrap*> predsNE_nominal;
30  std::map<std::string, std::map<std::string, std::map<int, PredictionNoExtrap*> > > predsNE_shifted;
31  std::map<std::string, PredictionSterile*> predsSt_nominal;
32  std::map<std::string, std::map<std::string, std::map<int, PredictionSterile*> > > predsSt_shifted;
33  std::string folder1="";
34  std::string folder = "/nova/ana/users/sedayath/CAFAna_work_place/job/NUS17/Syst/";
35  std::string filenm = "SystAcceptance17";
36 
37  std::string loadLocation = folder + filenm + ".root";
38  std::string saveLocation = folder1 + filenm + "Ana.root";
39  std::string textLocation = folder1 + filenm + "Ana.txt";
40 
41  TFile* rootL = new TFile(loadLocation.c_str(), "READ");
42  LoadMaps(rootL, &decomps_nominal, &decomps_shifted);
43  LoadMaps(rootL, &predsNE_nominal, &predsNE_shifted);
44  LoadMaps(rootL, &predsSt_nominal, &predsSt_shifted);
45  rootL->Close();
46 
47  TFile* rootF = new TFile(saveLocation.c_str(), "RECREATE");
48  FILE* textF;
49  textF = fopen(textLocation.c_str(), "w");
50 
51  for(const auto& sample : cut_samples) {
52  strings strs;
53  strs.fComponent = "NC";
54  strs.fDet = "ND";
55  strs.fPOT = StringFromDouble(NCSCALE);
56  strs.fSample = sample;
57  strs.fSystType = "Acceptance study";
58  strs.fXLabel = labelRecoE;
59 // double NCSCALE=9e20;
60 
61  InitializeSystText(textF, strs);
62 
63  TH1* hNomNC_decomp = GetNC(decomps_nominal[sample], NCSCALE);
64  TH1* hNomBG_decomp = GetBG(decomps_nominal[sample], NCSCALE);
65 
66  TH1* hNomNC_predNE = GetNC(predsNE_nominal[sample], NCSCALE);
67  TH1* hNomBG_predNE = GetBG(predsNE_nominal[sample], NCSCALE);
68 
69  TH1* hNomNC_predSt = GetNC(predsSt_nominal[sample], NCSCALE);
70  TH1* hNomBG_predSt = GetBG(predsSt_nominal[sample], NCSCALE);
71 
72  for(const auto& shifts : shiftlabels) {
73  strs.fSystS = shifts.first;
74  strs.fSystL = shifts.second;
75 
76  /* strs.fComponent = "NC";
77  strs.fDet = "ND";
78  PlotSyst(hNomNC_decomp,
79  decomps_shifted[sample][shifts.first][1],
80  rootF, textF, strs, NCSCALE, true, true);
81 
82  strs.fComponent = "BG";
83  PlotSyst(hNomBG_decomp,
84  decomps_shifted[sample][shifts.first][1],
85  rootF, textF, strs, NCSCALE, false, true);
86 */
87  strs.fComponent = "NC";
88  strs.fDet = "FD";
89  PlotSyst(hNomNC_predNE,
90  predsNE_shifted[sample][shifts.first][1],
91  rootF, textF, strs, NCSCALE, true, true);
92 
93  strs.fComponent = "BG";
94  PlotSyst(hNomBG_predNE,
95  predsNE_shifted[sample][shifts.first][1],
96  rootF, textF, strs, NCSCALE, false, true);
97 
98  strs.fComponent = "NC";
99  strs.fDet = "EX";
100  PlotSyst(hNomNC_predSt,
101  predsSt_shifted[sample][shifts.first][1],
102  rootF, textF, strs, NCSCALE, true, true);
103 
104  strs.fComponent = "BG";
105  PlotSyst(hNomBG_predSt,
106  predsSt_shifted[sample][shifts.first][1],
107  rootF, textF, strs, NCSCALE, false, true);
108  }
109  }
110 
111  fclose(textF);
112  rootF->Close();
113 
114  std::cout << "Finished. Ctrl+Z should be safe if the macro didn't quit." << std::endl;
115 }
void SystsAcceptanceAna17()
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
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