ViewVC Help
View File | Revision Log | Show Annotations | Root Listing
root/cvsroot/UserCode/nowaf/RootFilesInUse/Scan_cff.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 sys, ROOT, re, math
2 sys.path.append("/afs/naf.desy.de/user/n/nowaf/UserCode/nowaf/PythonScripts/")
3 import styles as Style
4 import definitions as Def
5
6 def readInHist( file, dir ):
7 hist = file.Get( dir + "/nEvts" )
8 hist.SetDirectory( 0 )
9 hist.UseCurrentStyle()
10 return hist
11
12 def readInScanHists( file, list=None ):
13 dirList = [ "ScanAnalyzerMC",
14 "ScanAnalyzerPreMC",
15 "ScanAnalyzerAllMC",
16 "ScanAnalyzerNLO",
17 "ScanAnalyzerPreNLO",
18 "ScanAnalyzerAllNLO",
19 "qcdPred2DPre",
20 "qcdPred2D",
21 "MuonTemplateAnalyzer2D",
22 "MuonTemplateAnalyzer2DPre",
23 "ScanAnalyzerJECUp",
24 "ScanAnalyzerPreJECUp",
25 "ScanAnalyzerJECDn",
26 "ScanAnalyzerPreJECDn",
27 "ScanAnalyzerTEUp",
28 "ScanAnalyzerPreTEUp",
29 "ScanAnalyzerTEDn",
30 "ScanAnalyzerPreTEDn",
31 "ScanAnalyzerNLO2",
32 "ScanAnalyzerPreNLO2",
33 "ScanAnalyzerNLO05",
34 "ScanAnalyzerPreNLO05",
35 "ScanAnalyzerMuonIsoUp",
36 "ScanAnalyzerPreMuonIsoUp",
37 "ScanAnalyzerMuonIsoDn",
38 "ScanAnalyzerPreMuonIsoDn",
39 "ScanAnalyzerElecIsoUp",
40 "ScanAnalyzerPreElecIsoUp",
41 "ScanAnalyzerElecIsoDn",
42 "ScanAnalyzerPreElecIsoDn",
43 #"ScanAnalyzerPrePDFxsec",
44 #"ScanAnalyzerPrePDFxsecUncert",
45 #"ScanAnalyzerPDFxsec",
46 #"ScanAnalyzerPDFxsecUncert",
47 ]
48 if not list == None:
49 dirList = list
50 pass
51
52 histDict = {}
53 for dir in dirList:
54 histDict[ dir ] = readInHist( file, dir )
55 pass
56
57 return histDict
58
59 def getPDFHists( file, histDict ):
60 hist1 = file.Get( "ScanAnalyzerPDF/nEvtsPDF1" )
61 hist1.SetDirectory( 0 )
62 hist1.UseCurrentStyle()
63 histDict[ "ScanAnalyzerPDF" ] = hist1
64 hist2 = file.Get( "ScanAnalyzerPrePDF/nEvtsPDF1" )
65 hist2.SetDirectory( 0 )
66 hist2.UseCurrentStyle()
67 histDict[ "ScanAnalyzerPrePDF" ] = hist2
68 hist3 = file.Get( "ScanAnalyzerAllPDF/nEvtsPDF1" )
69 hist3.SetDirectory( 0 )
70 hist3.UseCurrentStyle()
71 histDict[ "ScanAnalyzerAllPDF" ] = hist3
72 pass
73
74 def getRelPDFErr( histDict, Type="" ):
75
76 h2DUp = ROOT.TH2F( "PDFRateRelUp", "PDFRateRelUp", histDict[ "ScanAnalyzerAllPDF" ].GetNbinsX(),
77 histDict[ "ScanAnalyzerAllPDF" ].GetXaxis().GetXmin(),
78 histDict[ "ScanAnalyzerAllPDF" ].GetXaxis().GetXmax(),
79 histDict[ "ScanAnalyzerAllPDF" ].GetNbinsY(),
80 histDict[ "ScanAnalyzerAllPDF" ].GetYaxis().GetXmin(),
81 histDict[ "ScanAnalyzerAllPDF" ].GetYaxis().GetXmax() )
82 h2DDn = ROOT.TH2F( "PDFRateRelDn", "PDFRateRelDn", histDict[ "ScanAnalyzerAllPDF" ].GetNbinsX(),
83 histDict[ "ScanAnalyzerAllPDF" ].GetXaxis().GetXmin(),
84 histDict[ "ScanAnalyzerAllPDF" ].GetXaxis().GetXmax(),
85 histDict[ "ScanAnalyzerAllPDF" ].GetNbinsY(),
86 histDict[ "ScanAnalyzerAllPDF" ].GetYaxis().GetXmin(),
87 histDict[ "ScanAnalyzerAllPDF" ].GetYaxis().GetXmax() )
88 h2DAccUp = ROOT.TH2F( "PDFAcceptanceRelUp",
89 "PDFAcceptanceRelUp",
90 histDict[ "ScanAnalyzerAllPDF" ].GetNbinsX(),
91 histDict[ "ScanAnalyzerAllPDF" ].GetXaxis().GetXmin(),
92 histDict[ "ScanAnalyzerAllPDF" ].GetXaxis().GetXmax(),
93 histDict[ "ScanAnalyzerAllPDF" ].GetNbinsY(),
94 histDict[ "ScanAnalyzerAllPDF" ].GetYaxis().GetXmin(),
95 histDict[ "ScanAnalyzerAllPDF" ].GetYaxis().GetXmax() )
96 h2DAccDn = ROOT.TH2F( "PDFAcceptanceRelDn",
97 "PDFAcceptanceRelDn",
98 histDict[ "ScanAnalyzerAllPDF" ].GetNbinsX(),
99 histDict[ "ScanAnalyzerAllPDF" ].GetXaxis().GetXmin(),
100 histDict[ "ScanAnalyzerAllPDF" ].GetXaxis().GetXmax(),
101 histDict[ "ScanAnalyzerAllPDF" ].GetNbinsY(),
102 histDict[ "ScanAnalyzerAllPDF" ].GetYaxis().GetXmin(),
103 histDict[ "ScanAnalyzerAllPDF" ].GetYaxis().GetXmax() )
104 ### loop over each susy point
105 for ix in range( 1, histDict[ "ScanAnalyzerAllPDF" ].GetNbinsX() + 1 ):
106 for iy in range( 1, histDict[ "ScanAnalyzerAllPDF" ].GetNbinsY() + 1 ):
107 #### get the pdf mean
108 mean = histDict[ "ScanAnalyzer" + Type + "PDF" ].GetBinContent( ix, iy, 1 )
109 meanAll = histDict[ "ScanAnalyzerAllPDF" ].GetBinContent( ix, iy, 1 )
110 if mean == 0:
111 continue
112 ### get the variations up and dwn
113 nVary = 0
114 errUp = 0
115 errDn = 0
116 errUpAll = 0
117 errDnAll = 0
118 for iz in range( 2, histDict[ "ScanAnalyzerAllPDF" ].GetNbinsZ() + 1 ):
119 ### even is up, odd is dwn
120 even = False
121 nVary += 1
122 if not iz%2:
123 even = True
124 pass
125 value = histDict[ "ScanAnalyzer" + Type + "PDF" ].GetBinContent( ix, iy, iz )
126 valueAll = histDict[ "ScanAnalyzerAllPDF" ].GetBinContent( ix, iy, iz )
127 if even:
128 errUp += ( value - mean )**2
129 errUpAll += ( valueAll - meanAll )**2
130 else:
131 errDn += ( value - mean )**2
132 errDnAll += ( valueAll - meanAll )**2
133 pass
134 pass
135 if not nVary == 0:
136 errUp *= 1/( nVary/2. )
137 errDn *= 1/( nVary/2. )
138 errUpAll *= 1/( nVary/2. )
139 errDnAll *= 1/( nVary/2. )
140 pass
141 ### rel err on rate
142 relErrUp = math.sqrt( errUp )/float( mean )
143 relErrDn = math.sqrt( errUp )/float( mean )
144 h2DUp.SetBinContent( ix, iy, relErrUp )
145 h2DDn.SetBinContent( ix, iy, relErrDn )
146 ### rel err on acc=nsel/ntot
147 ### nsel = mean, ntot = meanAll
148 ### err**2 = ( ErrSel/ntot )**2 + ( nsel * ErrTot/(ntot)**2 )**2
149 Acc = mean/meanAll
150 errAccUp2 = errUp / ( meanAll )**2 + ( mean / meanAll**2 )**2 * errUpAll
151 errAccDn2 = errDn / ( meanAll )**2 + ( mean / meanAll**2 )**2 * errDnAll
152 relErrUpAcc = math.sqrt( errAccUp2 ) / Acc
153 relErrDnAcc = math.sqrt( errAccDn2 ) / Acc
154 h2DAccUp.SetBinContent( ix, iy, relErrUpAcc )
155 h2DAccDn.SetBinContent( ix, iy, relErrDnAcc )
156 pass
157 pass
158 histDict[ "RateRelPDFUp" + Type ] = h2DUp
159 histDict[ "RateRelPDFDn" + Type ] = h2DDn
160 histDict[ "AcceptanceRelPDFUp" + Type ] = h2DAccUp
161 histDict[ "AcceptanceRelPDFDn" + Type ] = h2DAccDn
162 pass
163
164 def getCombTheoRelRateErr( histDict, Type="" ):
165 histList = []
166 for h in histDict.keys():
167 if re.search( "RateRel", h ) and not re.search( "RateRel0", h ) \
168 and ( re.search( "PDFxsecUncert", h ) or re.search( "NLO", h ) ) :
169 histList.append( h )
170 pass
171 pass
172 histNEvts = histDict[ "Rate" + "NLO" + Type ].Clone()
173 xbins = 0
174 xmin = 0
175 xmax = 0
176 ybins = 0
177 ymin = 0
178 ymax = 0
179 if len( histList ) > 0:
180 xbins = histDict[ histList[ 0 ] ].GetNbinsX()
181 ybins = histDict[ histList[ 0 ] ].GetNbinsY()
182 xmin = histDict[ histList[ 0 ] ].GetXaxis().GetXmin()
183 ymin = histDict[ histList[ 0 ] ].GetYaxis().GetXmin()
184 xmax = histDict[ histList[ 0 ] ].GetXaxis().GetXmax()
185 ymax = histDict[ histList[ 0 ] ].GetYaxis().GetXmax()
186 pass
187 histUp = ROOT.TH2F( "RelRateCombTheoUp" + Type, "RelRateCombTheoUp" + Type,
188 xbins, xmin, xmax, ybins, ymin, ymax )
189 histDn = ROOT.TH2F( "RelRateCombTheoDn" + Type, "RelRateCombTheoDn" + Type,
190 xbins, xmin, xmax, ybins, ymin, ymax )
191 entryDictUp = {}
192 entryDictDn = {}
193 for h in histList:
194 ### xbins
195 for ix in range( 1, histDict[ h ].GetNbinsX() + 1 ):
196 if not ix in entryDictUp.keys():
197 entryDictUp[ ix ] = {}
198 entryDictDn[ ix ] = {}
199 pass
200 ### y axis
201 for iy in range( 1, histDict[ h ].GetNbinsY() + 1 ):
202 if not iy in entryDictUp[ ix ].keys():
203 entryDictUp[ ix ][ iy ] = 0
204 entryDictDn[ ix ][ iy ] = 0
205 pass
206 if histDict[ h ].GetBinContent( ix, iy ) == 0:
207 continue
208 if not re.search( "Dn", h ):
209 entryDictUp[ ix ][ iy ] += ( histDict[ h ].GetBinContent( ix, iy ) - 1 )**2
210 pass
211 if not re.search( "Up", h ):
212 entryDictDn[ ix ][ iy ] += ( histDict[ h ].GetBinContent( ix, iy ) - 1 )**2
213 pass
214 pass
215 pass
216 pass
217 if len( histList ) > 0:
218 for ix in range( 1, histDict[ histList[ 0 ] ].GetNbinsX() + 1 ):
219 for iy in range( 1, histDict[ histList[ 0 ] ].GetNbinsY() + 1 ):
220 histUp.SetBinContent( ix, iy, math.sqrt( entryDictUp[ ix ][ iy ] ) )
221 histDn.SetBinContent( ix, iy, math.sqrt( entryDictDn[ ix ][ iy ] ) )
222 pass
223 pass
224 pass
225 histDict[ "RateRelCombTheoUp" + Type ] = histUp
226 histDict[ "RateRelCombTheoDn" + Type ] = histDn
227
228
229
230 def getCombRelRateErr( histDict, Type="", addLumiAndTrig = True, lumiErr=0.045, trigErr=0.025 ):
231 histList = []
232 for h in histDict.keys():
233 if re.search( "RateRel", h ) and not re.search( "RateRel0", h ) \
234 and not re.search( "PDFxsec", h ) and not re.search( "NLO", h ) :
235 histList.append( h )
236 pass
237 #elif re.search( "SignalCont", h ) and re.search( "Rel", h ):
238 # histList.append( h )
239 # pass
240 pass
241 histNEvts = histDict[ "Rate" + "NLO" + Type ].Clone()
242 xbins = 0
243 xmin = 0
244 xmax = 0
245 ybins = 0
246 ymin = 0
247 ymax = 0
248 if len( histList ) > 0:
249 xbins = histDict[ histList[ 0 ] ].GetNbinsX()
250 ybins = histDict[ histList[ 0 ] ].GetNbinsY()
251 xmin = histDict[ histList[ 0 ] ].GetXaxis().GetXmin()
252 ymin = histDict[ histList[ 0 ] ].GetYaxis().GetXmin()
253 xmax = histDict[ histList[ 0 ] ].GetXaxis().GetXmax()
254 ymax = histDict[ histList[ 0 ] ].GetYaxis().GetXmax()
255 pass
256 histUp = ROOT.TH2F( "RelRateCombUp" + Type, "RelRateComb" + Type,
257 xbins, xmin, xmax, ybins, ymin, ymax )
258 histDn = ROOT.TH2F( "RelRateCombDn" + Type, "RelRateComb" + Type,
259 xbins, xmin, xmax, ybins, ymin, ymax )
260 entryDictUp = {}
261 entryDictDn = {}
262 for h in histList:
263 ### xbins
264 for ix in range( 1, histDict[ h ].GetNbinsX() + 1 ):
265 if not ix in entryDictUp.keys():
266 entryDictUp[ ix ] = {}
267 entryDictDn[ ix ] = {}
268 pass
269 ### y axis
270 for iy in range( 1, histDict[ h ].GetNbinsY() + 1 ):
271 if not iy in entryDictUp[ ix ].keys():
272 entryDictUp[ ix ][ iy ] = 0
273 entryDictDn[ ix ][ iy ] = 0
274 pass
275 #print "x=", ix, " y=", iy, histDict[ h ].GetBinContent( ix, iy )
276 if not re.search( "JEC", h ) and not re.search( "TE", h ) \
277 and not re.search( "NLO", h ):
278 if not re.search( "Dn", h ):
279 entryDictUp[ ix ][ iy ] += ( histDict[ h ].GetBinContent( ix, iy ) )**2
280 pass
281 if not re.search( "Up", h ):
282 entryDictDn[ ix ][ iy ] += ( histDict[ h ].GetBinContent( ix, iy ) )**2
283 pass
284 else:
285 if not histDict[ h ].GetBinContent( ix, iy ) == 0:
286 #if not re.search( "Dn", h ):
287 if 1 - histDict[ h ].GetBinContent( ix, iy ) > 0:
288 entryDictUp[ ix ][ iy ] += ( 1 - histDict[ h ].GetBinContent( ix, iy ) )**2
289 pass
290 #if not re.search( "Up", h ):
291 if 1 - histDict[ h ].GetBinContent( ix, iy ) < 0:
292 entryDictDn[ ix ][ iy ] += ( 1 - histDict[ h ].GetBinContent( ix, iy ) )**2
293 pass
294 pass
295 pass
296 pass
297 pass
298 pass
299 if addLumiAndTrig:
300 for ix in range( 1, histNEvts.GetNbinsX() + 1 ):
301 for iy in range( 1, histNEvts.GetNbinsY() + 1 ):
302 if histNEvts.GetBinContent( ix, iy ) == 0:
303 continue
304 entryDictUp[ ix ][ iy ] += lumiErr**2 + trigErr**2
305 entryDictDn[ ix ][ iy ] += lumiErr**2 + trigErr**2
306 pass
307 pass
308 pass
309 if len( histList ) > 0:
310 for ix in range( 1, histDict[ histList[ 0 ] ].GetNbinsX() + 1 ):
311 for iy in range( 1, histDict[ histList[ 0 ] ].GetNbinsY() + 1 ):
312 histUp.SetBinContent( ix, iy, math.sqrt( entryDictUp[ ix ][ iy ] ) )
313 histDn.SetBinContent( ix, iy, math.sqrt( entryDictDn[ ix ][ iy ] ) )
314 pass
315 pass
316 pass
317 histDict[ "RateRelCombUp" + Type ] = histUp
318 histDict[ "RateRelCombDn" + Type ] = histDn
319 pass
320
321 def getCombRelAccErr( histDict, Type="", addLumiAndTrig = True, lumiErr=0.045, trigErr=0.063 ):
322 histList = []
323 for h in histDict.keys():
324 if re.search( "AcceptanceRel", h ):
325 histList.append( h )
326 pass
327 pass
328 histNEvts = histDict[ "Acceptance" + "NLO" + Type ].Clone()
329 xbins = 0
330 xmin = 0
331 xmax = 0
332 ybins = 0
333 ymin = 0
334 ymax = 0
335 if len( histList ) > 0:
336 xbins = histDict[ histList[ 0 ] ].GetNbinsX()
337 ybins = histDict[ histList[ 0 ] ].GetNbinsY()
338 xmin = histDict[ histList[ 0 ] ].GetXaxis().GetXmin()
339 ymin = histDict[ histList[ 0 ] ].GetYaxis().GetXmin()
340 xmax = histDict[ histList[ 0 ] ].GetXaxis().GetXmax()
341 ymax = histDict[ histList[ 0 ] ].GetYaxis().GetXmax()
342 pass
343 histUp = ROOT.TH2F( "RelAccCombUp" + Type, "RelAccCombUp" + Type,
344 xbins, xmin, xmax, ybins, ymin, ymax )
345 histDn = ROOT.TH2F( "RelAccCombDn" + Type, "RelAccCombDn" + Type,
346 xbins, xmin, xmax, ybins, ymin, ymax )
347 entryDictUp = {}
348 entryDictDn = {}
349 for h in histList:
350 ### xbins
351 for ix in range( 1, histDict[ h ].GetNbinsX() + 1 ):
352 if not ix in entryDictUp.keys():
353 entryDictDn[ ix ] = {}
354 entryDictUp[ ix ] = {}
355 pass
356 ### y axis
357 for iy in range( 1, histDict[ h ].GetNbinsY() + 1 ):
358 if not iy in entryDictUp[ ix ].keys():
359 entryDictUp[ ix ][ iy ] = 0
360 entryDictDn[ ix ][ iy ] = 0
361 pass
362 if not re.search( "JEC", h ) and not re.search( "TE", h ) \
363 and not re.search( "NLO", h ):
364 if not re.search( "Dn", h ):
365 entryDictUp[ ix ][ iy ] += ( histDict[ h ].GetBinContent( ix, iy ) )**2
366 pass
367 if not re.search( "Up", h ):
368 entryDictDn[ ix ][ iy ] += ( histDict[ h ].GetBinContent( ix, iy ) )**2
369 pass
370 else:
371 if not histDict[ h ].GetBinContent( ix, iy ) == 0:
372 if 1 - histDict[ h ].GetBinContent( ix, iy ) > 0:
373 #if not re.search( "Dn", h ):
374 entryDictUp[ ix ][ iy ] += ( 1 - histDict[ h ].GetBinContent( ix, iy ) )**2
375 pass
376 #if not re.search( "Up", h ):
377 if 1 - histDict[ h ].GetBinContent( ix, iy ) < 0:
378 entryDictDn[ ix ][ iy ] += ( 1 - histDict[ h ].GetBinContent( ix, iy ) )**2
379 pass
380 pass
381 pass
382 pass
383 pass
384 pass
385 if addLumiAndTrig:
386 for ix in range( 1, histNEvts.GetNbinsX() + 1 ):
387 for iy in range( 1, histNEvts.GetNbinsY() + 1 ):
388 if histNEvts.GetBinContent( ix, iy ) == 0:
389 continue
390 entryDictUp[ ix ][ iy ] += lumiErr**2 + trigErr**2
391 entryDictDn[ ix ][ iy ] += lumiErr**2 + trigErr**2
392 pass
393 pass
394 pass
395 if len( histList ) > 0:
396 for ix in range( 1, histDict[ histList[ 0 ] ].GetNbinsX() + 1 ):
397 for iy in range( 1, histDict[ histList[ 0 ] ].GetNbinsY() + 1 ):
398 histUp.SetBinContent( ix, iy, math.sqrt( entryDictUp[ ix ][ iy ] ) )
399 histDn.SetBinContent( ix, iy, math.sqrt( entryDictDn[ ix ][ iy ] ) )
400 pass
401 pass
402 pass
403 histDict[ "AcceptanceRelCombUp" + Type ] = histUp
404 histDict[ "AcceptanceRelCombDn" + Type ] = histDn
405 pass
406
407 def getRelRate( histDict, rate1, rate2, Type="" ):
408 histRate1 = histDict[ "Rate" + rate1 + Type ].Clone()
409 histRate2 = histDict[ "Rate" + rate2 + Type ].Clone()
410 histRate1.Divide( histRate2 )
411 histDict[ "RateRel" + rate1 + Type ] = histRate1
412 histRate10 = histRate1.Clone()
413 for ix in range( 1,histRate10.GetNbinsX() + 1 ):
414 for iy in range( 1,histRate10.GetNbinsY() + 1 ):
415 if not histRate10.GetBinContent( ix, iy ) == 0:
416 histRate10.SetBinContent( ix, iy, math.fabs( histRate10.GetBinContent( ix, iy ) - 1 ) )
417 pass
418 pass
419 pass
420 histDict[ "RateRel0" + rate1 + Type ] = histRate10
421 pass
422
423 def getRelAcc( histDict, acc1, acc2, Type="" ):
424 histAcc1 = histDict[ "Acceptance" + acc1 + Type ].Clone()
425 histAcc2 = histDict[ "Acceptance" + acc2 + Type ].Clone()
426 histAcc1.Divide( histAcc2 )
427 histDict[ "AcceptanceRel" + acc1 + Type ] = histAcc1
428 pass
429
430 ## def getSignalCont( histDict, Type="", backgr="QCD", data=2.9, lumi=4.4 ):
431 ## hist = histDict[ "qcdPred2D" ].Clone()
432 ## if backgr == "QCD" and Type == "Pre":
433 ## hist = histDict[ "qcdPred2DPre" ].Clone()
434 ## elif backgr == "Muon":
435 ## hist = histDict[ "MuonTemplateAnalyzer2D" ].Clone()
436 ## if Type == "Pre":
437 ## hist = histDict[ "MuonTemplateAnalyzer2DPre" ].Clone()
438 ## pass
439 ## pass
440 ## histNEvtsTotal = histDict[ "ScanAnalyzerAllMC" ].Clone()
441 ## hist.Divide( histNEvtsTotal )
442 ## hist.Scale( lumi * 1000 )
443 ## histDict[ "SignalCont" + backgr + Type ] = hist.Clone()
444 ## histRel = hist.Clone()
445 ## histRel.Scale( 1/float(data) )
446 ## histDict[ "SignalCont" + backgr + "Rel" + Type ] = histRel.Clone()
447 ## pass
448
449 def getSignalCont( histDict, Type="", backgr="QCD", data=2.9, lumi=4.4 ):
450 hist = histDict[ "qcdPred2D" ].Clone()
451 if backgr == "QCD" and Type == "Pre":
452 hist = histDict[ "qcdPred2DPre" ].Clone()
453 elif backgr == "Muon":
454 hist = histDict[ "MuonTemplateAnalyzer2D" ].Clone()
455 if Type == "Pre":
456 hist = histDict[ "MuonTemplateAnalyzer2DPre" ].Clone()
457 pass
458 pass
459 histNEvtsTotal = histDict[ "ScanAnalyzerAllMC" ].Clone()
460 hist.Divide( histNEvtsTotal )
461 hist.Scale( lumi * 1000 )
462 histDict[ "SignalCont" + backgr + Type ] = hist.Clone()
463 histRel = hist.Clone()
464 #histRel.Scale( 1/float(data) )
465 histNEvtsNLO = histDict[ "ScanAnalyzer" + Type + "NLO" ].Clone()
466 histRel.Divide( histNEvtsNLO )
467 histDict[ "SignalCont" + backgr + "Rel" + Type ] = histRel.Clone()
468 pass
469
470
471 def getAccHist( histDict, appendix, Type="", otherApp=None ):
472 hist = histDict[ "ScanAnalyzer" + appendix ].Clone()
473 if Type == "Pre":
474 hist = histDict[ "ScanAnalyzerPre" + appendix ].Clone()
475 pass
476 if otherApp == None:
477 hist.Divide( histDict[ "ScanAnalyzerAll" + appendix ] )
478 else:
479 hist.Divide( histDict[ "ScanAnalyzerAll" + otherApp ] )
480 pass
481 histDict[ "Acceptance" + appendix + Type ] = hist
482 pass
483
484 def getRateHist( histDict, appendix, Type="", lumi=4.4 ):
485 hist = histDict[ "ScanAnalyzer" + Type + appendix ].Clone()
486 #### NLO hist is weighted to pb
487 #### *1000 ===> fb
488 #### / nEvtsTotal
489 histNEvtsTotal = histDict[ "ScanAnalyzerAllMC" ].Clone()
490 hist.Divide( histNEvtsTotal )
491 hist.Scale( lumi * 1000 )
492 histDict[ "Rate"+ appendix + Type ] = hist
493 pass
494
495 def drawRelErr( histDict,
496 app,
497 Type="",
498 xTitle="m_{0} [GeV]",
499 yTitle="m_{1/2} [GeV]",
500 title="" ):
501 cDict = {}
502 if app in [ "MuonIsoUp", "MuonIsoDn", "ElecIsoUp", "ElecIsoDn", "CombUp", "CombDn", "PDFUp", "PDFDn", "CombTheoUp", "CombTheoDn" ]:
503 Style.setHistStyle( histDict[ "RateRel" + app + Type ],
504 xTitle=xTitle,
505 yTitle=yTitle,
506 title=title )
507 else:
508 Style.setHistStyle( histDict[ "RateRel0" + app + Type ],
509 xTitle=xTitle,
510 yTitle=yTitle,
511 title=title )
512 #Style.setHistStyle( histDict[ "AcceptanceRel" + app + Type ],
513 # xTitle=xTitle,
514 # yTitle=yTitle,
515 # title=title )
516 ## take your canvas bags ...
517 cDict[ "RateRel" + app + Type ] = ROOT.TCanvas( "RateRel" + app + Type,
518 "RateRel" + app + Type )
519 cDict[ "RateRel" + app + Type ].cd()
520 if app in [ "MuonIsoUp", "MuonIsoDn", "ElecIsoUp", "ElecIsoDn", "CombUp", "CombDn", "PDFUp", "PDFDn", "CombTheoUp", "CombTheoDn" ]:
521 histDict[ "RateRel" + app + Type ].Draw( "COLZ" )
522 else:
523 histDict[ "RateRel0" + app + Type ].Draw( "COLZ" )
524
525 #cDict[ "AcceptanceRel" + app + Type ] = ROOT.TCanvas( "AcceptanceRel" + app + Type,
526 # "AcceptanceRel" + app + Type )
527 #cDict[ "AcceptanceRel" + app + Type ].cd()
528 #histDict[ "AcceptanceRel" + app + Type ].Draw( "COLZ" )
529
530 return cDict
531
532 def drawSignalCont( histDict,
533 Type="",
534 backgr="QCD",
535 xTitle="m_{0} [GeV]",
536 yTitle="m_{1/2} [GeV]",
537 title="" ):
538 cDict = {}
539 Style.setHistStyle( histDict[ "SignalCont" + backgr + Type ],
540 xTitle=xTitle,
541 yTitle=yTitle,
542 title=title )
543 Style.setHistStyle( histDict[ "SignalCont" + backgr + "Rel" + Type ],
544 xTitle=xTitle,
545 yTitle=yTitle,
546 title=title )
547 ### take your canvas bags ...
548 cDict[ "SignalCont" + backgr + Type ] = ROOT.TCanvas( "SignalCont" + backgr + Type,
549 "SignalCont" + backgr + Type )
550 cDict[ "SignalCont" + backgr + Type ].cd()
551 histDict[ "SignalCont" + backgr + Type ].GetZaxis().SetRangeUser( 10**-5, 10**2 )
552 histDict[ "SignalCont" + backgr + Type ].Draw( "COLZ" )
553 ROOT.gPad.SetLogz()
554
555 cDict[ "SignalCont" + backgr + "Rel" + Type ] = ROOT.TCanvas( "SignalCont" + backgr + "Rel" + Type,
556 "SignalCont" + backgr + "Rel" + Type )
557 cDict[ "SignalCont" + backgr + "Rel" + Type ].cd()
558 histDict[ "SignalCont" + backgr+ "Rel" + Type ].GetZaxis().SetRangeUser( 10**-3, 1 )
559 histDict[ "SignalCont" + backgr + "Rel" + Type ].Draw( "COLZ" )
560 ROOT.gPad.SetLogz()
561
562 return cDict
563
564 def drawStandard( histDict, Type="", xTitle="m_{0} [GeV]", yTitle="m_{1/2} [GeV]", title="" ):
565 cDict = {}
566 Style.setHistStyle( histDict[ "Rate" + "NLO" + Type ],
567 xTitle=xTitle,
568 yTitle=yTitle,
569 title=title )
570 Style.setHistStyle( histDict[ "Acceptance" + "NLO" + Type ],
571 xTitle=xTitle,
572 yTitle=yTitle,
573 title=title )
574 ### take your canvas bags ...
575 cDict[ "Rate" + "NLO" + Type ] = ROOT.TCanvas( "Rate" + Type + "NLO" , "Rate" + Type + "NLO" )
576 cDict[ "Rate" + "NLO" + Type ].cd()
577 histDict[ "Rate" + "NLO" + Type ].GetZaxis().SetRangeUser( 10**-4, 4*10**2 )
578 histDict[ "Rate" + "NLO" + Type ].Draw( "COLZ" )
579 ROOT.gPad.SetLogz()
580
581 cDict[ "Acc" + "NLO" + Type ] = ROOT.TCanvas( "Acc" + Type + "NLO" , "Acc" + Type + "NLO" )
582 cDict[ "Acc" + "NLO" + Type ].cd()
583 histDict[ "Acceptance" + "NLO" + Type ].Draw( "COLZ" )
584 ROOT.gPad.SetLogz()
585
586 return cDict
587
588 def drawMC( histDict, xTitle="m_{0} [GeV]", yTitle="m_{1/2} [GeV]", title="" ):
589 cDict = {}
590 Style.setHistStyle( histDict[ "ScanAnalyzerAllMC" ],
591 xTitle=xTitle,
592 yTitle=yTitle,
593 title=title )
594 Style.setHistStyle( histDict[ "ScanAnalyzerPreMC" ],
595 xTitle=xTitle,
596 yTitle=yTitle,
597 title=title )
598 Style.setHistStyle( histDict[ "ScanAnalyzerMC" ],
599 xTitle=xTitle,
600 yTitle=yTitle,
601 title=title )
602 ### take your canvas bags ...
603 cDict[ "MCAll" ] = ROOT.TCanvas( "MCAll" , "MCAll" )
604 cDict[ "MCAll" ].cd()
605 histDict[ "ScanAnalyzerAllMC" ].Draw( "COLZ" )
606
607 cDict[ "MCPre" ] = ROOT.TCanvas( "MCPre" , "MCPre" )
608 cDict[ "MCPre" ].cd()
609 histDict[ "ScanAnalyzerPreMC" ].GetZaxis().SetRangeUser( 10**0, 6*10**2 )
610 histDict[ "ScanAnalyzerPreMC" ].Draw( "COLZ" )
611 ROOT.gPad.SetLogz()
612
613 cDict[ "MC" ] = ROOT.TCanvas( "MC" , "MC" )
614 cDict[ "MC" ].cd()
615 histDict[ "ScanAnalyzerMC" ].GetZaxis().SetRangeUser( 10**0, 4*10**2 )
616 histDict[ "ScanAnalyzerMC" ].Draw( "COLZ" )
617 ROOT.gPad.SetLogz()
618
619 return cDict
620