PyROOT Fitting¶
- pydiana.tools.pyroot_fitting.eval_root_func(func, x, params=None)[source]¶
Interface for evaluating root functions
- Parameters:
func (ROOT.TF1 instance) --
x (array-like containing the points used for evaluation) --
params (array-like containing the values of the function parameters) --
- Returns:
y
- Return type:
array-like with the values of the evaluated function
- pydiana.tools.pyroot_fitting.extract_confidence_interval(x, ndim=1, cl=0.95)[source]¶
Function for extracting confidence intervals of LAST fitted function :type x: :param x: :type x: array at which to calculate the confidence interval, if in more than a 1D space then the coordinates must be given in order (x1,y1,z1,...,xn,yn,zn) :type ndim:
int:param ndim: :type ndim: dimension of the space of the x coordinates :type cl:float:param cl: :type cl: confidence interval used for calculation- Returns:
Vector with the values of the confidence interval
- pydiana.tools.pyroot_fitting.extract_fit_values(func)[source]¶
Interface for extracting basic fit quantities
- Parameters:
func (ROOT.TF1 instance (if units are indicated with '[' inside the parameter name, they are written in a separate column of the results).) --
- Return type:
Pandas dataframe containing the fit quantities
- pydiana.tools.pyroot_fitting.gaussian_fit(histogram, degree=None, type='Chebyshev', params=None, parfix=None, xrange=None, name='mygaus', unit='mV', get_detail_matrices=False, fit_options='QSLB', parlims=None)[source]¶
Fitting one gaussian to premade histogram
- Parameters:
histogram (dictionary containing "counts" with the heights of the histogram bars, and "bin_edges" containing the edges of the histogram bins (left and right)) --
params (array-like containing the parameters of the gaussian (constant,mean.stddev)) --
parfix (array-like contatining the index of the parameters to fix (0=constant,1=mean,2=stddev)) --
name (string with the name of the function) --
unit (units of mean/stddev) --
- Returns:
fit_results (pandas dataframe containing the fit results)
gaus (root fitted function)
- pydiana.tools.pyroot_fitting.root_fitting(graph, func, get_detail_matrices=False, options='QSB')[source]¶
Root fitting function
- Parameters:
graph (root graph instance) --
func (root function instance) --
get_detail_matrices (bool for enabling the return of the covariance and correlation matrices) --
- Returns:
Fit details and fitted function and if get detailed matrices also the covariance and correlation matrices.
- pydiana.tools.pyroot_fitting.root_func(expr, name='', parnames=None, parlims=None, parvals=None, parfix=None, xrange=None)[source]¶
Interface for defining a ROOT function
- Parameters:
(str) (name) --
(str) --
(dict) (parvals) --
(dict) --
(dict) --
(list) (parfix) --
(array-like) (xrange) --
- Return type:
ROOT TF1 Instance
- pydiana.tools.pyroot_fitting.root_hist(height, bin_edges, name=None, error_y=None)[source]¶
Interface for converting a numpy/matplotlib histogram in a ROOT histogram
- Parameters:
height (array-like containing all the heights of the bins) --
bin_edges (array-like containing all the bin edges (len(bin_edges) = len(height)+1)) --
(str) (name) --
- Return type:
ROOT TH1D instance
- pydiana.tools.pyroot_fitting.root_hist2d(height, xbin_edges, ybin_edges, name=None, title=None)[source]¶
Interface for converting a 2d numpy/matplotlib histogram in a ROOT histogram
- Parameters:
height (array-like containing all the heights of the bins) --
xbin_edges (array-like containing all the bin edges (len(bin_edges) = len(height)+1)) --
ybin_edges (array-like containing all the bin edges (len(bin_edges) = len(height)+1)) --
(str) (name) --
- Return type:
ROOT TH1D instance
- pydiana.tools.pyroot_fitting.root_hist_fit(heights, bin_edges, func, get_detail_matrices=False, options='QSBL')[source]¶
Histogram fitting function
- Parameters:
heights (Array-like containing the heights of the histogram) --
bin_edges (Array-like containing the edges of the bins) --
func (root function instance) --
get_detail_matrices (bool for enabling the return of the covariance and correlation matrices) --
- Returns:
Fit details and fitted function
- pydiana.tools.pyroot_fitting.root_scatter(y, x=None, yerr=None, xerr=None)[source]¶
Interface Function for making a root scatter plot
- Parameters:
y (array-like containing the y coordinates of the plot) --
x (array-like containing the x coordinates (if not provided the index of y will be used)) --
yerr (array-like containg the errors on the y coordinates (if absent set to 0)) --
xerr (array-like containg the errors on the x coordinates (if absent set to 0)) --
- Returns:
ROOT TGraphErrors instance