ViewVC Help
View File | Revision Log | Show Annotations | Root Listing
root/cvsroot/UserCode/Mrenna/SimpleLHEAnalysis/simple.py
Revision: 1.1.1.1 (vendor branch)
Committed: Wed Feb 20 08:20:55 2013 UTC (12 years, 2 months ago) by mrenna
Content type: text/x-python
Branch: V00-01, MAIN
CVS Tags: start, HEAD
Changes since 1.1: +0 -0 lines
Log Message:
SimpleLHE analysis code

File Contents

# User Rev Content
1 mrenna 1.1 import ROOT
2     import sys,glob
3    
4    
5     #ROOT.gEnv.SetValue("TFile.Recover",0)
6     # important! This doesn't work. Set in local .rootrc
7     filename=sys.argv[1]
8     f = ROOT.TFile(filename, "READ")
9     dirlist = f.GetListOfKeys()
10    
11    
12     f.cd("demo")
13    
14     t=ROOT.gDirectory.GetListOfKeys()
15    
16     c1=ROOT.TCanvas()
17     c1.SaveAs("test.ps[")
18     for k in t:
19     tp=k.GetName()
20     f.cd("demo/"+tp)
21     tt=ROOT.gDirectory.GetListOfKeys()
22     xmin=0.03
23     xmax=0.97
24     ymin=0.02
25     ymax=0.92
26     xstep=(xmax-xmin)/3
27     ystep=(ymax-ymin)/3
28     padList=[]
29     for j in range(0,9):
30     ix=j%3
31     iy=j/3
32     dx=xmin+xstep*ix
33     dy=ymin+ystep*iy
34     padList.append(ROOT.TPad(tp,tp,dx,dy,dx+xstep,dy+ystep))
35     padList[j].Draw()
36     print(dx,dy,dx+xstep,dy+ystep)
37     j=0
38     print(padList)
39     for kk in tt:
40     ttp=kk.GetName()
41     hnew_=ROOT.TH1F()
42     ROOT.gDirectory.GetObject(ttp,hnew_)
43     print(j)
44     pad_=padList[j]
45     # pad_.Draw()
46     if j==0:
47     label_=ROOT.TPaveLabel(0.3,0.94,0.7,0.98,tp)
48     label_.Draw()
49     pad_.cd()
50     hnew_.DrawCopy()
51     # ttext_=ROOT.TText()
52     # ttext_.DrawTextNDC(0.5,0.95,tp)
53     # pad_.Close()
54     j=j+1
55     c1.SaveAs("test.ps")
56     print(padList)
57     padList[8].Close()
58     padList[7].Close()
59     padList[6].Close()
60     padList[5].Close()
61     padList[4].Close()
62     padList[3].Close()
63     padList[2].Close()
64     padList[1].Close()
65     padList[0].Close()
66     # for j in range(0,6):
67     # pad_=padList[j]
68     # pad_.Clear()
69     f.cd("demo")
70    
71     c1.SaveAs("test.ps]")
72     sys.exit(0)
73    
74     h1 = ROOT.TH1F()
75     tp = "higgs_pT [#1]"
76     #higgs_mass and higgs_rap
77     ROOT.gDirectory.GetObject(tp,h1)
78     #f.Close()
79    
80     filename="H_WW_M.root"
81     g = ROOT.TFile(filename, "READ")
82     g.cd("jetsPt")
83     h2 = ROOT.TH1F()
84     tp = "higgs_pT [#1]"
85     #higgs_mass and higgs_rap
86     ROOT.gDirectory.GetObject(tp,h2)
87     #g.Close()
88    
89     filename="H_WW_L.root"
90     x = ROOT.TFile(filename, "READ")
91     x.cd("jetsPt")
92     h3 = ROOT.TH1F()
93     tp = "higgs_pT [#1]"
94     #higgs_mass and higgs_rap
95     ROOT.gDirectory.GetObject(tp,h3)
96     #x.Close()
97    
98     h1.SetLineColor(1)
99     h2.SetLineColor(2)
100     h3.SetLineColor(3)
101    
102     myPlot=ROOT.TCanvas("myPlot","Histo comparison",0,0,500,700)
103     pad1=ROOT.TPad("pad1","pad1",0,0.3,1,1)
104     pad2=ROOT.TPad("pad2","pad2",0,0,1,0.3)
105     #pad2=ROOT.TPad("pad2","pad2",0,0,1,1)
106    
107     pad1.Draw()
108     pad2.Draw()
109     pad1.cd()
110     h3.DrawCopy("")
111     h2.DrawCopy("same")
112     h1.DrawCopy("same")
113    
114     pad2.cd()
115    
116     h3.Divide(h1)
117     h2.Divide(h1)
118     h3.DrawCopy("")
119     h2.DrawCopy("same")
120    
121    
122     myPlot.SaveAs("pTHiggs.png")