ViewVC Help
View File | Revision Log | Show Annotations | Root Listing
root/cvsroot/UserCode/nowaf/RootFilesInUse/MakeErrPlots.py
Revision: 1.1.1.1 (vendor branch)
Committed: Tue Mar 20 13:12:08 2012 UTC (13 years, 1 month ago) by nowak
Content type: text/x-python
Branch: rootFilesInUse, MAIN
CVS Tags: start, HEAD
Changes since 1.1: +0 -0 lines
Log Message:
t files in use

File Contents

# Content
1 import ROOT
2 import sys, re
3 sys.path.append("/afs/naf.desy.de/user/n/nowaf/UserCode/nowaf/PythonScripts/")
4 import definitions as Def
5 import styles as Style
6 import FakeHelper as FH
7 from array import array
8
9 if __name__ == "__main__":
10
11
12 smooth = False
13 doDynamicRebin = True
14 dynamicRebin = 4
15
16 sampleList = []
17 #sampleList.append( "ZJets" )
18 sampleList.append( "WJets" )
19 sampleList.append( "TTbar" )
20 #sampleList.append( "QCDFlat" )
21 #sampleList.append( "Data" )
22 #sampleList.append( "Zinv" )
23 #sampleList.append( "WZJets" )
24
25 fileDict = {}
26 #fileDict[ "WJets" ] = "/scratch/hh/lustre/cms/user/nowaf/2011Data/VersionII/Plots/WJets_full_ii/WJets_full_ii.root"
27 #fileDict[ "QCDFlat" ] = "/scratch/hh/lustre/cms/user/nowaf/2011Data/VersionII/Plots/QCDFlat_cx/QCDFlat_cx.root"
28 fileDict[ "QCDFlat" ] = "/scratch/hh/lustre/cms/user/nowaf/2011Data/VersionII/Plots/QCDFlat_fakes_xxxiv/QCDFlat_fakes_xxxiv.root"
29 #fileDict[ "TTbar" ] = "/scratch/hh/lustre/cms/user/nowaf/2011Data/VersionII/Plots/RealTauEst/TTbar_cxxvi.root"
30 fileDict[ "TTbar" ] = "/scratch/hh/lustre/cms/user/nowaf/2011Data/VersionII/Plots/TTbar_full_ii/TTbar_full_ii.root"
31 #fileDict[ "TTbar" ] = "/scratch/hh/lustre/cms/user/nowaf/2011Data/VersionII/Plots/TTbar_TauTemplates_viii/TTbar_TauTemplate_viii.root"
32 fileDict[ "Data" ] = "/scratch/hh/lustre/cms/user/nowaf/2011Data/VersionII/Plots/Data_fakes_xxxiv/Data_fakes_xxxiv.root"
33 fileDict[ "Zinv" ] = "/scratch/hh/lustre/cms/user/nowaf/2011Data/VersionII/Plots/Zinv_fakes/Zinv_fakes_xxii.root"
34 fileDict[ "ZJets" ] = "/scratch/hh/lustre/cms/user/nowaf/2011Data/VersionII/Plots/ZJets_fakes_xxv/ZJets_fakes_xxv.root"
35 #fileDict[ "WJets" ] = "/scratch/hh/lustre/cms/user/nowaf/2011Data/VersionII/Plots/WJets_fakes_xxv/WJets_fakes_xxv.root"
36 fileDict[ "WZJets" ] = "/scratch/hh/lustre/cms/user/nowaf/2011Data/VersionII/Plots/WZJets_fakes_xxv/WZJets_fakes_xxv.root"
37 fileDict[ "WJets" ] = "/scratch/hh/lustre/cms/user/nowaf/2011Data/VersionII/Plots/RealTauEst/WJets_clxx.root"
38 fileDict[ "TTbar" ] = "/scratch/hh/lustre/cms/user/nowaf/2011Data/VersionII/Plots/RealTauEst/TTbar_clxx.root"
39
40 #fileName = "~/UserCode/nowaf/PythonScripts/2011/VersionII/" + "WJets" + "_HPS_eff_nVertex.root"
41 #fileName = "~/UserCode/nowaf/PythonScripts/2011/VersionII/" + "QCDFlat" + "_fakes_xxxiv.root"
42 #fileName = "~/UserCode/nowaf/PythonScripts/2011/VersionII/" + "WJets" + "_muonAcc_noSmooth.root"
43 #fileName = "~/UserCode/nowaf/PythonScripts/2011/VersionII/" + "WJets" + "_HPS_eff_GC_clxi.root"
44 #fileName = "~/UserCode/nowaf/PythonScripts/2011/VersionII/" + "Data" + "_fakes_xxxiv.root"
45 #fileName = "WJets_muonAcc.root"
46 #fileName = "~/UserCode/nowaf/PythonScripts/2011/VersionII/" + "TTbar" + "_HPS_eff_GC_clix.root"
47 #fileName = "~/UserCode/nowaf/PythonScripts/2011/VersionII/" + "TTbar" + "_muonAcc.root"
48 #fileName = "~/UserCode/nowaf/PythonScripts/2011/VersionII/" + "TTbar" + "_HPS_eff_nVertex_Full.root"
49 #fileName = "~/UserCode/nowaf/PythonScripts/2011/VersionII/" + "WZJets" + "_fakes.root"
50 fileName = None
51
52
53 isData = False
54 if "Data" in sampleList:
55 isData = True
56 pass
57
58 ### fakes : rebin = 1, dynamicRebin = 6, startAtBinCenter = 15
59 ### eff : rebin = 2, dynamicRebin = 10, startAtBinCenter = 20
60
61 rebin = 1
62 #rebin = 2
63 #rebin = 1
64
65 smoo = 2
66
67 draw = False
68 #### not from tau
69 drawAllDirsInOne = False
70 #### efficieny others
71 drawAllDirsInOneEff = False
72 drawAllDirsInOneEffVertex = False
73 drawEff = False
74 ####
75 drawAllDirsInOneMHT = False
76 drawAllDirsInOneHT = False
77 ### fakes
78 drawFakes = False
79 drawFakesCompare = False
80 drawEffCompare = True
81 #xtitle = "P_{T}^{#tau} [GeV]"
82 ytitle = "#epsilon_{#tau}^{reco}"
83 ###title = "W+Jets simulation, H_{T}>300 GeV, #slashH_{T}>200 GeV"
84 #title = "TTbar simulation, H_{T}>300 GeV, #slashH_{T}>200 GeV"
85 #title = "CMS Simulation, H_{T}>300 GeV, #slashH_{T}>200 GeV"
86 #title = "t#bar{t} simulation"
87 #color = ROOT.kOrange + 7
88 #title = "W+Jets simulation"
89
90 #xtitle = "P_{T}^{#mu} [GeV]"
91 #####ytitle = "pobability #mu not from #tau decay"
92 #ytitle = "p_{#mu}^{W}"
93 #title = "CMS Simulation"
94 ###title = "W+Jets MC, No Selection"
95 #title = "t#bar{t} simulation, HT>350 GeV"
96 #title = "TTbar Simulation"
97 color = ROOT.kAzure + 2
98 ##color = ROOT.kBlue + 2
99 #title = "QCD Simulation, P_{T}^{jet} < 30 GeV"
100 #title = "QCD Simulation, 30 GeV < P_{T}^{jet} < 50 GeV"
101 #title = "QCD Simulation, 50 GeV < P_{T}^{jet} < 100 GeV"
102 #title = "QCD Simulation, 100 GeV < P_{T}^{jet}"
103 #title = "QCD Simulation"
104 #title = "CMS Simulation, H_{T}>350 GeV"
105 #title = "QCD Simulation, H_{T}>350 GeV"
106 #title = "Simulation only, H_{T}>300 GeV"
107 #title = "CMS Simulation, H_{T}>300 GeV"
108 #title = "CMS Simulation"
109 #title = "W+Jets Simulation, H_{T}>300 GeV"
110 title = "CMS Simulation, H_{T}>300 GeV"
111
112 #xtitle = "P_{T}^{jet} [GeV]"
113 #ytitle = "fake rate"
114 #title = "ZJets H_{T}>350 GeV, MHT<20 GeV"
115 #title = "QCD simulation, H_{T}>300 GeV"
116 #title = "CMS Preliminary, H_{T}>350 GeV, #slashH_{T}<20 GeV"
117 #color = ROOT.kBlack
118 xtitle = "N^{G} + N^{C}"
119 #xtitleAdd = " (P_{T}^{#tau}<20 GeV)"
120 #xtitleAdd = " (20<P_{T}^{#tau}<40 GeV)"
121 #xtitleAdd = " (40<P_{T}^{#tau}<60 GeV)"
122 #xtitleAdd = " (60<P_{T}^{#tau}<80 GeV)"
123 #xtitleAdd = " (80<P_{T}^{#tau}<100 GeV)"
124 #xtitleAdd = " (P_{T}^{#tau}>100 GeV)"
125 #xtitleAdd = " (P_{T}^{#tau}>20 GeV)"
126 xtitleAdd = ""
127
128 colorDict = {}
129 colorDict[ "MuonAnalyzerNoSelection/" ] = ROOT.kBlack
130 colorDict[ "MuonAnalyzerMHT50/" ] = ROOT.kBlue - 7
131 colorDict[ "MuonAnalyzerMHT100/" ] = ROOT.kViolet - 6
132 colorDict[ "MuonAnalyzerMHT150/" ] = ROOT.kRed
133 #colorDict[ "MuonAnalyzerMHT200/" ] = ROOT.kOrange + 7
134 #colorDict[ "MuonAnalyzerMHT250/" ] = ROOT.kYellow + 1
135 #colorDict[ "MuonAnalyzerMHT400/" ] = ROOT.kYellow + 3
136 colorDict[ "MuonAnalyzerMHT200/" ] = ROOT.kYellow + 1
137 colorDict[ "MuonAnalyzerMHT250/" ] = ROOT.kYellow + 3
138 colorDict[ "MuonAnalyzerMHT400/" ] = ROOT.kGreen + 1
139
140
141 colorDict[ "JetTauPtJPT" ] = ROOT.kBlue - 9
142 colorDict[ "JetTauPtJPTData" ] = ROOT.kBlue + 3
143 colorDict[ "JetTauEtaJPT" ] = ROOT.kBlack
144 colorDict[ "JetTauPtJPTeta1" ] = ROOT.kRed - 9
145 colorDict[ "JetTauPtJPTeta1Data" ] = ROOT.kRed + 4
146 colorDict[ "JetTauPtJPTeta2" ] = ROOT.kOrange + 6
147 colorDict[ "JetTauPtJPTeta2Data" ] = ROOT.kOrange + 3
148 colorDict[ "JetTauPtJPTeta25" ] = ROOT.kYellow - 5
149 colorDict[ "JetTauPtJPTeta25Data" ] = ROOT.kYellow + 4
150 colorDict[ "NVertexTau" ] = ROOT.kCyan - 2
151 colorDict[ "NVertexTauData" ] = ROOT.kCyan + 4
152 colorDict[ "JetTauEtaJPTPt20" ] = ROOT.kBlack
153 colorDict[ "JetTauEtaJPTPt40" ] = ROOT.kBlue + 2
154 colorDict[ "JetTauEtaJPTPt60" ] = ROOT.kBlue - 6
155 colorDict[ "JetTauEtaJPTPt80" ] = ROOT.kAzure + 2
156 colorDict[ "JetTauEtaJPTPt100" ] = ROOT.kAzure + 10
157 colorDict[ "JetTauEtaJPTPt200" ] = ROOT.kCyan - 2
158 colorDict[ "JetTauEtaJPTPt500" ] = ROOT.kTeal - 1
159 colorDict[ "JetTauEtaJPTPtInf" ] = ROOT.kTeal + 3
160 colorDict[ "JetTauDist" ] = ROOT.kBlue - 9
161 colorDict[ "JetTauIso" ] = ROOT.kBlue - 9
162 colorDict[ "JetTauIsoRel" ] = ROOT.kBlue - 9
163 colorDict[ "JetTauNCharged" ] = ROOT.kBlue - 9
164 colorDict[ "JetTauNGamma" ] = ROOT.kBlue - 9
165 colorDict[ "JetTauNNeutral" ] = ROOT.kBlue - 9
166 colorDict[ "JetTauNCPlusG" ] = ROOT.kBlue - 9
167
168 colorDict[ "JetTauGCPt020" ] = ROOT.kBlack
169 colorDict[ "JetTauGCPt2030" ] = ROOT.kViolet + 1
170 colorDict[ "JetTauGCPt3050" ] = ROOT.kOrange - 5
171 colorDict[ "JetTauGCPt50100" ] = ROOT.kYellow - 6
172 colorDict[ "JetTauGCPt100" ] = ROOT.kGreen - 6
173
174 colorDict[ "EffRateHT0/" ] = ROOT.kBlack
175 colorDict[ "EffRateHT50/" ] = ROOT.kRed + 2
176 colorDict[ "EffRateHT100/" ] = ROOT.kRed-7
177 colorDict[ "EffRateHT150/" ] = ROOT.kMagenta - 2
178 colorDict[ "EffRateHT200/" ] = ROOT.kViolet - 7
179 colorDict[ "EffRateHT250/" ] = ROOT.kViolet + 7
180 colorDict[ "EffRateHT300/" ] = ROOT.kBlue + 3
181 colorDict[ "EffRateHT350/" ] = ROOT.kBlue - 7
182
183 colorDict[ "EffRate350HT600/" ] = ROOT.kBlue - 7
184 colorDict[ "EffRate600HT/" ] = ROOT.kBlue + 3
185 colorDict[ "EffRate400HT/" ] = ROOT.kBlack
186
187 colorDict[ "EffRateLowV/" ] = ROOT.kOrange + 7
188 colorDict[ "EffRateMidV/" ] = ROOT.kOrange + 4
189 colorDict[ "EffRateHighV/" ] = ROOT.kOrange + 3
190
191 colorDict[ "EffRateLowVBL/" ] = ROOT.kOrange + 7
192 colorDict[ "EffRateMidVBL/" ] = ROOT.kOrange + 4
193 colorDict[ "EffRateHighVBL/" ] = ROOT.kOrange + 3
194
195 colorDict[ "EffRateLowVFull/" ] = ROOT.kOrange + 7
196 colorDict[ "EffRateMidVFull/" ] = ROOT.kOrange + 4
197 colorDict[ "EffRateHighVFull/" ] = ROOT.kOrange + 3
198
199 colorDict[ "JetTauPtJPTLV" ] = ROOT.kOrange + 7
200 colorDict[ "JetTauPtJPTMV" ] = ROOT.kOrange + 4
201 colorDict[ "JetTauPtJPTHV" ] = ROOT.kOrange + 3
202
203 colorDict[ "FakeRateMHT20/" ] = ROOT.kBlue + 4
204 colorDict[ "FakeRate20MHT60/" ] = ROOT.kBlue - 6
205 colorDict[ "FakeRate60MHT100/" ] = ROOT.kAzure + 7
206 colorDict[ "FakeRate100MHT200/" ] = ROOT.kCyan + 3
207 colorDict[ "FakeRate200MHT400/" ] = ROOT.kCyan - 8
208 colorDict[ "FakeRate400MHT/" ] = ROOT.kTeal + 4
209 colorDict[ "FakeRateMHT20NoB/" ] = ROOT.kBlue + 4
210 colorDict[ "FakeRate20MHT60NoB/" ] = ROOT.kBlue - 6
211 colorDict[ "FakeRate60MHT100NoB/" ] = ROOT.kAzure + 7
212 colorDict[ "FakeRate100MHT200NoB/" ] = ROOT.kCyan + 3
213 colorDict[ "FakeRate200MHT400NoB/" ] = ROOT.kCyan - 8
214 colorDict[ "FakeRate400MHTNoB/" ] = ROOT.kTeal + 4
215
216 colorDict[ "FakeRate350HT600/" ] = ROOT.kBlue + 4
217 colorDict[ "FakeRate600HT/" ] = ROOT.kBlue - 6
218
219 colorDict[ "EffRateNoSelection/" ] = ROOT.kRed + 4
220 colorDict[ "EffRatePreRed/" ] = ROOT.kOrange + 7
221 colorDict[ "EffRatePre/" ] = ROOT.kOrange + 7
222 colorDict[ "EffRate/" ] = ROOT.kOrange + 3
223
224 colorDict[ "JetTauPtJPTLV" ] = ROOT.kOrange + 7
225 colorDict[ "JetTauPtJPTMV" ] = ROOT.kOrange + 4
226 colorDict[ "JetTauPtJPTHV" ] = ROOT.kOrange + 3
227
228 colorDict[ "FakeRateInvertMHTLoose/" ] = ROOT.kBlue + 4
229 colorDict[ "FakeRate40MHT60/" ] = ROOT.kBlue - 6
230 colorDict[ "FakeRate250MHT/" ] = ROOT.kRed
231 colorDict[ "FakeRate80MHT100/" ] = ROOT.kRed
232 colorDict[ "FakeRate100MHT120/" ] = ROOT.kRed
233
234 colorDict[ "WJets" ] = 8
235 colorDict[ "TTbar" ] = ROOT.kRed + 2
236 colorDict[ "TauGCPt020" ] = ROOT.kOrange
237 colorDict[ "TauGCPt20" ] = ROOT.kOrange + 7
238 colorDict[ "TauGCPt20100" ] = ROOT.kOrange + 3
239 colorDict[ "TauGCPt100" ] = ROOT.kTeal - 5
240 colorDict[ "TauGCPt20150" ] = ROOT.kOrange + 3
241 colorDict[ "TauGCPt150" ] = ROOT.kBlack
242 colorDict[ "TauPt" ] = ROOT.kOrange + 7
243 colorDict[ "TauGCPt40" ] = ROOT.kOrange +3
244 colorDict[ "TauGCPt2040" ] = ROOT.kOrange + 7
245 colorDict[ "TauGCPt30" ] = ROOT.kOrange +3
246 colorDict[ "TauGCPt2030" ] = ROOT.kOrange
247 colorDict[ "TauGCPt4060" ] = ROOT.kViolet - 6
248 colorDict[ "TauGCPt6080" ] = ROOT.kViolet + 6
249 colorDict[ "TauGCPt80100" ] = ROOT.kAzure + 7
250 colorDict[ "TauNPt020" ] = ROOT.kOrange + 7
251 colorDict[ "TauNPt100" ] = 8
252 colorDict[ "TauNPt20100" ] = ROOT.kOrange + 3
253
254 colorDict[ "TauGCNPt020" ] = ROOT.kOrange + 7
255 colorDict[ "TauGCNPt2040" ] = ROOT.kRed
256 colorDict[ "TauGCNPt4060" ] = ROOT.kBlue
257 colorDict[ "TauGCNPt6080" ] = ROOT.kBlack
258 colorDict[ "TauGCNPt80100" ] = ROOT.kViolet
259 colorDict[ "TauGCNPt100" ] = 8
260 colorDict[ "TauGCNPt20100" ] = ROOT.kOrange + 3
261
262
263
264 plotTitle = False
265 if not title == None:
266 plotTitle = True
267 pass
268 Def.SetGlobalStyles( withTitle=plotTitle )
269 if re.search( "slash", title ):
270 #ROOT.gStyle.SetTitleFontSize( 0.02 )
271 ROOT.gStyle.SetTitleH( 0.032 )
272 if re.search( "Preliminary", title ):
273 ROOT.gStyle.SetTitleH( 0.030 )
274 pass
275 pass
276
277
278
279 dirs = []
280 #dirs.append( "EffRatePre/" )
281 #dirs.append( "FakeRateDiJetsLoose/" )
282 #dirs.append( "FakeRateAllLoose/" )
283 #dirs.append( "FakeRateInvertMHTLoose/" )
284 #dirs.append( "FakeRate40MHT60/" )
285 #dirs.append( "MuonAnalyzerPre/" )
286 #dirs.append( "MuonAnalyzerNoSelection/" )
287 #dirs.append( "MuonAnalyzerMHT50/" )
288 #dirs.append( "MuonAnalyzerMHT100/" )
289 #dirs.append( "MuonAnalyzerMHT150/" )
290 #dirs.append( "MuonAnalyzerMHT200/" )
291 #dirs.append( "MuonAnalyzerMHT250/" )
292 #dirs.append( "MuonAnalyzerMHT400/" )
293 #dirs.append( "MuonAnalyzerPre/" )
294 #dirs.append( "EffRateHT0/")
295 #dirs.append( "EffRateHT50/")
296 ###dirs.append( "EffRateHT100/")
297 #dirs.append( "EffRateHT150/")
298 ###dirs.append( "EffRateHT200/")
299 #dirs.append( "EffRateHT250/")
300 ###dirs.append( "EffRateHT300/")
301 #dirs.append( "EffRateHT350/")
302 #dirs.append( "EffRateLowV/" )
303 #dirs.append( "EffRateMidV/" )
304 #dirs.append( "EffRateHighV/" )
305 #dirs.append( "EffRateLowVBL/" )
306 #dirs.append( "EffRateMidVBL/" )
307 #dirs.append( "EffRateHighVBL/" )
308 #dirs.append( "EffRateLowVFull/" )
309 #dirs.append( "EffRateMidVFull/" )
310 #dirs.append( "EffRateHighVFull/" )
311 #dirs.append( "EffRate350HT600/")
312 #dirs.append( "EffRate400HT/")
313 #dirs.append( "EffRate600HT/")
314 #dirs.append( "EffRatePreRed/" )
315 #dirs.append( "EffRatePre/" )
316 #dirs.append( "EffRate/" )
317 #dirs.append( "FakeRate60MHT100/" )
318 #dirs.append( "FakeRate100MHT250/" )
319 #dirs.append( "FakeRate250MHT400/" )
320 dirs.append( "EffRateNoSelection/" )
321 if drawAllDirsInOneMHT:
322 #dirs.append( "FakeRateMHT20/" )
323 #dirs.append( "FakeRate20MHT60/" )
324 #dirs.append( "FakeRate60MHT100/" )
325 #dirs.append( "FakeRate100MHT200/" )
326 #dirs.append( "FakeRate200MHT400/" )
327 #dirs.append( "FakeRate400MHT/" )
328 #dirs.append( "FakeRateMHT20NoB/" )
329 #dirs.append( "FakeRate20MHT60NoB/" )
330 #dirs.append( "FakeRate60MHT100NoB/" )
331 #dirs.append( "FakeRate100MHT200NoB/" )
332 #dirs.append( "FakeRate200MHT400NoB/" )
333 #dirs.append( "FakeRate400MHTNoB/" )
334 dirs.append( "FakeRateInvertMHTLoose/" )
335 dirs.append( "FakeRate40MHT60/" )
336 #dirs.append( "FakeRate100MHT120/" )
337 dirs.append( "FakeRate80MHT100/" )
338 pass
339 if drawAllDirsInOneEff:
340 dirs.append( "EffRateNoSelection/" )
341 #dirs.append( "EffRatePreRed/" )
342 dirs.append( "EffRatePre/" )
343 #dirs.append( "EffRate/" )
344
345 pass
346 if drawAllDirsInOneHT:
347 dirs.append( "FakeRate350HT600/" )
348 dirs.append( "FakeRate600HT/" )
349 pass
350 #if drawEffCompare:
351
352 startAtBinCenter = -1
353 #startAtBinCenter = 80
354 #startAtBinCenter = 20
355 #startAtBinCenter = 15
356
357 initialHistDict = {}
358 #initialHistDict[ "TauPt" ] = "GenPt"
359 #initialHistDict[ "MuonPtPromptNotFromTau" ] = "MuonPtPrompt"
360 #initialHistDict[ "JetTauPtJPT" ] = "JetPtJPT"
361 ####initialHistDict[ "JetTauPt" ] = "JetPt"
362 #initialHistDict[ "JetTauEtaJPT" ] = "JetEtaJPT"
363 ######initialHistDict[ "JetTauDist" ] = "JetDist"
364 #####initialHistDict[ "JetTauIsoRel" ] = "JetIsoRel"
365 ###initialHistDict[ "JetTauEtaJPTPt20" ] = "JetEtaJPTPt20"
366 ###initialHistDict[ "JetTauEtaJPTPt40" ] = "JetEtaJPTPt40"
367 ###initialHistDict[ "JetTauEtaJPTPt60" ] = "JetEtaJPTPt60"
368 ###initialHistDict[ "JetTauEtaJPTPt80" ] = "JetEtaJPTPt80"
369 ###initialHistDict[ "JetTauEtaJPTPt100" ] = "JetEtaJPTPt100"
370 ###initialHistDict[ "JetTauEtaJPTPt200" ] = "JetEtaJPTPt200"
371 ###initialHistDict[ "JetTauEtaJPTPt500" ] = "JetEtaJPTPt500"
372 ####initialHistDict[ "JetTauEtaJPTPtInf" ] = "JetEtaJPTPtInf"
373 #initialHistDict[ "JetTauPtJPTeta1" ] = "JetPtJPTeta1"
374 #initialHistDict[ "JetTauPtJPTeta2" ] = "JetPtJPTeta2"
375 #initialHistDict[ "JetTauPtJPTeta25" ] = "JetPtJPTeta25"
376 ####initialHistDict[ "JetTauIsoReleta1" ] = "JetIsoReleta1"
377 ###initialHistDict[ "JetTauIsoReleta2" ] = "JetIsoReleta2"
378 ###initialHistDict[ "JetTauIsoReleta25" ] = "JetIsoReleta25"
379 ###initialHistDict[ "JetTauIsoRelPt20" ] = "JetIsoRelPt20"
380 ###initialHistDict[ "JetTauIsoRelPt40" ] = "JetIsoRelPt40"
381 ###initialHistDict[ "JetTauIsoRelPt60" ] = "JetIsoRelPt60"
382 ###initialHistDict[ "JetTauIsoRelPt80" ] = "JetIsoRelPt80"
383 ###initialHistDict[ "JetTauIsoRelPt100" ] = "JetIsoRelPt100"
384 ###initialHistDict[ "JetTauIsoRelPt200" ] = "JetIsoRelPt200"
385 ###initialHistDict[ "JetTauIsoRelPt500" ] = "JetIsoRelPt500"
386 ###initialHistDict[ "JetTauIsoRelPtInf" ] = "JetIsoRelPtInf"
387 #initialHistDict[ "NVertexTau" ] = "NVertex"
388 #initialHistDict[ "JetTauPtJPTLV" ] = "JetPtJPTLV"
389 #initialHistDict[ "JetTauPtJPTMV" ] = "JetPtJPTMV"
390 #initialHistDict[ "JetTauPtJPTHV" ] = "JetPtJPTHV"
391 #initialHistDict[ "JetTauPtJPTDR" ] = "JetPtJPTDR"
392 #initialHistDict[ "JetTauDist" ] = "JetDist"
393 #initialHistDict[ "JetTauIso" ] = "JetIso"
394 #initialHistDict[ "JetTauIsoRel" ] = "JetIsoRel"
395 #initialHistDict[ "JetTauNCharged" ] = "JetNCharged"
396 #initialHistDict[ "JetTauNGamma" ] = "JetNGamma"
397 #initialHistDict[ "JetTauNNeutral" ] = "JetNNeutral"
398 #initialHistDict[ "JetTauNCPlusG" ] = "JetNCPlusG"
399 #initialHistDict[ "JetTauPtFC" ] = "JetPtFC"
400 #initialHistDict[ "JetTauPteta1FC" ] = "JetPteta1FC"
401 #initialHistDict[ "JetTauPtFG" ] = "JetPtFG"
402 #initialHistDict[ "JetTauPtFCG" ] = "JetPtFCG"
403 #initialHistDict[ "JetTauChargedPt" ] = "JetChargedPt"
404 #initialHistDict[ "JetTauGammaPt" ] = "JetGammaPt"
405 #initialHistDict[ "JetTauPtJPT" ] = "JetPtNoIso"
406 #initialHistDict[ "JetTauDecayMode" ] = "JetDecayMode"
407 #initialHistDict[ "JetTauLeadPFCandPt" ] = "JetLeadPFCandPt"
408 #initialHistDict[ "JetTauLeadChargedHadrPt" ] = "JetLeadChargedHadrPt"
409 #initialHistDict[ "JetTauSignalPFCandPt" ] = "JetSignalPFCandPt"
410 #initialHistDict[ "JetTauSignalPFGammaCandPt" ] = "JetSignalPFGammaCandPt"
411 #initialHistDict[ "JetTauPtNoGC" ] = "JetPtNoGC"
412 #initialHistDict[ "JetTauDecayModeNoGC" ] = "JetDecayModeNoGC"
413 #initialHistDict[ "JetTauPt_mis" ] = "JetPt_mis"
414 #initialHistDict[ "JetTauPt_well" ] = "JetPt_well"
415 #initialHistDict[ "JetTauPt_greater07" ] = "JetPt_greater07"
416 #initialHistDict[ "JetTauPtJPT" ] = "JetPtJPTMat"
417 #initialHistDict[ "JetTauEtaJPT" ] = "JetEtaJPTMat"
418 #initialHistDict[ "JetTauPtJPTeta1" ] = "JetPtJPTeta1Mat"
419 #initialHistDict[ "JetTauPtJPTeta2" ] = "JetPtJPTeta2Mat"
420 #initialHistDict[ "JetTauPtJPTeta25" ] = "JetPtJPTeta25Mat"
421 #initialHistDict[ "JetTauGCPt020" ] = "JetGCPt020"
422 #initialHistDict[ "JetTauGCPt2030" ] = "JetGCPt2030"
423 #initialHistDict[ "JetTauGCPt3050" ] = "JetGCPt3050"
424 #initialHistDict[ "JetTauGCPt50100" ] = "JetGCPt50100"
425 #initialHistDict[ "JetTauGCPt100" ] = "JetGCPt100"
426 #initialHistDict[ "TauGC" ] = "GenGC"
427 #initialHistDict[ "TauGCPt020" ] = "GenGCPt020"
428 ##initialHistDict[ "TauGCPt2030" ] = "GenGCPt2030"
429 ##initialHistDict[ "TauGCPt30" ] = "GenGCPt30"
430 #initialHistDict[ "TauGCPt2040" ] = "GenGCPt2040"
431 initialHistDict[ "TauGCPt4060" ] = "GenGCPt4060"
432 #initialHistDict[ "TauGCPt6080" ] = "GenGCPt6080"
433 #initialHistDict[ "TauGCPt80100" ] = "GenGCPt80100"
434 ##initialHistDict[ "TauGCPt40" ] = "GenGCPt40"
435 ##initialHistDict[ "TauGCPt20100" ] = "GenGCPt20100"
436 #initialHistDict[ "TauGCPt100" ] = "GenGCPt100"
437 #initialHistDict[ "TauGCPt20150" ] = "GenGCPt20150"
438 #initialHistDict[ "TauGCPt150" ] = "GenGCPt150"
439 #initialHistDict[ "TauGCPt20" ] = "GenGCPt20"
440 #initialHistDict[ "JetTauPt0GC" ] = "JetPt0GC"
441 #initialHistDict[ "JetTauPt1GC" ] = "JetPt1GC"
442 #initialHistDict[ "JetTauPt2GC" ] = "JetPt2GC"
443 #initialHistDict[ "JetTauPt3GC" ] = "JetPt3GC"
444 #initialHistDict[ "JetTauPt3InfGC" ] = "JetPt3InfGC"
445
446 #initialHistDict[ "TauNPt020" ] = "GenNPt020"
447 #initialHistDict[ "TauNPt20100" ] = "GenNPt20100"
448 #initialHistDict[ "TauNPt100" ] = "GenNPt100"
449
450 #initialHistDict[ "TauGCNPt020" ] = "GenGCNPt020"
451 ##initialHistDict[ "TauGCNPt20100" ] = "GenGCNPt20100"
452 #initialHistDict[ "TauGCNPt100" ] = "GenGCNPt100"
453 ##initialHistDict[ "TauGCNPt2030" ] = "GenGCNPt2030"
454 #initialHistDict[ "TauGCNPt2040" ] = "GenGCNPt2040"
455 #initialHistDict[ "TauGCNPt4060" ] = "GenGCNPt4060"
456 #initialHistDict[ "TauGCNPt6080" ] = "GenGCNPt6080"
457 #initialHistDict[ "TauGCNPt80100" ] = "GenGCNPt80100"
458 ##initialHistDict[ "TauGCNPt150" ] = "GenGCNPt150"
459
460 histDict = {}
461 graph = {}
462 Mean = {}
463 ErrUp = {}
464 ErrDwn = {}
465 cDict = {}
466 legDict = {}
467 for hist in initialHistDict.keys():
468 print "----- ", hist
469 histDict[ hist ] = {}
470 graph[ hist ] = {}
471 histDict[ initialHistDict[ hist ] ] = {}
472 Mean[ hist ] = {}
473 ErrUp[ hist ] = {}
474 ErrDwn[ hist ] = {}
475 for file in sampleList:
476 rootfile = ROOT.TFile.Open( fileDict[ file ] )
477 histDict[ hist ][ file ] = {}
478 histDict[ initialHistDict[ hist ] ][ file ] = {}
479 Mean[ hist ][ file ] = {}
480 ErrUp[ hist ][ file ] = {}
481 ErrDwn[ hist ][ file ] = {}
482 graph[ hist ][ file ] = {}
483 for dir in dirs:
484 histDict[ hist ][ file ][ dir ] = rootfile.Get( dir + hist )
485 print "hist: ", hist, " file: ", file, "dir: ", dir
486 histDict[ hist ][ file ][ dir ].SetDirectory( 0 )
487 histDict[ hist ][ file ][ dir ].UseCurrentStyle()
488 histDict[ hist ][ file ][ dir ].Rebin( rebin )
489
490 histDict[ initialHistDict[ hist ] ][ file ][ dir ] = rootfile.Get( dir + initialHistDict[ hist ] )
491 histDict[ initialHistDict[ hist ] ][ file ][ dir ].SetDirectory( 0 )
492 histDict[ initialHistDict[ hist ] ][ file ][ dir ].UseCurrentStyle()
493 histDict[ initialHistDict[ hist ] ][ file ][ dir ].Rebin( rebin )
494
495
496
497 #### make new, empty hists with same binning:
498 Mean[ hist ][ file ][ dir ] = ROOT.TH1F( hist + "Mean", hist + "Mean",
499 histDict[ hist ][ file ][ dir ].GetNbinsX(),
500 histDict[ hist ][ file ][ dir ].GetXaxis().GetXmin(),
501 histDict[ hist ][ file ][ dir ].GetXaxis().GetXmax() )
502
503 ErrUp[ hist ][ file ][ dir ] = ROOT.TH1F( hist + "ErrUp", hist + "ErrUp",
504 histDict[ hist ][ file ][ dir ].GetNbinsX(),
505 histDict[ hist ][ file ][ dir ].GetXaxis().GetXmin(),
506 histDict[ hist ][ file ][ dir ].GetXaxis().GetXmax() )
507
508 ErrDwn[ hist ][ file ][ dir ] = ROOT.TH1F( hist + "ErrDwn", hist + "ErrDwn",
509 histDict[ hist ][ file ][ dir ].GetNbinsX(),
510 histDict[ hist ][ file ][ dir ].GetXaxis().GetXmin(),
511 histDict[ hist ][ file ][ dir ].GetXaxis().GetXmax() )
512
513 Mean[ hist ][ file ][ dir ].SetDirectory( 0 )
514 ErrUp[ hist ][ file ][ dir ].SetDirectory( 0 )
515 ErrDwn[ hist ][ file ][ dir ].SetDirectory( 0 )
516
517 #print type( Mean[ hist ][ file ][ dir ] )
518
519 #print "1"
520
521 if doDynamicRebin:
522
523 drebin = dynamicRebin
524 #if drawFakesCompare and file == "QCDFlat":
525 # drebin = 20
526 # pass
527
528 lowerBinsHist = FH.getLowerBins( histDict[ hist ][ file ][ dir ], nEntries=drebin,
529 startAtBinCenter=startAtBinCenter )
530 lowerBinsHist2 = FH.getLowerBins( histDict[ initialHistDict[ hist ] ][ file ][ dir ], nEntries=drebin,
531 startAtBinCenter=startAtBinCenter )
532
533 rebinList = FH.mergeList( [ lowerBinsHist, lowerBinsHist2 ] )
534 #if hist == "JetTauEtaJPTPtInf":
535 # #rebinList = [-5.,5.]
536 # print rebinList
537 # pass
538 ## if file == "QCDFlat" and drawFakes:
539 ## if hist == "JetTauPtJPTeta2":
540 ## rebinList = [0.0, 5.0, 10.0, 15.0, 30.0, 50.0, 65.0, 120.0, 1000.0]
541 ## elif hist == "JetTauPtJPTeta25":
542 ## rebinList=[0.0, 5.0, 10.0, 15.0, 20.0, 25.0, 35.0, 40.0, 50.0, 65.0, 100.0, 175.0, 1000.0]
543 ## elif hist == "NVertexTau":
544 ## rebinList=[-0.5, 0.5, 1.5, 2.5, 3.5, 4.5, 5.5, 6.5, 7.5, 8.5, 9.5, 10.5, 11.5,
545 ## 12.5, 13.5, 14.5, 15.5, 16.5, 17.5, 19.5]
546 ## elif hist == "JetTauPtJPTeta1":
547 ## rebinList = [0.0, 5.0, 10.0, 15.0, 20.0, 30.0, 35.0, 45.0, 55.0, 70.0, 105.0, 1000.0]
548 ## elif hist == "JetTauPtJPT":
549 ## rebinList = [0.0, 5.0, 10.0, 15.0, 20.0, 25.0, 30.0, 35.0, 40.0, 45.0,
550 ## 50.0, 55.0, 60.0, 65.0, 75.0, 85.0, 115.0, 130.0, 175.0, 195.0, 1000.0]
551 ## pass
552 #if file == "QCDFlat" and drawFakes:
553 # if hist == "JetTauPtJPTeta2":
554 # rebinList = [0.0, 5.0, 10.0, 15.0, 30.0, 50.0, 65.0, 110.0, 1000.0]
555 # elif hist == "JetTauPtJPTeta25":
556 # rebinList=[0.0, 5.0, 10.0, 15.0, 20.0, 25.0, 35.0, 45.0, 55.0, 80.0, 120.0, 1000.0]
557 # elif hist == "NVertexTau":
558 # rebinList=[-0.5, 0.5, 1.5, 2.5, 3.5, 4.5, 5.5, 6.5, 7.5, 8.5, 9.5, 10.5, 11.5, 12.5, 13.5, 14.5, 15.5, 16.5, 17.5, 19.5]
559 # elif hist == "JetTauPtJPTeta1":
560 # rebinList = [0.0, 5.0, 10.0, 15.0, 20.0, 25.0, 30.0, 35.0, 40.0, 50.0, 65.0, 100.0, 170.0, 1000.0]
561 # elif hist == "JetTauPtJPT":
562 # rebinList = [0.0, 5.0, 10.0, 15.0, 20.0, 25.0, 30.0, 35.0, 40.0, 45.0, 50.0, 55.0, 60.0, 70.0, 80.0, 100.0, 120.0, 150.0, 180.0, 195.0, 1000.0]
563 # pass
564 #### 40 < MHT < 60
565 if file == "QCDFlat" and drawFakes:
566 if hist == "JetTauPtJPTeta2":
567 rebinList = [0.0, 5.0, 10.0, 15.0, 20.0, 25.0, 30.0, 35.0, 40.0, 50.0, 55.0, 70.0, 95.0, 135.0, 1000.0]
568 elif hist == "JetTauPtJPTeta25":
569 rebinList=[0.0, 5.0, 10.0, 15.0, 20.0, 25.0, 30.0, 35.0, 45.0, 50.0, 55.0, 75.0, 95.0, 150.0, 1000.0]
570 elif hist == "NVertexTau":
571 rebinList=[-0.5, 0.5, 1.5, 2.5, 3.5, 4.5, 5.5, 6.5, 7.5, 8.5, 9.5, 10.5, 11.5, 12.5, 13.5, 14.5, 15.5, 16.5, 17.5, 19.5]
572 elif hist == "JetTauPtJPTeta1":
573 rebinList = [0.0, 5.0, 10.0, 15.0, 20.0, 25.0, 30.0, 35.0, 40.0, 50.0, 65.0, 105.0, 145.0, 200.0, 1000.0]
574 elif hist == "JetTauPtJPT":
575 rebinList = [0.0, 5.0, 10.0, 15.0, 20.0, 25.0, 30.0, 35.0, 40.0, 45.0, 50.0, 55.0, 60.0, 65.0, 75.0, 85.0, 95.0, 105.0, 125.0, 140.0, 160.0, 170.0, 200.0, 1000.0]
576 elif hist == "JetTauGCPt030":
577 rebinList = [-0.5, 0.5, 1.5, 2.5, 3.5, 4.5, 19.5]
578 elif hist == "JetTauGCPt100":
579 rebinList = [-0.5, 0.5, 1.5, 2.5, 3.5, 4.5, 5.5, 19.5]
580 elif hist == "JetTauGCPt50100":
581 rebinList = [-0.5, 0.5, 1.5, 2.5, 3.5, 4.5, 5.5, 19.5]
582 elif hist == "JetTauGCPt3050":
583 rebinList = [-0.5, 0.5, 1.5, 2.5, 3.5, 4.5, 5.5, 19.5]
584 elif hist == "JetTauPt3InfGC":
585 rebinList = [0.0, 25.0, 30.0, 40.0, 50.0, 60.0, 75.0, 110.0, 160.0, 1000.0]
586 elif hist == "JetTauPt1GC":
587 rebinList = [0.0, 20.0, 30.0, 45.0, 80.0, 1000.0]
588 elif hist == "JetTauPt2GC":
589 rebinList = [0.0, 25.0, 30.0, 40.0, 60.0, 125.0, 1000.0]
590 elif hist == "JetTauPt3GC":
591 rebinList = [0.0, 25.0, 40.0, 55.0, 1000.0]
592 elif hist == "JetTauPt0GC":
593 rebinList = [0.0, 25.0, 1000.0]
594 pass
595
596
597 obj = array( 'd' )
598 for b in rebinList:
599 obj.append( b )
600 pass
601 histDict[ hist ][ file ][ dir ] = \
602 histDict[ hist ][ file ][ dir ].Rebin( len( rebinList ) -1 , hist , obj )
603 histDict[ initialHistDict[ hist ] ][ file ][ dir ] = \
604 histDict[ initialHistDict[ hist ] ][ file ][ dir ].Rebin( len( rebinList ) -1 , hist , obj )
605 Mean[ hist ][ file ][ dir ] = Mean[ hist ][ file ][ dir ].Rebin( len( rebinList ) -1 , hist , obj )
606 ErrUp[ hist ][ file ][ dir ] = ErrUp[ hist ][ file ][ dir ].Rebin( len( rebinList ) -1 , hist , obj )
607 ErrDwn[ hist ][ file ][ dir ] = ErrDwn[ hist ][ file ][ dir ].Rebin( len( rebinList ) -1 , hist , obj )
608
609 pass
610
611
612
613
614
615
616
617
618 #print "2"
619
620
621 Style.setHistStyle( Mean[ hist ][ file ][ dir ],
622 status="Signal",
623 color=1,
624 xTitle=xtitle, yTitle=ytitle )
625 Style.setHistStyle( ErrUp[ hist ][ file ][ dir ],
626 status="Signal",
627 color=9,
628 xTitle=xtitle, yTitle=ytitle )
629 Style.setHistStyle( ErrDwn[ hist ][ file ][ dir ],
630 status="Signal",
631 color=9,
632 xTitle=xtitle, yTitle=ytitle )
633
634 #histDict[ hist ][ file ].Divide( histDict[ initialHistDict[ hist ] ][ file ] )
635 #### make a TGraph first:
636 graph[ hist ][ file ][ dir ] = ROOT.TGraphAsymmErrors()
637 graph[ hist ][ file ][ dir ].BayesDivide( histDict[ hist ][ file ][ dir ],
638 histDict[ initialHistDict[ hist ] ][ file ][ dir ] )
639 graph[ hist ][ file ][ dir ].UseCurrentStyle()
640 ### remove very first bin
641 #for p in range( 0, graph[ hist ][ file ][ dir ].GetN() ):
642 # ix = ROOT.Double( 0 )
643 # yps = ROOT.Double( 0 )
644 # graph[ hist ][ file ][ dir ].GetPoint( p, ix, yps )
645 # if ix < 20 and yps < 10**-2:
646 # #if ix < 10:
647 # #graph[ hist ][ file ][ dir ].SetPoint( p,0,0 )
648 # #graph[ hist ][ file ][ dir ].SetPointError( p,0,0,0,0 )
649 # graph[ hist ][ file ][ dir ].RemovePoint( p )
650 # pass
651 # pass
652 #print "3"
653
654
655 #if hist == "JetTauPtJPTeta2":
656 # graph[ hist ][ file ][ dir ].Draw( "AP" )
657 # Def.DontQuit()
658
659 #print type( Mean[ hist ][ file ][ dir ] )
660
661 ### now get the mean, the err ups, and the err downs
662 ### note: bins start at 1, points at 0!
663 #for bin in range( 0, histDict[ hist ][ file ][ dir ].GetNbinsX() ):
664 for bin in range( 0, graph[ hist ][ file ][ dir ].GetN() ):
665 x = ROOT.Double( 0 )
666 y = ROOT.Double( 0 )
667 graph[ hist ][ file ][ dir ].GetPoint( ( bin ) , x, y )
668 #print bin, " x=", x, " y=", y
669 errUp = graph[ hist ][ file ][ dir ].GetErrorYhigh( bin )
670 errDwn = graph[ hist ][ file ][ dir ].GetErrorYlow( bin )
671 histbin = Mean[ hist ][ file ][ dir ].FindBin( x )
672 Mean[ hist ][ file ][ dir ].SetBinContent( histbin, y )
673
674
675 #print type( Mean[ hist ][ file ][ dir ] )
676 #if not y == 0:
677 #ErrUp[ hist ][ file ][ dir ].SetBinContent( bin + 1, y + errUp )
678 #ErrDwn[ hist ][ file ][ dir ].SetBinContent( bin + 1, y - errDwn )
679 ErrUp[ hist ][ file ][ dir ].SetBinContent( histbin ,errUp )
680 ErrDwn[ hist ][ file ][ dir ].SetBinContent( histbin, errDwn )
681 # pass
682 #else:
683 # ErrUp[ hist ][ file ][ dir ].SetBinContent( bin + 1, 0 )
684 # ErrDwn[ hist ][ file ][ dir ].SetBinContent( bin + 1, 0 )
685 # pass
686 pass
687 #if hist == "JetTauPtJPTeta2":
688 # Mean[ hist ][ file ][ dir ].Draw( )
689 # Def.DontQuit()
690
691 #print "4"
692
693
694 pass
695 #rootfile.Close()
696 pass
697 #pass
698
699 if smooth:
700 for hist in initialHistDict.keys():
701 for file in sampleList:
702 for dir in dirs:
703 Mean[ hist ][ file ][ dir ].Smooth( smoo )
704 ErrUp[ hist ][ file ][ dir ].Smooth( smoo )
705 ErrDwn[ hist ][ file ][ dir ].Smooth( smoo )
706 pass
707 pass
708 pass
709 pass
710
711 if draw:
712 cDict[ hist ] = ROOT.TCanvas( hist , hist )
713 cDict[ hist ].cd()
714 graph[ hist ][ "Draw" ] = ROOT.TGraphAsymmErrors()
715 j = 0
716 for i in range( 1,Mean[ hist ][ file ][ dir ].GetNbinsX() + 1 ):
717 y = Mean[ hist ][ file ][ dir ].GetBinContent( i )
718 x = Mean[ hist ][ file ][ dir ].GetBinCenter( i )
719 yerrup = ErrUp[ hist ][ file ][ dir ].GetBinContent( i )
720 yerrdwn = ErrDwn[ hist ][ file ][ dir ].GetBinContent( i )
721 binwidth = Mean[ hist ][ file ][ dir ].GetBinWidth( i )
722 if not y == 0:
723 graph[ hist ][ "Draw" ].SetPoint( j, x, y )
724 graph[ hist ][ "Draw" ].SetPointError( j, binwidth/2, binwidth/2, yerrdwn, yerrup )
725 j = j + 1
726 pass
727 pass
728 graph[ hist ][ "Draw" ].UseCurrentStyle()
729 Style.setHistStyle( graph[ hist ][ "Draw" ],
730 status="Err",
731 color=color,
732 xTitle=xtitle,
733 yTitle=ytitle,
734 title=title
735 )
736 graph[ hist ][ "Draw" ].Draw( "AP" )
737 #Mean[ hist ][ file ][ dir ].Draw()
738 #ErrUp[ hist ][ file ][ dir ].Draw( "same" )
739 #graph[ hist ][ "Draw" ].GetXaxis().SetRangeUser( 10., 1000. )
740 cDict[ hist ].Update()
741 Def.DontQuit()
742 pass
743 pass
744
745 if drawAllDirsInOne:
746 cDict[ "All" ] = ROOT.TCanvas( "All" , "All" )
747 cDict[ "All" ].cd()
748 same = "A"
749 graphList = []
750 hist = initialHistDict.keys()[ 0 ]
751 for dir in dirs:
752 graph[ dir ] = ROOT.TGraphAsymmErrors()
753 for i in range( 1,Mean[ hist ][ file ][ dir ].GetNbinsX() + 1 ):
754 y = Mean[ hist ][ file ][ dir ].GetBinContent( i )
755 x = Mean[ hist ][ file ][ dir ].GetBinCenter( i )
756 yerrup = ErrUp[ hist ][ file ][ dir ].GetBinContent( i )
757 yerrdwn = ErrDwn[ hist ][ file ][ dir ].GetBinContent( i )
758 binwidth = Mean[ hist ][ file ][ dir ].GetBinWidth( i )
759 graph[ dir ].SetPoint( i-1, x, y )
760 graph[ dir ].SetPointError( i-1, binwidth/2, binwidth/2, yerrdwn, yerrup )
761 pass
762 graph[ dir ].UseCurrentStyle()
763 Style.setHistStyle( graph[ dir ],
764 status="Err",
765 color=colorDict[ dir ],
766 xTitle=xtitle,
767 yTitle=ytitle,
768 title=title
769 )
770 graph[ dir ].Draw( "P" + same )
771 graphList.append( graph[ dir ] )
772 same = "same"
773 pass
774 legDict[ hist ] = Style.makeLegendSimple( graphList,
775 #[ "No Selection", "MHT>50 GeV", "MHT>100 GeV",
776 # "MHT>150 GeV", "MHT>200 GeV", "MHT>250 GeV", "MHT>400 GeV" ],
777 [ "MHT>0", "MHT>50 GeV", "MHT>100 GeV" ],
778 #statusDict=statusDict,
779 style="ep",
780 position="umr" )
781 legDict[ hist ].Draw( "same" )
782 Def.DontQuit()
783 pass
784
785 if drawAllDirsInOneMHT:
786 llist = [
787 "MHT<20 GeV",
788 #"20<MHT<60 GeV",
789 #"60<MHT<100 GeV",
790 #"100<MHT<200 GeV",
791 #"200<MHT<400 GeV",
792 #"400 GeV<MHT"
793 "40<MHT<60 GeV",
794 "80<MHT<100 GeV"
795 ]
796 cDict[ "All" ] = ROOT.TCanvas( "All" , "All" )
797 cDict[ "All" ].cd()
798 same = "A"
799 graphList = []
800 hist = initialHistDict.keys()[ 0 ]
801 if re.search( "Eta", hist ):
802 xtitle = "#eta^{jet}"
803 for dir in dirs:
804 graph[ dir ] = ROOT.TGraphAsymmErrors()
805 graph[ dir ].SetPoint( 0, 0, 0 )
806 for i in range( 1,Mean[ hist ][ file ][ dir ].GetNbinsX() + 1 ):
807 y = Mean[ hist ][ file ][ dir ].GetBinContent( i )
808 x = Mean[ hist ][ file ][ dir ].GetBinCenter( i )
809 yerrup = ErrUp[ hist ][ file ][ dir ].GetBinContent( i )
810 yerrdwn = ErrDwn[ hist ][ file ][ dir ].GetBinContent( i )
811 binwidth = Mean[ hist ][ file ][ dir ].GetBinWidth( i )
812 graph[ dir ].SetPoint( i, x, y )
813 graph[ dir ].SetPointError( i, binwidth/2, binwidth/2, yerrdwn, yerrup )
814 pass
815 graph[ dir ].UseCurrentStyle()
816 Style.setHistStyle( graph[ dir ],
817 status="Err",
818 color=colorDict[ dir ],
819 xTitle=xtitle,
820 yTitle=ytitle,
821 title=title
822 )
823 graph[ dir ].Draw( "P" + same )
824 graphList.append( graph[ dir ] )
825 same = "same"
826 pass
827 legDict[ hist ] = Style.makeLegendSimple( graphList,
828 llist,
829 #statusDict=statusDict,
830 style="ep",
831 position="umr" )
832 legDict[ hist ].Draw( "same" )
833 Def.DontQuit()
834 pass
835
836 if drawAllDirsInOneHT:
837 llist = [
838 "350<HT<600 GeV",
839 "600<MHT GeV",
840 ]
841 cDict[ "All" ] = ROOT.TCanvas( "All" , "All" )
842 cDict[ "All" ].cd()
843 same = "A"
844 graphList = []
845 hist = initialHistDict.keys()[ 0 ]
846 for dir in dirs:
847 graph[ dir ] = ROOT.TGraphAsymmErrors()
848 for i in range( 1,Mean[ hist ][ file ][ dir ].GetNbinsX() + 1 ):
849 y = Mean[ hist ][ file ][ dir ].GetBinContent( i )
850 x = Mean[ hist ][ file ][ dir ].GetBinCenter( i )
851 yerrup = ErrUp[ hist ][ file ][ dir ].GetBinContent( i )
852 yerrdwn = ErrDwn[ hist ][ file ][ dir ].GetBinContent( i )
853 binwidth = Mean[ hist ][ file ][ dir ].GetBinWidth( i )
854 graph[ dir ].SetPoint( i-1, x, y )
855 graph[ dir ].SetPointError( i-1, binwidth/2, binwidth/2, yerrdwn, yerrup )
856 pass
857 graph[ dir ].UseCurrentStyle()
858 Style.setHistStyle( graph[ dir ],
859 status="Err",
860 color=colorDict[ dir ],
861 xTitle=xtitle,
862 yTitle=ytitle,
863 title=title
864 )
865 graph[ dir ].Draw( "P" + same )
866 graphList.append( graph[ dir ] )
867 same = "same"
868 pass
869 legDict[ hist ] = Style.makeLegendSimple( graphList,
870 llist,
871 #statusDict=statusDict,
872 style="ep",
873 position="umr" )
874 legDict[ hist ].Draw( "same" )
875 Def.DontQuit()
876 pass
877
878 if drawEff:
879 legList = [
880 "P_{T}^{#tau}<20 GeV",
881 "20>P_{T}^{#tau}>40 GeV",
882 "40>P_{T}^{#tau}>60 GeV",
883 "60>P_{T}^{#tau}>80 GeV",
884 "80>P_{T}^{#tau}>100 GeV",
885 "P_{T}^{#tau}>100 GeV",
886 ]
887 cDict[ "All" ] = ROOT.TCanvas( "All" , "All" )
888 cDict[ "All" ].cd()
889 same = "A"
890 histList = []
891 if "TauGCPt020" in initialHistDict.keys():
892 histList = [ "TauGCPt020", "TauGCPt2040", "TauGCPt4060", "TauGCPt6080", "TauGCPt80100", "TauGCPt100" ]
893 else:
894 histList = initialHistDict.keys()
895 graphList = []
896 dir = dirs[ 0 ]
897 #file = sampleList[ 0 ]
898 #for hist in initialHistDict.keys():
899 for hist in histList:
900 graph[ hist ] = ROOT.TGraphAsymmErrors()
901 for i in range( 1,Mean[ hist ][ file ][ dir ].GetNbinsX() + 1 ):
902 y = Mean[ hist ][ file ][ dir ].GetBinContent( i )
903 x = Mean[ hist ][ file ][ dir ].GetBinCenter( i )
904 yerrup = ErrUp[ hist ][ file ][ dir ].GetBinContent( i )
905 yerrdwn = ErrDwn[ hist ][ file ][ dir ].GetBinContent( i )
906 binwidth = Mean[ hist ][ file ][ dir ].GetBinWidth( i )
907 graph[ hist ].SetPoint( i-1, x, y )
908 graph[ hist ].SetPointError( i-1, binwidth/2, binwidth/2, yerrdwn, yerrup )
909 pass
910 graph[ hist ].UseCurrentStyle()
911 Style.setHistStyle( graph[ hist ],
912 status="Err",
913 color=colorDict[ hist ],
914 xTitle=xtitle,
915 yTitle=ytitle,
916 title=title
917 )
918 graph[ hist ].Draw( "P" + same )
919 graphList.append( graph[ hist ] )
920 if same == "A":
921 graph[ hist ].SetMinimum( 10**-2 )
922 graph[ hist ].SetMaximum( 2*10**0 )
923 pass
924 same = "same"
925 pass
926 legDict[ hist ] = Style.makeLegendSimple( graphList,
927 legList,
928 #statusDict=statusDict,
929 style="ep",
930 position="umr" )
931 legDict[ hist ].Draw( "same" )
932 ROOT.gPad.SetLogy()
933 #ROOT.gPad.SetLogx()
934
935 ROOT.gPad.Update()
936 Def.DontQuit()
937 pass
938
939 if drawAllDirsInOneEff or drawAllDirsInOneEffVertex:
940 cDict[ "All" ] = ROOT.TCanvas( "All" , "All" )
941 cDict[ "All" ].cd()
942 same = "A"
943 graphList = []
944 hist = initialHistDict.keys()[ 0 ]
945 ytitle = "#epsilon_{#tau}^{reco}"
946 legList = [ #"No Sel",
947 "HT>50 GeV",
948 ##"HT>100 GeV",
949 "HT>150 GeV",
950 ##"HT>200 GeV",
951 "HT>250 GeV",
952 ##"HT>300 GeV",
953 "HT>350 GeV",
954 #"Red ",
955 #"Pre",
956 #"Full"
957 ]
958 if drawAllDirsInOneEffVertex:
959 legList = [ "nVertex < 6",
960 "6 <= nVertex < 10",
961 "10 <= nVertex" ]
962 pass
963 if drawAllDirsInOneEff:
964 legList = [ "H_{T} > 300 GeV",
965 "H_{T} > 350 GeV, #slashH_{T}> 250 GeV"
966 ]
967 pass
968 for dir in dirs:
969 graph[ dir ] = ROOT.TGraphAsymmErrors()
970 sub = 0
971 for i in range( 1,Mean[ hist ][ file ][ dir ].GetNbinsX() + 1 ):
972 y = Mean[ hist ][ file ][ dir ].GetBinContent( i )
973 x = Mean[ hist ][ file ][ dir ].GetBinCenter( i )
974 if x < 10 and not drawAllDirsInOneEff:
975 sub += 1
976 continue
977 yerrup = ErrUp[ hist ][ file ][ dir ].GetBinContent( i )
978 yerrdwn = ErrDwn[ hist ][ file ][ dir ].GetBinContent( i )
979 binwidth = Mean[ hist ][ file ][ dir ].GetBinWidth( i )
980 graph[ dir ].SetPoint( i-1 - sub, x, y )
981 graph[ dir ].SetPointError( i-1 - sub, binwidth/2, binwidth/2, yerrdwn, yerrup )
982 pass
983 graph[ dir ].UseCurrentStyle()
984 Style.setHistStyle( graph[ dir ],
985 status="Err",
986 color=colorDict[ dir ],
987 xTitle=xtitle,
988 yTitle=ytitle,
989 title=title
990 )
991 #graph[ dir ].GetXaxis().SetRangeUser( 9*10**0, 10**3 )
992 graph[ dir ].Draw( "P" + same )
993 if same == "A":
994 graph[ dir ].SetMinimum( 10**-3 )
995 graph[ dir ].SetMaximum( 2*10**0 )
996 pass
997 graphList.append( graph[ dir ] )
998 same = "same"
999 pass
1000 legDict[ hist ] = Style.makeLegendSimple( graphList,
1001 legList,
1002 #statusDict=statusDict,
1003 style="ep",
1004 position="umr" )
1005 legDict[ hist ].Draw( "same" )
1006 ROOT.gPad.SetLogy()
1007 #ROOT.gPad.SetLogx()
1008
1009 ROOT.gPad.Update()
1010
1011 Def.DontQuit()
1012 pass
1013
1014 if drawEffCompare:
1015 dir = dirs[ 0 ]
1016 gList1 = [ ]
1017 lList = [ "W+Jets", "t#bar{t}" ]
1018 ytitle = "#epsilon^{reco}_{#tau}"
1019 xtitle = xtitle + xtitleAdd
1020 cDict[ hist ] = ROOT.TCanvas( "Pt" , "Pt" )
1021 cDict[ hist ].cd()
1022 graph[ hist ] = {}
1023 for file in sampleList:
1024 #print file
1025 graph[ hist ][ file ] = ROOT.TGraphAsymmErrors()
1026 #for i in range( 1, Mean[ hist ][ file ][ dir ].GetNbinsX() + 1 ):
1027 for i in range( 1, Mean[ hist ][ file ][ dir ].GetNbinsX() + 1 ):
1028 y = Mean[ hist ][ file ][ dir ].GetBinContent( i )
1029 x = Mean[ hist ][ file ][ dir ].GetBinCenter( i )
1030 yerrup = ErrUp[ hist ][ file ][ dir ].GetBinContent( i )
1031 yerrdwn = ErrDwn[ hist ][ file ][ dir ].GetBinContent( i )
1032 binwidth = Mean[ hist ][ file ][ dir ].GetBinWidth( i )
1033 graph[ hist ][ file ].SetPoint( i-1, x, y )
1034 graph[ hist ][ file ].SetPointError( i-1, binwidth/2, binwidth/2, yerrdwn, yerrup )
1035 pass
1036 graph[ hist ][ file ].UseCurrentStyle()
1037 mstyle = 22
1038 #if file == "Data":
1039 # mstyle = 26
1040 # pass
1041 c = colorDict[ file ]
1042
1043 Style.setHistStyle( graph[ hist ][ file ],
1044 status="Err",
1045 color=c,
1046 xTitle=xtitle,
1047 yTitle=ytitle,
1048 title=title,
1049 markerStyle=mstyle
1050 )
1051 gList1.append( graph[ hist ][ file ] )
1052 pass
1053 #print "draw"
1054 option = "PA"
1055 for file in sampleList:
1056 graph[ hist ][ file ].Draw( option )
1057 if option == "PA":
1058 graph[ hist ][ file ].SetMinimum( 10**-3 )
1059 graph[ hist ][ file ].SetMaximum( 2*10**0 )
1060 pass
1061 option = "P"
1062 pass
1063
1064 ### i am legend
1065 legDict[ hist ] = Style.makeLegendSimple( gList1,
1066 lList,
1067 #statusDict=statusDict,
1068 style="ep",
1069 position="umr" )
1070
1071
1072 legDict[ hist ].Draw( "same" )
1073
1074 ROOT.gPad.SetLogy()
1075 #ROOT.gPad.SetLogx()
1076
1077 ROOT.gPad.Update()
1078
1079 Def.DontQuit()
1080 pass
1081
1082 if drawFakesCompare:
1083 dir = "FakeRateInvertMHTLoose/"
1084 #dir = dirs.at( 0 )
1085 gList1 = []
1086 gList2 = []
1087 if "JetTauPtJPT" in initialHistDict.keys():
1088 hist = "JetTauPtJPT"
1089 xtitle = "P_{T}^{jet} [GeV]"
1090 ytitle = "fake rate"
1091 title = "HT>350 GeV, MHT<20 GeV"
1092 cDict[ hist ] = ROOT.TCanvas( "Pt" , "Pt" )
1093 cDict[ hist ].cd()
1094 graph[ hist ] = {}
1095 for file in [ "QCDFlat", "Data" ]:
1096 graph[ hist ][ file ] = ROOT.TGraphAsymmErrors()
1097 for i in range( 1, Mean[ hist ][ file ][ dir ].GetNbinsX() + 1 ):
1098 y = Mean[ hist ][ file ][ dir ].GetBinContent( i )
1099 x = Mean[ hist ][ file ][ dir ].GetBinCenter( i )
1100 yerrup = ErrUp[ hist ][ file ][ dir ].GetBinContent( i )
1101 yerrdwn = ErrDwn[ hist ][ file ][ dir ].GetBinContent( i )
1102 binwidth = Mean[ hist ][ file ][ dir ].GetBinWidth( i )
1103 graph[ hist ][ file ].SetPoint( i-1, x, y )
1104 graph[ hist ][ file ].SetPointError( i-1, binwidth/2, binwidth/2, yerrdwn, yerrup )
1105 pass
1106 graph[ hist ][ file ].UseCurrentStyle()
1107 mstyle = 22
1108 if file == "Data":
1109 mstyle = 26
1110 pass
1111 c = colorDict[ hist ]
1112 if file == "Data":
1113 c = colorDict[ hist + file ]
1114 pass
1115 Style.setHistStyle( graph[ hist ][ file ],
1116 status="Err",
1117 color=c,
1118 xTitle=xtitle,
1119 yTitle=ytitle,
1120 title=title,
1121 markerStyle=mstyle
1122 )
1123 gList1.append( graph[ hist ][ file ] )
1124 pass
1125 graph[ hist ][ "QCDFlat" ].Draw( "PA" )
1126 graph[ hist ][ "Data" ].Draw( "P" )
1127
1128 ### i am legend
1129 legDict[ hist ] = Style.makeLegendSimple( gList1,
1130 [ "Simulation", "Data" ],
1131 #statusDict=statusDict,
1132 style="ep",
1133 position="umr" )
1134
1135
1136 legDict[ hist ].Draw( "same" )
1137
1138 ROOT.gPad.SetLogy()
1139 pass
1140
1141 if "JetTauEtaJPT" in initialHistDict.keys():
1142 hist = "JetTauEtaJPT"
1143 xtitle = "#eta^{jet}"
1144 ytitle = "fake rate"
1145 title = "HT>350 GeV, MHT<20 GeV"
1146 cDict[ hist ] = ROOT.TCanvas( "Eta" , "Eta" )
1147 cDict[ hist ].cd()
1148 graph[ hist ] = {}
1149 for file in [ "Data", "QCDFlat" ]:
1150 graph[ hist ][ file ] = ROOT.TGraphAsymmErrors()
1151 for i in range( 1, Mean[ hist ][ file ][ dir ].GetNbinsX() + 1 ):
1152 y = Mean[ hist ][ file ][ dir ].GetBinContent( i )
1153 x = Mean[ hist ][ file ][ dir ].GetBinCenter( i )
1154 yerrup = ErrUp[ hist ][ file ][ dir ].GetBinContent( i )
1155 yerrdwn = ErrDwn[ hist ][ file ][ dir ].GetBinContent( i )
1156 binwidth = Mean[ hist ][ file ][ dir ].GetBinWidth( i )
1157 graph[ hist ][ file ].SetPoint( i-1, x, y )
1158 graph[ hist ][ file ].SetPointError( i-1, binwidth/2, binwidth/2, yerrdwn, yerrup )
1159 pass
1160 graph[ hist ][ file ].UseCurrentStyle()
1161 mstyle = 22
1162 if file == "Data":
1163 mstyle = 26
1164 pass
1165 Style.setHistStyle( graph[ hist ][ file ],
1166 status="Err",
1167 color=colorDict[ hist ],
1168 xTitle=xtitle,
1169 yTitle=ytitle,
1170 title=title,
1171 markerStyle=mstyle
1172 )
1173 gList2.append( graph[ hist ][ file ] )
1174 pass
1175 graph[ hist ][ "QCDFlat" ].Draw( "PA" )
1176 graph[ hist ][ "Data" ].Draw( "P" )
1177 ROOT.gPad.SetLogy()
1178
1179 ### i am legend
1180 legDict[ hist ] = Style.makeLegendSimple( gList2,
1181 [ "QCD", "Data" ],
1182 #statusDict=statusDict,
1183 style="ep",
1184 position="umr" )
1185
1186
1187 legDict[ hist ].Draw( "same" )
1188 pass
1189
1190 if "JetTauPtJPTeta1" in initialHistDict.keys():
1191 hist = "JetTauPtJPTeta1"
1192 xtitle = "P_{T}^{jet} [GeV]"
1193 ytitle = "fake rate"
1194 title = "HT>350 GeV, MHT<20 GeV"
1195 cDict[ hist ] = ROOT.TCanvas( hist , hist )
1196 cDict[ hist ].cd()
1197 same = "A"
1198 graphList = []
1199 for h in [ "JetTauPtJPTeta1" ]:
1200 graph[ h ] = {}
1201 for file in [ "Data" , "QCDFlat" ]:
1202 graph[ h ][ file ] = ROOT.TGraphAsymmErrors()
1203 for i in range( 1, Mean[ h ][ file ][ dir ].GetNbinsX() + 1 ):
1204 y = Mean[ h ][ file ][ dir ].GetBinContent( i )
1205 x = Mean[ h ][ file ][ dir ].GetBinCenter( i )
1206 yerrup = ErrUp[ h ][ file ][ dir ].GetBinContent( i )
1207 yerrdwn = ErrDwn[ h ][ file ][ dir ].GetBinContent( i )
1208 binwidth = Mean[ h ][ file ][ dir ].GetBinWidth( i )
1209 graph[ h ][ file ].SetPoint( i-1, x, y )
1210 graph[ h ][ file ].SetPointError( i-1, binwidth/2, binwidth/2, yerrdwn, yerrup )
1211 pass
1212 graph[ h ][ file ].UseCurrentStyle()
1213 mstyle = 22
1214 if file == "Data":
1215 mstyle = 26
1216 pass
1217 c = colorDict[ h ]
1218 if file == "Data":
1219 c = colorDict[ h + file ]
1220 pass
1221 Style.setHistStyle( graph[ h ][ file ],
1222 status="Err",
1223 color=c,
1224 xTitle=xtitle,
1225 yTitle=ytitle,
1226 title=title,
1227 markerStyle=mstyle
1228 )
1229 pass
1230 graph[ h ][ "QCDFlat" ].Draw( "P" + same )
1231 if same == "A":
1232 graph[ h ][ file ].GetYaxis().SetRangeUser( 10**-5,1 )
1233 pass
1234 same = "same"
1235 graph[ h ][ "Data" ].Draw( "P" + same )
1236 graphList.append( graph[ h ][ "QCDFlat" ] )
1237 graphList.append( graph[ h ][ "Data" ] )
1238 pass
1239 pass
1240 ROOT.gPad.SetLogy()
1241 ### i am legend
1242 legDict[ hist ] = Style.makeLegendSimple( graphList,
1243 [ "Sim |#eta|<1","Data |#eta|<1" ],
1244 #statusDict=statusDict,
1245 style="ep",
1246 position="umr" )
1247
1248
1249 legDict[ hist ].Draw( "same" )
1250
1251 if "JetTauPtJPTeta2" in initialHistDict.keys():
1252 hist = "JetTauPtJPTeta2"
1253 xtitle = "P_{T}^{jet} [GeV]"
1254 ytitle = "fake rate"
1255 title = "HT>350 GeV, MHT<20 GeV"
1256 cDict[ hist ] = ROOT.TCanvas( hist , hist )
1257 cDict[ hist ].cd()
1258 same = "A"
1259 graphList = []
1260 for h in [ "JetTauPtJPTeta2" ]:
1261 graph[ h ] = {}
1262 for file in [ "Data" , "QCDFlat" ]:
1263 graph[ h ][ file ] = ROOT.TGraphAsymmErrors()
1264 for i in range( 1, Mean[ h ][ file ][ dir ].GetNbinsX() + 1 ):
1265 y = Mean[ h ][ file ][ dir ].GetBinContent( i )
1266 x = Mean[ h ][ file ][ dir ].GetBinCenter( i )
1267 yerrup = ErrUp[ h ][ file ][ dir ].GetBinContent( i )
1268 yerrdwn = ErrDwn[ h ][ file ][ dir ].GetBinContent( i )
1269 binwidth = Mean[ h ][ file ][ dir ].GetBinWidth( i )
1270 graph[ h ][ file ].SetPoint( i-1, x, y )
1271 graph[ h ][ file ].SetPointError( i-1, binwidth/2, binwidth/2, yerrdwn, yerrup )
1272 pass
1273 graph[ h ][ file ].UseCurrentStyle()
1274 mstyle = 22
1275 if file == "Data":
1276 mstyle = 26
1277 pass
1278 c = colorDict[ h ]
1279 if file == "Data":
1280 c = colorDict[ h + file ]
1281 pass
1282 Style.setHistStyle( graph[ h ][ file ],
1283 status="Err",
1284 color=c,
1285 xTitle=xtitle,
1286 yTitle=ytitle,
1287 title=title,
1288 markerStyle=mstyle
1289 )
1290 pass
1291 graph[ h ][ "QCDFlat" ].Draw( "P" + same )
1292 if same == "A":
1293 graph[ h ][ file ].GetYaxis().SetRangeUser( 10**-5,1 )
1294 pass
1295 same = "same"
1296 graph[ h ][ "Data" ].Draw( "P" + same )
1297 graphList.append( graph[ h ][ "QCDFlat" ] )
1298 graphList.append( graph[ h ][ "Data" ] )
1299 pass
1300 pass
1301 ROOT.gPad.SetLogy()
1302 ### i am legend
1303 legDict[ hist ] = Style.makeLegendSimple( graphList,
1304 [ "Sim 1<|#eta|<1.5","Data 1<|#eta|<1.5" ],
1305 #statusDict=statusDict,
1306 style="ep",
1307 position="umr" )
1308
1309
1310 legDict[ hist ].Draw( "same" )
1311
1312
1313 if "JetTauPtJPTeta25" in initialHistDict.keys():
1314 hist = "JetTauPtJPTeta25"
1315 xtitle = "P_{T}^{jet} [GeV]"
1316 ytitle = "fake rate"
1317 title = "HT>350 GeV, MHT<20 GeV"
1318 cDict[ hist ] = ROOT.TCanvas( hist , hist )
1319 cDict[ hist ].cd()
1320 same = "A"
1321 graphList = []
1322 for h in [ "JetTauPtJPTeta25" ]:
1323 graph[ h ] = {}
1324 for file in [ "Data" , "QCDFlat" ]:
1325 graph[ h ][ file ] = ROOT.TGraphAsymmErrors()
1326 for i in range( 1, Mean[ h ][ file ][ dir ].GetNbinsX() + 1 ):
1327 y = Mean[ h ][ file ][ dir ].GetBinContent( i )
1328 x = Mean[ h ][ file ][ dir ].GetBinCenter( i )
1329 yerrup = ErrUp[ h ][ file ][ dir ].GetBinContent( i )
1330 yerrdwn = ErrDwn[ h ][ file ][ dir ].GetBinContent( i )
1331 binwidth = Mean[ h ][ file ][ dir ].GetBinWidth( i )
1332 graph[ h ][ file ].SetPoint( i-1, x, y )
1333 graph[ h ][ file ].SetPointError( i-1, binwidth/2, binwidth/2, yerrdwn, yerrup )
1334 pass
1335 graph[ h ][ file ].UseCurrentStyle()
1336 mstyle = 22
1337 if file == "Data":
1338 mstyle = 26
1339 pass
1340 c = colorDict[ h ]
1341 if file == "Data":
1342 c = colorDict[ h + file ]
1343 pass
1344 Style.setHistStyle( graph[ h ][ file ],
1345 status="Err",
1346 color=c,
1347 xTitle=xtitle,
1348 yTitle=ytitle,
1349 title=title,
1350 markerStyle=mstyle
1351 )
1352 pass
1353 graph[ h ][ "QCDFlat" ].Draw( "P" + same )
1354 if same == "A":
1355 graph[ h ][ file ].GetYaxis().SetRangeUser( 10**-5,1 )
1356 pass
1357 same = "same"
1358 graph[ h ][ "Data" ].Draw( "P" + same )
1359 graphList.append( graph[ h ][ "QCDFlat" ] )
1360 graphList.append( graph[ h ][ "Data" ] )
1361 pass
1362 pass
1363 ROOT.gPad.SetLogy()
1364 ### i am legend
1365 legDict[ hist ] = Style.makeLegendSimple( graphList,
1366 [ "Sim 1.5<|#eta|<2.1", "Data 1.5<|#eta|<2.1" ],
1367 #statusDict=statusDict,
1368 style="ep",
1369 position="umr" )
1370
1371
1372 legDict[ hist ].Draw( "same" )
1373
1374
1375 gList4 = []
1376 if "NVertexTau" in initialHistDict.keys():
1377 hist = "NVertexTau"
1378 xtitle = "number of vertices"
1379 ytitle = "fake rate"
1380 title = "HT>350 GeV, MHT<20 GeV"
1381 cDict[ hist ] = ROOT.TCanvas( "nVertex" , "nVertex" )
1382 cDict[ hist ].cd()
1383 graph[ hist ] = {}
1384 for file in [ "QCDFlat", "Data" ]:
1385 graph[ hist ][ file ] = ROOT.TGraphAsymmErrors()
1386 for i in range( 1, Mean[ hist ][ file ][ dir ].GetNbinsX() + 1 ):
1387 y = Mean[ hist ][ file ][ dir ].GetBinContent( i )
1388 x = Mean[ hist ][ file ][ dir ].GetBinCenter( i )
1389 yerrup = ErrUp[ hist ][ file ][ dir ].GetBinContent( i )
1390 yerrdwn = ErrDwn[ hist ][ file ][ dir ].GetBinContent( i )
1391 binwidth = Mean[ hist ][ file ][ dir ].GetBinWidth( i )
1392 graph[ hist ][ file ].SetPoint( i-1, x, y )
1393 graph[ hist ][ file ].SetPointError( i-1, binwidth/2, binwidth/2, yerrdwn, yerrup )
1394 pass
1395 graph[ hist ][ file ].UseCurrentStyle()
1396 mstyle = 22
1397 if file == "Data":
1398 mstyle = 26
1399 pass
1400 c = colorDict[ hist ]
1401 if file == "Data":
1402 c = colorDict[ hist + file ]
1403 pass
1404 Style.setHistStyle( graph[ hist ][ file ],
1405 status="Err",
1406 color=c,
1407 xTitle=xtitle,
1408 yTitle=ytitle,
1409 title=title,
1410 markerStyle=mstyle
1411 )
1412 gList4.append( graph[ hist ][ file ] )
1413 pass
1414 graph[ hist ][ "QCDFlat" ].Draw( "PA" )
1415 graph[ hist ][ "Data" ].Draw( "P" )
1416
1417 ### i am legend
1418 legDict[ hist ] = Style.makeLegendSimple( gList4,
1419 [ "Simulation", "Data" ],
1420 #statusDict=statusDict,
1421 style="ep",
1422 position="umr" )
1423
1424
1425 legDict[ hist ].Draw( "same" )
1426
1427 ROOT.gPad.SetLogy()
1428 pass
1429
1430
1431 Def.DontQuit()
1432 pass
1433
1434 if drawFakes:
1435 file = "QCDFlat"
1436 #file = "ZJets"
1437 #file = "WZJets"
1438 #file = "Zinv"
1439 if isData:
1440 file = "Data"
1441 pass
1442 dir = "FakeRateInvertMHTLoose/"
1443 dir = dirs[ 0 ]
1444 if "JetTauPtJPT" in initialHistDict.keys():
1445 hist = "JetTauPtJPT"
1446 xtitle = "P_{T}^{jet} [GeV]"
1447 ytitle = "fake rate"
1448 title = "QCD simulation, H_{T}>350 GeV, #slashH_{T}<20 GeV"
1449 #title = "ZJets simulation, HT>350 GeV, MHT<20 GeV"
1450 if isData:
1451 title = "Data, HT>350 GeV, MHT<20 GeV"
1452 pass
1453 cDict[ hist ] = ROOT.TCanvas( "Pt" , "Pt" )
1454 cDict[ hist ].cd()
1455 graph[ hist ] = ROOT.TGraphAsymmErrors()
1456 for i in range( 1, Mean[ hist ][ file ][ dir ].GetNbinsX() + 1 ):
1457 y = Mean[ hist ][ file ][ dir ].GetBinContent( i )
1458 x = Mean[ hist ][ file ][ dir ].GetBinCenter( i )
1459 yerrup = ErrUp[ hist ][ file ][ dir ].GetBinContent( i )
1460 yerrdwn = ErrDwn[ hist ][ file ][ dir ].GetBinContent( i )
1461 binwidth = Mean[ hist ][ file ][ dir ].GetBinWidth( i )
1462 graph[ hist ].SetPoint( i-1, x, y )
1463 graph[ hist ].SetPointError( i-1, binwidth/2, binwidth/2, yerrdwn, yerrup )
1464 pass
1465 graph[ hist ].UseCurrentStyle()
1466 Style.setHistStyle( graph[ hist ],
1467 status="Err",
1468 color=colorDict[ hist ],
1469 xTitle=xtitle,
1470 yTitle=ytitle,
1471 title=title
1472 )
1473 graph[ hist ].Draw( "PA" )
1474 ROOT.gPad.SetLogy()
1475 pass
1476
1477 if "JetTauDist" in initialHistDict.keys():
1478 hist = "JetTauDist"
1479 xtitle = "#Delta R(tau,jet)"
1480 ytitle = "fake rate"
1481 #title = "QCD simulation, HT>350 GeV, MHT<20 GeV"
1482 title = "ZJets simulation, HT>350 GeV, MHT<20 GeV"
1483 if isData:
1484 title = "Data, HT>350 GeV, MHT<20 GeV"
1485 pass
1486 cDict[ hist ] = ROOT.TCanvas( "Dis" , "Dist" )
1487 cDict[ hist ].cd()
1488 graph[ hist ] = ROOT.TGraphAsymmErrors()
1489 for i in range( 1, Mean[ hist ][ file ][ dir ].GetNbinsX() + 1 ):
1490 y = Mean[ hist ][ file ][ dir ].GetBinContent( i )
1491 x = Mean[ hist ][ file ][ dir ].GetBinCenter( i )
1492 yerrup = ErrUp[ hist ][ file ][ dir ].GetBinContent( i )
1493 yerrdwn = ErrDwn[ hist ][ file ][ dir ].GetBinContent( i )
1494 binwidth = Mean[ hist ][ file ][ dir ].GetBinWidth( i )
1495 graph[ hist ].SetPoint( i-1, x, y )
1496 graph[ hist ].SetPointError( i-1, binwidth/2, binwidth/2, yerrdwn, yerrup )
1497 pass
1498 graph[ hist ].UseCurrentStyle()
1499 Style.setHistStyle( graph[ hist ],
1500 status="Err",
1501 color=colorDict[ hist ],
1502 xTitle=xtitle,
1503 yTitle=ytitle,
1504 title=title
1505 )
1506 graph[ hist ].Draw( "PA" )
1507 ROOT.gPad.SetLogy()
1508 pass
1509
1510 if "JetTauIso" in initialHistDict.keys():
1511 hist = "JetTauIso"
1512 xtitle = "tau particle isolation"
1513 ytitle = "fake rate"
1514 #title = "QCD simulation, HT>350 GeV, MHT<20 GeV"
1515 title = "ZJets simulation, HT>350 GeV, MHT<20 GeV"
1516 if isData:
1517 title = "Data, HT>350 GeV, MHT<20 GeV"
1518 pass
1519 cDict[ hist ] = ROOT.TCanvas( "Iso" , "Iso" )
1520 cDict[ hist ].cd()
1521 graph[ hist ] = ROOT.TGraphAsymmErrors()
1522 for i in range( 1, Mean[ hist ][ file ][ dir ].GetNbinsX() + 1 ):
1523 y = Mean[ hist ][ file ][ dir ].GetBinContent( i )
1524 x = Mean[ hist ][ file ][ dir ].GetBinCenter( i )
1525 yerrup = ErrUp[ hist ][ file ][ dir ].GetBinContent( i )
1526 yerrdwn = ErrDwn[ hist ][ file ][ dir ].GetBinContent( i )
1527 binwidth = Mean[ hist ][ file ][ dir ].GetBinWidth( i )
1528 graph[ hist ].SetPoint( i-1, x, y )
1529 graph[ hist ].SetPointError( i-1, binwidth/2, binwidth/2, yerrdwn, yerrup )
1530 pass
1531 graph[ hist ].UseCurrentStyle()
1532 Style.setHistStyle( graph[ hist ],
1533 status="Err",
1534 color=colorDict[ hist ],
1535 xTitle=xtitle,
1536 yTitle=ytitle,
1537 title=title
1538 )
1539 graph[ hist ].Draw( "PA" )
1540 ROOT.gPad.SetLogy()
1541 pass
1542
1543 if "JetTauIsoRel" in initialHistDict.keys():
1544 hist = "JetTauIsoRel"
1545 xtitle = "tau particle isolation / tau pt"
1546 ytitle = "fake rate"
1547 #title = "QCD simulation, HT>350 GeV, MHT<20 GeV"
1548 title = "ZJets simulation, HT>350 GeV, MHT<20 GeV"
1549 if isData:
1550 title = "Data, HT>350 GeV, MHT<20 GeV"
1551 pass
1552 cDict[ hist ] = ROOT.TCanvas( "IsoRel" , "IsoRel" )
1553 cDict[ hist ].cd()
1554 graph[ hist ] = ROOT.TGraphAsymmErrors()
1555 for i in range( 1, Mean[ hist ][ file ][ dir ].GetNbinsX() + 1 ):
1556 y = Mean[ hist ][ file ][ dir ].GetBinContent( i )
1557 x = Mean[ hist ][ file ][ dir ].GetBinCenter( i )
1558 yerrup = ErrUp[ hist ][ file ][ dir ].GetBinContent( i )
1559 yerrdwn = ErrDwn[ hist ][ file ][ dir ].GetBinContent( i )
1560 binwidth = Mean[ hist ][ file ][ dir ].GetBinWidth( i )
1561 graph[ hist ].SetPoint( i-1, x, y )
1562 graph[ hist ].SetPointError( i-1, binwidth/2, binwidth/2, yerrdwn, yerrup )
1563 pass
1564 graph[ hist ].UseCurrentStyle()
1565 Style.setHistStyle( graph[ hist ],
1566 status="Err",
1567 color=colorDict[ hist ],
1568 xTitle=xtitle,
1569 yTitle=ytitle,
1570 title=title
1571 )
1572 graph[ hist ].Draw( "PA" )
1573 ROOT.gPad.SetLogy()
1574 pass
1575
1576 if "JetTauNCharged" in initialHistDict.keys():
1577 hist = "JetTauNCharged"
1578 xtitle = "n(charged hadrons) in iso cone"
1579 ytitle = "fake rate"
1580 title = "QCD simulation, HT>350 GeV, MHT<20 GeV"
1581 if isData:
1582 title = "Data, HT>350 GeV, MHT<20 GeV"
1583 pass
1584 cDict[ hist ] = ROOT.TCanvas( "NC" , "NC" )
1585 cDict[ hist ].cd()
1586 graph[ hist ] = ROOT.TGraphAsymmErrors()
1587 for i in range( 1, Mean[ hist ][ file ][ dir ].GetNbinsX() + 1 ):
1588 y = Mean[ hist ][ file ][ dir ].GetBinContent( i )
1589 x = Mean[ hist ][ file ][ dir ].GetBinCenter( i )
1590 yerrup = ErrUp[ hist ][ file ][ dir ].GetBinContent( i )
1591 yerrdwn = ErrDwn[ hist ][ file ][ dir ].GetBinContent( i )
1592 binwidth = Mean[ hist ][ file ][ dir ].GetBinWidth( i )
1593 graph[ hist ].SetPoint( i-1, x, y )
1594 graph[ hist ].SetPointError( i-1, binwidth/2, binwidth/2, yerrdwn, yerrup )
1595 pass
1596 graph[ hist ].UseCurrentStyle()
1597 Style.setHistStyle( graph[ hist ],
1598 status="Err",
1599 color=colorDict[ hist ],
1600 xTitle=xtitle,
1601 yTitle=ytitle,
1602 title=title
1603 )
1604 graph[ hist ].Draw( "PA" )
1605 ROOT.gPad.SetLogy()
1606 pass
1607
1608 if "JetTauNGamma" in initialHistDict.keys():
1609 hist = "JetTauNGamma"
1610 xtitle = "n(gamma cand) in iso cone"
1611 ytitle = "fake rate"
1612 title = "QCD simulation, HT>350 GeV, MHT<20 GeV"
1613 if isData:
1614 title = "Data, HT>350 GeV, MHT<20 GeV"
1615 pass
1616 cDict[ hist ] = ROOT.TCanvas( "NG" , "NG" )
1617 cDict[ hist ].cd()
1618 graph[ hist ] = ROOT.TGraphAsymmErrors()
1619 for i in range( 1, Mean[ hist ][ file ][ dir ].GetNbinsX() + 1 ):
1620 y = Mean[ hist ][ file ][ dir ].GetBinContent( i )
1621 x = Mean[ hist ][ file ][ dir ].GetBinCenter( i )
1622 yerrup = ErrUp[ hist ][ file ][ dir ].GetBinContent( i )
1623 yerrdwn = ErrDwn[ hist ][ file ][ dir ].GetBinContent( i )
1624 binwidth = Mean[ hist ][ file ][ dir ].GetBinWidth( i )
1625 graph[ hist ].SetPoint( i-1, x, y )
1626 graph[ hist ].SetPointError( i-1, binwidth/2, binwidth/2, yerrdwn, yerrup )
1627 pass
1628 graph[ hist ].UseCurrentStyle()
1629 Style.setHistStyle( graph[ hist ],
1630 status="Err",
1631 color=colorDict[ hist ],
1632 xTitle=xtitle,
1633 yTitle=ytitle,
1634 title=title
1635 )
1636 graph[ hist ].Draw( "PA" )
1637 ROOT.gPad.SetLogy()
1638 pass
1639
1640 if "JetTauNNeutral" in initialHistDict.keys():
1641 hist = "JetTauNNeutral"
1642 xtitle = "n(neutral hadrons) in iso cone"
1643 ytitle = "fake rate"
1644 title = "QCD simulation, HT>350 GeV, MHT<20 GeV"
1645 if isData:
1646 title = "Data, HT>350 GeV, MHT<20 GeV"
1647 pass
1648 cDict[ hist ] = ROOT.TCanvas( "NN" , "NN" )
1649 cDict[ hist ].cd()
1650 graph[ hist ] = ROOT.TGraphAsymmErrors()
1651 for i in range( 1, Mean[ hist ][ file ][ dir ].GetNbinsX() + 1 ):
1652 y = Mean[ hist ][ file ][ dir ].GetBinContent( i )
1653 x = Mean[ hist ][ file ][ dir ].GetBinCenter( i )
1654 yerrup = ErrUp[ hist ][ file ][ dir ].GetBinContent( i )
1655 yerrdwn = ErrDwn[ hist ][ file ][ dir ].GetBinContent( i )
1656 binwidth = Mean[ hist ][ file ][ dir ].GetBinWidth( i )
1657 graph[ hist ].SetPoint( i-1, x, y )
1658 graph[ hist ].SetPointError( i-1, binwidth/2, binwidth/2, yerrdwn, yerrup )
1659 pass
1660 graph[ hist ].UseCurrentStyle()
1661 Style.setHistStyle( graph[ hist ],
1662 status="Err",
1663 color=colorDict[ hist ],
1664 xTitle=xtitle,
1665 yTitle=ytitle,
1666 title=title
1667 )
1668 graph[ hist ].Draw( "PA" )
1669 ROOT.gPad.SetLogy()
1670 pass
1671
1672 if "JetTauNCPlusG" in initialHistDict.keys():
1673 hist = "JetTauNCPlusG"
1674 xtitle = "n(charged + gamma) in iso cone"
1675 ytitle = "fake rate"
1676 title = "QCD simulation, HT>350 GeV, MHT<20 GeV"
1677 if isData:
1678 title = "Data, HT>350 GeV, MHT<20 GeV"
1679 pass
1680 cDict[ hist ] = ROOT.TCanvas( "NCG" , "NCG" )
1681 cDict[ hist ].cd()
1682 graph[ hist ] = ROOT.TGraphAsymmErrors()
1683 for i in range( 1, Mean[ hist ][ file ][ dir ].GetNbinsX() + 1 ):
1684 y = Mean[ hist ][ file ][ dir ].GetBinContent( i )
1685 x = Mean[ hist ][ file ][ dir ].GetBinCenter( i )
1686 yerrup = ErrUp[ hist ][ file ][ dir ].GetBinContent( i )
1687 yerrdwn = ErrDwn[ hist ][ file ][ dir ].GetBinContent( i )
1688 binwidth = Mean[ hist ][ file ][ dir ].GetBinWidth( i )
1689 graph[ hist ].SetPoint( i-1, x, y )
1690 graph[ hist ].SetPointError( i-1, binwidth/2, binwidth/2, yerrdwn, yerrup )
1691 pass
1692 graph[ hist ].UseCurrentStyle()
1693 Style.setHistStyle( graph[ hist ],
1694 status="Err",
1695 color=colorDict[ hist ],
1696 xTitle=xtitle,
1697 yTitle=ytitle,
1698 title=title
1699 )
1700 graph[ hist ].Draw( "PA" )
1701 ROOT.gPad.SetLogy()
1702 pass
1703
1704 if "JetTauEtaJPT" in initialHistDict.keys():
1705 hist = "JetTauEtaJPT"
1706 xtitle = "#eta^{jet}"
1707 ytitle = "fake rate"
1708 #title = "QCD simulation, HT>350 GeV, MHT<20 GeV"
1709 title = "ZJets simulation, HT>350 GeV, MHT<20 GeV"
1710 cDict[ hist ] = ROOT.TCanvas( "Eta" , "Eta" )
1711 cDict[ hist ].cd()
1712 graph[ hist ] = ROOT.TGraphAsymmErrors()
1713 for i in range( 1, Mean[ hist ][ file ][ dir ].GetNbinsX() + 1 ):
1714 y = Mean[ hist ][ file ][ dir ].GetBinContent( i )
1715 x = Mean[ hist ][ file ][ dir ].GetBinCenter( i )
1716 yerrup = ErrUp[ hist ][ file ][ dir ].GetBinContent( i )
1717 yerrdwn = ErrDwn[ hist ][ file ][ dir ].GetBinContent( i )
1718 binwidth = Mean[ hist ][ file ][ dir ].GetBinWidth( i )
1719 graph[ hist ].SetPoint( i-1, x, y )
1720 graph[ hist ].SetPointError( i-1, binwidth/2, binwidth/2, yerrdwn, yerrup )
1721 pass
1722 graph[ hist ].UseCurrentStyle()
1723 Style.setHistStyle( graph[ hist ],
1724 status="Err",
1725 color=colorDict[ hist ],
1726 xTitle=xtitle,
1727 yTitle=ytitle,
1728 title=title
1729 )
1730 graph[ hist ].Draw( "PA" )
1731 ROOT.gPad.SetLogy()
1732 pass
1733
1734 if "JetTauPtJPTeta1" in initialHistDict.keys():
1735 hist = "JetTauPtJPTeta1"
1736 xtitle = "P_{T}^{jet} [GeV]"
1737 ytitle = "fake rate"
1738 #title = "QCD simulation, HT>350 GeV, MHT<20 GeV"
1739 title = "ZJets simulation, HT>350 GeV, MHT<20 GeV"
1740 cDict[ hist ] = ROOT.TCanvas( "PtBinned" , "PtBinned" )
1741 cDict[ hist ].cd()
1742 same = "A"
1743 graphList = []
1744 statusDict = {}
1745 for h in [ "JetTauPtJPTeta1", "JetTauPtJPTeta2", "JetTauPtJPTeta25" ]:
1746 graph[ h ] = ROOT.TGraphAsymmErrors()
1747 graph[ h ].SetPoint( 0, 0, 0 )
1748 for i in range( 1, Mean[ h ][ file ][ dir ].GetNbinsX() + 1 ):
1749 y = Mean[ h ][ file ][ dir ].GetBinContent( i )
1750 x = Mean[ h ][ file ][ dir ].GetBinCenter( i )
1751 yerrup = ErrUp[ h ][ file ][ dir ].GetBinContent( i )
1752 yerrdwn = ErrDwn[ h ][ file ][ dir ].GetBinContent( i )
1753 binwidth = Mean[ h ][ file ][ dir ].GetBinWidth( i )
1754 graph[ h ].SetPoint( i, x, y )
1755 graph[ h ].SetPointError( i, binwidth/2, binwidth/2, yerrdwn, yerrup )
1756 pass
1757 graph[ h ].UseCurrentStyle()
1758 Style.setHistStyle( graph[ h ],
1759 status="Err",
1760 color=colorDict[ h ],
1761 xTitle=xtitle,
1762 yTitle=ytitle,
1763 title=title
1764 )
1765 graph[ h ].Draw( "P" + same )
1766 if same == "A":
1767 graph[ h ].GetYaxis().SetRangeUser( 10**-5,1 )
1768 same = "same"
1769 graphList.append( graph[ h ] )
1770 #statusDict[ h ] = "Err"
1771 pass
1772 ROOT.gPad.SetLogy()
1773 ### i am legend
1774 legDict[ hist ] = Style.makeLegendSimple( graphList,
1775 [ "|#eta|<1", "1<|#eta|<1.5", "1.5<|#eta|<2.1" ],
1776 #statusDict=statusDict,
1777 style="ep",
1778 position="umr" )
1779
1780
1781 legDict[ hist ].Draw( "same" )
1782
1783
1784 pass
1785
1786 if "JetTauGCPt020" in initialHistDict.keys():
1787 hist = "JetTauGCPt030"
1788 xtitle = "N^{G} + N^{C}"
1789 ytitle = "fake rate"
1790 #title = "QCD simulation, HT>350 GeV, MHT<20 GeV"
1791 title = "QCD simulation, H_{T}>350 GeV, #slashH_{T}<20 GeV"
1792 #title = "ZJets simulation, HT>350 GeV, MHT<20 GeV"
1793 cDict[ hist ] = ROOT.TCanvas( "GC" , "GC" )
1794 cDict[ hist ].cd()
1795 same = "A"
1796 graphList = []
1797 statusDict = {}
1798 for h in [ "JetTauGCPt020","JetTauGCPt2030", "JetTauGCPt3050", "JetTauGCPt50100", "JetTauGCPt100" ]:
1799 graph[ h ] = ROOT.TGraphAsymmErrors()
1800 graph[ h ].SetPoint( 0, 0, 0 )
1801 for i in range( 1, Mean[ h ][ file ][ dir ].GetNbinsX() + 1 ):
1802 y = Mean[ h ][ file ][ dir ].GetBinContent( i )
1803 x = Mean[ h ][ file ][ dir ].GetBinCenter( i )
1804 yerrup = ErrUp[ h ][ file ][ dir ].GetBinContent( i )
1805 yerrdwn = ErrDwn[ h ][ file ][ dir ].GetBinContent( i )
1806 binwidth = Mean[ h ][ file ][ dir ].GetBinWidth( i )
1807 graph[ h ].SetPoint( i, x, y )
1808 graph[ h ].SetPointError( i, binwidth/2, binwidth/2, yerrdwn, yerrup )
1809 pass
1810 graph[ h ].UseCurrentStyle()
1811 Style.setHistStyle( graph[ h ],
1812 status="Err",
1813 color=colorDict[ h ],
1814 xTitle=xtitle,
1815 yTitle=ytitle,
1816 title=title
1817 )
1818 graph[ h ].Draw( "P" + same )
1819 if same == "A":
1820 graph[ h ].GetYaxis().SetRangeUser( 10**-5,1 )
1821 same = "same"
1822 graphList.append( graph[ h ] )
1823 #statusDict[ h ] = "Err"
1824 pass
1825 ROOT.gPad.SetLogy()
1826 ### i am legend
1827 legDict[ hist ] = Style.makeLegendSimple( graphList,
1828 [ "P_{T}^{jet}<20 GeV", "20<P_{T}^{jet}<30 GeV","30<P_{T}^{jet}<50 GeV","50<P_{T}^{jet}<100 GeV", "100<P_{T}^{jet}", ],
1829 #statusDict=statusDict,
1830 style="ep",
1831 position="umr" )
1832
1833
1834 legDict[ hist ].Draw( "same" )
1835
1836
1837 pass
1838
1839 if "JetTauEtaJPTPt20" in initialHistDict.keys():
1840 hist = "JetTauEtaJPTPt20"
1841 xtitle = "#eta^{jet}"
1842 ytitle = "fake rate"
1843 #title = "QCD simulation, HT>350 GeV, MHT<20 GeV"
1844 title = "ZJets simulation, HT>350 GeV, MHT<20 GeV"
1845 cDict[ hist ] = ROOT.TCanvas( "EtaBinned" , "EtaBinned" )
1846 cDict[ hist ].cd()
1847 same = "A"
1848 graphList = []
1849 statusDict = {}
1850 for h in [ "JetTauEtaJPTPt20", "JetTauEtaJPTPt40", "JetTauEtaJPTPt60",
1851 "JetTauEtaJPTPt80", "JetTauEtaJPTPt100", "JetTauEtaJPTPt200",
1852 "JetTauEtaJPTPt500", "JetTauEtaJPTPtInf"]:
1853 graph[ h ] = ROOT.TGraphAsymmErrors()
1854 for i in range( 1, Mean[ h ][ file ][ dir ].GetNbinsX() + 1 ):
1855 y = Mean[ h ][ file ][ dir ].GetBinContent( i )
1856 x = Mean[ h ][ file ][ dir ].GetBinCenter( i )
1857 yerrup = ErrUp[ h ][ file ][ dir ].GetBinContent( i )
1858 yerrdwn = ErrDwn[ h ][ file ][ dir ].GetBinContent( i )
1859 binwidth = Mean[ h ][ file ][ dir ].GetBinWidth( i )
1860 graph[ h ].SetPoint( i-1, x, y )
1861 graph[ h ].SetPointError( i-1, binwidth/2, binwidth/2, yerrdwn, yerrup )
1862 pass
1863 graph[ h ].UseCurrentStyle()
1864 Style.setHistStyle( graph[ h ],
1865 status="Err",
1866 color=colorDict[ h ],
1867 xTitle=xtitle,
1868 yTitle=ytitle,
1869 title=title
1870 )
1871 graph[ h ].Draw( "P" + same )
1872 if same == "A":
1873 graph[ h ].GetYaxis().SetRangeUser( 10**-5,1 )
1874 same = "same"
1875 graphList.append( graph[ h ] )
1876 #statusDict[ h ] = "Err"
1877 pass
1878 ROOT.gPad.SetLogy()
1879 ### i am legend
1880 legDict[ hist ] = Style.makeLegendSimple( graphList,
1881 [ "P_{T}<20 GeV", "20<P_{T}<40 GeV", "40<P_{T}<60 GeV",
1882 "60<P_{T}<80 GeV", "80<P_{T}<100 GeV", "100<P_{T}<200 GeV",
1883 "200<P_{T}<500 GeV", "P_{T}>500 GeV" ],
1884 #statusDict=statusDict,
1885 style="ep",
1886 position="umr" )
1887
1888
1889 legDict[ hist ].Draw( "same" )
1890 pass
1891
1892 if "JetTauPtJPTLV" in initialHistDict.keys():
1893 hist = "JetTauPtJPTLV"
1894 xtitle = "P_{T}^{jet} [GeV]"
1895 ytitle = "fake rate"
1896 title = "QCD simulation, HT>350 GeV, MHT<20 GeV"
1897 cDict[ hist ] = ROOT.TCanvas( "VPtBinned" , "VPtBinned" )
1898 cDict[ hist ].cd()
1899 same = "A"
1900 graphList = []
1901 statusDict = {}
1902 for h in [ "JetTauPtJPTLV", "JetTauPtJPTMV", "JetTauPtJPTHV" ]:
1903 graph[ h ] = ROOT.TGraphAsymmErrors()
1904 for i in range( 1, Mean[ h ][ file ][ dir ].GetNbinsX() + 1 ):
1905 y = Mean[ h ][ file ][ dir ].GetBinContent( i )
1906 x = Mean[ h ][ file ][ dir ].GetBinCenter( i )
1907 yerrup = ErrUp[ h ][ file ][ dir ].GetBinContent( i )
1908 yerrdwn = ErrDwn[ h ][ file ][ dir ].GetBinContent( i )
1909 binwidth = Mean[ h ][ file ][ dir ].GetBinWidth( i )
1910 graph[ h ].SetPoint( i-1, x, y )
1911 graph[ h ].SetPointError( i-1, binwidth/2, binwidth/2, yerrdwn, yerrup )
1912 pass
1913 graph[ h ].UseCurrentStyle()
1914 Style.setHistStyle( graph[ h ],
1915 status="Err",
1916 color=colorDict[ h ],
1917 xTitle=xtitle,
1918 yTitle=ytitle,
1919 title=title
1920 )
1921 graph[ h ].Draw( "P" + same )
1922 if same == "A":
1923 graph[ h ].GetYaxis().SetRangeUser( 10**-5,1 )
1924 same = "same"
1925 graphList.append( graph[ h ] )
1926 #statusDict[ h ] = "Err"
1927 pass
1928 ROOT.gPad.SetLogy()
1929 ### i am legend
1930 legDict[ hist ] = Style.makeLegendSimple( graphList,
1931 [ "nVertex < 6", "6=<nVertex<10", "10<=nVertex" ],
1932 #statusDict=statusDict,
1933 style="ep",
1934 position="umr" )
1935
1936
1937 legDict[ hist ].Draw( "same" )
1938
1939
1940 pass
1941
1942 Def.DontQuit()
1943 pass
1944
1945 if not fileName == None:
1946 for file in sampleList:
1947 newrootfile = ROOT.TFile( fileName, "RECREATE" )
1948 for dir in dirs:
1949 newrootfile.mkdir( dir.split( "/" )[ 0 ] )
1950 thedir = newrootfile.GetDirectory( dir )
1951 for hist in initialHistDict.keys():
1952 Mean[ hist ][ file ][ dir ].SetName( hist )
1953 ErrUp[ hist ][ file ][ dir ].SetName( hist + "ErrUp" )
1954 ErrDwn[ hist ][ file ][ dir ].SetName( hist + "ErrDwn" )
1955 Mean[ hist ][ file ][ dir ].SetDirectory( thedir )
1956 ErrUp[ hist ][ file ][ dir ].SetDirectory( thedir )
1957 ErrDwn[ hist ][ file ][ dir ].SetDirectory( thedir )
1958 pass
1959 thedir.Write()
1960 pass
1961 newrootfile.Close()
1962 pass
1963 pass
1964