![]() |
Belle II Software development
|
Public Member Functions | |
None | __init__ (self, int n_variations=100, str weight_name="Weight", bool evaluate_plots=True, int nbins=50, float fillna=1.0) |
list | get_bin_columns (self, weight_df) |
dict | get_binning (self, weight_df) |
dict | get_fei_binning (self, weight_df) |
None | get_ntuple_variables (self, pd.DataFrame ntuple_df, ReweighterParticle particle) |
pd.DataFrame | merge_pid_weight_tables (self, dict weights_dict, dict pdg_pid_variable_dict) |
None | add_pid_weight_columns (self, pd.DataFrame ntuple_df, ReweighterParticle particle) |
None | add_pid_particle (self, str prefix, dict weights_dict, dict pdg_pid_variable_dict, dict variable_aliases=None, int sys_seed=None, bool syscorr=True) |
ReweighterParticle | get_particle (self, str prefix) |
convert_fei_table (self, pd.DataFrame table, float threshold) | |
None | add_fei_particle (self, str prefix, pd.DataFrame table, float threshold, np.ndarray cov=None, dict variable_aliases=None) |
add_fei_weight_columns (self, pd.DataFrame ntuple_df, ReweighterParticle particle) | |
reweight (self, pd.DataFrame df, bool generate_variations=True) | |
print_coverage (self) | |
plot_coverage (self) | |
Public Attributes | |
n_variations = n_variations | |
Number of weight variations to generate. | |
list | particles = [] |
List of particles. | |
list | correlations = [] |
Correlations between the particles. | |
weight_name = weight_name | |
Name of the weight column. | |
bool | weights_generated = False |
Flag to indicate if the weights have been generated. | |
evaluate_plots = evaluate_plots | |
Flag to indicate if the plots should be evaluated. | |
nbins = nbins | |
Number of bins for the plots. | |
fillna = fillna | |
Value to fill NaN values. | |
Class that reweights the dataframe. Args: n_variations (int): Number of weight variations to generate. weight_name (str): Name of the weight column. evaluate_plots (bool): Flag to indicate if the plots should be evaluated. nbins (int): Number of bins for the plots.
None __init__ | ( | self, | |
int | n_variations = 100, | ||
str | weight_name = "Weight", | ||
bool | evaluate_plots = True, | ||
int | nbins = 50, | ||
float | fillna = 1.0 ) |
Initializes the Reweighter class.
Definition at line 239 of file sysvar.py.
None add_fei_particle | ( | self, | |
str | prefix, | ||
pd.DataFrame | table, | ||
float | threshold, | ||
np.ndarray | cov = None, | ||
dict | variable_aliases = None ) |
Adds weight variations according to the total uncertainty for easier error propagation. Args: prefix (str): Prefix for the new columns. table (pandas.DataFrame): Dataframe containing the efficiency weights. threshold (float): Threshold for the efficiency weights. cov (numpy.ndarray): Covariance matrix for the efficiency weights. variable_aliases (dict): Dictionary containing variable aliases.
Definition at line 490 of file sysvar.py.
add_fei_weight_columns | ( | self, | |
pd.DataFrame | ntuple_df, | ||
ReweighterParticle | particle ) |
Adds weight columns according to the FEI calibration tables
Definition at line 529 of file sysvar.py.
None add_pid_particle | ( | self, | |
str | prefix, | ||
dict | weights_dict, | ||
dict | pdg_pid_variable_dict, | ||
dict | variable_aliases = None, | ||
int | sys_seed = None, | ||
bool | syscorr = True ) |
Adds weight variations according to the total uncertainty for easier error propagation. Args: prefix (str): Prefix for the new columns. weights_dict (pandas.DataFrame): Dataframe containing the efficiency weights. pdg_pid_variable_dict (dict): Dictionary containing the PID variables and thresholds. variable_aliases (dict): Dictionary containing variable aliases. sys_seed (int): Seed for the systematic variations. syscorr (bool): When true assume systematics are 100% correlated defaults to true. Note this is overridden by provision of a None value rho_sys
Definition at line 402 of file sysvar.py.
None add_pid_weight_columns | ( | self, | |
pd.DataFrame | ntuple_df, | ||
ReweighterParticle | particle ) |
Adds a weight and uncertainty columns to the dataframe. Args: ntuple_df (pandas.DataFrame): Dataframe containing the analysis ntuple. particle (ReweighterParticle): Particle object.
Definition at line 348 of file sysvar.py.
convert_fei_table | ( | self, | |
pd.DataFrame | table, | ||
float | threshold ) |
Checks if the tables are provided in a legacy format and converts them to the standard format.
Definition at line 453 of file sysvar.py.
list get_bin_columns | ( | self, | |
weight_df ) |
Returns the kinematic bin columns of the dataframe.
Definition at line 265 of file sysvar.py.
dict get_binning | ( | self, | |
weight_df ) |
Returns the kinematic binning of the dataframe.
Definition at line 271 of file sysvar.py.
dict get_fei_binning | ( | self, | |
weight_df ) |
Returns the irregular binning of the dataframe.
Definition at line 286 of file sysvar.py.
None get_ntuple_variables | ( | self, | |
pd.DataFrame | ntuple_df, | ||
ReweighterParticle | particle ) |
Checks if the variables are in the ntuple and returns them. Args: ntuple_df (pandas.DataFrame): Dataframe containing the analysis ntuple. particle (ReweighterParticle): Particle object containing the necessary variables.
Definition at line 293 of file sysvar.py.
ReweighterParticle get_particle | ( | self, | |
str | prefix ) |
Get a particle by its prefix.
Definition at line 444 of file sysvar.py.
pd.DataFrame merge_pid_weight_tables | ( | self, | |
dict | weights_dict, | ||
dict | pdg_pid_variable_dict ) |
Merges the efficiency and fake rate weight tables. Args: weights_dict (dict): Dictionary containing the weight tables. pdg_pid_variable_dict (dict): Dictionary containing the PDG codes and variable names.
Definition at line 310 of file sysvar.py.
plot_coverage | ( | self | ) |
print_coverage | ( | self | ) |
Prints the coverage of each particle.
Definition at line 589 of file sysvar.py.
reweight | ( | self, | |
pd.DataFrame | df, | ||
bool | generate_variations = True ) |
Reweights the dataframe according to the weight tables. Args: df (pandas.DataFrame): Dataframe containing the analysis ntuple. generate_variations (bool): When true generate weight variations.
Definition at line 567 of file sysvar.py.
list correlations = [] |
evaluate_plots = evaluate_plots |
n_variations = n_variations |
bool weights_generated = False |