template_fit

Documentation for the functions in the template_fit.template_fit module:

template_fit.template_fit.fit_mc_template(filepath, tree, var, fitfunc, Nbins=1000, histo_lims=(5.0, 5.6), histo_name='', histo_title='', savefig=False, img_name='template.png')[source]

Performs a max-Likelihood fit on the distribution of a MC template with a custom function given in input

Parameters:
  • filepath (str) – Root file where the MC set (background or signal) is stored

  • tree (str) – Name of the tree in Root files where the events are stored

  • var (str) – Variable the fit is performed on

  • fitfunc (ROOT::TF1) – Fit function

  • Nbins (int, optional) – Number of bins of the histogram

  • histo_lims (tuple[float]) – Range of the histogram

  • histo_name (str) – Name of the histogram

  • histo_title (str) – Title of the histogram

  • savefig (bool) – If is True saves the image of the fit

  • img_name (str) – Name of the image to be saved

Returns:

Best-fit farameters of the fit function

Return type:

tuple[float]

template_fit.template_fit.global_fit(filepath, tree, var, Nbins=1000, histo_lims=(5.0, 5.6), histo_name='', histo_title='', pars_mc1=(), pars_mc2=(), fit_range=(5.02, 5.42), savefig=False, img_name='fig/Fit_data.png')[source]

Performs a max-Likelihood fit on the data set, by linearly weighting the templates’ best-fit functions. The functional form used is fixed in the external library (ROOT.TemplateComposition function); the parameters retrieved from the fits on MC templates are used to fix this function’s parameters, resulting in two fit parameters.

Parameters:
  • filepath (str) – Root file where the data set is stored

  • tree (str) – Name of the tree in the root file where the events are stored

  • var (str) – Variable the fit is performed on

  • Nbins (int) – Number of bins of the histogram

  • histo_lims (tuple[float]) – Range of the histogram

  • histo_name (str) – Name of the histogram

  • histo_title – Title of the histogram

  • pars_mc1 (tuple[float]) – Best-fit parameters of the first template function

  • pars_mc2 (tuple[float]) – Best-fit parameters of the second template function

  • fit_range (tuple[float]) – Range where the fit is performed

  • savefig (bool) – If is True saves the image of the fit

  • img_name (str) – Name of the image to be saved

Returns:

Root object containing the fit details

Return type:

ROOT::TFitResult