コード例 #1
0
	def __init__(self, higgs_masses=["125"], ttbarFit=False, mmFit=False, year="", noJECuncSplit=False, cb=None, signal_processes=None):
		super(SMHttDatacards, self).__init__(cb)

		if cb is None:
			if signal_processes is None:
				signal_processes = ["ggH", "qqH", "WH", "ZH"]

			background_processes_mt = ["ZTT", "ZL", "ZJ", "EWKZ", "TTT", "TTJJ", "VV", "W", "QCD"]
			background_processes_et = ["ZTT", "ZL", "ZJ", "EWKZ", "TTT", "TTJJ", "VV", "W", "QCD"]
			background_processes_tt = ["ZTT", "ZL", "ZJ", "EWKZ", "TTT", "TTJJ", "VVT", "VVJ", "W", "QCD"]
			background_processes_em = ["ZTT", "ZLL", "EWKZ", "TT", "VV", "hww_gg125", "hww_qq125", "W", "QCD"]
			background_processes_mm = ["ZLL", "TT", "VV", "W"]
			background_processes_ttbar = ["ZTT", "ZLL", "EWKZ", "TT", "VV", "W", "QCD"]

			all_mc_bkgs = ["ZTT", "ZL", "ZJ", "ZLL", "EWKZ", "TT", "TTT", "TTJJ", "VV", "VVT", "VVJ", "W", "hww_gg125", "hww_qq125"]
			all_mc_bkgs_no_W = ["ZTT", "ZL", "ZJ", "ZLL", "EWKZ", "TT", "TTT", "TTJJ", "VV", "VVT", "VVJ", "hww_gg125", "hww_qq125"]
			all_mc_bkgs_no_TTJ = ["ZTT", "ZL", "ZJ", "ZLL", "EWKZ", "TT", "TTT", "VV", "VVT", "VVJ", "W", "hww_gg125", "hww_qq125"]
			
			# Lists of categories
			CP_categories = ["Vbf3D", "Vbf3D_CP", "Vbf3D_CP_jdeta", "Vbf3D_mela_GGH_DCPPlus", "Vbf3D_mela_GGH_DCPMinus", "Vbf4D_mela_GGH", "dijet_lowMjj", "dijet_lowM", "dijet_boosted", "dijet_highM"]
			sm_categories = ["ZeroJet2D", "Boosted2D", "Vbf2D"]
			##Generate instance of systematic libary, in which the relevant information about the systematics are safed

			systematics_list = SystLib.SystematicLibary()	

			# list of JEC uncertainties
			jecUncertNames = [
				"AbsoluteFlavMap",
				"AbsoluteMPFBias",
				"AbsoluteScale",
				"AbsoluteStat",
				"FlavorQCD",
				"Fragmentation",
				"PileUpDataMC",
				"PileUpPtBB",
				"PileUpPtEC1",
				"PileUpPtEC2",
				"PileUpPtHF",
				"PileUpPtRef",
				"RelativeBal",
				"RelativeFSR",
				"RelativeJEREC1",
				"RelativeJEREC2",
				"RelativeJERHF",
				"RelativePtBB",
				"RelativePtEC1",
				"RelativePtEC2",
				"RelativePtHF",
				"RelativeStatEC",
				"RelativeStatFSR",
				"RelativeStatHF",
				"SinglePionECAL",
				"SinglePionHCAL",
				"TimePtEta"
			]

			# ======================================================================
			# MT channel
			self.add_processes(
					channel="mt",
					categories=Categories.CategoriesDict().getCategories(["mt"])["mt"],
					bkg_processes=background_processes_mt,
					sig_processes=signal_processes,
					analysis=["htt"],
					era=["13TeV"],
					mass=higgs_masses
			)

			# efficiencies
			if year == "2016":
				self.cb.cp().channel(["mt"]).process(signal_processes+all_mc_bkgs_no_W).AddSyst(self.cb, *systematics_list.trigger_efficiency2016_syst_args)
				self.cb.cp().channel(["mt"]).process(signal_processes+all_mc_bkgs_no_W).AddSyst(self.cb, *systematics_list.muon_efficiency2016_syst_args)
				self.cb.cp().channel(["mt"]).process(signal_processes+all_mc_bkgs).AddSyst(self.cb, *systematics_list.tau_efficiency2016_syst_args)
			else:
				self.cb.cp().channel(["mt"]).process(signal_processes+all_mc_bkgs_no_W).AddSyst(self.cb, *systematics_list.muon_efficiency_syst_args)
				self.cb.cp().channel(["mt"]).process(signal_processes+["ZTT", "TTT", "VVT"]).AddSyst(self.cb, *systematics_list.tau_efficiency_syst_args)

			# mu->tau fake ES
			self.cb.cp().channel(["mt"]).process(["ZL"]).AddSyst(self.cb, *systematics_list.zl_shape_1prong_syst_args)
			self.cb.cp().channel(["mt"]).process(["ZL"]).AddSyst(self.cb, *systematics_list.zl_shape_1prong1pizero_syst_args)

			# mu->tau fake rate
			if year == "2016":
				self.cb.cp().channel(["mt"]).process(["ZL"]).bin(["mt_"+category for category in sm_categories+CP_categories]).AddSyst(self.cb, *systematics_list.mFakeTau_1prong_syst_args)
				self.cb.cp().channel(["mt"]).process(["ZL"]).bin(["mt_"+category for category in sm_categories+CP_categories]).AddSyst(self.cb, *systematics_list.mFakeTau_1prong1pizero_syst_args)
			else:
				self.cb.cp().channel(["mt"]).process(["ZL"]).AddSyst(self.cb, *systematics_list.muFakeTau_syst_args)

			# decay mode reweighting
			self.cb.cp().channel(["mt"]).process(["ZTT"]).bin(["mt_ZeroJet2D"]).AddSyst(self.cb, "CMS_tauDMReco_1prong_13TeV", "shape", ch.SystMap()(1.0))
			self.cb.cp().channel(["mt"]).process(["ZTT"]).bin(["mt_ZeroJet2D"]).AddSyst(self.cb, "CMS_tauDMReco_1prong1pizero_13TeV", "shape", ch.SystMap()(1.0))
			self.cb.cp().channel(["mt"]).process(["ZTT"]).bin(["mt_ZeroJet2D"]).AddSyst(self.cb, "CMS_tauDMReco_3prong_13TeV", "shape", ch.SystMap()(1.0))

			# ======================================================================
			# ET channel
			self.add_processes(
					channel="et",
					categories=Categories.CategoriesDict().getCategories(["et"])["et"],
					bkg_processes=background_processes_et,
					sig_processes=signal_processes,
					analysis=["htt"],
					era=["13TeV"],
					mass=higgs_masses
			)

			# efficiencies
			if year == "2016":
				self.cb.cp().channel(["et"]).process(signal_processes+all_mc_bkgs_no_W).AddSyst(self.cb, *systematics_list.trigger_efficiency2016_syst_args)
				self.cb.cp().channel(["et"]).process(signal_processes+all_mc_bkgs_no_W).AddSyst(self.cb, *systematics_list.electron_efficiency2016_syst_args)
				self.cb.cp().channel(["et"]).process(signal_processes+all_mc_bkgs).AddSyst(self.cb, *systematics_list.tau_efficiency2016_syst_args)
			else:
				self.cb.cp().channel(["et"]).process(signal_processes+all_mc_bkgs_no_W).AddSyst(self.cb, *systematics_list.electron_efficiency_syst_args)
				self.cb.cp().channel(["et"]).process(signal_processes+["ZTT", "TTT", "VVT"]).AddSyst(self.cb, *systematics_list.tau_efficiency_syst_args)

			# e->tau fake ES
			self.cb.cp().channel(["et"]).process(["ZL"]).AddSyst(self.cb, *systematics_list.zl_shape_1prong_syst_args)
			self.cb.cp().channel(["et"]).process(["ZL"]).AddSyst(self.cb, *systematics_list.zl_shape_1prong1pizero_syst_args)

			# e->tau fake rate
			if year == "2016":
				self.cb.cp().channel(["et"]).process(["ZL"]).bin(["et_"+category for category in sm_categories+CP_categories]).AddSyst(self.cb, *systematics_list.eFakeTau_1prong_syst_args)
				self.cb.cp().channel(["et"]).process(["ZL"]).bin(["et_"+category for category in sm_categories+CP_categories]).AddSyst(self.cb, *systematics_list.eFakeTau_1prong1pizero_syst_args)
			else:
				self.cb.cp().channel(["et"]).process(["ZL"]).AddSyst(self.cb, *systematics_list.eFakeTau_tight_syst_args)

			# decay mode reweighting
			self.cb.cp().channel(["et"]).process(["ZTT"]).bin(["et_ZeroJet2D"]).AddSyst(self.cb, "CMS_tauDMReco_1prong_13TeV", "shape", ch.SystMap()(1.0))
			self.cb.cp().channel(["et"]).process(["ZTT"]).bin(["et_ZeroJet2D"]).AddSyst(self.cb, "CMS_tauDMReco_1prong1pizero_13TeV", "shape", ch.SystMap()(1.0))
			self.cb.cp().channel(["et"]).process(["ZTT"]).bin(["et_ZeroJet2D"]).AddSyst(self.cb, "CMS_tauDMReco_3prong_13TeV", "shape", ch.SystMap()(1.0))

			# ======================================================================
			# EM channel
			self.add_processes(
					channel="em",
					categories=Categories.CategoriesDict().getCategories(["em"])["em"],
					bkg_processes=background_processes_em,
					sig_processes=signal_processes,
					analysis=["htt"],
					era=["13TeV"],
					mass=higgs_masses
			)

			# efficiencies
			if year == "2016":
				self.cb.cp().channel(["em"]).process(signal_processes+all_mc_bkgs).AddSyst(self.cb, *systematics_list.trigger_efficiency2016_em_syst_args)
				self.cb.cp().channel(["em"]).process(signal_processes+all_mc_bkgs).AddSyst(self.cb, *systematics_list.electron_efficiency2016_syst_args)
				self.cb.cp().channel(["em"]).process(signal_processes+all_mc_bkgs).AddSyst(self.cb, *systematics_list.muon_efficiency2016_syst_args)
			else:
				self.cb.cp().channel(["em"]).process(signal_processes+all_mc_bkgs).AddSyst(self.cb, *systematics_list.electron_efficiency_syst_args)
				self.cb.cp().channel(["em"]).process(signal_processes+all_mc_bkgs).AddSyst(self.cb, *systematics_list.muon_efficiency_syst_args)

			# B-Tag
			if year == "2016":
				self.cb.cp().channel(["em"]).process(["TT", "VV"]).bin(["em_"+category for category in sm_categories+CP_categories]).AddSyst(self.cb, *systematics_list.btag_efficiency2016_syst_args)

			# electron ES
			self.cb.cp().channel(["em"]).process(signal_processes+all_mc_bkgs+["QCD"]).AddSyst(self.cb, *systematics_list.ele_es_syst_args)

			# ======================================================================
			# TT channel
			self.add_processes(
					channel="tt",
					categories=Categories.CategoriesDict().getCategories(["tt"])["tt"],
					bkg_processes=background_processes_tt,
					sig_processes=signal_processes,
					analysis=["htt"],
					era=["13TeV"],
					mass=higgs_masses
			)


			# efficiencies
			if year == "2016":
				self.cb.cp().channel(["tt"]).process(signal_processes+all_mc_bkgs).AddSyst(self.cb, *systematics_list.trigger_efficiency2016_syst_args)
				self.cb.cp().channel(["tt"]).process(signal_processes+all_mc_bkgs).AddSyst(self.cb, *systematics_list.tau_efficiency2016_tt_syst_args)
			else:
				self.cb.cp().channel(["tt"]).process(signal_processes+["ZTT", "TTT", "VVT"]).AddSyst(self.cb, *systematics_list.tau_efficiency_syst_args)

			# ======================================================================
			# MM channel
			self.add_processes(
					channel="mm",
					categories=Categories.CategoriesDict().getCategories(["mm"])["mm"],
					bkg_processes=background_processes_mm,
					sig_processes=signal_processes,
					analysis=["htt"],
					era=["13TeV"],
					mass=higgs_masses
			)

			# efficiencies
			if year == "2016":
				self.cb.cp().channel(["mm"]).process(all_mc_bkgs).AddSyst(self.cb, *systematics_list.muon_efficiency2016_syst_args)
			else:
				self.cb.cp().channel(["mm"]).process(all_mc_bkgs).AddSyst(self.cb, *systematics_list.muon_efficiency_syst_args)

			# ======================================================================
			# ttbar "channel" to extract normalization of ttbar process
			self.add_processes(
					channel="ttbar",
					categories=Categories.CategoriesDict().getCategories(["ttbar"])["ttbar"],
					bkg_processes=background_processes_ttbar,
					sig_processes=signal_processes,
					analysis=["htt"],
					era=["13TeV"],
					mass=higgs_masses
			)

			if year == "2016":
				self.cb.cp().channel(["ttbar"]).process(signal_processes+all_mc_bkgs).AddSyst(self.cb, *systematics_list.trigger_efficiency2016_em_syst_args)
				self.cb.cp().channel(["ttbar"]).process(signal_processes+all_mc_bkgs).AddSyst(self.cb, *systematics_list.electron_efficiency2016_syst_args)
				self.cb.cp().channel(["ttbar"]).process(signal_processes+all_mc_bkgs).AddSyst(self.cb, *systematics_list.muon_efficiency2016_syst_args)

			self.cb.cp().channel(["ttbar"]).bin(["ttbar_TTbarCR"]).process(all_mc_bkgs).AddSyst(self.cb, "CMS_htt_scale_met_13TeV", "lnN", ch.SystMap()(1.01))

			# ======================================================================
			# All channels

			# ======================================================================
			# lumi
			if year == "2016":
				self.cb.cp().process(signal_processes+["VV", "VVT", "VVJ", "hww_gg125", "hww_qq125"]).AddSyst(self.cb, *systematics_list.lumi2016_syst_args)
				if not ttbarFit:
					self.cb.cp().process(["TT", "TTT", "TTJJ"]).AddSyst(self.cb, *systematics_list.lumi2016_syst_args)
				if mmFit:
					self.cb.cp().channel(["mt", "et", "tt", "em", "ttbar"]).process(["ZL", "ZJ", "ZLL"]).AddSyst(self.cb, *systematics_list.lumi2016_syst_args)
					self.cb.cp().channel(["mt", "et"]).process(["ZTT"]).bin([channel + "_" + category + "_" + cr for channel in ["mt", "et"] for category in ["ZeroJet2D", "Boosted2D"] for cr in ["WJCR", "QCDCR"]]).AddSyst(self.cb, *systematics_list.lumi2016_syst_args)
					self.cb.cp().channel(["tt"]).process(["ZTT"]).bin(["tt_" + category + "_QCDCR" for category in sm_categories]).AddSyst(self.cb, *systematics_list.lumi2016_syst_args)
					self.cb.cp().channel(["ttbar"]).process(["ZTT"]).bin(["ttbar_TTbarCR"]).AddSyst(self.cb, *systematics_list.lumi2016_syst_args)
					self.cb.cp().channel(["mm"]).process(["ZTT"]).AddSyst(self.cb, *systematics_list.lumi2016_syst_args)
				self.cb.cp().process(["W"]).channel(["em", "tt", "mm", "ttbar"]).AddSyst(self.cb, *systematics_list.lumi2016_syst_args)
			else:
				self.cb.cp().process(signal_processes+all_mc_bkgs_no_W).AddSyst(self.cb, *systematics_list.lumi_syst_args)
				self.cb.cp().process(["W"]).channel(["em", "tt", "mm"]).AddSyst(self.cb, *systematics_list.lumi_syst_args)

			# ======================================================================
			# cross section
			if mmFit:
				self.cb.cp().channel(["mt", "et", "tt", "em", "ttbar"]).process(["ZL", "ZJ", "ZLL"]).AddSyst(self.cb, *systematics_list.ztt_cross_section_syst_args)
				# add uncertainty for ZTT only in control regions
				self.cb.cp().channel(["mt", "et"]).process(["ZTT"]).bin([channel + "_" + category + "_" + cr for channel in ["mt", "et"] for category in ["ZeroJet2D", "Boosted2D"] for cr in ["WJCR", "QCDCR"]]).AddSyst(self.cb, *systematics_list.ztt_cross_section_syst_args)
				self.cb.cp().channel(["tt"]).process(["ZTT"]).bin(["tt_" + category + "_QCDCR" for category in ["ZeroJet2D", "Boosted2D", "Vbf2D"]]).AddSyst(self.cb, *systematics_list.ztt_cross_section_syst_args)
				self.cb.cp().channel(["ttbar"]).process(["ZTT"]).bin(["ttbar_TTbarCR"]).AddSyst(self.cb, *systematics_list.ztt_cross_section_syst_args)
			else:
				self.cb.cp().channel(["em"]).process(["ZTT", "ZLL", "EWKZ"]).bin(["em_ZeroJet2D"]).AddSyst(self.cb, "CMS_htt_zmm_norm_extrap_0jet_em_13TeV", "lnN", ch.SystMap()(1.07))
				self.cb.cp().channel(["tt"]).process(["ZTT", "ZL", "ZJ", "EWKZ"]).bin(["tt_ZeroJet2D", "tt_ZeroJet2D_QCDCR"]).AddSyst(self.cb, "CMS_htt_zmm_norm_extrap_0jet_tt_13TeV", "lnN", ch.SystMap()(1.07))
				self.cb.cp().channel(["mt", "et"]).process(["ZTT", "ZL", "ZJ", "EWKZ"]).bin(["mt_ZeroJet2D", "mt_ZeroJet2D_WJCR", "mt_ZeroJet2D_QCDCR", "et_ZeroJet2D", "et_ZeroJet2D_WJCR", "et_ZeroJet2D_QCDCR"]).AddSyst(self.cb, "CMS_htt_zmm_norm_extrap_0jet_lt_13TeV", "lnN", ch.SystMap()(1.07))

				self.cb.cp().channel(["em"]).process(["ZTT", "ZLL", "EWKZ"]).bin(["em_Boosted2D"]).AddSyst(self.cb, "CMS_htt_zmm_norm_extrap_boosted_em_13TeV", "lnN", ch.SystMap()(1.07))
				self.cb.cp().channel(["tt"]).process(["ZTT", "ZL", "ZJ", "EWKZ"]).bin(["tt_Boosted2D", "tt_Boosted2D_QCDCR"]).AddSyst(self.cb, "CMS_htt_zmm_norm_extrap_boosted_tt_13TeV", "lnN", ch.SystMap()(1.07))
				self.cb.cp().channel(["mt", "et"]).process(["ZTT", "ZL", "ZJ", "EWKZ"]).bin(["mt_Boosted2D", "mt_Boosted2D_WJCR", "mt_Boosted2D_QCDCR", "et_Boosted2D", "et_Boosted2D_WJCR", "et_Boosted2D_QCDCR"]).AddSyst(self.cb, "CMS_htt_zmm_norm_extrap_boosted_lt_13TeV", "lnN", ch.SystMap()(1.07))

				self.cb.cp().channel(["em"]).process(["ZTT", "ZLL", "EWKZ"]).bin(["em_Vbf2D"]+["em_"+category for category in CP_categories]).AddSyst(self.cb, "CMS_htt_zmm_norm_extrap_VBF_em_13TeV", "lnN", ch.SystMap()(1.15))
				self.cb.cp().channel(["tt"]).process(["ZTT", "ZL", "ZJ", "EWKZ"]).bin(["tt_Vbf2D", "tt_Vbf2D_QCDCR"]+["tt_"+category for category in CP_categories]).AddSyst(self.cb, "CMS_htt_zmm_norm_extrap_VBF_tt_13TeV", "lnN", ch.SystMap()(1.15))
				self.cb.cp().channel(["mt", "et"]).process(["ZTT", "ZL", "ZJ", "EWKZ"]).bin(["et_Vbf2D"]+["et_"+category for category in CP_categories]+["mt_Vbf2D"]+["mt_"+category for category in CP_categories]).AddSyst(self.cb, "CMS_htt_zmm_norm_extrap_VBF_lt_13TeV", "lnN", ch.SystMap()(1.10))

				self.cb.cp().channel(["mt", "et", "tt"]).process(["ZTT", "ZL", "ZJ", "EWKZ"]).bin([channel + "_Vbf2D" for channel in ["mt", "et", "tt"]]).AddSyst(self.cb, "CMS_htt_zmumuShape_VBF_13TeV", "shape", ch.SystMap()(1.0))
				self.cb.cp().channel(["tt"]).process(["ZTT", "ZL", "ZJ", "EWKZ"]).bin(["tt_Vbf2D_QCDCR"]).AddSyst(self.cb, "CMS_htt_zmumuShape_VBF_13TeV", "shape", ch.SystMap()(1.0))
				self.cb.cp().channel(["em"]).process(["ZTT", "ZLL"]).bin(["em_Vbf2D"]+["em_"+category for category in CP_categories]).AddSyst(self.cb, "CMS_htt_zmumuShape_VBF_13TeV", "shape", ch.SystMap()(1.0))
			if not ttbarFit:
				self.cb.cp().process(["TT", "TTT", "TTJJ"]).channel(["mt", "et", "em", "tt"]).AddSyst(self.cb, *systematics_list.ttj_cross_section_syst_args)
			if year == "2016":
				self.cb.cp().process(["VV", "VVT", "VVJ"]).AddSyst(self.cb, *systematics_list.vv_cross_section2016_syst_args)
			else:
				self.cb.cp().process(["VV", "VVT", "VVJ"]).AddSyst(self.cb, *systematics_list.vv_cross_section_syst_args)
			self.cb.cp().process(["W"]).channel(["em"]).AddSyst(self.cb, *systematics_list.htt_jetFakeLep_syst_args)
			self.cb.cp().process(["W"]).channel(["tt", "mm"]).AddSyst(self.cb, *systematics_list.wj_cross_section_syst_args)

			# ======================================================================
			# tau id efficiency
			if year == "2016":
				self.cb.cp().channel(["mt", "et"]).process(signal_processes+all_mc_bkgs).AddSyst(self.cb, *systematics_list.tau_efficiency2016_corr_syst_args)
				self.cb.cp().channel(["tt"]).process(signal_processes+all_mc_bkgs).AddSyst(self.cb, *systematics_list.tau_efficiency2016_tt_corr_syst_args)
			else:
				self.cb.cp().channel(["mt", "et", "tt"]).process(signal_processes+["ZTT", "TTT", "VVT"]).AddSyst(self.cb, *systematics_list.tau_efficiency_corr_syst_args)

			# ======================================================================
			# energy scales

			# tau ES
			self.cb.cp().channel(["mt", "et", "tt"]).process(signal_processes+all_mc_bkgs).AddSyst(self.cb, *systematics_list.scale_t_1prong_syst_args)
			self.cb.cp().channel(["mt", "et", "tt"]).process(signal_processes+all_mc_bkgs).AddSyst(self.cb, *systematics_list.scale_t_3prong_syst_args)
			self.cb.cp().channel(["mt", "et", "tt"]).process(signal_processes+all_mc_bkgs).AddSyst(self.cb, *systematics_list.scale_t_1prong1pizero_syst_args)

			# jet ES
			# TODO: use mix of lnN/shape systematics as done in official analysis?
			if noJECuncSplit:
				self.cb.cp().process(signal_processes+all_mc_bkgs+["QCD"]).bin([channel+"_"+category for channel in ["et", "mt", "tt", "em"] for category in sm_categories+CP_categories]).AddSyst(self.cb, "CMS_scale_j_Total_13TeV", "shape", ch.SystMap()(1.0))
				self.cb.cp().channel(["mt"]).process(signal_processes+all_mc_bkgs).bin(["mt_ZeroJet2D_WJCR", "mt_Boosted2D_WJCR", "mt_ZeroJet2D_QCDCR", "mt_Boosted2D_QCDCR"]).AddSyst(self.cb, "CMS_scale_j_Total_13TeV", "shape", ch.SystMap()(1.0))
				self.cb.cp().channel(["et"]).process(signal_processes+all_mc_bkgs).bin(["et_ZeroJet2D_WJCR", "et_Boosted2D_WJCR", "et_Boosted2D_QCDCR"]).AddSyst(self.cb, "CMS_scale_j_Total_13TeV", "shape", ch.SystMap()(1.0))
				self.cb.cp().channel(["et"]).process(signal_processes+all_mc_bkgs_no_TTJ).bin(["et_ZeroJet2D_QCDCR"]).AddSyst(self.cb, "CMS_scale_j_Total_13TeV", "shape", ch.SystMap()(1.0))
				self.cb.cp().channel(["tt"]).process(signal_processes+all_mc_bkgs).bin(["tt_ZeroJet2D_QCDCR", "tt_Boosted2D_QCDCR", "tt_Vbf2D_QCDCR"]).AddSyst(self.cb, "CMS_scale_j_Total_13TeV", "shape", ch.SystMap()(1.0))
			else:
				for jecUncert in jecUncertNames:
					self.cb.cp().process(signal_processes+all_mc_bkgs+["QCD"]).bin([channel+"_"+category for channel in ["et", "mt", "tt", "em"] for category in sm_categories+CP_categories]).AddSyst(self.cb, "CMS_scale_j_"+jecUncert+"_13TeV", "shape", ch.SystMap()(1.0))
					self.cb.cp().channel(["mt"]).process(signal_processes+all_mc_bkgs).bin(["mt_ZeroJet2D_WJCR", "mt_Boosted2D_WJCR", "mt_ZeroJet2D_QCDCR", "mt_Boosted2D_QCDCR"]).AddSyst(self.cb, "CMS_scale_j_"+jecUncert+"_13TeV", "shape", ch.SystMap()(1.0))
					self.cb.cp().channel(["et"]).process(signal_processes+all_mc_bkgs).bin(["et_ZeroJet2D_WJCR", "et_Boosted2D_WJCR", "et_Boosted2D_QCDCR"]).AddSyst(self.cb, "CMS_scale_j_"+jecUncert+"_13TeV", "shape", ch.SystMap()(1.0))
					self.cb.cp().channel(["et"]).process(signal_processes+all_mc_bkgs_no_TTJ).bin(["et_ZeroJet2D_QCDCR"]).AddSyst(self.cb, "CMS_scale_j_"+jecUncert+"_13TeV", "shape", ch.SystMap()(1.0))
					self.cb.cp().channel(["tt"]).process(signal_processes+all_mc_bkgs).bin(["tt_ZeroJet2D_QCDCR", "tt_Boosted2D_QCDCR", "tt_Vbf2D_QCDCR"]).AddSyst(self.cb, "CMS_scale_j_"+jecUncert+"_13TeV", "shape", ch.SystMap()(1.0))

			# jet->tau fake ES
			if year == "2016":
				self.cb.cp().channel(["et", "mt", "tt"]).process(["ZJ", "TTJJ", "VVJ"]).AddSyst(self.cb, "CMS_htt_jetToTauFake_13TeV", "shape", ch.SystMap()(1.0))
				self.cb.cp().channel(["et", "mt", "tt"]).process(["W"]).bin([channel+"_"+category for channel in ["et", "mt", "tt"] for category in sm_categories+CP_categories]).AddSyst(self.cb, "CMS_htt_jetToTauFake_13TeV", "shape", ch.SystMap()(1.0))
				self.cb.cp().channel(["et", "mt"]).process(["W"]).bin([channel+"_"+category for channel in ["et", "mt"] for category in ["ZeroJet2D_QCDCR", "Boosted2D_QCDCR"]]).AddSyst(self.cb, "CMS_htt_jetToTauFake_13TeV", "shape", ch.SystMap()(1.0))
			else:
				self.cb.cp().channel(["et", "mt", "tt"]).process(["ZJ", "W", "TTJJ", "VVJ"]).AddSyst(self.cb, *systematics_list.jetFakeTau_syst_args)

			# MET ES
			self.cb.cp().channel(["et", "mt", "tt", "em"]).process(signal_processes+all_mc_bkgs).bin([channel+"_"+category for channel in ["et", "mt", "tt", "em"] for category in sm_categories+CP_categories]).AddSyst(self.cb, "CMS_scale_met_clustered_13TeV", "shape", ch.SystMap()(1.0))
			self.cb.cp().channel(["et", "mt", "tt", "em"]).process(signal_processes+all_mc_bkgs).bin([channel+"_"+category for channel in ["et", "mt", "tt", "em"] for category in sm_categories+CP_categories]).AddSyst(self.cb, "CMS_scale_met_unclustered_13TeV", "shape", ch.SystMap()(1.0))
			self.cb.cp().channel(["et", "mt"]).process(all_mc_bkgs).bin([channel+"_"+category for channel in ["et", "mt"] for category in ["ZeroJet2D_WJCR", "ZeroJet2D_QCDCR", "Boosted2D_WJCR", "Boosted2D_QCDCR"]]).AddSyst(self.cb, "CMS_scale_met_clustered_13TeV", "shape", ch.SystMap()(1.0))
			self.cb.cp().channel(["et", "mt"]).process(all_mc_bkgs).bin([channel+"_"+category for channel in ["et", "mt"] for category in ["ZeroJet2D_WJCR", "ZeroJet2D_QCDCR", "Boosted2D_WJCR", "Boosted2D_QCDCR"]]).AddSyst(self.cb, "CMS_scale_met_unclustered_13TeV", "shape", ch.SystMap()(1.0))

			# ======================================================================
			# W+jets and QCD estimation uncertainties

			# QCD normalization
			self.cb.cp().channel(["em"]).process(["QCD"]).bin(["em_ZeroJet2D"]).AddSyst(self.cb, *systematics_list.htt_QCD_0jet_syst_args)
			self.cb.cp().channel(["em"]).process(["QCD"]).bin(["em_Boosted2D"]).AddSyst(self.cb, *systematics_list.htt_QCD_boosted_syst_args)
			self.cb.cp().channel(["em"]).process(["QCD"]).bin(["em_Vbf2D"]+["em_"+category for category in CP_categories]).AddSyst(self.cb, "CMS_htt_QCD_VBF_em_13TeV", "lnN", ch.SystMap()(1.20))

			self.cb.cp().channel(["tt"]).process(["QCD"]).bin(["tt_ZeroJet2D"]).AddSyst(self.cb, "CMS_htt_QCD_0jet_tt_13TeV", "lnN", ch.SystMap()(1.027))
			self.cb.cp().channel(["tt"]).process(["QCD"]).bin(["tt_Boosted2D"]).AddSyst(self.cb, "CMS_htt_QCD_boosted_tt_13TeV", "lnN", ch.SystMap()(1.027))
			self.cb.cp().channel(["tt"]).process(["QCD"]).bin(["tt_Vbf2D"]+["tt_"+category for category in CP_categories]).AddSyst(self.cb, "CMS_htt_QCD_VBF_tt_13TeV", "lnN", ch.SystMap()(1.15))

			self.cb.cp().channel(["mt"]).process(["QCD"]).bin(["mt_"+category for category in sm_categories+CP_categories]).AddSyst(self.cb, *systematics_list.QCD_Extrap_Iso_nonIso_syst_args)
			self.cb.cp().channel(["et"]).process(["QCD"]).bin(["et_"+category for category in sm_categories+CP_categories]).AddSyst(self.cb, *systematics_list.QCD_Extrap_Iso_nonIso_syst_args)

			self.cb.cp().channel(["et", "mt"]).process(["QCD"]).bin([channel+"_ZeroJet2D" for channel in ["et", "mt"]]).AddSyst(self.cb, *systematics_list.WSFUncert_0jet_syst_args)			
			self.cb.cp().channel(["et", "mt"]).process(["QCD"]).bin([channel+"_Boosted2D" for channel in ["et", "mt"]]).AddSyst(self.cb, *systematics_list.WSFUncert_boosted_syst_args)
			self.cb.cp().channel(["et", "mt"]).process(["QCD"]).bin([channel+"_Vbf2D" for channel in ["et", "mt"]]).AddSyst(self.cb, *systematics_list.WSFUncert_Vbf_syst_args)
			self.cb.cp().channel(["et", "mt"]).process(["QCD"]).bin([channel+"_dijet_boosted" for channel in ["et", "mt"]]).AddSyst(self.cb, "WSFUncert_$CHANNEL_dijet_boosted_13TeV", "shape", ch.SystMap()(1.0))
			self.cb.cp().channel(["et", "mt"]).process(["QCD"]).bin([channel+"_dijet_lowM" for channel in ["et", "mt"]]).AddSyst(self.cb, "WSFUncert_$CHANNEL_dijet_lowM_13TeV", "shape", ch.SystMap()(1.0))
			self.cb.cp().channel(["et", "mt"]).process(["QCD"]).bin([channel+"_dijet_highM" for channel in ["et", "mt"]]).AddSyst(self.cb, "WSFUncert_$CHANNEL_dijet_highM_13TeV", "shape", ch.SystMap()(1.0))
			self.cb.cp().channel(["et", "mt"]).process(["QCD"]).bin([channel+"_dijet_lowMjj" for channel in ["et", "mt"]]).AddSyst(self.cb, "WSFUncert_$CHANNEL_dijet_lowMjj_13TeV", "shape", ch.SystMap()(1.0))
			# W+jets high->low mt extrapolation uncertainty
			self.cb.cp().channel(["et", "mt"]).process(["W"]).bin([channel+"_ZeroJet2D" for channel in ["et", "mt"]]).AddSyst(self.cb, *systematics_list.WHighMTtoLowMT_0jet_syst_args)
			self.cb.cp().channel(["et", "mt"]).process(["W"]).bin([channel+"_Boosted2D" for channel in ["et", "mt"]]).AddSyst(self.cb, *systematics_list.WHighMTtoLowMT_boosted_syst_args)
			self.cb.cp().channel(["et", "mt"]).process(["W"]).bin([channel+"_Vbf2D" for channel in ["et", "mt"]]).AddSyst(self.cb, "WHighMTtoLowMT_vbf_13TeV", "lnN", ch.SystMap()(1.10))
			self.cb.cp().channel(["et", "mt"]).process(["W"]).bin([channel+category for category in CP_categories for channel in ["et", "mt"]]).AddSyst(self.cb, "WHighMTtoLowMT_vbf_13TeV", "lnN", ch.SystMap()(1.10))

			# ======================================================================
			# pt reweighting uncertainties

			# ttbar shape
			self.cb.cp().channel(["et", "mt", "em", "tt"]).process(["TTT", "TTJJ"]).AddSyst(self.cb, *systematics_list.ttj_syst_args)
			self.cb.cp().channel(["em"]).process(["TT"]).AddSyst(self.cb, *systematics_list.ttj_syst_args)

			# dy shape
			self.cb.cp().channel(["et", "mt", "tt"]).process(["ZTT", "ZL", "ZJ"]).AddSyst(self.cb, *systematics_list.dy_shape_syst_args)
			self.cb.cp().channel(["em"]).process(["ZTT", "ZLL"]).AddSyst(self.cb, *systematics_list.dy_shape_syst_args)

			# ======================================================================
			# Theory uncertainties
			self.cb.cp().channel(["mt", "et", "tt", "em"]).process(["ggH", "ggHsm", "ggHps", "ggHmm"]).bin([channel+"_"+category for channel in ["et", "mt", "em", "tt"] for category in sm_categories+CP_categories]).AddSyst(self.cb, "CMS_scale_gg_13TeV", "shape", ch.SystMap()(1.0))
			self.cb.cp().process(["qqH", "qqHsm", "qqHps", "qqHmm"]).AddSyst(self.cb, *systematics_list.htt_qcd_scale_qqh_syst_args)
			self.cb.cp().process(["ggH", "ggHsm", "ggHps", "ggHmm", "qqH", "qqHsm", "qqHps", "qqHmm"]).AddSyst(self.cb, *systematics_list.htt_pdf_scale_smhtt_syst_args)
			self.cb.cp().process(["ggH", "ggHsm", "ggHps", "ggHmm", "qqH", "qqHsm", "qqHps", "qqHmm"]).AddSyst(self.cb, *systematics_list.htt_ueps_smhtt_syst_args)

			# Uncertainty on BR of HTT @ 125 GeV
			self.cb.cp().signals().AddSyst(self.cb, "BR_htt_THU", "lnN", ch.SystMap()(1.017))
			self.cb.cp().signals().AddSyst(self.cb, "BR_htt_PU_mq", "lnN", ch.SystMap()(1.0099))
			self.cb.cp().signals().AddSyst(self.cb, "BR_htt_PU_alphas", "lnN", ch.SystMap()(1.0062))

			# Uncertainty on BR of HWW @ 125 GeV
			self.cb.cp().process(["hww_gg125", "hww_qq125"]).AddSyst(self.cb, "BR_hww_THU", "lnN", ch.SystMap()(1.0099))
			self.cb.cp().process(["hww_gg125", "hww_qq125"]).AddSyst(self.cb, "BR_hww_PU_mq", "lnN", ch.SystMap()(1.0099))
			self.cb.cp().process(["hww_gg125", "hww_qq125"]).AddSyst(self.cb, "BR_hww_PU_alphas", "lnN", ch.SystMap()(1.0066))

			self.cb.cp().process(["ggH", "ggHsm", "ggHps", "ggHmm", "hww_gg125"]).AddSyst(self.cb, "QCDScale_ggH", "lnN", ch.SystMap()(1.039))
			self.cb.cp().process(["qqH", "qqHsm", "qqHps", "qqHmm", "hww_qq125"]).AddSyst(self.cb, "QCDScale_qqH", "lnN", ch.SystMap()(1.004))
			self.cb.cp().process(["WH"]).AddSyst(self.cb, "QCDScale_VH", "lnN", ch.SystMap()(1.007))
			self.cb.cp().process(["ZH"]).AddSyst(self.cb, "QCDScale_VH", "lnN", ch.SystMap()(1.038))

			self.cb.cp().process(["ggH", "ggHsm", "ggHps", "ggHmm", "hww_gg125"]).AddSyst(self.cb, "pdf_Higgs_gg", "lnN", ch.SystMap()(1.032))
			self.cb.cp().process(["qqH", "qqHsm", "qqHps", "qqHmm", "hww_qq125"]).AddSyst(self.cb, "pdf_Higgs_qq", "lnN", ch.SystMap()(1.021))
			self.cb.cp().process(["WH"]).AddSyst(self.cb, "pdf_Higgs_VH", "lnN", ch.SystMap()(1.019))
			self.cb.cp().process(["ZH"]).AddSyst(self.cb, "pdf_Higgs_VH", "lnN", ch.SystMap()(1.016))

			# ======================================================================
			# ttbar rate parameters
			if ttbarFit:
				self.cb.cp().process(["TTT", "TTJJ"]).bin(["mt_ZeroJet2D"]).AddSyst(self.cb, "rate_ttbar", "rateParam", ch.SystMap()(1.0))
				self.cb.cp().process(["TTT", "TTJJ"]).bin(["et_ZeroJet2D"]).AddSyst(self.cb, "rate_ttbar", "rateParam", ch.SystMap()(1.0))
				self.cb.cp().process(["TTT", "TTJJ"]).bin(["tt_ZeroJet2D"]).AddSyst(self.cb, "rate_ttbar", "rateParam", ch.SystMap()(1.0))
				self.cb.cp().process(["TT"]).bin(["em_ZeroJet2D"]).AddSyst(self.cb, "rate_ttbar", "rateParam", ch.SystMap()(1.0))

				self.cb.cp().process(["TTT", "TTJJ"]).bin(["mt_Boosted2D"]).AddSyst(self.cb, "rate_ttbar", "rateParam", ch.SystMap()(1.0))
				self.cb.cp().process(["TTT", "TTJJ"]).bin(["et_Boosted2D"]).AddSyst(self.cb, "rate_ttbar", "rateParam", ch.SystMap()(1.0))
				self.cb.cp().process(["TTT", "TTJJ"]).bin(["tt_Boosted2D"]).AddSyst(self.cb, "rate_ttbar", "rateParam", ch.SystMap()(1.0))
				self.cb.cp().process(["TT"]).bin(["em_Boosted2D"]).AddSyst(self.cb, "rate_ttbar", "rateParam", ch.SystMap()(1.0))

				self.cb.cp().process(["TTT", "TTJJ"]).bin(["mt_Vbf2D", "mt_Vbf3D"]).AddSyst(self.cb, "rate_ttbar", "rateParam", ch.SystMap()(1.0))
				self.cb.cp().process(["TTT", "TTJJ"]).bin(["et_Vbf2D", "et_Vbf3D"]).AddSyst(self.cb, "rate_ttbar", "rateParam", ch.SystMap()(1.0))
				self.cb.cp().process(["TTT", "TTJJ"]).bin(["tt_Vbf2D", "tt_Vbf3D"]).AddSyst(self.cb, "rate_ttbar", "rateParam", ch.SystMap()(1.0))
				self.cb.cp().process(["TT"]).bin(["em_Vbf2D", "em_Vbf3D"]).AddSyst(self.cb, "rate_ttbar", "rateParam", ch.SystMap()(1.0))

				self.cb.cp().process(["TT"]).bin(["ttbar_TTbarCR"]).AddSyst(self.cb, "rate_ttbar", "rateParam", ch.SystMap()(1.0))

				self.cb.cp().GetParameter("rate_ttbar").set_range(0.8, 1.2)

			# ======================================================================
			# mm rate parameters
			if mmFit:
				self.cb.cp().process(["ZTT"]).bin(["mt_ZeroJet2D"]).AddSyst(self.cb, "rate_mm_ZTT_0jet", "rateParam", ch.SystMap()(1.0))
				self.cb.cp().process(["ZTT"]).bin(["et_ZeroJet2D"]).AddSyst(self.cb, "rate_mm_ZTT_0jet", "rateParam", ch.SystMap()(1.0))
				self.cb.cp().process(["ZTT"]).bin(["tt_ZeroJet2D"]).AddSyst(self.cb, "rate_mm_ZTT_0jet", "rateParam", ch.SystMap()(1.0))
				self.cb.cp().process(["ZTT"]).bin(["em_ZeroJet2D"]).AddSyst(self.cb, "rate_mm_ZTT_0jet", "rateParam", ch.SystMap()(1.0))
				self.cb.cp().process(["ZLL"]).bin(["mm_ZeroJet2D"]).AddSyst(self.cb, "rate_mm_ZTT_0jet", "rateParam", ch.SystMap()(1.0))

				self.cb.cp().process(["ZTT"]).bin(["mt_Boosted2D"]).AddSyst(self.cb, "rate_mm_ZTT_boosted", "rateParam", ch.SystMap()(1.0))
				self.cb.cp().process(["ZTT"]).bin(["et_Boosted2D"]).AddSyst(self.cb, "rate_mm_ZTT_boosted", "rateParam", ch.SystMap()(1.0))
				self.cb.cp().process(["ZTT"]).bin(["tt_Boosted2D"]).AddSyst(self.cb, "rate_mm_ZTT_boosted", "rateParam", ch.SystMap()(1.0))
				self.cb.cp().process(["ZTT"]).bin(["em_Boosted2D"]).AddSyst(self.cb, "rate_mm_ZTT_boosted", "rateParam", ch.SystMap()(1.0))
				self.cb.cp().process(["ZLL"]).bin(["mm_Boosted2D"]).AddSyst(self.cb, "rate_mm_ZTT_boosted", "rateParam", ch.SystMap()(1.0))

				self.cb.cp().process(["ZTT"]).bin(["mt_Vbf2D", "mt_Vbf3D"]).AddSyst(self.cb, "rate_mm_ZTT_vbf", "rateParam", ch.SystMap()(1.0))
				self.cb.cp().process(["ZTT"]).bin(["et_Vbf2D", "et_Vbf3D"]).AddSyst(self.cb, "rate_mm_ZTT_vbf", "rateParam", ch.SystMap()(1.0))
				self.cb.cp().process(["ZTT"]).bin(["tt_Vbf2D", "tt_Vbf3D"]).AddSyst(self.cb, "rate_mm_ZTT_vbf", "rateParam", ch.SystMap()(1.0))
				self.cb.cp().process(["ZTT"]).bin(["em_Vbf2D", "em_Vbf3D"]).AddSyst(self.cb, "rate_mm_ZTT_vbf", "rateParam", ch.SystMap()(1.0))
				self.cb.cp().process(["ZLL"]).bin(["mm_Vbf2D"]).AddSyst(self.cb, "rate_mm_ZTT_vbf", "rateParam", ch.SystMap()(1.0))

				self.cb.cp().GetParameter("rate_mm_ZTT_0jet").set_range(0.9, 1.1)
				self.cb.cp().GetParameter("rate_mm_ZTT_boosted").set_range(0.9, 1.1)
				self.cb.cp().GetParameter("rate_mm_ZTT_vbf").set_range(0.9, 1.1)

			# ======================================================================
			# control region rate parameters
			self.cb.cp().process(["W"]).bin(["mt_ZeroJet2D", "mt_ZeroJet2D_WJCR"]).AddSyst(self.cb, "rate_W_cr_0jet_mt", "rateParam", ch.SystMap()(1.0))
			self.cb.cp().process(["W"]).bin(["mt_Boosted2D", "mt_Boosted2D_WJCR", "mt_Vbf2D", "mt_Vbf3D"]).AddSyst(self.cb, "rate_W_cr_boosted_mt", "rateParam", ch.SystMap()(1.0))
			self.cb.cp().process(["W"]).bin(["et_ZeroJet2D", "et_ZeroJet2D_WJCR"]).AddSyst(self.cb, "rate_W_cr_0jet_et", "rateParam", ch.SystMap()(1.0))
			self.cb.cp().process(["W"]).bin(["et_Boosted2D", "et_Boosted2D_WJCR", "et_Vbf2D", "et_Vbf3D"]).AddSyst(self.cb, "rate_W_cr_boosted_et", "rateParam", ch.SystMap()(1.0))

			self.cb.cp().process(["QCD"]).bin(["mt_ZeroJet2D", "mt_ZeroJet2D_QCDCR"]).AddSyst(self.cb, "rate_QCD_cr_0jet_mt", "rateParam", ch.SystMap()(1.0))
			self.cb.cp().process(["QCD"]).bin(["mt_Boosted2D", "mt_Boosted2D_QCDCR", "mt_Vbf2D", "mt_Vbf3D"]).AddSyst(self.cb, "rate_QCD_cr_boosted_mt", "rateParam", ch.SystMap()(1.0))
			self.cb.cp().process(["QCD"]).bin(["et_ZeroJet2D", "et_ZeroJet2D_QCDCR"]).AddSyst(self.cb, "rate_QCD_cr_0jet_et", "rateParam", ch.SystMap()(1.0))
			self.cb.cp().process(["QCD"]).bin(["et_Boosted2D", "et_Boosted2D_QCDCR", "et_Vbf2D", "et_Vbf3D"]).AddSyst(self.cb, "rate_QCD_cr_boosted_et", "rateParam", ch.SystMap()(1.0))
			self.cb.cp().process(["QCD"]).bin(["tt_ZeroJet2D", "tt_ZeroJet2D_QCDCR"]).AddSyst(self.cb, "rate_QCD_cr_0jet_tt", "rateParam", ch.SystMap()(1.0))
			self.cb.cp().process(["QCD"]).bin(["tt_Boosted2D", "tt_Boosted2D_QCDCR"]).AddSyst(self.cb, "rate_QCD_cr_boosted_tt", "rateParam", ch.SystMap()(1.0))
			self.cb.cp().process(["QCD"]).bin(["tt_Vbf2D", "tt_Vbf3D", "tt_Vbf3D_CP", "tt_Vbf3D_CP_jdeta", "tt_Vbf2D_QCDCR"]).AddSyst(self.cb, "rate_QCD_cr_vbf_tt", "rateParam", ch.SystMap()(1.0))

			self.cb.cp().GetParameter("rate_W_cr_0jet_mt").set_range(0, 5)
			self.cb.cp().GetParameter("rate_W_cr_boosted_mt").set_range(0, 5)
			self.cb.cp().GetParameter("rate_W_cr_0jet_et").set_range(0, 5)
			self.cb.cp().GetParameter("rate_W_cr_boosted_et").set_range(0, 5)

			self.cb.cp().GetParameter("rate_QCD_cr_0jet_mt").set_range(0, 5)
			self.cb.cp().GetParameter("rate_QCD_cr_boosted_mt").set_range(0, 5)
			self.cb.cp().GetParameter("rate_QCD_cr_0jet_et").set_range(0, 5)
			self.cb.cp().GetParameter("rate_QCD_cr_boosted_et").set_range(0, 5)
			self.cb.cp().GetParameter("rate_QCD_cr_0jet_tt").set_range(0, 5)
			self.cb.cp().GetParameter("rate_QCD_cr_boosted_tt").set_range(0, 5)
			self.cb.cp().GetParameter("rate_QCD_cr_vbf_tt").set_range(0, 5)

			# ======================================================================

			if log.isEnabledFor(logging.DEBUG):
				self.cb.PrintAll()
コード例 #2
0
    def __init__(self,
                 channel_list,
                 signal_list,
                 category_list,
                 control_region_dic,
                 cb=None,
                 lnN_syst_enable=False,
                 shape_syst_enable=False,
                 rate_param_enable=False):
        super(LFVDatacards, self).__init__(cb)

        if cb is None:

            ###Define all background processes for each channel

            backgrounds = {
                "em": [
                    "ZTT", "ZLL", "EWKZ", "TT", "VV", "hww_gg125", "hww_qq125",
                    "W", "QCD"
                ],
                "et":
                ["ZTT", "ZL", "ZJ", "EWKZ", "TTT", "TTJJ", "VV", "W", "QCD"],
                "mt":
                ["ZTT", "ZL", "ZJ", "EWKZ", "TTT", "TTJJ", "VV", "W", "QCD"]
            }

            ##Generate instance of systematic libary, in which the relevant information about the systematics are safed

            systematics_list = SystLib.SystematicLibary()

            ###Fill Combine Harvester object with relevant information

            for channel in channel_list:

                ###Add channels as process in Combine Harvester
                for category in category_list + control_region_dic.keys():
                    self.add_processes(channel=channel,
                                       categories=[channel + "_" + category],
                                       bkg_processes=backgrounds[channel]
                                       if not "CR" in category else
                                       [control_region_dic[category][0]],
                                       sig_processes=[
                                           self.configs.sample2process(signal)
                                           for signal in signal_list
                                       ] if not "CR" in category else [],
                                       analysis=["LFV"],
                                       era=["13TeV"],
                                       mass=["125"])

                ###Add lnN/shape uncertanty for each channel, process and category

                if lnN_syst_enable:
                    for (systematic, process,
                         category) in systematics_list.get_LFV_systs(
                             channel, lnN=lnN_syst_enable):
                        if category == "":
                            self.cb.cp().channel([channel
                                                  ]).process(process).AddSyst(
                                                      self.cb, *systematic)
                        else:
                            self.cb.cp().channel([
                                channel
                            ]).process(process).bin(category).AddSyst(
                                self.cb, *systematic)

                if shape_syst_enable:
                    for (systematic, process,
                         category) in systematics_list.get_LFV_systs(
                             channel, shape=shape_syst_enable):
                        if category == "":
                            self.cb.cp().channel([channel
                                                  ]).process(process).AddSyst(
                                                      self.cb, *systematic)
                        else:
                            self.cb.cp().channel([
                                channel
                            ]).process(process).bin(category).AddSyst(
                                self.cb, *systematic)

                ##Add rate parameter

                if rate_param_enable:
                    for control_region, process in control_region_dic.iteritems(
                    ):
                        self.cb.cp().process([process[0]]).bin([
                            channel + "_" + cat
                            for cat in category_list + [control_region]
                        ]).AddSyst(self.cb,
                                   "rate_" + channel + "_" + process[0],
                                   "rateParam",
                                   ch.SystMap()(1.0))
コード例 #3
0
    def __init__(self,
                 cp_mixing_angles_over_pi_half=[],
                 higgs_masses=["125"],
                 year="2016",
                 add_data=True,
                 cb=None):
        super(CPStudiesDatacards, self).__init__(cb)

        if cb is None:
            signal_processes = ["ggH", "qqH", "VH", "WH"]

            #background_processes_tt = ["ZTT", "ZLL", "QCD"]
            background_processes_mt = [
                "ZTT", "ZL", "ZJ", "EWKZ", "TTT", "TTJJ", "VV", "W", "QCD"
            ]
            background_processes_et = [
                "ZTT", "ZL", "ZJ", "EWKZ", "TTT", "TTJJ", "VV", "W", "QCD"
            ]
            #background_processes_tt = ["ZTT", "ZL", "ZJ", "EWKZ", "TTT", "TTJJ", "VVT", "VVJ", "W", "QCD"]
            background_processes_tt = ["ZTT", "ZLL", "TTJJ", "QCD"]
            background_processes_em = [
                "ZTT", "ZLL", "EWKZ", "TT", "VV", "hww_gg125", "hww_qq125",
                "W", "QCD"
            ]
            background_processes_mm = ["ZLL", "TT", "VV", "W"]
            all_mc_bkgs = [
                "ZTT", "ZL", "ZJ", "ZLL", "TT", "TTT", "TTJJ", "VV", "VVT",
                "VVJ", "W", "hww_gg125", "hww_qq125"
            ]
            all_mc_bkgs_no_W = [
                "ZTT", "ZL", "ZJ", "ZLL", "EWKZ", "TT", "TTT", "TTJJ", "VV",
                "VVT", "VVJ", "hww_gg125", "hww_qq125"
            ]
            all_mc_bkgs_no_TTJ = [
                "ZTT", "ZL", "ZJ", "ZLL", "EWKZ", "TT", "TTT", "VV", "VVT",
                "VVJ", "W", "hww_gg125", "hww_qq125"
            ]

            ##Generate instance of systematic libary, in which the relevant information about the systematics are safed

            systematics_list = SystLib.SystematicLibary()

            jecUncertNames = [
                "AbsoluteFlavMap", "AbsoluteMPFBias", "AbsoluteScale",
                "AbsoluteStat", "FlavorQCD", "Fragmentation", "PileUpDataMC",
                "PileUpPtBB", "PileUpPtEC1", "PileUpPtEC2", "PileUpPtHF",
                "PileUpPtRef", "RelativeBal", "RelativeFSR", "RelativeJEREC1",
                "RelativeJEREC2", "RelativeJERHF", "RelativePtBB",
                "RelativePtEC1", "RelativePtEC2", "RelativePtHF",
                "RelativeStatEC", "RelativeStatFSR", "RelativeStatHF",
                "SinglePionECAL", "SinglePionHCAL", "TimePtEta"
            ]

            # ======================================================================
            # MT channel
            self.add_processes(
                channel="mt",
                #categories=["mt_"+category for category in ["0jet_low", "0jet_high", "1jet_low", "1jet_high", "2jet_vbf"]],
                categories=["mt_" + category for category in ["CP_mt"]],
                bkg_processes=["ZTT", "ZLL"],
                sig_processes=signal_processes,
                analysis=["htt"],
                era=["13TeV"],
                mass=cp_mixing_angles_over_pi_half,
                add_data=add_data)

            # efficiencies
            self.cb.cp().channel(["mt"]).process(["ZTT", "ZLL"]).AddSyst(
                self.cb, *systematics_list.muon_efficiency2016_syst_args)
            self.cb.cp().channel(["mt"]).signals().AddSyst(
                self.cb, *systematics_list.muon_efficiency2016_syst_args)

            self.cb.cp().channel(["mt"]).process(["ZTT"]).AddSyst(
                self.cb, *systematics_list.tau_efficiency2016_syst_args)
            self.cb.cp().channel(["mt"]).signals().AddSyst(
                self.cb, *systematics_list.tau_efficiency2016_syst_args)
            self.cb.cp().channel(["mt"]).process(["ZTT"]).AddSyst(
                self.cb, *systematics_list.tau_efficiency2016_corr_syst_args)
            self.cb.cp().channel(["mt"]).signals().AddSyst(
                self.cb, *systematics_list.tau_efficiency2016_corr_syst_args)

            # Tau ES
            self.cb.cp().channel(["mt"]).process(["ZTT"]).AddSyst(
                self.cb, *systematics_list.tau_es_syst_args)
            self.cb.cp().channel(["mt"]).signals().AddSyst(
                self.cb, *systematics_list.tau_es_syst_args)

            # fake-rate
            self.cb.cp().channel(["mt"]).process(["ZLL"]).AddSyst(
                self.cb, *systematics_list.zllFakeTau_syst_args)

            # ======================================================================
            # ET channel
            self.add_processes(
                channel="et",
                #categories=["et_"+category for category in ["0jet_low", "0jet_high", "1jet_low", "1jet_high", "2jet_vbf"]],
                categories=["et_" + category for category in ["CP_et"]],
                bkg_processes=["ZTT", "ZLL"],
                sig_processes=signal_processes,
                analysis=["htt"],
                era=["13TeV"],
                mass=cp_mixing_angles_over_pi_half,
                add_data=add_data)

            # efficiencies
            self.cb.cp().channel(["et"]).process(["ZTT", "ZLL"]).AddSyst(
                self.cb, *systematics_list.electron_efficiency2016_syst_args)
            self.cb.cp().channel(["et"]).signals().AddSyst(
                self.cb, *systematics_list.electron_efficiency2016_syst_args)

            self.cb.cp().channel(["et"]).process(["ZTT"]).AddSyst(
                self.cb, *systematics_list.tau_efficiency2016_syst_args)
            self.cb.cp().channel(["et"]).signals().AddSyst(
                self.cb, *systematics_list.tau_efficiency2016_syst_args)

            # Tau ES
            self.cb.cp().channel(["et"]).process(["ZTT"]).AddSyst(
                self.cb, *systematics_list.tau_es_syst_args)
            self.cb.cp().channel(["et"]).signals().AddSyst(
                self.cb, *systematics_list.tau_es_syst_args)

            # fake-rate
            self.cb.cp().channel(["et"]).process(["ZLL"]).AddSyst(
                self.cb, *systematics_list.zllFakeTau_syst_args)

            # ======================================================================
            # EM channel
            self.add_processes(
                channel="em",
                #categories=["em_"+category for category in ["0jet_low", "0jet_high", "1jet_low", "1jet_high", "2jet_vbf"]],
                categories=["em_" + category for category in ["CP_em"]],
                bkg_processes=["ZTT", "ZLL"],
                sig_processes=signal_processes,
                analysis=["htt"],
                era=["13TeV"],
                mass=cp_mixing_angles_over_pi_half,
                add_data=add_data)

            # efficiencies
            self.cb.cp().channel(["em"]).process(["ZTT", "ZLL"]).AddSyst(
                self.cb, *systematics_list.electron_efficiency2016_syst_args)
            self.cb.cp().channel(["em"]).signals().AddSyst(
                self.cb, *systematics_list.electron_efficiency2016_syst_args)

            self.cb.cp().channel(["em"]).process(["ZTT", "ZLL"]).AddSyst(
                self.cb, *systematics_list.muon_efficiency2016_syst_args)
            self.cb.cp().channel(["em"]).signals().AddSyst(
                self.cb, *systematics_list.muon_efficiency2016_syst_args)

            # ======================================================================
            # TT channel
            self.add_processes(
                channel="tt",
                categories=["tt_" + category for category in ["CP_tt"]],
                bkg_processes=["ZTT", "ZLL"],
                sig_processes=signal_processes,
                analysis=["htt"],
                era=["13TeV"],
                mass=cp_mixing_angles_over_pi_half,
                add_data=add_data)

            # TT channel for rho analysis
            # TODO: There are 3 different processes here. -> Merge to one.
            self.add_processes(channel="tt",
                               categories=[
                                   "tt_" + category
                                   for category in ["CP_rho_merged"]
                               ],
                               bkg_processes=background_processes_tt,
                               sig_processes=signal_processes,
                               analysis=["htt"],
                               era=["13TeV"],
                               mass=cp_mixing_angles_over_pi_half,
                               add_data=add_data)

            self.add_processes(channel="tt",
                               categories=[
                                   "tt_" + category
                                   for category in ["CP_rho_yLhigh"]
                               ],
                               bkg_processes=background_processes_tt,
                               sig_processes=signal_processes,
                               analysis=["htt"],
                               era=["13TeV"],
                               mass=cp_mixing_angles_over_pi_half,
                               add_data=add_data)

            self.add_processes(
                channel="tt",
                categories=["tt_" + category for category in ["CP_rho_yLlow"]],
                bkg_processes=background_processes_tt,
                sig_processes=signal_processes,
                analysis=["htt"],
                era=["13TeV"],
                mass=cp_mixing_angles_over_pi_half,
                add_data=add_data)

            # efficiencies
            if year == "2016":
                self.cb.cp().channel(
                    ["tt"]).process(signal_processes + all_mc_bkgs).AddSyst(
                        self.cb,
                        *systematics_list.trigger_efficiency2016_syst_args)
                self.cb.cp().channel(
                    ["tt"]).process(signal_processes + all_mc_bkgs).AddSyst(
                        self.cb,
                        *systematics_list.tau_efficiency2016_tt_syst_args)
            else:
                self.cb.cp().channel([
                    "tt"
                ]).process(signal_processes + ["ZTT", "TTT", "VVT"]).AddSyst(
                    self.cb, *systematics_list.tau_efficiency_syst_args)

            # # efficiencies
            # self.cb.cp().channel(["tt"]).process(signal_processes+all_mc_bkgs).AddSyst(self.cb, *systematics_list.tau_efficiency2016_syst_args)
            # #self.cb.cp().channel(["tt"]).signals().AddSyst(self.cb, *systematics_list.tau_efficiency2016_syst_args)
            #
            # # Tau ES
            # self.cb.cp().channel(["tt"]).process(signal_processes+all_mc_bkgs).AddSyst(self.cb, *systematics_list.tau_es_syst_args)
            # #self.cb.cp().channel(["tt"]).signals().AddSyst(self.cb, *systematics_list.tau_es_syst_args)
            #
            # # fake-rate
            # self.cb.cp().channel(["tt"]).process(["ZLL"]).AddSyst(self.cb, *systematics_list.zllFakeTau_syst_args)

            # ======================================================================
            # All channels

            # ======================================================================
            # lumi
            if year == "2016":
                self.cb.cp().process(
                    signal_processes +
                    ["VV", "VVT", "VVJ", "hww_gg125", "hww_qq125"]).AddSyst(
                        self.cb, *systematics_list.lumi2016_syst_args)

                self.cb.cp().process(["TT", "TTT", "TTJJ"]).AddSyst(
                    self.cb, *systematics_list.lumi2016_syst_args)
                self.cb.cp().process(["W"]).channel([
                    "em", "tt", "mm", "ttbar"
                ]).AddSyst(self.cb, *systematics_list.lumi2016_syst_args)
            else:
                self.cb.cp().process(signal_processes +
                                     all_mc_bkgs_no_W).AddSyst(
                                         self.cb,
                                         *systematics_list.lumi_syst_args)
                self.cb.cp().process(["W"]).channel(
                    ["em", "tt",
                     "mm"]).AddSyst(self.cb, *systematics_list.lumi_syst_args)

            # ======================================================================
            # cross section

            self.cb.cp().channel(["em"]).process(["ZTT", "ZLL", "EWKZ"]).bin([
                "em_ZeroJet2D"
            ]).AddSyst(self.cb, "CMS_htt_zmm_norm_extrap_0jet_em_13TeV", "lnN",
                       ch.SystMap()(1.07))
            self.cb.cp().channel(["tt"]).process([
                "ZTT", "ZL", "ZJ", "EWKZ"
            ]).bin(["tt_ZeroJet2D", "tt_ZeroJet2D_QCDCR"
                    ]).AddSyst(self.cb,
                               "CMS_htt_zmm_norm_extrap_0jet_tt_13TeV", "lnN",
                               ch.SystMap()(1.07))
            self.cb.cp().channel(["mt", "et"]).process(
                ["ZTT", "ZL", "ZJ", "EWKZ"]).bin([
                    "mt_ZeroJet2D", "mt_ZeroJet2D_WJCR", "mt_ZeroJet2D_QCDCR",
                    "et_ZeroJet2D", "et_ZeroJet2D_WJCR", "et_ZeroJet2D_QCDCR"
                ]).AddSyst(self.cb, "CMS_htt_zmm_norm_extrap_0jet_lt_13TeV",
                           "lnN",
                           ch.SystMap()(1.07))

            self.cb.cp().channel(["em"]).process(["ZTT", "ZLL", "EWKZ"]).bin([
                "em_Boosted2D"
            ]).AddSyst(self.cb, "CMS_htt_zmm_norm_extrap_boosted_em_13TeV",
                       "lnN",
                       ch.SystMap()(1.07))
            self.cb.cp().channel(["tt"]).process([
                "ZTT", "ZL", "ZJ", "EWKZ"
            ]).bin(["tt_Boosted2D", "tt_Boosted2D_QCDCR"
                    ]).AddSyst(self.cb,
                               "CMS_htt_zmm_norm_extrap_boosted_tt_13TeV",
                               "lnN",
                               ch.SystMap()(1.07))
            self.cb.cp().channel(["mt", "et"]).process(
                ["ZTT", "ZL", "ZJ", "EWKZ"]).bin([
                    "mt_Boosted2D", "mt_Boosted2D_WJCR", "mt_Boosted2D_QCDCR",
                    "et_Boosted2D", "et_Boosted2D_WJCR", "et_Boosted2D_QCDCR"
                ]).AddSyst(self.cb, "CMS_htt_zmm_norm_extrap_boosted_lt_13TeV",
                           "lnN",
                           ch.SystMap()(1.07))

            self.cb.cp().channel(["em"]).process(["ZTT", "ZLL", "EWKZ"]).bin([
                "em_Vbf2D"
            ]).AddSyst(self.cb, "CMS_htt_zmm_norm_extrap_VBF_em_13TeV", "lnN",
                       ch.SystMap()(1.15))
            self.cb.cp().channel(["tt"]).process([
                "ZTT", "ZL", "ZJ", "EWKZ"
            ]).bin(["tt_Vbf2D", "tt_Vbf2D_QCDCR"
                    ]).AddSyst(self.cb, "CMS_htt_zmm_norm_extrap_VBF_tt_13TeV",
                               "lnN",
                               ch.SystMap()(1.15))
            self.cb.cp().channel(["mt", "et"]).process([
                "ZTT", "ZL", "ZJ", "EWKZ"
            ]).bin(["mt_vbf2D", "et_vbf2D"
                    ]).AddSyst(self.cb, "CMS_htt_zmm_norm_extrap_VBF_lt_13TeV",
                               "lnN",
                               ch.SystMap()(1.10))

            self.cb.cp().channel(["mt", "et", "tt"]).process([
                "ZTT", "ZL", "ZJ", "EWKZ"
            ]).bin([channel + "_Vbf2D" for channel in ["mt", "et", "tt"]
                    ]).AddSyst(self.cb, "CMS_htt_zmumuShape_VBF_13TeV",
                               "shape",
                               ch.SystMap()(1.0))
            self.cb.cp().channel(["tt"]).process([
                "ZTT", "ZL", "ZJ", "EWKZ"
            ]).bin(["tt_Vbf2D_QCDCR"]).AddSyst(self.cb,
                                               "CMS_htt_zmumuShape_VBF_13TeV",
                                               "shape",
                                               ch.SystMap()(1.0))
            self.cb.cp().channel(["em"]).process(["ZTT", "ZLL"]).bin(
                ["em_Vbf2D"]).AddSyst(self.cb, "CMS_htt_zmumuShape_VBF_13TeV",
                                      "shape",
                                      ch.SystMap()(1.0))

            self.cb.cp().process(["TT", "TTT", "TTJJ"]).channel([
                "mt", "et", "em", "tt"
            ]).AddSyst(self.cb, *systematics_list.ttj_cross_section_syst_args)
            if year == "2016":
                self.cb.cp().process(["VV", "VVT", "VVJ"]).AddSyst(
                    self.cb, *systematics_list.vv_cross_section2016_syst_args)
            else:
                self.cb.cp().process(["VV", "VVT", "VVJ"]).AddSyst(
                    self.cb, *systematics_list.vv_cross_section_syst_args)
            self.cb.cp().process(["W"]).channel(["em"]).AddSyst(
                self.cb, "CMS_htt_jetFakeLep_13TeV", "lnN",
                ch.SystMap()(1.20))
            self.cb.cp().process(["W"]).channel(["tt", "mm"]).AddSyst(
                self.cb, *systematics_list.wj_cross_section_syst_args)

            # ======================================================================
            # tau id efficiency
            if year == "2016":
                self.cb.cp().channel(
                    ["mt",
                     "et"]).process(signal_processes + all_mc_bkgs).AddSyst(
                         self.cb,
                         *systematics_list.tau_efficiency2016_corr_syst_args)
                self.cb.cp().channel(
                    ["tt"]).process(signal_processes + all_mc_bkgs).AddSyst(
                        self.cb,
                        *systematics_list.tau_efficiency2016_tt_corr_syst_args)
            else:
                self.cb.cp().channel([
                    "mt", "et", "tt"
                ]).process(signal_processes + ["ZTT", "TTT", "VVT"]).AddSyst(
                    self.cb, *systematics_list.tau_efficiency_corr_syst_args)

            # ======================================================================
            # energy scales

            # tau ES
            self.cb.cp().channel(
                ["mt", "et",
                 "tt"]).process(signal_processes + all_mc_bkgs).AddSyst(
                     self.cb, "CMS_scale_t_1prong_13TeV", "shape",
                     ch.SystMap()(1.0))
            self.cb.cp().channel(
                ["mt", "et",
                 "tt"]).process(signal_processes + all_mc_bkgs).AddSyst(
                     self.cb, "CMS_scale_t_1prong1pizero_13TeV", "shape",
                     ch.SystMap()(1.0))
            self.cb.cp().channel(
                ["mt", "et",
                 "tt"]).process(signal_processes + all_mc_bkgs).AddSyst(
                     self.cb, "CMS_scale_t_3prong_13TeV", "shape",
                     ch.SystMap()(1.0))

            # jet ES
            # TODO: use mix of lnN/shape systematics as done in official analysis?

            for jecUncert in jecUncertNames:
                self.cb.cp().process(
                    signal_processes + all_mc_bkgs + ["QCD"]).bin([
                        channel + "_" + category
                        for channel in ["et", "mt", "tt", "em"]
                        for category in ["ZeroJet2D", "Boosted2D", "Vbf2D"]
                    ]).AddSyst(self.cb, "CMS_scale_j_" + jecUncert + "_13TeV",
                               "shape",
                               ch.SystMap()(1.0))
                self.cb.cp().channel(
                    ["mt"]).process(signal_processes + all_mc_bkgs).bin([
                        "mt_ZeroJet2D_WJCR", "mt_Boosted2D_WJCR",
                        "mt_ZeroJet2D_QCDCR", "mt_Boosted2D_QCDCR"
                    ]).AddSyst(self.cb, "CMS_scale_j_" + jecUncert + "_13TeV",
                               "shape",
                               ch.SystMap()(1.0))
                self.cb.cp().channel(
                    ["et"]).process(signal_processes + all_mc_bkgs).bin([
                        "et_ZeroJet2D_WJCR", "et_Boosted2D_WJCR",
                        "et_Boosted2D_QCDCR"
                    ]).AddSyst(self.cb, "CMS_scale_j_" + jecUncert + "_13TeV",
                               "shape",
                               ch.SystMap()(1.0))
                self.cb.cp().channel([
                    "et"
                ]).process(signal_processes + all_mc_bkgs_no_TTJ).bin([
                    "et_ZeroJet2D_QCDCR"
                ]).AddSyst(self.cb, "CMS_scale_j_" + jecUncert + "_13TeV",
                           "shape",
                           ch.SystMap()(1.0))
                self.cb.cp().channel(
                    ["tt"]).process(signal_processes + all_mc_bkgs).bin([
                        "tt_ZeroJet2D_QCDCR", "tt_Boosted2D_QCDCR",
                        "tt_Vbf2D_QCDCR"
                    ]).AddSyst(self.cb, "CMS_scale_j_" + jecUncert + "_13TeV",
                               "shape",
                               ch.SystMap()(1.0))

            # jet->tau fake ES
            if year == "2016":
                self.cb.cp().channel(["et", "mt", "tt"]).process([
                    "ZJ", "TTJJ", "VVJ"
                ]).AddSyst(self.cb, "CMS_htt_jetToTauFake_13TeV", "shape",
                           ch.SystMap()(1.0))
                self.cb.cp().channel(["et", "mt", "tt"]).process(["W"]).bin([
                    channel + "_" + category for channel in ["et", "mt", "tt"]
                    for category in ["ZeroJet2D", "Boosted2D", "Vbf2D"]
                ]).AddSyst(self.cb, "CMS_htt_jetToTauFake_13TeV", "shape",
                           ch.SystMap()(1.0))
                self.cb.cp().channel(["et", "mt"]).process(["W"]).bin([
                    channel + "_" + category for channel in ["et", "mt"]
                    for category in ["ZeroJet2D_QCDCR", "Boosted2D_QCDCR"]
                ]).AddSyst(self.cb, "CMS_htt_jetToTauFake_13TeV", "shape",
                           ch.SystMap()(1.0))
            else:
                self.cb.cp().channel(["et", "mt", "tt"]).process([
                    "ZJ", "W", "TTJJ", "VVJ"
                ]).AddSyst(self.cb, *systematics_list.jetFakeTau_syst_args)

            # MET ES
            self.cb.cp().channel(
                ["et", "mt", "tt",
                 "em"]).process(signal_processes + all_mc_bkgs).bin([
                     channel + "_" + category
                     for channel in ["et", "mt", "tt", "em"]
                     for category in ["ZeroJet2D", "Boosted2D", "Vbf2D"]
                 ]).AddSyst(self.cb, "CMS_scale_met_clustered_13TeV", "shape",
                            ch.SystMap()(1.0))
            self.cb.cp().channel(
                ["et", "mt", "tt",
                 "em"]).process(signal_processes + all_mc_bkgs).bin([
                     channel + "_" + category
                     for channel in ["et", "mt", "tt", "em"]
                     for category in ["ZeroJet2D", "Boosted2D", "Vbf2D"]
                 ]).AddSyst(self.cb, "CMS_scale_met_unclustered_13TeV",
                            "shape",
                            ch.SystMap()(1.0))
            self.cb.cp().channel(["et", "mt"]).process(all_mc_bkgs).bin([
                channel + "_" + category for channel in ["et", "mt"]
                for category in [
                    "ZeroJet2D_WJCR", "ZeroJet2D_QCDCR", "Boosted2D_WJCR",
                    "Boosted2D_QCDCR"
                ]
            ]).AddSyst(self.cb, "CMS_scale_met_clustered_13TeV", "shape",
                       ch.SystMap()(1.0))
            self.cb.cp().channel(["et", "mt"]).process(all_mc_bkgs).bin([
                channel + "_" + category for channel in ["et", "mt"]
                for category in [
                    "ZeroJet2D_WJCR", "ZeroJet2D_QCDCR", "Boosted2D_WJCR",
                    "Boosted2D_QCDCR"
                ]
            ]).AddSyst(self.cb, "CMS_scale_met_unclustered_13TeV", "shape",
                       ch.SystMap()(1.0))

            # ======================================================================
            # W+jets and QCD estimation uncertainties

            # QCD normalization
            self.cb.cp().channel(["em"]).process(["QCD"]).bin(
                ["em_ZeroJet2D"]).AddSyst(self.cb, "CMS_htt_QCD_0jet_em_13TeV",
                                          "lnN",
                                          ch.SystMap()(1.10))
            self.cb.cp().channel(["em"]).process(["QCD"]).bin([
                "em_Boosted2D"
            ]).AddSyst(self.cb, "CMS_htt_QCD_boosted_em_13TeV", "lnN",
                       ch.SystMap()(1.10))
            self.cb.cp().channel(["em"]).process(["QCD"]).bin(
                ["em_Vbf2D"]).AddSyst(self.cb, "CMS_htt_QCD_VBF_em_13TeV",
                                      "lnN",
                                      ch.SystMap()(1.20))

            self.cb.cp().channel(["tt"]).process(["QCD"]).bin(
                ["tt_ZeroJet2D"]).AddSyst(self.cb, "CMS_htt_QCD_0jet_tt_13TeV",
                                          "lnN",
                                          ch.SystMap()(1.027))
            self.cb.cp().channel(["tt"]).process(["QCD"]).bin([
                "tt_Boosted2D"
            ]).AddSyst(self.cb, "CMS_htt_QCD_boosted_tt_13TeV", "lnN",
                       ch.SystMap()(1.027))
            self.cb.cp().channel(["tt"]).process(["QCD"]).bin(
                ["tt_Vbf2D"]).AddSyst(self.cb, "CMS_htt_QCD_VBF_tt_13TeV",
                                      "lnN",
                                      ch.SystMap()(1.15))

            self.cb.cp().channel(["mt"]).process(["QCD"]).bin([
                "mt_" + category
                for category in ["ZeroJet2D", "Boosted2D", "Vbf2D"]
            ]).AddSyst(self.cb, "QCD_Extrap_Iso_nonIso_mt_13TeV", "lnN",
                       ch.SystMap()(1.20))
            self.cb.cp().channel(["et"]).process(["QCD"]).bin([
                "et_" + category
                for category in ["ZeroJet2D", "Boosted2D", "Vbf2D"]
            ]).AddSyst(self.cb, "QCD_Extrap_Iso_nonIso_et_13TeV", "lnN",
                       ch.SystMap()(1.20))

            self.cb.cp().channel(["et", "mt"]).process(["QCD"]).bin([
                channel + "_ZeroJet2D" for channel in ["et", "mt"]
            ]).AddSyst(self.cb, "WSFUncert_$CHANNEL_0jet_13TeV", "shape",
                       ch.SystMap()(1.0))
            self.cb.cp().channel(["et", "mt"]).process(["QCD"]).bin([
                channel + "_Boosted2D" for channel in ["et", "mt"]
            ]).AddSyst(self.cb, "WSFUncert_$CHANNEL_boosted_13TeV", "shape",
                       ch.SystMap()(1.0))
            self.cb.cp().channel(["et", "mt"]).process(["QCD"]).bin([
                channel + "_Vbf2D" for channel in ["et", "mt"]
            ]).AddSyst(self.cb, "WSFUncert_$CHANNEL_vbf_13TeV", "shape",
                       ch.SystMap()(1.0))

            # W+jets high->low mt extrapolation uncertainty
            self.cb.cp().channel(["et", "mt"]).process(["W"]).bin([
                channel + "_ZeroJet2D" for channel in ["et", "mt"]
            ]).AddSyst(self.cb, "WHighMTtoLowMT_0jet_13TeV", "lnN",
                       ch.SystMap()(1.10))
            self.cb.cp().channel(["et", "mt"]).process(["W"]).bin([
                channel + "_Boosted2D" for channel in ["et", "mt"]
            ]).AddSyst(self.cb, "WHighMTtoLowMT_boosted_13TeV", "lnN",
                       ch.SystMap()(1.05))
            self.cb.cp().channel(["et", "mt"]).process(["W"]).bin([
                channel + "_Vbf2D" for channel in ["et", "mt"]
            ]).AddSyst(self.cb, "WHighMTtoLowMT_vbf_13TeV", "lnN",
                       ch.SystMap()(1.10))

            # ======================================================================
            # pt reweighting uncertainties

            # ttbar shape
            self.cb.cp().channel(["et", "mt", "em",
                                  "tt"]).process(["TTT", "TTJJ"]).AddSyst(
                                      self.cb, *systematics_list.ttj_syst_args)
            self.cb.cp().channel(["em"]).process(["TT"]).AddSyst(
                self.cb, *systematics_list.ttj_syst_args)

            # dy shape
            self.cb.cp().channel(["et", "mt",
                                  "tt"]).process(["ZTT", "ZL", "ZJ"]).AddSyst(
                                      self.cb,
                                      *systematics_list.dy_shape_syst_args)
            self.cb.cp().channel(["em"]).process(["ZTT", "ZLL"]).AddSyst(
                self.cb, *systematics_list.dy_shape_syst_args)

            # ======================================================================
            # Theory uncertainties
            self.cb.cp().channel(["mt", "et", "tt", "em"]).process(
                ["ggH"]).bin([
                    channel + "_" + category
                    for channel in ["et", "mt", "em", "tt"]
                    for category in ["ZeroJet2D", "Boosted2D", "Vbf2D"]
                ]).AddSyst(self.cb, "CMS_scale_gg_13TeV", "shape",
                           ch.SystMap()(1.0))
            self.cb.cp().process(["qqH"]).AddSyst(
                self.cb, *systematics_list.htt_qcd_scale_qqh_syst_args)
            self.cb.cp().process(["ggH", "qqH"]).AddSyst(
                self.cb, *systematics_list.htt_pdf_scale_smhtt_syst_args)
            self.cb.cp().process(["ggH", "qqH"]).AddSyst(
                self.cb, *systematics_list.htt_ueps_smhtt_syst_args)

            # Uncertainty on BR of HTT @ 125 GeV
            self.cb.cp().signals().AddSyst(self.cb, "BR_htt_THU", "lnN",
                                           ch.SystMap()(1.017))
            self.cb.cp().signals().AddSyst(self.cb, "BR_htt_PU_mq", "lnN",
                                           ch.SystMap()(1.0099))
            self.cb.cp().signals().AddSyst(self.cb, "BR_htt_PU_alphas", "lnN",
                                           ch.SystMap()(1.0062))

            # Uncertainty on BR of HWW @ 125 GeV
            self.cb.cp().process(["hww_gg125", "hww_qq125"
                                  ]).AddSyst(self.cb, "BR_hww_THU", "lnN",
                                             ch.SystMap()(1.0099))
            self.cb.cp().process(["hww_gg125", "hww_qq125"
                                  ]).AddSyst(self.cb, "BR_hww_PU_mq", "lnN",
                                             ch.SystMap()(1.0099))
            self.cb.cp().process(["hww_gg125", "hww_qq125"
                                  ]).AddSyst(self.cb, "BR_hww_PU_alphas",
                                             "lnN",
                                             ch.SystMap()(1.0066))

            self.cb.cp().process(["ggH", "hww_gg125"
                                  ]).AddSyst(self.cb, "QCDScale_ggH", "lnN",
                                             ch.SystMap()(1.039))
            self.cb.cp().process(["qqH", "hww_qq125"
                                  ]).AddSyst(self.cb, "QCDScale_qqH", "lnN",
                                             ch.SystMap()(1.004))
            self.cb.cp().process(["WH"]).AddSyst(self.cb, "QCDScale_VH", "lnN",
                                                 ch.SystMap()(1.007))
            self.cb.cp().process(["ZH"]).AddSyst(self.cb, "QCDScale_VH", "lnN",
                                                 ch.SystMap()(1.038))

            self.cb.cp().process(["ggH", "hww_gg125"
                                  ]).AddSyst(self.cb, "pdf_Higgs_gg", "lnN",
                                             ch.SystMap()(1.032))
            self.cb.cp().process(["qqH", "hww_qq125"
                                  ]).AddSyst(self.cb, "pdf_Higgs_qq", "lnN",
                                             ch.SystMap()(1.021))
            self.cb.cp().process(["WH"]).AddSyst(self.cb, "pdf_Higgs_VH",
                                                 "lnN",
                                                 ch.SystMap()(1.019))
            self.cb.cp().process(["ZH"]).AddSyst(self.cb, "pdf_Higgs_VH",
                                                 "lnN",
                                                 ch.SystMap()(1.016))

            # ======================================================================
            # control region rate parameters
            self.cb.cp().process(["W"
                                  ]).bin(["mt_ZeroJet2D", "mt_ZeroJet2D_WJCR"
                                          ]).AddSyst(self.cb,
                                                     "rate_W_cr_0jet_mt",
                                                     "rateParam",
                                                     ch.SystMap()(1.0))
            self.cb.cp().process(["W"]).bin([
                "mt_Boosted2D", "mt_Boosted2D_WJCR", "mt_Vbf2D"
            ]).AddSyst(self.cb, "rate_W_cr_boosted_mt", "rateParam",
                       ch.SystMap()(1.0))
            self.cb.cp().process(["W"
                                  ]).bin(["et_ZeroJet2D", "et_ZeroJet2D_WJCR"
                                          ]).AddSyst(self.cb,
                                                     "rate_W_cr_0jet_et",
                                                     "rateParam",
                                                     ch.SystMap()(1.0))
            self.cb.cp().process(["W"]).bin([
                "et_Boosted2D", "et_Boosted2D_WJCR", "et_Vbf2D"
            ]).AddSyst(self.cb, "rate_W_cr_boosted_et", "rateParam",
                       ch.SystMap()(1.0))

            self.cb.cp().process(["QCD"]).bin([
                "mt_ZeroJet2D", "mt_ZeroJet2D_QCDCR"
            ]).AddSyst(self.cb, "rate_QCD_cr_0jet_mt", "rateParam",
                       ch.SystMap()(1.0))
            self.cb.cp().process(["QCD"]).bin([
                "mt_Boosted2D", "mt_Boosted2D_QCDCR", "mt_Vbf2D"
            ]).AddSyst(self.cb, "rate_QCD_cr_boosted_mt", "rateParam",
                       ch.SystMap()(1.0))
            self.cb.cp().process(["QCD"]).bin([
                "et_ZeroJet2D", "et_ZeroJet2D_QCDCR"
            ]).AddSyst(self.cb, "rate_QCD_cr_0jet_et", "rateParam",
                       ch.SystMap()(1.0))
            self.cb.cp().process(["QCD"]).bin([
                "et_Boosted2D", "et_Boosted2D_QCDCR", "et_Vbf2D"
            ]).AddSyst(self.cb, "rate_QCD_cr_boosted_et", "rateParam",
                       ch.SystMap()(1.0))
            self.cb.cp().process(["QCD"]).bin([
                "tt_ZeroJet2D", "tt_ZeroJet2D_QCDCR"
            ]).AddSyst(self.cb, "rate_QCD_cr_0jet_tt", "rateParam",
                       ch.SystMap()(1.0))
            self.cb.cp().process(["QCD"]).bin([
                "tt_Boosted2D", "tt_Boosted2D_QCDCR"
            ]).AddSyst(self.cb, "rate_QCD_cr_boosted_tt", "rateParam",
                       ch.SystMap()(1.0))
            self.cb.cp().process(["QCD"
                                  ]).bin(["tt_Vbf2D", "tt_Vbf2D_QCDCR"
                                          ]).AddSyst(self.cb,
                                                     "rate_QCD_cr_vbf_tt",
                                                     "rateParam",
                                                     ch.SystMap()(1.0))

            #self.cb.cp().GetParameter("rate_W_cr_0jet_mt").set_range(0, 5)
            #self.cb.cp().GetParameter("rate_W_cr_boosted_mt").set_range(0, 5)
            #self.cb.cp().GetParameter("rate_W_cr_0jet_et").set_range(0, 5)
            #self.cb.cp().GetParameter("rate_W_cr_boosted_et").set_range(0, 5)

            # self.cb.cp().GetParameter("rate_QCD_cr_0jet_mt").set_range(0, 5)
            # self.cb.cp().GetParameter("rate_QCD_cr_boosted_mt").set_range(0, 5)
            # self.cb.cp().GetParameter("rate_QCD_cr_0jet_et").set_range(0, 5)
            # self.cb.cp().GetParameter("rate_QCD_cr_boosted_et").set_range(0, 5)
            # self.cb.cp().GetParameter("rate_QCD_cr_0jet_tt").set_range(0, 5)
            # self.cb.cp().GetParameter("rate_QCD_cr_boosted_tt").set_range(0, 5)
            # self.cb.cp().GetParameter("rate_QCD_cr_vbf_tt").set_range(0, 5)

            # ======================================================================

            if log.isEnabledFor(logging.DEBUG):
                self.cb.PrintAll()
