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) |
def | 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) |
def | add_fei_weight_columns (self, pd.DataFrame ntuple_df, ReweighterParticle particle) |
def | reweight (self, pd.DataFrame df, bool generate_variations=True) |
def | print_coverage (self) |
def | plot_coverage (self) |
Public Attributes | |
n_variations | |
Number of weight variations to generate. | |
particles | |
List of particles. | |
correlations | |
Correlations between the particles. | |
weight_name | |
Name of the weight column. | |
weights_generated | |
Flag to indicate if the weights have been generated. | |
evaluate_plots | |
Flag to indicate if the plots should be evaluated. | |
nbins | |
Number of bins for the plots. | |
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 235 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 486 of file sysvar.py.
def add_fei_weight_columns | ( | self, | |
pd.DataFrame | ntuple_df, | ||
ReweighterParticle | particle | ||
) |
Adds weight columns according to the FEI calibration tables
Definition at line 525 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 398 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 344 of file sysvar.py.
def 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 449 of file sysvar.py.
list get_bin_columns | ( | self, | |
weight_df | |||
) |
Returns the kinematic bin columns of the dataframe.
Definition at line 261 of file sysvar.py.
dict get_binning | ( | self, | |
weight_df | |||
) |
Returns the kinematic binning of the dataframe.
Definition at line 267 of file sysvar.py.
dict get_fei_binning | ( | self, | |
weight_df | |||
) |
Returns the irregular binning of the dataframe.
Definition at line 282 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 289 of file sysvar.py.
ReweighterParticle get_particle | ( | self, | |
str | prefix | ||
) |
Get a particle by its prefix.
Definition at line 440 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 306 of file sysvar.py.
def plot_coverage | ( | self | ) |
def print_coverage | ( | self | ) |
Prints the coverage of each particle.
Definition at line 585 of file sysvar.py.
def 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 563 of file sysvar.py.
evaluate_plots |
weights_generated |