Commit 81f143e9 authored by Dennis Noll's avatar Dennis Noll
Browse files

[recipes] tth: lepton sf - now also use tth tight

renaming commented until confirmation from torben

three different lepton sf:
- id+loose tth
- loose tth to tight tth
- tight tth to relaxed tth
parent e9ece4c2
......@@ -25,14 +25,16 @@ btagWeight_lf=CMS_btag_LF_2016_2017_2018
btagWeight_lfstats1=CMS_btag_lfstats1_2016
btagWeight_lfstats2=CMS_btag_lfstats2_2016
btagWeight_subjet=CMS_btag_subjet_2016
electron_id_loose=CMS_eff_e_2016
electron_tth_loose=CMS_ttHID_eff_e_loose_2016
#electron_id_loose=CMS_ttHID_reco_e_2016
#electron_tth_tight=CMS_ttHID_eff_e_tight_2016
#electron_tth_relaxed=CMS_ttHID_eff_e_loose_2016
jer=CMS_res_j_2016
jet_PUid_efficiency=CMS_eff_j_PUJET_id_2016
jet_PUid_mistag=CMS_eff_j_PUJET_mistag_2016
l1_ecal_prefiring=CMS_l1_ecal_prefiring_2016
muon_idiso_loose=CMS_eff_m_2016
muon_tth_loose=CMS_ttHID_eff_m_loose_2016
#muon_idiso_loose=CMS_eff_m_2016
#muon_tth_tight=CMS_ttHID_eff_m_tight_2016
#muon_tth_relaxed=CMS_ttHID_eff_m_loose_2016
pileup=CMS_pileup_2016
top_pT_reweighting=CMS_top_pT_reweighting
trigger_muon_sf=CMS_bbww_sl_TriggerWeight_mu_2016
......
......@@ -25,14 +25,16 @@ btagWeight_lf=CMS_btag_LF_2016_2017_2018
btagWeight_lfstats1=CMS_btag_lfstats1_2017
btagWeight_lfstats2=CMS_btag_lfstats2_2017
btagWeight_subjet=CMS_btag_subjet_2017
electron_id_loose=CMS_eff_e_2017
electron_tth_loose=CMS_ttHID_eff_e_loose_2017
#electron_id_loose=CMS_ttHID_reco_e_2017
#electron_tth_tight=CMS_ttHID_eff_e_tight_2017
#electron_tth_relaxed=CMS_ttHID_eff_e_loose_2017
jer=CMS_res_j_2017
jet_PUid_efficiency=CMS_eff_j_PUJET_id_2017
jet_PUid_mistag=CMS_eff_j_PUJET_mistag_2017
l1_ecal_prefiring=CMS_l1_ecal_prefiring_2017
muon_idiso_loose=CMS_eff_m_2017
muon_tth_loose=CMS_ttHID_eff_m_loose_2017
#muon_idiso_loose=CMS_eff_m_2017
#muon_tth_tight=CMS_ttHID_eff_m_tight_2017
#muon_tth_relaxed=CMS_ttHID_eff_m_loose_2017
pileup=CMS_pileup_2017
top_pT_reweighting=CMS_top_pT_reweighting
trigger_muon_sf=CMS_bbww_sl_TriggerWeight_mu_2017
......
......@@ -25,14 +25,16 @@ btagWeight_hfstats2=CMS_btag_hfstats2_2018
btagWeight_lf=CMS_btag_LF_2016_2017_2018
btagWeight_lfstats1=CMS_btag_lfstats1_2018
btagWeight_lfstats2=CMS_btag_lfstats2_2018
electron_id_loose=CMS_eff_e_2018
electron_tth_loose=CMS_ttHID_eff_e_loose_2018
#electron_id_loose=CMS_ttHID_reco_e_2018
#electron_tth_tight=CMS_ttHID_eff_e_tight_2018
#electron_tth_relaxed=CMS_ttHID_eff_e_loose_2018
jer=CMS_res_j_2018
jet_PUid_efficiency=CMS_eff_j_PUJET_id_2018
jet_PUid_mistag=CMS_eff_j_PUJET_mistag_2018
l1_ecal_prefiring=CMS_l1_ecal_prefiring_2018
muon_idiso_loose=CMS_eff_m_2018
muon_tth_loose=CMS_ttHID_eff_m_loose_2018
#muon_idiso_loose=CMS_eff_m_2018
#muon_tth_tight=CMS_ttHID_eff_m_tight_2018
#muon_tth_relaxed=CMS_ttHID_eff_m_loose_2018
pileup=CMS_pileup_2018
top_pT_reweighting=CMS_top_pT_reweighting
trigger_muon_sf=CMS_bbww_sl_TriggerWeight_mu_2018
......
......@@ -529,21 +529,22 @@ class Base(common.NeutrinoBase, common.Base):
# lepton sf
e_corr = self.corrections["electron"]
mu_corr = self.corrections["muon"]
mask = (abs(lep.pdgId) == 11) & lep.gen_matched
# electrons
# fmt: off
loose_1 = e_corr[f"electron_Tallinn_id_loose_01_EGamma_SF2D"](abs(lep.eta), lep.pt)[mask]
loose_1_err = e_corr[f"electron_Tallinn_id_loose_01_EGamma_SF2D_error"](abs(lep.eta), lep.pt)[mask]
loose_2 = e_corr[f"electron_Tallinn_id_loose_02_EGamma_SF2D"](abs(lep.eta), lep.pt)[mask]
loose_2_err = e_corr[f"electron_Tallinn_id_loose_02_EGamma_SF2D_error"](abs(lep.eta), lep.pt)[mask]
## id and loose tth id
mask = (abs(lep.pdgId) == 11) & lep.gen_matched
loose_1 = e_corr[f"electron_Tallinn_id_loose_01_EGamma_SF2D"](abs(lep.eta), lep.pt)[mask] # using pT
loose_1_err = e_corr[f"electron_Tallinn_id_loose_01_EGamma_SF2D_error"](abs(lep.eta), lep.pt)[mask] # using pT
loose_2 = e_corr[f"electron_Tallinn_id_loose_02_EGamma_SF2D"](abs(lep.eta), lep.pt)[mask] # using pT
loose_2_err = e_corr[f"electron_Tallinn_id_loose_02_EGamma_SF2D_error"](abs(lep.eta), lep.pt)[mask] # using pT
if self.year in ("2016", "2017"):
# for 2016 and 2017 the reco eff is split into a low and high pt region
reco_low = e_corr[f"electron_Tallinn_reco_low_EGamma_SF2D"](lep.eta, lep.pt)[mask & (lep.pt < 20)]
reco_low_err = e_corr[f"electron_Tallinn_reco_low_EGamma_SF2D_error"](lep.eta, lep.pt)[mask & (lep.pt < 20)]
reco_high = e_corr[f"electron_Tallinn_reco_high_EGamma_SF2D"](lep.eta, lep.pt)[mask & (lep.pt >= 20)]
reco_high_err = e_corr[f"electron_Tallinn_reco_high_EGamma_SF2D_error"](lep.eta, lep.pt)[mask & (lep.pt >= 20)]
reco_low = e_corr[f"electron_Tallinn_reco_low_EGamma_SF2D"](lep.eta, lep.pt)[mask & (lep.pt < 20)] # using pT
reco_low_err = e_corr[f"electron_Tallinn_reco_low_EGamma_SF2D_error"](lep.eta, lep.pt)[mask & (lep.pt < 20)] # using pT
reco_high = e_corr[f"electron_Tallinn_reco_high_EGamma_SF2D"](lep.eta, lep.pt)[mask & (lep.pt >= 20)] # using pT
reco_high_err = e_corr[f"electron_Tallinn_reco_high_EGamma_SF2D_error"](lep.eta, lep.pt)[mask & (lep.pt >= 20)] # using pT
electron_id_nom, electron_id_down, electron_id_up = (
reduce(
mul,
......@@ -559,8 +560,8 @@ class Base(common.NeutrinoBase, common.Base):
for sign in (0, -1, +1)
)
elif self.year == "2018":
reco = e_corr[f"electron_Tallinn_reco_EGamma_SF2D"](lep.eta, lep.pt)[mask]
reco_err = e_corr[f"electron_Tallinn_reco_EGamma_SF2D_error"](lep.eta, lep.pt)[mask]
reco = e_corr[f"electron_Tallinn_reco_EGamma_SF2D"](lep.eta, lep.pt)[mask] # using pT
reco_err = e_corr[f"electron_Tallinn_reco_EGamma_SF2D_error"](lep.eta, lep.pt)[mask] # using pT
electron_id_nom, electron_id_down, electron_id_up = (
reduce(
mul,
......@@ -583,45 +584,72 @@ class Base(common.NeutrinoBase, common.Base):
shift=False,
)
# fmt: off
## tight tth id
mask = (abs(lep.pdgId) == 11) & lep.gen_matched & lep.tight_cand
prefix = "electron_Tallinn_tth_loose_EGamma_SF2D"
nominal = ak.prod(e_corr["electron_Tallinn_tth_tight_EGamma_SF2D"](abs(lep.eta), lep.pt)[mask], axis=-1) # using pT
up = ak.prod(e_corr["electron_Tallinn_tth_tight_error_histo_eff_data_max"](abs(lep.eta), lep.pt)[mask], axis=-1) # using pT
down = ak.prod(e_corr["electron_Tallinn_tth_tight_error_histo_eff_data_min"](abs(lep.eta), lep.pt)[mask], axis=-1) # using pT
weights.add(
"electron_tth_loose",
ak.prod(e_corr[f"{prefix}"](abs(lep.eta), lep.pt)[mask], axis=-1),
weightUp=ak.prod(e_corr[f"{prefix}_Up"](abs(lep.eta), lep.pt)[mask], axis=-1),
weightDown=ak.prod(
e_corr[f"{prefix}_Down"](abs(lep.eta), lep.pt)[mask], axis=-1
),
"electron_tth_tight",
nominal,
weightUp=nominal * up,
weightDown=nominal * down,
shift=False,
)
## relaxed tth id
prefix = "electron_Tallinn_tth_relaxed_EGamma_SF2D"
weights.add(
"electron_tth_relaxed",
ak.prod(e_corr[f"{prefix}"](abs(lep.eta), lep.pt)[mask], axis=-1), # using pT
weightUp=ak.prod(e_corr[f"{prefix}_Up"](abs(lep.eta), lep.pt)[mask], axis=-1), # using pT
weightDown=ak.prod(e_corr[f"{prefix}_Down"](abs(lep.eta), lep.pt)[mask], axis=-1), # using pT
)
# fmt: on
# muons
# id&iso
## id&iso
mask = (abs(lep.pdgId) == 13) & lep.gen_matched
prefix = "muon_Tallinn_idiso_loose_EGamma_SF2D"
weights.add(
"muon_idiso_loose",
ak.prod(mu_corr[f"{prefix}"](abs(lep.eta), lep.pt)[mask], axis=-1),
ak.prod(mu_corr[f"{prefix}"](abs(lep.eta), lep.pt)[mask], axis=-1), # using pT
weightUp=ak.where(
ak.any(mask, axis=-1),
ak.prod(mu_corr[f"{prefix}_error"](abs(lep.eta), lep.pt)[mask], axis=-1),
ak.prod(
mu_corr[f"{prefix}_error"](abs(lep.eta), lep.pt)[mask], axis=-1
), # using pT
0,
),
weightDown=None,
shift=True,
)
# loose tth
# fmt: off
## tight tth id
mask = (abs(lep.pdgId) == 13) & lep.gen_matched & lep.tight_cand
prefix = "muon_Tallinn_tth_loose_EGamma_SF2D"
nominal = ak.prod(e_corr["muon_Tallinn_tth_tight_EGamma_SF2D"](abs(lep.eta), lep.pt)[mask], axis=-1) # using pT
up = ak.prod(e_corr["muon_Tallinn_tth_tight_error_histo_eff_data_max"](abs(lep.eta), lep.pt)[mask], axis=-1) # using pT
down = ak.prod(e_corr["muon_Tallinn_tth_tight_error_histo_eff_data_min"](abs(lep.eta), lep.pt)[mask], axis=-1) # using pT
weights.add(
"muon_tth_loose",
ak.prod(mu_corr[f"{prefix}"](abs(lep.eta), lep.pt)[mask], axis=-1),
weightUp=ak.prod(mu_corr[f"{prefix}_Up"](abs(lep.eta), lep.pt)[mask], axis=-1),
weightDown=ak.prod(
mu_corr[f"{prefix}_Down"](abs(lep.eta), lep.pt)[mask], axis=-1
),
"muon_tth_tight",
nominal,
weightUp=nominal * up,
weightDown=nominal * down,
shift=False,
)
## relaxed tth id
prefix = f"muon_Tallinn_tth_relaxed_EGamma_SF2D"
weights.add(
f"muon_tth_relaxed",
ak.prod(mu_corr[f"{prefix}"](abs(lep.eta), lep.pt)[mask], axis=-1), # using pT
weightUp=ak.prod(mu_corr[f"{prefix}_Up"](abs(lep.eta), lep.pt)[mask], axis=-1), # using pT
weightDown=ak.prod(mu_corr[f"{prefix}_Down"](abs(lep.eta), lep.pt)[mask], axis=-1), # using pT
)
# fmt: on
# trigger sf (based on cone_pt)
lep_pt = util.normalize(lep.pt, pad=True)
lep_abseta = np.abs(util.normalize(lep.eta, pad=True))
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment