Skip to content

Commit

Permalink
store bin edges in rebin task
Browse files Browse the repository at this point in the history
  • Loading branch information
mafrahm committed Nov 13, 2023
1 parent 5a78093 commit 368a159
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion hbw/tasks/inference.py
Original file line number Diff line number Diff line change
Expand Up @@ -264,6 +264,7 @@ def output(self):
return {
"card": self.target(basename(f"datacard_rebin_{n_bins}", "txt")),
"shapes": self.target(basename(f"shapes_rebin_{n_bins}", "root")),
"edges": self.target(basename(f"edges_{n_bins}", "json")),
}

def run(self):
Expand Down Expand Up @@ -295,7 +296,7 @@ def run(self):
cat_name = list(cat_names)[0]
if cat_name != self.branch_data.name:
raise Exception(
f"Category name in the histograms {cat_name} does not agree with the"
f"Category name in the histograms {cat_name} does not agree with the "
f"datacard category name {self.branch_data.name}",
)

Expand All @@ -320,6 +321,7 @@ def run(self):

print(f"Finding rebin values for category {cat_name} using processes {rebin_processes}")
rebin_values = get_rebin_values(hist, self.get_n_bins())
outputs["edges"].dump(rebin_values, formatter="json")

# apply rebinning on all histograms and store resulting hists in a ROOT file
out_file = uproot.recreate(outputs["shapes"].fn)
Expand Down

0 comments on commit 368a159

Please sign in to comment.