Skip to content

Commit 017862b

Browse files
committed
tmp
1 parent f6e2548 commit 017862b

File tree

4 files changed

+21
-6
lines changed

4 files changed

+21
-6
lines changed

hbw/inference/base.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -152,8 +152,10 @@ def add_inference_categories(self: InferenceModel):
152152
]
153153

154154
# add the category to the inference model
155-
self.add_category(cat_name, **cat_kwargs)
156-
155+
try:
156+
self.add_category(cat_name, **cat_kwargs)
157+
except Exception as e:
158+
from hbw.util import debugger; debugger()
157159
# do some customization of the inference category
158160
self.customize_category(self.get_category(cat_name), cat_inst)
159161

hbw/production/normalized_btag.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,10 @@ def normalized_btag_weights_init(self: Producer) -> None:
7575
@normalized_btag_weights.requires
7676
def normalized_btag_weights_requires(self: Producer, reqs: dict) -> None:
7777
from hbw.tasks.corrections import GetBtagNormalizationSF
78-
reqs["btag_renormalization_sf"] = GetBtagNormalizationSF.req(self.task)
78+
processes = ["tt"]
79+
if "dy" in self.dataset_inst.name:
80+
processes = ["dy_m50toinf", "dy_m10to50"]
81+
reqs["btag_renormalization_sf"] = GetBtagNormalizationSF.req(self.task, processes=processes)
7982

8083

8184
@normalized_btag_weights.setup

hbw/production/weights.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -262,7 +262,7 @@ def combined_normalization_weights_init(self: Producer) -> None:
262262
normalized_pu_weights,
263263
},
264264
mc_only=True,
265-
version=1,
265+
version=3,
266266
)
267267
def event_weights(self: Producer, events: ak.Array, **kwargs) -> ak.Array:
268268
"""

hbw/tasks/corrections.py

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -180,9 +180,19 @@ def safe_div(num, den):
180180
h = self.reduce_hist(h, mode)
181181
denominator = h.values()
182182

183+
# get axes for the output histogram
184+
out_axes = []
185+
for ax in h.axes:
186+
if isinstance(ax, hist.axis.Variable):
187+
out_axes.append(ax)
188+
elif isinstance(ax, hist.axis.Integer):
189+
out_axes.append(hist.axis.Variable(ax.edges, name=ax.name, label=ax.label))
190+
else:
191+
raise ValueError(f"Unsupported axis type {type(ax)}")
192+
183193
# calculate the scale factor and store it as a correctionlib evaluator
184194
sf = safe_div(numerator, denominator)
185-
sfhist = hist.Hist(*h.axes, data=sf)
195+
sfhist = hist.Hist(*out_axes, data=sf)
186196
sfhist.name = f"{mode_str}_{weight_name}"
187197
sfhist.label = "out"
188198

@@ -193,7 +203,7 @@ def safe_div(num, den):
193203
# set overflow bins behavior (default is to raise an error when out of bounds)
194204
# NOTE: claming seems to not work for int axes. Hopefully the number of jets considered to
195205
# create these SFs is always large enough to not hit the overflow bin.
196-
if any(isinstance(ax, hist.axis.Variable) for ax in h.axes):
206+
if any(isinstance(ax, hist.axis.Variable) for ax in out_axes):
197207
btag_renormalization.data.flow = "clamp"
198208

199209
# store the evaluator

0 commit comments

Comments
 (0)