コード例 #4
0
    def __init__(self, year="", noJECuncSplit=True, cb=None):
        super(ZttLepTauFakeRateDatacards, self).__init__(cb)

        systematics_list = SystLib.SystematicLibary()

        all_mc_bkgs = ["ZTT", "ZL", "ZJ", "TTT", "TTJJ", "VV", "W"]
        all_mc_bkgs_no_W = ["ZTT", "ZL", "ZJ", "TTT", "TTJJ", "VV"]

        if cb is None:
            # ======================================================================
            # MT channel
            self.add_processes(
                channel="mt",
                categories=[
                    "mt_" + category
                    for category in ["antimutightpass", "antimutightfail"]
                ],
                bkg_processes=["ZTT", "ZJ", "TT", "VV", "W", "QCD"],
                sig_processes=["ZL"],
                analysis=["ztt"],
                era=["13TeV"],
                mass=["90"])

            # efficiencies
            self.cb.cp().channel(["mt"]).process([
                "ZL", "ZJ", "TT", "VV", "W", "QCD"
            ]).AddSyst(self.cb, *systematics_list.muon_efficiency_syst_args)
            self.cb.cp().channel(["mt"]).process(["ZTT", "TT", "VV"]).AddSyst(
                self.cb, *systematics_list.tau_efficiency_syst_args)

            # Tau ES
            self.cb.cp().channel(["mt"]).process(["ZTT"]).AddSyst(
                self.cb, *systematics_list.tau_es_syst_args)

            # ======================================================================
            # ET channel
            self.add_processes(
                channel="et",
                categories=[
                    "et_" + category
                    for category in ["antievloosepass", "antievloosefail"]
                ],
                bkg_processes=["ZTT", "ZJ", "TT", "VV", "W", "QCD"],
                sig_processes=["ZL"],
                analysis=["ztt"],
                era=["13TeV"],
                mass=["90"])

            # efficiencies
            if year == "2016":
                self.cb.cp().channel(["et"]).process(all_mc_bkgs_no_W).AddSyst(
                    self.cb,
                    *systematics_list.electron_efficiency2016_syst_args)
                self.cb.cp().channel(["et"]).process(all_mc_bkgs_no_W).AddSyst(
                    self.cb,
                    *systematics_list.trigger_efficiency2016_syst_args)
                self.cb.cp().channel(["et"]).process([
                    "ZTT", "TTT", "VV"
                ]).AddSyst(self.cb,
                           *systematics_list.tau_efficiency2016_corr_syst_args)
                self.cb.cp().channel(["et"]).process([
                    "ZTT", "TTT", "VV"
                ]).AddSyst(self.cb,
                           *systematics_list.tau_efficiency2016_syst_args)
            else:
                self.cb.cp().channel(["et"]).process(all_mc_bkgs_no_W).AddSyst(
                    self.cb, *systematics_list.electron_efficiency_syst_args)
                self.cb.cp().channel(["et"]).process([
                    "ZTT", "TTT", "VV"
                ]).AddSyst(self.cb,
                           *systematics_list.tau_efficiency_corr_syst_args)
                self.cb.cp().channel(["et"]).process(
                    ["ZTT", "TTT",
                     "VV"]).AddSyst(self.cb,
                                    *systematics_list.tau_efficiency_syst_args)

            # Probe Tau ES
            self.cb.cp().channel(["et"]).process(["ZTT"]).AddSyst(
                self.cb, *systematics_list.probetau_es_syst_args)

            # Probe Electron ES
            self.cb.cp().channel(["et"]).process(["ZL"]).AddSyst(
                self.cb, *systematics_list.probeele_es_syst_args)

            # Tag Electron ES
            self.cb.cp().channel(["et"]).process(["ZL"]).AddSyst(
                self.cb, *systematics_list.tagele_es_syst_args)

            # Visible mass resolution
            self.cb.cp().channel(["et"]).process(["ZL"]).AddSyst(
                self.cb, *systematics_list.massres_syst_args)

            # additional nuisance for possible differences in Z -> ee norm., in addition to the Z->tautau norm.
            self.cb.cp().channel(["et"]).process(["ZL"]).AddSyst(
                self.cb, *systematics_list.zee_norm_syst_args)

            # ===========================================================================
            # All channels
            # lumi
            if year == "2016":
                self.cb.cp().process(all_mc_bkgs_no_W).AddSyst(
                    self.cb, *systematics_list.lumi2016_syst_args)
            else:
                self.cb.cp().process(all_mc_bkgs_no_W).AddSyst(
                    self.cb, *systematics_list.lumi_syst_args)

            # cross section
            self.cb.cp().process(["ZTT", "ZL", "ZJ"]).AddSyst(
                self.cb, *systematics_list.ztt_cross_section_syst_args)
            self.cb.cp().process(["TTJ", "TTJJ"]).AddSyst(
                self.cb, *systematics_list.ttj_cross_section_syst_args)
            self.cb.cp().process(["W"]).AddSyst(
                self.cb, *systematics_list.wj_cross_section_syst_args)
            if year == "2016":
                self.cb.cp().process(["VV"]).AddSyst(
                    self.cb, *systematics_list.vv_cross_section2016_syst_args)
            else:
                self.cb.cp().process(["VV"]).AddSyst(
                    self.cb, *systematics_list.vv_cross_section_syst_args)

            # W+jets extrapolation
            self.cb.cp().process(["W"]).AddSyst(
                self.cb, *systematics_list.wj_extrapol_syst_args)

            # QCD systematic
            self.cb.cp().process(["QCD"
                                  ]).AddSyst(self.cb,
                                             *systematics_list.qcd_syst_args)

            # QCD systematic
            self.cb.cp().channel(["mt", "et"]).process(["QCD"]).AddSyst(
                self.cb, "CMS_QCD_Extrap_Iso_nonIso_lt_13TeV", "lnN",
                ch.SystMap()(1.20))
            self.cb.cp().channel(["mt", "et"]).process(["QCD"]).AddSyst(
                self.cb, "CMS_WSFUncert_lt_13TeV", "shape",
                ch.SystMap()(1.0))

            # W+jets high->low mt extrapolation uncertainty
            #self.cb.cp().channel(["mt", "et"]).process(["W"]).AddSyst(self.cb, "WHighMTtoLowMT_13TeV", "lnN", ch.SystMap()(1.10))

            if log.isEnabledFor(logging.DEBUG):
                self.cb.PrintAll()
コード例 #5
0
    def __init__(self,
                 quantity="m_vis",
                 year="",
                 mapping_category2binid=None,
                 cb=None):
        super(QcdFactorsDatacards, self).__init__(cb)

        if mapping_category2binid is not None:
            self.configs._mapping_category2binid.update(mapping_category2binid)

    ##Generate instance of systematic libary, in which the relevant information about the systematics are safed

        systematics_list = SystLib.SystematicLibary()

        all_mc_bkgs = ["ZTT", "ZL", "ZJ", "TTT", "TTJJ", "VVT", "VVJ", "W"]
        all_mc_bkgs_no_W = ["ZTT", "ZL", "ZJ", "TTT", "TTJJ", "VVT", "VVJ"
                            ]  #don't no whether this is still needed here...
        signal_processes = ["QCD"]
        categories_for_SSOS_factor_estimation = [
            "ZeroJet2D_antiiso", "Boosted2D_antiiso",
            "dijet2D_lowboost_antiiso", "dijet2D_boosted_antiiso",
            "ZeroJet2D_antiiso_tau", "Boosted2D_antiiso_tau",
            "dijet2D_lowboost_antiiso_tau", "dijet2D_boosted_antiiso_tau",
            "ZeroJet2D_antiiso_taulep", "Boosted2D_antiiso_taulep",
            "dijet2D_lowboost_antiiso_taulep",
            "dijet2D_boosted_antiiso_taulep", "dijet2D_antiiso",
            "ZeroJet2D_antiiso_near", "Boosted2D_antiiso_near",
            "dijet2D_lowboost_antiiso_near", "dijet2D_boosted_antiiso_near",
            "dijet2D_antiiso_near", "ZeroJet2D_antiiso_far",
            "Boosted2D_antiiso_far", "dijet2D_lowboost_antiiso_far",
            "dijet2D_boosted_antiiso_far", "dijet2D_antiiso_far"
        ]
        if cb is None:
            # ======================================================================
            # MT channel
            self.add_processes(
                channel="mt",
                categories=[
                    "mt_" + category
                    for category in categories_for_SSOS_factor_estimation
                ],
                bkg_processes=all_mc_bkgs,
                sig_processes=signal_processes,
                analysis=["htt"],
                era=["13TeV"],
                mass=["125"])

            # efficiencies
            ##########
            # Only uncorrelated efficienies used here since we examine both channels individually

            if year == "2016":
                self.cb.cp().channel(["mt"]).process(all_mc_bkgs_no_W).AddSyst(
                    self.cb,
                    *systematics_list.trigger_efficiency2016_syst_args)
                self.cb.cp().channel(["mt"]).process(all_mc_bkgs).AddSyst(
                    self.cb, *systematics_list.muon_efficiency2016_syst_args
                )  #https://github.com/cms-analysis/CombineHarvester/blob/f553ba7f1c2816e535cfd98fb18210ba0c2bc16d/HTTSMCP2016/src/HttSystematics_SMRun2.cc#L101
                self.cb.cp().channel(["mt"]).process([
                    "ZTT", "TTT", "VVT"
                ]).AddSyst(self.cb, *systematics_list.tau_efficiency_syst_args)
                self.cb.cp().channel(["mt"]).process(["ZL"]).AddSyst(
                    self.cb, *systematics_list.muFakeTau_tight_syst_args)

            # mu->tau fake ES (only for 1-prongs and 1-prong+Pi0s)
            # self.cb.cp().channel(["mt"]).process(["ZL"]).bin(categoriesForMuFakeTauES).AddSyst(self.cb, *systematics_list.muFakeTau_es_syst_args)

            # fake-rate
            # if year == "2016":
            # 	self.cb.cp().channel(["mt"]).process(["ZL"]).bin(categoriesForMuFakeTauES).AddSyst(self.cb, *systematics_list.muFakeTau2016_syst_args)

            # ======================================================================
            # ET channel
            self.add_processes(
                channel="et",
                categories=[
                    "et_" + category
                    for category in categories_for_SSOS_factor_estimation
                ],
                bkg_processes=all_mc_bkgs,
                sig_processes=signal_processes,
                analysis=["htt"],
                era=["13TeV"],
                mass=["125"])

            # efficiencies
            ##########
            # - Only uncorrelated efficienies used here since we examine both channels individually
            # - CMS_eff_e to be applied  also to W as it comes from MC.
            if year == "2016":
                self.cb.cp().channel(["et"]).process(all_mc_bkgs_no_W).AddSyst(
                    self.cb,
                    *systematics_list.trigger_efficiency2016_syst_args)
                self.cb.cp().channel(["et"]).process(all_mc_bkgs).AddSyst(
                    self.cb,
                    *systematics_list.electron_efficiency2016_syst_args
                )  # https://github.com/cms-analysis/CombineHarvester/blob/f553ba7f1c2816e535cfd98fb18210ba0c2bc16d/HTTSMCP2016/src/HttSystematics_SMRun2.cc#L105
                self.cb.cp().channel(["et"]).process([
                    "ZTT", "TTT", "VVT"
                ]).AddSyst(self.cb, *systematics_list.tau_efficiency_syst_args)

            # e->tau fake
            # self.cb.cp().channel(["et"]).AddSyst(self.cb, *systematics_list.eleFakeTau_es_syst_args)
            self.cb.cp().channel(["et"]).AddSyst(
                self.cb, *systematics_list.eFakeTau_1prong_syst_args)
            self.cb.cp().channel(["et"]).AddSyst(
                self.cb, *systematics_list.eFakeTau_1prong1pizero_syst_args)
            # self.cb.cp().channel(["et"]).AddSyst(self.cb, *systematics_list.eleFakeTau_es_syst_args)

            # fake-rate
            if year == "2016":
                self.cb.cp().channel(["et"]).process(["ZL"]).AddSyst(
                    self.cb, *systematics_list.eFakeTau2016_syst_args)
                # self.cb.cp().channel(["et"]).process(["ZL"]).AddSyst(self.cb, *systematics_list.eFakeTau_tight_syst_args)
                self.cb.cp().channel(["et"]).process(["ZL"]).AddSyst(
                    self.cb, *systematics_list.eFakeTau_vloose_syst_args)

            # ======================================================================
            # All channels

            # lumi
            # (hopefully) temporary fix
            if year == "2016":
                self.cb.cp().process(all_mc_bkgs_no_W).AddSyst(
                    self.cb, *systematics_list.lumi2016_syst_args)

            # cross section
            self.cb.cp().process(["ZTT", "ZLL", "ZL", "ZJ"]).AddSyst(
                self.cb, *systematics_list.ztt_cross_section_syst_args)
            if year == "2016":
                self.cb.cp().process(["VVT", "VVJ"]).AddSyst(
                    self.cb, *systematics_list.vv_cross_section2016_syst_args)
            self.cb.cp().process(["TTT", "TTJJ"]).AddSyst(
                self.cb, *systematics_list.ttj_cross_section_syst_args)
            self.cb.cp().process(["W"]).AddSyst(
                self.cb, *systematics_list.wj_cross_section_syst_args)

            # Normalizations
            self.cb.cp().process(["W"]).AddSyst(
                self.cb, *systematics_list.htt_wnorm_syst_args)
            self.cb.cp().process(["TTT", "TTJ"]).AddSyst(
                self.cb, *systematics_list.htt_ttnorm_syst_args)
            self.cb.cp().process(["VVJ", "VVT"]).AddSyst(
                self.cb, *systematics_list.htt_vvnorm_syst_args)

            # signal acceptance/efficiency
            self.cb.cp().process(["ZTT"]).AddSyst(
                self.cb, *systematics_list.ztt_pdf_scale_syst_args)
            self.cb.cp().process(["ZTT"]).AddSyst(
                self.cb, *systematics_list.ztt_qcd_scale_syst_args)

            # W+jets high->low mt extrapolation uncertainty
            self.cb.cp().channel(["mt", "et"]).process(["W"]).AddSyst(
                self.cb, "WHighMTtoLowMT_13TeV", "lnN",
                ch.SystMap()(1.10))

            # tau energy scale
            if year == "2016":
                # self.cb.cp().channel(["mt"]).process(["ZTT", "TTT", "VVT"]).AddSyst(self.cb, *systematics_list.tau_es_syst_args)
                self.cb.cp().channel(["mt", "et"]).process([
                    "ZTT", "TTT", "VVT"
                ]).AddSyst(self.cb, *systematics_list.scale_t_1prong_syst_args)
                self.cb.cp().channel(["mt", "et"]).process([
                    "ZTT", "TTT", "VVT"
                ]).AddSyst(self.cb, *systematics_list.scale_t_3prong_syst_args)
                self.cb.cp().channel(["mt", "et"]).process([
                    "ZTT", "TTT", "VVT"
                ]).AddSyst(self.cb,
                           *systematics_list.scale_t_1prong1pizero_syst_args)

            if year == "2016":
                self.cb.cp().channel(["mt", "et"]).process([
                    "ZTT", "TTT", "VVT"
                ]).AddSyst(self.cb,
                           *systematics_list.tau_efficiency2016_corr_syst_args)

            # jet->tau fakes
            if year == "2016":
                self.cb.cp().channel(["mt", "et"]).process([
                    "ZJ", "TTJJ", "VVJ"
                ]).AddSyst(self.cb, "CMS_htt_jetToTauFake_13TeV", "shape",
                           ch.SystMap()(1.0))

            if log.isEnabledFor(logging.DEBUG):
                self.cb.PrintAll()
コード例 #6
0
    def __init__(self, cb=None):
        super(ZttEffDatacards, self).__init__(cb)

        systematics_list = SystLib.SystematicLibary()
        if cb is None:
            # ======================================================================
            # MT channel
            self.add_processes(
                channel="mt",
                categories=[
                    "mt_" + category
                    for category in ["tauidvtightpass", "tauidvtightfail"]
                ],
                bkg_processes=["ZL", "ZJ", "TT", "VV", "W", "QCD"],
                sig_processes=["ZTT"],
                analysis=["ztt"],
                era=["13TeV"],
                mass=["90"])

            # efficiencies
            self.cb.cp().channel(["mt"]).process([
                "ZL", "ZJ", "TT", "VV", "W", "QCD"
            ]).AddSyst(self.cb, *systematics_list.muon_efficiency_syst_args)

            # mu->tau fake ES
            self.cb.cp().channel(["mt"]).process(["ZL"]).AddSyst(
                self.cb, *systematics_list.muFakeTau_es_syst_args)

            # Tau ES
            self.cb.cp().channel(["mt"]).process(["ZTT"]).AddSyst(
                self.cb, *systematics_list.tau_es_syst_args)

            # fake-rate
            self.cb.cp().channel(["mt"]).process(["ZL"]).AddSyst(
                self.cb, *systematics_list.eFakeTau_vloose_syst_args)
            self.cb.cp().channel(["mt"]).process(["ZL"]).AddSyst(
                self.cb, *systematics_list.muFakeTau_syst_args)

            # b-tag efficiency and mistag
            self.cb.cp().channel(["mt"]).process(["ZTT", "TT"]).AddSyst(
                self.cb, *systematics_list.btag_efficiency_syst_args)
            self.cb.cp().channel(["mt"]).process(["ZTT", "TT"]).AddSyst(
                self.cb, *systematics_list.btag_mistag_syst_args)

            # ======================================================================
            # ET channel
            self.add_processes(
                channel="et",
                categories=[
                    "et_" + category
                    for category in ["tauidpass", "tauidfail"]
                ],
                bkg_processes=["ZL", "ZJ", "TT", "VV", "W", "QCD"],
                sig_processes=["ZTT"],
                analysis=["ztt"],
                era=["13TeV"],
                mass=["90"])

            # efficiencies
            self.cb.cp().channel(["et"]).process([
                "ZL", "ZJ", "TT", "VV", "W", "QCD"
            ]).AddSyst(self.cb,
                       *systematics_list.electron_efficiency_syst_args)

            # Tau ES
            self.cb.cp().channel(["et"]).process(["ZTT"]).AddSyst(
                self.cb, *systematics_list.tau_es_syst_args)

            # fake-rate
            self.cb.cp().channel(["et"]).process(["ZL"]).AddSyst(
                self.cb, *systematics_list.eFakeTau_tight_syst_args)
            self.cb.cp().channel(["et"]).process(["ZL"]).AddSyst(
                self.cb, *systematics_list.muFakeTau_syst_args)

            # b-tag efficiency and mistag
            self.cb.cp().channel(["et"]).process(["ZTT", "TT"]).AddSyst(
                self.cb, *systematics_list.btag_efficiency_syst_args)
            self.cb.cp().channel(["et"]).process(["ZTT", "TT"]).AddSyst(
                self.cb, *systematics_list.btag_mistag_syst_args)

            # ======================================================================
            # All channels
            # lumi
            self.cb.cp().process(["ZTT", "ZLL", "ZL", "ZJ", "TT", "VV"
                                  ]).AddSyst(self.cb,
                                             *systematics_list.lumi_syst_args)

            # cross section
            self.cb.cp().process(["ZL", "ZJ"]).AddSyst(
                self.cb, *systematics_list.ztt_cross_section_syst_args)
            self.cb.cp().process(["VV"]).AddSyst(
                self.cb, *systematics_list.vv_cross_section_syst_args)
            self.cb.cp().process(["TT"]).AddSyst(
                self.cb, *systematics_list.ttj_cross_section_syst_args)
            self.cb.cp().process(["W"]).AddSyst(
                self.cb, *systematics_list.wj_cross_section_syst_args)

            # signal acceptance/efficiency
            self.cb.cp().process(["ZTT"]).AddSyst(
                self.cb, *systematics_list.ztt_pdf_scale_syst_args)
            self.cb.cp().process(["ZTT"]).AddSyst(
                self.cb, *systematics_list.ztt_qcd_scale_syst_args)

            # W+jets extrapolation
            self.cb.cp().process(["W"]).AddSyst(
                self.cb, *systematics_list.wj_extrapol_syst_args)

            # QCD systematic
            self.cb.cp().process(["QCD"]).AddSyst(
                self.cb, *systematics_list.qcd_syst_inclusive_args)

            if log.isEnabledFor(logging.DEBUG):
                self.cb.PrintAll()
コード例 #7
0
    def __init__(self, cb=None, model='default'):
        super(ZttXsecDatacards, self).__init__(cb)

        if cb is None:

            ##Generate instance of systematic libary, in which the relevant information about the systematics are safed

            systematics_list = SystLib.SystematicLibary()
            # ======================================================================
            # MT channel
            self.add_processes(
                channel="mt",
                categories=["mt_" + category for category in ["inclusive"]],
                bkg_processes=["ZL", "ZJ", "TT", "VV", "W", "QCD"],
                sig_processes=["ZTT"],
                analysis=["ztt"],
                era=["13TeV"],
                mass=["90"])

            # efficiencies
            self.cb.cp().channel(["mt"]).process([
                "ZTT", "ZL", "ZJ", "TT", "VV"
            ]).AddSyst(self.cb, *systematics_list.muon_efficiency_syst_args)
            if "taueff" not in model:
                self.cb.cp().channel(["mt"]).process([
                    "ZTT", "TT", "VV"
                ]).AddSyst(self.cb,
                           *systematics_list.tau_efficiency_corr_syst_args)
                self.cb.cp().channel(["mt"]).process(
                    ["ZTT", "TT",
                     "VV"]).AddSyst(self.cb,
                                    *systematics_list.tau_efficiency_syst_args)

            # extrapolation uncertainty
            self.cb.cp().channel(["mt"]).process(["W"]).AddSyst(
                self.cb, *systematics_list.wj_extrapol_syst_args)

            # Tau ES
            self.cb.cp().channel(["mt"]).process(["ZTT"]).AddSyst(
                self.cb, *systematics_list.tau_es_syst_args)

            # fake-rate
            self.cb.cp().channel(["mt"]).process(["ZL"]).AddSyst(
                self.cb, *systematics_list.eFakeTau_vloose_syst_args)
            self.cb.cp().channel(["mt"]).process(["ZL"]).AddSyst(
                self.cb, *systematics_list.muFakeTau_syst_args)

            # Top pT reweight
            self.cb.cp().channel(["mt"]).process(["TT"]).AddSyst(
                self.cb, *systematics_list.ttj_syst_args)

            # ======================================================================
            # ET channel
            self.add_processes(
                channel="et",
                categories=["et_" + category for category in ["inclusive"]],
                bkg_processes=["ZL", "ZJ", "TT", "VV", "W", "QCD"],
                sig_processes=["ZTT"],
                analysis=["ztt"],
                era=["13TeV"],
                mass=["90"])

            # efficiencies
            self.cb.cp().channel(["et"]).process([
                "ZTT", "ZL", "ZJ", "TT", "VV"
            ]).AddSyst(self.cb,
                       *systematics_list.electron_efficiency_syst_args)
            if "taueff" not in model:
                self.cb.cp().channel(["et"]).process([
                    "ZTT", "TT", "VV"
                ]).AddSyst(self.cb,
                           *systematics_list.tau_efficiency_corr_syst_args)
                self.cb.cp().channel(["et"]).process(
                    ["ZTT", "TT",
                     "VV"]).AddSyst(self.cb,
                                    *systematics_list.tau_efficiency_syst_args)

            # extrapolation uncertainty
            self.cb.cp().channel(["et"]).process(["W"]).AddSyst(
                self.cb, *systematics_list.wj_extrapol_syst_args)

            # Tau ES
            self.cb.cp().channel(["et"]).process(["ZTT"]).AddSyst(
                self.cb, *systematics_list.tau_es_syst_args)

            # fake-rate
            self.cb.cp().channel(["et"]).process(["ZL"]).AddSyst(
                self.cb, *systematics_list.eFakeTau_tight_syst_args)
            self.cb.cp().channel(["et"]).process(["ZL"]).AddSyst(
                self.cb, *systematics_list.muFakeTau_syst_args)

            # Top pT reweight
            self.cb.cp().channel(["et"]).process(["TT"]).AddSyst(
                self.cb, *systematics_list.ttj_syst_args)

            # ======================================================================
            # EM channel
            self.add_processes(
                channel="em",
                categories=["em_" + category for category in ["inclusive"]],
                bkg_processes=["ZLL", "TT", "VV", "W", "QCD"],
                sig_processes=["ZTT"],
                analysis=["ztt"],
                era=["13TeV"],
                mass=["90"])

            # efficiencies
            self.cb.cp().channel(["em"]).process([
                "ZTT", "ZLL", "TT", "VV", "W", "QCD"
            ]).AddSyst(self.cb,
                       *systematics_list.electron_efficiency_syst_args)
            self.cb.cp().channel(["em"]).process([
                "ZTT", "ZLL", "TT", "VV", "W", "QCD"
            ]).AddSyst(self.cb, *systematics_list.muon_efficiency_syst_args)

            # extrapolation uncertainty
            self.cb.cp().channel(["em"]).process(["TT"]).AddSyst(
                self.cb, *systematics_list.ttj_extrapol_syst_args)

            # Electron ES
            self.cb.cp().channel(["em"]).process(
                ["ZTT", "TT", "W",
                 "VV"]).AddSyst(self.cb, *systematics_list.ele_es_syst_args)

            # Muon ES
            self.cb.cp().channel(["em"]).process(
                ["ZTT", "TT", "W",
                 "VV"]).AddSyst(self.cb, *systematics_list.mu_es_syst_args)

            # Top pT reweight
            self.cb.cp().channel(["em"]).process(["TT"]).AddSyst(
                self.cb, *systematics_list.ttj_syst_args)

            # ======================================================================
            # All channels
            #self.cb.cp().process(["ZTT"]).AddSyst(self.cb, "ZTT_uniform_2", "lnU", ch.SystMap()(2.0))

            # lumi
            self.cb.cp().process(["ZTT", "ZLL", "ZL", "ZJ", "TT", "VV"
                                  ]).AddSyst(self.cb,
                                             *systematics_list.lumi_syst_args)

            # cross section
            self.cb.cp().process(["VV"]).AddSyst(
                self.cb, *systematics_list.vv_cross_section_syst_args)
            self.cb.cp().process(["TT"]).AddSyst(
                self.cb, *systematics_list.ttj_cross_section_syst_args)
            self.cb.cp().process(["W"]).AddSyst(
                self.cb, *systematics_list.wj_cross_section_syst_args)

            # signal acceptance/efficiency
            self.cb.cp().process(["ZTT"]).AddSyst(
                self.cb, *systematics_list.ztt_pdf_scale_syst_args)
            self.cb.cp().process(["ZTT"]).AddSyst(
                self.cb, *systematics_list.ztt_qcd_scale_syst_args)

            # QCD systematic
            self.cb.cp().process(["QCD"
                                  ]).AddSyst(self.cb,
                                             *systematics_list.qcd_syst_args)

            if log.isEnabledFor(logging.DEBUG):
                self.cb.PrintAll()
コード例 #8
0
    def __init__(self, cb=None):
        super(ZttPolarisationDatacards, self).__init__(cb)

        if cb is None:

            systematics_library = systematics_libary.SystematicLibary()

            # ======================================================================
            # MT channel
            self.add_processes(
                channel="mt",
                categories=[
                    "mt_" + category for category in ["rho", "oneprong"]
                ],  # "a1"
                bkg_processes=["ZL", "ZJ", "TT", "VV", "W", "QCD"],
                sig_processes=["ZTTPOSPOL", "ZTTNEGPOL"],
                analysis=["ztt"],
                era=["13TeV"],
                mass=["0"])

            # efficiencies
            self.cb.cp().channel(["mt"]).process([
                "ZTTPOSPOL", "ZTTNEGPOL", "ZL", "ZJ", "TT", "VV"
            ]).AddSyst(self.cb, *systematics_library.muon_efficiency_syst_args)

            self.cb.cp().channel(["mt"]).process([
                "ZTTPOSPOL", "ZTTNEGPOL"
            ]).AddSyst(self.cb,
                       *systematics_library.tau_efficiency_corr_syst_args)
            self.cb.cp().channel(["mt"]).process(
                ["ZTTPOSPOL",
                 "ZTTNEGPOL"]).AddSyst(self.cb,
                                       *systematics_library.tau_es_syst_args)
            #self.cb.cp().channel(["mt"]).process(["ZTTPOSPOL", "ZTTNEGPOL"]).AddSyst(self.cb, *systematics_library.tau_efficiency_syst_args)

            # from Yuta
            self.cb.cp().channel(["mt"]).process(["ZL", "ZJ", "W"]).AddSyst(
                self.cb, *systematics_library.boson_scale_met_syst_args)
            self.cb.cp().channel(["mt"]).process(["ZL", "ZJ", "W"]).AddSyst(
                self.cb, *systematics_library.boson_resolution_met_syst_args)
            self.cb.cp().channel(["mt"]).process(["TT", "VV"]).AddSyst(
                self.cb, *systematics_library.ewk_top_scale_met_syst_args)
            self.cb.cp().channel(["mt"]).process(["TT", "VV"]).AddSyst(
                self.cb, *systematics_library.ewk_top_resolution_met_syst_args)

            # extrapolation uncertainty
            self.cb.cp().channel(["mt"]).process(["TT"]).AddSyst(
                self.cb, *systematics_library.ttj_extrapol_syst_args)
            self.cb.cp().channel(["mt"]).process(["W"]).AddSyst(
                self.cb, *systematics_library.wj_extrapol_syst_args)

            # Tau ES
            self.cb.cp().channel(["mt"]).process(
                ["ZTTPOSPOL",
                 "ZTTNEGPOL"]).AddSyst(self.cb,
                                       *systematics_library.tau_es_syst_args)

            # fake-rate
            self.cb.cp().channel(["mt"]).process(["ZL"]).AddSyst(
                self.cb, *systematics_library.eFakeTau_vloose_syst_args)
            self.cb.cp().channel(["mt"]).process(["ZL"]).AddSyst(
                self.cb, *systematics_library.muFakeTau_syst_args)
            self.cb.cp().channel(["mt"]).process(["ZJ"]).AddSyst(
                self.cb, *systematics_library.zjFakeTau_syst_args)

            # Top pT reweight
            #self.cb.cp().channel(["mt"]).process(["TT"]).AddSyst(self.cb, *systematics_library.ttj_syst_args)

            # ======================================================================
            # ET channel
            self.add_processes(
                channel="et",
                categories=[
                    "et_" + category for category in ["rho", "oneprong"]
                ],  # "a1"
                bkg_processes=["ZL", "ZJ", "TT", "VV", "W", "QCD"],
                sig_processes=["ZTTPOSPOL", "ZTTNEGPOL"],
                analysis=["ztt"],
                era=["13TeV"],
                mass=["0"])

            # efficiencies
            self.cb.cp().channel(["et"]).process([
                "ZTTPOSPOL", "ZTTNEGPOL", "ZL", "ZJ", "TT", "VV"
            ]).AddSyst(self.cb,
                       *systematics_library.electron_efficiency_syst_args)

            self.cb.cp().channel(["et"]).process([
                "ZTTPOSPOL", "ZTTNEGPOL"
            ]).AddSyst(self.cb,
                       *systematics_library.tau_efficiency_corr_syst_args)
            self.cb.cp().channel(["et"]).process(
                ["ZTTPOSPOL",
                 "ZTTNEGPOL"]).AddSyst(self.cb,
                                       *systematics_library.tau_es_syst_args)
            #self.cb.cp().channel(["et"]).process(["ZTTPOSPOL", "ZTTNEGPOL"]).AddSyst(self.cb, *systematics_library.tau_efficiency_syst_args)

            # from Yuta
            self.cb.cp().channel(["et"]).process(["ZL", "ZJ", "W"]).AddSyst(
                self.cb, *systematics_library.boson_scale_met_syst_args)
            self.cb.cp().channel(["et"]).process(["ZL", "ZJ", "W"]).AddSyst(
                self.cb, *systematics_library.boson_resolution_met_syst_args)
            self.cb.cp().channel(["et"]).process(["TT", "VV"]).AddSyst(
                self.cb, *systematics_library.ewk_top_scale_met_syst_args)
            self.cb.cp().channel(["et"]).process(["TT", "VV"]).AddSyst(
                self.cb, *systematics_library.ewk_top_resolution_met_syst_args)

            # extrapolation uncertainty
            self.cb.cp().channel(["et"]).process(["TT"]).AddSyst(
                self.cb, *systematics_library.ttj_extrapol_syst_args)
            self.cb.cp().channel(["et"]).process(["W"]).AddSyst(
                self.cb, *systematics_library.wj_extrapol_syst_args)

            # Tau ES
            self.cb.cp().channel(["et"]).process(
                ["ZTTPOSPOL",
                 "ZTTNEGPOL"]).AddSyst(self.cb,
                                       *systematics_library.tau_es_syst_args)

            # fake-rate
            self.cb.cp().channel(["et"]).process(["ZL"]).AddSyst(
                self.cb, *systematics_library.eFakeTau_tight_syst_args)
            self.cb.cp().channel(["et"]).process(["ZL"]).AddSyst(
                self.cb, *systematics_library.muFakeTau_syst_args)
            self.cb.cp().channel(["et"]).process(["ZJ"]).AddSyst(
                self.cb, *systematics_library.zjFakeTau_syst_args)

            # Top pT reweight
            #self.cb.cp().channel(["et"]).process(["TT"]).AddSyst(self.cb, *systematics_library.ttj_syst_args)

            # ======================================================================
            # TT channel
            self.add_processes(
                channel="tt",
                categories=[
                    "tt_" + category for category in [
                        "rho", "rho_1", "rho_2", "oneprong",
                        "combined_oneprong_oneprong", "combined_rho_rho"
                    ]
                ],  # "a1"
                bkg_processes=["ZL", "ZJ", "TT", "VV", "W", "QCD"],
                sig_processes=["ZTTPOSPOL", "ZTTNEGPOL"],
                analysis=["ztt"],
                era=["13TeV"],
                mass=["0"])

            # efficiencies
            self.cb.cp().channel(["tt"]).process([
                "ZTTPOSPOL", "ZTTNEGPOL"
            ]).AddSyst(self.cb,
                       *systematics_library.tau_efficiency_corr_syst_args)
            self.cb.cp().channel(["tt"]).process(
                ["ZTTPOSPOL",
                 "ZTTNEGPOL"]).AddSyst(self.cb,
                                       *systematics_library.tau_es_syst_args)
            #self.cb.cp().channel(["tt"]).process(["ZTTPOSPOL", "ZTTNEGPOL"]).AddSyst(self.cb, *systematics_library.tau_efficiency_syst_args)

            # from Yuta
            self.cb.cp().channel(["tt"]).process(["ZL", "ZJ", "W"]).AddSyst(
                self.cb, *systematics_library.boson_scale_met_syst_args)
            self.cb.cp().channel(["tt"]).process(["ZL", "ZJ", "W"]).AddSyst(
                self.cb, *systematics_library.boson_resolution_met_syst_args)
            self.cb.cp().channel(["tt"]).process(["TT", "VV"]).AddSyst(
                self.cb, *systematics_library.ewk_top_scale_met_syst_args)
            self.cb.cp().channel(["tt"]).process(["TT", "VV"]).AddSyst(
                self.cb, *systematics_library.ewk_top_resolution_met_syst_args)

            # extrapolation uncertainty
            self.cb.cp().channel(["mt"]).process(["TT"]).AddSyst(
                self.cb, *systematics_library.ttj_extrapol_syst_args)
            self.cb.cp().channel(["tt"]).process(["W"]).AddSyst(
                self.cb, *systematics_library.wj_extrapol_syst_args)

            # Tau ES
            self.cb.cp().channel(["tt"]).process(
                ["ZTTPOSPOL",
                 "ZTTNEGPOL"]).AddSyst(self.cb,
                                       *systematics_library.tau_es_syst_args)

            # fake-rate
            self.cb.cp().channel(["tt"]).process(["ZL"]).AddSyst(
                self.cb, *systematics_library.eFakeTau_tight_syst_args)
            self.cb.cp().channel(["tt"]).process(["ZL"]).AddSyst(
                self.cb, *systematics_library.muFakeTau_syst_args)
            self.cb.cp().channel(["tt"]).process(["ZJ"]).AddSyst(
                self.cb, *systematics_library.zjFakeTau_syst_args)

            # Top pT reweight
            #self.cb.cp().channel(["tt"]).process(["TT"]).AddSyst(self.cb, *systematics_library.ttj_syst_args)

            # ======================================================================
            # EM channel
            self.add_processes(
                channel="em",
                categories=["em_" + category for category in ["oneprong"]],
                bkg_processes=["ZL", "ZJ", "TT", "VV", "W", "QCD"],
                sig_processes=["ZTTPOSPOL", "ZTTNEGPOL"],
                analysis=["ztt"],
                era=["13TeV"],
                mass=["0"])

            # efficiencies
            self.cb.cp().channel(["em"]).process([
                "ZTTPOSPOL", "ZTTNEGPOL", "ZL", "ZJ", "TT", "VV"
            ]).AddSyst(self.cb,
                       *systematics_library.electron_efficiency_syst_args)
            self.cb.cp().channel(["em"]).process([
                "ZTTPOSPOL", "ZTTNEGPOL", "ZL", "ZJ", "TT", "VV"
            ]).AddSyst(self.cb, *systematics_library.muon_efficiency_syst_args)

            # from Yuta
            self.cb.cp().channel(["em"]).process(["ZL", "ZJ", "W"]).AddSyst(
                self.cb, *systematics_library.boson_scale_met_syst_args)
            self.cb.cp().channel(["em"]).process(["ZL", "ZJ", "W"]).AddSyst(
                self.cb, *systematics_library.boson_resolution_met_syst_args)
            self.cb.cp().channel(["em"]).process(["TT", "VV"]).AddSyst(
                self.cb, *systematics_library.ewk_top_scale_met_syst_args)
            self.cb.cp().channel(["em"]).process(["TT", "VV"]).AddSyst(
                self.cb, *systematics_library.ewk_top_resolution_met_syst_args)

            # extrapolation uncertainty
            self.cb.cp().channel(["em"]).process(["TT"]).AddSyst(
                self.cb, *systematics_library.ttj_extrapol_syst_args)
            self.cb.cp().channel(["em"]).process(["W"]).AddSyst(
                self.cb, *systematics_library.wj_extrapol_syst_args)

            # Top pT reweight
            #self.cb.cp().channel(["em"]).process(["TT"]).AddSyst(self.cb, *systematics_library.ttj_syst_args)

            # ======================================================================
            # All channels
            #self.cb.cp().process(["ZTTPOSPOL", "ZTTNEGPOL"]).AddSyst(self.cb, "ZTTPOSPOL_uniform_2", "ZTTNEGPOL_uniform_2", "lnU", ch.SystMap()(2.0))

            # lumi
            self.cb.cp().process(
                ["ZTTPOSPOL", "ZTTNEGPOL", "ZL", "ZJ", "TT",
                 "VV"]).AddSyst(self.cb, *systematics_library.lumi_syst_args)

            # cross section
            self.cb.cp().process([
                "ZTTPOSPOL", "ZTTNEGPOL", "ZL", "ZJ"
            ]).AddSyst(self.cb,
                       *systematics_library.zll_cross_section_syst_args)
            self.cb.cp().process(["VV"]).AddSyst(
                self.cb, *systematics_library.vv_cross_section_syst_args)
            self.cb.cp().process(["TT"]).AddSyst(
                self.cb, *systematics_library.ttj_cross_section_syst_args)
            self.cb.cp().process(["W"]).AddSyst(
                self.cb, *systematics_library.wj_cross_section_syst_args)

            # signal acceptance/efficiency
            self.cb.cp().process(["ZTTPOSPOL", "ZTTNEGPOL"]).AddSyst(
                self.cb, *systematics_library.ztt_pdf_scale_syst_args)
            self.cb.cp().process(["ZTTPOSPOL", "ZTTNEGPOL"]).AddSyst(
                self.cb, *systematics_library.ztt_qcd_scale_syst_args)

            # QCD systematic
            self.cb.cp().process(["QCD"]).AddSyst(
                self.cb, *systematics_library.qcd_syst_inclusive_args)

            # ======================================================================
            # Groups of systematics
            self.cb.SetGroup("syst", [".*"])

            if log.isEnabledFor(logging.DEBUG):
                self.cb.PrintAll()
