SystsFidContAna.C
Go to the documentation of this file.
4 
5 using namespace ana;
6 
7 void PlotSysts(TH1* nom, TH1* hxn, TH1* hxp, TH1* hyn, TH1* hyp,
8  TH1* hzl, TH1* hzh, TH1* hrl, TH1* hrh,
9  TDirectory* rootOUT, FILE* textOFS,
10  strings strs);
11 
13 {
14  TH1::AddDirectory(0);
15 
16  // A map of systematic labels
17  std::map<std::string, std::string> shiftlabels;
18  shiftlabels["FidXPos"] = "Fiducial Positive X";
19  shiftlabels["FidXNeg"] = "Fiducial Negative X";
20  shiftlabels["FidYPos"] = "Fiducial Positive Y";
21  shiftlabels["FidYNeg"] = "Fiducial Negative Y";
22  shiftlabels["FidZLow"] = "Fiducial Low Z";
23  shiftlabels["FidZHgh"] = "Fiducial High Z";
24  shiftlabels["FidInner"] = "Fiducial Inner Region";
25  shiftlabels["FidOuter"] = "Fiducial Outer Region";
26 
27  std::string labelRecoE = "Calorimetric Energy (GeV)";
28  std::vector<std::string> cut_samples;
29  cut_samples.push_back("Ana01");
30 
31  // Set up maps to the decompositions/predictions (each flavor component)
32  // Nominal maps are indexed purely by sample label
33  // Shifted maps are indexed by sample label, systematic label, then sigma of the shift
34  std::map<std::string, IDecomp*> decomps_nominal;
35  std::map<std::string, std::map<std::string, std::map<int, IDecomp*> > > decomps_shifted;
36  std::map<std::string, PredictionNoExtrap*> predsNE_nominal;
37  std::map<std::string, std::map<std::string, std::map<int, PredictionNoExtrap*> > > predsNE_shifted;
38  std::map<std::string, PredictionSterile*> predsSt_nominal;
39  std::map<std::string, std::map<std::string, std::map<int, PredictionSterile*> > > predsSt_shifted;
40 
41  std::string folder = "/nova/ana/steriles/Ana01/Systematics/";
42  std::string filenm = "SystsFidCont";
43 
44  std::string loadLocation = folder + filenm + ".root";
45  std::string saveLocation = folder + filenm + "Ana.root";
46  std::string textLocation = folder + filenm + "Ana.txt";
47 
48  TFile* rootL = new TFile(loadLocation.c_str(), "READ");
49  LoadMaps(rootL, &decomps_nominal, &decomps_shifted);
50  LoadMaps(rootL, &predsNE_nominal, &predsNE_shifted);
51  LoadMaps(rootL, &predsSt_nominal, &predsSt_shifted);
52  rootL->Close();
53 
54  TFile* rootF = new TFile(saveLocation.c_str(), "RECREATE");
55  FILE* textF;
56  textF = fopen(textLocation.c_str(), "w");
57 
58  for(const auto& sample : cut_samples) {
59  strings strs;
60  strs.fComponent = "NC";
61  strs.fDet = "ND";
63  strs.fSample = sample;
64  strs.fSystType = "FidCont";
65  strs.fXLabel = labelRecoE;
66 
67  InitializeSystText(textF, strs);
68 
69  TH1* hNomNC_decomp = GetNC(decomps_nominal[sample], NCSCALE);
70  TH1* hNomBG_decomp = GetBG(decomps_nominal[sample], NCSCALE);
71 
72  TH1* hNomNC_predNE = GetNC(predsNE_nominal[sample], NCSCALE);
73  TH1* hNomBG_predNE = GetBG(predsNE_nominal[sample], NCSCALE);
74 
75  TH1* hNomNC_predSt = GetNC(predsSt_nominal[sample], NCSCALE);
76  TH1* hNomBG_predSt = GetBG(predsSt_nominal[sample], NCSCALE);
77 
78  for(const auto& shifts : shiftlabels) {
79  strs.fSystS = shifts.first;
80  strs.fSystL = shifts.second;
81 
82  strs.fComponent = "NC";
83  strs.fDet = "ND";
84  PlotSyst(hNomNC_decomp,
85  decomps_shifted[sample][shifts.first][1],
86  rootF, textF, strs, NCSCALE, true, true);
87 
88  strs.fComponent = "BG";
89  PlotSyst(hNomBG_decomp,
90  decomps_shifted[sample][shifts.first][1],
91  rootF, textF, strs, NCSCALE, false, true);
92 
93  strs.fComponent = "NC";
94  strs.fDet = "FD";
95  PlotSyst(hNomNC_predNE,
96  predsNE_shifted[sample][shifts.first][1],
97  rootF, textF, strs, NCSCALE, true, true);
98 
99  strs.fComponent = "BG";
100  PlotSyst(hNomBG_predNE,
101  predsNE_shifted[sample][shifts.first][1],
102  rootF, textF, strs, NCSCALE, false, true);
103 
104  strs.fComponent = "NC";
105  strs.fDet = "EX";
106  PlotSyst(hNomNC_predSt,
107  predsSt_shifted[sample][shifts.first][1],
108  rootF, textF, strs, NCSCALE, true, true);
109 
110  strs.fComponent = "BG";
111  PlotSyst(hNomBG_predSt,
112  predsSt_shifted[sample][shifts.first][1],
113  rootF, textF, strs, NCSCALE, false, true);
114  }
115 
116  TH1* hXNNC_decomp = GetNC(decomps_shifted[sample]["FidXNeg"][1], NCSCALE);
117  TH1* hXNBG_decomp = GetBG(decomps_shifted[sample]["FidXNeg"][1], NCSCALE);
118  TH1* hXPNC_decomp = GetNC(decomps_shifted[sample]["FidXPos"][1], NCSCALE);
119  TH1* hXPBG_decomp = GetBG(decomps_shifted[sample]["FidXPos"][1], NCSCALE);
120  TH1* hYNNC_decomp = GetNC(decomps_shifted[sample]["FidYNeg"][1], NCSCALE);
121  TH1* hYNBG_decomp = GetBG(decomps_shifted[sample]["FidYNeg"][1], NCSCALE);
122  TH1* hYPNC_decomp = GetNC(decomps_shifted[sample]["FidYPos"][1], NCSCALE);
123  TH1* hYPBG_decomp = GetBG(decomps_shifted[sample]["FidYPos"][1], NCSCALE);
124  TH1* hZLNC_decomp = GetNC(decomps_shifted[sample]["FidZLow"][1], NCSCALE);
125  TH1* hZLBG_decomp = GetBG(decomps_shifted[sample]["FidZLow"][1], NCSCALE);
126  TH1* hZHNC_decomp = GetNC(decomps_shifted[sample]["FidZHgh"][1], NCSCALE);
127  TH1* hZHBG_decomp = GetBG(decomps_shifted[sample]["FidZHgh"][1], NCSCALE);
128  TH1* hRLNC_decomp = GetNC(decomps_shifted[sample]["FidInner"][1], NCSCALE);
129  TH1* hRLBG_decomp = GetBG(decomps_shifted[sample]["FidInner"][1], NCSCALE);
130  TH1* hRHNC_decomp = GetNC(decomps_shifted[sample]["FidOuter"][1], NCSCALE);
131  TH1* hRHBG_decomp = GetBG(decomps_shifted[sample]["FidOuter"][1], NCSCALE);
132 
133  TH1* hXNNC_predNE = GetNC(predsNE_shifted[sample]["FidXNeg"][1], NCSCALE);
134  TH1* hXNBG_predNE = GetBG(predsNE_shifted[sample]["FidXNeg"][1], NCSCALE);
135  TH1* hXPNC_predNE = GetNC(predsNE_shifted[sample]["FidXPos"][1], NCSCALE);
136  TH1* hXPBG_predNE = GetBG(predsNE_shifted[sample]["FidXPos"][1], NCSCALE);
137  TH1* hYNNC_predNE = GetNC(predsNE_shifted[sample]["FidYNeg"][1], NCSCALE);
138  TH1* hYNBG_predNE = GetBG(predsNE_shifted[sample]["FidYNeg"][1], NCSCALE);
139  TH1* hYPNC_predNE = GetNC(predsNE_shifted[sample]["FidYPos"][1], NCSCALE);
140  TH1* hYPBG_predNE = GetBG(predsNE_shifted[sample]["FidYPos"][1], NCSCALE);
141  TH1* hZLNC_predNE = GetNC(predsNE_shifted[sample]["FidZLow"][1], NCSCALE);
142  TH1* hZLBG_predNE = GetBG(predsNE_shifted[sample]["FidZLow"][1], NCSCALE);
143  TH1* hZHNC_predNE = GetNC(predsNE_shifted[sample]["FidZHgh"][1], NCSCALE);
144  TH1* hZHBG_predNE = GetBG(predsNE_shifted[sample]["FidZHgh"][1], NCSCALE);
145  TH1* hRLNC_predNE = GetNC(predsNE_shifted[sample]["FidInner"][1], NCSCALE);
146  TH1* hRLBG_predNE = GetBG(predsNE_shifted[sample]["FidInner"][1], NCSCALE);
147  TH1* hRHNC_predNE = GetNC(predsNE_shifted[sample]["FidOuter"][1], NCSCALE);
148  TH1* hRHBG_predNE = GetBG(predsNE_shifted[sample]["FidOuter"][1], NCSCALE);
149 
150  TH1* hXNNC_predSt = GetNC(predsSt_shifted[sample]["FidXNeg"][1], NCSCALE);
151  TH1* hXNBG_predSt = GetBG(predsSt_shifted[sample]["FidXNeg"][1], NCSCALE);
152  TH1* hXPNC_predSt = GetNC(predsSt_shifted[sample]["FidXPos"][1], NCSCALE);
153  TH1* hXPBG_predSt = GetBG(predsSt_shifted[sample]["FidXPos"][1], NCSCALE);
154  TH1* hYNNC_predSt = GetNC(predsSt_shifted[sample]["FidYNeg"][1], NCSCALE);
155  TH1* hYNBG_predSt = GetBG(predsSt_shifted[sample]["FidYNeg"][1], NCSCALE);
156  TH1* hYPNC_predSt = GetNC(predsSt_shifted[sample]["FidYPos"][1], NCSCALE);
157  TH1* hYPBG_predSt = GetBG(predsSt_shifted[sample]["FidYPos"][1], NCSCALE);
158  TH1* hZLNC_predSt = GetNC(predsSt_shifted[sample]["FidZLow"][1], NCSCALE);
159  TH1* hZLBG_predSt = GetBG(predsSt_shifted[sample]["FidZLow"][1], NCSCALE);
160  TH1* hZHNC_predSt = GetNC(predsSt_shifted[sample]["FidZHgh"][1], NCSCALE);
161  TH1* hZHBG_predSt = GetBG(predsSt_shifted[sample]["FidZHgh"][1], NCSCALE);
162  TH1* hRLNC_predSt = GetNC(predsSt_shifted[sample]["FidInner"][1], NCSCALE);
163  TH1* hRLBG_predSt = GetBG(predsSt_shifted[sample]["FidInner"][1], NCSCALE);
164  TH1* hRHNC_predSt = GetNC(predsSt_shifted[sample]["FidOuter"][1], NCSCALE);
165  TH1* hRHBG_predSt = GetBG(predsSt_shifted[sample]["FidOuter"][1], NCSCALE);
166 
167  strs.fComponent = "NC";
168  strs.fDet = "ND";
169  PlotSysts(hNomNC_decomp,
170  hXNNC_decomp, hXPNC_decomp, hYNNC_decomp, hYPNC_decomp,
171  hZLNC_decomp, hZHNC_decomp, hRLNC_decomp, hRHNC_decomp,
172  rootF, textF, strs);
173 
174  strs.fComponent = "BG";
175  PlotSysts(hNomBG_decomp,
176  hXNBG_decomp, hXPBG_decomp, hYNBG_decomp, hYPBG_decomp,
177  hZLBG_decomp, hZHBG_decomp, hRLBG_decomp, hRHBG_decomp,
178  rootF, textF, strs);
179 
180  strs.fComponent = "NC";
181  strs.fDet = "FD";
182  PlotSysts(hNomNC_predNE,
183  hXNNC_predNE, hXPNC_predNE, hYNNC_predNE, hYPNC_predNE,
184  hZLNC_predNE, hZHNC_predNE, hRLNC_predNE, hRHNC_predNE,
185  rootF, textF, strs);
186 
187  strs.fComponent = "BG";
188  PlotSysts(hNomBG_predNE,
189  hXNBG_predNE, hXPBG_predNE, hYNBG_predNE, hYPBG_predNE,
190  hZLBG_predNE, hZHBG_predNE, hRLBG_predNE, hRHBG_predNE,
191  rootF, textF, strs);
192 
193  strs.fComponent = "NC";
194  strs.fDet = "EX";
195  PlotSysts(hNomNC_predSt,
196  hXNNC_predSt, hXPNC_predSt, hYNNC_predSt, hYPNC_predSt,
197  hZLNC_predSt, hZHNC_predSt, hRLNC_predSt, hRHNC_predSt,
198  rootF, textF, strs);
199 
200  strs.fComponent = "BG";
201  PlotSysts(hNomBG_predSt,
202  hXNBG_predSt, hXPBG_predSt, hYNBG_predSt, hYPBG_predSt,
203  hZLBG_predSt, hZHBG_predSt, hRLBG_predSt, hRHBG_predSt,
204  rootF, textF, strs);
205  }
206 
207  fclose(textF);
208  rootF->Close();
209 
210  std::cout << "Finished. Ctrl+Z should be safe if the macro didn't quit." << std::endl;
211 }
212 
213 void PlotSysts(TH1* nom, TH1* hxn, TH1* hxp, TH1* hyn, TH1* hyp,
214  TH1* hzl, TH1* hzh, TH1* hrl, TH1* hrh,
215  TDirectory* rootOUT, FILE* textOFS,
216  strings strs)
217 {
218  double nNom = nom->Integral();
219  double nXN = hxn->Integral();
220  double nXP = hxp->Integral();
221  double nYN = hyn->Integral();
222  double nYP = hyp->Integral();
223  double nZL = hzl->Integral();
224  double nZH = hzh->Integral();
225  double nRL = hrl->Integral();
226  double nRH = hrh->Integral();
227 
228  ZeroError(nom);
229  ZeroError(hxn);
230  ZeroError(hxp);
231  ZeroError(hyn);
232  ZeroError(hyp);
233  ZeroError(hzl);
234  ZeroError(hzh);
235  ZeroError(hrl);
236  ZeroError(hrh);
237 
238  fprintf(textOFS, "\nEvent counts for %.2s %.2s %s Systs:\n",
239  strs.fDet.c_str(), strs.fComponent.c_str(), strs.fSystType.c_str());
240  fprintf(textOFS, "NC: %6.2f, X Neg: %6.2f, X Pos: %6.2f, Y Neg: %6.2f, Y Pos: %6.2f, ",
241  nNom, nXN, nXP, nYN, nYP);
242  fprintf(textOFS, "Z Low: %6.2f, Z High: %6.2f, R Low: %6.2f, R High: %6.2f\n",
243  nZL, nZH, nRL, nRH);
244  fprintf(textOFS, "X Neg Diff: %6.2f, X Pos Diff: %6.2f, Y Neg Diff: %6.2f, Y Pos Diff: %6.2f, ",
245  100.*std::abs(nXN/nNom - 1.), 100.*std::abs(nYN/nNom - 1.),
246  100.*std::abs(nYN/nNom - 1.), 100.*std::abs(nYP/nNom - 1.));
247  fprintf(textOFS, "Z Low Diff: %6.2f, Z High Diff: %6.2f, R Low Diff: %6.2f, R High Diff: %6.2f, ",
248  100.*std::abs(nZL/nNom - 1.), 100.*std::abs(nZH/nNom - 1.),
249  100.*std::abs(nRL/nNom - 1.), 100.*std::abs(nRH/nNom - 1.));
250 
251  double diffs[] = {std::abs(nXN - nNom),
252  std::abs(nXP - nNom),
253  std::abs(nYN - nNom),
254  std::abs(nYP - nNom),
255  std::abs(nZL - nNom),
256  std::abs(nZH - nNom),
257  std::abs(nRL - nNom),
258  std::abs(nRH - nNom)};
259  if( *std::max_element(diffs, diffs+8) == diffs[0]) {
260  AddErrorInQuadrature(nom, hxn, true);
261  }
262  else if(*std::max_element(diffs, diffs+8) == diffs[1]){
263  AddErrorInQuadrature(nom, hxp, true);
264  }
265  else if(*std::max_element(diffs, diffs+8) == diffs[2]){
266  AddErrorInQuadrature(nom, hyn, true);
267  }
268  else if(*std::max_element(diffs, diffs+8) == diffs[3]){
269  AddErrorInQuadrature(nom, hyp, true);
270  }
271  else if(*std::max_element(diffs, diffs+8) == diffs[4]){
272  AddErrorInQuadrature(nom, hzl, true);
273  }
274  else if(*std::max_element(diffs, diffs+8) == diffs[5]){
275  AddErrorInQuadrature(nom, hzh, true);
276  }
277  else if(*std::max_element(diffs, diffs+8) == diffs[6]){
278  AddErrorInQuadrature(nom, hrl, true);
279  }
280  else {
281  AddErrorInQuadrature(nom, hrh, true);
282  }
283 
284  std::string xlabel = strs.fXLabel;
285  std::string ylabel = "Events / " + strs.fPOT + " / 0.25 GeV";
286  std::string title = strs.fDet + " " + strs.fComponent +
287  " Errors for All " + strs.fSystType + " Systematics";
288 // std::string fullTitle = title + ";" + xlabel + ";" + ylabel;
289  std::string fullTitle = ";" + xlabel + ";" + ylabel;
290  std::string name = "c" + strs.fComponent + strs.fDet +
291  strs.fSystType + "SystsAll" + strs.fSample;
292  std::string ylabelRat = "Shifted / Nominal";
293  std::string fullTitleRat = ";" + xlabel + ";" + ylabelRat;
294 
295  TH1* hRat = (TH1*)nom->Clone();
296  TH1* hXNRat = (TH1*)hxn->Clone();
297  TH1* hXPRat = (TH1*)hxp->Clone();
298  TH1* hYNRat = (TH1*)hyn->Clone();
299  TH1* hYPRat = (TH1*)hyp->Clone();
300  TH1* hZLRat = (TH1*)hzl->Clone();
301  TH1* hZHRat = (TH1*)hzh->Clone();
302  TH1* hRLRat = (TH1*)hrl->Clone();
303  TH1* hRHRat = (TH1*)hrh->Clone();
304 
305  int nBins = nom->GetNbinsX();
306  for(int i = 0; i <= nBins+1; ++i) {
307  hRat->SetBinContent(i, 1.);
308  }
309  hXNRat->Divide(nom);
310  hXPRat->Divide(nom);
311  hYNRat->Divide(nom);
312  hYPRat->Divide(nom);
313  hZLRat->Divide(nom);
314  hZHRat->Divide(nom);
315  hRLRat->Divide(nom);
316  hRHRat->Divide(nom);
317 
318  double maxval = nom->GetBinContent(nom->GetMaximumBin());
319  maxval = std::max(maxval, hxn->GetBinContent(hxn->GetMaximumBin()));
320  maxval = std::max(maxval, hxp->GetBinContent(hxp->GetMaximumBin()));
321  maxval = std::max(maxval, hyn->GetBinContent(hyn->GetMaximumBin()));
322  maxval = std::max(maxval, hyp->GetBinContent(hyp->GetMaximumBin()));
323  maxval = std::max(maxval, hzl->GetBinContent(hzl->GetMaximumBin()));
324  maxval = std::max(maxval, hzh->GetBinContent(hzh->GetMaximumBin()));
325  maxval = std::max(maxval, hrl->GetBinContent(hrl->GetMaximumBin()));
326  maxval = std::max(maxval, hrh->GetBinContent(hrh->GetMaximumBin()));
327 
328  double minval = nom->GetBinContent(nom->GetMinimumBin());
329  minval = std::min(minval, hxn->GetBinContent(hxn->GetMinimumBin()));
330  minval = std::min(minval, hxp->GetBinContent(hxp->GetMinimumBin()));
331  minval = std::min(minval, hyn->GetBinContent(hyn->GetMinimumBin()));
332  minval = std::min(minval, hyp->GetBinContent(hyp->GetMinimumBin()));
333  minval = std::min(minval, hzl->GetBinContent(hzl->GetMinimumBin()));
334  minval = std::min(minval, hzh->GetBinContent(hzh->GetMinimumBin()));
335  minval = std::min(minval, hrl->GetBinContent(hrl->GetMinimumBin()));
336  minval = std::min(minval, hrh->GetBinContent(hrh->GetMinimumBin()));
337 
338  if(maxval < minval) { std::swap(maxval, minval); }
339 
340  double maxvalRat = hRat->GetBinContent(hRat->GetMaximumBin());
341  maxvalRat = std::max(maxvalRat, hXNRat->GetBinContent(hXNRat->GetMaximumBin()));
342  maxvalRat = std::max(maxvalRat, hXPRat->GetBinContent(hXPRat->GetMaximumBin()));
343  maxvalRat = std::max(maxvalRat, hYNRat->GetBinContent(hYNRat->GetMaximumBin()));
344  maxvalRat = std::max(maxvalRat, hYPRat->GetBinContent(hYPRat->GetMaximumBin()));
345  maxvalRat = std::max(maxvalRat, hZLRat->GetBinContent(hZLRat->GetMaximumBin()));
346  maxvalRat = std::max(maxvalRat, hZHRat->GetBinContent(hZHRat->GetMaximumBin()));
347  maxvalRat = std::max(maxvalRat, hRLRat->GetBinContent(hRLRat->GetMaximumBin()));
348  maxvalRat = std::max(maxvalRat, hRHRat->GetBinContent(hRHRat->GetMaximumBin()));
349 
350  double minvalRat = hRat->GetBinContent(hRat->GetMinimumBin());
351  for(int i = 1; i <= nBins; ++i) {
352  if(hXNRat->GetBinContent(i) > 0.) {
353  minvalRat = std::min(minvalRat, hXNRat->GetBinContent(i));
354  }
355  if(hXPRat->GetBinContent(i) > 0.) {
356  minvalRat = std::min(minvalRat, hXPRat->GetBinContent(i));
357  }
358  if(hYNRat->GetBinContent(i) > 0.) {
359  minvalRat = std::min(minvalRat, hYNRat->GetBinContent(i));
360  }
361  if(hYPRat->GetBinContent(i) > 0.) {
362  minvalRat = std::min(minvalRat, hYPRat->GetBinContent(i));
363  }
364  if(hZLRat->GetBinContent(i) > 0.) {
365  minvalRat = std::min(minvalRat, hZLRat->GetBinContent(i));
366  }
367  if(hZHRat->GetBinContent(i) > 0.) {
368  minvalRat = std::min(minvalRat, hZHRat->GetBinContent(i));
369  }
370  if(hRLRat->GetBinContent(i) > 0.) {
371  minvalRat = std::min(minvalRat, hRLRat->GetBinContent(i));
372  }
373  if(hRHRat->GetBinContent(i) > 0.) {
374  minvalRat = std::min(minvalRat, hRHRat->GetBinContent(i));
375  }
376  }
377 
378  if(std::abs(maxvalRat - 1.) > std::abs(1. - minvalRat)) {
379  minvalRat = 1 - std::abs(maxvalRat - 1.);
380  maxvalRat = 1 + std::abs(maxvalRat - 1.);
381  }
382  else {
383  minvalRat = 1 - std::abs(1. - minvalRat);
384  maxvalRat = 1 + std::abs(1. - minvalRat);
385  }
386 
387  CenterTitles(nom);
388  nom->SetLineColor(kBlack);
389  nom->SetMaximum(1.1*maxval);
390  nom->SetMinimum(0);
391  nom->SetTitle(fullTitle.c_str());
392 
393  CenterTitles(hxn);
394  hxn->SetLineColor(kRed);
395  hxn->SetLineStyle(2);
396  hxn->SetMaximum(1.1*maxval);
397  hxn->SetMinimum(0);
398  hxn->SetTitle(fullTitle.c_str());
399 
400  CenterTitles(hxp);
401  hxp->SetLineColor(kRed);
402  hxp->SetLineStyle(5);
403  hxp->SetMaximum(1.1*maxval);
404  hxp->SetMinimum(0);
405  hxp->SetTitle(fullTitle.c_str());
406 
407  CenterTitles(hyn);
408  hyn->SetLineColor(kBlue);//kGreen+2);
409  hyn->SetLineStyle(2);
410  hyn->SetMaximum(1.1*maxval);
411  hyn->SetMinimum(0);
412  hyn->SetTitle(fullTitle.c_str());
413 
414  CenterTitles(hyp);
415  hyp->SetLineColor(kBlue);//kViolet-5);
416  hyp->SetLineStyle(5);
417  hyp->SetMaximum(1.1*maxval);
418  hyp->SetMinimum(0);
419  hyp->SetTitle(fullTitle.c_str());
420 
421  CenterTitles(hzl);
422  hzl->SetLineColor(kGreen+2);
423  hzl->SetLineStyle(2);
424  hzl->SetMaximum(1.1*maxval);
425  hzl->SetMinimum(0);
426  hzl->SetTitle(fullTitle.c_str());
427 
428  CenterTitles(hzh);
429  hzh->SetLineColor(kGreen+2);
430  hzh->SetLineStyle(5);
431  hzh->SetMaximum(1.1*maxval);
432  hzh->SetMinimum(0);
433  hzh->SetTitle(fullTitle.c_str());
434 
435  CenterTitles(hrl);
436  hrl->SetLineColor(kViolet-5);
437  hrl->SetLineStyle(2);
438  hrl->SetMaximum(1.1*maxval);
439  hrl->SetMinimum(0);
440  hrl->SetTitle(fullTitle.c_str());
441 
442  CenterTitles(hrh);
443  hrh->SetLineColor(kViolet-5);
444  hrh->SetLineStyle(5);
445  hrh->SetMaximum(1.1*maxval);
446  hrh->SetMinimum(0);
447  hrh->SetTitle(fullTitle.c_str());
448 
449  CenterTitles(hRat);
450  hRat->SetLineColor(kBlack);
451  hRat->SetMaximum(1.1*maxvalRat);
452  hRat->SetMinimum(0.9*minvalRat);
453  hRat->SetTitle(fullTitleRat.c_str());
454 
455  CenterTitles(hXNRat);
456  hXNRat->SetLineColor(kRed);
457  hXNRat->SetLineStyle(2);
458  hXNRat->SetMaximum(1.1*maxvalRat);
459  hXNRat->SetMinimum(0.9*minvalRat);
460  hXNRat->SetTitle(fullTitleRat.c_str());
461 
462  CenterTitles(hXPRat);
463  hXPRat->SetLineColor(kRed);
464  hXPRat->SetLineStyle(5);
465  hXPRat->SetMaximum(1.1*maxvalRat);
466  hXPRat->SetMinimum(0.9*minvalRat);
467  hXPRat->SetTitle(fullTitleRat.c_str());
468 
469  CenterTitles(hYNRat);
470  hYNRat->SetLineColor(kBlue);
471  hYNRat->SetLineStyle(2);
472  hYNRat->SetMaximum(1.1*maxvalRat);
473  hYNRat->SetMinimum(0.9*minvalRat);
474  hYNRat->SetTitle(fullTitleRat.c_str());
475 
476  CenterTitles(hYPRat);
477  hYPRat->SetLineColor(kBlue);
478  hYPRat->SetLineStyle(5);
479  hYPRat->SetMaximum(1.1*maxvalRat);
480  hYPRat->SetMinimum(0.9*minvalRat);
481  hYPRat->SetTitle(fullTitleRat.c_str());
482 
483  CenterTitles(hZLRat);
484  hZLRat->SetLineColor(kGreen+2);
485  hZLRat->SetLineStyle(2);
486  hZLRat->SetMaximum(1.1*maxvalRat);
487  hZLRat->SetMinimum(0.9*minvalRat);
488  hZLRat->SetTitle(fullTitleRat.c_str());
489 
490  CenterTitles(hZHRat);
491  hZHRat->SetLineColor(kGreen+2);
492  hZHRat->SetLineStyle(5);
493  hZHRat->SetMaximum(1.1*maxvalRat);
494  hZHRat->SetMinimum(0.9*minvalRat);
495  hZHRat->SetTitle(fullTitleRat.c_str());
496 
497  CenterTitles(hRLRat);
498  hRLRat->SetLineColor(kViolet-5);
499  hRLRat->SetLineStyle(2);
500  hRLRat->SetMaximum(1.1*maxvalRat);
501  hRLRat->SetMinimum(0.9*minvalRat);
502  hRLRat->SetTitle(fullTitleRat.c_str());
503 
504  CenterTitles(hRHRat);
505  hRHRat->SetLineColor(kViolet-5);
506  hRHRat->SetLineStyle(5);
507  hRHRat->SetMaximum(1.1*maxvalRat);
508  hRHRat->SetMinimum(0.9*minvalRat);
509  hRHRat->SetTitle(fullTitleRat.c_str());
510 
511  double xL = 0.625, xR = 0.875;
512  double yB = 0.39, yT = 0.89;
513  TLegend* leg = new TLegend(xL, yB, xR, yT);
514  leg->AddEntry(nom, "Nominal", "l");
515  leg->AddEntry(hxn, "-X Region", "l");
516  leg->AddEntry(hxp, "+X Region", "l");
517  leg->AddEntry(hyn, "-Y Region", "l");
518  leg->AddEntry(hyp, "+Y Region", "l");
519  leg->AddEntry(hzl, "Low Z Region", "l");
520  leg->AddEntry(hzh, "High Z Region", "l");
521  leg->AddEntry(hrl, "Inner Region", "l");
522  leg->AddEntry(hrh, "Outer Region", "l");
523 
524  TCanvas* c = new TCanvas(name.c_str(), title.c_str(), 800, 800);
525  TPad* pSpecs = new TPad("pSpecs", "", 0., 0.375, 1., 1.);
526  TPad* pRatio = new TPad("pRatio", "", 0., 0., 1., 0.375);
527  pSpecs->Draw();
528  pRatio->Draw();
529 
530  pSpecs->cd();
531  nom->Draw("hist");
532  hxn->Draw("hist same");
533  hxp->Draw("hist same");
534  hyn->Draw("hist same");
535  hyp->Draw("hist same");
536  hzl->Draw("hist same");
537  hzh->Draw("hist same");
538  hrl->Draw("hist same");
539  hrh->Draw("hist same");
540  leg->Draw();
541  Simulation();
542 
543  pRatio->cd();
544  hRat->Draw("hist");
545  hXNRat->Draw("hist same");
546  hXPRat->Draw("hist same");
547  hYNRat->Draw("hist same");
548  hYPRat->Draw("hist same");
549  hZLRat->Draw("hist same");
550  hZHRat->Draw("hist same");
551  hRLRat->Draw("hist same");
552  hRHRat->Draw("hist same");
553 
554  c->Update();
555  rootOUT->WriteTObject(c);
556  return;
557 }
void Simulation()
Definition: tools.h:16
T max(const caf::Proxy< T > &a, T b)
const XML_Char * name
Definition: expat.h:151
int nBins
Definition: plotROC.py:16
std::string fDet
Definition: PPFXHelper.h:104
enum BeamMode kRed
Cuts and Vars for the 2020 FD DiF Study.
Definition: vars.h:6
std::string fComponent
Definition: PPFXHelper.h:103
void PlotSysts(TH1 *nom, TH1 *hxn, TH1 *hxp, TH1 *hyn, TH1 *hyp, TH1 *hzl, TH1 *hzh, TH1 *hrl, TH1 *hrh, TDirectory *rootOUT, FILE *textOFS, strings strs)
void PlotSyst(TH1 *h, TH1 *hp1, TH1 *hm1, TH1 *hp2, TH1 *hm2, TDirectory *out, FILE *text, strings strs)
Definition: PPFXHelper.h:662
void ZeroError(TH1 *nom)
Set the errors of the input histogram to 0.
Definition: PPFXHelper.h:149
void CenterTitles(TH1 *histo)
Definition: Plots.cxx:1481
float abs(float number)
Definition: d0nt_math.hpp:39
void swap(art::HLTGlobalStatus &lhs, art::HLTGlobalStatus &rhs)
TH1 * GetNC(IDecomp *specs, double POT)
Definition: PPFXHelper.h:211
fclose(fg1)
void AddErrorInQuadrature(TH1 *nom, TH1 *up, bool use_max)
Definition: PPFXHelper.h:163
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
enum BeamMode kViolet
std::string fSystType
Definition: PPFXHelper.h:107
std::string fSystS
Definition: PPFXHelper.h:108
void SystsFidContAna()
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
T min(const caf::Proxy< T > &a, T b)
TH1 * GetBG(IDecomp *specs, double POT)
Definition: PPFXHelper.h:236
enum BeamMode kGreen
enum BeamMode kBlue
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