utils¶
Documentation for functions in the utilities.utils module:
- utilities.utils.default_rootpaths()[source]¶
Returns the default root file paths of the package, where background is pions and signal is kaons.
- Returns:
Three element tuple containing the paths of the pion MC, the kaon MC and the mixed data root files, respectively.
- Return type:
tuple[str]
- utilities.utils.default_txtpaths()[source]¶
Returns the .txt file paths containing the training MC array and the data array, to be used in DNN or DTC analyses.
- Returns:
Tuple containing the paths of the MC training array (50/50 signal/background for unbiased training) and the path of the data array, respectively.
- Return type:
tuple[str]
- utilities.utils.default_vars()[source]¶
Returns default variables used by the package in the pi-K analysis.
- Returns:
13 element tuple containing the names of the default variables to use.
- Return type:
tuple[str]
- utilities.utils.default_figpath(figname, dir='fig', figtype='pdf')[source]¶
Returns the path to the figure folder with respect to the cwd in which to then save figures.
- Parameters:
figname (str) – Name with which to save the figure.
dir (str) – Directory relative to cwd where to save the figure.
figtype (str) – Type of figure save file.
- Returns:
Path where to save the figure.
- Return type:
str
- utilities.utils.default_resultsdir(dir='outputs-PiKclassifier')[source]¶
Returns the path where to store the outputs of the package.
- Parameters:
dir (str) – Directory where to save the outputs.
- Returns:
The figure path.
- Return type:
str
- utilities.utils.find_cut(pi_array, k_array, efficiency, specificity_mode=False, inverse_mode=False)[source]¶
Finds where to cut a certain variable to obtain a certain sensitivity/specificity in a hypothesis test between two given species’ arrays.
- Parameters:
pi_array (numpy.array[float]) – Array containing the background species.
k_array (numpy.array[float]) – Array containing the signal species.
efficiency (float) – Sensitivity required from the test (specificity if
specificity_mode = True).specificity_mode (bool) – If set to
Truethe efficiency given is taken to be the intended specificity.inverse_mode (bool) – Set to
Trueif the signal events tend to have lower values.
- Returns:
Two element tuple containing cut value and misidentification probability for the negative species (or sensitivity if
specificity_mode = True)- Return type:
tuple[double]
- utilities.utils.plot_rocs(rocx_arrays, rocy_arrays, roc_labels, roc_linestyles, roc_colors, x_pnts=(), y_pnts=(), point_labels='', eff=0, figtitle='ROC', figname='')[source]¶
Draws superimposed roc curves and/or points
- Parameters:
rocx_arrays (list[numpy.array[float]] or tuple[numpy.array[float]]) – List or tuple of numpy arrays, each containing the respective x points of different roc curves to be plotted.
rocy_arrays (list[numpy.array[float]] or tuple[numpy.array[float]]) – List or tuple of numpy arrays, each containing the respective y points of different roc curves to be plotted.
roc_labels (list[str] or tuple[str]) – Names of the respective species whose roc coordinates were given.
roc_linestyles (list[str] or tuple[str]) – Linestyles of the respective species whose roc coordinates were given.
roc_colors (list[str] or tuple[str]) – Colors of the respective species whose roc coordinates were given.
x_pnts (list[double] or tuple[double]) – List or tuple of the respective x coordinates of points to be plotted.
y_pnts (list[double] or tuple[double]) – List or tuple of the respective y coordinates of points to be plotted.
point_labels (list[str] or tuple[str]) – List or tuple of names of the respective species whose point coordinates were given.
eff (double) – If different than 0., draws a green dashed line at y = eff on the plot.
figtitle (str) – Title to be given to the figure.
figname (str) – If different than ‘’, saves the figure as a pdf with name figname.
- utilities.utils.roc(pi_array, k_array, inverse_mode=False, makefig=False, eff=0, name='ROC')[source]¶
Returns the roc curve’s x and y coordinates given two arrays of values for two different species. optionally draws the roc curve using plot_rocs().
- Parameters:
pi_array (numpy.array[float]) – Array containing the “negative” species.
k_array (numpy.array[float]) – Array containing the “positive” species.
inverse_mode (bool) – To activate if the “positive” events tend to have lower values
makefig (bool) – If set to True draws the roc curve
eff (double) – If different than 0. and makefig = True , draws a green dashed line at y = eff on the plot.
name (str) – If makefig = True , name of the saved figure.
- Returns:
Three element tuple containing: numpy array of floats of x coordinates of the roc curve, numpy array of floats of y coordinates of the roc curve, AUC of the ROC curve.
- Return type:
tuple[numpy.array[float], numpy.array[float], float]
- utilities.utils.stat_error(fraction, data_size, eff, misid)[source]¶
Evaluates the statistical error on fraction estimate due to the finite sample of the data set, using the variance of sum of two binomials (of signal and background events respectively).
- Parameters:
fraction (float) – Estimated fraction by the algorithm.
data_size – Size of the data set.
eff (float) – Estimated efficiency of the algorithm.
misid (float) – Estimated misidentification probability (false positive) of the algorithm.
- Returns:
The statistical error associated to the fraction.
- Return type:
float
- utilities.utils.syst_error(fraction, template_sizes, eff, misid)[source]¶
Evaluates the systematic error on fraction estimate due to the finite sample used to evaluate the “efficiency” and “misid” parameters.
- Parameters:
fraction (float) – Estimated fraction by the algorithm.
template_sizes (list[int] tuple[int]) – Two element list or tuple of sizes of the evaluation arrays (background and signal dataset, in this order).
eff (float) – Estimated efficiency of the algorithm.
misid (float) – Estimated misidentification probability (false positive) of the algorithm
- Returns:
The systematic error associated to the fraction.
- Return type:
float