ViewVC Help
View File | Revision Log | Show Annotations | Root Listing
root/cvsroot/UserCode/nowaf/RootFilesInUse/MakeRealTauEst2Gen.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

# User Rev Content
1 nowak 1.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 RT
7    
8     if __name__ == "__main__":
9    
10     Def.SetGlobalStyles()
11     ROOT.gStyle.SetHatchesLineWidth( 1 )
12    
13     fileName = "_lxii"
14     #fileDir = "/scratch/hh/lustre/cms/user/nowaf/2011Data/VersionII/Plots/TTbar_TaNC_viii_unbinned/"
15     fileDir = "/scratch/hh/lustre/cms/user/nowaf/2011Data/VersionII/Plots/RealTauEst/"
16     #fileDir = "/afs/naf.desy.de/group/cms/scratch/nowaf/CMSSW_4_2_4/src/RA2/Configuration/test/"
17    
18     Type = "Pre"
19     #Type = "Full"
20    
21     saveToEPS = False
22     saveToPS = False
23     saveName = "plots/RealTauEst_MCClosure_binned_gen" + fileName + "_" + Type
24    
25     draw = True
26     mcColor = ROOT.kGreen - 9
27     logY = True
28    
29     useDataEff = False
30    
31     removeSamplesAcc = []
32     removeSamplesAcc.append( "TTbar" )
33     removeSamplesAcc.append( "GVJets" )
34     removeSamplesAcc.append( "WWJets" )
35     removeSamplesAcc.append( "Zinv" )
36     removeSamplesAcc.append( "ZJets" )
37     #removeSamplesAcc.append( "WJets" )
38     removeSamplesAcc.append( "QCDFlat" )
39     removeSamplesAcc.append( "Data" )
40    
41     ### currently: All the same
42     removeSamplesEff = removeSamplesAcc
43     removeSamplesRT = removeSamplesAcc
44     removeSamplesMT = removeSamplesAcc
45    
46     addSample = []
47     #addSample.append( "WWJets" )
48    
49     dirAcc = ""
50     dirEff = ""
51     dirRT = ""
52     dir = ""
53     #rebin = 4
54     rebinDict = {}
55     rebinDict[ "MHTMHT" ] = 4
56     rebinDict[ "MHTGen" ] = 4
57     rebinDict[ "MHTUnscaledGen" ] = 4
58     rebinDict[ "HTHT" ] = 4
59     rebinDict[ "HTGen" ] = 4
60     rebinDict[ "HTUnscaledGen" ] = 4
61     rebinDict[ "Tau1PtGenUnscaled" ] = 2
62     rebinDict[ "Tau1PtGen" ] = 2
63     rebinDict[ "TauSelectionTau1Pt" ] = 2
64    
65    
66     if Type == "Pre":
67     #dirAcc = "MuonAnalyzerPre/"
68     ##dirAcc = "finalPlotMuonTauPrePrompt/"
69     dirAcc = "MuonAnalyzerPre/"
70     dirEff = "EffRatePre/"
71     dir = "MuonTemplateAnalyzerGen/"
72     dirRT = "finalPlotTauPreSelectionGen/"
73     pass
74     elif Type == "Full":
75     dirAcc = "MuonAnalyzer/"
76     dirEff = "EffRate/"
77     dirRT = "finalPlotTauGen/"
78     dir = "MuonTemplateAnalyzer/"
79     rebin = 5
80     pass
81    
82     accReadIn = RT.ReadIn( fileDir, fileName )
83     accReadIn.removeSamples( removeSamplesAcc )
84     accReadIn.addSamples( addSample )
85     accReadIn.removeHists( [ "MHT" ] )
86     accReadIn.addHists( [ "MuonPt", "MuonPtPrompt", "MuonPtPromptNotFromTau",
87     "GenMuonPt", "GenMuonPtMatched" ] )
88     accReadIn.dontScale()
89     histDictAcc = accReadIn.getHists( dirAcc )
90     histDictAccOneBin = {}
91     for hist in accReadIn.histList:
92     OBH = RT.OneBinHist( histDictAcc[ hist ] )
93     histDictAccOneBin[ hist ] = OBH.getOneBinHists()
94     pass
95    
96     #muonReco = {}
97     #muonPrompt = {}
98     #muonNoTau = {}
99     #print "--------- reco/iso/prompt/notFromTau eff---------"
100     #for sample in accReadIn.sampleList:
101     # muonReco[ sample ] = RT.Eff( histDictAccOneBin[ "GenMuonPtMatched" ][ sample ].GetBinContent( 1 ),
102     # histDictAccOneBin[ "GenMuonPt" ][ sample ].GetBinContent( 1 ) )
103     # muonPrompt[ sample ] = RT.Eff( histDictAccOneBin[ "MuonPtPrompt" ][ sample ].GetBinContent( 1 ),
104     # histDictAccOneBin[ "MuonPt" ][ sample ].GetBinContent( 1 ) )
105     # muonNoTau[ sample ] = RT.Eff( histDictAccOneBin[ "MuonPtPromptNotFromTau" ][ sample ].GetBinContent( 1 ),
106     # histDictAccOneBin[ "MuonPtPrompt" ][ sample ].GetBinContent( 1 ) )
107    
108     # print sample, " :", " reco eff=", round( muonReco[ sample ].eff, 2 ), \
109     # " +", round( muonReco[ sample ].errUp,2 ), " -", round( muonReco[ sample ].errDwn,2 ), \
110     # " | prob prompt=", round( muonPrompt[ sample ].eff, 2 ), \
111     # " +", round( muonPrompt[ sample ].errUp,2 ), " -", round( muonPrompt[ sample ].errDwn,2 ), \
112     # " | prob no tau=", round( muonNoTau[ sample ].eff, 2 ), \
113     # " +", round( muonNoTau[ sample ].errUp,2 ), " -", round( muonNoTau[ sample ].errDwn,2 )
114     # pass
115    
116    
117    
118     #accReadIn = RT.ReadIn( fileDir, fileName )
119     #accReadIn.removeSamples( removeSamplesAcc )
120     #accReadIn.addSamples( addSample )
121     #accReadIn.removeHists( [ "MHT" ] )
122     #accReadIn.addHists( [ "MHTMuonTauNumberOfPassed_n1",
123     # "MHTMuonTauNumberOfPassedGen_n1",
124     # "MHTMuonTauNumberOfPassedGenFromTau_n1" ] )
125     #accReadIn.dontScale()
126     #histDictAcc = accReadIn.getHists( dirAcc )
127    
128     #muonAcc = {}
129     #print
130     #print "----- acceptance ------"
131     #for sample in accReadIn.sampleList:
132     # passedBin = histDictAcc[ "MHTMuonTauNumberOfPassed_n1" ][ sample ].FindBin( 1. )
133     # muonAcc[ sample ] = RT.Eff( histDictAcc[ "MHTMuonTauNumberOfPassed_n1" ][ sample ].GetBinContent( passedBin ),
134     # histDictAcc[ "MHTMuonTauNumberOfPassedGen_n1" ][ sample ].GetBinContent( passedBin ) )
135     # print sample, ": reco=", int( muonAcc[ sample ].upper ) ,\
136     # " gen=", int( muonAcc[ sample ].lower ), " acc=", round( muonAcc[ sample ].eff, 2 ),\
137     # " + ", round( muonAcc[ sample ].errUp, 2 ), " - ", round( muonAcc[ sample ].errDwn, 2 )
138     # pass
139     #print
140    
141     #print "WARNING! setting reco, prompt, notau to 1!"
142     #for key in muonReco.keys():
143     # muonReco[ key ].eff = 1.
144     # muonReco[ key ].errUp = 0.
145     # muonReco[ key ].errDwn = 0.
146     # muonPrompt[ key ].eff = 1.
147     # muonPrompt[ key ].errUp = 0.
148     # muonPrompt[ key ].errDwn = 0.
149     # muonNoTau[ key ].eff = 1.
150     # muonNoTau[ key ].errUp = 0.
151     # muonNoTau[ key ].errDwn = 0.
152     # pass
153     #print
154     #print
155     #pass
156    
157    
158    
159    
160     #muonFromTau = {}
161     #print
162     #print "----- muons from tau ------"
163     #for sample in accReadIn.sampleList:
164     # passedBin = histDictAcc[ "MHTMuonTauNumberOfPassedGen_n1" ][ sample ].FindBin( 1. )
165     # muonFromTau[ sample ] = RT.Eff( histDictAcc[ "MHTMuonTauNumberOfPassedGenFromTau_n1" ][ sample ].\
166     # GetBinContent( passedBin ),
167     # histDictAcc[ "MHTMuonTauNumberOfPassedGen_n1" ][ sample ].\
168     # GetBinContent( passedBin ) )
169     # print sample, ": from tau=", int( muonFromTau[ sample ].upper ) ,\
170     # " all=", int( muonFromTau[ sample ].lower ), " frac=", round( muonFromTau[ sample ].eff, 2 ),\
171     # " + ", round( muonFromTau[ sample ].errUp, 2 ), " - ", round( muonFromTau[ sample ].errDwn, 2 )
172     # pass
173     #print
174    
175     #effReadIn = RT.ReadIn( fileDir, fileName )
176     #effReadIn.removeSamples( removeSamplesEff )
177     #effReadIn.addSamples( addSample )
178     #effReadIn.removeHists( [ "MHT" ] )
179     #effReadIn.addHists( [ "TauPt", "GenPt" ] )
180     #effReadIn.dontScale()
181     #histDictEff = effReadIn.getHists( dirEff )
182    
183     tauEff = {}
184     #print
185     #print "----- efficiency ------"
186     for sample in accReadIn.sampleList:
187     tauEff[ sample ] = RT.Eff( 1.,1. )
188     # tauEff[ sample ] = RT.Eff( histDictEff[ "TauPt" ][ sample ].Integral(),
189     # histDictEff[ "GenPt" ][ sample ].Integral() )
190     # print sample, ": reco=", int( tauEff[ sample ].upper ) ,\
191     # " gen=", int( tauEff[ sample ].lower ), " eff=", round( tauEff[ sample ].eff, 2 ),\
192     # " + ", round( tauEff[ sample ].errUp, 2 ), " - ", round( tauEff[ sample ].errDwn, 2 )
193     # pass
194     #print
195    
196     #if useDataEff:
197     # print "Using reco eff from data: 50% +- 24%"
198     # for key in tauEff.keys():
199     # tauEff[ key ].eff = 0.5
200     # tauEff[ key ].errUp = 0.24
201     # tauEff[ key ].errDwn = 0.24
202     # pass
203     # print
204     # print
205     # pass
206    
207    
208    
209     for key in tauEff.keys():
210     tauEff[ key ].eff = 1.
211     tauEff[ key ].errUp = 0.
212     tauEff[ key ].errDwn = 0.
213     pass
214    
215    
216     realTausReadIn = RT.ReadIn( fileDir, fileName, rebinDict=rebinDict )
217     realTausReadIn.removeSamples( removeSamplesRT )
218     realTausReadIn.addSamples( addSample )
219     realTausReadIn.removeHists( [ "MHT" ] )
220     realTausReadIn.addHists( [ "MHTMHT" ] )
221     realTausReadIn.addHists( [ "HTHT" ] )
222     realTausReadIn.addHists( [ "TauSelectionTau1Pt" ] )
223     histDictRT = realTausReadIn.getHists( dirRT )
224    
225    
226     realTausReadInUnscaled = RT.ReadIn( fileDir, fileName, rebinDict=rebinDict )
227     realTausReadInUnscaled.removeSamples( removeSamplesRT )
228     realTausReadInUnscaled.addSamples( addSample )
229     realTausReadInUnscaled.removeHists( [ "MHT" ] )
230     realTausReadInUnscaled.addHists( [ "MHTMHT" ] )
231     realTausReadInUnscaled.addHists( [ "HTHT" ] )
232     realTausReadInUnscaled.addHists( [ "TauSelectionTau1Pt" ] )
233     realTausReadInUnscaled.dontScale()
234     histDictRTUnscaled = realTausReadInUnscaled.getHists( dirRT )
235     errsRTDict = {}
236     errsBinRTDict = {}
237     for hist in realTausReadInUnscaled.histList:
238     errsRT = RT.StackErr( histDictRT[ hist ], histDictRTUnscaled[ hist ] )
239     errsRTDict[ hist ], errsBinRTDict[ hist ] = errsRT.getStackErr()
240     pass
241     for hist in realTausReadIn.histList:
242     addup = RT.AddUp( histDictRT[ hist ] )
243     histDictRT[ hist ][ "All" ] = addup.add()
244     pass
245    
246     print
247     print "----- real taus -----"
248     for hist in [ "MHTMHT" ]:
249     print hist
250     for sample in realTausReadIn.sampleList:
251     print sample, ": nEvts=", round( histDictRT[ hist ][ sample ].Integral(), 2 ), " +- ",\
252     round( errsRTDict[ hist ][ sample ], 2 )
253     pass
254     print "======="
255     print "All: nEvts=", round( histDictRT[ hist ][ "All" ].Integral(), 2 ), " +- ",\
256     round( errsRTDict[ hist ][ "All" ], 2 )
257     pass
258     print
259     #print "Number of events used (scaled)=", histDictRT[ "MHTMHT" ][ "All" ]
260     #print "nEvents in tau sample at L=", round(lumi, 0)
261     #for sample in realTausReadInUnscaled.sampleList:
262     # print "\t", sample, " : ", histDictRT[ "MHTMHT" ][ sample ].Integral()
263     # pass
264     #print
265     print "nEvents (MC) in tau sample"
266     for sample in realTausReadInUnscaled.sampleList:
267     print "\t", sample, " : ", histDictRTUnscaled[ "MHTMHT" ][ sample ].Integral(),\
268     " +- ", round( math.sqrt( histDictRTUnscaled[ "MHTMHT" ][ sample ].Integral() ), 2 )
269     pass
270     print
271    
272     muonTausReadIn = RT.ReadIn( fileDir, fileName, rebinDict=rebinDict )
273     muonTausReadIn.removeSamples( removeSamplesMT )
274     muonTausReadIn.addSamples( addSample )
275     muonTausReadIn.removeHists( [ "MHT" ] )
276     muonTausReadIn.addHists( [ "MHTGen" ] )
277     muonTausReadIn.addHists( [ "HTGen" ] )
278     muonTausReadIn.addHists( [ "Tau1PtGen" ] )
279     #muonTausReadIn.addHists( [ "MHT" ] )
280     #muonTausReadIn.addHists( [ "HT" ] )
281     #muonTausReadIn.addHists( [ "Tau1Pt" ] )
282     histDictMT = muonTausReadIn.getHists( dir )
283     #allHistMT = {}
284     #for hist in muonTausReadIn.histList:
285     # addup = RT.AddUp( histDictMT[ hist ] )
286     # #histDictMT[ hist ][ "All" ] = addup.add()
287     # allHistMT[ hist ] = addup.add()
288     # pass
289    
290     muonTausReadInUnscaled = RT.ReadIn( fileDir, fileName, rebinDict=rebinDict )
291     muonTausReadInUnscaled.removeSamples( removeSamplesMT )
292     muonTausReadInUnscaled.addSamples( addSample )
293     muonTausReadInUnscaled.removeHists( [ "MHT" ] )
294     muonTausReadInUnscaled.addHists( [ "MHTUnscaledGen" ] )
295     muonTausReadInUnscaled.addHists( [ "HTUnscaledGen" ] )
296     muonTausReadInUnscaled.addHists( [ "Tau1PtGenUnscaled" ] )
297     #muonTausReadInUnscaled.addHists( [ "MHTUnscaled" ] )
298     #muonTausReadInUnscaled.addHists( [ "HTUnscaled" ] )
299     #muonTausReadInUnscaled.addHists( [ "Tau1PtUnscaled" ] )
300     muonTausReadInUnscaled.dontScale()
301     histDictMTUnscaled = muonTausReadInUnscaled.getHists( dir )
302    
303    
304    
305     #pred = RT.RealTauPred( histDictMT, acc=muonAcc, eff=tauEff )
306     pred = RT.RealTauPred( histDictMT, reco={}, prompt={}, notau={}, eff={} )
307     predHistDict = pred.predHistDict
308     allHistMT = {}
309     for hist in predHistDict.keys():
310     addup = RT.AddUp( predHistDict[ hist ] )
311     allHistMT[ hist ] = addup.add()
312     pass
313    
314     #allHistMT[ "MHTGen" ].Rebin( rebin )
315     #histDictRT[ "MHTMHT" ][ "All" ].Rebin( rebin )
316     ##errHistUpDict[ "MHTGen" ][ "All" ].Rebin( rebin )
317     ##errHistDwnDict[ "MHTGen" ][ "All" ].Rebin( rebin )
318    
319    
320     errsMTDict = {}
321     errsMTDictBin = {}
322     for hist in muonTausReadInUnscaled.histList:
323     nameScaled = "".join( hist.split( "Unscaled" ) )
324     errsMT = RT.StackErr( histDictMT[ nameScaled ], histDictMTUnscaled[ hist ] )
325     errsMTDict[ nameScaled ], errsMTDictBin[ nameScaled ] = errsMT.getStackErr()
326     pass
327    
328     print "nEvents in muon sample at L=", round( muonTausReadIn.lumi, 0 )
329     for sample in realTausReadInUnscaled.sampleList:
330     print "\t", sample, " : ", round( histDictMT[ "MHTGen" ][ sample ].Integral() ,2 ),\
331     " +- ", round( math.sqrt( errsMTDict[ "MHTGen" ][ sample ] ),2 )
332     pass
333     print
334     print "nEvents (MC) in muon sample"
335     for sample in realTausReadInUnscaled.sampleList:
336     print "\t", sample, " : ", round( histDictMTUnscaled[ "MHTUnscaledGen" ][ sample ].Integral() , 2 ),\
337     " +- ", round( math.sqrt( histDictMTUnscaled[ "MHTUnscaledGen" ][ sample ].Integral() ), 2 )
338     pass
339     print
340    
341    
342    
343     errHistUpDict = {}
344     errHistDwnDict = {}
345     for hist in allHistMT.keys():
346     ErrHists = RT.StatErrorHists( allHistMT[ hist ],errsMTDictBin[ hist ] ,colorUp=ROOT.kCyan+2, colorDwn = mcColor )
347     errHistUpDict[ hist ], errHistDwnDict[ hist ] = ErrHists.getErrHists( histname = hist )
348    
349    
350     print
351     print "----- prediction -----"
352     #for hist in [ "MHT" ]:
353     for hist in [ "MHTGen" ]:
354     print hist
355     for sample in muonTausReadIn.sampleList:
356     print sample, " pred=", round( pred.predDict[ hist ][ sample ], 2 ), \
357     " +- ", round( errsMTDict[ hist ][ sample ], 2 )
358     #" +", round( pred.errUpDict[ hist ][ sample ],2 ), "(acc/eff) -", \
359     #round( pred.errDwnDict[ hist ][ sample ],2 ), "(acc/eff)"
360     pass
361     print "======"
362     print "All pred=", round( pred.predDict[ hist ][ "All" ], 2 ), \
363     " +- ", round( errsMTDict[ hist ][ "All" ], 2 )
364     #" +", round( pred.errUpDict[ hist ][ "All" ],2 ), "(acc/eff) -", \
365     #round( pred.errDwnDict[ hist ][ "All" ],2 ), "(acc/eff)"
366     pass
367    
368     if draw:
369    
370     cDict = {}
371     legDict = {}
372     ratioDict = {}
373    
374     cDict[ "MHT" ] = ROOT.TCanvas( "MHT" , "MHT" )
375     cDict[ "MHT" ].cd()
376     #allHistMT[ "MHTMuonTauMHTMuonTau" ].UseCurrentStyle()
377     allHistMT[ "MHTGen" ].UseCurrentStyle()
378     #allHistMT[ "MHT" ].UseCurrentStyle()
379     histDictRT[ "MHTMHT" ][ "All" ].UseCurrentStyle()
380     #allHistMT[ "MHTMuonTauMHTMuonTau" ].Rebin( rebin )
381    
382    
383     #errDictBin = {}
384     #r = 1
385     #binList = errsMTDictBin[ "MHTGen" ][ "All" ].keys()
386     #binList.sort()
387     #counter = 1
388     #for i in binList:
389     # if r == 1:
390     # errDictBin[ counter ] = errsMTDictBin[ "MHTGen" ][ "All" ][ i ]
391     # counter = counter + 1
392     # pass
393     # r = r + 1
394     # if r == rebin + 1:
395     # r = 1
396     # pass
397     # pass
398    
399     #Style.setHistStyle( allHistMT[ "MHT" ],
400     # status="BG",
401     # color=8,
402     # xTitle="MHT [GeV]", yTitle="events" )
403     Style.setHistStyle( allHistMT[ "MHTGen" ],
404     status="BG",
405     color=mcColor,
406     xTitle="MHT [GeV]", yTitle="events" )
407     Style.setHistStyle( histDictRT[ "MHTMHT" ][ "All" ],
408     status="Data",
409     color=1,
410     xTitle="MHT [GeV]", yTitle="events" )
411     #allHistMT[ "MHTMuonTauMHTMuonTau" ].Draw( "hist" )
412     allHistMT[ "MHTGen" ].Draw( "hist" )
413     #allHistMT[ "MHT" ].Draw( "hist" )
414     errHistUpDict[ "MHTGen" ][ "All" ].Draw( "same" )
415     errHistDwnDict[ "MHTGen" ][ "All" ].Draw( "same" )
416     histDictRT[ "MHTMHT" ][ "All" ].Draw( "same" )
417    
418     errHistUpDict[ "MHTGen" ][ "All" ].Draw( "axissame" )
419    
420     if logY:
421     allHistMT[ "MHTGen" ].SetMinimum( 6 * 10**-2 )
422     #allHistMT[ "HT" ].SetMinimum( 10**-3 )
423     histDictRT[ "MHTMHT" ][ "All" ].SetMinimum( 6 * 10**-2 )
424     pass
425    
426     if logY:
427     ROOT.gPad.SetLogy()
428     pass
429    
430     #legDict[ "MHT" ] = Style.makeLegendSimple( [ allHistMT[ "MHT" ],
431     # histDictRT[ "MHTMHT" ][ "All" ] ],
432     # [ "predicted tau", "true tau (MC)" ],
433     # statusDict={ "predicted tau" : "BG",
434     # "true tau (MC)" : "Data"})
435     legDict[ "MHT" ] = Style.makeLegendSimple( [ histDictRT[ "MHTMHT" ][ "All" ],
436     allHistMT[ "MHTGen" ],
437     errHistUpDict[ "MHTGen" ][ "All" ], ],
438     [ "true tau (MC)", "predicted tau", "stat err" ],
439     statusDict={ "predicted tau" : "BG",
440     "true tau (MC)" : "Data",
441     "stat err" : "BG"})
442    
443    
444     legDict[ "MHT" ].Draw( "same" )
445    
446     #ratioDict[ "MHT" ] = RT.Ratio( histDictRT[ "MHTMHT" ][ "All" ],
447     # allHistMT[ "MHT" ])
448    
449     ratioDict[ "MHT" ] = RT.Ratio( histDictRT[ "MHTMHT" ][ "All" ],
450     allHistMT[ "MHTGen" ],
451     mcHistErrDict=errsMTDictBin[ "MHTGen" ][ "All" ] )
452     ratioDict[ "MHT" ].drawRatio( ROOT.gPad )
453    
454    
455     #print errsMTDictBin[ "MHTGen" ][ "All" ]
456    
457    
458     cDict[ "HT" ] = ROOT.TCanvas( "HT" , "HT" )
459     cDict[ "HT" ].cd()
460     #allHistMT[ "HT" ].UseCurrentStyle()
461     allHistMT[ "HTGen" ].UseCurrentStyle()
462     histDictRT[ "HTHT" ][ "All" ].UseCurrentStyle()
463     #allHistMT[ "HTGen" ].Rebin( rebin )
464     ##allHistMT[ "HT" ].Rebin( rebin )
465     #histDictRT[ "HTHT" ][ "All" ].Rebin( rebin )
466     #errHistUpDict[ "HTGen" ][ "All" ].Rebin( rebin )
467     #errHistDwnDict[ "HTGen" ][ "All" ].Rebin( rebin )
468     allHistMT[ "HTGen" ].SetMinimum( 0.01 )
469     #allHistMT[ "HT" ].SetMinimum( 0.01 )
470     histDictRT[ "HTHT" ][ "All" ].SetMinimum( 0.01 )
471     allHistMT[ "HTGen" ].GetXaxis().SetRangeUser( 0.,4000. )
472     #allHistMT[ "HT" ].GetXaxis().SetRangeUser( 0.,4000. )
473     histDictRT[ "HTHT" ][ "All" ].GetXaxis().SetRangeUser( 0.,4000. )
474     if logY:
475     allHistMT[ "HTGen" ].SetMinimum( 6 * 10**-2 )
476     #allHistMT[ "HT" ].SetMinimum( 10**-3 )
477     histDictRT[ "HTHT" ][ "All" ].SetMinimum( 6 * 10**-2 )
478     pass
479     Style.setHistStyle( allHistMT[ "HTGen" ],
480     status="BG",
481     color=mcColor,
482     xTitle="HT [GeV]", yTitle="events" )
483     #Style.setHistStyle( allHistMT[ "HT" ],
484     # status="BG",
485     # color=8,
486     # xTitle="HT [GeV]", yTitle="events" )
487     Style.setHistStyle( histDictRT[ "HTHT" ][ "All" ],
488     status="Data",
489     color=1,
490     xTitle="HT [GeV]", yTitle="events" )
491     allHistMT[ "HTGen" ].Draw( "hist" )
492     #allHistMT[ "HT" ].Draw( "hist" )
493     errHistUpDict[ "HTGen" ][ "All" ].Draw( "same" )
494     errHistDwnDict[ "HTGen" ][ "All" ].Draw( "same" )
495     histDictRT[ "HTHT" ][ "All" ].Draw( "same" )
496    
497     allHistMT[ "HTGen" ].Draw( "axissame" )
498    
499     if logY:
500     ROOT.gPad.SetLogy()
501     pass
502     legDict[ "HT" ] = Style.makeLegendSimple( [ histDictRT[ "HTHT" ][ "All" ],
503     allHistMT[ "HTGen" ],
504     errHistUpDict[ "HTGen" ][ "All" ] ],
505     [ "true tau (MC)","predicted tau", "stat err" ],
506     statusDict={ "predicted tau" : "BG",
507     "true tau (MC)" : "Data",
508     "stat err" : "BG"})
509     #legDict[ "HT" ] = Style.makeLegendSimple( [ allHistMT[ "HT" ],
510     # histDictRT[ "HTHT" ][ "All" ] ],
511     # [ "predicted tau", "true tau (MC)" ],
512     # statusDict={ "predicted tau" : "BG",
513     # "true tau (MC)" : "Data"})
514     legDict[ "HT" ].Draw( "same" )
515    
516     ratioDict[ "HT" ] = RT.Ratio( histDictRT[ "HTHT" ][ "All" ],
517     allHistMT[ "HTGen" ],
518     mcHistErrDict=errsMTDictBin[ "HTGen" ][ "All" ])
519     #ratioDict[ "HT" ] = RT.Ratio( histDictRT[ "HTHT" ][ "All" ],
520     # allHistMT[ "HT" ])
521     ratioDict[ "HT" ].drawRatio( ROOT.gPad )
522    
523    
524     cDict[ "Tau1Pt" ] = ROOT.TCanvas( "Tau1Pt" , "Tau1Pt" )
525     cDict[ "Tau1Pt" ].cd()
526     allHistMT[ "Tau1PtGen" ].UseCurrentStyle()
527     #allHistMT[ "Tau1Pt" ].UseCurrentStyle()
528     histDictRT[ "TauSelectionTau1Pt" ][ "All" ].UseCurrentStyle()
529     #allHistMT[ "MHTMuonTauTau1PtMuonTau" ].Rebin( 2 )
530     #allHistMT[ "Tau1PtGen" ].Rebin( 2 )
531     ##allHistMT[ "Tau1Pt" ].Rebin( 2 )
532     #histDictRT[ "TauSelectionTau1Pt" ][ "All" ].Rebin( 2 )
533     #errHistUpDict[ "Tau1PtGen" ][ "All" ].Rebin( 2 )
534     #errHistDwnDict[ "Tau1PtGen" ][ "All" ].Rebin( 2 )
535     allHistMT[ "Tau1PtGen" ].GetXaxis().SetRangeUser( 0, 1000. )
536     #allHistMT[ "Tau1Pt" ].GetXaxis().SetRangeUser( 0, 1000. )
537     #allHistMT[ "MHTMuonTauTau1PtMuonTau" ].GetXaxis().SetRangeUser( 0, 1000. )
538     histDictRT[ "TauSelectionTau1Pt" ][ "All" ].GetXaxis().SetRangeUser( 0, 1000. )
539     #Style.setHistStyle( allHistMT[ "Tau1Pt" ],
540     # status="BG",
541     # color=8,
542     # xTitle="Tau1 P_{T} [GeV]", yTitle="events" )
543     Style.setHistStyle( allHistMT[ "Tau1PtGen" ],
544     status="BG",
545     color=mcColor,
546     xTitle="Tau1 P_{T} [GeV]", yTitle="events" )
547     Style.setHistStyle( histDictRT[ "TauSelectionTau1Pt" ][ "All" ],
548     status="Data",
549     color=1,
550     xTitle="Tau1 P_{T} [GeV]", yTitle="events" )
551     #allHistMT[ "MHTMuonTauTau1PtMuonTau" ].Draw( "hist" )
552     allHistMT[ "Tau1PtGen" ].Draw( "hist" )
553     #allHistMT[ "Tau1Pt" ].Draw( "hist" )
554     errHistUpDict[ "Tau1PtGen" ][ "All" ].Draw( "same" )
555     errHistDwnDict[ "Tau1PtGen" ][ "All" ].Draw( "same" )
556     histDictRT[ "TauSelectionTau1Pt" ][ "All" ].Draw( "same" )
557    
558     allHistMT[ "Tau1PtGen" ].Draw( "axissame" )
559    
560     if logY:
561     ROOT.gPad.SetLogy()
562     pass
563    
564     #legDict[ "Tau1Pt" ] = Style.makeLegendSimple( [ allHistMT[ "Tau1Pt" ],
565     # histDictRT[ "TauSelectionTau1Pt" ][ "All" ] ],
566     # [ "predicted tau", "true tau (MC)" ],
567     # statusDict={ "predicted tau" : "BG",
568     # "true tau (MC)" : "Data"})
569    
570     legDict[ "Tau1Pt" ] = Style.makeLegendSimple( [ histDictRT[ "TauSelectionTau1Pt" ][ "All" ],
571     allHistMT[ "Tau1PtGen" ],
572     errHistUpDict[ "Tau1PtGen" ][ "All" ] ],
573     [ "true tau (MC)", "predicted tau", "stat err" ],
574     statusDict={ "predicted tau" : "BG",
575     "stat err" : "BG",
576     "true tau (MC)" : "Data"})
577     legDict[ "Tau1Pt" ].Draw( "same" )
578    
579     #ratioDict[ "Tau1Pt" ] = RT.Ratio( histDictRT[ "TauSelectionTau1Pt" ][ "All" ],
580     # allHistMT[ "Tau1Pt" ])
581     ratioDict[ "Tau1Pt" ] = RT.Ratio( histDictRT[ "TauSelectionTau1Pt" ][ "All" ],
582     allHistMT[ "Tau1PtGen" ],
583     mcHistErrDict=errsMTDictBin[ "Tau1PtGen" ][ "All" ])
584     ratioDict[ "Tau1Pt" ].drawRatio( ROOT.gPad )
585    
586    
587     if saveToPS:
588     Style.saveToPS( saveName, cDict )
589     pass
590     if saveToEPS:
591     Style.saveToEPS( saveName, cDict )
592     pass
593     pass
594    
595    
596     Def.DontQuit()