simpleFluxPlot.py
Go to the documentation of this file.
1 import ROOT, sys, os
2 
3 
4 
5 fluxpaths = ["/lbne/data/users/kirby/g4lbne_output/test2_300k_B_011.root","/lbne/data/users/ljf26/fluxfiles/g4lbne/v3r2p4/QGSP_BERT/Nominal/200kA/flux/"]
6 fluxfiles = []
7 fluxchains = []
8 
9 for i in range(0,len(fluxpaths)):
10  fluxfiles.append([])
11  if os.path.isdir(fluxpaths[i]):
12  print "The path you specified ("+fluxpaths[i]+") appears to be a directory... looking for flux files in that directory."
13 
14  for root,dirs,files in os.walk(fluxpaths[i]):
15  for file in files:
16  temppath = os.path.join(root,file)
17 
18  if file.startswith("g4lbne_") and file.endswith(".root"):
19  fluxfiles[i].append(temppath)
20  print "Found ",len(fluxfiles[i])," flux files to consider"
21  else:
22  print "Drawing fluxes from file:",fluxpaths[i]
23  fluxfiles[i].append(fluxpaths[i])
24 
25 
26 ##### CREATE CHAINS OF FLUX NTUPLES #####
27 
28  fluxchains.append(ROOT.TChain("nudata"))
29  for file in fluxfiles[i]:
30  fluxchains[i].Add(file)
31 
32 vars_to_draw1 = ["beamX","beamY","protonX","protonY","protonPx","protonPy","protonPz","nuTarZ","hornCurrent","Ndxdz","Ndydz","Npz","Nenergy","NdxdzNear[0]","NdydzNear[0]","NenergyN[0]","NWtNear[0]","NdxdzFar[0]","NdydzFar[0]","NenergyF[0]","NWtFar[0]","Norig","Ndecay","Ntype","Vx","Vy","Vz","ppdxdz","ppdydz","pppz","ppenergy","ptype","ppvx","ppvy","ppvz","muparpx","muparpy","muparpz","Necm","Nimpwt","tvx","tvy","tvz","tpx","tpy","tpz","tptype","tgen"]
33 vars_to_draw2 = ["beamX","beamY","protonX","protonY","protonPx","protonPy","protonPz","nuTarZ","hornCurrent","Ndxdz","Ndydz","Npz","Nenergy","NdxdzNear[0]","NdydzNear[0]","NenergyN[0]","NWtNear[0]","NdxdzFar[0]","NdydzFar[0]","NenergyF[0]","NWtFar[0]","Norig","Ndecay","Ntype","Vx","Vy","Vz","ppdxdz","ppdydz","pppz","ppenergy","ptype","ppvx","ppvy","ppvz","muparpx","muparpy","muparpz","Necm","Nimpwt","tvx","tvy","tvz","tpx","tpy","tpz","tptype","tgen"]
34 
35 
36 canv = ROOT.TCanvas("canvas","canvas")
37 hists1 = []
38 hists2 = []
39 for i in range(0,len(vars_to_draw1)):
40  fluxchains[0].Draw(vars_to_draw1[i]+">>"+vars_to_draw1[i]+"_1");
41  hists1.append(ROOT.gDirectory.Get(vars_to_draw1[i]+"_1"))
42  hists2.append(hists1[i].Clone(vars_to_draw2[i]+"_2"))
43  fluxchains[1].Draw(vars_to_draw1[i]+">>"+vars_to_draw2[i]+"_2");
44 
45  hists2[i].Scale(3.0/190.0);
46 
47  hists1[i].SetLineColor(4)
48  hists1[i].SetLineWidth(2)
49  hists1[i].Draw()
50  hists2[i].SetLineColor(2);
51  hists2[i].Draw("SAME")
52 
53  canv.Print("plots/"+vars_to_draw1[i]+".eps")
54  canv.Print("plots/"+vars_to_draw2[i]+".png")
55 
56 os.system("mkdir ~/public_html/temp/ntuple_comps/")
57 os.system("cp plots/*.png ~/public_html/temp/ntuple_comps/")
58 os.system("cp dirindex.sh ~/public_html/temp/ntuple_comps/")
59 os.system("chmod u+x ~/public_html/temp/ntuple_comps/dirindex.sh")
60 os.system("cd plots/; ~/public_html/temp/ntuple_comps/dirindex.sh | tee ~/public_html/temp/ntuple_comps/index.html")
61 
62 """
63 canv = ROOT.TCanvas("NeutrinoTheta","NeutrinoTheta")
64 canv.cd()
65 H_NeutrinoTheta = ROOT.TH1F("H_NeutrinoTheta","H_NeutrinoTheta",100,0,0.5);
66 FluxChain.Draw("360.0/(2*TMath::Pi())*TMath::ACos(TMath::Sqrt(1/(1+pow(NdxdzNear[0],2)+pow(NdydzNear[0],2))))>>H_NeutrinoTheta","Nimpwt*NWtNear[0]")
67 #FluxChain.Draw("Nimpwt");
68 
69 canv.Print("NeutrinoTheta.png");
70 canv..Print("NeutrinoTheta.eps");
71 
72 
73 H_NeutrinoDxdz = ROOT.TH1F("H_NeutrinoDxdz","H_NeutrinoDxdz",200,-0.03,0.03);
74 FluxChain.Draw("NdxdzNear[0]>>H_NeutrinoDxdz","Nimpwt*NWtNear[0]")
75 
76 canv.Print("NeutrinoDxdz.png");
77 canv.Print("NeutrinoDxdz.eps");
78 
79 
80 H_NeutrinoDydz = ROOT.TH1F("H_NeutrinoDyDz","H_NeutrinoDyDz",200,-0.03,0.03);
81 FluxChain.Draw("NdydzNear[0]>>H_NeutrinoDxdz","Nimpwt*NWtNear[0]")
82 
83 canv.Print("NeutrinoDydz.png");
84 canv.Print("NeutrinoDydz.eps");
85 
86 canv.cd()
87 H_NeutrinoEnergy = ROOT.TH1F("H_NeutrinoEnergy","H_NeutrinoEnergy",100,0,20);
88 FluxChain.Draw("NenergyN[0]>>H_NeutrinoEnergy","Nimpwt*NWtNear[0]")
89 H_NeutrinoEnergy.Draw();
90 
91 canv.Print("NeutrinoEnergy.png");
92 canv.Print("NeutrinoEnergy.eps");
93 """
Scale(size_t pos, T factor) -> Scale< T >