1 |
#!/afs/cern.ch/cms/slc5_amd64_gcc434/cms/cmssw/CMSSW_4_2_8/external/slc5_amd64_gcc434/bin/python2.6
|
2 |
|
3 |
import os,sys
|
4 |
import ROOT
|
5 |
from optparse import OptionParser
|
6 |
|
7 |
argv = sys.argv
|
8 |
parser = OptionParser()
|
9 |
parser.add_option("-F", "--file", dest="file", default="",
|
10 |
help="File with TH to create the .row from, must contain M125, eg vhbb_TH_BDT_M125_ZeeLowPt_8TeV.root")
|
11 |
(opts, args) = parser.parse_args(argv)
|
12 |
files = opts.file
|
13 |
histos=[ 'TT','ZjLF','ZjHF', 'VV','s_Top' ]
|
14 |
masses = [110,115,120,125,130,135]
|
15 |
dictNr = {'QCD': '--','WjHF': '--','WjLF': '--','WH110':'--','WH115':'--','WH120':'--','WH125':'--','WH130':'--','WH135':'--'}
|
16 |
|
17 |
def dc_tex_converter(rootFile):
|
18 |
def getNr(th1):
|
19 |
error = ROOT.Double()
|
20 |
integral = th1.IntegralAndError(0,1000,error)
|
21 |
return integral,error
|
22 |
if 'Zee' in rootFile: dictNr['mode'] = 'ZeeH'
|
23 |
if 'Zmm' in rootFile: dictNr['mode'] = 'ZmmH'
|
24 |
|
25 |
for mass in masses:
|
26 |
infile = ROOT.TFile(rootFile.replace('M125','M%.0f'%mass),"READ")
|
27 |
th1 = infile.Get('VH')
|
28 |
integral,error = getNr(th1)
|
29 |
dictNr['ZH%.0f'%mass] = ' ' + '$%.2f' %(integral) + ' \pm ' + '%.2f$' %(error)
|
30 |
|
31 |
infile = ROOT.TFile(rootFile,"READ")
|
32 |
for histo in histos:
|
33 |
th1 = infile.Get(histo)
|
34 |
integral,error = getNr(th1)
|
35 |
dictNr[histo] = ' ' + '$%.2f' %(integral) + ' \pm ' + '%.2f$' %(error)
|
36 |
|
37 |
theString = '$\\%(mode)s$ & %(ZjLF)s & %(ZjHF)s & %(WjLF)s & %(WjLF)s & %(TT)s & %(s_Top)s & %(VV)s & %(ZH110)s & %(WH110)s & %(ZH115)s & %(WH115)s & %(ZH120)s & %(WH120)s & %(ZH125)s & %(WH125)s & %(ZH130)s & %(WH130)s & %(ZH135)s & %(WH135)s \\\\'%dictNr
|
38 |
outname = rootFile.replace('.root','.row')
|
39 |
f = open(outname,'w')
|
40 |
f.write(theString)
|
41 |
print outname
|
42 |
f.close()
|
43 |
|
44 |
if __name__ == "__main__":
|
45 |
dc_tex_converter(files)
|