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)] |
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) |
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 |
|
|
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 |
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); |
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) |