1 |
#! /usr/bin/env python
|
2 |
|
3 |
from ROOT import *
|
4 |
from decimal import Decimal
|
5 |
import sys,os, math
|
6 |
|
7 |
path = "./"
|
8 |
Ndecimals = 2
|
9 |
IsMC = False
|
10 |
Lumi = 10.93 # in pb-1
|
11 |
JetType = "PF" #calo
|
12 |
showGh = False
|
13 |
kFactor = 1.0
|
14 |
#WprimeType = "RH"
|
15 |
splitWjets = False
|
16 |
|
17 |
if len(sys.argv) < 2:
|
18 |
print "usage: mkCutFlowTables.py <path to files> <Lumi for MC> < 1 =will produce table for signal Gh>"
|
19 |
sys.exit()
|
20 |
|
21 |
if len(sys.argv) > 1:
|
22 |
|
23 |
path = sys.argv[1]
|
24 |
print " path: "+ path
|
25 |
if len(sys.argv)>2:
|
26 |
IsMC = True
|
27 |
Lumi = float(sys.argv[2])
|
28 |
print " Luminosity for MC samples: "+str(Lumi)
|
29 |
|
30 |
if len(sys.argv)>3:
|
31 |
|
32 |
if sys.argv[3] == "Wbb":
|
33 |
splitWjets = True
|
34 |
else:
|
35 |
showGh = True
|
36 |
GhType = sys.argv[3]
|
37 |
print "checking Gh files of type: " + GhType
|
38 |
|
39 |
Nevents = {}
|
40 |
xsec = {} # xsection in pb
|
41 |
file = {}
|
42 |
label = {}
|
43 |
# MC files
|
44 |
if IsMC:
|
45 |
file['ttbar'] = path+'/results_ttbar.root'
|
46 |
file['ttbar_powheg'] = path+'/results_ttbar_powheg.root'
|
47 |
file['QCD'] = path+'/results_QCD.root'
|
48 |
if splitWjets:
|
49 |
file['Wbb'] = path+'/results_Wbb.root'
|
50 |
file['Wcc']= path+'/results_Wcc.root'
|
51 |
file['Wqq']= path+'/results_Wqq.root'
|
52 |
else:
|
53 |
file['Wjets'] = path+'/results_WJets.root'
|
54 |
file['Zjets'] = path+'/results_ZJets.root'
|
55 |
file['tch'] = path+'/results_STtch.root'
|
56 |
file['tWch'] = path+'/results_STtWch.root'
|
57 |
file['sch'] = path+'/results_STsch.root'
|
58 |
file['tch_bar'] = path+'/results_STtch_bar.root'
|
59 |
file['tWch_bar'] = path+'/results_STtWch_bar.root'
|
60 |
file['sch_bar'] = path+'/results_STsch_bar.root'
|
61 |
file['WW'] = path+'/results_WW.root'
|
62 |
file['WZ'] = path+'/results_WZ.root'
|
63 |
|
64 |
file['ttttSM'] = path+'/results_tttt_SM.root'
|
65 |
file['Gh1100'] = path+'/results_4Top1100.root'
|
66 |
file['UED6'] = path+'/results_4TopUED6.root'
|
67 |
file['Gh400'] = path+'/results_tttt_Gh400.root'
|
68 |
file['Gh500'] = path+'/results_tttt_Gh500.root'
|
69 |
file['Gh600'] = path+'/results_tttt_Gh600.root'
|
70 |
file['Gh700'] = path+'/results_tttt_Gh700.root'
|
71 |
file['Gh800'] = path+'/results_tttt_Gh800.root'
|
72 |
file['Gh900'] = path+'/results_tttt_Gh900.root'
|
73 |
file['Gh1000'] = path+'/results_tttt_Gh1000.root'
|
74 |
file['Gh1200'] = path+'/results_tttt_Gh1200.root'
|
75 |
file['UED6'] = path+'/results_tttt_UED6.root'
|
76 |
|
77 |
xsec['ttbar'] = 163.0 #157.5
|
78 |
xsec['ttbar_powheg'] = 163.0 #157.5
|
79 |
xsec['QCD'] = 84679.3
|
80 |
xsec['Wjets'] = 31314.0
|
81 |
|
82 |
xsec['Wbb'] = 31314.0 * 1.21
|
83 |
xsec['Wcc'] = 31314.0 * 1.66
|
84 |
xsec['Wqq'] = 31314.0 * 0.58
|
85 |
|
86 |
xsec['Zjets'] = 3048.0
|
87 |
xsec['tch'] = 41.92
|
88 |
xsec['tWch'] = 7.87
|
89 |
xsec['sch'] = 3.19
|
90 |
xsec['tch_bar'] = 22.65
|
91 |
xsec['tWch_bar'] = 7.87
|
92 |
xsec['sch_bar'] = 1.44
|
93 |
xsec['WW'] = 43.0
|
94 |
xsec['WZ'] = 18.0
|
95 |
xsec['ttttSM'] = 0.0004746*kFactor
|
96 |
xsec['Gh400'] = 0.89550*kFactor
|
97 |
xsec['Gh500'] = 0.18182*kFactor
|
98 |
xsec['Gh600'] = 0.044471*kFactor
|
99 |
xsec['Gh700'] = 0.012131*kFactor
|
100 |
xsec['Gh800'] = 0.003609*kFactor
|
101 |
xsec['Gh900'] = 0.0011484*kFactor
|
102 |
xsec['Gh1000'] = 0.00038029*kFactor
|
103 |
xsec['Gh1100'] = 0.00012830*kFactor
|
104 |
xsec['UED6'] = 0.134*0.2*0.2*kFactor
|
105 |
xsec['Gh1200'] = 0.000044145*kFactor
|
106 |
|
107 |
#Nevents['ttbar'] = 3701947.0 #Summer11
|
108 |
Nevents['ttbar'] = 59366767.0
|
109 |
Nevents['ttbar_powheg'] = 16330372.0
|
110 |
Nevents['Wjets'] = 77105816.0
|
111 |
|
112 |
Nevents['Wbb'] = 77105816.0
|
113 |
Nevents['Wcc'] = 77105816.0
|
114 |
Nevents['Wqq'] = 77105816.0
|
115 |
|
116 |
Nevents['Zjets'] = 36277961.0
|
117 |
Nevents['WW'] = 4225916.0
|
118 |
Nevents['WZ'] = 4265243.0
|
119 |
Nevents['QCD'] = 25080241.0
|
120 |
Nevents['sch'] = 259971.0
|
121 |
Nevents['sch_bar'] = 137980.0
|
122 |
Nevents['tch'] = 3900171.0
|
123 |
Nevents['tch_bar'] = 1944826.0
|
124 |
Nevents['tWch'] = 814390.0
|
125 |
Nevents['tWch_bar'] = 809984.0
|
126 |
|
127 |
Nevents['ttttSM'] = 10000.0 #3057.0
|
128 |
Nevents['Gh1100'] = 10000.0 #4041.0
|
129 |
Nevents['UED6'] = 10000.0 #3290.0
|
130 |
|
131 |
Nevents['Gh400'] = 100000.0 # 19000.0
|
132 |
Nevents['Gh500'] = 98000.0
|
133 |
Nevents['Gh600'] = 98000.0 #100000.0
|
134 |
Nevents['Gh700'] = 100000.0
|
135 |
Nevents['Gh800'] = 100000.0
|
136 |
Nevents['Gh900'] = 100000.0
|
137 |
Nevents['Gh1000'] = 86000.0
|
138 |
Nevents['Gh1200'] = 20000.0
|
139 |
|
140 |
label['ttbar'] = '$t\\overline{t}$'
|
141 |
label['ttbar_powheg'] = '$t\\overline{t}$'
|
142 |
label['QCD'] = 'QCD'
|
143 |
label['Wjets'] = '$W\\rightarrow l\\nu$'
|
144 |
|
145 |
label['Wbb'] = '$Wbb$'
|
146 |
label['Wcc'] = '$Wcc$'
|
147 |
label['Wqq'] = '$Wqq$'
|
148 |
|
149 |
label['Zjets'] = '$Z\\rightarrow l^{+}l^{-}$'
|
150 |
label['tch'] = 'top t-ch'
|
151 |
label['tWch'] = 'top tW-ch'
|
152 |
label['sch'] = 'top s-ch'
|
153 |
label['tch_bar'] = 'anti-top t-ch'
|
154 |
label['tWch_bar'] = 'anti-top tW-ch'
|
155 |
label['sch_bar'] = 'anti-top s-ch'
|
156 |
label['WW'] = 'WW'
|
157 |
label['WZ'] = 'WZ'
|
158 |
|
159 |
label['ttttSM'] = 'tttt SM'
|
160 |
|
161 |
label['Gh400'] = "Gh 0.4 TeV"
|
162 |
label['Gh500'] = "Gh 0.5 TeV"
|
163 |
label['Gh600'] = "Gh 0.6 TeV"
|
164 |
label['Gh700'] = "Gh 0.7 TeV"
|
165 |
label['Gh800'] = "Gh 0.8 TeV"
|
166 |
label['Gh900'] = "Gh 0.9 TeV"
|
167 |
label['Gh1000'] = "Gh 1.0 TeV"
|
168 |
label['Gh1100'] = "Gh 1.1 TeV"
|
169 |
label['Gh1200'] = "Gh 1.2 TeV"
|
170 |
label['UED6'] = "4Top UED6"
|
171 |
|
172 |
label['Total'] = 'Total MC'
|
173 |
else:
|
174 |
# data files
|
175 |
#file['Jun14'] = ''
|
176 |
#file['MB'] = '/uscmst1b_scratch/lpc1/cmsroc/yumiceva/top_prod_Sep22/Jun14/ttmuj_Jun14_MB_PSep23.root'#'/uscms_data/d3/ttmuj/Documents/NtupleMaker/Data/2.88pb-1/ttmuj_MB_Sep3.root'
|
177 |
#file['Jul16'] = '/uscmst1b_scratch/lpc1/cmsroc/yumiceva/top_prod_Sep22/Jul16/ttmuj_Jul16_PSep23.root'#'/uscms_data/d3/ttmuj/Documents/NtupleMaker/Data/2.88pb-1/ttmuj_Jul16_Sep3.root'
|
178 |
#file['Prompt']= '/uscms_data/d3/ttmuj/Documents/NtupleMaker/Data/2.88pb-1/ttmuj_Prompt_Sep3.root'
|
179 |
|
180 |
#label['Jun14'] = 'Jun 14th Mu'
|
181 |
#label['MB'] = 'Jun 14th MinimumBias'
|
182 |
#label['Jul16'] = 'Jul 16th'
|
183 |
#label['Prompt'] = 'PromptReco'
|
184 |
|
185 |
#if os.path.isfile(path+'/JPT/cutflow_JPT_data.txt'):
|
186 |
# file['dataJPT'] = path+'/cutflow_JPT_data.txt'
|
187 |
# label['dataJPT'] = 'JPT Ref. Sel.'
|
188 |
#if os.path.isfile(path+'/calo/cutflow_calo_data.txt'):
|
189 |
# file['datacalo'] = path+'/cutflow_calo_data.txt'
|
190 |
# label['datacalo'] = 'Calo Ref. Sel.'
|
191 |
#if os.path.isfile(path+'/PF/cutflow_PF_data.txt'):
|
192 |
# file['dataPF'] = path+'/cutflow_PF_data.txt'
|
193 |
# label['dataPF'] = 'PF Ref. Sel.'
|
194 |
|
195 |
file['data'] = path+'/results_data.root';
|
196 |
label['data'] = "Data";
|
197 |
|
198 |
|
199 |
keys = file.keys()
|
200 |
cutflow = {}
|
201 |
cutflowerr = {}
|
202 |
cutlabel = {}
|
203 |
cutlabel['Processed'] = 'Processed'
|
204 |
cutlabel['CleanFilters'] = 'CleanFilters'
|
205 |
cutlabel['HLT'] = 'HLT'
|
206 |
cutlabel['GoodPV'] = 'Skim'
|
207 |
cutlabel['OneIsoMu'] = 'One Iso $\mu$'
|
208 |
cutlabel['LooseMuVeto'] = 'Loose $\mu$ veto'
|
209 |
cutlabel['ElectronVeto'] = 'Electron veto'
|
210 |
cutlabel['ZMassVeto'] = 'Z Mass veto'
|
211 |
cutlabel['MET'] = 'MET'
|
212 |
cutlabel['1Jet'] = 'jets $\geq 1$'
|
213 |
cutlabel['2Jet'] = 'jets $\geq 2$'
|
214 |
cutlabel['3Jet'] = 'jets $\geq 3$'
|
215 |
cutlabel['4Jet'] = 'jets $\geq 4$'
|
216 |
cutlabel['7Jet'] = 'jets $\geq 7$'
|
217 |
cutlabel['8Jet'] = 'jets $\geq 8$'
|
218 |
cutlabel['9Jet'] = 'jets $\geq 9$'
|
219 |
cutlabel['Ht'] = '$H_t \geq 300$'
|
220 |
cutlabel['4Jet0b'] = 'btags $ = 0$'
|
221 |
cutlabel['4Jet1b'] = 'btags $\geq 3$'
|
222 |
cutlabel['4JetCut'] = '$p_t^{jet4} > 40$ '
|
223 |
cutlabel['Ht2'] = '$H_t \geq 500$'
|
224 |
cutlabel['Stjet'] = '$S_t^{jet} \geq 500$'
|
225 |
|
226 |
cutlabelvector = [ 'GoodPV', 'OneIsoMu', 'LooseMuVeto', 'ElectronVeto', 'MET', '4Jet','Ht', '4Jet0b', '4Jet1b', '4JetCut', 'Stjet', '7Jet', '8Jet', '9Jet']
|
227 |
#cutlabelvector = [ 'GoodPV', 'OneIsoMu', 'LooseMuVeto', 'ElectronVeto', 'ZMassVeto', 'MET', '4Jet','Ht', '4Jet0b', '4Jet1b', '4JetCut', 'Stjet']
|
228 |
#cutlabelvector = [ 'GoodPV', 'OneIsoMu', 'ElectronVeto', 'MET' '4Jet','Ht', '4Jet0b', '4Jet1b', '4JetCut', 'Stjet']
|
229 |
#SKIPCUTS = ['LooseMuVeto','4Jet0b']#'GoodPV', 'OneIsoMu', 'LooseMuVeto', 'ElectronVeto', 'MET',]
|
230 |
SKIPCUTS = ['GoodPV', 'OneIsoMu', 'LooseMuVeto', 'ElectronVeto', 'MET', '4Jet0b']
|
231 |
|
232 |
allmap = {}
|
233 |
allmaperr = {}
|
234 |
|
235 |
weightmap = {}
|
236 |
|
237 |
#tablelist = ['ttbar','Wjets','Zjets', 'QCD', 'tch','tch_bar','tWch','tWch_bar','sch','sch_bar','WW','WZ','Total']
|
238 |
tablelist = ['ttbar']
|
239 |
|
240 |
if splitWjets:
|
241 |
tablelist = ['ttbar','Wbb','Wcc','Wqq','Zjets','tch','tch_bar','tWch','tWch_bar','sch','sch_bar','WW','WZ','Total']
|
242 |
#tablelist = ['ttbar','Wbb','Wcc','Wqq','Zjets','QCD','tch','tch_bar','tWch','tWch_bar','sch','sch_bar','WW','WZ','Total']
|
243 |
#tablelist = ['ttbar_powheg','Wbb','Wcc','Wqq','Zjets','QCD','tch','tch_bar','tWch','tWch_bar','sch','sch_bar','WW','WZ','Total']
|
244 |
|
245 |
if showGh:
|
246 |
#tablelist = ['Gh500','Gh700','Gh900','Gh1000','Gh1100']
|
247 |
#tablelist = ['4TopSM','Gh500','Gh900','Gh1100','UED6']
|
248 |
tablelist = ['ttttSM', 'Gh400','Gh500','Gh600','Gh700','Gh800','Gh900','Gh1000', 'UED6']
|
249 |
|
250 |
if Lumi<=0:
|
251 |
tablelist = ['ttbar','Wjets','Zjets','tch','tch_bar','tWch','tWch_bar','sch','sch_bar','WW','WZ']
|
252 |
#tablelist = ['ttbar','Wjets','Zjets','tch','tch_bar','tWch','tWch_bar','sch','WW','WZ']
|
253 |
|
254 |
if not IsMC:
|
255 |
tablelist = ['data']
|
256 |
|
257 |
for sample in tablelist:
|
258 |
|
259 |
if sample=="Total": continue
|
260 |
print " processing " + sample
|
261 |
|
262 |
cutmap = {}
|
263 |
cutmaperr = {}
|
264 |
#txtfile = open(file[sample])
|
265 |
roofile = TFile(file[sample])
|
266 |
hcutflow = gDirectory.Get("cutflow")
|
267 |
print " entries in cutflow histogram: " + str(hcutflow.GetEntries())
|
268 |
|
269 |
for ibin in xrange(1, hcutflow.GetNbinsX() +1 ):
|
270 |
|
271 |
skipthiscut = False
|
272 |
for skipcut in SKIPCUTS:
|
273 |
if skipcut == cutlabelvector[ibin-1]: skipthiscut = True
|
274 |
if skipthiscut:
|
275 |
print "skip counting cut name: "+cutlabelvector[ibin-1]
|
276 |
continue
|
277 |
cutname = cutlabelvector[ibin-1]
|
278 |
acut = hcutflow.GetBinContent(ibin)
|
279 |
#print cutname
|
280 |
#print acut
|
281 |
#if sample=="data":
|
282 |
if sample.find("data")!=-1:
|
283 |
cutmap[ cutname ] = int(float(acut))
|
284 |
cutmaperr[ cutname ] = math.sqrt( cutmap[cutname] )
|
285 |
else:
|
286 |
cutmap[ cutname ] = Decimal(str(acut))
|
287 |
cutmaperr[ cutname ] = cutmap[cutname].sqrt() #math.sqrt( cutmap[cutname] )
|
288 |
|
289 |
roofile.Close()
|
290 |
|
291 |
scale = 1.
|
292 |
if IsMC and Lumi>0:
|
293 |
scale = Decimal( str( Lumi * xsec[ sample ] / Nevents[sample] ))
|
294 |
print "sample weight = "+ str( xsec[ sample ] / Nevents[sample] )
|
295 |
weightmap[sample] = xsec[ sample ] / Nevents[sample]
|
296 |
ilabel = 0
|
297 |
for key in cutmap.keys():
|
298 |
|
299 |
cutmap[ key ] = Decimal(str(scale)) * cutmap[ key]
|
300 |
cutmaperr[key]= Decimal(str(scale)) * Decimal(str(cutmaperr[key])) * Decimal( str(scale) ) * Decimal(str(cutmaperr[key]))
|
301 |
|
302 |
print " cut "+str(key) + " ("+cutlabel[key]+") "+" = "+str( round(cutmap[key],Ndecimals) )
|
303 |
|
304 |
if allmap.has_key(key):
|
305 |
allmap[ key ] += cutmap[ key ]
|
306 |
allmaperr[ key ] += cutmaperr[key]
|
307 |
else:
|
308 |
allmap[ key ] = cutmap[ key ]
|
309 |
allmaperr[ key ] = cutmap[key]
|
310 |
ilabel += 1
|
311 |
cutflow[ sample ] = cutmap
|
312 |
cutflowerr[ sample ] = cutmaperr
|
313 |
|
314 |
print " TOTAL"
|
315 |
ilabel=0
|
316 |
for key in allmap.keys():
|
317 |
print " cut "+str(key) + " ("+cutlabel[key]+") "+" = "+str( round(allmap[key],Ndecimals) )
|
318 |
ilabel += 1
|
319 |
|
320 |
cutflow["Total"] = allmap
|
321 |
cutflowerr["Total"] = allmaperr
|
322 |
|
323 |
# write latex
|
324 |
#sortedcutlist = ['GoodPV','OneIsoMu','LooseMuVeto','ElectronVeto', 'MET']
|
325 |
#sortedcutlist = ['GoodPV','OneIsoMu','LooseMuVeto','ElectronVeto', 'ZMassVeto', 'MET']
|
326 |
#sortedcutlist = ['GoodPV','OneIsoMu','ElectronVeto', 'MET','4Jet']
|
327 |
#sortedcutlist = ['GoodPV','ElectronVeto', '4Jet', 'Ht']
|
328 |
sortedcutlist= ['4Jet', 'Ht', '4Jet1b', '4JetCut','Stjet']
|
329 |
#sortedcutlist= ['4Jet', '4Jet1b']
|
330 |
#sortedcutlist= ['4Jet', '7Jet', '8Jet', '9Jet']
|
331 |
#sortedcutlist2= [ 'Ht', '4Jet1b', '4JetCut', 'Stjet']
|
332 |
sortedcutlist2= []
|
333 |
|
334 |
if IsMC:
|
335 |
cutlabel['CleanFilters'] = 'Processed'
|
336 |
|
337 |
texname = "cutflow_"+JetType+"_data.tex"
|
338 |
|
339 |
if IsMC:
|
340 |
texname = "cutflow_"+JetType+"_MC.tex"
|
341 |
if showGh:
|
342 |
texname = "cutflow_"+JetType+"_MC_4Top.tex"
|
343 |
|
344 |
outtex = open(texname,"w")
|
345 |
|
346 |
sss = " & "
|
347 |
|
348 |
# Write Header
|
349 |
outtex.write('''
|
350 |
\\documentclass[a4paper]{article}
|
351 |
\\usepackage[a4paper, left=1.5cm, right=1cm, top=2cm, bottom=2cm]{geometry}
|
352 |
\\begin{document}
|
353 |
\\begin{table}[h]
|
354 |
\\begin{centering}
|
355 |
''')
|
356 |
if IsMC:
|
357 |
aline = '\\begin{tabular}{|l|'+'c|'*(len(sortedcutlist)+1) +'} \hline \n'
|
358 |
if Lumi<=0:
|
359 |
aline = '\\begin{tabular}{|l|'+'c|'*len(sortedcutlist) +'} \hline \n'
|
360 |
outtex.write(aline)
|
361 |
#outtex.write('Cut & ttbar & Wjets & Zjets & QCD & STtch \hline')
|
362 |
line = "Sample"
|
363 |
for icut in sortedcutlist:
|
364 |
line += sss+cutlabel[icut]
|
365 |
outtex.write(line+" \\\ \hline \n")
|
366 |
else:
|
367 |
aline = '\\begin{tabular}{l|r|r|r|} \hline \n'
|
368 |
|
369 |
outtex.write(aline)
|
370 |
line = "Sample"
|
371 |
for icut in sortedcutlist:
|
372 |
line += sss+cutlabel[icut]
|
373 |
outtex.write(line+" \\\ \hline \n")
|
374 |
|
375 |
ilabel = 0
|
376 |
#for key in allmap.keys():
|
377 |
# Write content
|
378 |
for sample in tablelist:
|
379 |
|
380 |
line = label[sample]
|
381 |
|
382 |
for key in sortedcutlist:
|
383 |
cutmap = cutflow[sample]
|
384 |
cutmaperr = cutflowerr[sample]
|
385 |
acut = cutmap[key]
|
386 |
acuterr = cutmaperr[key]
|
387 |
stracut = str(int(acut))
|
388 |
stracuterr = str(round(math.sqrt(acuterr),Ndecimals))
|
389 |
#stracut = stracut.strip('.0')
|
390 |
if IsMC:
|
391 |
acut = round(cutmap[key],Ndecimals)
|
392 |
stracut = str(acut)
|
393 |
line += sss + stracut + " $\\pm$ " + stracuterr
|
394 |
else:
|
395 |
line += sss + stracut
|
396 |
if sample=="Total":line = '\\hline \n'+line
|
397 |
outtex.write(line+" \\\ \n")
|
398 |
ilabel += 1
|
399 |
|
400 |
outtex.write(''' \hline
|
401 |
\end{tabular}
|
402 |
%\caption{MC cutflow}\label{tab:tab}
|
403 |
\end{centering}
|
404 |
\end{table}
|
405 |
''')
|
406 |
|
407 |
|
408 |
if len(sortedcutlist2) > 0:
|
409 |
|
410 |
|
411 |
# Write Header
|
412 |
outtex.write('''
|
413 |
\\begin{table}[h]
|
414 |
\\begin{centering}
|
415 |
''')
|
416 |
if IsMC:
|
417 |
aline = '\\begin{tabular}{|l|'+'c|'*(len(sortedcutlist2)+1) +'} \hline \n'
|
418 |
if Lumi<=0:
|
419 |
aline = '\\begin{tabular}{|l|'+'c|'*len(sortedcutlist2) +'} \hline \n'
|
420 |
outtex.write(aline)
|
421 |
#outtex.write('Cut & ttbar & Wjets & Zjets & QCD & STtch \hline')
|
422 |
line = "Sample"
|
423 |
for icut in sortedcutlist2:
|
424 |
line += sss+cutlabel[icut]
|
425 |
outtex.write(line+" \\\ \hline \n")
|
426 |
else:
|
427 |
aline = '\\begin{tabular}{|l|r|r|r|} \hline \n'
|
428 |
|
429 |
outtex.write(aline)
|
430 |
line = "Sample"
|
431 |
for icut in sortedcutlist2:
|
432 |
line += sss+cutlabel[icut]
|
433 |
outtex.write(line+" \\\ \hline \n")
|
434 |
|
435 |
ilabel = 0
|
436 |
#for key in allmap.keys():
|
437 |
# Write content
|
438 |
for sample in tablelist:
|
439 |
|
440 |
line = label[sample]
|
441 |
|
442 |
for key in sortedcutlist2:
|
443 |
cutmap = cutflow[sample]
|
444 |
cutmaperr = cutflowerr[sample]
|
445 |
acut = cutmap[key]
|
446 |
acuterr = cutmaperr[key]
|
447 |
stracut = str(int(acut))
|
448 |
stracuterr = str(round(math.sqrt(acuterr),Ndecimals))
|
449 |
#stracut = stracut.strip('.0')
|
450 |
if IsMC:
|
451 |
acut = round(cutmap[key],Ndecimals)
|
452 |
stracut = str(acut)
|
453 |
line += sss + stracut + " $\\pm$ " + stracuterr
|
454 |
else:
|
455 |
line += sss + stracut
|
456 |
if sample=="Total":line = '\\hline \n'+line
|
457 |
outtex.write(line+" \\\ \n")
|
458 |
ilabel += 1
|
459 |
|
460 |
outtex.write(''' \hline
|
461 |
\end{tabular}
|
462 |
%\caption{MC cutflow}\label{tab:tab}
|
463 |
\end{centering}
|
464 |
\end{table}
|
465 |
\end{document}
|
466 |
''')
|
467 |
|
468 |
print "file "+texname+ " has been written."
|
469 |
|
470 |
if IsMC:
|
471 |
|
472 |
print "\n MC Weights"
|
473 |
tmplistsamples = weightmap.keys()
|
474 |
tmplistsamples.sort()
|
475 |
for sample in tmplistsamples:
|
476 |
|
477 |
print sample+" "+str(weightmap[sample])
|
478 |
|
479 |
|
480 |
|
481 |
|