ViewVC Help
View File | Revision Log | Show Annotations | Root Listing
root/cvsroot/UserCode/VHbb/test/prepare_datacard.py
(Generate patch)

Comparing UserCode/VHbb/test/prepare_datacard.py (file contents):
Revision 1.2 by bortigno, Wed May 9 09:23:30 2012 UTC vs.
Revision 1.4 by bortigno, Fri Jun 22 15:49:45 2012 UTC

# Line 1 | Line 1
1 < #!/usr/bin/python2.6  
1 > #!/afs/cern.ch/cms/slc5_amd64_gcc434/cms/cmssw/CMSSW_4_2_8/external/slc5_amd64_gcc434/bin/python2.6
2 > ##!/usr/bin/python2.6  
3  
4   import os
5   import math
# Line 53 | Line 54 | for line in file:
54  
55      if ( line.find('DYB') ) > 0:
56          if( line.find('stat') > 0 ):
57 <            stat[2] = getfloat_from_line(line)
57 >            stat[1] = getfloat_from_line(line)
58          if ( line.find('btag') > 0 )  or (line.find('mistag') > 0 ):
59              dyb_btag = get_errors( line, dyb_btag )
60          if ( line.find('jer') > 0 ) or ( line.find('jec') > 0):
# Line 61 | Line 62 | for line in file:
62  
63      if ( line.find('TTbar') ) > 0:
64          if( line.find('stat') > 0 ):
65 <            stat[3] = getfloat_from_line(line)
65 >            stat[2] = getfloat_from_line(line)
66          if ( line.find('btag') > 0 )  or (line.find('mistag') > 0 ):
67              ttbar_btag = get_errors( line, ttbar_btag )
68          if ( line.find('jer') > 0 ) or ( line.find('jec') > 0):
# Line 69 | Line 70 | for line in file:
70  
71  
72   dyl_syst = sum_errors( max(dyl_btag), max(dyl_je) )
73 < dyc_syst = sum_errors( max(dyc_btag), max(dyc_je) )
73 > #dyc_syst = sum_errors( max(dyc_btag), max(dyc_je) )
74   dyb_syst = sum_errors( max(dyb_btag), max(dyb_je) )
75   ttbar_syst = sum_errors( max(dyl_btag), max(ttbar_je) )
76  
77 +
78 + print 'Systematics only'
79   print dyl_syst
80 < print dyc_syst
80 > #print dyc_syst
81   print dyb_syst
82   print ttbar_syst
83  
84   print "Final"
85  
86   dyl_err = sum_errors( stat[0], dyl_syst )
87 < dyc_err = sum_errors( stat[1], dyc_syst )
88 < dyb_err = sum_errors( stat[2], dyb_syst )
89 < ttbar_err = sum_errors( stat[3], ttbar_syst )
87 > #dyc_err = sum_errors( stat[1], dyc_syst )
88 > dyb_err = sum_errors( stat[1], dyb_syst )
89 > ttbar_err = sum_errors( stat[2], ttbar_syst )
90  
91   print dyl_err
92 < print dyc_err
92 > #print dyc_err
93   print dyb_err
94   print ttbar_err
95  
# Line 94 | Line 97 | correlation_file = open('CorrelationMatr
97   corr = get_correlation_matrix( correlation_file )
98   print corr
99  
100 < dyl_string = 'CMS_vhbb_ZjLF_SF    lnN    -    -     -    ' + '%.3f' % (1.+float(corr[0][0])*dyl_err) + ' ' + '%.3f' %(1.+(float(corr[0][1])*dyl_err)) + ' ' + '%.3f' %(1.+float(corr[0][2])*dyl_err) + ' ' + '%.3f' %(1.+float(corr[0][3])*dyl_err) + '   -   -   -   -  \n'
101 < dyc_string = 'CMS_vhbb_ZjCF_SF    lnN    -    -     -    ' + '%.3f' %(1.+float(corr[1][0])*dyc_err) + ' ' + '%.3f' %(1.+(float(corr[1][1])*dyc_err)) + ' ' + '%.3f' %(1.+float(corr[1][2])*dyc_err) + ' ' + '%.3f' %(1.+float(corr[1][3])*dyc_err) + '   -   -   -   -  \n'
102 < dyb_string = 'CMS_vhbb_ZjHF_SF    lnN    -    -     -    ' + '%.3f' %(1.+float(corr[2][0])*dyb_err) + ' ' + '%.3f' %(1.+(float(corr[2][1])*dyb_err)) + ' ' + '%.3f' %(1.+float(corr[2][2])*dyb_err) + ' ' + '%.3f' %(1.+float(corr[2][3])*dyb_err) + '   -   -   -   -  \n'
103 < ttbar_string = 'CMS_vhbb_TT_SF    lnN    -    -     -    ' + '%.3f' %(1.+float(corr[3][0])*ttbar_err) + ' ' + '%.3f' %(1.+(float(corr[3][1])*ttbar_err)) + ' ' + '%.3f' %(1.+float(corr[3][2])*ttbar_err) + ' ' + '%.3f' %(1.+float(corr[3][3])*ttbar_err) + '   -   -   -   -  \n'
100 > # dyl_string = 'CMS_vhbb_ZjLF_SF    lnN    -    -     -    ' + '%.3f' % (1.+float(corr[0][0])*dyl_err) + ' ' + '%.3f' %(1.+(float(corr[0][1])*dyl_err)) + ' ' + '%.3f' %(1.+float(corr[0][2])*dyl_err) + ' ' + '%.3f' %(1.+float(corr[0][3])*dyl_err) + '   -   -   -   -  \n'
101 > # dyc_string = 'CMS_vhbb_ZjCF_SF    lnN    -    -     -    ' + '%.3f' %(1.+float(corr[1][0])*dyc_err) + ' ' + '%.3f' %(1.+(float(corr[1][1])*dyc_err)) + ' ' + '%.3f' %(1.+float(corr[1][2])*dyc_err) + ' ' + '%.3f' %(1.+float(corr[1][3])*dyc_err) + '   -   -   -   -  \n'
102 > # dyb_string = 'CMS_vhbb_ZjHF_SF    lnN    -    -     -    ' + '%.3f' %(1.+float(corr[2][0])*dyb_err) + ' ' + '%.3f' %(1.+(float(corr[2][1])*dyb_err)) + ' ' + '%.3f' %(1.+float(corr[2][2])*dyb_err) + ' ' + '%.3f' %(1.+float(corr[2][3])*dyb_err) + '   -   -   -   -  \n'
103 > # ttbar_string = 'CMS_vhbb_TT_SF    lnN    -    -     -    ' + '%.3f' %(1.+float(corr[3][0])*ttbar_err) + ' ' + '%.3f' %(1.+(float(corr[3][1])*ttbar_err)) + ' ' + '%.3f' %(1.+float(corr[3][2])*ttbar_err) + ' ' + '%.3f' %(1.+float(corr[3][3])*ttbar_err) + '   -   -   -   -  \n'
104 >
105 > dyl_string = 'CMS_vhbb_ZjLF_SF    lnN    -    -     -    ' + '%.3f' % (1.+float(corr[0][0])*dyl_err) + ' ' + '%.3f' %(1.+(float(corr[0][1])*dyl_err)) + ' ' + '%.3f' %(1.+float(corr[0][2])*dyl_err) + '   -   -   -   -  \n'
106 > dyb_string = 'CMS_vhbb_ZjHF_SF    lnN    -    -     -    ' + '%.3f' %(1.+float(corr[1][0])*dyb_err) + ' ' + '%.3f' %(1.+(float(corr[1][1])*dyb_err)) + ' ' + '%.3f' %(1.+float(corr[1][2])*dyb_err) + '   -   -   -   -  \n'
107 > ttbar_string = 'CMS_vhbb_TT_SF    lnN    -    -     -    ' + '%.3f' %(1.+float(corr[2][0])*ttbar_err) + ' ' + '%.3f' %(1.+(float(corr[2][1])*ttbar_err)) + ' ' + '%.3f' %(1.+float(corr[2][2])*ttbar_err) + '   -   -   -   -  \n'
108 >
109  
110   print dyl_string
111 < print dyc_string
111 > #print dyc_string
112   print dyb_string
113   print ttbar_string
114  
115   outfile = open("Datacard.txt",'w')
116   outfile.writelines(dyl_string)
117 < outfile.writelines(dyc_string)
117 > #outfile.writelines(dyc_string)
118   outfile.writelines(dyb_string)
119   outfile.writelines(ttbar_string)
120   outfile.close()

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines