1 |
import ROOT
|
2 |
import sys, re
|
3 |
sys.path.append("/afs/naf.desy.de/user/n/nowaf/UserCode/nowaf/PythonScripts/")
|
4 |
import definitions as Def
|
5 |
import styles as Style
|
6 |
import MakeRealTauEst_cff as RT
|
7 |
|
8 |
if __name__ == "__main__":
|
9 |
|
10 |
Def.SetGlobalStyles( withTitle=True )
|
11 |
|
12 |
#lumi = 1000.
|
13 |
### v4
|
14 |
lumi = 927.9
|
15 |
|
16 |
fileName = "_full"
|
17 |
|
18 |
|
19 |
saveName = "plots/Selection/CutFlow" + fileName
|
20 |
|
21 |
saveToPS = False
|
22 |
saveToEPS = False
|
23 |
|
24 |
removeSamplesAcc = []
|
25 |
#removeSamplesAcc.append( "TTbar" )
|
26 |
removeSamplesAcc.append( "GVJets" )
|
27 |
removeSamplesAcc.append( "WWJets" )
|
28 |
removeSamplesAcc.append( "Zinv" )
|
29 |
removeSamplesAcc.append( "ZJets" )
|
30 |
removeSamplesAcc.append( "WJets" )
|
31 |
removeSamplesAcc.append( "QCDFlat" )
|
32 |
removeSamplesAcc.append( "Data" )
|
33 |
|
34 |
addSample = []
|
35 |
#addSample.append( "LM13" )
|
36 |
#addSample.append( "LM2" )
|
37 |
|
38 |
fileDir = "/scratch/hh/lustre/cms/user/nowaf/2011Data/VersionII/Plots/RealTauEst/"
|
39 |
|
40 |
theTitle = "Cut Flow, " + str( round( lumi, 1 ) ) + " pb^{-1}, #sqrt{s}=7 TeV"
|
41 |
|
42 |
dirpre = "finalPlotTauPreSelectionCutFlow/"
|
43 |
dirfull = "finalPlotTauCutFlow/"
|
44 |
|
45 |
histList = []
|
46 |
histList.append( "CutFlow" )
|
47 |
|
48 |
colorDict = {}
|
49 |
colorDict[ "QCDFlat" ] = ROOT.kYellow + 3
|
50 |
colorDict[ "TTbar" ] = ROOT.kRed + 3
|
51 |
colorDict[ "GVJets" ] = ROOT.kRed
|
52 |
colorDict[ "ZJets" ] = ROOT.kOrange
|
53 |
colorDict[ "Zinv" ] = ROOT.kOrange - 3
|
54 |
#colorDict[ "WWJets" ] = ROOT.kOrange
|
55 |
#colorDict[ "ZZJets" ] = ROOT.kOrange
|
56 |
#colorDict[ "WZJets" ] = ROOT.kOrange
|
57 |
colorDict[ "WWJets" ] = ROOT.kOrange + 7
|
58 |
colorDict[ "WJets" ] = ROOT.kYellow + 2
|
59 |
#colorDict[ "LM13" ] = ROOT.kBlue
|
60 |
colorDict[ "LM2" ] = ROOT.kBlue - 7
|
61 |
colorDict[ "LM13" ] = ROOT.kAzure + 10
|
62 |
colorDict[ "GMSBc" ] = ROOT.kCyan + 2
|
63 |
colorDict[ "Data" ] = ROOT.kBlack
|
64 |
|
65 |
statusDict = {}
|
66 |
statusDict[ "QCDFlat" ] = "BG"
|
67 |
#statusDict[ "QCDFlat" ] = "Signal"
|
68 |
statusDict[ "TTbar" ] = "BG"
|
69 |
statusDict[ "GVJets" ] = "BG"
|
70 |
statusDict[ "ZJets" ] = "BG"
|
71 |
statusDict[ "Zinv" ] = "BG"
|
72 |
statusDict[ "WWJets" ] = "BG"
|
73 |
statusDict[ "WJets" ] = "BG"
|
74 |
statusDict[ "LM13" ] = "Signal"
|
75 |
statusDict[ "LM2" ] = "Signal"
|
76 |
statusDict[ "LM8" ] = "Signal"
|
77 |
statusDict[ "GMSBc" ] = "Signal"
|
78 |
statusDict[ "Data" ] = "Data"
|
79 |
|
80 |
logDict = {}
|
81 |
logDict[ "CutFlow" ] = True
|
82 |
|
83 |
titleDict = {}
|
84 |
titleDict[ "CutFlow" ] = ( "", "" )
|
85 |
|
86 |
positionDict = {}
|
87 |
positionDict[ "CutFlow" ] = "ur"
|
88 |
|
89 |
#######################################################################
|
90 |
readInPre = RT.ReadIn( fileDir, fileName, lumi, rebinDict={} )
|
91 |
readInPre.removeSamples( removeSamplesAcc )
|
92 |
readInPre.addSamples( addSample )
|
93 |
readInPre.removeHists( [ "MHT" ] )
|
94 |
readInPre.addHists( histList ) #accReadIn.dontScale()
|
95 |
histDictPre = readInPre.getHists( dirpre )
|
96 |
|
97 |
readInFull = RT.ReadIn( fileDir, fileName, lumi, rebinDict={} )
|
98 |
readInFull.removeSamples( removeSamplesAcc )
|
99 |
readInFull.addSamples( addSample )
|
100 |
readInFull.removeHists( [ "MHT" ] )
|
101 |
readInFull.addHists( histList ) #accReadIn.dontScale()
|
102 |
histDictFull = readInFull.getHists( dirfull )
|
103 |
|
104 |
|
105 |
cfDict = {}
|
106 |
for hist in histList:
|
107 |
cfDict[ hist ] = {}
|
108 |
for file in readInPre.sampleList:
|
109 |
xtitle = titleDict[ hist ][ 0 ]
|
110 |
ytitle = titleDict[ hist ][ 1 ]
|
111 |
histDictPre[ hist ][ file ].UseCurrentStyle()
|
112 |
histDictFull[ hist ][ file ].UseCurrentStyle()
|
113 |
Style.setHistStyle( histDictPre[ hist ][ file ] , status=statusDict[ file ],\
|
114 |
color=colorDict[ file ], xTitle=xtitle, yTitle=ytitle,
|
115 |
markerStyle=20, title=theTitle )
|
116 |
Style.setHistStyle( histDictFull[ hist ][ file ] , status=statusDict[ file ],\
|
117 |
color=colorDict[ file ], xTitle=xtitle, yTitle=ytitle,
|
118 |
markerStyle=20, title=theTitle )
|
119 |
cfDict[ hist ][ file ] = ROOT.TH1F( hist + file, hist + file,
|
120 |
histDictPre[ hist ][ file ].GetNbinsX() + 2,
|
121 |
0,
|
122 |
7 )
|
123 |
#print histDictPre[ hist ][ file ].GetNbinsX()
|
124 |
|
125 |
#cfDict[ hist ][ file ].Draw()
|
126 |
#Def.DontQuit()
|
127 |
|
128 |
for i in range( 1, histDictPre[ hist ][ file ].GetNbinsX() + 1 ):
|
129 |
cfDict[ hist ][ file ].SetBinContent( i, histDictPre[ hist ][ file ].GetBinContent( i ) )
|
130 |
if not re.search( "HT", histDictPre[ hist ][ file ].GetXaxis().GetBinLabel( i ) ):
|
131 |
cfDict[ hist ][ file ].GetXaxis().SetBinLabel( i,
|
132 |
histDictPre[ hist ][ file ].GetXaxis().GetBinLabel( i ) )
|
133 |
else:
|
134 |
if histDictPre[ hist ][ file ].GetXaxis().GetBinLabel( i ) == "HT":
|
135 |
cfDict[ hist ][ file ].GetXaxis().SetBinLabel( i, "HT (Base-Line)" )
|
136 |
elif histDictPre[ hist ][ file ].GetXaxis().GetBinLabel( i ) == "MHT":
|
137 |
cfDict[ hist ][ file ].GetXaxis().SetBinLabel( i, "MHT (Trigger)" )
|
138 |
pass
|
139 |
pass
|
140 |
pass
|
141 |
for j in range( histDictFull[ hist ][ file ].GetNbinsX() + 1, histDictFull[ hist ][ file ].GetNbinsX() + 3 ):
|
142 |
cfDict[ hist ][ file ].SetBinContent( j, histDictFull[ hist ][ file ].GetBinContent( j - 2 ) )
|
143 |
if histDictFull[ hist ][ file ].GetXaxis().GetBinLabel( j -2 ) == "HT":
|
144 |
cfDict[ hist ][ file ].GetXaxis().SetBinLabel( j, "HT (Full)" )
|
145 |
elif histDictFull[ hist ][ file ].GetXaxis().GetBinLabel( j - 2 ) == "MHT":
|
146 |
cfDict[ hist ][ file ].GetXaxis().SetBinLabel( j, "MHT (Full)" )
|
147 |
pass
|
148 |
pass
|
149 |
|
150 |
#cfDict[ hist ][ file ].Draw()
|
151 |
#Def.DontQuit()
|
152 |
|
153 |
Style.setHistStyle( cfDict[ hist ][ file ] , status=statusDict[ file ],\
|
154 |
color=colorDict[ file ], xTitle=xtitle, yTitle=ytitle,
|
155 |
markerStyle=20, title=theTitle )
|
156 |
pass
|
157 |
pass
|
158 |
|
159 |
|
160 |
#### get lists of samples not to be stacked
|
161 |
NonStackList = []
|
162 |
DataList = []
|
163 |
StackList = []
|
164 |
for sample in readInPre.sampleList:
|
165 |
if statusDict[ sample ] == "Data":
|
166 |
DataList.append( sample )
|
167 |
elif statusDict[ sample ] == "Signal":
|
168 |
NonStackList.append( sample )
|
169 |
pass
|
170 |
pass
|
171 |
|
172 |
cDict = {}
|
173 |
stackDict = {}
|
174 |
legDict = {}
|
175 |
textDict = {}
|
176 |
for hist in histList:
|
177 |
|
178 |
#### make the stack
|
179 |
#print "Begin stack"
|
180 |
if len( NonStackList + DataList ) != len( readInPre.sampleList ):
|
181 |
stackDict[ hist ] = ROOT.THStack( hist, hist )
|
182 |
for sample in readInPre.sampleList:
|
183 |
if statusDict[ sample ] == "BG":
|
184 |
stackDict[ hist ].Add( cfDict[ hist ][ sample ] )
|
185 |
pass
|
186 |
pass
|
187 |
pass
|
188 |
#print "end stack"
|
189 |
print "1"
|
190 |
cDict[ hist ] = ROOT.TCanvas( hist, hist )
|
191 |
cDict[ hist ].cd()
|
192 |
|
193 |
#### draw non-stack stuff first
|
194 |
option = ""
|
195 |
for dsample in DataList:
|
196 |
cfDict[ hist ][ dsample ].Draw( option + "p" )
|
197 |
option = "same"
|
198 |
pass
|
199 |
|
200 |
nondataOption = "hist"
|
201 |
for nssample in NonStackList:
|
202 |
cfDict[ hist ][ nssample ].Draw( nondataOption+option )
|
203 |
option = "same"
|
204 |
pass
|
205 |
|
206 |
print "2"
|
207 |
|
208 |
#### i hate stacks.
|
209 |
#### set all the fucking stylings AGAIN.
|
210 |
if stackDict:
|
211 |
|
212 |
#### now draw the stack
|
213 |
stackDict[ hist ].Draw( nondataOption+option )
|
214 |
|
215 |
#if hist in xrangeDict.keys():
|
216 |
# stackDict[ hist ].GetXaxis().SetRangeUser( xrangeDict[ hist ][ 0 ], xrangeDict[ hist ][ 1 ] )
|
217 |
# pass
|
218 |
#if hist in yrangeDict.keys():
|
219 |
# #stackDict[ hist ].GetYaxis().SetRangeUser( yrangeDict[ hist ][ 0 ], yrangeDict[ hist ][ 1 ] )
|
220 |
stackDict[ hist ].SetMinimum( 10**-2 )
|
221 |
stackDict[ hist ].SetMaximum( 10**9 )
|
222 |
# pass
|
223 |
if hist in titleDict.keys():
|
224 |
stackDict[ hist ].GetXaxis().SetTitle( titleDict[ hist ][ 0 ] )
|
225 |
stackDict[ hist ].GetYaxis().SetTitle( titleDict[ hist ][ 1 ] )
|
226 |
pass
|
227 |
|
228 |
stackDict[ hist ].SetTitle( "" )
|
229 |
#axishist = stackDict[ hist ].GetHistogram()
|
230 |
pass
|
231 |
|
232 |
print "3"
|
233 |
|
234 |
for nssample in NonStackList:
|
235 |
#histDict[ hist ][ nssample ].GetXaxis().SetRangeUser( xrangeDict[ hist ][ 0 ], xrangeDict[ hist ][ 1 ] )
|
236 |
cfDict[ hist ][ nssample ].SetMinimum( 10**-2 )
|
237 |
cfDict[ hist ][ nssample ].SetMaximum( 10**9 )
|
238 |
cfDict[ hist ][ nssample ].Draw( nondataOption + option )
|
239 |
option = "same"
|
240 |
pass
|
241 |
|
242 |
for dsample in DataList:
|
243 |
#histDict[ hist ][ dsample ].GetXaxis().SetRangeUser( xrangeDict[ hist ][ 0 ], xrangeDict[ hist ][ 1 ] )
|
244 |
cfDict[ hist ][ dsample ].SetMinimum( 10**-2 )
|
245 |
cfDict[ hist ][ dsample ].SetMaximum( 10**9 )
|
246 |
cfDict[ hist ][ dsample ].Draw( option + "p" )
|
247 |
option = "same"
|
248 |
pass
|
249 |
|
250 |
#axishist.Draw( "axissame" )
|
251 |
cfDict[ histList[ 0 ] ][ readInPre.sampleList[ 0 ] ].Draw( "axissame" )
|
252 |
|
253 |
print "4"
|
254 |
|
255 |
if hist in logDict.keys() and logDict[ hist ]:
|
256 |
ROOT.gPad.SetLogy()
|
257 |
pass
|
258 |
cDict[ hist ].Update()
|
259 |
|
260 |
position = "ur"
|
261 |
if hist in positionDict.keys():
|
262 |
position = positionDict[ hist ]
|
263 |
pass
|
264 |
|
265 |
legDict[ hist ] = Style.makeLegend( hist, cfDict, readInPre.sampleList, statusDict, position )
|
266 |
legDict[ hist ].Draw( "same" )
|
267 |
|
268 |
#if hist in latexDict.keys():
|
269 |
# for i in range( 0, len( latexDict[ hist ][ 0 ] ) ):
|
270 |
# textDict[ hist + str ( i ) ] = ROOT.TLatex( latexDict[ hist ][ 1 ][ i ], \
|
271 |
# latexDict[ hist ][ 2 ][ i ], \
|
272 |
# latexDict[ hist ][ 0 ][ i ] )
|
273 |
# textDict[ hist + str ( i ) ].Draw( "same" )
|
274 |
# pass
|
275 |
# pass
|
276 |
|
277 |
|
278 |
cDict[ hist ].Update()
|
279 |
|
280 |
print "5"
|
281 |
|
282 |
pass
|
283 |
|
284 |
if saveToPS:
|
285 |
Style.saveToPS( saveName, cDict, histList )
|
286 |
if saveToEPS:
|
287 |
Style.saveToEPS( saveName, cDict )
|
288 |
pass
|
289 |
|
290 |
Def.DontQuit()
|