def rename_and_write(cb): print '>> Setting standardised bin names...' ch.SetStandardBinNames(cb) writer = ch.CardWriter( 'LIMITS/$TAG/$MASS/$ANALYSIS_$CHANNEL_$BINID_$ERA.txt', 'LIMITS/$TAG/common/$ANALYSIS_$CHANNEL.input.root') # writer.SetVerbosity(1) writer.WriteCards('cmb', cb) for chn in chns: writer.WriteCards(chn, cb.cp().channel([chn])) print '>> Done!'
ch.SystMap('process')(['ttZ'], 0.919)(['ttH'], 0.926)) cb.cp().AddSyst( cb, 'pdf_qqbar', 'lnN', ch.SystMap('process')(['tH_YtMinus'], 1.048)(['ttW'], 1.072)(['WZ', 'ZZ'], 1.040)) cb.cp().AddSyst(cb, 'pdf_qg', 'lnN', ch.SystMap('process')(['tHW'], 1.048)) print '>> Extracting histograms from input root files...' file = aux_shapes + 'CERN/htt_th.inputs-sm-8TeV.root' cb.cp().backgrounds().ExtractShapes(file, '$BIN/$PROCESS', '$BIN/$PROCESS_$SYSTEMATIC') cb.cp().signals().ExtractShapes(file, '$BIN/$PROCESS$MASS', '$BIN/$PROCESS$MASS_$SYSTEMATIC') print '>> Generating bbb uncertainties...' bbb = ch.BinByBinFactory() bbb.SetAddThreshold(0.1).SetFixNorm(True) bbb.AddBinByBin(cb.cp().process(['reducible']), cb) print '>> Setting standardised bin names...' ch.SetStandardBinNames(cb) cb.PrintAll() writer = ch.CardWriter('$TAG/$MASS/$ANALYSIS_$CHANNEL_$BINID_$ERA.txt', '$TAG/common/$ANALYSIS_$CHANNEL.input.root') writer.SetVerbosity(1) writer.WriteCards('output/sm_cards/LIMITS', cb) print '>> Done!'
cb.cp().process(['TTT','TTL','TTJ','ST']).AddSyst(cb, 'xsec_top', 'lnN', ch.SystMap()(1.10)) cb.cp().process(['VV']).AddSyst(cb, 'xsec_vv', 'lnN', ch.SystMap()(1.15)) cb.cp().process(['ZL','ZTT','ZJ']).AddSyst(cb, 'xsec_z', 'lnN', ch.SystMap()(1.03)) cb.cp().process(['W']).AddSyst(cb, 'w_estimation', 'lnN', ch.SystMap()(1.20)) cb.cp().process(['ZJ','TTJ']).AddSyst(cb, 'jet_to_tauFR', 'lnN', ch.SystMap()(1.30)) cb.cp().process(['QCD']).AddSyst(cb, 'ss_to_os_extrap', 'lnN', ch.SystMap()(1.2)) cb.cp().process(['ZL']).AddSyst(cb, 'vsjetSF', 'rateParam', ch.SystMap()(1.0)) cb.cp().process(['ZTT', 'TTT']).AddSyst(cb, 'TES', 'shape', ch.SystMap()(1.0)) cb.cp().process(['ZL', 'TTL']).AddSyst(cb, 'FES', 'shape', ch.SystMap()(1.0)) filepath = os.path.join(os.environ['CMSSW_BASE'],'src/TauFW/Fitter/MuTauFR/input', "MuTauFR_m_vis_eta%s_mt-2016.inputs.root")%(ieta) processName = '%s$BIN/$PROCESS'%(iwp) systematicName = '%s$BIN/$PROCESS_$SYSTEMATIC'%(iwp) cb.cp().backgrounds().ExtractShapes(filepath, processName, systematicName) cb.cp().signals().ExtractShapes(filepath, processName, systematicName) ch.SetStandardBinNames(cb, '$BIN') # Define the name of the category names #cb.SetAutoMCStats(cb, 0.0) # Introducing statistical uncertainties on the total background for each histogram bin (Barlow-Beeston lite approach) bbb = ch.BinByBinFactory() bbb.SetAddThreshold(0.1).SetMergeThreshold(0.5).SetFixNorm(True) bbb.MergeBinErrors(cb.cp().backgrounds()) bbb.AddBinByBin(cb.cp().backgrounds(), cb) datacardPath = 'input/2016/MuTauFR/%s_eta%s.txt'%(iwp,ieta) shapePath = 'input/2016/MuTauFR/common/%s_eta%s.root'%(iwp,ieta) writer = ch.CardWriter(datacardPath,shapePath) writer.SetWildcardMasses([]) writer.WriteCards('cmb', cb) # writing all datacards into one folder for combination #cb.PrintAll() #writer.WriteCards(channel, cb.cp().channel([channel])) # writing datacards for each final state in a corresponding folder to be able to perform the measurement individually in each final state print 'pre-fit fake rate:'