ViewVC Help
View File | Revision Log | Show Annotations | Root Listing
root/cvsroot/UserCode/bm409/autoPlotter.py
(Generate patch)

Comparing UserCode/bm409/autoPlotter.py (file contents):
Revision 1.1 by bm409, Wed Aug 4 08:25:24 2010 UTC vs.
Revision 1.3 by bm409, Thu Aug 5 15:41:35 2010 UTC

# Line 17 | Line 17 | Root.gStyle.SetOptTitle(1)
17   Root.gStyle.SetOptStat(0)
18  
19  
20 + def DrawHist(H,col,norm):
21 +        Hist =
22   def HistogramMaxYmum(H):
23          Nbins = H.GetNbinsX()
24          Entries = [H.GetBinContent(i) for i in range(1,Nbins+1)]
# Line 78 | Line 80 | closeList = []
80   for dir in range(0,len(DirKeys)):
81    for hist in HistNames[dir]:
82      if "/" in hist : continue
83 <    leg = Root.TLegend(0.6, 0.6, 0.9, 0.9)
83 >    leg = Root.TLegend(0.6, 0.6, 0.8, 0.8)
84      leg.SetShadowColor(0)
85      leg.SetFillColor(0)
86      leg.SetLineColor(0)
# Line 88 | Line 90 | for dir in range(0,len(DirKeys)):
90      MaxY = 1.0
91      MaxX = 1.0
92      XMin = 1000.
93 <    c1 = Root.TCanvas("canvas"+hist,"morename",1200,1200)
93 >    c1 = Root.TCanvas("canvas"+hist,"canname"+hist,1200,1200)
94      # c1.Divide(1,2)#,0.4,0.4)
95 <    mainPad = Root.TPad("","",0.01,0.31,0.99,0.99);
95 >    mainPad = Root.TPad("","",0.01,0.21,0.99,0.99);
96      mainPad.SetNumber(1);
97      mainPad.Draw();
98  
99 <    ratioPad = Root.TPad("","",0.01,0.01,0.99,0.3);
99 >    ratioPad = Root.TPad("","",0.01,0.01,0.99,0.2);
100      ratioPad.SetNumber(2);
101      ratioPad.Draw();
102  
# Line 103 | Line 105 | for dir in range(0,len(DirKeys)):
105        a = Root.TFile.Open(file)
106        closeList.append(a)
107        b = a.Get(DirKeys[dir].GetTitle())
108 <      if "JetMETTau" in file :
108 >      if "AK5Calo_JetMETTau_Run2010A_Compleate" in file :
109          c1.SetLogy()
110          c = b.Get(hist)
111          if c.IsA().InheritsFrom("TH2") : continue
# Line 115 | Line 117 | for dir in range(0,len(DirKeys)):
117            XMin = HistogramMinX(c)
118          if HistogramMaxX(c) > MaxX :
119            MaxX = HistogramMaxX(c)
120 <        title = Root.TLatex(0.2,0.95,(DirKeys[dir].GetTitle())+"_"+hist)
120 >        title = Root.TLatex(0.2,0.95,(DirKeys[dir].GetTitle())+"_"+hist[0:-4])
121          title.SetNDC()
122          title.Draw()
123          leg.AddEntry(c,(RootFileList[0])[19:-5],"Pl")
124        if "JetMETTau" not in file :
125          d = b.Get(hist)
126          if d.IsA().InheritsFrom("TH2") : continue
127 <        if col == 3 or col == 9 : col+=1
127 >        if col == 10 or col == 9 : col+=1
128          d.SetLineColor(col)
129          d.SetLineWidth(3)
130          if d.Integral() > 0:
131            Norm = 100.
130          if "AK5Calo_WJets-madgraph" in file :
131            Norm = 1.0
132            d.Scale(intlumi/Norm)
133            # d.Scale(c.Integral()/d.Integral())
134          if "QCD" in file:
135            d.SetFillColor(Root.kRed)
136            d.SetLineColor(Root.kRed)
137            d.SetFillStyle(3002)
138 <        d.Draw("Sameh")
139 <        if "AK5Calo_SumOfAllBackgrounds" in file :
138 >
139 >        if "AK5Calo_TotalBackgrounds" in file :
140 >          d.SetLineColor(Root.kAzure)
141            RatioBottom = d.Clone()
142          leg.AddEntry(d,(RootFileList[fileno])[19:-5],"lpf")
143          leg.Draw("same")
144 +        d.Draw("Sameh")
145          if HistogramMaxYmum(d) > MaxY :
146            MaxY = HistogramMaxYmum(d)
147          if HistogramMaxX(d) > MaxX :
148            MaxX = HistogramMaxX(d)
149 <        if HistogramMinX(c) < XMin:
150 <          XMin = HistogramMinX(c)
149 >        if HistogramMinX(d) < XMin:
150 >          XMin = HistogramMinX(d)
151          col+=1
152          fileno+=1
153      c.GetXaxis().SetRangeUser(XMin,MaxX)
154      c.GetYaxis().SetRangeUser(0.0001,1.2*MaxY)
155      RatioTop.Divide(RatioBottom)
156      RatioTop.GetYaxis().SetRangeUser(0.,2.)
157 +    RatioTop.GetYaxis().SetTitle("data / sim")
158 +    RatioTop.GetXaxis().SetTitle(d.GetXaxis().GetTitle())
159      c1.cd(2)
160      unity = Root.TLine();
161      unity.SetLineWidth(2);
# Line 167 | Line 171 | for dir in range(0,len(DirKeys)):
171        if (DirKeys[dir].GetTitle())[0] != "n":
172  
173          Images ='''<tr>
174 <          <td><a href="'''+(DirKeys[dir].GetTitle())+"_"+hist+'.png\"><img src=\"'+(DirKeys[dir].GetTitle())+"_"+hist+'.png\" width =\"598\" height=\"286\" /></a></td>' + "<td><a href=\""+"n"+(DirKeys[dir].GetTitle())+"_"+hist+'.png\"><img src=\"'+"n"+(DirKeys[dir].GetTitle())+"_"+hist+'.png\" width =\"598\" height=\"286\" /></a></td> <tr>' + "<td><a href=\""+(DirKeys[dir].GetTitle())+"_Log_"+hist+'.png\"><img src=\"'+(DirKeys[dir].GetTitle())+"_Log_"+hist+'.png\" width =\"598\" height=\"286\" /></a></td>'"<td><a href=\""+"n"+(DirKeys[dir].GetTitle())+"_Log_"+hist+'.png\"><img src=\"'+"n"+(DirKeys[dir].GetTitle())+"_Log_"+hist+'.png\" width =\"598\" height=\"286\" /></a></td>'
174 >          <td><a href="'''+(DirKeys[dir].GetTitle())+"_"+hist+'.png\"><img src=\"'+(DirKeys[dir].GetTitle())+"_"+hist+'.png\" width =\"598\" height=\"286\" /></a></td> \n' + "<td><a href=\""+"n"+(DirKeys[dir].GetTitle())+"_"+hist+'.png\"><img src=\"'+"n"+(DirKeys[dir].GetTitle())+"_"+hist+'.png\" width =\"598\" height=\"286\" /></a></td> <tr> \n' + "<td><a href=\""+(DirKeys[dir].GetTitle())+"_Log_"+hist+'.png\"><img src=\"'+(DirKeys[dir].GetTitle())+"_Log_"+hist+'.png\" width =\"598\" height=\"286\" /></a></td>\n' "<td><a href=\""+"n"+(DirKeys[dir].GetTitle())+"_Log_"+hist+'.png\"><img src=\"'+"n"+(DirKeys[dir].GetTitle())+"_Log_"+hist+'.png\" width =\"598\" height=\"286\" /></a></td>\n'
175          Webpage.write(Images)
176  
177        # mergedPlots.writeTObject(c1)

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines