ViewVC Help
View File | Revision Log | Show Annotations | Root Listing
root/cvsroot/UserCode/VHbb/python/dc_tex_converter.py
Revision: 1.4
Committed: Tue Oct 9 22:20:49 2012 UTC (12 years, 7 months ago) by nmohr
Content type: text/x-python
Branch: MAIN
CVS Tags: lhcp_UnblindFix, hcp_Unblind, lhcp_11April, LHCP_PreAppFixAfterFreeze, LHCP_PreAppFreeze, workingVersionAfterHCP, hcpApproval, HCP_unblinding, hcpPreApp, HEAD
Changes since 1.3: +9 -4 lines
Log Message:
Add parser

File Contents

# User Rev Content
1 bortigno 1.1 #!/afs/cern.ch/cms/slc5_amd64_gcc434/cms/cmssw/CMSSW_4_2_8/external/slc5_amd64_gcc434/bin/python2.6
2    
3 nmohr 1.4 import os,sys
4 bortigno 1.1 import ROOT
5 nmohr 1.4 from optparse import OptionParser
6 bortigno 1.1
7 nmohr 1.4 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 nmohr 1.2 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 bortigno 1.1
17     def dc_tex_converter(rootFile):
18 nmohr 1.2 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 bortigno 1.1 infile = ROOT.TFile(rootFile,"READ")
32     for histo in histos:
33 nmohr 1.2 th1 = infile.Get(histo)
34     integral,error = getNr(th1)
35     dictNr[histo] = ' ' + '$%.2f' %(integral) + ' \pm ' + '%.2f$' %(error)
36 bortigno 1.1
37 nmohr 1.3 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 nmohr 1.2 outname = rootFile.replace('.root','.row')
39     f = open(outname,'w')
40     f.write(theString)
41     print outname
42     f.close()
43 bortigno 1.1
44     if __name__ == "__main__":
45 nmohr 1.4 dc_tex_converter(files)