Skip to content

Commit

Permalink
Merge branch 'master' into feature/qcd_hist_hook
Browse files Browse the repository at this point in the history
  • Loading branch information
aalvesan committed Feb 6, 2025
2 parents a3d1277 + d1a53c9 commit e28696e
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 3 deletions.
8 changes: 6 additions & 2 deletions hbt/weight/default.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,8 @@ def default(self: WeightProducer, events: ak.Array, **kwargs) -> ak.Array:

@default.init
def default_init(self: WeightProducer) -> None:
dataset_inst = getattr(self, "dataset_inst", None)

# use the config's auxiliary event_weights, drop some of them based on drop_weights, and on this
# weight producer instance, store weight_columns, used columns, and shifts
self.weight_columns = []
Expand All @@ -40,13 +42,15 @@ def default_init(self: WeightProducer) -> None:
do_drop = pattern_matcher(self.drop_weights) if self.drop_weights else (lambda _, /: False)

# collect all possible weight columns and affected shifts
all_weights = self.config_inst.x.event_weights | self.dataset_inst.x("event_weights", {})
all_weights = self.config_inst.x.event_weights
if dataset_inst:
all_weights.update(dataset_inst.x("event_weights", {}))
for weight_name, shift_insts in all_weights.items():
if not do_keep(weight_name) or do_drop(weight_name):
continue

# manually skip pdf and scale weights for samples that do not have lhe info
if getattr(self, "dataset_inst", None) is not None:
if dataset_inst:
is_lhe_weight = any(shift_inst.has_tag("lhe_weight") for shift_inst in shift_insts)
if is_lhe_weight and self.dataset_inst.has_tag("no_lhe_weights"):
continue
Expand Down
2 changes: 1 addition & 1 deletion modules/columnflow

0 comments on commit e28696e

Please sign in to comment.