ViewVC Help
View File | Revision Log | Show Annotations | Root Listing
root/cvsroot/UserCode/dhidas/OSUAnalysis/Tools/scripts/plotWpri.py
Revision: 1.1.1.1 (vendor branch)
Committed: Thu Dec 1 16:28:48 2011 UTC (13 years, 5 months ago) by dhidas
Content type: text/x-python
Branch: dhidas, MAIN
CVS Tags: START, HEAD
Changes since 1.1: +0 -0 lines
Log Message:
osu copy modified

File Contents

# Content
1 from __future__ import division
2
3 from tdrStyle import *
4 from ROOT import *
5
6 canvases = []
7 scanvases = []
8 counter = 0
9
10 def plotMttbar():
11 tdrstyle = setTDRStyle();
12 gStyle.SetHatchesSpacing(1.0);
13 lumi = 1091;
14 oldLumi = 1600;
15 scale = lumi / oldLumi;
16 qcdScale = {'default':1.72, 'withMETAndAsymJets': 3.03};
17 # data = TFile.Open("data2.9pb_fullSetOfVars.root");
18
19 data = TFile.Open("Run_1091pb_PFElectron_PF2PATJets_PFMET.root");
20 ttbar = TFile.Open("TT_Tune_1091pb_PFElectron_PF2PATJets_PFMET.root");
21 wjets = TFile.Open("WToENu_1091pb_PFElectron_PF2PATJets_PFMET.root");
22 # zjets = TFile.Open("DYJets_35.9pb_PFElectron_PF2PATJets_PFMET.root");
23 bce1 = TFile.Open("QCD_Pt-20to30_BCtoE_1091pb_PFElectron_PF2PATJets_PFMET.root");
24 bce2 = TFile.Open("QCD_Pt-30to80_BCtoE_1091pb_PFElectron_PF2PATJets_PFMET.root");
25 bce3 = TFile.Open("QCD_Pt-80to170_BCtoE_1091pb_PFElectron_PF2PATJets_PFMET.root");
26 # enri1 = TFile.Open("QCD_Pt-20to30_EMEnriched_35.9pb_PFElectron_PF2PATJets_PFMET.root");
27 # enri2 = TFile.Open("QCD_Pt-30to80_EMEnriched_35.9pb_PFElectron_PF2PATJets_PFMET.root");
28 # enri3 = TFile.Open("QCD_Pt-80to170_EMEnriched_35.9pb_PFElectron_PF2PATJets_PFMET.root");
29 # zjets = TFile.Open("DYJets_35.9pb_PFElectron_PF2PATJets_PFMET.root");
30 # Zprime500 = TFile.Open("Zprime_M500GeV_W50GeV_1091pb_PFElectron_PF2PATJets_PFMET.root");
31 # Zprime1500 = TFile.Open("Zprime_M1500GeV_W15GeV_1091pb_PFElectron_PF2PATJets_PFMET.root");
32 # Zprime750 = TFile.Open("Zprime_M750GeV_W7500MeV_35.9pb_PFElectron_PF2PATJets_PFMET.root");
33 # Zprime1000 = TFile.Open("Zprime_M1000GeV_W10GeV_35.9pb_PFElectron_PF2PATJets_PFMET.root");
34 # Zprime2000 = TFile.Open("Zprime_M2000GeV_W20GeV_35.9pb_PFElectron_PF2PATJets_PFMET.root");
35 # Zprime4000 = TFile.Open("Zprime_M4000GeV_W400GeV_1091pb_PFElectron_PF2PATJets_PFMET.root");
36 # Tprime300 = TFile.Open("TprimeToWb_M300_35.9pb_PFElectron_PF2PATJets_PFMET.root");
37 # Tprime350 = TFile.Open("TprimeToWb_M350_35.9pb_PFElectron_PF2PATJets_PFMET.root");
38 WprimeTToTTD_M1000 = TFile.Open("WprimeTToTTD_M1000_1091pb_PFElectron_PF2PATJets_PFMET.root");
39 WprimeTToTTD_M600 = TFile.Open("WprimeTToTTD_M600_1091pb_PFElectron_PF2PATJets_PFMET.root");
40 WprimeToTTBbar_M1000 = TFile.Open("WprimeToTBbar_M-1000_1091pb_PFElectron_PF2PATJets_PFMET.root");
41
42 # pj1 = TFile.Open("pj1_36.145pb_PFElectron_PF2PATJets_PFMET.root");
43 # pj2 = TFile.Open("pj2_36.145pb_PFElectron_PF2PATJets_PFMET.root");
44 # pj3 = TFile.Open("pj3_36.145pb_PFElectron_PF2PATJets_PFMET.root");
45 # tW = TFile.Open("tW_36.145pb_PFElectron_PF2PATJets_PFMET.root");
46 # tchan = TFile.Open("tchan_36.145pb_PFElectron_PF2PATJets_PFMET.root");
47 # vqq = TFile.Open("vqq_7.22pb_V4PFCalo.root__fullSetOfVars.root");
48 # Zprime1250 = TFile.Open("/storage/workspace/BristolAnalysisTools/outputfiles/Zprime_M1250GeV_W12500MeV_36.135pb.root");
49 # Zprime1500 = TFile.Open("/storage/workspace/BristolAnalysisTools/outputfiles/Zprime_M1500GeV_W15GeV_36.135pb.root");
50
51 hists = [];
52 # hists.append('mttbar_QCDEnriched')
53 # hists.append('mttbar_conversions')
54 # hists.append('mttbar_conversions_withMETCut')
55 # hists.append('mttbar_conversions_withMETAndAsymJets')
56 # hists.append('mttbar_conversions_withAsymJetsCut')
57 # hists.append('mttbar_controlRegion')
58 # hists.append("jet12vsjet13");
59 # hists.append("jet12vsjet23");
60 # hists.append("jet13vsjet23");
61 # hists.append("mttbar");
62 # hists.append("tPrimeMass");
63 # hists.append("tPrimepT");
64 # hists.append("tPrimeHT");
65 # hists.append("tPrime_pt");
66 # hists.append("tPrime_px");
67 # hists.append("tPrime_py");
68 # hists.append("tPrime_pz");
69 # hists.append("mLeptonicTopLone");
70 hists.append("mLepTopLoneNM");
71 # hists.append("mHadTopLoneNM");
72 # hists.append("mHadronicTopLone");
73 # hists.append("chiHadronicTop");
74 # hists.append("chiLeptonicTop");
75 # hists.append("chiGlobal");
76 # hists.append("chiTotal");
77 # hists.append("lepTopDeltaR");
78 # hists.append("hadTopDeltaR");
79 # hists.append("lepTopLep");
80 # hists.append("hadTopHad");
81 # hists.append("numHadTopMCMatches");
82 # hists.append("numLepTopMCMatches");
83 # hists.append("numHadTopCorrectID");
84 # hists.append("numLepTopCorrectID");
85 # hists.append("mttbar_2ndSolution");
86 # hists.append("mttbar_3rdSolution");
87 # hists.append("mttbar_allSolutions");
88 ##
89 # hists.append("mttbar_withMETCut");
90 # hists.append("mttbar_2ndSolution_withMETCut");
91 # hists.append("mttbar_3rdSolution_withMETCut");
92 # hists.append("mttbar_allSolutions_withMETCut");
93 #
94 # hists.append("mttbar_withMETAndAsymJets");
95 # hists.append("mttbar_2ndSolution_withMETAndAsymJets");
96 # hists.append("mttbar_3rdSolution_withMETAndAsymJets");
97 # hists.append("mttbar_allSolutions_withMETAndAsymJets");
98 #
99 # hists.append("mttbar_withAsymJetsCut");
100 # hists.append("mttbar_2ndSolution_withAsymJetsCut");
101 # hists.append("mttbar_3rdSolution_withAsymJetsCut");
102 # hists.append("mttbar_allSolutions_withAsymJetsCut");
103 #
104 # hists.append("ttbar_pt");
105 # hists.append("ttbar_pt_2ndSolution");
106 # hists.append("ttbar_pt_3rdSolution");
107 # hists.append("ttbar_pt_allSolutions");
108 #
109 # hists.append("ttbar_pt_withMETCut");
110 # hists.append("ttbar_pt_2ndSolution_withMETCut");
111 # hists.append("ttbar_pt_3rdSolution_withMETCut");
112 # hists.append("ttbar_pt_allSolutions_withMETCut");
113 #
114 # hists.append("ttbar_pt_withMETAndAsymJets");
115 # hists.append("ttbar_pt_2ndSolution_withMETAndAsymJets");
116 # hists.append("ttbar_pt_3rdSolution_withMETAndAsymJets");
117 # hists.append("ttbar_pt_allSolutions_withMETAndAsymJets");
118 #
119 # hists.append("ttbar_pt_withAsymJetsCut");
120 # hists.append("ttbar_pt_2ndSolution_withAsymJetsCut");
121 # hists.append("ttbar_pt_3rdSolution_withAsymJetsCut");
122 # # hists.append("ttbar_pt_allSolutions_withAsymJetsCut");
123 # hists.append("angleTops");
124 # hists.append("angleTops_withMETCut");
125 # hists.append("angleTops_withMETAndAsymJets");
126 # hists.append("angleTops_withAsymJetsCut");
127 #
128 # hists.append("pt_leadingTop");
129 hists.append("pt_loneLepTop");
130 # hists.append("pt_loneHadTop");
131 # hists.append("pt_leadingTop_withMETCut");
132 # hists.append("pt_leadingTop_withMETAndAsymJets");
133 # hists.append("pt_leadingTop_withAsymJetsCut");
134 #
135 # hists.append("pt_NextToLeadingTop");
136 # hists.append("pt_NextToLeadingTop_withMETCut");
137 # hists.append("pt_NextToLeadingTop_withMETAndAsymJets");
138 # hists.append("pt_NextToLeadingTop_withAsymJetsCut");
139 #
140 # hists.append("mLeptonicTop");
141 # hists.append("mHadronicTop");
142 # hists.append("mAllTop");
143 #
144 # hists.append("ttbar_px");
145 # hists.append("ttbar_py");
146 # hists.append("ttbar_pz");
147 #
148 # hists.append("m3");
149 # hists.append("HT");
150 hists.append("HT_ltop");
151 # hists.append("qkjet_eta");
152 # hists.append("qkjet_rapid");
153 # hists.append("leadjet_rap");
154 # hists.append("lepb_angle");
155 # hists.append("MET");
156 hists.append("MET_ltop");
157 # hists.append("METtopangle_ltop");
158 hists.append("METpt_ltop");
159 hists.append("HT3jet_ltop");
160 hists.append("HT4jet_ltop");
161 hists.append("mass4jets");
162 hists.append("ST_ltop");
163 # hists.append("leadingJetMass");
164 # hists.append("mtW");
165 # hists.append("neutrino_pz");
166 suffixes = ["0orMoreBtag",
167 "1orMoreBtag",
168 "2orMoreBtags",
169 "3orMoreBtags",'4orMoreBtags' ]
170 hists = [hist + '_' + suffix for hist in hists for suffix in suffixes]
171
172 # jetBinned = ["allJets",
173 # "1orMoreJets",
174 # "2orMoreJets",
175 # "3orMoreJets" , "4orMoreJets"]
176 # jetBinnedhists = []
177 # jetBinnedhists.append("QCDest_CombRelIso")
178 # jetBinnedhists.append("QCDest_CombRelIso_1btag")
179 # jetBinnedhists.append("QCDest_CombRelIso_2btag")
180 # jetBinnedhists.append("QCDest_CombRelIso_controlRegion")
181 # jetBinnedhists.append("QCDest_CombRelIso_controlRegion_1btag")
182 # jetBinnedhists.append("QCDest_CombRelIso_controlRegion_2btag")
183 #
184 # jetBinnedhists.append("QCDest_PFIsolation")
185 # jetBinnedhists.append("QCDest_PFIsolation_WithMETCut")
186 # jetBinnedhists.append("QCDest_PFIsolation_WithMETCutAndAsymJetCuts")
187 # jetBinnedhists.append("QCDest_PFIsolation_WithAsymJetCuts")
188
189 # jetBinnedhists.append("QCDest_PFIsolation_1btag")
190 # jetBinnedhists.append("QCDest_PFIsolation_2btag")
191 # jetBinnedhists.append("QCDest_PFIsolation_controlRegion")
192 # jetBinnedhists.append("QCDest_PFIsolation_controlRegion_1btag")
193 # jetBinnedhists.append("QCDest_PFIsolation_controlRegion_2btag")
194 # jetBinnedhists.append("QCDest_PFIsolation_controlRegion2")
195 # jetBinnedhists.append("QCDest_PFIsolation_controlRegion2_WithMETCut")
196 # jetBinnedhists.append("QCDest_PFIsolation_controlRegion2_WithMETCutAndAsymJetCuts")
197 # jetBinnedhists.append("QCDest_PFIsolation_controlRegion2_WithAsymJetCuts")
198 # jetBinnedhists.append("QCDest_PFIsolation_controlRegion2_1btag")
199 # jetBinnedhists.append("QCDest_PFIsolation_controlRegion2_2btag")
200
201 # jetBinnedhists = [hist + '_' + suffix for hist in jetBinnedhists for suffix in jetBinned]
202 # hists.extend(jetBinnedhists)
203 gcd = gROOT.cd
204
205 for histname in hists:
206 currentSelection = 'default'
207 if 'withMETAndAsymJets' in histname:
208 currentSelection = 'withMETAndAsymJets'
209 gcd()
210 print histname
211 hist_data = data.Get(histname);
212
213 # hist_data2;
214 # if (histname == "mttbar_rebinned")
215 # hist_data2 = data2.Get(histname);
216 # else
217 # hist_data2 = TH1F(*hist_data);
218 # hist_data.Sumw2();
219 # hist_data2.Sumw2();
220 hist_ttbar = ttbar.Get(histname);
221 hist_wjets = wjets.Get(histname);
222 # hist_zjets = zjets.Get(histname);
223
224 hist_bce1 = bce1.Get(histname);
225 hist_bce2 = bce2.Get(histname);
226 hist_bce3 = bce3.Get(histname);
227 # hist_enri1 = enri1.Get(histname);
228 # hist_enri2 = enri2.Get(histname);
229 # hist_enri3 = enri3.Get(histname);
230 # # hist_pj1 = pj1.Get(histname);
231 # # hist_pj2 = pj2.Get(histname);
232 # hist_pj3 = pj3.Get(histname);
233 # hist_singleTop = tW.Get(histname)
234 # hist_singleTop.Add(tchan.Get(histname))
235
236 # hist_Zprime500 = Zprime500.Get(histname);
237 # hist_Zprime750 = Zprime750.Get(histname);
238 # hist_Zprime1000 = Zprime1000.Get(histname);
239 # hist_Zprime1500 = Zprime1500.Get(histname);
240 # hist_Zprime2000 = Zprime2000.Get(histname);
241 # hist_Zprime4000 = Zprime4000.Get(histname);
242 # hist_Tprime300 = Tprime300.Get(histname);
243 # hist_Tprime350 = Tprime350.Get(histname);
244 # # hist_Zprime1250 = Zprime1250.Get(histname);
245 hist_wpm1000 = WprimeTToTTD_M1000.Get(histname);
246 hist_wpm600 = WprimeTToTTD_M600.Get(histname);
247 hist_wptb1000 = WprimeToTTBbar_M1000.Get(histname);
248
249 hist_ttbar.Scale(scale);
250 hist_wjets.Scale(scale);
251 # hist_zjets.Scale(scale);
252
253 hist_bce1.Scale(scale);
254 hist_bce2.Scale(scale);
255 hist_bce3.Scale(scale);
256
257 # hist_enri1.Scale(scale);
258 # hist_enri2.Scale(scale);
259 # hist_enri3.Scale(scale);
260
261 # hist_pj1.Scale(scale);
262 # hist_pj2.Scale(scale);
263 # hist_pj3.Scale(scale);
264
265 # scale = scale * 10.0;
266 # hist_Zprime500.Scale(scale);
267 # hist_Zprime750.Scale(scale);
268 # hist_Zprime1000.Scale(scale);
269 # hist_Zprime2000.Scale(scale);
270 # hist_Zprime1500.Scale(scale);
271 # hist_Zprime4000.Scale(scale);
272 # hist_Tprime300.Scale(scale);
273 # hist_Tprime350.Scale(scale);
274 # hist_Zprime1250.Scale(scale);
275 hist_wpm1000.Scale(scale);
276 hist_wpm600.Scale(scale);
277 hist_wptb1000.Scale(scale);
278
279 hist_qcd = hist_bce1.Clone("qcd")#TH1F(*hist_bce1);
280 hist_qcd.Add(hist_bce2);
281 hist_qcd.Add(hist_bce3);
282 # hist_qcd.Add(hist_enri1);
283 # hist_qcd.Add(hist_enri2);
284 # hist_qcd.Add(hist_enri3);
285 # hist_qcd.Add(hist_pj1);
286 # hist_qcd.Add(hist_pj2);
287 # hist_qcd.Add(hist_pj3);
288 hist_qcd.Scale(qcdScale[currentSelection]);
289 # ndata = hist_data.Integral();
290 # ntop = hist_ttbar.Integral();
291 # nwj = hist_wjets.Integral();
292 # nzj = hist_zjets.Integral();
293 nqcd = hist_qcd.Integral();
294 # sumMC = ntop + nwj + nzj + nqcd;
295 # cout << ndata << " " << sumMC << endl;
296 # hist_wjets.Scale(ndata / sumMC);
297 # hist_ttbar.Scale(ndata / sumMC);
298 # hist_zjets.Scale(ndata / sumMC);
299 # hist_qcd.Scale(ndata / sumMC);
300 # mttbars = ['mttbar_' + suffix for suffix in suffixes]
301 # mttbars2 = ['mttbar_withMETAndAsymJets_' + suffix for suffix in suffixes]
302 # if histname in mttbars or histname in mttbars2:
303 # print "taking QCD shape from DATA"
304 # name = histname.replace('mttbar', 'mttbar_conversions')
305 # hist_qcd = data.Get(name)
306 # if( hist_qcd.Integral() > 0):
307 # hist_qcd.Scale(nqcd/hist_qcd.Integral())
308 hist_mc = hist_qcd.Clone("all_mc")
309 # hist_mc = hist_ttbar.Clone("all_mc")
310 hist_mc.Add(hist_ttbar);
311 # hist_mc.Add(hist_zjets);
312 hist_mc.Add(hist_wjets);
313 # hist_mc.Add(hist_singleTop);
314
315 rebin = 1;
316 Urange = (0,5000)
317 if ("mttbar" in histname):
318 hist_data.SetXTitle("M_{t#bar{t}}/GeV");
319 hist_data.SetYTitle("Events/(100 GeV)");
320 rebin = 100;
321 Urange = (0, 2200)
322 elif ("tPrimeMass" in histname):
323 hist_data.SetXTitle("T' mass/GeV");
324 hist_data.SetYTitle("Events/(100 GeV)");
325 rebin = 200;
326 Urange = (0, 2000)
327 elif ("jet12" in histname or "jet13" in histname):
328 hist_data.SetXTitle("Jet mass/GeV");
329 hist_data.SetYTitle("Jet mass/GeV)");
330 elif ("tPrimepT" in histname):
331 hist_data.SetXTitle("T' pT/GeV");
332 hist_data.SetYTitle("Events/(8 GeV)");
333 rebin = 8;
334 Urange = (0, 200)
335 elif ("tPrimeHT" in histname):
336 hist_data.SetXTitle("T' HT");
337 hist_data.SetYTitle("Events");
338 rebin = 4;
339 Urange = (0, 1.5)
340 elif ("m3" in histname):
341 hist_data.SetXTitle("M3/GeV");
342 hist_data.SetYTitle("Events/(50 GeV)");
343 rebin = 50;
344 Urange = (0, 1500)
345 elif (histname == "electron_et"):
346 hist_data.SetXTitle("electron p_{T}/GeV");
347 hist_data.SetYTitle("Events/(5 GeV)");
348 rebin = 5;
349 elif ("ttbar_pt" in histname):
350 hist_data.SetXTitle("p_{T} of t#bar{t} system/GeV");
351 hist_data.SetYTitle("Events/(10 GeV)");
352 rebin = 10;
353 Urange = (0, 500)
354 elif ("ttbar_px" in histname):
355 hist_data.SetXTitle("p_{x} of t#bar{t} system/GeV");
356 hist_data.SetYTitle("Events/(10 GeV)");
357 rebin = 10;
358 Urange = (0, 500)
359 elif ("ttbar_py" in histname):
360 hist_data.SetXTitle("p_{y} of t#bar{t} system/GeV");
361 hist_data.SetYTitle("Events/(10 GeV)");
362 rebin = 10;
363 Urange = (0, 500)
364 elif ("ttbar_pz" in histname):
365 hist_data.SetXTitle("p_{z} of t#bar{t} system/GeV");
366 hist_data.SetYTitle("Events/(50 GeV)");
367 rebin = 50;
368 Urange = (0, 2000)
369 elif ("METpt_ltop" in histname):
370 hist_data.SetXTitle("MET p_{T}/GeV");
371 hist_data.SetYTitle("Events/(10 GeV)");
372 rebin = 10;
373 Urange = (0, 400)
374 elif ("tPrime_pt" in histname):
375 hist_data.SetXTitle("p_{T} of T' system/GeV");
376 hist_data.SetYTitle("Events/(20 GeV)");
377 rebin = 20;
378 Urange = (0, 200)
379 elif ("tPrime_px" in histname):
380 hist_data.SetXTitle("p_{x} of T' system/GeV");
381 hist_data.SetYTitle("Events/(20 GeV)");
382 rebin = 20;
383 Urange = (0, 200)
384 elif ("tPrime_py" in histname):
385 hist_data.SetXTitle("p_{y} of T' system/GeV");
386 hist_data.SetYTitle("Events/(20 GeV)");
387 rebin = 20;
388 Urange = (0, 200)
389 elif ("tPrime_pz" in histname):
390 hist_data.SetXTitle("p_{z} of T' system/GeV");
391 hist_data.SetYTitle("Events/(100 GeV)");
392 rebin = 200;
393 Urange = (0, 1800)
394 elif ("HT_" in histname):
395 hist_data.SetXTitle("#Sigma p_{T}/GeV");
396 hist_data.SetYTitle("Events/(50 GeV)");
397 rebin = 50;
398 Urange = (0, 2000)
399 elif ("ST" in histname):
400 hist_data.SetXTitle("ST/GeV");
401 hist_data.SetYTitle("Events/(50 GeV)");
402 rebin = 50;
403 Urange = (0, 1000)
404 elif ("HT3jet_ltop" in histname):
405 hist_data.SetXTitle("#Sigma p_{T} of leading 3 jets/GeV");
406 hist_data.SetYTitle("Events/(50 GeV)");
407 rebin = 50;
408 Urange = (0, 1000)
409 elif ("HT4jet_ltop" in histname):
410 hist_data.SetXTitle("#Sigma p_{T} of leading 4 jets/GeV");
411 hist_data.SetYTitle("Events/(50 GeV)");
412 rebin = 50;
413 Urange = (0, 1200)
414 elif (histname == "numberOfJets"):
415 hist_data.SetXTitle("number of jets");
416 hist_data.SetYTitle("Events");
417 elif (histname == "numberOfBJets"):
418 hist_data.SetXTitle("number of b-tagged jets (SSVHE medium)");
419 hist_data.SetYTitle("Events");
420 elif ('MET_' in histname and 'MET_ltop' not in histname):
421 hist_data.SetXTitle("MET/GeV");
422 hist_data.SetYTitle("Events/(10 GeV)");
423 rebin = 2;
424 Urange = (0, 400)
425 elif ('MET_ltop' in histname):
426 hist_data.SetXTitle("MET/GeV");
427 hist_data.SetYTitle("Events/(10 GeV)");
428 rebin = 20;
429 Urange = (0, 400)
430 elif ("leadingJetMass" in histname):
431 hist_data.SetXTitle("leading jet mass/GeV");
432 hist_data.SetYTitle("Events/(5 GeV)");
433 rebin = 5;
434 Urange = (0, 150)
435 elif ("mtW" in histname):
436 hist_data.SetXTitle("transverse W-boson mass/GeV");
437 hist_data.SetYTitle("Events/(10 GeV)");
438 rebin = 10;
439 elif ("electronD0" in histname):
440 hist_data.SetXTitle("electron d_{0} / cm");
441 hist_data.SetYTitle("Events/(0.001 cm)");
442 rebin = 10;
443 elif ("angleTops" in histname):
444 hist_data.SetXTitle("angle between top quarks");
445 hist_data.SetYTitle("Events/(0.1 rad)");
446 rebin = 10;
447 elif ("lepb_angle" in histname):
448 hist_data.SetXTitle("angle between electron and b jet");
449 hist_data.SetYTitle("Events/(0.1 rad)");
450 rebin = 10;
451 elif ("METtopangle_ltop" in histname):
452 hist_data.SetXTitle("angle between MET and top p_{T}");
453 hist_data.SetYTitle("Events/(0.1 rad)");
454 rebin = 10;
455 Urange = (-2, 2)
456 elif ("qkjet_eta" in histname):
457 hist_data.SetXTitle("#eta of b jet");
458 hist_data.SetYTitle("Events/(0.1 rad)");
459 Urange = (-3, 3)
460 rebin = 10;
461 elif ("_rap" in histname):
462 hist_data.SetXTitle("Jet Rapidity");
463 hist_data.SetYTitle("Events/(0.1 rad)");
464 Urange = (-3, 3)
465 rebin = 20;
466 elif ("neutrino_pz" in histname):
467 hist_data.SetXTitle("neutrino p_{Z} /GeV");
468 hist_data.SetYTitle("Events/(20 GeV)");
469 rebin = 20;
470 Urange = (-500, 500)
471 elif ('mHadronicTopLone' in histname or 'mHadTopLoneNM' in histname):
472 hist_data.SetXTitle("top mass /GeV");
473 hist_data.SetYTitle("Events/(25 GeV)");
474 rebin = 25;
475 Urange = (0, 300)
476 elif ('mass4jets' in histname):
477 hist_data.SetXTitle("4-jet mass /GeV");
478 hist_data.SetYTitle("Events/(60 GeV)");
479 rebin = 60;
480 Urange = (0, 1500)
481 elif ('mLeptonicTopLone' in histname or 'mLepTopLoneNM' in histname):
482 hist_data.SetXTitle("top mass /GeV");
483 hist_data.SetYTitle("Events/(50 GeV)");
484 rebin = 25;
485 Urange = (0, 700)
486 elif ('chiHadronicTop' in histname or 'chiLeptonicTop' in histname):
487 hist_data.SetXTitle("top #chi^{2} /GeV");
488 hist_data.SetYTitle("Events/(1)");
489 rebin = 1;
490 Urange = (0, 30)
491 elif ('chiGlobal' in histname or 'chiTotal' in histname):
492 hist_data.SetXTitle("Event #chi^{2} /GeV");
493 hist_data.SetYTitle("Events/(100)");
494 rebin = 100;
495 elif ('numHadTopMCMatches' in histname or 'numLepTopMCMatches' in histname):
496 hist_data.SetXTitle("Number of MC-Truth Matches");
497 hist_data.SetYTitle("Events");
498 elif ('numHadTopCorrectID' in histname or 'numLepTopCorrectID' in histname):
499 hist_data.SetXTitle("Number of Reco Candidates Matched to MC-Truth Particles");
500 hist_data.SetYTitle("Events");
501 elif ('lepTopDeltaR' in histname or 'hadTopDeltaR' in histname):
502 hist_data.SetXTitle("#Delta R of MC truth top");
503 hist_data.SetYTitle("Events");
504 rebin = 2;
505 elif ('lepTopLep' in histname or 'hadTopHad' in histname):
506 hist_data.SetXTitle("top MC truth identity");
507 hist_data.SetYTitle("Events");
508 Urange = (0, 2)
509 elif ('mHadronicTop' in histname or 'mAllTop' in histname or 'mLeptonicTop' in histname):
510 hist_data.SetXTitle("top mass /GeV");
511 hist_data.SetYTitle("Events/(50 GeV)");
512 rebin = 50;
513 elif ('pt_leadingTop' in histname or 'pt_NextToLeadingTop' in histname or 'pt_loneLepTop' in histname
514 or 'pt_loneHadTop' in histname):
515 hist_data.SetXTitle("top p_{T} /GeV");
516 hist_data.SetYTitle("Events/(40 GeV)");
517 rebin = 40;
518 Urange = (0, 500)
519 elif('QCDest_CombRelIso' in histname):
520 hist_data.SetXTitle("relative isolation");
521 hist_data.SetYTitle("Events/(0.1)");
522 rebin = 10;
523 Urange = (0, 2)
524 elif('QCDest_PFIsolation' in histname):
525 hist_data.SetXTitle("ParticleFlow isolation");
526 hist_data.SetYTitle("Events/(0.1)");
527 rebin = 10
528 Urange = (0, 2)
529
530
531 hist_data.SetTitleOffset(1.3, "Y");
532 if ('jet1' in histname):
533 hist_data.Rebin2D();
534 hist_ttbar.Rebin2D();
535 hist_Tprime300.Rebin2D();
536 hist_Tprime350.Rebin2D();
537 hist_data.SetAxisRange(0, 600, "X");
538 hist_data.SetAxisRange(0, 600, "Y");
539 hist_ttbar.SetAxisRange(0, 600, "X");
540 hist_ttbar.SetAxisRange(0, 600, "Y");
541 # hist_Tprime300.SetAxisRange(0, 600, "X");
542 # hist_Tprime300.SetAxisRange(0, 600, "Y");
543 # hist_Tprime350.SetAxisRange(0, 600, "X");
544 # hist_Tprime350.SetAxisRange(0, 600, "Y");
545 else:
546 hist_data.Rebin(rebin);
547 hist_ttbar.Rebin(rebin);
548 hist_wjets.Rebin(rebin);
549 # hist_zjets.Rebin(rebin);
550 hist_qcd.Rebin(rebin);
551 # hist_Zprime500.Rebin(rebin);
552 # hist_Zprime1500.Rebin(rebin);
553 # hist_Zprime750.Rebin(rebin);
554 # hist_Zprime1000.Rebin(rebin);
555 # hist_Zprime2000.Rebin(rebin);
556 # hist_Zprime4000.Rebin(rebin);
557 # hist_Tprime300.Rebin(rebin);
558 # hist_Tprime350.Rebin(rebin);
559 # hist_singleTop.Rebin(rebin)
560 hist_wpm1000.Rebin(rebin);
561 hist_wpm600.Rebin(rebin);
562 hist_wptb1000.Rebin(rebin);
563
564 hist_data.SetAxisRange(Urange[0], Urange[1]);
565 hist_ttbar.SetAxisRange(Urange[0], Urange[1]);
566 hist_wjets.SetAxisRange(Urange[0], Urange[1]);
567 # hist_zjets.SetAxisRange(Urange[0], Urange[1]);
568 hist_qcd.SetAxisRange(Urange[0], Urange[1]);
569 # hist_Zprime500.SetAxisRange(Urange[0], Urange[1]);
570 # hist_Zprime750.SetAxisRange(Urange[0], Urange[1]);
571 # hist_Zprime1000.SetAxisRange(Urange[0], Urange[1]);
572 # hist_Zprime1500.SetAxisRange(Urange[0], Urange[1]);
573 # hist_Zprime2000.SetAxisRange(Urange[0], Urange[1]);
574 # hist_Zprime4000.SetAxisRange(Urange[0], Urange[1]);
575 # hist_Tprime300.SetAxisRange(Urange[0], Urange[1]);
576 # hist_Tprime350.SetAxisRange(Urange[0], Urange[1]);
577 # hist_singleTop.SetAxisRange(Urange[0], Urange[1]);
578 hist_wpm1000.SetAxisRange(Urange[0], Urange[1]);
579 hist_wpm600.SetAxisRange(Urange[0], Urange[1]);
580 hist_wptb1000.SetAxisRange(Urange[0], Urange[1]);
581
582 hist_data.SetMarkerStyle(8);
583 hist_data.SetMarkerSize(1.5);
584
585 hist_ttbar.SetFillStyle(1001);
586 hist_ttbar.SetFillColor(kRed);
587 hist_wjets.SetFillStyle(1001);
588 hist_wjets.SetFillColor(4);
589 # hist_zjets.SetFillStyle(1001);
590 # hist_zjets.SetFillColor(8);
591 hist_qcd.SetFillStyle(1001);
592 hist_qcd.SetFillColor(kYellow);
593 hist_qcd.SetFillColor(12);
594 # hist_singleTop.SetFillStyle(1001);
595 # hist_singleTop.SetFillColor(kMagenta)
596 # nbins = hist_qcd.GetXaxis().GetNbins();
597 # binwidth = (hist_qcd.GetXaxis().GetXmax() - hist_qcd.GetXaxis().GetXmin()) / nbins;
598 # for i in range(1, nbins + 1):
599 # yvalue = hist_qcd.GetBinContent(i);
600 # # float xvalue = hist_qcd.GetBinCenter(i);
601 # # float ymin = yvalue - yvalue*0.5;
602 # # float ymax = yvalue + yvalue*0.5;
603 # # float xmin = xvalue - 0.5*binwidth;
604 # # float xmax = xvalue + 0.5*binwidth;
605 # error = yvalue * 0.5;
606 # hist_mc.SetBinError(i, error);
607 # # qcdUncert.SetPointError(i, xmin, xmax, ymin, ymax);
608 #
609 # qcdUncert = TGraphAsymmErrors(hist_mc);
610
611 linewidth = 6;
612 # hist_Zprime500.SetLineColor(6);
613 # hist_Zprime500.SetLineWidth(linewidth);
614 # hist_Zprime500.SetFillStyle(0);
615 # hist_Zprime500.SetFillColor(kWhite);
616
617 # hist_Zprime750.SetLineColor(5);
618 # hist_Zprime750.SetLineWidth(linewidth);
619 # hist_Zprime750.SetFillStyle(0);
620 # hist_Zprime750.SetFillColor(kWhite);
621
622 # hist_Zprime1000.SetLineColor(7);
623 # hist_Zprime1000.SetLineWidth(linewidth);
624 # hist_Zprime1000.SetFillStyle(0);
625 # hist_Zprime1000.SetFillColor(kWhite);
626 # hist_Zprime2000.SetLineColor(42);
627 # hist_Zprime2000.SetLineWidth(linewidth);
628 # hist_Zprime2000.SetFillStyle(0);
629 # hist_Zprime2000.SetFillColor(kWhite);
630 # # hist_Zprime4000.SetLineColor(50);
631 # hist_Zprime4000.SetLineWidth(linewidth);
632 # hist_Zprime4000.SetFillStyle(0);
633 # hist_Zprime4000.SetFillColor(kWhite);
634
635 # hist_Tprime300.SetLineColor(kOrange + 1);
636 # hist_Tprime300.SetLineWidth(linewidth);
637 # hist_Tprime350.SetLineColor(kGray + 3);
638 # hist_Tprime350.SetLineWidth(linewidth);
639 #
640 # hist_Zprime1250.SetLineColor(kCyan - 5);
641 # hist_Zprime1250.SetLineWidth(linewidth);
642 # hist_Zprime1250.SetFillStyle(0);
643 # hist_Zprime1250.SetFillColor(kWhite);
644 #
645 # hist_Zprime1500.SetLineColor(42);
646 # hist_Zprime1500.SetLineWidth(linewidth);
647 # hist_Zprime1500.SetFillStyle(0);
648 # hist_Zprime1500.SetFillColor(kWhite);
649
650 hist_wpm1000.SetLineColor(kOrange + 1);
651 hist_wpm1000.SetLineWidth(linewidth);
652 hist_wpm600.SetLineColor(kGray + 3);
653 hist_wpm600.SetLineWidth(linewidth);
654 hist_wptb1000.SetLineColor(kCyan);
655 hist_wptb1000.SetLineWidth(linewidth);
656
657 # qcdUncert.SetFillColor(kGray + 3);
658 # qcdUncert.SetFillStyle(3003);
659
660 leg = TLegend(0.696, 0.35, 0.94, 0.92);
661 leg.SetBorderSize(0);
662 leg.SetLineStyle(0);
663 leg.SetTextFont(42);
664 leg.SetFillStyle(0);
665
666 leg.AddEntry(hist_data, "data", "P");
667 # leg.AddEntry(hist_data2, "data(no HLT)", "P");
668 leg.AddEntry(hist_ttbar, "t#bar{t}", "f");
669 leg.AddEntry(hist_wjets, "W#rightarrowl#nu", "f");
670 # leg.AddEntry(hist_zjets, "Z/#gamma*#rightarrowl^{+}l^{-}", "f");
671 leg.AddEntry(hist_qcd, "QCD", "F");
672 # leg.AddEntry(hist_qcd, "QCD/#gamma + jets");
673 # leg.AddEntry(hist_singleTop, "Single-Top")
674 # leg.AddEntry(hist_Zprime500, "Z' 0.5TeV (50 pb)", "L");
675 # leg.AddEntry(hist_Zprime750, "Z' 0.75TeV", "L");
676 # leg.AddEntry(hist_Zprime1000, "Z' 1TeV", "L");
677 # leg.AddEntry(hist_Zprime1500, "Z' 1.5TeV (50 pb)", "L");
678 # leg.AddEntry(hist_Zprime2000, "Z' 2TeV", "L");
679 # leg.AddEntry(hist_Zprime4000, "Z' 4TeV (50 pb)", "L");
680 # leg.AddEntry(hist_Tprime300, "T' 300GeV", "L");
681 # leg.AddEntry(hist_Tprime350, "T' 350GeV", "L");
682 # leg.AddEntry(hist_Zprime1250, "Z' 1.25TeV");
683 leg.AddEntry(hist_wpm600, "W't 600GeV (8 pb)", "L");
684 leg.AddEntry(hist_wpm1000, "W't 1TeV (0.72 pb)", "L");
685 leg.AddEntry(hist_wptb1000, "W'-> tb 1TeV (8 pb)", "L");
686
687
688 canvases.append(TCanvas("cname" + histname, histname, 1200, 900))
689 canvases[-1].cd().SetRightMargin(0.04);
690 if ('jet1' in histname):
691 hist_data.SetMarkerStyle(8);
692 hist_ttbar.SetMarkerStyle(21);
693 hist_ttbar.SetMarkerColor(kRed);
694 hist_Tprime300.SetMarkerColor(kOrange + 1);
695 hist_Tprime300.SetMarkerStyle(22);
696 hist_Tprime350.SetMarkerColor(kGray + 3);
697 hist_Tprime350.SetMarkerStyle(3);
698 else:
699 hs = THStack("MC", "MC");
700 hs.Add(hist_qcd);
701 # hs.Add(hist_zjets);
702 hs.Add(hist_wjets);
703 # hs.Add(hist_singleTop);
704 hs.Add(hist_ttbar);
705 max = 0
706 if hs.GetMaximum() > hist_data.GetMaximum():
707 max = hs.GetMaximum()*1.1
708 else:
709 max = hist_data.GetMaximum()*1.1
710
711 hist_data.GetYaxis().SetRangeUser(0, max);
712 hist_data.SetStats(1);
713 hist_data.Draw('error');
714 hist_data.SetMarkerStyle(8);
715 if ('jet1' in histname):
716 hist_ttbar.Draw("same");
717 else:
718 hs.Draw("hist same");
719 # hist_Zprime500.Draw("same");
720 # hist_Zprime750.Draw("same");
721 # hist_Zprime1000.Draw("same");
722 # hist_Zprime2000.Draw("same");
723 # hist_Zprime4000.Draw("same");
724 # hist_Tprime300.Draw("same");
725 # hist_Tprime350.Draw("same");
726 # hist_Zprime1250.Draw("same");
727 # hist_Zprime1500.Draw("same");
728 hist_wpm1000.Draw("same");
729 hist_wpm600.Draw("same");
730 hist_wptb1000.Draw("same");
731 # qcdUncert.Draw("1 same");
732 # hist_data2.Draw("error same");
733 hist_data.Draw("error same");
734 leg.Draw();
735
736 text1 = TLatex(3.570061, 23.08044, "CMS Preliminary");
737 text1.SetNDC();
738 text1.SetTextAlign(13);
739 text1.SetX(0.38);
740 text1.SetY(0.928);
741 #text1.SetLineWidth(2);
742 text1.SetTextFont(42);
743 text1.SetTextSizePixels(24);# dflt=28
744 text1.Draw();
745
746 text2 = TLatex(3.570061, 23.08044, "~%.1f pb^{-1} at #sqrt{s} = 7 TeV" % lumi);
747 text2.SetNDC();
748 text2.SetTextAlign(13);
749 text2.SetX(0.38);
750 text2.SetY(0.88);
751 #text2.SetLineWidth(2);
752 text2.SetTextFont(42);
753 text2.SetTextSizePixels(24);# dflt=28
754 text2.Draw();
755 canvases[-1].SaveAs('plots/' + histname + '.png')
756 # canvases[-1].SaveAs('plots/' + histname + '.root')
757 # canvases[-1].SaveAs('/storage/results/' + histname + '.png')
758
759 # cu_hist_data = getCumulativePlot(hist_data, "data");
760 # cu_hist_ttbar = getCumulativePlot(hist_ttbar, "ttbar");
761 # cu_hist_wjets = getCumulativePlot(hist_wjets, "wjets");
762 # cu_hist_zjets = getCumulativePlot(hist_zjets, "zjets");
763 # cu_hist_qcd = getCumulativePlot(hist_qcd, "qcd");
764 # cu_hist_singleTop = getCumulativePlot(hist_singleTop, "singleTop");
765 # cu_hist_Zprime500 = getCumulativePlot(hist_Zprime500, "Zprime500");
766 # cu_hist_Zprime750 = getCumulativePlot(hist_Zprime750, "Zprime750");
767 # cu_hist_Zprime1000 = getCumulativePlot(hist_Zprime1000, "Zprime1000");
768 # cu_hist_Zprime2000 = getCumulativePlot(hist_Zprime2000, "Zprime2000");
769 # cu_hist_Zprime4000 = getCumulativePlot(hist_Zprime4000, "Zprime4000");
770 # cu_hist_Tprime300 = getCumulativePlot(hist_Tprime300, "Tprime300");
771 # cu_hist_Tprime350 = getCumulativePlot(hist_Tprime350, "Tprime350");
772 ## cu_hist_Zprime1250 = getCumulativePlot(hist_Zprime1250, "Zprime1250");
773 ## cu_hist_Zprime1500 = getCumulativePlot(hist_Zprime1500, "Zprime1500");
774 # cu_hist_data.SetYTitle("Integrated Events/(50 GeV)");
775 ##
776 #
777 # cu_hist_data.SetAxisRange(Urange[0], Urange[1]);
778 # cu_hist_ttbar.SetAxisRange(Urange[0], Urange[1]);
779 # cu_hist_wjets.SetAxisRange(Urange[0], Urange[1]);
780 # cu_hist_zjets.SetAxisRange(Urange[0], Urange[1]);
781 # cu_hist_qcd.SetAxisRange(Urange[0], Urange[1]);
782 # cu_hist_singleTop.SetAxisRange(Urange[0], Urange[1]);
783
784 # cu_hs = THStack("cu_MC", "cu_MC");
785 # cu_hs.Add(cu_hist_qcd);
786 # cu_hs.Add(cu_hist_zjets);
787 # cu_hs.Add(cu_hist_wjets);
788 # cu_hs.Add(cu_hist_ttbar);
789
790 # scanvases.append(TCanvas("cu_cname" + histname, histname + "(cu)", 1200, 900))
791 # scanvases[-1].cd().SetRightMargin(0.04);
792 # cu_hist_data.Draw("error");
793 # cu_hs.Draw("hist same");
794 # cu_hist_Zprime500.Draw("same");
795 # cu_hist_Zprime750.Draw("same");
796 # cu_hist_Zprime1000.Draw("same");
797 # cu_hist_Zprime2000.Draw("same");
798 # cu_hist_Zprime4000.Draw("same");
799 # cu_hist_Tprime300.Draw("same");
800 # cu_hist_Tprime350.Draw("same");
801 ### cu_hist_Zprime1250.Draw("same");
802 ### cu_hist_Zprime1500.Draw("same");
803 ## # cu_hist_data2.Draw("error same");
804 # cu_hist_data.Draw("error same");
805 # leg.Draw();
806 ##
807 # text1.Draw();
808 ##
809 # text2.Draw();
810 # scanvases[-1].SaveAs('/storage/results/' + histname + '_integrated.png')
811 # scanvases[-1].SaveAs('plots/' + histname + '_integrated.png')
812
813
814
815 # tdrGrid: Turns the grid lines on (true) or off (false)
816
817 #def tdrGrid(bool gridOn):
818 # tdrStyle.SetPadGridX(gridOn);
819 # tdrStyle.SetPadGridY(gridOn);
820 #
821
822 # fixOverlay: Redraws the axis
823
824 def fixOverlay():
825 gPad.RedrawAxis();
826
827
828 def getCumulativePlot(initial, type):
829 global counter
830 counter = counter + 1;
831 name = initial.GetName()
832 name = "cu_" + name + "_" + type + str(counter);
833 title = initial.GetTitle()
834 title = "cu_" + title + "_" + type;
835 xaxis = initial.GetXaxis().GetTitle();
836 yaxis = initial.GetYaxis().GetTitle();
837 nBins = initial.GetNbinsX();
838 cu = TH1F(name, title, nBins, initial.GetXaxis().GetXmin(), initial.GetXaxis().GetXmax());
839 for bin in range(1,nBins+1):
840 cu.SetBinContent(bin, initial.Integral(bin, nBins));
841
842 cu.SetFillStyle(initial.GetFillStyle());
843 cu.SetFillColor(initial.GetFillColor());
844 cu.SetLineColor(initial.GetLineColor());
845 cu.SetMarkerSize(initial.GetMarkerSize());
846 cu.SetMarkerStyle(initial.GetMarkerStyle());
847 cu.SetMarkerColor(initial.GetMarkerColor());
848 cu.SetLineWidth(initial.GetLineWidth());
849 cu.GetXaxis().SetTitle(xaxis);
850 cu.GetYaxis().SetTitle(yaxis);
851 return cu;
852
853 if __name__ == "__main__":
854 gROOT.SetBatch(True)
855 gROOT.ProcessLine('gErrorIgnoreLevel = 1001;')
856 plotMttbar()
857 # print "press enter to quit"
858 # a = raw_input()