1 import ROOT, os, array, sys, OptimizationUtils,Optimizations
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);
22 for i
in range(0,histo.GetNbinsX()):
23 if histo.GetBinContent(i+1) < min:
24 min = histo.GetBinContent(i+1)
27 hierarchies = [
"nh",
"ih"]
28 plotvars = [
"cp_75thpercentile",
"mh_minimum"]
34 for hierarchy
in hierarchies:
35 for plotvar
in plotvars:
36 amounts_varied = [177,3544,4177,6177,6911,7177,7862,8177,8186]
40 mixing_param = plotvar[0:2]
41 baseline_file =ROOT.TFile(
"/lbne/data/users/lblpwg_tools/FastMC_Data/outputs/ljf26/Sensitivity_Plots/ProtonP120GeV_"+hierarchy+
"_"+mixing_param+
"_histos.root");
43 if(plotvar==
"cp_75thpercentile"):
44 baseline_medians.append(
GetPercentile(baseline_file.Get(
"h1"),75))
45 baseline_medians.append(
GetPercentile(baseline_file.Get(
"h2"),75))
46 baseline_medians.append(
GetPercentile(baseline_file.Get(
"h3"),75))
47 elif(plotvar==
"mh_minimum"):
48 baseline_medians.append(
GetMinimum(baseline_file.Get(
"h1")))
49 baseline_medians.append(
GetMinimum(baseline_file.Get(
"h2")))
50 baseline_medians.append(
GetMinimum(baseline_file.Get(
"h3")))
56 amounts_varied_good_files = []
57 for amount_varied
in amounts_varied:
60 var =
"Optimizations_CP_run3_"+
str(amount_varied)
61 file_prefix = var+
"_"+hierarchy+
"_"+mixing_param
63 t_file = ROOT.TFile(
"/lbne/data/users/lblpwg_tools/FastMC_Data/outputs/ljf26/Sensitivity_Plots/"+file_prefix+
"_histos.root");
66 if(t_file.IsZombie()
or t_file.Get(
"h2").Integral()==0):
68 amounts_varied_good_files.append(amount_varied)
70 histos[0].append(t_file.Get(
"h1").Clone(
"h1_"+
str(amount_varied)))
71 histos[1].append(t_file.Get(
"h2").Clone(
"h2_"+
str(amount_varied)))
72 histos[2].append(t_file.Get(
"h3").Clone(
"h3_"+
str(amount_varied)))
74 if(plotvar==
"cp_75thpercentile"):
77 print amount_varied,
GetPercentile(t_file.Get(
"h2"),75),t_file.Get(
"h2").Integral()
80 elif(plotvar==
"mh_minimum"):
81 medians[0].append(
GetMinimum(t_file.Get(
"h1")))
82 medians[1].append(
GetMinimum(t_file.Get(
"h2")))
83 medians[2].append(
GetMinimum(t_file.Get(
"h3")))
91 if(plotvar ==
"cp_75thpercentile"):
95 nomfhcfile =
"/lbne/data/users/ljf26/fluxfiles/g4lbne/v3r2p4/QGSP_BERT/Nominal/200kA/flux/histos_g4lbne_v3r2p4_QGSP_BERT_Nominal_200kA_LBNEFD_fastmc.root" 96 nomrhcfile =
"/lbne/data/users/ljf26/fluxfiles/g4lbne/v3r2p4/QGSP_BERT/Nominal/-200kA/flux/histos_g4lbne_v3r2p4_QGSP_BERT_Nominal_-200kA_LBNEFD_fastmc.root" 97 for var
in range(len(amounts_varied_good_files)):
99 varfhcfile =
"/lbne/data/users/ljf26/fluxfiles/g4lbne/v3r3p2/QGSP_BERT/Optimizations-CP_run3-"+
str(amounts_varied_good_files[var])+
"/200kA/flux/histos_g4lbne_"+optimization.g4lbne_version+
"_QGSP_BERT_Optimizations-CP_run3-"+
str(amounts_varied_good_files[var])+
"_200kA_LBNEFD_fastmc.root" 100 varrhcfile =
"/lbne/data/users/ljf26/fluxfiles/g4lbne/v3r3p2/QGSP_BERT/Optimizations-CP_run3-"+
str(amounts_varied_good_files[var])+
"/-200kA/flux/histos_g4lbne_"+optimization.g4lbne_version+
"_QGSP_BERT_Optimizations-CP_run3-"+
str(amounts_varied_good_files[var])+
"_-200kA_LBNEFD_fastmc.root" 102 energy = optimization.getEnergy(float(amounts_varied_good_files[var]),
"")
106 if plotvar.startswith(
"mh"):
111 print "metric",fitnesses[0],fitnesses[7],fitnesses[8]
113 metrics[1].append(fitnesses[7])
115 metrics[1].append(fitnesses[8])
119 ROOT.gStyle.SetMarkerStyle(21);
120 ROOT.gStyle.SetMarkerStyle(21);
122 c1 = ROOT.TCanvas(file_prefix);
127 line_styles = [1,2,3]
128 line_colors = [1,2,4]
132 temp = ROOT.TGraph(len(amounts_varied_good_files),array.array(
'd',amounts_varied_good_files),array.array(
'd',medians[i]));
133 temp.SetName(plotvar+
"_"+hierarchy)
135 t_graphs.append(temp)
137 if(plotvar ==
"cp_75thpercentile"):
138 t_graphs[i].GetYaxis().SetTitle(
"75% CP Sensitivity (#sigma)");
139 elif(plotvar ==
"mh_minimum"):
140 t_graphs[i].GetYaxis().SetTitle(
"Change in Minimum MH Sensitivity (#sigma)");
142 t_graphs[i].GetXaxis().SetTitle(
"Optimization Configuration");
144 t_graphs[i].SetLineColor(line_colors[i])
145 t_graphs[i].SetMarkerColor(line_colors[i])
150 m_graph = ROOT.TGraph(len(amounts_varied_good_files),array.array(
'd',amounts_varied_good_files),array.array(
'd',metrics[i]));
151 m_graph.SetLineColor(line_colors[i])
152 m_graph.SetMarkerColor(line_colors[i])
153 m_graph.SetLineStyle(2)
154 t_graphs[i].SetMaximum(3.5);
155 t_graphs[i].SetMinimum(0);
156 t_graphs[i].Draw(
"ACP")
157 m_graph.Draw(
"SAME CP")
159 leg = ROOT.TLegend(0.4,0.2,0.6,0.4);
161 leg.AddEntry(t_graphs[1],
"Fast MC",
"l");
162 leg.AddEntry(m_graph,
"Metric",
"l");
164 leg.SetBorderSize(0);
169 file_prefix =
"sensitivity_plots/optimization_test_"+hierarchy+
"_"+plotvar
172 c1.Print(file_prefix+
".eps")
173 c1.Print(file_prefix+
".png")
def ComputeMean75PercentSensitivityAndError(varfhcfile, varrhcfile, fhcvarenergy=120.0, rhcvarenergy=120.0, antinufrac=0.5, quantity="cp")
def GetPercentile(histo, X)