Skip to content

Commit

Permalink
Run 3 Analysis Setup (uhh-cms#19)
Browse files Browse the repository at this point in the history
* added run 3 configs

* adjusted run 2 config for the tau triggers

* turned off `MET_PHI` corrector for run 3

* small changes in the config + new config instance for the custom nanos

* commented out the datasets

* implemented 50% of  Marcel's & Philip's comments

* using campaign.x.run instead of a config tag

* refactored wp from selection, calibration and production

* added 2 alternative triggers for data run 3
  • Loading branch information
haddadanas authored Jun 5, 2024
1 parent 9eec0ec commit 06a024e
Show file tree
Hide file tree
Showing 12 changed files with 1,516 additions and 62 deletions.
10 changes: 7 additions & 3 deletions hbt/calibration/default.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
from columnflow.production.cms.seeds import deterministic_seeds
from columnflow.util import maybe_import

from hbt.util import IF_RUN_2
from hbt.calibration.tau import tec


Expand All @@ -24,10 +25,12 @@

@calibrator(
uses={
mc_weight, jec_nominal, jec_full, jer, tec, deterministic_seeds, met_phi,
mc_weight, jec_nominal, jec_full, jer, tec, deterministic_seeds,
IF_RUN_2(met_phi),
},
produces={
mc_weight, jec_nominal, jec_full, jer, tec, deterministic_seeds, met_phi,
mc_weight, jec_nominal, jec_full, jer, tec, deterministic_seeds,
IF_RUN_2(met_phi),
},
)
def default(self: Calibrator, events: ak.Array, **kwargs) -> ak.Array:
Expand All @@ -42,7 +45,8 @@ def default(self: Calibrator, events: ak.Array, **kwargs) -> ak.Array:
events = self[jec_full](events, **kwargs)
events = self[jer](events, **kwargs)

events = self[met_phi](events, **kwargs)
if self.config_inst.campaign.x.run == 2:
events = self[met_phi](events, **kwargs)

if self.dataset_inst.is_mc:
events = self[tec](events, **kwargs)
Expand Down
4 changes: 3 additions & 1 deletion hbt/calibration/tau.py
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,8 @@ def tec(
scales_down = np.ones_like(dm_mask, dtype=np.float32)

args = (pt[dm_mask], eta[dm_mask], dm[dm_mask], match[dm_mask], self.config_inst.x.tau_tagger)
if self.config_inst.campaign.x.run == 3:
args += self.config_inst.x.tau_energy_calibration
scales_nom[dm_mask] = self.tec_corrector(*args, "nom")
scales_up[dm_mask] = self.tec_corrector(*args, "up")
scales_down[dm_mask] = self.tec_corrector(*args, "down")
Expand Down Expand Up @@ -176,4 +178,4 @@ def tec_setup(self: Calibrator, reqs: dict, inputs: dict, reader_targets: Insert
self.tec_corrector = correction_set["tau_energy_scale"]

# check versions
assert self.tec_corrector.version in [0]
assert self.tec_corrector.version in [0, 1]
26 changes: 26 additions & 0 deletions hbt/config/analysis_hbt.py
Original file line number Diff line number Diff line change
Expand Up @@ -81,3 +81,29 @@
config_id=32,
limit_dataset_files=2,
)


#
# Run 3 configs
#

# 2022
from hbt.config.configs_run3 import add_config as add_config_run3
from cmsdb.campaigns.run3_2022_preEE_nano_uhh_v12 import campaign_run3_2022_preEE_nano_uhh_v12

# preEE v12 config
add_config_run3(
analysis_hbt,
campaign_run3_2022_preEE_nano_uhh_v12.copy(),
config_name="run3_2022_preEE_limited",
config_id=4,
limit_dataset_files=2,
)

# preEE v12 config
add_config_run3(
analysis_hbt,
campaign_run3_2022_preEE_nano_uhh_v12.copy(),
config_name="run3_2022_preEE",
config_id=14,
)
28 changes: 28 additions & 0 deletions hbt/config/configs_run2ul.py
Original file line number Diff line number Diff line change
Expand Up @@ -255,6 +255,31 @@ def add_config(
},
})

# tau ID working points
if campaign.x.version < 10:
cfg.x.tau_id_working_points = DotDict.wrap({
"tau_vs_e": {"vvvloose": 1, "vvloose": 2, "vloose": 4, "loose": 8, "medium": 16, "tight": 32, "vtight": 64, "vvtight": 128}, # noqa
"tau_vs_jet": {"vvvloose": 1, "vvloose": 2, "vloose": 4, "loose": 8, "medium": 16, "tight": 32, "vtight": 64, "vvtight": 128}, # noqa
"tau_vs_mu": {"vloose": 1, "loose": 2, "medium": 4, "tight": 8},
})
else:
cfg.x.tau_id_working_points = DotDict.wrap({
"tau_vs_e": {"vvvloose": 1, "vvloose": 2, "vloose": 3, "loose": 4, "medium": 5, "tight": 6, "vtight": 7, "vvtight": 8}, # noqa
"tau_vs_jet": {"vvvloose": 1, "vvloose": 2, "vloose": 3, "loose": 4, "medium": 5, "tight": 6, "vtight": 7, "vvtight": 8}, # noqa
"tau_vs_mu": {"vloose": 1, "loose": 2, "medium": 3, "tight": 4},
})

# tau trigger working points
cfg.x.tau_trigger_working_points = DotDict.wrap({
"id_vs_jet_v0": "VVLoose",
"id_vs_jet_gv0": ("Loose", "VVLoose"),
"id_vs_mu_single": "Tight",
"id_vs_mu_cross": "VLoose",
"id_vs_e_single": "VLoose",
"id_vs_e_cross": "VVLoose",
"trigger_corr": "VVLoose",
})

# jec configuration
# https://twiki.cern.ch/twiki/bin/view/CMS/JECDataMC?rev=201
jerc_postfix = "APV" if year == 2016 and campaign.x.vfp == "pre" else ""
Expand Down Expand Up @@ -571,6 +596,9 @@ def add_config(
# tau energy correction and scale factors
"tau_sf": (f"{json_mirror}/POG/TAU/{year}{corr_postfix}_UL/tau.json.gz", "v1"),

# tau trigger scale factors
"tau_trigger_sf": (f"{json_mirror}/POG/TAU/{year}{corr_postfix}_UL/tau.json.gz", "v1"),

# electron scale factors
"electron_sf": (f"{json_mirror}/POG/EGM/{year}{corr_postfix}_UL/electron.json.gz", "v1"),

Expand Down
Loading

0 comments on commit 06a024e

Please sign in to comment.