prettyPlotComps.py
Go to the documentation of this file.
1 import ROOT,sys
2 from array import array
3 
4 ROOT.TGaxis.SetMaxDigits(3)
5 
6 plotvars = ["flux","wrongsign"]
7 
8 #Draw
9 canvas = ROOT.TCanvas("canvas","canvas");
10 
11 for i in range(0,1):
12 
13  plotvar = plotvars[i]
14 
15  # Get the histo files
16  f_1 = ROOT.TFile("/dune/data/users/ljf26/fluxfiles/g4lbne/v3r5p4/QGSP_BERT/OptimizedEngineeredNov2017/neutrino/flux//histos_g4lbne_v3r5p4_QGSP_BERT_OptimizedEngineeredNov2017_neutrino_LBNEFD_fastmc.root")
17 # f_2 = ROOT.TFile("/dune/data2/users/ljf26/fluxfiles/g4lbne/v3r3p7/QGSP_BERT/NuMI_Opt_2015CDR_Be_80GeV_WideDecayPipe/neutrino/flux//histos_g4lbne_v3r3p7_QGSP_BERT_NuMI_Opt_2015CDR_Be_80GeV_WideDecayPipe_neutrino_LBNEFD_fastmc.root")
18 # f_3 = ROOT.TFile("/dune/data2/users/ljf26/fluxfiles/g4lbne/v3r3p7/QGSP_BERT/NuMI_Opt_2015CDR_Be_80GeV_LongDecayPipe/neutrino/flux//histos_g4lbne_v3r3p7_QGSP_BERT_NuMI_Opt_2015CDR_Be_80GeV_LongDecayPipe_neutrino_LBNEFD_fastmc.root")
19 # f_4 = ROOT.TFile("/dune/data/users/ljf26/fluxfiles/g4lbne/v3r3p6/QGSP_BERT/CP_run5_9116_80GeV/neutrino/flux//histos_g4lbne_v3r3p6_QGSP_BERT_CP_run5_9116_80GeV_neutrino_LBNEFD_fastmc.root")
20 # f_5 = ROOT.TFile("/dune/data/users/ljf26/fluxfiles/g4lbne/v3r3p6/QGSP_BERT/CP_run5_9116_80GeV_LongDecayPipe/neutrino/flux//histos_g4lbne_v3r3p6_QGSP_BERT_CP_run5_9116_80GeV_LongDecayPipe_neutrino_LBNEFD_fastmc.root")
21 # f_6 = ROOT.TFile("/dune/data/users/ljf26/fluxfiles/g4lbne/v3r5p4/QGSP_BERT/Perfect_80GeV_LongDecayPipe/neutrino/flux//histos_g4lbne_v3r5p4_QGSP_BERT_Perfect_80GeV_LongDecayPipe_neutrino_LBNEFD_fastmc.root")
22 
23  """
24  if plotvar=="wrongsign":
25  f_1 = ROOT.TFile("/dune/data/users/ljf26/fluxfiles/g4lbne/v3r5p4/QGSP_BERT/NuMI_Opt_2015CDR_80GeV/antineutrino/flux//histos_g4lbne_v3r5p4_QGSP_BERT_NuMI_Opt_2015CDR_80GeV_antineutrino_LBNEFD_fastmc.root")
26  f_2 = ROOT.TFile("/dune/data2/users/ljf26/fluxfiles/g4lbne/v3r3p7/QGSP_BERT/NuMI_Opt_2015CDR_Be_80GeV_WideDecayPipe/antineutrino/flux//histos_g4lbne_v3r3p7_QGSP_BERT_NuMI_Opt_2015CDR_Be_80GeV_WideDecayPipe_antineutrino_LBNEFD_fastmc.root")
27  f_3 = ROOT.TFile("/dune/data2/users/ljf26/fluxfiles/g4lbne/v3r3p7/QGSP_BERT/NuMI_Opt_2015CDR_Be_80GeV_LongDecayPipe/antineutrino/flux//histos_g4lbne_v3r3p7_QGSP_BERT_NuMI_Opt_2015CDR_Be_80GeV_LongDecayPipe_antineutrino_LBNEFD_fastmc.root")
28  f_4 = ROOT.TFile("/dune/data/users/ljf26/fluxfiles/g4lbne/v3r3p6/QGSP_BERT/CP_run5_9116_80GeV/antineutrino/flux//histos_g4lbne_v3r3p6_QGSP_BERT_CP_run5_9116_80GeV_antineutrino_LBNEFD_fastmc.root")
29  f_5 = ROOT.TFile("/dune/data/users/ljf26/fluxfiles/g4lbne/v3r3p6/QGSP_BERT/CP_run5_9116_80GeV_LongDecayPipe/antineutrino/flux//histos_g4lbne_v3r3p6_QGSP_BERT_CP_run5_9116_80GeV_LongDecayPipe_antineutrino_LBNEFD_fastmc.root")
30  f_6 = ROOT.TFile("/dune/data/users/ljf26/fluxfiles/g4lbne/v3r5p4/QGSP_BERT/Perfect_80GeV_LongDecayPipe/antineutrino/flux//histos_g4lbne_v3r3p6_QGSP_BERT_Perfect_80GeV_LongDecayPipe_antineutrino_LBNEFD_fastmc.root")
31  """
32 
33  histo_title = "numu_flux"
34 
35  h_1 = f_1.Get(histo_title)
36 # h_2 = f_2.Get(histo_title)
37 # h_3 = f_3.Get(histo_title)
38 # h_4 = f_4.Get(histo_title)
39 # h_5 = f_5.Get(histo_title)
40 # h_6 = f_6.Get(histo_title)
41 
42  if(plotvar=="flux" or plotvar=="wrongsign"):
43  # Rebin and convert to /GeV units
44  newbins = [0.0]
45  for i in range(61):
46  newbins.append((i+1)*0.125)
47 # for i in range(4):
48 # newbins.append(8.0 + (i+1)*0.5)
49  #for i in range(24):
50  # newbins.append(8.0 + (i+1)*0.5)
51  #for i in range(7):
52  # newbins.append(20.0 + (i+1)*2)
53 
54  h_1 = h_1.Rebin(len(newbins)-1,"1_flux",array('d',newbins))
55  #h_2 = h_2.Rebin(len(newbins)-1,"2_flux",array('d',newbins))
56  #h_3 = h_3.Rebin(len(newbins)-1,"3_flux",array('d',newbins))
57  #h_4 = h_4.Rebin(len(newbins)-1,"4_flux",array('d',newbins))
58  #h_5 = h_5.Rebin(len(newbins)-1,"5_flux",array('d',newbins))
59  #h_6 = h_6.Rebin(len(newbins)-1,"6_flux",array('d',newbins))
60 
61 
62  h_1.Scale(1,"width") # convert to per GeV from flux per bin
63  #h_2.Scale(1,"width") # convert to per GeV from flux per bin
64  #h_3.Scale(1,"width") # convert to per GeV from flux per bin
65  #h_4.Scale(1,"width") # convert to per GeV from flux per bin
66  #h_5.Scale(1,"width") # convert to per GeV from flux per bin
67  #h_6.Scale(1,"width") # convert to per GeV from flux per bin
68 
69  # Scale to flux per year instead of flux per POT
70  scale_factor_120GeV = 1.1e21
71  scale_factor_80GeV = 1.47e21
72  scale_factor_60GeV = 1.89e21
73 
74  h_1.Scale(scale_factor_120GeV);
75  #h_2.Scale(scale_factor_80GeV);
76  #h_3.Scale(scale_factor_80GeV);
77  #h_4.Scale(scale_factor_80GeV);
78  #h_5.Scale(scale_factor_80GeV);
79  #h_6.Scale(scale_factor_80GeV);
80 
81  # Rename axes appropriately
82  y_title = "Unoscillated #nu_{#mu}s / GeV / m^{2} / Year"
83  h_1.GetYaxis().SetTitle(y_title);
84  #h_2.GetYaxis().SetTitle(y_title);
85  #h_3.GetYaxis().SetTitle(y_title);
86  #h_4.GetYaxis().SetTitle(y_title);
87  #h_5.GetYaxis().SetTitle(y_title);
88  #h_6.GetYaxis().SetTitle(y_title);
89 
90  h_1.GetXaxis().SetTitle("Neutrino Energy (GeV)")
91 
92  h_1.SetLineColor(2);
93  #h_2.SetLineColor(6);
94  #h_3.SetLineColor(1);
95  #h_4.SetLineColor(2);
96  #h_5.SetLineColor(4);
97  #h_6.SetLineColor(15);
98 
99  #h_2.SetMaximum(100e9)
100 
101  a_title = "#nu_{#mu} Flux, #nu Mode, Far Detector"
102  if(plotvar=="wrongsign"):
103  a_title = "#nu_{#mu} Flux, #bar{#nu} Mode"
104  ROOT.gStyle.SetTitleY(0.93);
105  ROOT.gStyle.SetTitleFont(42,"t");
106 
107  h_1.SetTitle(a_title);
108  #h_2.SetTitle(a_title);
109  #h_3.SetTitle(a_title);
110  #h_4.SetTitle(a_title);
111  #h_5.SetTitle(a_title);
112  #h_6.SetTitle(a_title);
113 
114  #maxes = [h_1.GetMaximum(),h_2.GetMaximum(),h_3.GetMaximum(),h_4.GetMaximum(),h_5.GetMaximum(),h_6.GetMaximum()]
115  plot_max = h_1.GetMaximum()*1.2
116 # if(plotvar=="flux"):
117 # plot_max = 70e9
118 
119 
120  for histo in [h_1]:
121  histo.GetXaxis().CenterTitle()
122  histo.GetYaxis().CenterTitle()
123  histo.SetMaximum(plot_max)
124 
125  h_1.DrawCopy("hist");
126 
127 
128  ROOT.gStyle.SetOptTitle(1)
129  ROOT.gPad.Update()
130 
131  title = ROOT.gPad.GetPrimitive("title");
132  title.SetBorderSize(0);
133  #title.SetTextSize(0.04);
134  #title.SetTextFont(42)
135 
136  #canvas.SetLogx();
137  #h_6.DrawCopy("histsame");
138 # h_2.DrawCopy("histsame");
139 # h_3.DrawCopy("histsame");
140  h_1.DrawCopy("histsame");
141 # h_5.DrawCopy("histsame");
142  #h_1.DrawCopy("histsame");
143 
144  if(plotvar=="flux"):
145  leg = ROOT.TLegend(0.5,0.6,0.9,0.9);
146  #leg.AddEntry(h_6,"Perfect Focusing, 250x4 m DP","l");
147  # leg.AddEntry(h_5,"Optimized, 241x4 m DP","l");
148 # leg.AddEntry(h_4,"Optimized","l");
149 # leg.AddEntry(h_3,"Enhanced Reference, 250x4 m DP","l");
150 # leg.AddEntry(h_2,"Enhanced Reference","l");
151  leg.AddEntry(h_1,"DUNE Flux (Nov 2017)","l");
152  leg.SetFillStyle(0);
153  leg.SetTextFont(42);
154  leg.Draw();
155 
156  ROOT.gPad.RedrawAxis()
157  ROOT.gPad.Update()
158 
159 """
160  if not plotvar=="flux":
161  latex = ROOT.TLatex()
162  latex.SetTextSize(0.07);
163  latex.SetTextColor(14)
164  latex.SetNDC()
165  latex.DrawLatex(.2,.3,"PLACEHOLDER PLOT");
166 """
167 ROOT.gEnv.Print()
168 canvas.Print("DUNE_Numu_Flux_Nov2017.eps")
169 canvas.Print("DUNE_Numu_Flux_Nov2017.pdg")
170 canvas.Print("DUNE_Numu_Flux_Nov2017.png")
171 
auto array(Array const &a)
Returns a manipulator which will print the specified array.
Definition: DumpUtils.h:228
if(!yymsg) yymsg