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"]
45 tweaks = [
"fhc_numu",
"fhc_numubar",
"fhc_nue",
"rhc_numu",
"rhc_numu",
"rhc_numubar",
"rhc_nuebar"]
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/"+file_prefix+
"_histos.root");
93 t_file = ROOT.TFile(
"/lbne/data/users/lblpwg_tools/FastMC_Data/outputs/ljf26/Sensitivity_Plots/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"):
105 medians[0].append(
GetPercentile(t_file.Get(
"h1"),75)-baseline_medians[0])
106 medians[1].append(
GetPercentile(t_file.Get(
"h2"),75)-baseline_medians[1])
107 medians[2].append(
GetPercentile(t_file.Get(
"h3"),75)-baseline_medians[2])
109 elif(plotvar==
"mh_minimum"):
110 medians[0].append(
GetMinimum(t_file.Get(
"h1"))-baseline_medians[0])
111 medians[1].append(
GetMinimum(t_file.Get(
"h2"))-baseline_medians[1])
112 medians[2].append(
GetMinimum(t_file.Get(
"h3"))-baseline_medians[2])
114 elif(plotvar==
"cp_median"):
115 medians[0].append(
GetMedian(t_file.Get(
"h1"))-baseline_medians[0])
116 medians[1].append(
GetMedian(t_file.Get(
"h2"))-baseline_medians[1])
117 medians[2].append(
GetMedian(t_file.Get(
"h3"))-baseline_medians[2])
119 elif(plotvar==
"cp_3sigma"):
131 if(plotvar ==
"cp_75thpercentile"):
135 nomfhcfile =
"/lbne/data/users/ljf26/fluxfiles/g4lbne/v3r2p4/QGSP_BERT/Nominal/200kA/flux/histos_g4lbne_v3r2p4_QGSP_BERT_Nominal_200kA_LBNEFD_fastmc.root" 136 nomrhcfile =
"/lbne/data/users/ljf26/fluxfiles/g4lbne/v3r2p4/QGSP_BERT/Nominal/-200kA/flux/histos_g4lbne_v3r2p4_QGSP_BERT_Nominal_-200kA_LBNEFD_fastmc.root" 137 if(tweak==
"antinufrac"):
138 varfhcfile =
"/lbne/data/users/ljf26/fluxfiles/g4lbne/v3r2p4/QGSP_BERT/Nominal/200kA/flux/histos_g4lbne_v3r2p4_QGSP_BERT_Nominal_200kA_LBNEFD_fastmc.root" 139 varrhcfile =
"/lbne/data/users/ljf26/fluxfiles/g4lbne/v3r2p4/QGSP_BERT/Nominal/-200kA/flux/histos_g4lbne_v3r2p4_QGSP_BERT_Nominal_-200kA_LBNEFD_fastmc.root" 143 for var
in range(len(amounts_varied_good_files)):
145 if tweak !=
"antinufrac":
146 varfhcfile =
"temp/fhc_"+tweak+
str(amounts_varied_good_files[var])+
".root" 147 varrhcfile =
"temp/rhc_"+tweak+
str(amounts_varied_good_files[var])+
".root" 150 antinufrac = amounts_varied_good_files[var]/100.0
154 print "metric",fitnesses[0],fitnesses[7],fitnesses[8]
156 metrics[1].append(fitnesses[7]-baseline_medians[1])
158 metrics[1].append(fitnesses[8]-baseline_medians[1])
162 ROOT.gStyle.SetMarkerStyle(21);
163 ROOT.gStyle.SetMarkerStyle(21);
165 c1 = ROOT.TCanvas(file_prefix);
170 line_styles = [1,2,3]
171 line_colors = [1,2,4]
175 temp = ROOT.TGraph(len(amounts_varied_good_files),array.array(
'd',amounts_varied_good_files),array.array(
'd',medians[i]));
176 temp.SetName(plotvar+
"_"+hierarchy)
181 t_graphs.append(temp)
183 if(plotvar ==
"cp_75thpercentile"):
185 t_graphs[i].GetYaxis().SetTitle(
"75% CP Sensitivity (#sigma)");
186 elif(plotvar ==
"mh_minimum"):
188 t_graphs[i].GetYaxis().SetTitle(
"Change in Minimum MH Sensitivity (#sigma)");
189 elif(plotvar ==
"cp_median"):
191 t_graphs[i].GetYaxis().SetTitle(
"Median CP Sensitivity (#sigma)");
193 if tweak==
"antinufrac":
194 t_graphs[i].GetXaxis().SetTitle(
"Antineutrino Running Fraction of Total");
196 t_graphs[i].GetXaxis().SetTitle(
"Normalization of "+tweak+
" flux to nominal configuration (%)");
198 t_graphs[i].SetLineColor(line_colors[i])
199 t_graphs[i].SetMarkerColor(line_colors[i])
202 if(plotvar!=
"cp_75thpercentile"):
203 t_graphs[i].SetMinimum(-1);
204 t_graphs[i].SetMaximum(1);
206 t_graphs[i].Draw(
"ACP");
208 t_graphs[i].Draw(
"SAME CP");
210 leg = ROOT.TLegend(0.35,0.2,0.65,0.5);
211 leg.SetHeader(
"Sig/Bkgd Uncertainties");
212 leg.AddEntry(t_graphs[0],
"1%/5%",
"lp");
213 leg.AddEntry(t_graphs[1],
"2%/5%",
"lp");
214 leg.AddEntry(t_graphs[2],
"5%/10%",
"lp");
216 leg.SetBorderSize(0);
220 if(plotvar ==
"cp_75thpercentile" and i==1):
221 m_graph = ROOT.TGraph(len(amounts_varied_good_files),array.array(
'd',amounts_varied_good_files),array.array(
'd',metrics[i]));
222 m_graph.SetLineColor(line_colors[i])
223 m_graph.SetMarkerColor(line_colors[i])
224 m_graph.SetLineStyle(2)
225 t_graphs[i].SetMaximum(1);
226 t_graphs[i].SetMinimum(-1);
227 t_graphs[i].Draw(
"ACP")
228 m_graph.Draw(
"SAME CP")
230 leg = ROOT.TLegend(0.4,0.7,0.6,0.9);
232 leg.AddEntry(t_graphs[1],
"Fast MC",
"l");
233 leg.AddEntry(m_graph,
"Metric",
"l");
235 leg.SetBorderSize(0);
239 file_prefix =
"sensitivity_plots/normscales_"+tweak+
"_"+hierarchy+
"_"+plotvar
242 c1.Print(file_prefix+
".eps")
243 c1.Print(file_prefix+
".png")
246 ofile = ROOT.TFile(file_prefix+
".root",
"RECREATE")
254 colors = [2,4,6,1,3,5,7] 255 for i in range(len(histos[1])): 256 histos[1][i].SetLineColor(colors[i]) 257 histos[1][i].SetMaximum(10) 261 histos[1][i].Draw("same") 263 leg = ROOT.TLegend(0.45,0.5,0.85,0.85); 264 if(tweak=="antinufrac"): 265 leg.AddEntry(histos[1][0],"10/0"); 266 leg.AddEntry(histos[1][1],"9/1"); 267 leg.AddEntry(histos[1][2],"7.5/2.5"); 268 leg.AddEntry(histos[1][3],"5/5"); 269 leg.AddEntry(histos[1][4],"2.5/7.5"); 270 leg.AddEntry(histos[1][5],"1/9"); 271 leg.AddEntry(histos[1][6],"0/10"); 273 for i in range(len(histos[1])): 274 leg.AddEntry(histos[1][i],str(amounts_varied[i])) 278 leg.SetBorderSize(0); 281 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)