ViewVC Help
View File | Revision Log | Show Annotations | Root Listing
root/cvsroot/UserCode/nowaf/RootFilesInUse/MakeFakeTauEst.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, math
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 MakeRealTauEst_cff as Helper
7 from copy import deepcopy
8
9 if __name__ == "__main__":
10
11 #fileDir = "/afs/naf.desy.de/group/cms/scratch/nowaf/CMSSW_4_2_4/src/RA2/Configuration/FinalPlots/"
12 fileDir = "/scratch/hh/lustre/cms/user/nowaf/2011Data/VersionII/Plots/RealTauEst/"
13 #fileDir = "/scratch/hh/lustre/cms/user/nowaf/2011Data/VersionII/Plots/QCDFlat_fakes_xxviii/"
14 #fileDir = "/scratch/hh/lustre/cms/user/nowaf/2011Data/VersionII/Plots/Data_fakes_xxviii/"
15
16 theTheTitle = "QCD Simulation only, L = " + str( int( 1 ) ) + " fb^{-1}, #sqrt{s} = 7 TeV"
17 #theTheTitle = "Data, H_{T}>350 GeV, 20<#slashH_{T}<40 GeV"
18 #theTheTitle = "CMS Preliminary, H_{T}>350 GeV, 20<#slashH_{T}<40 GeV"
19 #theTheTitle = "CMS Preliminary, H_{T}>350 GeV, 60<#slashH_{T}<80 GeV"
20 #theTheTitle = "CMS Simulation, L = " + str( int( 1 ) ) + " fb^{-1}, #sqrt{s} = 7 TeV"
21
22 #fileName = "_cviii"
23 fileName = "_clxix"
24 #fileName = "_fakes_xxviii"
25
26
27 #Type = "Pre"
28 Type = "Full"
29 #Type = "PreCheck"
30
31 draw = False
32 saveToEPS = False
33 saveToPS = False
34
35 plotRatio = False
36 displayNEvents = False
37 plotTitle = True
38 doSystScaling = False
39 statErrsOnly = False
40 displayControlPlots = False
41
42 Def.SetGlobalStyles( withTitle=plotTitle )
43 if re.search( "slash", theTheTitle ):
44 #ROOT.gStyle.SetTitleFontSize( 0.02 )
45 ROOT.gStyle.SetTitleH( 0.032 )
46 if re.search( "Preliminary", theTheTitle ):
47 ROOT.gStyle.SetTitleH( 0.030 )
48 pass
49 pass
50
51 roundTo = 2
52 if Type == "Pre":
53 roundTo = 1
54 pass
55
56 eta = False
57 all = False
58 pre = False
59 inv = True
60 f2d = True
61
62 ### always false currently
63 relIso = False
64
65 add = "Dijets"
66 if all:
67 add = "All"
68 pass
69 if pre:
70 add = "BaseLine"
71 pass
72 if inv:
73 add ="InvertMHT"
74 pass
75
76 add2 = "1D"
77 if f2d:
78 add2 = "2D"
79 pass
80
81 add3 = "Pt"
82 if eta:
83 add3 = "eta"
84 pass
85 if relIso:
86 add3 = "relIso"
87 pass
88
89
90 #mcColor = ROOT.kRed - 9
91 #errColor = ROOT.kRed + 2
92 mcColor = ROOT.kCyan+2
93 errColor = ROOT.kGreen - 9
94
95 logY = True
96
97 removeSamples = []
98 #removeSamples.append( "TTbar" )
99 removeSamples.append( "GVJets" )
100 #removeSamples.append( "WWJets" )
101 #removeSamples.append( "Zinv" )
102 #removeSamples.append( "ZJets" )
103 #removeSamples.append( "WJets" )
104 #removeSamples.append( "QCDFlat" )
105 removeSamples.append( "Data" )
106
107 addSamples = []
108 #addSamples.append( "LM13" )
109 #addSamples.append( "LM2" )
110 #addSamples.append( "LM8" )
111
112 ### currently: All the same
113 #removeSamples = removeSamplesAcc ### alias
114 removeSamplesSel = removeSamples[:] ### clone
115 if Type == "Full":
116 removeSamplesSel.append( "ZJets" )
117 ##removeSamplesSel.append( "GVJets" )
118 removeSamplesSel.append( "WWJets" )
119 pass
120
121
122 saveName = "plots/FakeTauEst/final/FakeTauEst_MCClosure_" + add + "_" + add3 + "_" + add2 + fileName + "_" + Type
123 if re.search( "Preliminary", theTheTitle ):
124 saveName = saveName + "_CMSPrelim"
125 pass
126 if re.search( "CMS Simulation", theTheTitle ):
127 saveName = saveName + "_CMSSim"
128 pass
129
130 yRangeDict = {}
131 yRangeDict[ "MHT" ] = ( 6*10**-2, 10**3 )
132 yRangeDict[ "HT" ] = ( 6*10**-2, 10**3 )
133 yRangeDict[ "JetPt" ] = ( 6*10**-2, 10**3 )
134 yRangeDict[ "JetEta" ] = ( 6*10**-2, 10**4 )
135 yRangeDict[ "Jet1Pt" ] = ( 6*10**-2, 10**3 )
136 yRangeDict[ "Jet1Eta" ] = ( 6*10**-2, 10**4 )
137 yRangeDict[ "Jet2Pt" ] = ( 6*10**-2, 10**3 )
138 yRangeDict[ "Jet2Eta" ] = ( 6*10**-2, 10**4 )
139 yRangeDict[ "Jet3Pt" ] = ( 6*10**-2, 10**3 )
140 yRangeDict[ "Jet3Eta" ] = ( 6*10**-2, 10**4 )
141 yRangeDict[ "nJets" ] = ( 6*10**-2, 10**3 )
142 yRangeDict[ "DPhiMHTTau" ] = ( 6*10**-1, 10**4 )
143 yRangeDict[ "MinDPhiMHTJ" ] = ( 6*10**-2, 10**3 )
144 yRangeDict[ "DPhi12" ] = ( 6*10**-2, 10**3 )
145 yRangeDict[ "DPhi13" ] = ( 6*10**-2, 10**3 )
146 yRangeDict[ "DPhi23" ] = ( 6*10**-1, 10**4 )
147 if re.search( "Simulation", theTheTitle ):
148 yRangeDict[ "MHT" ] = ( 6*10**-5, 10**2 )
149 yRangeDict[ "HT" ] = ( 6*10**-5, 10**2 )
150 yRangeDict[ "JetPt" ] = ( 6*10**-5, 10**2 )
151 yRangeDict[ "JetEta" ] = ( 6*10**-5, 10**3 )
152 yRangeDict[ "Jet1Pt" ] = ( 6*10**-5, 10**2 )
153 yRangeDict[ "Jet1Eta" ] = ( 6*10**-5, 5*10**3 )
154 yRangeDict[ "Jet2Pt" ] = ( 6*10**-5, 10**2 )
155 yRangeDict[ "Jet2Eta" ] = ( 6*10**-5, 10**3 )
156 yRangeDict[ "Jet3Pt" ] = ( 6*10**-5, 10**2 )
157 yRangeDict[ "Jet3Eta" ] = ( 6*10**-5, 10**3 )
158 yRangeDict[ "nJets" ] = ( 6*10**-5, 10**2 )
159 yRangeDict[ "DPhiMHTTau" ] = ( 6*10**-5, 10**3 )
160 yRangeDict[ "MinDPhiMHTJ" ] = ( 6*10**-5, 10**2 )
161 yRangeDict[ "DPhi12" ] = ( 6*10**-4, 10**3 )
162 yRangeDict[ "DPhi13" ] = ( 6*10**-4, 10**3 )
163 yRangeDict[ "DPhi23" ] = ( 6*10**-5, 10**3 )
164
165
166 xRangeDict = {}
167 xRangeDict[ "MHT" ] = ( 250,1000 )
168 xRangeDict[ "HT" ] = ( 350,2000 )
169 xRangeDict[ "Tau1Pt" ] = ( 0,1000 )
170 xRangeDict[ "Jet1Pt" ] = ( 0,1600 )
171 xRangeDict[ "Jet2Pt" ] = ( 0,1600 )
172 xRangeDict[ "Jet3Pt" ] = ( 0,1600 )
173 if re.search( "Simulation", theTheTitle ):
174 xRangeDict[ "HT" ] = ( 350,4000 )
175
176 posDict = {}
177 posDict[ "DPhi12" ] = "ul"
178 posDict[ "DPhi13" ] = "ul"
179 #osDict[ "DPhi23" ] = "ul"
180
181 rebinDict = {}
182 rebinDict[ "MHTMHT" ] = 4
183 rebinDict[ "MHT" ] = 4
184 rebinDict[ "MHTMHTEta" ] = 4
185 rebinDict[ "MHTEta" ] = 4
186 rebinDict[ "MHTMHTPhi" ] = 4
187 rebinDict[ "MHTPhi" ] = 4
188 rebinDict[ "MHTUnweighted" ] = 4
189 rebinDict[ "MHTEtaUnweighted" ] = 4
190 rebinDict[ "MHTPhiUnweighted" ] = 4
191 rebinDict[ "HTHT" ] = 4
192 rebinDict[ "HT" ] = 4
193 rebinDict[ "HTUnweighted" ] = 4
194 rebinDict[ "JetPtUnweighted" ] = 4
195 rebinDict[ "JetPt" ] = 4
196 rebinDict[ "JetEtaUnweighted" ] = 4
197 rebinDict[ "JetEta" ] = 4
198 rebinDict[ "JetPhiUnweighted" ] = 4
199 rebinDict[ "JetPhi" ] = 4
200 rebinDict[ "Jet1PtUnweighted" ] = 2
201 rebinDict[ "Jet1Pt" ] = 2
202 rebinDict[ "Jet1EtaUnweighted" ] = 4
203 rebinDict[ "Jet1Eta" ] = 4
204 rebinDict[ "Jet1PhiUnweighted" ] = 4
205 rebinDict[ "Jet1Phi" ] = 4
206 rebinDict[ "Jet2PtUnweighted" ] = 2
207 rebinDict[ "Jet2Pt" ] = 2
208 rebinDict[ "Jet2EtaUnweighted" ] = 4
209 rebinDict[ "Jet2Eta" ] = 4
210 rebinDict[ "Jet2PhiUnweighted" ] = 4
211 rebinDict[ "Jet2Phi" ] = 4
212 rebinDict[ "Jet3PtUnweighted" ] = 2
213 rebinDict[ "Jet3Pt" ] = 2
214 rebinDict[ "Jet3EtaUnweighted" ] = 4
215 rebinDict[ "Jet3Eta" ] = 4
216 rebinDict[ "Jet3PhiUnweighted" ] = 4
217 rebinDict[ "Jet3Phi" ] = 4
218 rebinDict[ "TauSelectionTau1Pt" ] = 4
219 rebinDict[ "TauSelectionTau1Eta" ] = 4
220 rebinDict[ "TauSelectionTau1Phi" ] = 4
221 rebinDict[ "JetSelection30Jet1Pt" ] = 2
222 rebinDict[ "JetSelection30Jet1Eta" ] = 4
223 rebinDict[ "JetSelection30Jet1Phi" ] = 4
224 rebinDict[ "JetSelection30Jet2Pt" ] = 2
225 rebinDict[ "JetSelection30Jet2Eta" ] = 4
226 rebinDict[ "JetSelection30Jet2Phi" ] = 4
227 rebinDict[ "JetSelection30Jet3Pt" ] = 2
228 rebinDict[ "JetSelection30Jet3Eta" ] = 4
229 rebinDict[ "JetSelection30Jet3Phi" ] = 4
230 rebinDict[ "TauSelectiondPhiMHTTau" ] = 10
231 rebinDict[ "DPhiMHTTau" ] = 10
232 rebinDict[ "DPhiMHTTauUnweighted" ] = 10
233 rebinDict[ "MHTdPhiMinmhtDphi" ] = 4
234 rebinDict[ "MinDPhiMHTJ" ] = 4
235 rebinDict[ "MinDPhiMHTJUnweighted" ] = 4
236 rebinDict[ "MHTdPhiMindPhi12" ] = 10
237 rebinDict[ "DPhi12" ] = 10
238 rebinDict[ "DPhi12Unweighted" ] = 10
239 rebinDict[ "MHTdPhiMindPhi13" ] = 10
240 rebinDict[ "DPhi13" ] = 10
241 rebinDict[ "DPhi13Unweighted" ] = 10
242 rebinDict[ "MHTdPhiMindPhi23" ] = 10
243 rebinDict[ "DPhi23" ] = 10
244 rebinDict[ "DPhi23Unweighted" ] = 10
245 if Type == "Full":
246 rebinDict[ "JetPtUnweighted" ] = 8
247 rebinDict[ "JetPt" ] = 8
248 rebinDict[ "TauSelectionTau1Pt" ] = 8
249 pass
250
251 if Type == "Pre":
252 dirFakeTau = "finalPlotTauPreSelectionVetoMatchedTauControl/"
253 #dirFakeTau = "finalPlotTauPreSelectionControl/"
254 #dirFakeTau = "finalPlotTauPreSelectionControlLV/"
255 #dirFakeTau = "finalPlotTauPreSelectionControlMV/"
256 #dirFakeTau = "finalPlotTauPreSelectionControlHV/"
257 #dirFakeTau = "finalPlotTauPreSelectionVetoMatchedTauControl/"
258 #dirFakeTau = "finalPlotTauPreSelectionControl20MHT40/"
259 #dirFakeTau = "finalPlotTauPreSelectionControl20MHT40HT500/"
260 #dirFakeTau = "finalPlotTauPreSelectionControl40MHT60/"
261 #dirFakeTau = "finalPlotTauPreSelectionControl40MHT60HT500/"
262 #dirFakeTau = "finalPlotTauPreSelectionControl60MHT100/"
263 #dirFakeTau = "finalPlotTauPreSelectionControl60MHT80/"
264 #dirFakeTau = "finalPlotTauPreSelectionControl60MHT80HT500/"
265 #dirFakeTau = "finalPlotTauPreSelectionControl80MHT100/"
266 #dirFakeTau = "finalPlotTauPreSelectionControl80MHT100HT500/"
267 #dirFakeTau = "finalPlotTauPreSelectionControl60MHT100HT500/"
268 #dirFakeTau = "finalPlotTauPreSelectionControl100MHT120/"
269 #dirFakeTau = "finalPlotTauPreSelectionControl100MHT120HT500/"
270 #dirFakeTau = "finalPlotTauPreSelectionControl120MHT140/"
271 #dirFakeTau = "finalPlotTauPreSelectionControl120MHT140HT500/"
272 #dirFakeTau = "finalPlotTauPreSelectionControl100MHT200/"
273 #dirFakeTau = "finalPlotTauPreSelectionControl200MHT400/"
274 #dirFakeTau = "finalPlotTauPreSelectionControl400MHT/"
275 #dirFakeTau = "finalPlotTauPreSelectionControl20MHT40LV/"
276 #dirFakeTau = "finalPlotTauPreSelectionControl40MHT60LV/"
277 #dirFakeTau = "finalPlotTauPreSelectionControl60MHT100LV/"
278 #dirFakeTau = "finalPlotTauPreSelectionControl20MHT40MV/"
279 #dirFakeTau = "finalPlotTauPreSelectionControl40MHT60MV/"
280 #dirFakeTau = "finalPlotTauPreSelectionControl60MHT100MV/"
281 #dirFakeTau = "finalPlotTauPreSelectionControl20MHT40HV/"
282 #dirFakeTau = "finalPlotTauPreSelectionControl40MHT60HV/"
283 #dirFakeTau = "finalPlotTauPreSelectionControl60MHT100HV/"
284 #dirPredTau = "QCDPredictionAnalyzerPre/"
285 if f2d :
286 dirPredTau = "QCDPredictionAnalyzerPre2D/"
287 pass
288 if relIso:
289 dirPredTau = "QCDPredictionAnalyzerPreRelIso/"
290 if all:
291 dirPredTau = "QCDPredictionAnalyzerAllPre/"
292 if relIso:
293 dirPredTau = "QCDPredictionAnalyzerAllPreRelIso/"
294 if f2d:
295 dirPredTau = "QCDPredictionAnalyzerAllPre2D/"
296 elif pre:
297 dirPredTau = "QCDPredictionAnalyzerPrePre/"
298 elif inv:
299 dirPredTau = "QCDPredictionAnalyzerInvertPre/"
300 if relIso:
301 dirPredTau = "QCDPredictionAnalyzerInvertPreRelIso/"
302 if f2d:
303 dirPredTau = "QCDPredictionAnalyzerInvertPre2D/"
304 #dirPredTau = "QCDPredictionAnalyzerInvertPreGC/"
305 #dirPredTau = "QCDPredictionAnalyzerInvertPre2DPtHat/"
306 #dirPredTau = "QCDPredictionAnalyzerInvertPre2DLV/"
307 #dirPredTau = "QCDPredictionAnalyzerInvertPre2DMV/"
308 #dirPredTau = "QCDPredictionAnalyzerInvertPre2DHV/"
309 #dirPredTau = "QCDPredictionAnalyzerInvertPre2D20MHT40/"
310 #dirPredTau = "QCDPredictionAnalyzerInvert2D20MHT40HT500/"
311 #dirPredTau = "QCDPredictionAnalyzerInvertPre2D40MHT60/"
312 #dirPredTau = "QCDPredictionAnalyzerInvert2D40MHT60HT500/"
313 #dirPredTau = "QCDPredictionAnalyzerInvertPre2D60MHT100/"
314 #dirPredTau = "QCDPredictionAnalyzerInvertPre2D60MHT80/"
315 #dirPredTau = "QCDPredictionAnalyzerInvert2D60MHT80HT500/"
316 #dirPredTau = "QCDPredictionAnalyzerInvertPre2D80MHT100/"
317 #dirPredTau = "QCDPredictionAnalyzerInvert2D80MHT100HT500/"
318 #dirPredTau = "QCDPredictionAnalyzerInvert2D60MHT100HT500/"
319 #dirPredTau = "QCDPredictionAnalyzerInvertPre2D100MHT120/"
320 #dirPredTau = "QCDPredictionAnalyzerInvert2D100MHT120HT500/"
321 #dirPredTau = "QCDPredictionAnalyzerInvertPre2D120MHT140/"
322 #dirPredTau = "QCDPredictionAnalyzerInvert2D120MHT140HT500/"
323 #dirPredTau = "QCDPredictionAnalyzerInvertPre2D100MHT200/"
324 #dirPredTau = "QCDPredictionAnalyzerInvertPre2D200MHT400/"
325 #dirPredTau = "QCDPredictionAnalyzerInvertPre2D400MHT/"
326 #dirPredTau = "QCDPredictionAnalyzerInvertPre2D20MHT40LV/"
327 #dirPredTau = "QCDPredictionAnalyzerInvertPre2D40MHT60LV/"
328 #dirPredTau = "QCDPredictionAnalyzerInvertPre2D60MHT100LV/"
329 #dirPredTau = "QCDPredictionAnalyzerInvertPre2D20MHT40MV/"
330 #dirPredTau = "QCDPredictionAnalyzerInvertPre2D40MHT60MV/"
331 #dirPredTau = "QCDPredictionAnalyzerInvertPre2D60MHT100MV/"
332 #dirPredTau = "QCDPredictionAnalyzerInvertPre2D20MHT40HV/"
333 #dirPredTau = "QCDPredictionAnalyzerInvertPre2D40MHT60HV/"
334 #dirPredTau = "QCDPredictionAnalyzerInvertPre2D60MHT100HV/"
335 #dirPredTau = "QCDPredictionAnalyzerInvertPreGC20MHT40/"
336 #dirPredTau = "QCDPredictionAnalyzerInvertGC20MHT40HT500/"
337 #dirPredTau = "QCDPredictionAnalyzerInvertPreGC40MHT60/"
338 #dirPredTau = "QCDPredictionAnalyzerInvertGC40MHT60HT500/"
339 #dirPredTau = "QCDPredictionAnalyzerInvertPreGC60MHT100/"
340 #dirPredTau = "QCDPredictionAnalyzerInvertGC60MHT100HT500/"
341 pass
342 pass
343 if eta:
344 dirPredTau = "QCDPredictionAnalyzerPreEta/"
345 if f2d:
346 dirPredTau = "QCDPredictionAnalyzerPre2DEta/"
347 if all:
348 dirPredTau = "QCDPredictionAnalyzerAllPreEta/"
349 if f2d:
350 dirPredTau = "QCDPredictionAnalyzerAllPre2DEta/"
351 elif pre:
352 dirPredTau = "QCDPredictionAnalyzerPrePreEta/"
353 elif inv:
354 dirPredTau = "QCDPredictionAnalyzerInvertPreEta/"
355 if f2d:
356 dirPredTau = "QCDPredictionAnalyzerInvertPre2DEta/"
357 pass
358 pass
359 pass
360 elif Type == "PreCheck":
361 dirFakeTau = "finalPlotTauPreSelectionPS/"
362 dirPredTau = "QCDPredictionAnalyzer2DEtaMDP/"
363 pass
364 elif Type == "Full":
365 dirFakeTau = "finalPlotTauVetoMatchedTauControl/"
366 #dirFakeTau = "finalPlotTauVetoMatchedTauControlPtHat/"
367 #dirFakeTau = "finalPlotTauControl/"
368 #dirFakeTau = "finalPlotTauControl20MHT40/"
369 #dirFakeTau = "finalPlotTauControl40MHT60/"
370 #dirFakeTau = "finalPlotTauControl60MHT100/"
371 #dirFakeTau = "finalPlotTauControl60MHT80/"
372 #dirFakeTau = "finalPlotTauControl80MHT100/"
373 #dirFakeTau = "finalPlotTauControl100MHT200/"
374 #dirFakeTau = "finalPlotTauControl200MHT400/"
375 #dirFakeTau = "finalPlotTauControl100MHT120/"
376 #dirFakeTau = "finalPlotTauControl120MHT140/"
377 #dirFakeTau = "finalPlotTauControl400MHT/"
378 #dirFakeTau = "finalPlotTauControl20MHT40LV/"
379 #dirFakeTau = "finalPlotTauControl40MHT60LV/"
380 #dirFakeTau = "finalPlotTauControl60MHT100LV/"
381 #dirFakeTau = "finalPlotTauControl20MHT40MV/"
382 #dirFakeTau = "finalPlotTauControl40MHT60MV/"
383 #dirFakeTau = "finalPlotTauControl60MHT100MV/"
384 #dirFakeTau = "finalPlotTauControl20MHT40HV/"
385 #dirFakeTau = "finalPlotTauControl40MHT60HV/"
386 #dirFakeTau = "finalPlotTauControl60MHT100HV/"
387 dirPredTau = "QCDPredictionAnalyzer/"
388 if f2d:
389 dirPredTau = "QCDPredictionAnalyzer2D/"
390 if relIso:
391 dirPredTau = "QCDPredictionAnalyzerRelIso/"
392 if all:
393 dirPredTau = "QCDPredictionAnalyzerAll/"
394 if f2d:
395 dirPredTau = "QCDPredictionAnalyzerAll2D/"
396 if relIso:
397 dirPredTau = "QCDPredictionAnalyzerAllRelIso/"
398 elif pre:
399 dirPredTau = "QCDPredictionAnalyzerPreFull/"
400 elif inv:
401 dirPredTau = "QCDPredictionAnalyzerInvert/"
402 if f2d:
403 dirPredTau = "QCDPredictionAnalyzerInvert2D/"
404 #dirPredTau = "QCDPredictionAnalyzerInvert2DPtHat/"
405 #dirPredTau = "QCDPredictionAnalyzerInvert2DLV/"
406 #dirPredTau = "QCDPredictionAnalyzerInvertGC/"
407 #dirPredTau = "QCDPredictionAnalyzerInvert2D20MHT40/"
408 #dirPredTau = "QCDPredictionAnalyzerInvert2D40MHT60/"
409 #dirPredTau = "QCDPredictionAnalyzerInvert2D60MHT100/"
410 #dirPredTau = "QCDPredictionAnalyzerInvert2D60MHT80/"
411 #dirPredTau = "QCDPredictionAnalyzerInvert2D80MHT100/"
412 #dirPredTau = "QCDPredictionAnalyzerInvert2D100MHT120/"
413 #dirPredTau = "QCDPredictionAnalyzerInvert2D120MHT140/"
414 #dirPredTau = "QCDPredictionAnalyzerInvert2D100MHT200/"
415 #dirPredTau = "QCDPredictionAnalyzerInvert2D200MHT400/"
416 #dirPredTau = "QCDPredictionAnalyzerInvert2D400MHT/"
417 #dirPredTau = "QCDPredictionAnalyzerInvert2D20MHT40LV/"
418 #dirPredTau = "QCDPredictionAnalyzerInvert2D40MHT60LV/"
419 #dirPredTau = "QCDPredictionAnalyzerInvert2D60MHT100LV/"
420 #dirPredTau = "QCDPredictionAnalyzerInvert2D20MHT40MV/"
421 #dirPredTau = "QCDPredictionAnalyzerInvert2D40MHT60MV/"
422 #dirPredTau = "QCDPredictionAnalyzerInvert2D60MHT100MV/"
423 #dirPredTau = "QCDPredictionAnalyzerInvert2D20MHT40HV/"
424 #dirPredTau = "QCDPredictionAnalyzerInvert2D40MHT60HV/"
425 #dirPredTau = "QCDPredictionAnalyzerInvert2D60MHT100HV/"
426 #dirPredTau = "QCDPredictionAnalyzerInvertGC20MHT40/"
427 #dirPredTau = "QCDPredictionAnalyzerInvertGC40MHT60/"
428 #dirPredTau = "QCDPredictionAnalyzerInvertGC60MHT100/"
429 pass
430 if relIso:
431 dirPredTau = "QCDPredictionAnalyzerInvertRelIso/"
432 if eta:
433 dirPredTau = "QCDPredictionAnalyzerEta/"
434 if f2d:
435 dirPredTau = "QCDPredictionAnalyzer2DEta/"
436 if all:
437 dirPredTau = "QCDPredictionAnalyzerAllEta/"
438 if f2d:
439 dirPredTau = "QCDPredictionAnalyzerAll2DEta/"
440 elif pre:
441 dirPredTau = "QCDPredictionAnalyzerPreFullEta/"
442 elif inv:
443 dirPredTau = "QCDPredictionAnalyzerInvertEta/"
444 if f2d:
445 dirPredTau = "QCDPredictionAnalyzerInvert2DEta/"
446
447 pass
448
449 theSystDict = {}
450 if not statErrsOnly:
451 theSystDict[ "FakeRateStatErrs" ] = {}
452 #theSystDict[ "FakeRateUncert" ] = {}
453 #theSystDict[ "FakeRateStatErrs" ][ "Up" ] = 0.02 ## data 20<MHT<40
454 #theSystDict[ "FakeRateStatErrs" ][ "Dwn" ] = 0.02
455 theSystDict[ "FakeRateStatErrs" ][ "Up" ] = 0.01 ## mc BL
456 theSystDict[ "FakeRateStatErrs" ][ "Dwn" ] = 0.01
457 #theSystDict[ "FakeRateUncert" ][ "Up" ] = 0.06 ## mc BL
458 #theSystDict[ "FakeRateUncert" ][ "Dwn" ] = 0.06
459 pass
460
461 scale = 1.
462 if doSystScaling:
463 scale = 1.15 ### pred/sel = 0.86 in data; no, p/s = 1 +- ...
464 theSystDict[ "closure" ] = {}
465 theSystDict[ "closure" ][ "Up" ] = 0.15 ### 11% underprediction of selection, but 30% error!
466 theSystDict[ "closure" ][ "Dwn" ] = 0.15 ### 11% underprediction of selection, but 30% error!
467 pass
468
469
470 print dirPredTau
471
472
473 ############# read in prediction plots #############################################
474 histDict = {}
475 readIn = Helper.ReadIn( fileDir, fileName, rebinDict=rebinDict, externalScalingFactor=scale )
476 readIn.removeSamples( removeSamples )
477 readIn.addSamples( addSamples )
478 readIn.addHists( [ "HT", "JetPt" ] )
479 if displayControlPlots:
480 readIn.addHists( [ "MHTEta", "MHTPhi",
481 "JetEta", "JetPhi",
482 "Jet1Pt", "Jet1Eta", "Jet1Phi",
483 "Jet2Pt", "Jet2Eta", "Jet2Phi",
484 "Jet3Pt", "Jet3Eta", "Jet3Phi",
485 "nJets", "DPhiMHTTau",
486 "MinDPhiMHTJ","DPhi12",
487 "DPhi13", "DPhi23" ] )
488 pass
489 #print readIn.histList
490 histDict = readIn.getHists( dirPredTau )
491
492 ### for the right stat err
493 #histDictPred = {}
494 #predReadIn = Helper.ReadIn( fileDir, fileName, rebinDict=rebinDict )
495 #predReadIn.removeSamples( removeSamples )
496 #predReadIn.addSamples( addSamples )
497 #predReadIn.removeHists( [ "MHT" ] )
498 #predReadIn.addHists( [ "nPredEvents", "statErr" ] )
499 ##predReadIn.dontScale()
500 #histDictPred = predReadIn.getHists( dirPredTau )
501 ####################################################################################
502
503
504 ############# read in selection plots #############################################
505 histDictSel = {}
506 selReadIn = Helper.ReadIn( fileDir, fileName, rebinDict=rebinDict )
507 selReadIn.removeSamples( removeSamplesSel )
508 selReadIn.addSamples( addSamples )
509 selReadIn.removeHists( [ "MHT" ] )
510 selReadIn.addHists( [ "MHTMHT", "HTHT", "TauSelectionTau1Pt" ] )
511 if displayControlPlots:
512 selReadIn.addHists( [ "MHTMHTEta", "MHTMHTPhi",
513 "TauSelectionTau1Eta", "TauSelectionTau1Phi",
514 "JetSelection30Jet1Pt", "JetSelection30Jet1Eta", "JetSelection30Jet1Phi",
515 "JetSelection30Jet2Pt", "JetSelection30Jet2Eta", "JetSelection30Jet2Phi",
516 "JetSelection30Jet3Pt", "JetSelection30Jet3Eta", "JetSelection30Jet3Phi",
517 "JetSelection30NumberOfJets",
518 "TauSelectiondPhiMHTTau", "MHTdPhiMinmhtDphi",
519 "MHTdPhiMindPhi12","MHTdPhiMindPhi13", "MHTdPhiMindPhi23" ] )
520 pass
521 histDictSel = selReadIn.getHists( dirFakeTau )
522 ####################################################################################
523
524 ############# read in prediction plots unscaled ####################################
525 histDictUnscaled = {}
526 readInUnscaled = Helper.ReadIn( fileDir, fileName, rebinDict=rebinDict )
527 readInUnscaled.removeHists( [ "MHT" ] )
528 readInUnscaled.removeSamples( removeSamples )
529 readInUnscaled.addSamples( addSamples )
530 readInUnscaled.addHists( [ "HTUnweighted", "MHTUnweighted", "JetPtUnweighted" ] )
531 if displayControlPlots:
532 readInUnscaled.addHists( [ "MHTEtaUnweighted", "MHTPhiUnweighted",
533 "JetEtaUnweighted", "JetPhiUnweighted",
534 "Jet1PtUnweighted", "Jet1EtaUnweighted", "Jet1PhiUnweighted",
535 "Jet2PtUnweighted", "Jet2EtaUnweighted", "Jet2PhiUnweighted",
536 "Jet3PtUnweighted", "Jet3EtaUnweighted", "Jet3PhiUnweighted",
537 "nJetsUnweighted", "DPhiMHTTauUnweighted", "MinDPhiMHTJUnweighted",
538 "DPhi12Unweighted", "DPhi13Unweighted", "DPhi23Unweighted" ] )
539 pass
540 readInUnscaled.dontScale()
541 #print readIn.histList
542 histDictUnscaled = readInUnscaled.getHists( dirPredTau )
543 ####################################################################################
544
545 ############# read in only mc-scaled ##############################################
546 histDictMCScaled = {}
547 readInMCScaled = Helper.ReadIn( fileDir, fileName, rebinDict=rebinDict )
548 readInMCScaled.removeHists( [ "MHT" ] )
549 readInMCScaled.removeSamples( removeSamples )
550 readInMCScaled.addSamples( addSamples )
551 readInMCScaled.addHists( [ "MHTMCWeights" ] )
552 #print readIn.histList
553 histDictMCScaled = readInMCScaled.getHists( dirPredTau )
554 ####################################################################################
555
556
557 ############# print && tex file ####################################################
558 TF = Def.MakeTexFile( fileName="tex/newCommandsFakeTau" + Type )
559 TF.addCommand( name="FT" + Type + "Lumi",
560 value=readIn.lumi/1000.,
561 roundTo=0 )
562 print
563 print "Number of events in control region at L=", readIn.lumi
564 tauControlAll = 0.
565 #print "########## currently nonsense"
566 for sample in readIn.sampleList:
567 tauControl = histDictMCScaled[ "MHTMCWeights" ][ sample ].Integral()
568 tauControlAll += tauControl
569 print sample, " : ", round( tauControl, 2 ),\
570 " +- ", round( math.sqrt( histDictUnscaled[ "MHTUnweighted" ][ sample ].Integral() ) *\
571 tauControl/histDictUnscaled[ "MHTUnweighted" ][ sample ].Integral(),2 )
572 TF.addCommand( name="FT" + Type + "FakeControl" + sample,
573 value=tauControl,
574 roundTo=1 )
575 pass
576 TF.addCommand( name="FT" + Type + "FakeControl" + "All",
577 value=tauControlAll,
578 roundTo=1 )
579
580 print
581 tauControlMCAll = 0
582 print "Number of events in control sample (MC)"
583 for sample in readIn.sampleList:
584 print sample, " : ", round( histDictUnscaled[ "MHTUnweighted" ][ sample ].Integral(),2 ), \
585 " +- ", round( math.sqrt( histDictUnscaled[ "MHTUnweighted" ][ sample ].Integral() ), 2 )
586 tauControlMCAll += histDictUnscaled[ "MHTUnweighted" ][ sample ].Integral()
587 TF.addCommand( name="FT" + Type + "MCFakes" + sample,
588 value=histDictUnscaled[ "MHTUnweighted" ][ sample ].Integral(),
589 roundTo=0 )
590 pass
591 TF.addCommand( name="FT" + Type + "MCFakes" + "All",
592 value=tauControlMCAll,
593 roundTo=0 )
594
595 print
596 print "Number of MC events selected"
597 print
598 selMCAll = 0
599 for sample in readIn.sampleList:
600 if sample in selReadIn.sampleList:
601 print sample, " : ", histDictSel[ "MHTMHT" ][ sample ].GetEntries()
602 selMCAll += histDictSel[ "MHTMHT" ][ sample ].GetEntries()
603 TF.addCommand( name="FT" + Type + "MCTau" + sample,
604 value=histDictSel[ "MHTMHT" ][ sample ].GetEntries(),
605 roundTo=0 )
606 else:
607 TF.addCommand( name="FT" + Type + "MCTau" + sample,
608 value=0,
609 roundTo=0 )
610 pass
611 pass
612
613 TF.addCommand( name="FT" + Type + "MCTau" + "All",
614 value=selMCAll,
615 roundTo=0 )
616
617 print "----- tau-selected events (no gen tau) ----"
618 tauSelAll = 0
619 errAll = 0
620 order = 10**-roundTo
621 errSel = {}
622 selSel = {}
623 for sample in readIn.sampleList:
624 if sample in selReadIn.sampleList:
625 err = ROOT.Double( 0 )
626 tauSel2 = histDictSel[ "MHTMHT" ][ sample ].IntegralAndError( 0,
627 histDictSel[ "MHTMHT" ][ sample ].GetNbinsX() \
628 + 1,
629 err )
630 errSel[ sample ] = err
631 selSel[ sample ] = tauSel2
632 print sample , ": ", round( tauSel2,2 ), \
633 " +- ", round( err,2 )
634 tauSelAll += tauSel2
635 #err = math.sqrt( histDictSel[ "MHTMHT" ][ sample ].GetEntries() )
636 errAll += err**2
637 #print sample , " n sel events = ", round( tauSel,2 ), \
638 # " +- ", err
639
640 rt = roundTo
641 if( round( tauSel2, roundTo ) < order or
642 round( err, roundTo ) < order ):
643 rt = roundTo + 1
644 TF.addCommand( name="FT" + Type + "Sel" + sample,
645 value=tauSel2,
646 roundTo=rt )
647 TF.addCommand( name="FT" + Type + "Sel" + sample + "StatErr",
648 value=err,
649 roundTo=rt )
650 else:
651 TF.addCommand( name="FT" + Type + "Sel" + sample,
652 value="-",
653 roundTo=None )
654 TF.addCommand( name="FT" + Type + "Sel" + sample + "StatErr",
655 value="-",
656 roundTo=None )
657 pass
658
659 pass
660 print "-----------------------------"
661 print "Sum :", round( tauSelAll, 2 ), " +- ", round( math.sqrt( errAll ),2 )
662 TF.addCommand( name="FT" + Type + "Sel" + "All",
663 value=tauSelAll,
664 roundTo=roundTo )
665 TF.addCommand( name="FT" + Type + "Sel" + "All" + "StatErr",
666 value=math.sqrt( errAll ),
667 roundTo=roundTo )
668
669 #avFakeRate = tauSel / ( tauSel + tauControl )
670 #print
671 #print "Average fake rate=", round( avFakeRate, 2 )
672 #scaleControl = 1/( 1-avFakeRate )
673 #print "(Not done) Scale control sample with 1/(1-f)=", round( scaleControl, 2 )
674
675
676 print
677 print "----- pred Events ------"
678 predAll = 0
679 predErrAll = 0
680 errPred = {}
681 selPred = {}
682 for sample in readIn.sampleList:
683 err = ROOT.Double( 0 )
684 p = histDict[ "MHT" ][ sample ].IntegralAndError( 0,
685 histDict[ "MHT" ][ sample ].GetNbinsX() + 1,
686 err )
687 print sample, ": ", round( p,3 ), " +- ", round( err,3 )
688 #print sample , " n pred events = ", round( histDictPred[ "nPredEvents" ][ sample ].GetBinContent( 1 ) ,2 ) ,\
689 # " +- ", round( histDictPred[ "statErr" ][ sample ].GetBinContent( 1 ) ,2 )
690 #predAll += histDictPred[ "nPredEvents" ][ sample ].GetBinContent( 1 )
691 #predErrAll += histDictPred[ "statErr" ][ sample ].GetBinContent( 1 )**2
692 predAll += p
693 predErrAll += err**2
694
695 errPred[ sample ] = err
696 selPred[ sample ] = p
697
698 rt = roundTo
699 if( round( p, roundTo ) < order or
700 round( err, roundTo ) < order ):
701 rt = roundTo + 1
702 TF.addCommand( name="FT" + Type + "Pred" + sample,
703 value=p,
704 roundTo=rt )
705 TF.addCommand( name="FT" + Type + "Pred" + sample + "StatErr",
706 value=err,
707 roundTo=rt )
708 #print sample , " n pred events * 1/(1-f) = ", \
709 # round( scaleControl * histDictPred[ "nPredEvents" ][ sample ].GetBinContent( 1 ) ,2 ) ,\
710 # " +- ", round( histDictPred[ "statErr" ][ sample ].GetBinContent( 1 ) ,2 )
711 pass
712 print "-----------------------------"
713 print "Sum :", round( predAll, 2 ), " +- ", round( math.sqrt( predErrAll ),2 )
714 print
715 #print
716 TF.addCommand( name="FT" + Type + "Pred" + "All",
717 value=predAll,
718 roundTo=roundTo )
719 TF.addCommand( name="FT" + Type + "Pred" + "All" + "StatErr",
720 value=math.sqrt( predErrAll ),
721 roundTo=roundTo )
722
723 print "------------ s/p -------------"
724 for sample in readIn.sampleList:
725 if not sample in selReadIn.sampleList:
726 continue
727 print sample , ": ", round( ( ( selPred[ sample ] / selSel[ sample ] ) )**-1 ,2 ), " +- ",\
728 round( math.sqrt( ( ( errSel[ sample ] / selPred[ sample ] )**2 + \
729 ( selSel[ sample ] * errPred[ sample ] / ( selPred[ sample ] )**2 )**2 ) ) ,2 )
730 TF.addCommand( name="FT" + Type + "Rat" + sample,
731 value=( selPred[ sample ] / selSel[ sample ] )**-1,
732 roundTo=roundTo )
733 TF.addCommand( name="FT" + Type + "Rat" + sample + "StatErr",
734 value= math.sqrt( ( errSel[ sample ] / selPred[ sample ] )**2 + \
735 ( selSel[ sample ] * errPred[ sample ] / ( selPred[ sample ] )**2 )**2 ),
736 roundTo=roundTo )
737 pass
738 print "-----------------------------"
739 print "All: ", round( ( predAll/tauSelAll )**-1 ,2 ), " +- ", \
740 round( math.sqrt( ( math.sqrt( errAll )/ predAll )**2 + \
741 ( tauSelAll * math.sqrt( predErrAll ) / ( predAll )**2 )**2 ),2 )
742 TF.addCommand( name="FT" + Type + "Rat" + "All",
743 value=( predAll/tauSelAll )**-1,
744 roundTo=roundTo )
745 TF.addCommand( name="FT" + Type + "Rat" + "All" + "StatErr",
746 value=math.sqrt( ( math.sqrt( errAll )/predAll )**2 +\
747 ( tauSelAll * math.sqrt( predErrAll ) / ( predAll )**2 )**2 ) ,
748 roundTo=roundTo )
749 print
750 print
751
752 TF.writeTexFile()
753 ####################################################################################
754
755 ################## syst errs #######################################################
756
757 fakeTausSystReadIn = Helper.ReadIn( fileDir, fileName, rebinDict={} )
758 fakeTausSystReadIn.removeSamples( removeSamples )
759 fakeTausSystReadIn.addSamples( addSamples )
760 fakeTausSystReadIn.removeHists( [ "MHT" ] )
761 fakeTausSystReadIn.addHists( [ "StatErrUp" ] )
762 fakeTausSystReadIn.addHists( [ "StatErrDwn" ] )
763 histDictFTSyst = fakeTausSystReadIn.getHists( dirPredTau )
764 SFH = Helper.SystFromHist( dict=histDictFTSyst )
765 sDict = SFH.getSystDict()
766
767 print
768 print "--------- syst --------"
769 for syst in sDict.keys():
770 print syst, " abs=", round( math.sqrt( sDict[ syst ] ),2 ), \
771 " rel=", round( math.sqrt( sDict[ syst ] )/ predAll,2 )
772 pass
773
774 #print "-------------------- ratio ------------------------"
775 #print "Pred/sel=", round( ( predAll/tauSelAll ) * 100,1 ), " +- ",\
776 # round( ( math.sqrt( predErrAll/( tauSelAll )**2 +
777 # predAll**2 * errAll/( tauSelAll )**4 +
778 # sDict[ "StatErrUp" ]/( tauSelAll )**2 ) ) * 100,1 )
779
780 ####################################################################################
781
782 ############# draw #################################################################
783 if draw:
784
785 legendErrEntry = "total uncertainty"
786 if statErrsOnly:
787 legendErrEntry = "total stat. uncert."
788 pass
789
790 legend = [ "selected",
791 "predicted",
792 legendErrEntry ]
793 statDict = { "predicted" : "BG",
794 legendErrEntry : "BG",
795 "selected" : "Data"}
796 if displayNEvents:
797
798 nSel = histDictRT[ "MHTMHT" ][ "All" ].Integral()
799 nPred = pred.predDict[ "MHT" ][ "All" ]
800
801 legend = [ "selected (" + str( round( nSel,1 ) ) + ")",
802 "predicted (" + str( round( nPred,1 ) ) + ")",
803 "total stat. uncert." ]
804 statDict = { "predicted (" + str( round( nPred,1 ) ) + ")" : "BG",
805 "total stat. uncert." : "BG",
806 "selected (" + str( round( nSel,1 ) ) + ")" : "Data"}
807 pass
808
809 theTitle = ""
810 if plotTitle:
811 theTitle = theTheTitle
812 pass
813
814 #print "###### plots are not scaled with 1/(1-f) yet ########"
815
816 #### get the full stat error and the hist binned stat error
817 errsDict = {}
818 errsBinDict = {}
819 for hist in readIn.histList:
820 errs = Helper.StackErr( histDict[ hist ], histDictUnscaled[ hist + "Unweighted" ] )
821 errsDict[ hist ], errsBinDict[ hist ] = errs.getStackErrQCD()
822 pass
823
824 #### get the sample stack of all selected fake tau events
825 for hist in selReadIn.histList:
826 addup = Helper.AddUp( histDictSel[ hist ] )
827 histDictSel[ hist ][ "All" ] = addup.add()
828 pass
829
830 #### get the sample stack of predicted fake tau distributions
831 allHist = {}
832 for hist in histDict.keys():
833 addup = Helper.AddUp( histDict[ hist ] )
834 allHist[ hist ] = addup.add()
835 pass
836
837 ################### get the syst ers ###################################################
838 errsSystDict = {}
839 errsSystDictBin = {}
840 for hist in readIn.histList:
841 errsSystDict[ hist ] = {}
842 errsSyst = Helper.SystErr( allHist[ hist ], theSystDict=theSystDict )
843 #errsSystDict[ hist ], errsSystDictBin[ hist ] = errsSyst.getSystErr()
844 tuple = errsSyst.getSystErr()
845 errsSystDict[ hist ][ "Up" ] = tuple[ 0 ][ 0 ]
846 errsSystDict[ hist ][ "Dwn" ] = tuple[ 0 ][ 1 ]
847 errsSystDictBin[ hist ] = tuple[ 1 ]
848 pass
849 ########################################################################################
850
851
852 #################### add up the bin errs dicts #########################################
853 #errsCombinedDictBin = deepcopy( errsBinDict ) ### makes a true copy, *not* an alias
854 #if not statErrsOnly:
855 # errsCombinedDictBin = {}
856 # for hist in allHist.keys():
857 # errsCombinedDictBin[ hist ] = {}
858 # errsCombinedDictBin[ hist ][ "All" ] = {}
859 # for bin in errsBinDict[ hist ][ "All" ].keys():
860 # ### both errDicts already squared
861 # errsCombinedDictBin[ hist ][ "All" ][ bin ] = errsBinDict[ hist ][ "All" ][ bin ] + \
862 # errsSystDictBin[ hist ][ bin ]
863 # pass
864 # pass
865 # pass
866
867 errsCombinedDictBin = {}
868 errsCombinedDictBin[ "Up" ] = deepcopy( errsBinDict ) ### makes a true copy, *not* an alias
869 errsCombinedDictBin[ "Dwn" ] = deepcopy( errsBinDict ) ### makes a true copy, *not* an alias
870 if not statErrsOnly:
871 errsCombinedDictBin = {}
872 errsCombinedDictBin[ "Up" ] = {}
873 errsCombinedDictBin[ "Dwn" ] = {}
874 for hist in allHist.keys():
875 errsCombinedDictBin[ "Up" ][ hist ] = {}
876 errsCombinedDictBin[ "Dwn" ][ hist ] = {}
877 errsCombinedDictBin[ "Up" ][ hist ][ "All" ] = {}
878 errsCombinedDictBin[ "Dwn" ][ hist ][ "All" ] = {}
879 for bin in errsBinDict[ hist ][ "All" ].keys():
880 ### both errDicts already squared
881 errsCombinedDictBin[ "Up" ][ hist ][ "All" ][ bin ] = errsBinDict[ hist ][ "All" ][ bin ] + \
882 errsSystDictBin[ hist ][ bin ][ "Up" ]
883 errsCombinedDictBin[ "Dwn" ][ hist ][ "All" ][ bin ] = errsBinDict[ hist ][ "All" ][ bin ] + \
884 errsSystDictBin[ hist ][ bin ][ "Dwn" ]
885 pass
886 pass
887 pass
888
889 ########################################################################################
890
891
892 #### get the hists for the stat errors
893 errHistUpDict = {}
894 errHistDwnDict = {}
895 for hist in allHist.keys():
896 ErrHists = Helper.StatErrorHists( allHist[ hist ],
897 errsCombinedDictBin[ "Up" ][ hist ] ,
898 errsCombinedDictBin[ "Dwn" ][ hist ] ,
899 colorUp=errColor,
900 colorDwn = mcColor )
901 errHistUpDict[ hist ], errHistDwnDict[ hist ] = ErrHists.getErrHists( histname = hist )
902 pass
903
904
905
906 nameMap = {}
907 nameMap[ "MHT" ] = "MHTMHT"
908 nameMap[ "MHTEta" ] = "MHTMHTEta"
909 nameMap[ "MHTPhi" ] = "MHTMHTPhi"
910 nameMap[ "HT" ] = "HTHT"
911 nameMap[ "JetPt" ] = "TauSelectionTau1Pt"
912 nameMap[ "JetEta" ] = "TauSelectionTau1Eta"
913 nameMap[ "JetPhi" ] = "TauSelectionTau1Phi"
914 nameMap[ "Jet1Pt" ] = "JetSelection30Jet1Pt"
915 nameMap[ "Jet1Eta" ] = "JetSelection30Jet1Eta"
916 nameMap[ "Jet1Phi" ] = "JetSelection30Jet1Phi"
917 nameMap[ "Jet2Pt" ] = "JetSelection30Jet2Pt"
918 nameMap[ "Jet2Eta" ] = "JetSelection30Jet2Eta"
919 nameMap[ "Jet2Phi" ] = "JetSelection30Jet2Phi"
920 nameMap[ "Jet3Pt" ] = "JetSelection30Jet3Pt"
921 nameMap[ "Jet3Eta" ] = "JetSelection30Jet3Eta"
922 nameMap[ "Jet3Phi" ] = "JetSelection30Jet3Phi"
923 nameMap[ "nJets" ] = "JetSelection30NumberOfJets"
924 nameMap[ "DPhiMHTTau" ] = "TauSelectiondPhiMHTTau"
925 nameMap[ "MinDPhiMHTJ" ] = "MHTdPhiMinmhtDphi"
926 nameMap[ "DPhi12" ] = "MHTdPhiMindPhi12"
927 nameMap[ "DPhi13" ] = "MHTdPhiMindPhi13"
928 nameMap[ "DPhi23" ] = "MHTdPhiMindPhi23"
929
930 xtitleDict = {}
931 xtitleDict[ "MHT" ] = "#slash H_{T} [GeV]"
932 xtitleDict[ "MHTEta" ] = "#eta^{MHT}"
933 xtitleDict[ "MHTPhi" ] = "#phi^{MHT}"
934 xtitleDict[ "HT" ] = "H_{T} [GeV]"
935 xtitleDict[ "JetPt" ] = "P_{T}^{#tau} [GeV]"
936 xtitleDict[ "JetEta" ] = "#eta^{#tau}"
937 xtitleDict[ "JetPhi" ] = "#phi^{#tau}"
938 xtitleDict[ "Jet1Pt" ] = "P_{T}^{jet1} [GeV]"
939 xtitleDict[ "Jet1Eta" ] = "#eta^{jet1}"
940 xtitleDict[ "Jet1Phi" ] = "#phi^{jet1}"
941 xtitleDict[ "Jet2Pt" ] = "P_{T}^{jet2} [GeV]"
942 xtitleDict[ "Jet2Eta" ] = "#eta^{jet2}"
943 xtitleDict[ "Jet2Phi" ] = "#phi^{jet2}"
944 xtitleDict[ "Jet3Pt" ] = "P_{T}^{jet3} [GeV]"
945 xtitleDict[ "Jet3Eta" ] = "#eta^{jet3}"
946 xtitleDict[ "Jet3Phi" ] = "#phi^{jet3}"
947 xtitleDict[ "nJets" ] = "Number of jets"
948 #xtitleDict[ "MuonDRJet" ] = "#DeltaR(#mu/#tau, jet)"
949 xtitleDict[ "DPhiMHTTau" ] = "#Delta#Phi(MHT,#tau)"
950 xtitleDict[ "DPhi12" ] = "#Delta#Phi(jet1,jet2)"
951 xtitleDict[ "DPhi13" ] = "#Delta#Phi(jet1,jet3)"
952 xtitleDict[ "DPhi23" ] = "#Delta#Phi(jet2,jet3)"
953 xtitleDict[ "MinDPhiMHTJ" ] = "min #Delta#Phi(MHT,jet123)"
954
955 pos = "umr"
956 #if Type == "Full":
957 # pos = "ul"
958 # pass
959
960 markerStyle = 22
961 if re.search( "Data", theTheTitle ) or re.search( "Preliminary", theTheTitle ):
962 markerStyle = 20
963 pass
964
965 cDict = {}
966 legDict = {}
967 ratioDict = {}
968
969 for hist in readIn.histList:
970
971 #### get the x,y titles
972 ytitle = "Events"
973 if re.search( "GeV", xtitleDict[ hist ] ):
974 b = allHist[ hist ].GetBinWidth( 1 )
975 ytitle = "Events/"+ str( int( b ) ) + " GeV"
976 pass
977 ### get new legend position if necessary
978 if hist in posDict.keys():
979 pos = posDict[ hist ]
980 pass
981 ### take your canvas bags ...
982 cDict[ hist ] = ROOT.TCanvas( hist , hist )
983 cDict[ hist ].cd()
984 ### stylings
985 allHist[ hist ].UseCurrentStyle()
986 histDictSel[ nameMap[ hist ] ][ "All" ].UseCurrentStyle()
987 Style.setHistStyle( allHist[ hist ],
988 status="BG",
989 color=mcColor,
990 xTitle=xtitleDict[ hist ],
991 yTitle=ytitle,
992 title=theTitle,
993 )
994 Style.setHistStyle( histDictSel[ nameMap[ hist ] ][ "All" ],
995 status="Data",
996 color=1,
997 xTitle=xtitleDict[ hist ],
998 yTitle=ytitle,
999 title=theTitle,
1000 markerStyle=markerStyle
1001 )
1002 ### draw
1003 allHist[ hist ].Draw( "hist" )
1004 errHistUpDict[ hist ][ "All" ].Draw( "same" )
1005 errHistDwnDict[ hist ][ "All" ].Draw( "same" )
1006 histDictSel[ nameMap[ hist ] ][ "All" ].Draw( "same" )
1007 if( hist in xRangeDict.keys() ):
1008 allHist[ hist ].GetXaxis().SetRangeUser( xRangeDict[ hist ][ 0 ],
1009 xRangeDict[ hist ][ 1 ] )
1010 pass
1011 ### for the axis
1012 allHist[ hist ].Draw( "axissame" )
1013 if logY:
1014 ROOT.gPad.SetLogy()
1015 if( hist in yRangeDict.keys() ):
1016 allHist[ hist ].GetYaxis().SetRangeUser( yRangeDict[ hist ][ 0 ],
1017 yRangeDict[ hist ][ 1 ] )
1018 pass
1019 pass
1020 ### i am legend
1021 legDict[ hist ] = Style.makeLegendSimple( [ histDictSel[ nameMap[ hist ] ][ "All" ],
1022 allHist[ hist ],
1023 errHistUpDict[ hist ][ "All" ] ],
1024 legend,
1025 statusDict=statDict,
1026 position= pos )
1027
1028
1029 legDict[ hist ].Draw( "same" )
1030 #### ratio
1031 if plotRatio:
1032 ratioDict[ hist ] = RT.Ratio( histDictSel[ nameMap[ hist ] ][ "All" ],
1033 allHist[ hist ],
1034 mcHistErrDict=errsCombinedDictBin[ hist ][ "All" ])
1035
1036 ratioDict[ hist ].drawRatio( ROOT.gPad )
1037 pass
1038 pass
1039
1040 if doSystScaling:
1041 print "##############################################"
1042 print "WARNING! Systematic scaling applied!!"
1043 print "##############################################"
1044 pass
1045
1046
1047
1048 ## cDict[ "MHT" ] = ROOT.TCanvas( "MHT" , "MHT" )
1049 ## cDict[ "MHT" ].cd()
1050 ## allHist[ "MHT" ].UseCurrentStyle()
1051 ## histDictSel[ "MHTMHT" ][ "All" ].UseCurrentStyle()
1052 ## Style.setHistStyle( allHist[ "MHT" ],
1053 ## status="BG",
1054 ## color=mcColor,
1055 ## xTitle="MHT [GeV]", yTitle="events", title=theTitle )
1056 ## Style.setHistStyle( histDictSel[ "MHTMHT" ][ "All" ],
1057 ## status="Data",
1058 ## color=1,
1059 ## xTitle="MHT [GeV]", yTitle="events", title=theTitle )
1060 ## allHist[ "MHT" ].Draw( "hist" )
1061 ## errHistUpDict[ "MHT" ][ "All" ].Draw( "same" )
1062 ## errHistDwnDict[ "MHT" ][ "All" ].Draw( "same" )
1063 ## histDictSel[ "MHTMHT" ][ "All" ].Draw( "same" )
1064
1065 ## errHistUpDict[ "MHT" ][ "All" ].Draw( "axissame" )
1066
1067 ## if logY:
1068 ## allHist[ "MHT" ].SetMinimum( 6 * 10**-4 )
1069 ## histDictSel[ "MHTMHT" ][ "All" ].SetMinimum( 6 * 10**-4 )
1070 ## allHist[ "MHT" ].SetMaximum( 10**3 )
1071 ## histDictSel[ "MHTMHT" ][ "All" ].SetMaximum( 10**3 )
1072 ## pass
1073
1074 ## if logY:
1075 ## ROOT.gPad.SetLogy()
1076 ## pass
1077
1078
1079 ## legDict[ "MHT" ] = Style.makeLegendSimple( [ histDictSel[ "MHTMHT" ][ "All" ],
1080 ## allHist[ "MHT" ],
1081 ## errHistUpDict[ "MHT" ][ "All" ], ],
1082 ## legend,
1083 ## statusDict=statDict )
1084
1085
1086 ## legDict[ "MHT" ].Draw( "same" )
1087
1088 ## if plotRatio:
1089 ## ratioDict[ "MHT" ] = Helper.Ratio( histDictSel[ "MHTMHT" ][ "All" ],
1090 ## allHist[ "MHT" ],
1091 ## mcHistErrDict=errsBinDict[ "MHT" ][ "All" ], colorUp=errColor )
1092 ## ratioDict[ "MHT" ].drawRatio( ROOT.gPad )
1093 ## pass
1094
1095
1096
1097 ## cDict[ "HT" ] = ROOT.TCanvas( "HT" , "HT" )
1098 ## cDict[ "HT" ].cd()
1099 ## allHist[ "HT" ].UseCurrentStyle()
1100 ## histDictSel[ "HTHT" ][ "All" ].UseCurrentStyle()
1101 ## Style.setHistStyle( allHist[ "HT" ],
1102 ## status="BG",
1103 ## color=mcColor,
1104 ## xTitle="HT [GeV]", yTitle="events", title=theTitle )
1105 ## Style.setHistStyle( histDictSel[ "HTHT" ][ "All" ],
1106 ## status="Data",
1107 ## color=1,
1108 ## xTitle="HT [GeV]", yTitle="events", title=theTitle )
1109 ## allHist[ "HT" ].Draw( "hist" )
1110 ## errHistUpDict[ "HT" ][ "All" ].Draw( "same" )
1111 ## errHistDwnDict[ "HT" ][ "All" ].Draw( "same" )
1112 ## histDictSel[ "HTHT" ][ "All" ].Draw( "same" )
1113
1114 ## errHistUpDict[ "HT" ][ "All" ].Draw( "axissame" )
1115
1116 ## if logY:
1117 ## allHist[ "HT" ].SetMinimum( 6 * 10**-4 )
1118 ## histDictSel[ "HTHT" ][ "All" ].SetMinimum( 6 * 10**-4 )
1119 ## allHist[ "HT" ].SetMaximum( 10**3 )
1120 ## histDictSel[ "HTHT" ][ "All" ].SetMaximum( 10**3 )
1121 ## pass
1122
1123 ## if logY:
1124 ## ROOT.gPad.SetLogy()
1125 ## pass
1126
1127
1128 ## legDict[ "HT" ] = Style.makeLegendSimple( [ histDictSel[ "HTHT" ][ "All" ],
1129 ## allHist[ "HT" ],
1130 ## errHistUpDict[ "HT" ][ "All" ], ],
1131 ## legend,
1132 ## statusDict=statDict )
1133
1134
1135 ## legDict[ "HT" ].Draw( "same" )
1136
1137 ## if plotRatio:
1138 ## ratioDict[ "HT" ] = Helper.Ratio( histDictSel[ "HTHT" ][ "All" ],
1139 ## allHist[ "HT" ],
1140 ## mcHistErrDict=errsBinDict[ "HT" ][ "All" ], colorUp=errColor )
1141 ## ratioDict[ "HT" ].drawRatio( ROOT.gPad )
1142 ## pass
1143
1144
1145
1146 ## cDict[ "Tau1Pt" ] = ROOT.TCanvas( "Tau1Pt" , "Tau1Pt" )
1147 ## cDict[ "Tau1Pt" ].cd()
1148 ## allHist[ "JetPt" ].UseCurrentStyle()
1149 ## histDictSel[ "TauSelectionTau1Pt" ][ "All" ].UseCurrentStyle()
1150 ## Style.setHistStyle( allHist[ "JetPt" ],
1151 ## status="BG",
1152 ## color=mcColor,
1153 ## xTitle="Tau1 P_{T} [GeV]", yTitle="events", title=theTitle )
1154 ## Style.setHistStyle( histDictSel[ "TauSelectionTau1Pt" ][ "All" ],
1155 ## status="Data",
1156 ## color=1,
1157 ## xTitle="Tau1 P_{T} [GeV]", yTitle="events", title=theTitle )
1158 ## allHist[ "JetPt" ].Draw( "hist" )
1159 ## errHistUpDict[ "JetPt" ][ "All" ].Draw( "same" )
1160 ## errHistDwnDict[ "JetPt" ][ "All" ].Draw( "same" )
1161 ## histDictSel[ "TauSelectionTau1Pt" ][ "All" ].Draw( "same" )
1162
1163 ## errHistUpDict[ "JetPt" ][ "All" ].Draw( "axissame" )
1164
1165 ## if logY:
1166 ## allHist[ "JetPt" ].SetMinimum( 6 * 10**-4 )
1167 ## histDictSel[ "TauSelectionTau1Pt" ][ "All" ].SetMinimum( 6 * 10**-4 )
1168 ## allHist[ "JetPt" ].SetMaximum( 10**3 )
1169 ## histDictSel[ "TauSelectionTau1Pt" ][ "All" ].SetMaximum( 10**3 )
1170 ## pass
1171
1172 ## if logY:
1173 ## ROOT.gPad.SetLogy()
1174 ## pass
1175
1176
1177 ## legDict[ "Tau1Pt" ] = Style.makeLegendSimple( [ histDictSel[ "TauSelectionTau1Pt" ][ "All" ],
1178 ## allHist[ "JetPt" ],
1179 ## errHistUpDict[ "JetPt" ][ "All" ], ],
1180 ## legend,
1181 ## statusDict=statDict )
1182
1183
1184 ## legDict[ "Tau1Pt" ].Draw( "same" )
1185
1186 ## if plotRatio:
1187 ## ratioDict[ "Tau1Pt" ] = Helper.Ratio( histDictSel[ "TauSelectionTau1Pt" ][ "All" ],
1188 ## allHist[ "JetPt" ],
1189 ## mcHistErrDict=errsBinDict[ "JetPt" ][ "All" ], colorUp=errColor )
1190 ## ratioDict[ "Tau1Pt" ].drawRatio( ROOT.gPad )
1191 ## pass
1192
1193
1194 if saveToPS:
1195 Style.saveToPS( saveName, cDict )
1196 pass
1197 if saveToEPS:
1198 Style.saveToEPS( saveName, cDict )
1199 pass
1200 pass
1201
1202 Def.DontQuit()