Skip to content

Commit

Permalink
Merge branch 'feature/egamma_smearing_and_res' of github.com:uhh-cms/…
Browse files Browse the repository at this point in the history
…hh2bbtautau into feature/egamma_smearing_and_res
  • Loading branch information
Bogdan-Wiederspan committed Jan 23, 2025
2 parents 6bc538e + 420a9a1 commit cb5ba42
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 39 deletions.
39 changes: 1 addition & 38 deletions hbt/calibration/default.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
from columnflow.calibration.cms.met import met_phi
from columnflow.calibration.cms.jets import jec, jec_nominal, jer
from columnflow.calibration.cms.tau import tec, tec_nominal
from columnflow.calibration.cms.egamma import pec, per, eer, eec
from columnflow.calibration.cms.egamma import eer, eec
from columnflow.production.cms.mc_weight import mc_weight
from columnflow.production.cms.supercluster_eta import photon_sceta, electron_sceta
from columnflow.production.cms.seeds import (
Expand Down Expand Up @@ -39,7 +39,6 @@
mc_weight, custom_deterministic_event_seeds, deterministic_jet_seeds,
deterministic_photon_seeds, deterministic_electron_seeds,
photon_sceta, electron_sceta,
"Electron.mass",
},
produces={
mc_weight, custom_deterministic_event_seeds, deterministic_jet_seeds,
Expand All @@ -56,14 +55,8 @@ def default(self: Calibrator, events: ak.Array, **kwargs) -> ak.Array:
# !! so no manual sorting needed here (but necessary if, e.g., jec is applied before)
events = self[custom_deterministic_event_seeds](events, **kwargs)
events = self[deterministic_jet_seeds](events, **kwargs)
events = self[deterministic_photon_seeds](events, **kwargs)
events = self[deterministic_electron_seeds](events, **kwargs)

# superclusterEta is only available for nanoAOD v14 and later
# otherwise, calculate it by hand
if self.config_inst.campaign.x.version <= 14:
events = self[photon_sceta](events, **kwargs)

events = self[electron_sceta](events, **kwargs)
if self.dataset_inst.is_data or not self.global_shift_inst.is_nominal:
events = self[self.jec_nominal_cls](events, **kwargs)
Expand All @@ -72,19 +65,15 @@ def default(self: Calibrator, events: ak.Array, **kwargs) -> ak.Array:
# and will only execute something if it's data
if self.dataset_inst.is_data:
events = self[self.electron_scale_nominal_cls](events, **kwargs)
events = self[self.photon_scale_nominal_cls](events, **kwargs)
else:
events = self[self.electron_res_nominal_cls](events, **kwargs)
events = self[self.photon_res_nominal_cls](events, **kwargs)
else:
events = self[self.jec_full_cls](events, **kwargs)
events = self[self.deterministic_jer_cls](events, **kwargs)
# in this block, we are in the nominal case in MC

events = self[self.electron_res_cls](events, **kwargs)
events = self[self.electron_scale_cls](events, **kwargs)
events = self[self.photon_res_cls](events, **kwargs)
events = self[self.photon_scale_cls](events, **kwargs)

if self.config_inst.campaign.x.run == 2:
events = self[self.met_phi_cls](events, **kwargs)
Expand Down Expand Up @@ -153,24 +142,6 @@ def default_init(self: Calibrator) -> None:
"with_uncertainties": False,
})

# derive electron scale calibrators
self.config_inst.x.calib_photon_scale_cls = pec.derive("pec_full", cls_dict={
})

self.config_inst.x.calib_photon_scale_nominal_cls = pec.derive("pec_nominal", cls_dict={
"with_uncertainties": False,
})

# derive photon resolution calibrator
self.config_inst.x.calib_photon_res_cls = per.derive("per_full", cls_dict={
"deterministic_seed_index": 0,
})

self.config_inst.x.calib_photon_res_nominal_cls = per.derive("per_nominal", cls_dict={
"deterministic_seed_index": 0,
"with_uncertainties": False,
})

# change the flag
self.config_inst.set_aux(flag, True)

Expand All @@ -184,10 +155,6 @@ def default_init(self: Calibrator) -> None:
self.electron_scale_nominal_cls = self.config_inst.x.calib_electron_scale_nominal_cls
self.electron_res_cls = self.config_inst.x.calib_electron_res_cls
self.electron_res_nominal_cls = self.config_inst.x.calib_electron_res_nominal_cls
self.photon_scale_cls = self.config_inst.x.calib_photon_scale_cls
self.photon_scale_nominal_cls = self.config_inst.x.calib_photon_scale_nominal_cls
self.photon_res_cls = self.config_inst.x.calib_photon_res_cls
self.photon_res_nominal_cls = self.config_inst.x.calib_photon_res_nominal_cls

# collect derived calibrators and add them to the calibrator uses and produces
derived_calibrators = {
Expand All @@ -201,10 +168,6 @@ def default_init(self: Calibrator) -> None:
self.electron_scale_nominal_cls,
self.electron_res_cls,
self.electron_res_nominal_cls,
self.photon_scale_cls,
self.photon_scale_nominal_cls,
self.photon_res_cls,
self.photon_res_nominal_cls,
}
self.uses |= derived_calibrators
self.produces |= derived_calibrators

0 comments on commit cb5ba42

Please sign in to comment.