1 |
algomez |
1.1 |
#!/usr/bin/env python
|
2 |
|
|
###################################################
|
3 |
|
|
# This python script ...
|
4 |
|
|
####################################################
|
5 |
|
|
|
6 |
|
|
import os,sys,string,re,math
|
7 |
|
|
from array import array
|
8 |
|
|
|
9 |
|
|
try:
|
10 |
|
|
from ROOT import *
|
11 |
|
|
except:
|
12 |
|
|
print "\nCannot load PYROOT, make sure you have setup ROOT in the path"
|
13 |
|
|
print "and pyroot library is also defined in the variable PYTHONPATH, try:\n"
|
14 |
|
|
if (os.getenv("PYTHONPATH")):
|
15 |
|
|
print " setenv PYTHONPATH ${PYTHONPATH}:$ROOTSYS/lib\n"
|
16 |
|
|
else:
|
17 |
|
|
print " setenv PYTHONPATH $ROOTSYS/lib\n"
|
18 |
|
|
sys.exit()
|
19 |
|
|
|
20 |
|
|
#import Inspector
|
21 |
|
|
#import Style
|
22 |
|
|
|
23 |
|
|
gROOT.SetStyle("Plain")
|
24 |
|
|
gStyle.SetOptStat(0)
|
25 |
|
|
DEBUG = False
|
26 |
|
|
|
27 |
|
|
# style
|
28 |
|
|
#thestyle = Style.Style()
|
29 |
|
|
HasCMSStyle = False
|
30 |
|
|
style = None
|
31 |
|
|
if os.path.isfile('tdrstyle.C'):
|
32 |
|
|
gROOT.ProcessLine('.L tdrstyle.C')
|
33 |
|
|
ROOT.setTDRStyle()
|
34 |
|
|
print "Found tdrstyle.C file, using this style."
|
35 |
|
|
HasCMSStyle = True
|
36 |
|
|
if os.path.isfile('CMSTopStyle.cc'):
|
37 |
|
|
gROOT.ProcessLine('.L CMSTopStyle.cc+')
|
38 |
|
|
style = CMSTopStyle()
|
39 |
|
|
print "Found CMSTopStyle.cc file, use TOP style if requested in xml file."
|
40 |
|
|
if not HasCMSStyle:
|
41 |
|
|
print "No CMSTopStyle.cc"
|
42 |
|
|
|
43 |
|
|
FOpen = ['results_4Top_1000.root',
|
44 |
|
|
'results_4Top_500.root',
|
45 |
|
|
'results_QCD.root',
|
46 |
|
|
'results_STsch.root',
|
47 |
|
|
'results_STsch_bar.root',
|
48 |
|
|
'results_STtWch.root',
|
49 |
|
|
'results_STtWch_bar.root',
|
50 |
|
|
'results_STtch.root',
|
51 |
|
|
'results_STtch_bar.root',
|
52 |
|
|
'results_WJets.root',
|
53 |
|
|
'results_ZJets.root',
|
54 |
|
|
'results_WW.root',
|
55 |
|
|
'results_WZ.root',
|
56 |
|
|
'results_ttbar.root']
|
57 |
|
|
|
58 |
|
|
#######################################
|
59 |
|
|
#def Disc(ofile, name):
|
60 |
|
|
######################################
|
61 |
|
|
for ofile in FOpen:
|
62 |
|
|
tmpname = ofile.replace('results_','')
|
63 |
|
|
name = tmpname.replace('.root','')
|
64 |
|
|
|
65 |
|
|
infile = TFile(ofile)
|
66 |
|
|
histo1 = infile.Get("/jets/1st_bdisc_"+name)
|
67 |
|
|
histo2 = infile.Get("/jets/2nd_bdisc_"+name)
|
68 |
|
|
|
69 |
|
|
scale1 = 1/histo1.Integral()
|
70 |
|
|
scale2 = 1/histo2.Integral()
|
71 |
|
|
|
72 |
|
|
histo1.Scale(scale1)
|
73 |
|
|
histo2.Scale(scale2)
|
74 |
|
|
|
75 |
|
|
totalhisto = TH1F(histo1*histo2)
|
76 |
|
|
|
77 |
|
|
#if ofile[1]:
|
78 |
|
|
# c1.cd()
|
79 |
|
|
# histo1.Draw("Hist")
|
80 |
|
|
#else:
|
81 |
|
|
# c1.cd()
|
82 |
|
|
# histo1.Draw("Hist same")
|
83 |
|
|
#if ofile[len(FOpen)]: c1.SaveAs("test.png")
|
84 |
|
|
|
85 |
|
|
def legend():
|
86 |
|
|
leg = TLegend(0.66,0.65,0.93,0.93)
|
87 |
|
|
leg.SetMargin(0.12)
|
88 |
|
|
leg.SetTextSize(0.035)
|
89 |
|
|
leg.SetFillColor(0)
|
90 |
|
|
leg.SetFillStyle(0)
|
91 |
|
|
leg.SetBorderSize(0)
|
92 |
|
|
leg.AddEntry(httbar_1, style.TtbarText, "l" )
|
93 |
|
|
leg.AddEntry(hWJets_1,style.WJetsText, "l" )
|
94 |
|
|
leg.AddEntry(hZJets_1, style.DYZJetsText, "l" )
|
95 |
|
|
leg.AddEntry(hQCD_1,"QCD", "l" )
|
96 |
|
|
leg.AddEntry(hWZ_1,"Dibosons", "l" )
|
97 |
|
|
leg.AddEntry(hSTtch_bar_1,"Single-Top", "l" )
|
98 |
|
|
leg.AddEntry(h4Top_1000_1,"Gh 1 TeV", "l" )
|
99 |
|
|
leg.AddEntry(h4Top_500_1,"Gh 0.5 TeV", "l" )
|
100 |
|
|
leg.Draw()
|
101 |
|
|
return leg
|
102 |
|
|
|
103 |
|
|
|
104 |
|
|
# Open files
|
105 |
|
|
f4Top_1000 = TFile("results_4Top_1000.root")
|
106 |
|
|
h4Top_1000_1 = f4Top_1000.Get("/jets/1st_bdisc_4Top_1000")
|
107 |
|
|
h4Top_1000_1.Scale(1/h4Top_1000_1.Integral())
|
108 |
|
|
h4Top_1000_2 = f4Top_1000.Get("/jets/2nd_bdisc_4Top_1000")
|
109 |
|
|
h4Top_1000_2.Scale(1/h4Top_1000_2.Integral())
|
110 |
|
|
h4Top_1000 = TH1F(h4Top_1000_1*h4Top_1000_2)
|
111 |
|
|
#h4Top_1000_3 = f4Top_1000.Get("/jets/3rd_bdisc_4Top_1000")
|
112 |
|
|
|
113 |
|
|
f4Top_500 = TFile("results_4Top_500.root")
|
114 |
|
|
h4Top_500_1 = f4Top_500.Get("/jets/1st_bdisc_4Top_500")
|
115 |
|
|
h4Top_500_1.Scale(1/h4Top_500_1.Integral())
|
116 |
|
|
h4Top_500_2 = f4Top_500.Get("/jets/2nd_bdisc_4Top_500")
|
117 |
|
|
h4Top_500_2.Scale(1/h4Top_500_2.Integral())
|
118 |
|
|
h4Top_500 = TH1F(h4Top_500_1*h4Top_500_2)
|
119 |
|
|
|
120 |
|
|
fQCD = TFile("results_QCD.root")
|
121 |
|
|
hQCD_1 = fQCD.Get("/jets/1st_bdisc_QCD")
|
122 |
|
|
hQCD_1.Scale(1/hQCD_1.Integral())
|
123 |
|
|
hQCD_2 = fQCD.Get("/jets/2nd_bdisc_QCD")
|
124 |
|
|
hQCD_2.Scale(1/hQCD_2.Integral())
|
125 |
|
|
hQCD = TH1F(hQCD_1*hQCD_2)
|
126 |
|
|
|
127 |
|
|
fSTsch = TFile("results_STsch.root")
|
128 |
|
|
hSTsch_1 = fSTsch.Get("/jets/1st_bdisc_STsch")
|
129 |
|
|
hSTsch_1.Scale(1/hSTsch_1.Integral())
|
130 |
|
|
hSTsch_2 = fSTsch.Get("/jets/2nd_bdisc_STsch")
|
131 |
|
|
hSTsch_2.Scale(1/hSTsch_2.Integral())
|
132 |
|
|
hSTsch = TH1F(hSTsch_1*hSTsch_2)
|
133 |
|
|
|
134 |
|
|
fSTsch_bar = TFile("results_STsch_bar.root")
|
135 |
|
|
hSTsch_bar_1 = fSTsch_bar.Get("/jets/1st_bdisc_STsch_bar")
|
136 |
|
|
hSTsch_bar_1.Scale(1/hSTsch_bar_1.Integral())
|
137 |
|
|
hSTsch_bar_2 = fSTsch_bar.Get("/jets/2nd_bdisc_STsch_bar")
|
138 |
|
|
hSTsch_bar_2.Scale(1/hSTsch_bar_2.Integral())
|
139 |
|
|
hSTsch_bar = TH1F(hSTsch_bar_1*hSTsch_bar_2)
|
140 |
|
|
|
141 |
|
|
fSTtWch = TFile("results_STtWch.root")
|
142 |
|
|
hSTtWch_1 = fSTtWch.Get("/jets/1st_bdisc_STtWch")
|
143 |
|
|
hSTtWch_1.Scale(1/hSTtWch_1.Integral())
|
144 |
|
|
hSTtWch_2 = fSTtWch.Get("/jets/2nd_bdisc_STtWch")
|
145 |
|
|
hSTtWch_2.Scale(1/hSTtWch_2.Integral())
|
146 |
|
|
hSTtWch = TH1F(hSTtWch_1*hSTtWch_2)
|
147 |
|
|
|
148 |
|
|
fSTtWch_bar = TFile("results_STtWch_bar.root")
|
149 |
|
|
hSTtWch_bar_1 = fSTtWch_bar.Get("/jets/1st_bdisc_STtWch_bar")
|
150 |
|
|
hSTtWch_bar_1.Scale(1/hSTtWch_bar_1.Integral())
|
151 |
|
|
hSTtWch_bar_2 = fSTtWch_bar.Get("/jets/2nd_bdisc_STtWch_bar")
|
152 |
|
|
hSTtWch_bar_2.Scale(1/hSTtWch_bar_2.Integral())
|
153 |
|
|
hSTtWch_bar = TH1F(hSTtWch_bar_1*hSTtWch_bar_2)
|
154 |
|
|
|
155 |
|
|
fSTtch = TFile("results_STtch.root")
|
156 |
|
|
hSTtch_1 = fSTtch.Get("/jets/1st_bdisc_STtch")
|
157 |
|
|
hSTtch_1.Scale(1/hSTtch_1.Integral())
|
158 |
|
|
hSTtch_2 = fSTtch.Get("/jets/2nd_bdisc_STtch")
|
159 |
|
|
hSTtch_2.Scale(1/hSTtch_2.Integral())
|
160 |
|
|
hSTtch = TH1F(hSTtch_1*hSTtch_2)
|
161 |
|
|
|
162 |
|
|
fSTtch_bar = TFile("results_STtch_bar.root")
|
163 |
|
|
hSTtch_bar_1 = fSTtch_bar.Get("/jets/1st_bdisc_STtch_bar")
|
164 |
|
|
hSTtch_bar_1.Scale(1/hSTtch_bar_1.Integral())
|
165 |
|
|
hSTtch_bar_2 = fSTtch_bar.Get("/jets/2nd_bdisc_STtch_bar")
|
166 |
|
|
hSTtch_bar_2.Scale(1/hSTtch_bar_2.Integral())
|
167 |
|
|
hSTtch_bar = TH1F(hSTtch_bar_1*hSTtch_bar_2)
|
168 |
|
|
|
169 |
|
|
fWJets = TFile("results_WJets.root")
|
170 |
|
|
hWJets_1 = fWJets.Get("/jets/1st_bdisc_WJets")
|
171 |
|
|
hWJets_1.Scale(1/hWJets_1.Integral())
|
172 |
|
|
hWJets_2 = fWJets.Get("/jets/2nd_bdisc_WJets")
|
173 |
|
|
hWJets_2.Scale(1/hWJets_2.Integral())
|
174 |
|
|
hWJets = TH1F(hWJets_1*hWJets_2)
|
175 |
|
|
|
176 |
|
|
fZJets = TFile("results_ZJets.root")
|
177 |
|
|
hZJets_1 = fZJets.Get("/jets/1st_bdisc_ZJets")
|
178 |
|
|
hZJets_1.Scale(1/hZJets_1.Integral())
|
179 |
|
|
hZJets_2 = fZJets.Get("/jets/2nd_bdisc_ZJets")
|
180 |
|
|
hZJets_2.Scale(1/hZJets_2.Integral())
|
181 |
|
|
hZJets = TH1F(hZJets_1*hZJets_2)
|
182 |
|
|
|
183 |
|
|
fWW = TFile("results_WW.root")
|
184 |
|
|
hWW_1 = fWW.Get("/jets/1st_bdisc_WW")
|
185 |
|
|
hWW_1.Scale(1/hWW_1.Integral())
|
186 |
|
|
hWW_2 = fWW.Get("/jets/2nd_bdisc_WW")
|
187 |
|
|
hWW_2.Scale(1/hWW_2.Integral())
|
188 |
|
|
hWW = TH1F(hWW_1*hWW_2)
|
189 |
|
|
|
190 |
|
|
fWZ = TFile("results_WZ.root")
|
191 |
|
|
hWZ_1 = fWZ.Get("/jets/1st_bdisc_WZ")
|
192 |
|
|
hWZ_1.Scale(1/hWZ_1.Integral())
|
193 |
|
|
hWZ_2 = fWZ.Get("/jets/2nd_bdisc_WZ")
|
194 |
|
|
hWZ_2.Scale(1/hWZ_2.Integral())
|
195 |
|
|
hWZ = TH1F(hWZ_1*hWZ_2)
|
196 |
|
|
|
197 |
|
|
fttbar = TFile("results_ttbar.root")
|
198 |
|
|
httbar_1 = fttbar.Get("/jets/1st_bdisc_ttbar")
|
199 |
|
|
httbar_1.Scale(1/httbar_1.Integral())
|
200 |
|
|
httbar_2 = fttbar.Get("/jets/2nd_bdisc_ttbar")
|
201 |
|
|
httbar_2.Scale(1/httbar_2.Integral())
|
202 |
|
|
httbar_3 = fttbar.Get("/jets/3rd_bdisc_ttbar")
|
203 |
|
|
httbar = TH1F(httbar_1*httbar_2)
|
204 |
|
|
|
205 |
|
|
|
206 |
|
|
can = TCanvas('can', '', 1000,800)
|
207 |
|
|
can.cd()
|
208 |
|
|
can.SetLogy()
|
209 |
|
|
|
210 |
|
|
h4Top_1000_1.SetLineColor(1)
|
211 |
|
|
h4Top_1000_1.Draw("Hist")
|
212 |
|
|
|
213 |
|
|
h4Top_500_1.SetLineColor(1)
|
214 |
|
|
h4Top_500_1.SetLineWidth(2)
|
215 |
|
|
h4Top_500_1.Draw("Hist same")
|
216 |
|
|
|
217 |
|
|
hQCD_1.SetLineColor(style.QCDColor)
|
218 |
|
|
hQCD_1.SetLineWidth(2)
|
219 |
|
|
hQCD_1.Draw("Hist same")
|
220 |
|
|
|
221 |
|
|
hSTsch_bar_1.Add(hSTsch_1)
|
222 |
|
|
hSTtWch_1.Add(hSTsch_bar_1)
|
223 |
|
|
hSTtWch_bar_1.Add(hSTtWch_1)
|
224 |
|
|
hSTtch_1.Add(hSTtWch_bar_1)
|
225 |
|
|
hSTtch_bar_1.Add(hSTtch_1)
|
226 |
|
|
hSTtch_bar_1.SetLineColor(style.SingleTopColor)
|
227 |
|
|
hSTtch_bar_1.SetLineWidth(2)
|
228 |
|
|
hSTtch_bar_1.Draw("Hist same")
|
229 |
|
|
|
230 |
|
|
hWJets_1.SetLineColor(style.WJetsColor)
|
231 |
|
|
hWJets_1.SetLineWidth(2)
|
232 |
|
|
hWJets_1.Draw("Hist same")
|
233 |
|
|
|
234 |
|
|
hZJets_1.SetLineColor(style.DYZJetsColor)
|
235 |
|
|
hZJets_1.SetLineWidth(2)
|
236 |
|
|
hZJets_1.Draw("Hist same")
|
237 |
|
|
|
238 |
|
|
hWZ_1.Add(hWW_1)
|
239 |
|
|
hWZ_1.SetLineColor(style.DibosonsColor)
|
240 |
|
|
hWZ_1.SetLineWidth(2)
|
241 |
|
|
hWZ_1.Draw("Hist same")
|
242 |
|
|
|
243 |
|
|
httbar_1.SetLineColor(style.TtbarColor)
|
244 |
|
|
httbar_1.SetLineWidth(2)
|
245 |
|
|
httbar_1.Draw("Hist same")
|
246 |
|
|
|
247 |
|
|
leg = legend()
|
248 |
|
|
can.SaveAs("1st_bdisc.png")
|
249 |
|
|
|
250 |
|
|
|
251 |
|
|
can2 = TCanvas('can2', '', 1000,800)
|
252 |
|
|
can2.cd()
|
253 |
|
|
can2.SetLogy()
|
254 |
|
|
h4Top_1000_2.SetLineColor(1)
|
255 |
|
|
h4Top_1000_2.Draw("Hist")
|
256 |
|
|
|
257 |
|
|
h4Top_500_2.SetLineColor(1)
|
258 |
|
|
h4Top_500_2.SetLineWidth(2)
|
259 |
|
|
h4Top_500_2.Draw("Hist same")
|
260 |
|
|
|
261 |
|
|
hQCD_2.SetLineColor(style.QCDColor)
|
262 |
|
|
hQCD_2.SetLineWidth(2)
|
263 |
|
|
hQCD_2.Draw("Hist same")
|
264 |
|
|
|
265 |
|
|
hSTsch_bar_2.Add(hSTsch_2)
|
266 |
|
|
hSTtWch_2.Add(hSTsch_bar_2)
|
267 |
|
|
hSTtWch_bar_2.Add(hSTtWch_2)
|
268 |
|
|
hSTtch_2.Add(hSTtWch_bar_2)
|
269 |
|
|
hSTtch_bar_2.Add(hSTtch_2)
|
270 |
|
|
hSTtch_bar_2.SetLineColor(style.SingleTopColor)
|
271 |
|
|
hSTtch_bar_2.SetLineWidth(2)
|
272 |
|
|
hSTtch_bar_2.Draw("Hist same")
|
273 |
|
|
|
274 |
|
|
hWJets_2.SetLineColor(style.WJetsColor)
|
275 |
|
|
hWJets_2.SetLineWidth(2)
|
276 |
|
|
hWJets_2.Draw("Hist same")
|
277 |
|
|
|
278 |
|
|
hZJets_2.SetLineColor(style.DYZJetsColor)
|
279 |
|
|
hZJets_2.SetLineWidth(2)
|
280 |
|
|
hZJets_2.Draw("Hist same")
|
281 |
|
|
|
282 |
|
|
hWZ_2.Add(hWW_2)
|
283 |
|
|
hWZ_2.SetLineColor(style.DibosonsColor)
|
284 |
|
|
hWZ_2.SetLineWidth(2)
|
285 |
|
|
hWZ_2.Draw("Hist same")
|
286 |
|
|
|
287 |
|
|
httbar_2.SetLineColor(style.TtbarColor)
|
288 |
|
|
httbar_2.SetLineWidth(2)
|
289 |
|
|
httbar_2.Draw("Hist same")
|
290 |
|
|
|
291 |
|
|
leg = legend()
|
292 |
|
|
can2.SaveAs("2nd_bdisc.png")
|
293 |
|
|
|
294 |
|
|
|
295 |
|
|
can3 = TCanvas('can3', '', 1000,800)
|
296 |
|
|
can3.cd()
|
297 |
|
|
can3.SetLogy()
|
298 |
|
|
|
299 |
|
|
h4Top_1000.SetLineColor(1)
|
300 |
|
|
h4Top_1000.Draw("Hist")
|
301 |
|
|
h4Top_1000.GetXaxis().SetTitle("total b discriminator")
|
302 |
|
|
h4Top_1000.SetTitle("Total B Discriminator")
|
303 |
|
|
h4Top_1000.SetMinimum(10e-7)
|
304 |
|
|
h4Top_1000.SetMaximum(10e-2)
|
305 |
|
|
|
306 |
|
|
h4Top_500.SetLineColor(1)
|
307 |
|
|
h4Top_500.SetLineWidth(2)
|
308 |
|
|
h4Top_500.Draw("Hist same")
|
309 |
|
|
|
310 |
|
|
hQCD.SetLineColor(style.QCDColor)
|
311 |
|
|
hQCD.SetLineWidth(2)
|
312 |
|
|
hQCD.Draw("Hist same")
|
313 |
|
|
|
314 |
|
|
hSTsch_bar.Add(hSTsch)
|
315 |
|
|
hSTtWch.Add(hSTsch_bar)
|
316 |
|
|
hSTtWch_bar.Add(hSTtWch)
|
317 |
|
|
hSTtch.Add(hSTtWch_bar)
|
318 |
|
|
hSTtch_bar.Add(hSTtch)
|
319 |
|
|
hSTtch_bar.SetLineColor(style.SingleTopColor)
|
320 |
|
|
hSTtch_bar.SetLineWidth(2)
|
321 |
|
|
hSTtch_bar.Draw("Hist same")
|
322 |
|
|
|
323 |
|
|
hWJets.SetLineColor(style.WJetsColor)
|
324 |
|
|
hWJets.SetLineWidth(2)
|
325 |
|
|
hWJets.Draw("Hist same")
|
326 |
|
|
|
327 |
|
|
hZJets.SetLineColor(style.DYZJetsColor)
|
328 |
|
|
hZJets.SetLineWidth(2)
|
329 |
|
|
hZJets.Draw("Hist same")
|
330 |
|
|
|
331 |
|
|
hWZ.Add(hWW)
|
332 |
|
|
hWZ.SetLineColor(style.DibosonsColor)
|
333 |
|
|
hWZ.SetLineWidth(2)
|
334 |
|
|
hWZ.Draw("Hist same")
|
335 |
|
|
|
336 |
|
|
httbar.SetLineColor(style.TtbarColor)
|
337 |
|
|
httbar.SetLineWidth(2)
|
338 |
|
|
httbar.Draw("Hist same")
|
339 |
|
|
|
340 |
|
|
leg = legend()
|
341 |
|
|
can3.SaveAs("total_bdisc.png")
|