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.3 by bortigno, Thu May 31 08:31:47 2012 UTC

# Line 53 | Line 53 | for line in file:
53  
54      if ( line.find('DYB') ) > 0:
55          if( line.find('stat') > 0 ):
56 <            stat[2] = getfloat_from_line(line)
56 >            stat[1] = getfloat_from_line(line)
57          if ( line.find('btag') > 0 )  or (line.find('mistag') > 0 ):
58              dyb_btag = get_errors( line, dyb_btag )
59          if ( line.find('jer') > 0 ) or ( line.find('jec') > 0):
# Line 61 | Line 61 | for line in file:
61  
62      if ( line.find('TTbar') ) > 0:
63          if( line.find('stat') > 0 ):
64 <            stat[3] = getfloat_from_line(line)
64 >            stat[2] = getfloat_from_line(line)
65          if ( line.find('btag') > 0 )  or (line.find('mistag') > 0 ):
66              ttbar_btag = get_errors( line, ttbar_btag )
67          if ( line.find('jer') > 0 ) or ( line.find('jec') > 0):
# Line 69 | Line 69 | for line in file:
69  
70  
71   dyl_syst = sum_errors( max(dyl_btag), max(dyl_je) )
72 < dyc_syst = sum_errors( max(dyc_btag), max(dyc_je) )
72 > #dyc_syst = sum_errors( max(dyc_btag), max(dyc_je) )
73   dyb_syst = sum_errors( max(dyb_btag), max(dyb_je) )
74   ttbar_syst = sum_errors( max(dyl_btag), max(ttbar_je) )
75  
76 +
77 + print 'Systematics only'
78   print dyl_syst
79 < print dyc_syst
79 > #print dyc_syst
80   print dyb_syst
81   print ttbar_syst
82  
83   print "Final"
84  
85   dyl_err = sum_errors( stat[0], dyl_syst )
86 < dyc_err = sum_errors( stat[1], dyc_syst )
87 < dyb_err = sum_errors( stat[2], dyb_syst )
88 < ttbar_err = sum_errors( stat[3], ttbar_syst )
86 > #dyc_err = sum_errors( stat[1], dyc_syst )
87 > dyb_err = sum_errors( stat[1], dyb_syst )
88 > ttbar_err = sum_errors( stat[2], ttbar_syst )
89  
90   print dyl_err
91 < print dyc_err
91 > #print dyc_err
92   print dyb_err
93   print ttbar_err
94  
# Line 94 | Line 96 | correlation_file = open('CorrelationMatr
96   corr = get_correlation_matrix( correlation_file )
97   print corr
98  
99 < 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'
100 < 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'
101 < 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'
102 < 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'
99 > # 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'
100 > # 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'
101 > # 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'
102 > # 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'
103 >
104 > 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'
105 > 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'
106 > 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'
107 >
108  
109   print dyl_string
110 < print dyc_string
110 > #print dyc_string
111   print dyb_string
112   print ttbar_string
113  
114   outfile = open("Datacard.txt",'w')
115   outfile.writelines(dyl_string)
116 < outfile.writelines(dyc_string)
116 > #outfile.writelines(dyc_string)
117   outfile.writelines(dyb_string)
118   outfile.writelines(ttbar_string)
119   outfile.close()

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines