All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Functions | Variables
MakePlots Namespace Reference

Functions

def make_count_plot
 Main function ~~~~~~~~~~~~~. More...
 
def plot_cov_output
 
def plot_chi2_output
 
def compare_w_proposal
 
def dm2_chi2_slice
 
def sin_chi2_slice
 

Variables

list buildpath = os.environ['SBN_LIB_DIR']
 
tuple parser = argparse.ArgumentParser()
 
tuple args = parser.parse_args()
 

Function Documentation

def MakePlots.compare_w_proposal (   args)

Definition at line 189 of file MakePlots.py.

190 def compare_w_proposal(args):
191 
192  chi2file = TFile(args.chifile)
193 
194  gStyle = TStyle()
195  gStyle.SetPadLeftMargin(0.15); gStyle.SetPadRightMargin(0.15)
196 
197  colours = [30, 38, 46]
198  contours = [chi2file.Get('90pct'),
199  chi2file.Get('3sigma'),
200  chi2file.Get('5sigma')]
201 
202  propcontours = []
203  contournames = ['90pct', '3s', '5s']
204  contourtitles = ['90% Confidence Level', '3#sigma Confidence Level', '5#sigma Confidence Level']
205 
206  gr_range = TGraph()
207  gr_range.SetPoint(0, 0.001, 0.01)
208  gr_range.SetPoint(1, 1, 100)
209  gr_range.SetMarkerColor(0)
210 
211  bestfit = TGraph()
212  bestfit.SetPoint(0, 0.062, 1.7)
213  bestfit.SetMarkerStyle(29)
214  bestfit.SetMarkerSize(1.6)
215  bestfit.SetMarkerColor(40)
216 
217  print("contours has length " + str(len(contours)))
218 
219  for i in range(len(contours)):
220 
221  x = []
222  y = []
223 
224  with open(args.compdir+'numu'+contournames[i]+'.txt') as f:
225  for l, line in enumerate(f):
226  if l == 0: continue
227  x.append(float(line.split(', ')[0]))
228  y.append(float(line.split(', ')[1].replace("\n", "")))
229 
230  propcontours.append(TGraph())
231  for j in range(len(x)):
232  propcontours[i].SetPoint(j, x[j], y[j])
233 
234  tempcanvas = TCanvas('temp_canvas', '', 1020, 990)
235 
236  templegend = TLegend()
237  templegend.AddEntry(contours[i], 'Our contour', 'l')
238  templegend.AddEntry(propcontours[i], 'From proposal', 'l')
239  templegend.AddEntry(bestfit, 'Best Fit Point', 'p')
240 
241  tempcanvas.SetLogy()
242  tempcanvas.SetLogx()
243 
244  gr_range.SetTitle(contourtitles[i]+' Comparison; sin^{2}(2#theta); #Delta m^{2} (eV^{2})')
245 
246  gr_range.Draw('AP')
247  gr_range.GetXaxis().SetRangeUser(0.001, 1)
248  gr_range.GetYaxis().SetRangeUser(0.01, 100)
249 
250  for lst in (contours, propcontours):
251  lst[i].SetMarkerStyle(20)
252  lst[i].SetMarkerSize(0.25)
253  lst[i].SetMarkerColor(colours[i] if lst == contours else 1)
254  lst[i].SetLineColor(colours[i] if lst == contours else 1)
255 
256  contours[i].Draw('P same')
257  propcontours[i].Draw('P same')
258 
259  templegend.Draw()
260  bestfit.Draw('P same')
261 
262  tempcanvas.SaveAs(args.outdir+contournames[i]+'_comparison.pdf')
263 
do one_file $F done echo for F in find $TOP name CMakeLists txt print
auto enumerate(Iterables &&...iterables)
Range-for loop helper tracking the number of iteration.
Definition: enumerate.h:69
def compare_w_proposal
Definition: MakePlots.py:189
open(RACETRACK) or die("Could not open file $RACETRACK for writing")
def MakePlots.dm2_chi2_slice (   args)

Definition at line 264 of file MakePlots.py.

