ijazz.ScaleAndSmearing
Classes
Scale-and-smearing fitter with category handling and plotting helpers. |
|
Apply IJazZ scale/smear corrections to data and MC dataframes. |
Functions
entry point for the ijazz_sas command |
|
|
Perform the scale and smearing fit, plot the results and save the results. |
|
Wrapper to compute the scale and smearing parameters |
Module Contents
- ijazz.ScaleAndSmearing.ijazz_sas(config: dict = None, do_fit=True, save_corrlib=True, correct_files=True, suffixe_plots: str = '')[source]
Perform the scale and smearing fit, plot the results and save the results. The configuration file should contain the following sections:
file_dt: data file (parquet format)
file_mc: mc file (parquet format)
dir_results: directory where to save the results
fitter: configuration for the fitter
sas: configuration for the scale and smearing fit
minimizer: configuration for the minimizer
syst: configuration for the systematic computation
corrlib: add description and version number to the correctionlib file
cat_latex: dictionary to convert the category name to latex
scale_flat_syst: flat systematic for scale
smear_flat_syst: flat systematic for smearing
dset_name: name of the dataset eg
2023cset_name: name of the correction set eg
EtaR9
See an example sas_config.yaml
- Parameters:
config (dict) – configuration dictionary containing the parameters for the fit
do_fit – if True, perform the fit
save_corrlib – if True, save the correctionlib file
correct_files – if True, apply the correction to the input files and save them
- class ijazz.ScaleAndSmearing.IJazZSAS(dt: pandas.DataFrame, mc: pandas.DataFrame, config: dict, categories: dict = None)[source]
Scale-and-smearing fitter with category handling and plotting helpers.
- fit(optimizer=tf.keras.optimizers.Adam) numpy.ndarray[source]
Actually performs the fit
- Parameters:
optimizer (class) – tensorflow compatible optimizer for instance tf.keras.optimizers.Adam (this is not the optimizer the the class)
learning_rate (float, optional) – learning rate to pass to the optimizer. Defaults to 0.01.
dnll_tol (float, optional) – delta likelihood tolerance to stop the fit. Defaults to 0.01.
max_epochs (int, optional) – maximum number of iteration. Defaults to 1000.
init_rand (bool, optional) – random starting poin. Defaults to False.
batch_size (int, optional) – can perform the fit in batch size (usefull for large number of parameters). Defaults to -1.
device (str, optional) – _description_. Defaults to ‘CPU’.
batch_training (bool, optional) – use the batch training mode. Defaults to False.
hess (str, optional) – computation of the hession (None, ‘numerical’, or ‘analytical’), it can take a while. Defaults to ‘numerical’.
cats (_type_, optional) – subset of categories to perform the fit. Defaults to slice(None).
- Returns:
array of the value of the -2 * log likelihood during the fit
- Return type:
np.ndarray
- correct_data(response: numpy.ndarray, prefix: str = None)[source]
correct the data dataframe after the fit
- Parameters:
response (np.ndarray) – array with the responses to apply for correction
prefix (str, optional) – prefix used for naming the categorisation. Defaults to None.
- correct_mc(resolution: numpy.ndarray, prefix: str = None)[source]
correct the mc dataframe
- Parameters:
resolution (np.ndarray) – array with the relative resolution to smear the MC
prefix (str, optional) – prefix used for naming the categorisation. Defaults to None.
- ijazz.ScaleAndSmearing.compute_sas(dt, mc, cfg, categories=None) IJazZSAS[source]
Wrapper to compute the scale and smearing parameters
- Parameters:
dt (pd.DataFrame) – input dataframe for data
mc (pd.DataFrame) – input dataframe for mc
cfg (Union[str, Path]) – config file to control the sas fit
categories (dict, optional) – categories to do the fit (can be specified in config). Defaults to None.
- Returns:
return the ScaleAndSmearing fitter
- Return type: