merge_variables

Documentation for the functions in the utilities.merge_variables module:

utilities.merge_variables.mix_function(y, x, m)[source]

Mixing function of the two variables (x,y), with the external parameter m

utilities.merge_variables.KS_optimization(v_pi, v_k, parlims=(-20, 20), n_try=1001)[source]

Performs different attempts of variable mixing, using mix_function(), calculating for each case the Kolmogorov-Smirnov statistic.

Parameters:
  • v_pi (numpy.array) – Two-column array containing the variables to be mixed, taken from the Pion template dataset

  • v_k (numpy.array) – Two-column array containing the variables to be mixed, taken from the Kaon template dataset

  • parlims (tuple[float]) – Limits of the parameter “m” where to apply the algorithm

  • n_try (int) – Number of attempts of the algorithm

Returns:

The maximum value found of the KS statistic and the corresponding value of “m”

Return type:

float, float

utilities.merge_variables.mergevar(rootpaths=('/home/docs/checkouts/readthedocs.org/user_builds/cmepda-pikclassifier/checkouts/latest/utilities/../data/root_files/B0PiPi_MC.root', '/home/docs/checkouts/readthedocs.org/user_builds/cmepda-pikclassifier/checkouts/latest/utilities/../data/root_files/B0sKK_MC.root', '/home/docs/checkouts/readthedocs.org/user_builds/cmepda-pikclassifier/checkouts/latest/utilities/../data/root_files/Bhh_data.root'), tree='t_M0pipi', vars=('M0_MKpi', 'M0_MpiK'), savefig=False, savetxt=False)[source]

Function that takes two variables stored in TTrees and mixes them to create a new feature, by using the algorithm defined implemented previously in this module. This feature is then computed for both the MCs and for data and stored in 3 arrays, returned by the function.

Parameters:
  • rootpaths (list[str] or tuple[str]) – Three element list or tuple containing .root file paths, of the “background” set (flag=0), the “signal” set (flag=1) and the mixed data set, in this order.

  • tree (str) – Name of the tree from which to load

  • vars (list[str] or tuple[str]) – Two element list or tuple of variables that are going to be merged

  • savefig (bool) – If True the figure of the new variable’s distribution is saved

  • savetxt (bool) – If True the array containing the new variable’s events is saved as .txt file

Returns:

Three element tuple containing respectively: a three element tuple of numpy arrays of the new variable (MC background, MC signal, data); a two element tuple of value retrieved by KS_optimization() and the KS statistic of the original variables; the parameter “m” which the original variables were merged with

Return type:

tuple[tuple[numpy.array[float]], tuple[float], float]