265 def dm2_chi2_slice(args):
266 
267  dm2s = [float(dm2) for dm2 in args.dm2list.split(",")]
268 
269  chi2file = TFile(args.chifile)
270  chi2 = chi2file.Get('chisq')
271 
272  min_sin = chi2.GetXmin(); max_sin = chi2.GetXmax()
273  min_dm2 = chi2.GetYmin(); max_dm2 = chi2.GetYmax()
274 
275  chi2_vals = [float(chi) for chi in chi2.GetZ()]
276  NP = int(math.sqrt(len(chi2_vals)))
277 
278  reusable_canvas = TCanvas()
279  print(dm2s)
280  print("min_sin = " + str(min_sin) + " and max_sin = " + str(max_sin))
281  print("min_dm2 = " + str(min_dm2) + " and max_dm2 + " + str(max_dm2))
282  print("NP + " + str(NP))
283  slices = []
284  for m, dm2 in enumerate(dm2s):
285 
286  jval = int((math.log10(dm2) - min_dm2)*(NP-1)/(max_dm2-min_dm2))
287  tempslice = [chi2_vals[i*NP + jval] for i in range(NP)]
288 
289  slices.append(TGraph())
290  for c, chi in enumerate(tempslice):
291  slices[m].SetPoint(c, (min_sin + c*(max_sin - min_sin)/(NP-1)), chi)
292 
293  if args.chilims:
294  chilims = [float(lim) for lim in args.chilims.split(",")]
295  if len(chilims) == 1:
296  slices[m].GetYaxis().SetRangeUser(0, chilims[0])
297  else:
298  slices[m].GetYaxis().SetRangeUser(chilims[0], chilims[1])
299 
300  slices[m].SetTitle("#chi^{2} @ #Delta m^{2} = " + str(dm2) + "; log_{10}(sin^{2}(2#theta)); #chi^{2}")
301  slices[m].Draw("AP")
302 
303  reusable_canvas.SaveAs(args.outdir + "dm2_"+str(dm2).replace(".", "-")+"_slice.pdf")
do one_file $F done echo for F in find $TOP name CMakeLists txt print
def dm2_chi2_slice
Definition: MakePlots.py:264
auto enumerate(Iterables &&...iterables)
Range-for loop helper tracking the number of iteration.
Definition: enumerate.h:69
def MakePlots.make_count_plot (   args)

Main function ~~~~~~~~~~~~~.

Definition at line 20 of file MakePlots.py.

20 
21 def make_count_plot(args):
22 
23  # Count plots
24 
25  countfile = TFile(args.cntfile)
26 
27  dets = []
28  for key in countfile.GetListOfKeys():
29  key = key.GetName()
30  if key[:key.find("_")] not in dets:
31  dets.append(key[:key.find("_")])
32 
33  samples = []
34  for key in countfile.GetListOfKeys():
35  key = key.GetName()
36  if key[key.find("_")+1:key.find("_")+1+key[key.find("_")+1:].find("_")] not in samples:
37  samples.append(key[key.find("_")+1:key.find("_")+1+key[key.find("_")+1:].find("_")])
38 
39  samplename = {"numu": "#nu_{#mu}", "nue": "#nu_{e}"}
40  canvases = []; stacks = []; ct_hists = []; bkg_hists = []; legends = []
41  for s, sample in enumerate(samples):
42 
43  canvases.append(TCanvas(sample+"_canvas"))
44  canvases[s].Divide(len(dets), 1)
45 
46  ct_hists.append([])
47  bkg_hists.append([])
48  stacks.append([])
49 
50  legends.append([])
51 
52  for d, det in enumerate(dets):
53 
54  ct_hists[s].append(countfile.Get(det+"_"+sample+"_cts"))
55  ct_hists[s][d].SetLineColor(38)
56  ct_hists[s][d].SetFillColor(38)
57 
58  bkg_hists[s].append(countfile.Get(det+"_"+sample+"_bkg"))
59  bkg_hists[s][d].SetLineColor(30)
60  bkg_hists[s][d].SetFillColor(30)
61 
62  for b in range(ct_hists[s][d].GetNbinsX()):
63  ct_hists[s][d].SetBinContent(1+b, ct_hists[s][d].GetBinContent(1+b) / ct_hists[s][d].GetBinWidth(1+b))
64  bkg_hists[s][d].SetBinContent(1+b, bkg_hists[s][d].GetBinContent(1+b) / bkg_hists[s][d].GetBinWidth(1+b))
65 
66  stacks[s].append(THStack(det+"_"+sample+"_stack", det+"; Counts; Energy (GeV)"))
67  stacks[s][d].Add(bkg_hists[s][d])
68  stacks[s][d].Add(ct_hists[s][d])
69 
70  legends[s].append(TLegend())
71  legends[s][d].AddEntry(ct_hists[s][d], 'CC -> #mu + X', 'f')
72  legends[s][d].AddEntry(bkg_hists[s][d], 'NC -> #pi^{#pm} + X', 'f')
73 
74  canvases[s].cd(d+1)
75  stacks[s][d].Draw("hist")
76  legends[s][d].Draw()
77 
78  # NOTE: This will have to be changed when nue samples are added; this assumed a simple
79  # count + background histogram stack, whereas nue plots in the proposal have the
80  # background broken up into many different 'types'
81 
82  canvases[s].SaveAs(args.outdir + sample + "_selection.pdf")
83 
auto enumerate(Iterables &&...iterables)
Range-for loop helper tracking the number of iteration.
Definition: enumerate.h:69
def make_count_plot
Main function ~~~~~~~~~~~~~.
Definition: MakePlots.py:20
do cd
def MakePlots.plot_chi2_output (   args)

