ijazz.ScaleAndSmearing

Classes

IJazZSAS

IJazZEnergyCorrector

Functions

ijazz_sas_cmd()

entry point for the ijazz_sas command

ijazz_sas([config, do_fit, save_corrlib])

Perform the scale and smearing fit, plot the results and save the results.

compute_sas(→ IJazZSAS)

Wrapper to compute the scale and smearing parameters

Module Contents

ijazz.ScaleAndSmearing.ijazz_sas_cmd()[source]

entry point for the ijazz_sas command

ijazz.ScaleAndSmearing.ijazz_sas(config: dict = None, do_fit=True, save_corrlib=True)[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 2023

  • cset_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

class ijazz.ScaleAndSmearing.IJazZSAS(dt: pandas.DataFrame, mc: pandas.DataFrame, config: dict, categories: dict = None)[source]
categories_def = None[source]
cfg[source]
double_gaussian[source]
mll_name[source]
pt_name[source]
cat_name[source]
cut = ''[source]
has_pt = False[source]
categories_mc[source]
categories_dt[source]
dt[source]
mc[source]
fitter = None[source]
resp = None[source]
reso = None[source]
resp_corr = None[source]
reso_uncorr = None[source]
eresp = None[source]
ereso = None[source]
eresp_mc = None[source]
ereso_mc = None[source]
pt_mean = None[source]
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

calc_err_stat(force=False)[source]
calc_err_mc()[source]

compute the error due to MC statistical fluctuations, this may take a while

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.

recast_pt_bins(prefix='cat')[source]

when doing a fit that contains pt bining with the option use_r_pt, one has to recast the relative pt in real pt value (in GeV)

Parameters:

prefix (str, optional) – prefix used for naming the categorisation. Defaults to ‘cat’.

dump_json(outfile: pathlib.Path | str = None)[source]

Dump the resulst to a json file

Parameters:

outfile (Union[Path, str], optional) – output file name. 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:

IJazZSAS

class ijazz.ScaleAndSmearing.IJazZEnergyCorrector(dt: pandas.DataFrame, mc: pandas.DataFrame, json_file: str | pathlib.Path | Dict, mll_name, pt_name)[source]
categories[source]
resp[source]
reso[source]
eresp[source]
ereso[source]
mll_name[source]
pt_name[source]
prefix = 'LepCatCorr'[source]
mc[source]
dt[source]
reset_data()[source]
reset_mc()[source]
correct_data()[source]
correct_mc(do_syst=False)[source]