Skip to content

Commit

Permalink
Added new mechanism to remove fields used for the calibration on the fly
Browse files Browse the repository at this point in the history
  • Loading branch information
Bogdan-Wiederspan committed Dec 4, 2024
1 parent 99f4ce0 commit f5c1293
Showing 1 changed file with 18 additions and 7 deletions.
25 changes: 18 additions & 7 deletions hbt/calibration/default.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
from columnflow.calibration.cms.jets import jec, jec_nominal, jer
from columnflow.calibration.cms.tau import tec, tec_nominal
from columnflow.production.cms.mc_weight import mc_weight
from columnflow.production.cms.seeds import deterministic_seeds
from columnflow.production.cms.seeds import deterministic_event_seeds, deterministic_jet_seeds
from columnflow.util import maybe_import

from hbt.util import IF_RUN_2
Expand All @@ -20,25 +20,36 @@
# derive calibrators to add settings
jec_full = jec.derive("jec_full", cls_dict={"mc_only": True, "nominal_only": True})

# remove GenPart.pt from object_count_columns, this column differs between central and custom Nano

custom_deterministic_event_seeds = deterministic_event_seeds.derive(
"custom_deterministic_event_seeds",
cls_dict={"object_count_columns": [
route for route in deterministic_event_seeds.object_count_columns
if route != "GenPart.pt"
]},

)
# version of jer that uses the first random number from deterministic_seeds
deterministic_jer = jer.derive("deterministic_jer", cls_dict={"deterministic_seed_index": 0})
deterministic_jer = jer.derive("deterministic_jer", cls_dict={"deterministic_seed_index": 1})


@calibrator(
uses={
mc_weight, deterministic_seeds, jec_nominal, jec_full, deterministic_jer, tec_nominal, tec,
IF_RUN_2(met_phi),
mc_weight, custom_deterministic_event_seeds, deterministic_jet_seeds, jec_nominal, jec_full,
deterministic_jer, tec_nominal, tec, IF_RUN_2(met_phi),
},
produces={
mc_weight, deterministic_seeds, jec_nominal, jec_full, deterministic_jer, tec_nominal, tec,
IF_RUN_2(met_phi),
mc_weight, custom_deterministic_event_seeds, deterministic_jet_seeds, jec_nominal, jec_full,
deterministic_jer, tec_nominal, tec, IF_RUN_2(met_phi),
},
)
def default(self: Calibrator, events: ak.Array, **kwargs) -> ak.Array:
if self.dataset_inst.is_mc:
events = self[mc_weight](events, **kwargs)

events = self[deterministic_seeds](events, **kwargs)
events = self[custom_deterministic_event_seeds](events, **kwargs)
events = self[deterministic_jet_seeds](events, **kwargs)
if self.dataset_inst.is_data or not self.global_shift_inst.is_nominal:
events = self[jec_nominal](events, **kwargs)
else:
Expand Down

0 comments on commit f5c1293

Please sign in to comment.