drawinteraction.py
Go to the documentation of this file.
1 import ROOT
2 
3 def DrawTogether(rootfile,directory,urange):
4  hists=[]
5  histogram=["h_aveint_vs_enu_tot","h_aveint_vs_enu_thin_pCpion","h_aveint_vs_enu_thin_pCkaon","h_aveint_vs_enu_thin_nCpion","h_aveint_vs_enu_thin_pCnucleon","h_aveint_vs_enu_thin_mesoninc","h_aveint_vs_enu_thin_nucleona","h_aveint_vs_enu_others"]
6  legends=["Total HP","pC-->#pi X","pC-->KX","nC-->#pi X","pC-->nucleonX","meson inc.","nucloen-A","others"]
7  color=[1,4,4,42,42,28,28,39]
8  style=[1,1,2,1,2,1,2,1]
9  histo_universe=[]
10  for j in range(0,len(histogram)):
11  in_dir = directory+"/"+histogram[j]
12  histo_universe.append(rootfile.Get(str(in_dir)))
13  c1 = ROOT.TCanvas("c1","c1",750,750)
14  c1.cd()
15  leg = ROOT.TLegend(0.3,0.3,0.5,0.9)
16  histo_universe[0].SetLineWidth(3)
17  histo_universe[0].SetLineColor(color[0])
18  histo_universe[0].SetLineStyle(style[0])
19  leg.AddEntry(histo_universe[0],str(legends[0]),"lp")
20  #histo_universe[0].Scale(1/100)
21  if urange:
22  (histo_universe[0].GetXaxis()).SetRangeUser(0,20)
23  histo_universe[0].SetMinimum(0)
24  histo_universe[0].SetMaximum(220)
25  histo_universe[0].Draw("hist")
26  for i in range(1,len(histo_universe)):
27  histo_universe[i].SetLineWidth(3)
28  histo_universe[i].SetLineColor(color[i])
29  histo_universe[i].SetLineStyle(style[i])
30  leg.AddEntry(histo_universe[i],str(legends[i]),"lp")
31  #histo_universe[i].Scale(1/100)
32  histo_universe[i].Draw("Same")
33  leg.Draw("")
34  raw_input()
35 
36 r_file = ROOT.TFile("output_interactionmap_opt.root")
37 DrawTogether(r_file,"Projectile",True)
38 
39 
40 
def DrawTogether(rootfile, directory, urange)
static QCString str