1 import ROOT, os, array, sys
3 use_realistic_powers =
True 11 x.append(histo.GetBinCenter(i+1));
12 y.append(histo.GetBinContent(i+1));
13 y_array = array.array(
'd',y)
15 return ROOT.TMath.Median(n,y_array);
18 n = histo.GetNbinsX();
23 x.append(histo.GetBinCenter(i+1));
24 y.append(histo.GetBinContent(i+1));
25 y_array = array.array(
'd',y)
27 percentiles = array.array(
'd',[0.0]);
28 probs = array.array(
'd',[1-float(X)/100.0])
30 ROOT.TMath.Quantiles(n,1,y_array,percentiles,probs,
False);
34 n = histo.GetNbinsX();
39 x.append(histo.GetBinCenter(i+1));
40 y.append(histo.GetBinContent(i+1));
43 pos = float(100-X)/100.0 * n;
44 if ROOT.TMath.Floor(pos)==pos:
47 i = ROOT.TMath.FloorNint(pos)
48 return (y[i]+y[i+1])/2
51 n = histo.GetNbinsX();
57 total = total + float(histo.GetBinWidth(i+1));
58 if(histo.GetBinContent(i+1)>=X):
59 greaterThanX = greaterThanX + float(histo.GetBinWidth(i+1));
61 return greaterThanX/total;
66 for i
in range(0,histo.GetNbinsX()):
67 if histo.GetBinContent(i+1) < min:
68 min = histo.GetBinContent(i+1)
75 energies = [20,30,40,50,60,70,80,90,100,120,130]
76 energies_array = array.array(
'd',energies)
78 nh_cp_medians = [[],[],[]]
79 ih_cp_medians = [[],[],[]]
80 nh_cp_75thpercentiles = [[],[],[]]
81 ih_cp_75thpercentiles = [[],[],[]]
82 nh_cp_3sigmafracs = [[],[],[]]
83 ih_cp_3sigmafracs = [[],[],[]]
84 nh_cp_5sigmafracs = [[],[],[]]
85 ih_cp_5sigmafracs = [[],[],[]]
86 nh_mh_minimums = [[],[],[]]
87 ih_mh_minimums = [[],[],[]]
89 for energy
in energies:
90 nh_cp_file = ROOT.TFile(
"/lbne/data/users/lblpwg_tools/FastMC_Data/outputs/ljf26/Sensitivity_Plots/ProtonP"+
str(energy)+
"GeV_nh_cp_histos.root");
91 if(use_realistic_powers
and energy!=120):
92 nh_cp_file = ROOT.TFile(
"/lbne/data/users/lblpwg_tools/FastMC_Data/outputs/ljf26/Sensitivity_Plots/ProtonP"+
str(energy)+
"GeV_RealisticPower_nh_cp_histos.root");
94 nh_cp_medians[0].append(
GetMedian(nh_cp_file.Get(
"h1")))
95 nh_cp_medians[1].append(
GetMedian(nh_cp_file.Get(
"h2")))
96 nh_cp_medians[2].append(
GetMedian(nh_cp_file.Get(
"h3")))
98 nh_cp_75thpercentiles[0].append(
GetPercentile(nh_cp_file.Get(
"h1"),75))
99 nh_cp_75thpercentiles[1].append(
GetPercentile(nh_cp_file.Get(
"h2"),75))
100 nh_cp_75thpercentiles[2].append(
GetPercentile(nh_cp_file.Get(
"h3"),75))
110 ih_cp_file = ROOT.TFile(
"/lbne/data/users/lblpwg_tools/FastMC_Data/outputs/ljf26/Sensitivity_Plots/ProtonP"+
str(energy)+
"GeV_ih_cp_histos.root");
111 if(use_realistic_powers
and energy!=120):
112 ih_cp_file = ROOT.TFile(
"/lbne/data/users/lblpwg_tools/FastMC_Data/outputs/ljf26/Sensitivity_Plots/ProtonP"+
str(energy)+
"GeV_RealisticPower_ih_cp_histos.root");
114 ih_cp_medians[0].append(
GetMedian(ih_cp_file.Get(
"h1")))
115 ih_cp_medians[1].append(
GetMedian(ih_cp_file.Get(
"h2")))
116 ih_cp_medians[2].append(
GetMedian(ih_cp_file.Get(
"h3")))
118 ih_cp_75thpercentiles[0].append(
GetPercentile(ih_cp_file.Get(
"h1"),75))
119 ih_cp_75thpercentiles[1].append(
GetPercentile(ih_cp_file.Get(
"h2"),75))
120 ih_cp_75thpercentiles[2].append(
GetPercentile(ih_cp_file.Get(
"h3"),75))
130 nh_mh_file = ROOT.TFile(
"/lbne/data/users/lblpwg_tools/FastMC_Data/outputs/ljf26/Sensitivity_Plots/ProtonP"+
str(energy)+
"GeV_nh_mh_histos.root");
131 if(use_realistic_powers
and energy !=120):
132 nh_mh_file = ROOT.TFile(
"/lbne/data/users/lblpwg_tools/FastMC_Data/outputs/ljf26/Sensitivity_Plots/ProtonP"+
str(energy)+
"GeV_RealisticPower_nh_mh_histos.root");
134 nh_mh_minimums[0].append(
GetMinimum(nh_mh_file.Get(
"h1")))
135 nh_mh_minimums[1].append(
GetMinimum(nh_mh_file.Get(
"h2")))
136 nh_mh_minimums[2].append(
GetMinimum(nh_mh_file.Get(
"h3")))
138 ih_mh_file = ROOT.TFile(
"/lbne/data/users/lblpwg_tools/FastMC_Data/outputs/ljf26/Sensitivity_Plots/ProtonP"+
str(energy)+
"GeV_ih_mh_histos.root");
139 if(use_realistic_powers
and energy !=120):
140 ih_mh_file = ROOT.TFile(
"/lbne/data/users/lblpwg_tools/FastMC_Data/outputs/ljf26/Sensitivity_Plots/ProtonP"+
str(energy)+
"GeV_RealisticPower_ih_mh_histos.root");
142 ih_mh_minimums[0].append(
GetMinimum(ih_mh_file.Get(
"h1")))
143 ih_mh_minimums[1].append(
GetMinimum(ih_mh_file.Get(
"h2")))
144 ih_mh_minimums[2].append(
GetMinimum(ih_mh_file.Get(
"h3")))
148 ROOT.gStyle.SetMarkerStyle(21);
149 ROOT.gStyle.SetMarkerStyle(21);
151 c_nh_cp_m = ROOT.TCanvas(
"nh_cp_m");
152 c_ih_cp_m = ROOT.TCanvas(
"ih_cp_m");
153 c_nh_cp_p = ROOT.TCanvas(
"nh_cp_p");
154 c_ih_cp_p = ROOT.TCanvas(
"ih_cp_p");
155 c_nh_cp_3 = ROOT.TCanvas(
"nh_cp_3");
156 c_ih_cp_3 = ROOT.TCanvas(
"ih_cp_3");
157 c_nh_cp_5 = ROOT.TCanvas(
"nh_cp_5");
158 c_ih_cp_5 = ROOT.TCanvas(
"ih_cp_5");
160 c_nh_mh = ROOT.TCanvas(
"nh_mh");
161 c_ih_mh = ROOT.TCanvas(
"ih_mh");
174 line_styles = [1,2,3]
175 line_colors = [1,2,4]
178 temp = ROOT.TGraph(len(energies),energies_array,array.array(
'd',nh_cp_medians[i]));
179 nh_cp_mgraphs.append(temp)
180 temp = ROOT.TGraph(len(energies),energies_array,array.array(
'd',ih_cp_medians[i]));
181 ih_cp_mgraphs.append(temp)
183 temp = ROOT.TGraph(len(energies),energies_array,array.array(
'd',nh_cp_75thpercentiles[i]));
184 nh_cp_pgraphs.append(temp)
185 temp = ROOT.TGraph(len(energies),energies_array,array.array(
'd',ih_cp_75thpercentiles[i]));
186 ih_cp_pgraphs.append(temp)
188 temp = ROOT.TGraph(len(energies),energies_array,array.array(
'd',nh_cp_3sigmafracs[i]));
189 nh_cp_3graphs.append(temp)
190 temp = ROOT.TGraph(len(energies),energies_array,array.array(
'd',ih_cp_3sigmafracs[i]));
191 ih_cp_3graphs.append(temp)
192 temp = ROOT.TGraph(len(energies),energies_array,array.array(
'd',nh_cp_5sigmafracs[i]));
193 nh_cp_5graphs.append(temp)
194 temp = ROOT.TGraph(len(energies),energies_array,array.array(
'd',ih_cp_5sigmafracs[i]));
195 ih_cp_5graphs.append(temp)
196 temp = ROOT.TGraph(len(energies),energies_array,array.array(
'd',nh_mh_minimums[i]));
197 nh_mh_mgraphs.append(temp)
198 temp = ROOT.TGraph(len(energies),energies_array,array.array(
'd',ih_mh_minimums[i]));
199 ih_mh_mgraphs.append(temp)
201 nh_cp_mgraphs[i].SetMinimum(1);
202 ih_cp_mgraphs[i].SetMinimum(1);
203 nh_cp_pgraphs[i].SetMinimum(1);
204 ih_cp_pgraphs[i].SetMinimum(1);
205 nh_cp_3graphs[i].SetMinimum(30);
206 ih_cp_3graphs[i].SetMinimum(30);
207 nh_cp_5graphs[i].SetMinimum(30);
208 ih_cp_5graphs[i].SetMinimum(30);
209 nh_cp_3graphs[i].SetMaximum(80);
210 ih_cp_3graphs[i].SetMaximum(80);
211 nh_cp_5graphs[i].SetMaximum(100);
212 ih_cp_5graphs[i].SetMaximum(100);
213 nh_mh_mgraphs[i].SetMinimum(2.5);
214 ih_mh_mgraphs[i].SetMinimum(2.5);
216 nh_cp_mgraphs[i].GetXaxis().SetTitle(
"Proton Energy (GeV)");
217 ih_cp_mgraphs[i].GetXaxis().SetTitle(
"Proton Energy (GeV)");
218 nh_cp_pgraphs[i].GetXaxis().SetTitle(
"Proton Energy (GeV)");
219 ih_cp_pgraphs[i].GetXaxis().SetTitle(
"Proton Energy (GeV)");
220 nh_cp_3graphs[i].GetXaxis().SetTitle(
"Proton Energy (GeV)");
221 ih_cp_3graphs[i].GetXaxis().SetTitle(
"Proton Energy (GeV)");
222 nh_cp_5graphs[i].GetXaxis().SetTitle(
"Proton Energy (GeV)");
223 ih_cp_5graphs[i].GetXaxis().SetTitle(
"Proton Energy (GeV)");
224 nh_mh_mgraphs[i].GetXaxis().SetTitle(
"Proton Energy (GeV)");
225 ih_mh_mgraphs[i].GetXaxis().SetTitle(
"Proton Energy (GeV)");
227 nh_cp_mgraphs[i].GetYaxis().SetTitle(
"Median CP Sensitivity (#sigma)");
228 ih_cp_mgraphs[i].GetYaxis().SetTitle(
"Median CP Sensitivity (#sigma)");
229 nh_cp_pgraphs[i].GetYaxis().SetTitle(
"75% CP Sensitivity) (#sigma)");
230 ih_cp_pgraphs[i].GetYaxis().SetTitle(
"75% CP Sensitivity) (#sigma)");
231 nh_cp_3graphs[i].GetYaxis().SetTitle(
"3 Sigma Coverage (%)");
232 ih_cp_3graphs[i].GetYaxis().SetTitle(
"3 Sigma Coverage (%)");
233 nh_cp_5graphs[i].GetYaxis().SetTitle(
"5 Sigma Coverage (%)");
234 ih_cp_5graphs[i].GetYaxis().SetTitle(
"5 Sigma Coverage (%)");
235 nh_mh_mgraphs[i].GetYaxis().SetTitle(
"Minimum MH Sensitivity (#sigma)");
236 ih_mh_mgraphs[i].GetYaxis().SetTitle(
"Minimum MH Sensitivity (#sigma)");
238 nh_cp_mgraphs[i].SetTitle(
"");
239 ih_cp_mgraphs[i].SetTitle(
"");
240 nh_cp_pgraphs[i].SetTitle(
"");
241 ih_cp_pgraphs[i].SetTitle(
"");
242 nh_cp_3graphs[i].SetTitle(
"");
243 ih_cp_3graphs[i].SetTitle(
"");
244 nh_cp_5graphs[i].SetTitle(
"");
245 ih_cp_5graphs[i].SetTitle(
"");
246 nh_mh_mgraphs[i].SetTitle(
"");
247 ih_mh_mgraphs[i].SetTitle(
"");
254 nh_cp_mgraphs[i].SetLineColor(line_colors[i])
255 ih_cp_mgraphs[i].SetLineColor(line_colors[i])
256 nh_cp_pgraphs[i].SetLineColor(line_colors[i])
257 ih_cp_pgraphs[i].SetLineColor(line_colors[i])
258 nh_cp_3graphs[i].SetLineColor(line_colors[i])
259 ih_cp_3graphs[i].SetLineColor(line_colors[i])
260 nh_cp_5graphs[i].SetLineColor(line_colors[i])
261 ih_cp_5graphs[i].SetLineColor(line_colors[i])
262 nh_mh_mgraphs[i].SetLineColor(line_colors[i])
263 ih_mh_mgraphs[i].SetLineColor(line_colors[i])
265 nh_cp_mgraphs[i].SetMarkerColor(line_colors[i])
266 ih_cp_mgraphs[i].SetMarkerColor(line_colors[i])
267 nh_cp_pgraphs[i].SetMarkerColor(line_colors[i])
268 ih_cp_pgraphs[i].SetMarkerColor(line_colors[i])
269 nh_cp_3graphs[i].SetMarkerColor(line_colors[i])
270 ih_cp_3graphs[i].SetMarkerColor(line_colors[i])
271 nh_cp_5graphs[i].SetMarkerColor(line_colors[i])
272 ih_cp_5graphs[i].SetMarkerColor(line_colors[i])
273 nh_mh_mgraphs[i].SetMarkerColor(line_colors[i])
274 ih_mh_mgraphs[i].SetMarkerColor(line_colors[i])
278 nh_cp_mgraphs[i].Draw(
"ACP");
280 nh_cp_mgraphs[i].Draw(
"SAME CP");
284 ih_cp_mgraphs[i].Draw(
"ACP");
286 ih_cp_mgraphs[i].Draw(
"SAME CP");
290 nh_cp_pgraphs[i].Draw(
"ACP");
292 nh_cp_pgraphs[i].Draw(
"SAME CP");
296 ih_cp_pgraphs[i].Draw(
"ACP");
298 ih_cp_pgraphs[i].Draw(
"SAME CP");
302 nh_cp_3graphs[i].Draw(
"ACP");
304 nh_cp_3graphs[i].Draw(
"SAME CP");
308 ih_cp_3graphs[i].Draw(
"ACP");
310 ih_cp_3graphs[i].Draw(
"SAME CP");
314 nh_cp_5graphs[i].Draw(
"ACP");
316 nh_cp_5graphs[i].Draw(
"SAME CP");
320 ih_cp_5graphs[i].Draw(
"ACP");
322 ih_cp_5graphs[i].Draw(
"SAME CP");
326 nh_mh_mgraphs[i].Draw(
"ACP");
328 nh_mh_mgraphs[i].Draw(
"SAME CP");
332 ih_mh_mgraphs[i].Draw(
"ACP");
334 ih_mh_mgraphs[i].Draw(
"SAME CP");
336 leg = ROOT.TLegend(0.45,0.2,0.85,0.45);
337 leg.SetHeader(
"Sig/Bkgd Uncertainties");
338 leg.AddEntry(nh_cp_mgraphs[0],
"1%/5%",
"lp");
339 leg.AddEntry(nh_cp_mgraphs[1],
"2%/5%",
"lp");
340 leg.AddEntry(nh_cp_mgraphs[2],
"5%/10%",
"lp");
342 leg.SetBorderSize(0);
366 if(use_realistic_powers):
368 c_nh_cp_m.Print(
"summary_rp_nh_cp_median.eps");
369 c_nh_cp_m.Print(
"summary_rp_nh_cp_median.png");
371 c_ih_cp_m.Print(
"summary_rp_ih_cp_median.eps");
372 c_ih_cp_m.Print(
"summary_rp_ih_cp_median.png");
374 c_nh_cp_p.Print(
"summary_rp_nh_cp_75thpercentile.eps");
375 c_nh_cp_p.Print(
"summary_rp_nh_cp_75thpercentile.png");
377 c_ih_cp_p.Print(
"summary_rp_ih_cp_75thpercentile.eps");
378 c_ih_cp_p.Print(
"summary_rp_ih_cp_75thpercentile.png");
380 c_nh_cp_3.Print(
"summary_rp_nh_cp_3sigmafrac.eps");
381 c_nh_cp_3.Print(
"summary_rp_nh_cp_3sigmafrac.png");
383 c_ih_cp_3.Print(
"summary_rp_ih_cp_3sigmafrac.eps");
384 c_ih_cp_3.Print(
"summary_rp_ih_cp_3sigmafrac.png");
386 c_nh_cp_5.Print(
"summary_rp_nh_cp_5sigmafrac.eps");
387 c_nh_cp_5.Print(
"summary_rp_nh_cp_5sigmafrac.png");
389 c_ih_cp_5.Print(
"summary_rp_ih_cp_5sigmafrac.eps");
390 c_ih_cp_5.Print(
"summary_rp_ih_cp_5sigma.png");
392 c_nh_mh.Print(
"summary_rp_nh_mh.eps");
393 c_nh_mh.Print(
"summary_rp_nh_mh.png");
395 c_ih_mh.Print(
"summary_rp_ih_mh.eps");
396 c_ih_mh.Print(
"summary_rp_ih_mh.png");
400 c_nh_cp_m.Print(
"summary_nh_cp_median.eps");
401 c_nh_cp_m.Print(
"summary_nh_cp_median.png");
403 c_ih_cp_m.Print(
"summary_ih_cp_median.eps");
404 c_ih_cp_m.Print(
"summary_ih_cp_median.png");
406 c_nh_cp_m.Print(
"summary_nh_cp_75thpercentile.eps");
407 c_nh_cp_m.Print(
"summary_nh_cp_75thperceentile.png");
409 c_ih_cp_m.Print(
"summary_ih_cp_75thpercentile.eps");
410 c_ih_cp_m.Print(
"summary_ih_cp_75thpercentile.png");
412 c_nh_cp_3.Print(
"summary_nh_cp_3sigmafrac.eps");
413 c_nh_cp_3.Print(
"summary_nh_cp_3sigmafrac.png");
415 c_ih_cp_3.Print(
"summary_ih_cp_3sigmafrac.eps");
416 c_ih_cp_3.Print(
"summary_rp_ih_cp_3sigmafrac.png");
418 c_nh_cp_5.Print(
"summary_nh_cp_5sigmafrac.eps");
419 c_nh_cp_5.Print(
"summary_nh_cp_5sigmafrac.png");
421 c_ih_cp_5.Print(
"summary_ih_cp_5sigmafrac.eps");
422 c_ih_cp_5.Print(
"summary_ih_cp_5sigma.png");
424 c_nh_mh.Print(
"summary_nh_mh.eps");
425 c_nh_mh.Print(
"summary_nh_mh.png");
427 c_ih_mh.Print(
"summary_ih_mh.eps");
428 c_ih_mh.Print(
"summary_ih_mh.png");
def GetPercentileCheck(histo, X)
def GetFractionAtMoreThanXSigma(histo, X)
def GetPercentile(histo, X)