1 import ROOT, os, array, sys, OptimizationUtils
9 x.append(histo.GetBinCenter(i+1));
10 y.append(histo.GetBinContent(i+1));
11 y_array = array.array(
'd',y)
13 percentiles = array.array(
'd',[0.0]);
14 probs = array.array(
'd',[1-float(X)/100.0])
16 ROOT.TMath.Quantiles(n,1,y_array,percentiles,probs,
False);
21 n = histo.GetNbinsX();
26 x.append(histo.GetBinCenter(i+1));
27 y.append(histo.GetBinContent(i+1));
28 y_array = array.array(
'd',y)
30 return ROOT.TMath.Median(n,y_array);
37 for i
in range(0,histo.GetNbinsX()):
38 if histo.GetBinContent(i+1) < min:
39 min = histo.GetBinContent(i+1)
42 hierarchies = [
"nh",
"ih"]
43 plotvars = [
"cp_75thpercentile",
"mh_minimum"]
46 tweaks = [
"antinufrac"]
47 plotvars = [
"cp_75thpercentile",
"mh_minimum",
"cp_median"]
49 for hierarchy
in hierarchies:
50 for plotvar
in plotvars:
51 if tweak==
"antinufrac":
52 amounts_varied = [0,10,25,50,75,90,100]
54 amounts_varied = [0,50,90,100,110,200]
58 mixing_param = plotvar[0:2]
59 baseline_file =ROOT.TFile(
"/lbne/data/users/lblpwg_tools/FastMC_Data/outputs/ljf26/Sensitivity_Plots/ProtonP120GeV_"+hierarchy+
"_"+mixing_param+
"_histos.root");
61 if(plotvar==
"cp_3sigma"):
65 if(plotvar==
"cp_75thpercentile"):
66 baseline_medians.append(
GetPercentile(baseline_file.Get(
"h1"),75))
67 baseline_medians.append(
GetPercentile(baseline_file.Get(
"h2"),75))
69 baseline_medians.append(
GetPercentile(baseline_file.Get(
"h3"),75))
70 elif(plotvar==
"mh_minimum"):
71 baseline_medians.append(
GetMinimum(baseline_file.Get(
"h1")))
72 baseline_medians.append(
GetMinimum(baseline_file.Get(
"h2")))
73 baseline_medians.append(
GetMinimum(baseline_file.Get(
"h3")))
74 elif(plotvar==
"cp_median"):
75 baseline_medians.append(
GetMedian(baseline_file.Get(
"h1")))
76 baseline_medians.append(
GetMedian(baseline_file.Get(
"h2")))
77 baseline_medians.append(
GetMedian(baseline_file.Get(
"h3")))
83 amounts_varied_good_files = []
84 for amount_varied
in amounts_varied:
87 var = tweak+
str(amount_varied)
88 file_prefix = var+
"_"+hierarchy+
"_"+mixing_param
90 if (tweak ==
"antinufrac" or amount_varied != 100):
91 t_file = ROOT.TFile(
"/lbne/data/users/lblpwg_tools/FastMC_Data/outputs/ljf26/Sensitivity_Plots/bug/"+file_prefix+
"_histos.root");
93 t_file = ROOT.TFile(
"/lbne/data/users/lblpwg_tools/FastMC_Data/outputs/ljf26/Sensitivity_Plots/bug/ProtonP120GeV_"+hierarchy+
"_"+mixing_param+
"_histos.root");
96 if(t_file.IsZombie()
or t_file.Get(
"h2").Integral()==0):
98 amounts_varied_good_files.append(amount_varied)
100 histos[0].append(t_file.Get(
"h1").Clone(
"h1_"+
str(amount_varied)))
101 histos[1].append(t_file.Get(
"h2").Clone(
"h2_"+
str(amount_varied)))
102 histos[2].append(t_file.Get(
"h3").Clone(
"h3_"+
str(amount_varied)))
104 if(plotvar==
"cp_75thpercentile"):
107 print amount_varied,
GetPercentile(t_file.Get(
"h2"),75),t_file.Get(
"h2").Integral()
110 elif(plotvar==
"mh_minimum"):
111 medians[0].append(
GetMinimum(t_file.Get(
"h1")))
112 medians[1].append(
GetMinimum(t_file.Get(
"h2")))
113 medians[2].append(
GetMinimum(t_file.Get(
"h3")))
115 elif(plotvar==
"cp_median"):
116 medians[0].append(
GetMedian(t_file.Get(
"h1")))
117 medians[1].append(
GetMedian(t_file.Get(
"h2")))
118 medians[2].append(
GetMedian(t_file.Get(
"h3")))
120 elif(plotvar==
"cp_3sigma"):
132 if(plotvar ==
"cp_75thpercentile"):
136 nomfhcfile =
"/lbne/data/users/ljf26/fluxfiles/g4lbne/v3r2p4/QGSP_BERT/Nominal/200kA/flux/histos_g4lbne_v3r2p4_QGSP_BERT_Nominal_200kA_LBNEFD_fastmc.root" 137 nomrhcfile =
"/lbne/data/users/ljf26/fluxfiles/g4lbne/v3r2p4/QGSP_BERT/Nominal/-200kA/flux/histos_g4lbne_v3r2p4_QGSP_BERT_Nominal_-200kA_LBNEFD_fastmc.root" 138 if(tweak==
"antinufrac"):
139 varfhcfile =
"/lbne/data/users/ljf26/fluxfiles/g4lbne/v3r2p4/QGSP_BERT/Nominal/200kA/flux/histos_g4lbne_v3r2p4_QGSP_BERT_Nominal_200kA_LBNEFD_fastmc.root" 140 varrhcfile =
"/lbne/data/users/ljf26/fluxfiles/g4lbne/v3r2p4/QGSP_BERT/Nominal/-200kA/flux/histos_g4lbne_v3r2p4_QGSP_BERT_Nominal_-200kA_LBNEFD_fastmc.root" 144 for var
in range(len(amounts_varied_good_files)):
146 if tweak !=
"antinufrac":
147 varfhcfile =
"temp/fhc_"+tweak+
str(amounts_varied_good_files[var])+
".root" 148 varrhcfile =
"temp/rhc_"+tweak+
str(amounts_varied_good_files[var])+
".root" 151 antinufrac = amounts_varied_good_files[var]/100.0
155 print "metric",fitnesses[0],fitnesses[7],fitnesses[8]
157 metrics[1].append(fitnesses[7])
159 metrics[1].append(fitnesses[8])
163 ROOT.gStyle.SetMarkerStyle(21);
164 ROOT.gStyle.SetMarkerStyle(21);
166 c1 = ROOT.TCanvas(file_prefix);
171 line_styles = [1,2,3]
172 line_colors = [1,2,4]
176 temp = ROOT.TGraph(len(amounts_varied_good_files),array.array(
'd',amounts_varied_good_files),array.array(
'd',medians[i]));
177 temp.SetName(plotvar+
"_"+hierarchy)
182 t_graphs.append(temp)
184 if(plotvar ==
"cp_75thpercentile"):
186 t_graphs[i].GetYaxis().SetTitle(
"75% CP Sensitivity (#sigma)");
187 elif(plotvar ==
"mh_minimum"):
189 t_graphs[i].GetYaxis().SetTitle(
"Change in Minimum MH Sensitivity (#sigma)");
190 elif(plotvar ==
"cp_median"):
192 t_graphs[i].GetYaxis().SetTitle(
"Median CP Sensitivity (#sigma)");
194 if tweak==
"antinufrac":
195 t_graphs[i].GetXaxis().SetTitle(
"Antineutrino Running Fraction of Total");
197 t_graphs[i].GetXaxis().SetTitle(
"Normalization of "+tweak+
" flux to nominal configuration (%)");
199 t_graphs[i].SetLineColor(line_colors[i])
200 t_graphs[i].SetMarkerColor(line_colors[i])
203 if(plotvar!=
"cp_75thpercentile"):
204 t_graphs[i].SetMinimum(0);
205 t_graphs[i].SetMaximum(5);
206 t_graphs[i].SetTitle(
"")
208 t_graphs[i].Draw(
"ACP");
210 t_graphs[i].Draw(
"SAME CP");
212 leg = ROOT.TLegend(0.35,0.2,0.65,0.5);
213 leg.SetHeader(
"Sig/Bkgd Uncertainties");
214 leg.AddEntry(t_graphs[0],
"1%/5%",
"lp");
215 leg.AddEntry(t_graphs[1],
"2%/5%",
"lp");
216 leg.AddEntry(t_graphs[2],
"5%/10%",
"lp");
218 leg.SetBorderSize(0);
222 if(plotvar ==
"cp_75thpercentile" and i==1):
223 m_graph = ROOT.TGraph(len(amounts_varied_good_files),array.array(
'd',amounts_varied_good_files),array.array(
'd',metrics[i]));
224 m_graph.SetLineColor(line_colors[i])
225 m_graph.SetMarkerColor(line_colors[i])
226 m_graph.SetLineStyle(2)
227 t_graphs[i].SetMaximum(3.5);
228 t_graphs[i].SetMinimum(0);
229 t_graphs[i].SetTitle(
"")
230 t_graphs[i].Draw(
"ACP")
231 m_graph.Draw(
"SAME CP")
233 leg = ROOT.TLegend(0.4,0.7,0.6,0.9);
235 leg.AddEntry(t_graphs[1],
"Fast MC",
"l");
236 leg.AddEntry(m_graph,
"Metric",
"l");
238 leg.SetBorderSize(0);
242 file_prefix =
"sensitivity_plots/"+tweak+
"_"+hierarchy+
"_"+plotvar
245 c1.Print(file_prefix+
".eps")
246 c1.Print(file_prefix+
".png")
250 ofile = ROOT.TFile(file_prefix+".root","RECREATE") 259 colors = [2,4,6,1,3,5,7] 260 for i in range(len(histos[1])): 261 histos[1][i].SetLineColor(colors[i]) 262 histos[1][i].SetMaximum(10) 266 histos[1][i].Draw("same") 268 leg = ROOT.TLegend(0.45,0.5,0.85,0.85); 269 if(tweak=="antinufrac"): 270 leg.AddEntry(histos[1][0],"10/0"); 271 leg.AddEntry(histos[1][1],"9/1"); 272 leg.AddEntry(histos[1][2],"7.5/2.5"); 273 leg.AddEntry(histos[1][3],"5/5"); 274 leg.AddEntry(histos[1][4],"2.5/7.5"); 275 leg.AddEntry(histos[1][5],"1/9"); 276 leg.AddEntry(histos[1][6],"0/10"); 278 for i in range(len(histos[1])): 279 leg.AddEntry(histos[1][i],str(amounts_varied[i])) 283 leg.SetBorderSize(0); 286 c1.Print(plotvar+"_"+hierarchy+"blah.eps")
def GetFractionAtMoreThanXSigma(histo, X)
def ComputeMean75PercentSensitivityAndError(varfhcfile, varrhcfile, fhcvarenergy=120.0, rhcvarenergy=120.0, antinufrac=0.5, quantity="cp")
def GetPercentile(histo, X)