def print_yield_table(procs, rates, output_name): hists = [] bkgh = r.TH1F("Total", "Total", 1, 0, 1) total_rate = E(0, 0) for proc, rate in zip(procs, rates): procname = proc.split("_")[1] h = r.TH1F(procname, procname, 1, 0, 1) if procname != "sig" and procname != "wzz" and procname != "wzz" and procname != "zzz": total_rate += rate h.SetBinContent(1, rate.val) h.SetBinError(1, rate.err) hists.append(h) bkgh.SetBinContent(1, total_rate.val) bkgh.SetBinError(1, total_rate.err) hists.insert(0, bkgh) obsh = bkgh.Clone("obs") obsh.Reset() hists.insert(0, obsh) p.print_yield_table_from_list(hists, output_name + ".txt", prec=2, binrange=[1]) p.print_yield_tex_table_from_list(hists, output_name + ".tex", prec=2)
def main(): # -- combined version where only one transfer factor is computed # MET/Mll combined extrapolation hists = get_alpha_hists("zz", "ChannelOffZHighMET", "ChannelOnZ") p.print_yield_table_from_list(hists, "exp/zz_eemm_tf.txt", prec=4, binrange=[1, 2, 3], noerror=True) p.print_yield_tex_table_from_list(hists, "exp/zz_eemm_tf.tex", prec=4, caption="eemm zz transfer factor", noerror=True) # flavor/Mll/MT combined extrapolation hists = get_alpha_hists("zz", "ChannelEMuHighMT", "ChannelOnZ") p.print_yield_table_from_list(hists, "exp/zz_emu_tf.txt", prec=4, binrange=[1, 2, 3], noerror=True) p.print_yield_tex_table_from_list(hists, "exp/zz_emu_tf.tex", prec=4, caption="emu zz transfer factor", noerror=True) # nbjet/MT combined extrapolation hists = get_alpha_hists("ttz", "ChannelEMuHighMT", "ChannelBTagEMu") p.print_yield_table_from_list(hists, "exp/ttz_emu_tf.txt", prec=4, binrange=[1, 2, 3], noerror=True) p.print_yield_tex_table_from_list(hists, "exp/ttz_emu_tf.tex", prec=4, caption="emu ttz transfer factor", noerror=True) # flavor/nbjet/MET combined extrapolation hists = get_alpha_hists("ttz", "ChannelOffZHighMET", "ChannelBTagEMu") p.print_yield_table_from_list(hists, "exp/ttz_eemm_tf.txt", prec=4, binrange=[1, 2, 3], noerror=True) p.print_yield_tex_table_from_list(hists, "exp/ttz_eemm_tf.tex", prec=4, caption="eemm ttz transfer factor", noerror=True)
def main_add(): # hists = get_eff_ratios("ttz" , "BTagEMu" , "MET" , "mc") # p.print_yield_table_from_list(hists, "exp/eff_ratio_ttz_met.txt", prec=4, binrange=[1], noerror=False) # p.print_yield_tex_table_from_list(hists, "exp/eff_ratio_ttz_met.tex", prec=4, caption="ttz cut eff. comparison", noerror=False) # hists = get_eff_ratios("ttz" , "BTagEMu" , "MET" , "data") # p.print_yield_table_from_list(hists, "exp/eff_ratio_ttz_met.txt", prec=4, binrange=[1], noerror=False) # p.print_yield_tex_table_from_list(hists, "exp/eff_ratio_ttz_met.tex", prec=4, caption="ttz cut eff. comparison", noerror=False) hists = get_eff_ratios("ttz", "BTagEMu", "MET", "ratio") p.print_yield_table_from_list(hists, "exp/eff_ratio_ttz_met.txt", prec=4, binrange=[1], noerror=False) p.print_yield_tex_table_from_list(hists, "exp/eff_ratio_ttz_met.tex", prec=4, caption="ttz cut eff. comparison", noerror=False) # hists = get_eff_ratios("ttz" , "BTagEMu" , "MT" , "mc") # p.print_yield_table_from_list(hists, "exp/eff_ratio_ttz_mt.txt", prec=4, binrange=[1], noerror=False) # p.print_yield_tex_table_from_list(hists, "exp/eff_ratio_ttz_mt.tex", prec=4, caption="ttz cut eff. comparison", noerror=False) # hists = get_eff_ratios("ttz" , "BTagEMu" , "MT" , "data") # p.print_yield_table_from_list(hists, "exp/eff_ratio_ttz_mt.txt", prec=4, binrange=[1], noerror=False) # p.print_yield_tex_table_from_list(hists, "exp/eff_ratio_ttz_mt.tex", prec=4, caption="ttz cut eff. comparison", noerror=False) hists = get_eff_ratios("ttz", "BTagEMu", "MT", "ratio") p.print_yield_table_from_list(hists, "exp/eff_ratio_ttz_mt.txt", prec=4, binrange=[1], noerror=False) p.print_yield_tex_table_from_list(hists, "exp/eff_ratio_ttz_mt.tex", prec=4, caption="ttz cut eff. comparison", noerror=False) # hists = get_eff_ratios("ttz" , "BTagEMu" , "MET" , "mc") # p.print_yield_table_from_list(hists, "exp/eff_ratio_ttz_met.txt", prec=4, binrange=[1], noerror=False) # p.print_yield_tex_table_from_list(hists, "exp/eff_ratio_ttz_met.tex", prec=4, caption="zz cut eff. comparison", noerror=False) # hists = get_eff_ratios("ttz" , "BTagEMu" , "MET" , "data") # p.print_yield_table_from_list(hists, "exp/eff_ratio_ttz_met.txt", prec=4, binrange=[1], noerror=False) # p.print_yield_tex_table_from_list(hists, "exp/eff_ratio_ttz_met.tex", prec=4, caption="zz cut eff. comparison", noerror=False) hists = get_eff_ratios("zz", "OnZ", "MET", "ratio") p.print_yield_table_from_list(hists, "exp/eff_ratio_zz_met.txt", prec=4, binrange=[1], noerror=False) p.print_yield_tex_table_from_list(hists, "exp/eff_ratio_zz_met.tex", prec=4, caption="zz cut eff. comparison", noerror=False) # hists = get_eff_ratios("zz" , "OnZ" , "MT" , "mc") # p.print_yield_table_from_list(hists, "exp/eff_ratio_zz_mt.txt", prec=4, binrange=[1], noerror=False) # p.print_yield_tex_table_from_list(hists, "exp/eff_ratio_zz_mt.tex", prec=4, caption="zz cut eff. comparison", noerror=False) # hists = get_eff_ratios("zz" , "OnZ" , "MT" , "data") # p.print_yield_table_from_list(hists, "exp/eff_ratio_zz_mt.txt", prec=4, binrange=[1], noerror=False) # p.print_yield_tex_table_from_list(hists, "exp/eff_ratio_zz_mt.tex", prec=4, caption="zz cut eff. comparison", noerror=False) hists = get_eff_ratios("zz", "OnZ", "MT", "ratio") p.print_yield_table_from_list(hists, "exp/eff_ratio_zz_mt.txt", prec=4, binrange=[1], noerror=False) p.print_yield_tex_table_from_list(hists, "exp/eff_ratio_zz_mt.tex", prec=4, caption="zz cut eff. comparison", noerror=False)
def main_old_v2(): # N btag extrapolation uncertainty from simulation hists = get_alpha_hists("ttz", "ChannelEMu", "ChannelBTagEMu") p.print_yield_table_from_list(hists, "exp/ttz_emu_alpha.txt", prec=2, binrange=[1, 2, 3], noerror=True) p.print_yield_tex_table_from_list(hists, "exp/ttz_emu_alpha.tex", prec=2, caption="Nb extrapolation", noerror=True) # N btag and em to eemm extrapolation uncertainty from simulation hists = get_alpha_hists("ttz", "ChannelOffZ", "ChannelBTagEMu") p.print_yield_table_from_list(hists, "exp/ttz_offz_alpha.txt", prec=2, binrange=[1, 2, 3], noerror=True) p.print_yield_tex_table_from_list(hists, "exp/ttz_offz_alpha.tex", prec=2, caption="Nb plus emu eemm Extrapolation", noerror=True) # MT extrapolation hists = get_alpha_hists("ttz", "ChannelEMuHighMT", "ChannelEMu") p.print_yield_table_from_list(hists, "exp/ttz_emu_mt_alpha.txt", prec=2, binrange=[1, 2, 3], noerror=True) p.print_yield_tex_table_from_list(hists, "exp/ttz_emu_mt_alpha.tex", prec=2, caption="emu MT extrapolation", noerror=True) # MET extrapolation hists = get_alpha_hists("ttz", "ChannelOffZHighMET", "ChannelOffZ") p.print_yield_table_from_list(hists, "exp/ttz_eemm_met_alpha.txt", prec=2, binrange=[1, 2, 3], noerror=True) p.print_yield_tex_table_from_list(hists, "exp/ttz_eemm_met_alpha.tex", prec=2, caption="eemm MET extrapolation", noerror=True) # Mll extrapolation hists = get_alpha_hists("zz", "ChannelOffZ", "ChannelOnZ") p.print_yield_table_from_list(hists, "exp/zz_eemm_mll_alpha.txt", prec=2, binrange=[1, 2, 3], noerror=True) p.print_yield_tex_table_from_list(hists, "exp/zz_eemm_mll_alpha.tex", prec=2, caption="eemm Mll extrapolation", noerror=True) # MET extrapolation hists = get_alpha_hists("zz", "ChannelOffZHighMET", "ChannelOffZ") p.print_yield_table_from_list(hists, "exp/zz_eemm_met_alpha.txt", prec=2, binrange=[1, 2, 3], noerror=True) p.print_yield_tex_table_from_list(hists, "exp/zz_eemm_met_alpha.tex", prec=2, caption="eemm Mll extrapolation", noerror=True) # MET extrapolation hists = get_alpha_hists("zz", "ChannelEMu", "ChannelOnZ") p.print_yield_table_from_list(hists, "exp/zz_emu_flav_alpha.txt", prec=2, binrange=[1, 2, 3], noerror=True) p.print_yield_tex_table_from_list(hists, "exp/zz_emu_flav_alpha.tex", prec=2, caption="emu flavor extrapolation", noerror=True) # MT extrapolation hists = get_alpha_hists("zz", "ChannelEMuHighMT", "ChannelEMu") p.print_yield_table_from_list(hists, "exp/zz_emu_mt_alpha.txt", prec=2, binrange=[1, 2, 3], noerror=True) p.print_yield_tex_table_from_list(hists, "exp/zz_emu_mt_alpha.tex", prec=2, caption="emu mtor extrapolation", noerror=True)