interactionmap.py
Go to the documentation of this file.
1 from optparse import OptionParser
2 import sys, os, subprocess, shutil, ROOT, array, math
3 
4 usage = "usage: %prog[options]"
5 parser = OptionParser(usage=usage)
6 
7 parser.add_option("-f","--filename",dest="filename",help="filename for histogram creation",default="NA")
8 
9 (options,args)=parser.parse_args()
10 pathname = options.filename
11 
12 output_objects=[]
13 #collision=[]
14 #histos=[]
15 
16 f = ROOT.TFile(str(pathname))
17 for keys in f.GetListOfKeys():
18  output_objects.append(f.Get(keys.GetName()))
19 
20 
21 def drawhistos(lists,start,particle,histos):
22  xmax=0
23  ymax=0
24  collision=[]
25  histogram=[]
26  histcontainer=[]
27  ROOT.gStyle.SetPaintTextFormat("4.4f")
28  c1=ROOT.TCanvas("c1","c1",750,750)
29  c1.cd()
30  for objects in lists:
31  if objects.GetName()==start:
32  for keys in objects.GetListOfKeys():
33  collision.append(objects.Get(keys.GetName()))
34 
35  for particles in collision:
36  if particles.GetName()==particle:
37  #print 'Yes i got {}'.format(particle)
38  for keys in particles.GetListOfKeys():
39  histogram.append(particles.Get(keys.GetName()))
40 
41  for hists in histogram:
42  if hists.GetName()==histos:
43  #print 'Yes I got {}'.format(histos)
44  for i in range(1,hists.GetNbinsX()):
45  if(hists.GetXaxis()).GetBinLabel(i)=="":
46  xmax=i-1
47  break
48  for j in range(1,hists.GetNbinsY()):
49  if(hists.GetYaxis()).GetBinLabel(j)=="":
50  ymax=j
51  #print j
52  break
53 
54  c1.cd()
55  (hists.GetXaxis()).SetRangeUser(0,xmax)
56  (hists.GetYaxis()).SetRangeUser(0,ymax)
57  hists.SetMinimum(0.0001)
58  hists.Draw("COLZTEXT")
59  raw_input()
60 
61 
62 def allparticlehistos(lists,start,histos):
63  xmax=0
64  ymax=0
65  collision=[]
66  histogram=[]
67  histcontainer=[]
68  ROOT.gStyle.SetPaintTextFormat("4.4f")
69  c1=ROOT.TCanvas("c1","c1",750,750)
70  c1.cd()
71  for objects in lists:
72  if objects.GetName()==start:
73  for keys in objects.GetListOfKeys():
74  collision.append(objects.Get(keys.GetName()))
75 
76 
77  for hists in collision:
78  if hists.GetName()==histos:
79  #print 'Yes I got {}'.format(histos)
80  for i in range(1,hists.GetNbinsX()):
81  if(hists.GetXaxis()).GetBinLabel(i)=="":
82  xmax=i-1
83  break
84  for j in range(1,hists.GetNbinsY()):
85  if(hists.GetYaxis()).GetBinLabel(j)=="":
86  ymax=j
87  #print j
88  break
89 
90  c1.cd()
91  (hists.GetXaxis()).SetRangeUser(0,xmax)
92  (hists.GetYaxis()).SetRangeUser(0,ymax)
93  hists.SetMinimum(0.0001)
94  hists.Draw("COLZTEXT")
95  raw_input()
96 
97 
98 
99 #
100 #drawhistos(output_objects,"Produced","Proton","hmatbkgpi+")
101 allparticlehistos(output_objects,"Projectile","h_in_vs_mat")
102 
103 
104 
105 
def drawhistos(lists, start, particle, histos)
def allparticlehistos(lists, start, histos)
if(!yymsg) yymsg
static QCString str