ijazz.sas_utils
Attributes
Classes
Functions
|
Returns the shape to be used for reshaping the tensor of parameters of the ijazz fit |
|
Extract and re-shape the IJazZ sas results saved in a json file |
|
Dump the parameters dictionnary to a json file |
|
|
|
Create a correction lib files based |
|
Compute the systematic uncertainties from the json files |
|
Apply the correction lib to a pandas dataframe |
|
|
|
Function to fit the pT-dependent sas to make them smooth |
|
Create a correction lib files based |
entry point for the ijazz_sas_smoothing command |
Module Contents
- ijazz.sas_utils.ijazz_shape(categories: dict) List[source]
Returns the shape to be used for reshaping the tensor of parameters of the ijazz fit
- Parameters:
categories (dict) – categories used in the ijazz sas fit
- Returns:
shape
- Return type:
list
- ijazz.sas_utils.parameters_from_json(json_file: str | pathlib.Path | Dict) Dict[source]
Extract and re-shape the IJazZ sas results saved in a json file
- Parameters:
json_file (Union[str, Path, Dict]) – name of the json file where the fit results are stored
- Returns:
dictionnary with the categories used in the fit and the results of the fit
- Return type:
dict
- ijazz.sas_utils.parameters_to_json(params: Dict, outfile: str | pathlib.Path) None[source]
Dump the parameters dictionnary to a json file
- Parameters:
params (Dict) – input dictionnary
outfile (Union[str, Path]) – output file
- ijazz.sas_utils.to_correction_lib(sas: Dict | str | pathlib.Path, dir_results: pathlib.Path | str = './tmp/', dset_name='DSET', cset_name='CSET', cset_description: str = None, cset_version=1, cat_latex=None) Tuple[str, List[str]][source]
Create a correction lib files based
- Parameters:
sas (Dict,) – dictionnary with scales and smearings
dir_results (Path, optional) – directory. Defaults to Path(‘./tmp/’).
dset_name (str, optional) – dataset nickname. Defaults to ‘DSET’.
cset_name (str, optional) – correction saet name. Defaults to ‘CSET’.
cset_description (str, optional) – description of the correction set. Defaults to None.
cset_version (int, optional) – correction set version. Defaults to 1.
cat_latex (Dict, optional) – dictionnary with a description of variables in categories. Defaults to None.
- ijazz.sas_utils.compute_syst_from_jsons(nominal: Dict | str | pathlib.Path, syst_jsons: List[Dict | str | pathlib.Path], fit_2g: Dict | str | pathlib.Path = None, scale_flat_syst: float = 0.0, smear_flat_syst: float = 0.0) Tuple[str, List[str]][source]
Compute the systematic uncertainties from the json files
- Parameters:
nominal (Union[Dict, str, Path]) – nominal json file
syst_jsons (List[Union[Dict, str, Path]]) – list of json files with systematic variations
fit_2g (Union[Dict, str, Path], optional) – json file with the parameters of the double gaussian fit. Defaults to None.
scale_flat_syst (float, optional) – flat scale systematic uncertainty. Defaults to 0.0.
smear_flat_syst (float, optional) – flat smear systematic uncertainty. Defaults to 0.0.
Returns:
- ijazz.sas_utils.apply_corrlib_df(df: pandas.DataFrame, cset_vars: List[str], cset_name: str, cset_file: str, syst_name: str, mll_name='mass', ptl_name='pt')[source]
Apply the correction lib to a pandas dataframe
- Parameters:
df (pd.DataFrame) – dataframe with the variables to correct
cset_vars (List[str]) – list of the variables used in the correction
cset_name (str) – name of the correction set
cset_file (str) – name of the correction file
syst_name (str) – type of correction to apply: scale or smear
mll_name (str, optional) – dilepton mass variable name. Defaults to ‘mass’.
ptl_name (str, optional) – lepton tranverse momentum variable name. Defaults to ‘pt’.
- class ijazz.sas_utils.FuncStr(expression: str)[source]
- ijazz.sas_utils.do_pt_fit(axval, avar, eavar, func: FuncStr, p0, p_range, do_plot=False, min_pt=25, max_pt=160, width_pt=0.5)[source]
- ijazz.sas_utils.pt_smoothing(json_file: str | pathlib.Path | Dict, dim_to_fit='pt', do_plot=False) Tuple[Dict, Dict][source]
Function to fit the pT-dependent sas to make them smooth
- Parameters:
json_file (Union[str, Path]) – name of the json file containing the result of the sas fit
dim_to_fit (str, optional) – name of the pt dimension. Defaults to ‘pt’.
- Returns:
new sas dictionnary
- Return type:
Dict
- ijazz.sas_utils.create_pt_corrector(sas: Dict | str | pathlib.Path, dir_results: pathlib.Path | str = './tmp/', dset_name='DSET', cset_name='CSET', cset_description: str = None, cset_version=1, cat_latex=None, pt_name='pt')[source]
Create a correction lib files based
- Parameters:
sas (Dict,) – dictionnary with scales and smearings
dir_results (Path, optional) – directory. Defaults to Path(‘./tmp/’).
dset_name (str, optional) – dataset nickname. Defaults to ‘DSET’.
cset_name (str, optional) – correction saet name. Defaults to ‘CSET’.
cset_description (str, optional) – description of the correction set. Defaults to None.
cset_version (int, optional) – correction set version. Defaults to 1.
cat_latex (Dict, optional) – dictionnary with a description of variables in categories. Defaults to None.