Skip to content

Commit

Permalink
better data yield variable names
Browse files Browse the repository at this point in the history
  • Loading branch information
alexander-held committed Feb 5, 2021
1 parent ff0b64d commit f2e0746
Showing 1 changed file with 6 additions and 8 deletions.
14 changes: 6 additions & 8 deletions src/cabinetry/visualize.py
Original file line number Diff line number Diff line change
Expand Up @@ -192,9 +192,7 @@ def data_MC(
m.tolist() for m in np.split(yields_combined, region_split_indices, axis=1)
]
# data is only indexed by channel (and bin)
data_per_channel = [
d.tolist() for d in np.split(data_combined, region_split_indices)
]
data_yields = [d.tolist() for d in np.split(data_combined, region_split_indices)]

# calculate the total standard deviation of the model prediction
# indices: channel (and bin) for per-bin uncertainties, channel for per-channel
Expand All @@ -209,17 +207,17 @@ def data_MC(
else:
log.info("generating post-fit yield table")
tabulate._yields_per_bin(
model, model_yields, total_stdev_model_bins, data_per_channel
model, model_yields, total_stdev_model_bins, data_yields
)

# yields per channel
model_yields_per_channel = np.sum(ak.from_iter(model_yields), axis=-1).tolist()
data_per_channel_summed = [sum(d) for d in data_per_channel]
data_per_channel = [sum(d) for d in data_yields]
tabulate._yields_per_channel(
model,
model_yields_per_channel,
total_stdev_model_channels,
data_per_channel_summed,
data_per_channel,
)

# process channel by channel
Expand All @@ -233,7 +231,7 @@ def data_MC(
variable = region_dict["Variable"]
else:
# fall back to defaults
bin_edges = np.arange(len(data_per_channel[i_chan]) + 1)
bin_edges = np.arange(len(data_yields[i_chan]) + 1)
variable = "bin"

for i_sam, sample_name in enumerate(model.config.samples):
Expand All @@ -251,7 +249,7 @@ def data_MC(
{
"label": "Data",
"isData": True,
"yields": data_per_channel[i_chan],
"yields": data_yields[i_chan],
"variable": variable,
}
)
Expand Down

0 comments on commit f2e0746

Please sign in to comment.