Skip to content

Commit

Permalink
Update to cf changes, better type hints.
Browse files Browse the repository at this point in the history
  • Loading branch information
riga committed Nov 8, 2023
1 parent dd718d5 commit a40fb20
Show file tree
Hide file tree
Showing 5 changed files with 17 additions and 17 deletions.
5 changes: 4 additions & 1 deletion hbt/inference/test.py
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,10 @@ def test(self):
self.add_parameter(
"CMS_pileup2",
type=ParameterType.rate_uniform,
transformations=[ParameterTransformation.effect_from_shape, ParameterTransformation.symmetrize],
transformations=[
ParameterTransformation.effect_from_shape,
ParameterTransformation.symmetrize,
],
config_shift_source="minbias_xs",
)
self.add_parameter_to_group("CMS_pileup2", "experiment")
Expand Down
8 changes: 4 additions & 4 deletions hbt/production/tau.py
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ def tau_weights(self: Producer, events: ak.Array, **kwargs) -> ak.Array:
if self.id_vs_jet_corrector.version == 0:
# pt, dm, genmatch, jet wp, syst, sf type
tau_args = lambda mask, syst: (pt[mask], dm[mask], match[mask], "VVLoose", syst, "dm")
elif self.id_vs_jet_corrector.version == 1:
elif self.id_vs_jet_corrector.version in (1, 2):
# pt, dm, genmatch, jet wp, e wp, syst, sf type
tau_args = lambda mask, syst: (pt[mask], dm[mask], match[mask], "Loose", "VVLoose", syst, "dm")
else:
Expand Down Expand Up @@ -200,9 +200,9 @@ def tau_weights_setup(self: Producer, reqs: dict, inputs: dict, reader_targets:
self.id_vs_mu_corrector = correction_set[f"{tagger_name}VSmu"]

# check versions
assert self.id_vs_jet_corrector.version in [0, 1]
assert self.id_vs_e_corrector.version in [0, 1]
assert self.id_vs_mu_corrector.version in [0, 1]
assert self.id_vs_jet_corrector.version in (0, 1, 2)
assert self.id_vs_e_corrector.version in (0,)
assert self.id_vs_mu_corrector.version in (0,)


@producer(
Expand Down
12 changes: 5 additions & 7 deletions hbt/selection/lepton.py
Original file line number Diff line number Diff line change
Expand Up @@ -388,7 +388,8 @@ def lepton_selection(
sel_muon_indices = empty_indices
sel_tau_indices = empty_indices

# perform each lepton election step separately per trigger
# perform each lepton election step separately per trigger, avoid caching
sel_kwargs = {**kwargs, "call_force": True}
for trigger, trigger_fired, leg_masks in trigger_results.x.trigger_data:
is_single = trigger.has_tag("single_trigger")
is_cross = trigger.has_tag("cross_trigger")
Expand All @@ -398,17 +399,15 @@ def lepton_selection(
events,
trigger,
leg_masks,
call_force=True,
**kwargs,
**sel_kwargs,
)

# muon selection
muon_indices, muon_veto_indices = self[muon_selection](
events,
trigger,
leg_masks,
call_force=True,
**kwargs,
**sel_kwargs,
)

# tau selection
Expand All @@ -418,8 +417,7 @@ def lepton_selection(
leg_masks,
electron_indices,
muon_indices,
call_force=True,
**kwargs,
**sel_kwargs,
)

# lepton pair selecton per trigger via lepton counting
Expand Down
7 changes: 3 additions & 4 deletions hbt/util.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,16 +8,15 @@

__all__ = ["IF_NANO_V9", "IF_NANO_V11"]

from typing import Any

from columnflow.types import Any
from columnflow.columnar_util import ArrayFunction, deferred_column


@deferred_column
def IF_NANO_V9(self, func: ArrayFunction) -> Any | set[Any]:
def IF_NANO_V9(self: ArrayFunction.DeferredColumn, func: ArrayFunction) -> Any | set[Any]:
return self.get() if func.config_inst.campaign.x.version == 9 else None


@deferred_column
def IF_NANO_V11(self, func: ArrayFunction) -> Any | set[Any]:
def IF_NANO_V11(self: ArrayFunction.DeferredColumn, func: ArrayFunction) -> Any | set[Any]:
return self.get() if func.config_inst.campaign.x.version == 11 else None
2 changes: 1 addition & 1 deletion modules/columnflow
Submodule columnflow updated 50 files
+0 βˆ’1 analysis_templates/cms_minimal/__cf_module_name__/calibration/example.py
+0 βˆ’1 analysis_templates/cms_minimal/__cf_module_name__/categorization/example.py
+1 βˆ’3 analysis_templates/cms_minimal/__cf_module_name__/ml/example.py
+0 βˆ’1 analysis_templates/cms_minimal/__cf_module_name__/production/example.py
+0 βˆ’1 analysis_templates/cms_minimal/__cf_module_name__/selection/example.py
+0 βˆ’1 analysis_templates/cms_minimal/tests/__init__.py
+5 βˆ’3 bin/cf_diff.py
+13 βˆ’16 bin/cf_inspect.py
+2 βˆ’8 columnflow/__init__.py
+0 βˆ’1 columnflow/calibration/cms/jets.py
+0 βˆ’1 columnflow/calibration/cms/met.py
+0 βˆ’1 columnflow/calibration/util.py
+108 βˆ’61 columnflow/columnar_util.py
+68 βˆ’63 columnflow/inference/__init__.py
+1 βˆ’1 columnflow/inference/cms/datacard.py
+0 βˆ’1 columnflow/ml/__init__.py
+0 βˆ’2 columnflow/plotting/plot_all.py
+0 βˆ’1 columnflow/plotting/plot_functions_1d.py
+0 βˆ’1 columnflow/plotting/plot_functions_2d.py
+0 βˆ’1 columnflow/plotting/plot_util.py
+1 βˆ’1 columnflow/production/categories.py
+0 βˆ’1 columnflow/production/cms/btag.py
+0 βˆ’1 columnflow/production/cms/electron.py
+0 βˆ’1 columnflow/production/cms/gen_top_decay.py
+0 βˆ’1 columnflow/production/cms/mc_weight.py
+0 βˆ’1 columnflow/production/cms/muon.py
+1 βˆ’1 columnflow/production/cms/pdf.py
+1 βˆ’1 columnflow/production/cms/pileup.py
+1 βˆ’1 columnflow/production/cms/scale.py
+0 βˆ’1 columnflow/production/cms/seeds.py
+0 βˆ’1 columnflow/production/normalization.py
+0 βˆ’1 columnflow/production/processes.py
+0 βˆ’1 columnflow/production/util.py
+7 βˆ’8 columnflow/selection/__init__.py
+0 βˆ’1 columnflow/selection/cms/json_filter.py
+0 βˆ’1 columnflow/selection/cms/met_filters.py
+0 βˆ’1 columnflow/selection/matching.py
+0 βˆ’1 columnflow/selection/stats.py
+0 βˆ’1 columnflow/selection/util.py
+0 βˆ’1 columnflow/tasks/calibration.py
+7 βˆ’3 columnflow/tasks/cms/base.py
+0 βˆ’1 columnflow/tasks/framework/mixins.py
+16 βˆ’12 columnflow/tasks/framework/remote.py
+0 βˆ’1 columnflow/tasks/reduction.py
+0 βˆ’1 columnflow/tasks/selection.py
+1 βˆ’3 columnflow/types.py
+0 βˆ’1 tests/__init__.py
+0 βˆ’1 tests/test_columnar_util.py
+0 βˆ’1 tests/test_task_parameters.py
+0 βˆ’1 tests/test_util.py

0 comments on commit a40fb20

Please sign in to comment.