def demo1(): dc = card('hww-19.47fb.mH110.sf_vh2j_shape.txt') dc2 = card('hwwsf_0j_cut_7TeV.txt') info('examples of reading card') print 'read sf_vh2j, ggH, CMS_8TeV_eff_l, shape', dc.getSyst(bin='sf_vh2j',process='ggH', syst='shapeN2', tag='CMS_8TeV_eff_l') print 'read sf_vh2j, ggH, Gen_pow_WW, shape', dc.getSyst(bin='sf_vh2j',process='WW', syst='shapeN2', tag='Gen_pow_WW') print 'read sf_vh2j, ggH, Gen_pow_WW, shape', dc.getSyst(bin='sf_vh2j',process='VV', syst='shapeN2', tag='Gen_pow_WW') print info('examples of adding columns') print 'adding column of dc2 to dc (new names):' dc.setCol(content=dc2.getCol(bin='j0sf7tev',process='ZH'),bin='addedbin',process='addedprocess',processId='99') print 'adding column of dc2 to dc (orig names):' dc.setCol(content=dc2.getCol(bin='j0sf7tev',process='ZH')) dc.write()
def demo0(): dc = card('datacard_mbbCor_m115_CATMIN1_Binned_adapted.txt') #################### info('Example printout of scanned card:') dc.write() print #################### info('Example of reading and setting rate:') print 'read CAT1, signal, rate: \t', dc.getRate(bin='CAT1', process='signal') print 'read CAT1, 0, rate: \t', dc.getRate(bin='CAT1', processId='0') print 'read CAT1, background, rate: \t', dc.getRate(bin='CAT1', process='background') print 'set CAT1, background, rate to 1.111' dc.setRate(bin='CAT1', process='background',value='1.111') print 'read CAT, background, rate: \t', dc.getRate(bin='CAT1', process='background') print #################### info('Example of reading and setting systematic (lnN):') print 'read CAT1, signal, lnN, lumi:\t', dc.getSyst(bin='CAT1', process='signal', syst='lnN', tag='lumi') print 'read CAT3, signal, lnN, trigEff:\t', dc.getSyst(bin='CAT3', process='signal', syst='lnN', tag='trigEff') print 'read CAT3, 0, lnN, trigEff:\t', dc.getSyst(bin='CAT3', processId='0', syst='lnN', tag='trigEff') print 'set CAT3, 0, lnN, trigEff to 1.111' dc.setSyst(bin='CAT3', processId='0', syst='lnN', tag='trigEff',value='1.111') print 'read CAT3, 0, lnN, trigEff:\t', dc.getSyst(bin='CAT3', processId='0', syst='lnN', tag='trigEff') print #################### info('Example of reading and setting systematic (gmN):') print 'read CAT1, signal, gmN, blablabla: \t', dc.getSyst(bin='CAT1', process='signal', syst='gmN', tag='blablabla') print #################### info('Example of reading and setting systematic (param):') print 'read nzjet_CAT1, column 0: \t', dc.getSyst(syst='param',tag='nzjet_CAT1',col=0) print 'set nzjet_CAT1, column 0 to 9.9999' dc.setSyst(syst='param',tag='nzjet_CAT1',col=0,value='9.9999') print 'read nzjet_CAT1, column 0: \t', dc.getSyst(syst='param',tag='nzjet_CAT1',col=0) print #################### info('Example of adding shape:') dc.addShape('signal2','*','bla','blablabla') print #################### info('Example of adding column:') dc.addCol('CAT5','signal','0','22.55','-1') dc.addCol('CAT5','background','1','33.44','-1') #################### info('Example of filling new column:') dc.setSyst(bin='CAT5', process='signal',syst='lnN',tag='trigEff',value='1.033') dc.setSyst(bin='CAT5', process='signal',syst='lnN',tag='lumi',value=dc.getSyst(bin='CAT1',process='signal',syst='lnN',tag='lumi')) print #################### info('Example printout of edited card (to screen):') dc.write() ##################### #info('Example printout of edited card (to dataCard_new.txt):') #dc.write('dataCard_new.txt') print #################### info('Example getCol()') dc.setCol(content=dc.getCol(bin='CAT1',process='signal',processId='0'),bin='CAT17',process='signal',processId='0') dc.write()