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