Definition at line 117 of file MakePlots.py.

118 def plot_chi2_output(args):
119 
120  # Chi squareds
121 
122  chi2file = TFile(args.chifile)
123 
124  gStyle = TStyle()
125 
126  chi2 = chi2file.Get('chisq')
127 
128  chi2canvas = TCanvas()
129 
130  chi2.SetTitle('#chi^{2}; log_{10}(sin^{2}(2#theta)); log_{10}(#Delta m^{2}); #chi^{2}');
131  gStyle.SetPalette(1)
132  chi2.Draw('surf1')
133  chi2canvas.SaveAs(args.outdir + "chisq.pdf")
134 
135 
136  # Contours
137  contcanvas = TCanvas('cont_canvas', '', 1020, 990)
138  gStyle.SetPadLeftMargin(0.15); gStyle.SetPadRightMargin(0.15)
139 
140  colours = [30, 38, 46]
141  contours = [chi2file.Get('90pct'),
142  chi2file.Get('3sigma'),
143  chi2file.Get('5sigma')]
144 
145  for g in range(len(contours)):
146 
147  contours[g].SetMarkerStyle(20)
148  contours[g].SetMarkerSize(0.25)
149  contours[g].SetMarkerColor(colours[g])
150  contours[g].SetLineColor(colours[g])
151 
152  gr_range = TGraph()
153  gr_range.SetPoint(0, 0.001, 0.01)
154  gr_range.SetPoint(1, 1, 100)
155  gr_range.SetMarkerColor(0)
156 
157  bestfit = TGraph()
158  bestfit.SetPoint(0, 0.062, 1.7)
159  bestfit.SetMarkerStyle(29)
160  bestfit.SetMarkerSize(1.6)
161  bestfit.SetMarkerColor(40)
162 
163  gr_range.SetTitle('SBN Sensitivity; sin^{2}(2#theta); #Delta m^{2} (eV^{2})')
164 
165  legend = TLegend()
166  legend.AddEntry(contours[0], '90% CL', 'l')
167  legend.AddEntry(contours[1], '3#sigma CL', 'l')
168  legend.AddEntry(contours[2], '5#sigma CL', 'l')
169  legend.AddEntry(bestfit, 'Best Fit Point', 'p')
170 
171  contcanvas.SetLogy()
172  contcanvas.SetLogx()
173 
174  gr_range.Draw('AP')
175  gr_range.GetXaxis().SetRangeUser(0.001, 1)
176  gr_range.GetYaxis().SetRangeUser(0.01, 100)
177 
178  contours[0].Draw('P same')
179  contours[1].Draw('P same')
180  contours[2].Draw('P same')
181 
182  legend.Draw()
183  bestfit.Draw('P same')
184 
185  contcanvas.SetLeftMargin(0.15)
186  contcanvas.Update()
187  contcanvas.SaveAs(args.outdir+'Sensitivity.pdf')
188 
def plot_chi2_output
Definition: MakePlots.py:117
def MakePlots.plot_cov_output (   args)

