Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix data shape in qcd hook. #60

Merged
merged 2 commits into from
Jan 22, 2025
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 14 additions & 0 deletions hbt/config/hist_hooks.py
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,20 @@ def qcd_estimation(task, hists):
ss_noniso_data = hist_to_num(get_hist(data_hist, "ss_noniso"), "ss_noniso_data")
ss_iso_data = hist_to_num(get_hist(data_hist, "ss_iso"), "ss_iso_data")

# data will always have a single shift whereas mc might have multiple,
# broadcast numbers in-place manually if necessary
if (n_shifts := mc_hist.axes["shift"].size) > 1:
def broadcast_data_num(num: sn.Number) -> None:
num._nominal = np.repeat(num.nominal, n_shifts, axis=0)
for name, (unc_up, unc_down) in num._uncertainties.items():
num._uncertainties[name] = (
np.repeat(unc_up, n_shifts, axis=0),
np.repeat(unc_down, n_shifts, axis=0),
)
broadcast_data_num(os_noniso_data)
broadcast_data_num(ss_noniso_data)
broadcast_data_num(ss_iso_data)

# estimate qcd shapes in the three sideband regions
# shapes: (SHIFT, VAR)
os_noniso_qcd = os_noniso_data - os_noniso_mc
Expand Down
Loading