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

feat: improved axis labels for HEPData figures #223

Merged
merged 1 commit into from
Aug 14, 2024
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: 8 additions & 6 deletions analyses/cms-open-data-ttbar/utils/hepdata.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,18 +47,20 @@ def create_hep_data_table(index, model, model_prediction, config):
table = Table(table_name)

# Create a single variable for the region corresponding to the feature index
region = config['Regions'][index - 1]
var = Variable(f"Region {index}", is_independent=True, is_binned=False, units=region['Variable'])
var.values = [f"Feature{index} bin{k_bin}" for k_bin in range(len(model_prediction.model_yields[0][0]))]
formatted_values = [(config['Regions'][index]['Binning'][i-1], config['Regions'][index]['Binning'][i]) for i in range(1, len(config['Regions'][index]['Binning']))]
var = Variable(config['Regions'][index]['Variable'].split('[')[0], is_independent=True, is_binned=True, units=config['Regions'][index]['Variable'].partition('[')[2].partition(']')[0] or " ")
var.values = formatted_values
table.add_variable(var)

# Add dependent variables and uncertainties
for i, sample in enumerate(model.config.samples):
data_var = Variable(sample, is_independent=False, is_binned=False, units="Number of jets")
data_var.values = model_prediction.model_yields[index - 1][i]
model_yields = model_prediction.model_yields[index - 1][i]
total_stdev = model_prediction.total_stdev_model_bins[index - 1][i]

data_var.values = model_yields

unc = Uncertainty("A symmetric error", is_symmetric=True)
unc.values = model_prediction.total_stdev_model_bins[index - 1][i]
unc.values = total_stdev

data_var.add_uncertainty(unc)
table.add_variable(data_var)
Expand Down
Loading