コード例 #9
0
    def __init__(self,
                 quantity="m_vis",
                 year="",
                 mapping_category2binid=None,
                 cb=None):
        super(QcdFactorsDatacards, self).__init__(cb)

        if mapping_category2binid is not None:
            self.configs._mapping_category2binid.update(mapping_category2binid)

    ##Generate instance of systematic libary, in which the relevant information about the systematics are safed

        systematics_list = SystLib.SystematicLibary()

        all_mc_bkgs = ["ZTT", "ZL", "ZJ", "TTT", "TTJJ", "VVT", "VVJ", "W"]
        all_mc_bkgs_no_W = ["ZTT", "ZL", "ZJ", "TTT", "TTJJ", "VVT", "VVJ"
                            ]  #don't no whether this is still needed here...
        signal_processes = ["QCD"]
        categories_for_SSOS_factor_estimation = [
            channel + "_" + bin for channel in ["et", "mt"] for bin in
            ["ZeroJet2D", "Boosted2D", "dijet2D_lowboost", "dijet2D_boosted"]
        ]

        if cb is None:
            # ======================================================================
            # MT channel
            self.add_processes(
                channel="mt",
                categories=categories_for_SSOS_factor_estimation,
                bkg_processes=all_mc_bkgs,
                sig_processes=signal_processes,
                analysis=["htt"],
                era=["13TeV"],
                mass="125")

            # efficiencies
            if year == "2016":
                self.cb.cp().channel(["mt"]).process(all_mc_bkgs_no_W).AddSyst(
                    self.cb,
                    *systematics_list.trigger_efficiency2016_syst_args)
                self.cb.cp().channel(["mt"]).process(all_mc_bkgs).AddSyst(
                    self.cb, *systematics_list.muon_efficiency2016_syst_args)
                self.cb.cp().channel(["mt"]).process([
                    "ZTT", "TTT", "VVT"
                ]).AddSyst(self.cb,
                           *systematics_list.tau_efficiency2016_syst_args)
                self.cb.cp().channel(["mt"]).process(
                    ["ZTT", "TTT",
                     "VVT"]).AddSyst(self.cb,
                                     *systematics_list.tau_es_syst_args)
                self.cb.cp().channel(["mt"]).process(["ZL"]).AddSyst(
                    self.cb, *systematics_list.muFakeTau_tight_syst_args)

            # mu->tau fake ES (only for 1-prongs and 1-prong+Pi0s)
            # self.cb.cp().channel(["mt"]).process(["ZL"]).bin(categoriesForMuFakeTauES).AddSyst(self.cb, *systematics_list.muFakeTau_es_syst_args)

            # fake-rate
            # if year == "2016":
            # 	self.cb.cp().channel(["mt"]).process(["ZL"]).bin(categoriesForMuFakeTauES).AddSyst(self.cb, *systematics_list.muFakeTau2016_syst_args)

            # ======================================================================
            # ET channel
            self.add_processes(
                channel="et",
                categories=categories_for_SSOS_factor_estimation,
                bkg_processes=all_mc_bkgs,
                sig_processes=signal_processes,
                analysis=["htt"],
                era=["13TeV"],
                mass="125")

            # efficiencies
            if year == "2016":
                self.cb.cp().channel(["et"]).process(all_mc_bkgs_no_W).AddSyst(
                    self.cb,
                    *systematics_list.trigger_efficiency2016_syst_args)
                self.cb.cp().channel(["et"]).process(all_mc_bkgs_no_W).AddSyst(
                    self.cb,
                    *systematics_list.electron_efficiency2016_syst_args)
                self.cb.cp().channel(["et"]).process([
                    "ZTT", "TTT", "VVT"
                ]).AddSyst(self.cb,
                           *systematics_list.tau_efficiency2016_syst_args)

            # e->tau fake
            self.cb.cp().channel(["et"]).AddSyst(
                self.cb, *systematics_list.eleFakeTau_es_syst_args)
            self.cb.cp().channel(["et"]).AddSyst(
                self.cb, *systematics_list.eFakeTau_1prong_syst_args)
            self.cb.cp().channel(["et"]).AddSyst(
                self.cb, *systematics_list.eFakeTau_1prong1pizero_syst_args)
            self.cb.cp().channel(["et"]).AddSyst(
                self.cb, *systematics_list.eleFakeTau_es_syst_args)

            # fake-rate
            if year == "2016":
                self.cb.cp().channel(["et"]).process(["ZL"]).AddSyst(
                    self.cb, *systematics_list.eFakeTau2016_syst_args)
                self.cb.cp().channel(["et"]).process(["ZL"]).AddSyst(
                    self.cb, *systematics_list.eFakeTau_tight_syst_args)

            # ======================================================================
            # All channels

            # lumi
            # (hopefully) temporary fix
            if year == "2016":
                self.cb.cp().process(all_mc_bkgs_no_W).AddSyst(
                    self.cb, *systematics_list.lumi2016_syst_args)

            # cross section
            self.cb.cp().process(["ZTT", "ZLL", "ZL", "ZJ"]).AddSyst(
                self.cb, *systematics_list.ztt_cross_section_syst_args)
            if year == "2016":
                self.cb.cp().process(["VVT", "VVJ"]).AddSyst(
                    self.cb, *systematics_list.vv_cross_section2016_syst_args)
            self.cb.cp().process(["TTT", "TTJJ"]).AddSyst(
                self.cb, *systematics_list.ttj_cross_section_syst_args)
            self.cb.cp().process(["W"]).AddSyst(
                self.cb, *systematics_list.wj_cross_section_syst_args)

            # Normalizations
            self.cb.cp().process(["W"]).AddSyst(
                self.cb, *systematics_list.htt_wnorm_syst_args)
            self.cb.cp().process(["TTT", "TTJ"]).AddSyst(
                self.cb, *systematics_list.htt_ttnorm_syst_args)
            self.cb.cp().process(["VVJ", "VVT"]).AddSyst(
                self.cb, *systematics_list.htt_vvnorm_syst_args)

            # signal acceptance/efficiency
            self.cb.cp().process(["ZTT"]).AddSyst(
                self.cb, *systematics_list.ztt_pdf_scale_syst_args)
            self.cb.cp().process(["ZTT"]).AddSyst(
                self.cb, *systematics_list.ztt_qcd_scale_syst_args)

            # W+jets high->low mt extrapolation uncertainty
            self.cb.cp().channel(["mt", "et"]).process(["W"]).AddSyst(
                self.cb, "WHighMTtoLowMT_13TeV", "lnN",
                ch.SystMap()(1.10))

            if year == "2016":
                self.cb.cp().channel(["mt", "et"]).process([
                    "ZTT", "TTT", "VVT"
                ]).AddSyst(self.cb,
                           *systematics_list.tau_efficiency2016_corr_syst_args)

            # jet->tau fakes
            if year == "2016":
                self.cb.cp().channel(["mt", "et"]).process([
                    "ZJ", "TTJJ", "VVJ"
                ]).AddSyst(self.cb, "CMS_htt_jetToTauFake_13TeV", "shape",
                           ch.SystMap()(1.0))

            if log.isEnabledFor(logging.DEBUG):
                self.cb.PrintAll()
コード例 #10
0
def create_datacards(channel, method):
    backgrounds = {"ZTT": "ztt", "VV": "vv", "W": "wj", "QCD": "qcd"}
    backgrounds.update({
        "TT": "ttj",
        "ZLL": "zll"
    } if channel == "em" else {
        "TTT": "ttt",
        "TTJJ": "ttjj",
        "ZL": "zl",
        "ZJ": "zj"
    })

    ##Combine harvester instance
    cb = ch.CombineHarvester()

    #Instance for extracting histograms
    sample_settings = samples.Samples()
    config_list = []

    ##weights
    cut_info = yaml.load(
        open(os.environ["CMSSW_BASE"] + "/src/FlavioOutput/Configs/cuts.yaml",
             "r"))
    parameter_info = yaml.load(
        open(
            os.environ["CMSSW_BASE"] +
            "/src/FlavioOutput/Configs/parameter.yaml", "r"))

    weights = []

    for index, category in enumerate(
        ["(njetspt30==0)", "(njetspt30==1)",
         "(njetspt30>1)"]):  #, "(nbtag==2)"]):
        #cut_strings = [parameter_info[param][4] for param in cut_info[index][channel].keys()]
        #cut_values, cut_side = [[entry[index2] for entry in cut_info[index][channel].values()] for index2 in [0,1]]

        weights.append(
            {  #"cut_based":	"*".join([cut_strings[index2].format(side = side, cut = value) for index2, (side, value) in enumerate(zip(cut_side, cut_values))] + [category]),
                "cut_BDT": "(BDT_forcut_score>0.7)*" + category,
                "cut_Ada_BDT": "(BDT_Ada_forcut_score>0.0)*" + category,
                "BDT": category,
                "Ada_BDT": category
            })

    ##Fill combine harvester with categories/processes
    for category in categories + controlregions:
        ##Add data/signal
        cb.AddObservations(["*"], ["lfv"], ["13TeV"], [channel], [category])

        if not "CR" in category[1]:
            cb.AddProcesses(["*"], ["lfv"], ["13TeV"], [channel],
                            ["Z" + channel.upper()], [category], True)

        ##Config for each category
        config = sample_settings.get_config(
            [
                getattr(samples.Samples, sample)
                for sample in data.values() + {
                    True: ["z" + channel],
                    False: []
                }["CR" not in category[1]] + backgrounds.values()
            ],
            channel,
            None,
            estimationMethod="new",
            weight=weights[category[0]][method])
        config.pop("legend_markers")
        config += {
            "filename": "input_" + method + "_nominal_" + category[1],
            "plot_modules": ["ExportRoot"],
            "file_mode": "UPDATE",
            "directories": os.environ["MCPATH"],
            "x_expressions": x[method],
            "x_bins": x_bins[method],
            "output_dir": output_dir + channel,
            "no_cache": True
        }
        config["labels"] = [
            category[1] + "/" + process for process in data.keys() + {
                True: ["Z" + channel.upper()],
                False: []
            }["CR" not in category[1]] + backgrounds.keys()
        ]
        config_list.append(config)

        for process in backgrounds.keys():
            ##Add background
            cb.AddProcesses(["*"], ["lfv"], ["13TeV"], [channel], [process],
                            [category], False)

    ##Fill combine with control regions
    for CR in controlregions:
        cb.cp().channel([channel]).bin([category[1]]).AddSyst(
            cb, "scale_" + category[1].remove("_CR"), "rateParam",
            ch.SystMap())

        for category in catogories:
            cb.cp().bin([category[0]
                         ]).AddSyst(cb, "scale_" + category[1].remove("_CR"),
                                    "rateParam", ch.SystMapFunc())

    ##Fill combine harvester with systematics
    systematics_list = SystLib.SystematicLibary()
    systematics_factory = systematics.SystematicsFactory()

    for (systematic, process, category) in systematics_list.get_LFV_systs(
            channel, lnN=True) + systematics_list.get_LFV_systs(channel,
                                                                shape=True):
        cb.cp().channel([channel]).process(process).AddSyst(cb, *systematic)

        if "W" in process and "QCD" not in process:
            process.append("QCD")

        if "QCD" in process and "W" not in process:
            process.append("W")

        if systematic[1] == "shape":
            ##Config for each systematic shift:
            for category in categories + controlregions:

                if "CR" in category[1] and "Z" + channel.upper() in process:
                    process.remove("Z" + channel.upper())

                for shift in ["Down", "Up"]:
                    config = sample_settings.get_config(
                        [
                            getattr(samples.Samples,
                                    dict(signals, **backgrounds)[sample])
                            for sample in process
                        ],
                        channel,
                        None,
                        estimationMethod="new",
                        weight=weights[category[0]][method])
                    config.pop("legend_markers")
                    config += {
                        "filename":
                        "input_" + method + "_" + systematic[0].replace(
                            "$ERA", "13TeV").replace("$CHANNEL", channel) +
                        shift + "_" + category[1],
                        "plot_modules": ["ExportRoot"],
                        "file_mode":
                        "UPDATE",
                        "directories":
                        os.environ["MCPATH"],
                        "x_expressions":
                        x[method],
                        "x_bins":
                        x_bins[method],
                        "output_dir":
                        output_dir + channel,
                        "no_cache":
                        True
                    }
                    config["labels"] = [
                        category[1] + "/" + proc + "_" + systematic[0].replace(
                            "$ERA", "13TeV").replace("$CHANNEL", channel) +
                        shift for proc in process
                    ]

                    if systematic[0].replace("$ERA", "13TeV").replace(
                            "$CHANNEL", channel) == "CMS_scale_j_13TeV":
                        systematics_settings = systematics_factory.get(
                            systematic[0].replace("$ERA", "13TeV").replace(
                                "$CHANNEL", channel))(config, "Total")

                    else:
                        systematics_settings = systematics_factory.get(
                            systematic[0].replace("$ERA", "13TeV").replace(
                                "$CHANNEL", channel))(config)

                    config = systematics_settings.get_config(1 if shift ==
                                                             "Up" else -1)
                    config_list.append(config)

    pool = Pool(cpu_count())
    for config in config_list:
        pool.apply_async(harry_do_your_job, args=(config, ))

    pool.close()
    pool.join()

    os.system("hadd {target}.root {root_files}*.root".format(
        target=output_dir + channel + "/input_" + method,
        root_files=output_dir + channel + "/input_" + method))

    ##Fill combine harvester with the shapes which were extracted before from harry.py
    cb.cp().backgrounds().ExtractShapes(
        output_dir + channel + "/input_" + method + ".root", "$BIN/$PROCESS",
        "$BIN/$PROCESS_$SYSTEMATIC")
    cb.cp().signals().ExtractShapes(
        output_dir + channel + "/input_" + method + ".root", "$BIN/$PROCESS",
        "$BIN/$PROCESS_$SYSTEMATIC")

    #Write datacard and call combine
    cb.WriteDatacard(
        output_dir + channel + "/combined_" + method + ".txt",
        output_dir + channel + "/combined_datacard_" + method + ".root")

    for category in categories:
        cb_copy = cb.cp()
        cb_copy.FilterAll(lambda obj: obj.bin() != category[1])
        cb_copy.WriteDatacard(
            output_dir + channel + "/" + category[1] + "_" + method + ".txt",
            output_dir + channel + "/" + category[1] + "_datacard_" + method +
            ".root")