Definition at line 84 of file MakePlots.py.

84 
85 def plot_cov_output(args):
86 
87  # Covariance, fractional covariance and correlation
88 
89  covfile = TFile(args.covfile)
90 
91  covcanvas = TCanvas()
92 
93  gStyle = TStyle()
94  gStyle.SetPadLeftMargin(0.25); gStyle.SetPadRightMargin(0.15)
95  gStyle.SetPalette(56)
96 
97  for matname in ('cov', 'fcov', 'corr'):
98 
99  mat = covfile.Get(matname)
100 
101  mat.GetYaxis().LabelsOption('v') # doesn't work...
102  mat.GetYaxis().SetLabelSize(0.07)
103  mat.GetXaxis().SetLabelSize(0.07)
104 
105  mat.SetTitleSize(0.3, 't') # doesn't work...
106 
107  if matname == 'corr':
108  mat.GetZaxis().SetRangeUser(-0.4, 1)
109  mat.SetTitle("Flux Correlation Matrix")
110 
111  mat.Draw("colz")
112  mat.SetStats(False)
113  covcanvas.SetLeftMargin(0.25)
114  covcanvas.Update()
115  covcanvas.SaveAs(args.outdir + matname + "_plot.pdf")
116 
def plot_cov_output
Definition: MakePlots.py:84
def MakePlots.sin_chi2_slice (   args)

Definition at line 304 of file MakePlots.py.

305 def sin_chi2_slice(args):
306 
307  sins = [float(sin) for sin in args.sinlist.split(",")]
308 
309  chi2file = TFile(args.chifile)
310  chi2 = chi2file.Get('chisq')
311 
312  min_sin = chi2.GetXmin(); max_sin = chi2.GetXmax()
313  min_dm2 = chi2.GetYmin(); max_dm2 = chi2.GetYmax()
314 
315  chi2_vals = [float(chi) for chi in chi2.GetZ()]
316  NP = int(math.sqrt(len(chi2_vals)))
317 
318  reusable_canvas = TCanvas()
319 
320  slices = []
321  for s, sin in enumerate(sins):
322 
323  ival = int((math.log10(sin) - min_sin)*(NP-1)/(max_sin-min_sin))
324  tempslice = [chi2_vals[ival*NP + j] for j in range(NP)]
325 
326  slices.append(TGraph())
327  for c, chi in enumerate(tempslice):
328  slices[s].SetPoint(c, 10**(min_dm2 + c*(max_dm2 - min_dm2)/(NP-1)), chi)
329 
330  if args.chilims:
331  chilims = [float(lim) for lim in args.chilims.split(",")]
332  if len(chilims) == 1:
333  slices[s].GetYaxis().SetRangeUser(0, chilims[0])
334  else:
335  slices[s].GetYaxis().SetRangeUser(chilims[0], chilims[1])
336 
337  slices[s].SetTitle("#chi^{2} @ #sin^{2}(2#theta) = " + str(sin) + "; log_{10}(#Delta m^{2}); #chi^{2}")
338  slices[s].Draw("AP")
339  reusable_canvas.SaveAs(args.outdir + "sin_"+str(sin).replace(".", "-")+"_slice.pdf")
340 
def sin_chi2_slice
Definition: MakePlots.py:304
auto enumerate(Iterables &&...iterables)
Range-for loop helper tracking the number of iteration.
Definition: enumerate.h:69

Variable Documentation

tuple MakePlots.args = parser.parse_args()

Definition at line 361 of file MakePlots.py.

list MakePlots.buildpath = os.environ['SBN_LIB_DIR']

Definition at line 343 of file MakePlots.py.

tuple MakePlots.parser = argparse.ArgumentParser()

Definition at line 351 of file MakePlots.py.