Skip to content

Commit

Permalink
more fixes :)
Browse files Browse the repository at this point in the history
  • Loading branch information
haddadanas committed Nov 6, 2024
1 parent 05e9227 commit 88c4f2f
Showing 1 changed file with 9 additions and 7 deletions.
16 changes: 9 additions & 7 deletions columnflow/production/normalization.py
Original file line number Diff line number Diff line change
Expand Up @@ -176,9 +176,9 @@ def normalization_weights(self: Producer, events: ak.Array, **kwargs) -> ak.Arra
attribute. When py:attr`allow_stitching` is set to True, the sum of event weights is computed
for all datasets with a leaf process contained in the leaf processes of the
py:attr:`dataset_inst`. For stitching, the process_id needs to be reconstructed for each leaf
process on a per event basis. Moreover, when stitching is enabled, the an additional normalization
process on a per event basis. Moreover, when stitching is enabled, an additional normalization
weight is computed for the inclusive dataset only and stored in a column named
py:attr:`weight_name`_inclusive_only. This weight resembles the normalization weight for the
`<weight_name>_inclusive_only`. This weight resembles the normalization weight for the
inclusive dataset, as if it were unstitched and should therefore only be applied, when using the
inclusive dataset as a standalone dataset.
Expand All @@ -203,9 +203,9 @@ def normalization_weights(self: Producer, events: ak.Array, **kwargs) -> ak.Arra
events = set_ak_column(events, self.weight_name, norm_weight, value_type=np.float32)

# If we are stitching, we also compute the inclusive weight for debugging purposes
if self.allow_stitching and self.dataset_inst == self.get_inclusive_dataset():
if self.allow_stitching and self.dataset_inst == self.inclusive_dataset:
incl_norm_weight = events.mc_weight * self.inclusive_weight
events = set_ak_column(events, f"{self.weight_name}_inclusive_only", incl_norm_weight, value_type=np.float32)
events = set_ak_column(events, self.weight_name_incl, incl_norm_weight, value_type=np.float32)
return events


Expand Down Expand Up @@ -296,7 +296,7 @@ def normalization_weights_setup(
# create a event weight lookup table
process_weight_table = sp.sparse.lil_matrix((1, max_id + 1), dtype=np.float32)
if self.allow_stitching and self.get_xsecs_from_inclusive_dataset:
inclusive_dataset = self.get_inclusive_dataset()
inclusive_dataset = self.inclusive_dataset
logger.info(f"using inclusive dataset {inclusive_dataset.name} for cross section lookup")

# get the branching ratios from the inclusive sample
Expand Down Expand Up @@ -342,11 +342,13 @@ def normalization_weights_init(self: Producer) -> None:
self.produces.add(self.weight_name)
if self.allow_stitching:
self.stitching_datasets = self.get_stitching_datasets()
self.inclusive_dataset = self.get_inclusive_dataset()
else:
self.stitching_datasets = [self.dataset_inst]

if self.allow_stitching and self.dataset_inst == self.get_inclusive_dataset():
self.produces.add(f"{self.weight_name}_inclusive_only")
if self.allow_stitching and self.dataset_inst == self.inclusive_dataset:
self.weight_name_incl = f"{self.weight_name}_inclusive_only"
self.produces.add(self.weight_name_incl)


stitched_normalization_weights = normalization_weights.derive(
Expand Down

0 comments on commit 88c4f2f

Please sign in to comment.