Logo ROOT  
Reference Guide
 
Loading...
Searching...
No Matches
ROOT::Fit::Fitter Class Reference

Fitter class, entry point for performing all type of fits.

Fits are performed using the generic ROOT::Fit::Fitter::Fit method. The inputs are the data points and a model function (using a ROOT::Math::IParamFunction) The result of the fit is returned and kept internally in the ROOT::Fit::FitResult class. The configuration of the fit (parameters, options, etc...) are specified in the ROOT::Math::FitConfig class. After fitting the config of the fit will be modified to have the new values the resulting parameter of the fit with step sizes equal to the errors. FitConfig can be preserved with initial parameters by calling FitConfig.SetUpdateAfterFit(false);

Definition at line 77 of file Fitter.h.

Public Types

typedef ROOT::Math::IMultiGenFunction BaseFunc
 
typedef ROOT::Math::IMultiGradFunction BaseGradFunc
 
typedef ROOT::Math::IParamGradFunction IGradModel1DFunction
 
typedef ROOT::Math::IParamMultiGradFunction IGradModelFunction
 
typedef ROOT::Math::IParamMultiGradFunction IGradModelFunction_v
 
typedef ROOT::Math::IParamFunction IModel1DFunction
 
typedef ROOT::Math::IParamMultiFunction IModelFunction
 
typedef ROOT::Math::IParamMultiFunction IModelFunction_v
 
template<class T >
using IModelFunctionTempl = ROOT::Math::IParamMultiFunctionTempl< T >
 
typedef void(* MinuitFCN_t) (int &npar, double *gin, double &f, double *u, int flag)
 fit using user provided FCN with Minuit-like interface If npar = 0 it is assumed that the parameters are specified in the parameter settings created before For the options same consideration as in the previous method
 

Public Member Functions

 Fitter ()
 Default constructor.
 
 Fitter (const Fitter &)=delete
 Copy constructor (disabled, class is not copyable)
 
 Fitter (const std::shared_ptr< FitResult > &result)
 Constructor from a result.
 
virtual ~Fitter ()
 Destructor.
 
bool ApplyWeightCorrection (const ROOT::Math::IMultiGenFunction &loglw2, bool minimizeW2L=false)
 apply correction in the error matrix for the weights for likelihood fits This method can be called only after a fit.
 
bool CalculateHessErrors ()
 perform an error analysis on the result using the Hessian Errors are obtained from the inverse of the Hessian matrix To be called only after fitting and when a minimizer supporting the Hessian calculations is used otherwise an error (false) is returned.
 
bool CalculateMinosErrors ()
 perform an error analysis on the result using MINOS To be called only after fitting and when a minimizer supporting MINOS is used otherwise an error (false) is returned.
 
FitConfigConfig ()
 access to the configuration (non const method)
 
const FitConfigConfig () const
 access to the fit configuration (const method)
 
bool EvalFCN ()
 Perform a simple FCN evaluation.
 
bool Fit (const BinData &data, const ROOT::EExecutionPolicy &executionPolicy=ROOT::EExecutionPolicy::kSequential)
 Fit a binned data set using a least square fit.
 
template<class Data , class Function , class cond = typename std::enable_if<!(std::is_same<Function, ROOT::EExecutionPolicy>::value || std::is_same<Function, int>::value), Function>::type>
bool Fit (const Data &data, const Function &func, const ROOT::EExecutionPolicy &executionPolicy=ROOT::EExecutionPolicy::kSequential)
 fit a data set using any generic model function If data set is binned a least square fit is performed If data set is unbinned a maximum likelihood fit (not extended) is done Pre-requisite on the function: it must implement the 1D or multidimensional parametric function interface.
 
bool Fit (const std::shared_ptr< BinData > &data, const ROOT::EExecutionPolicy &executionPolicy=ROOT::EExecutionPolicy::kSequential)
 Fit a binned data set using a least square fit.
 
bool Fit (const std::shared_ptr< UnBinData > &data, bool extended=false, const ROOT::EExecutionPolicy &executionPolicy=ROOT::EExecutionPolicy::kSequential)
 Fit an un-binned data set using the negative log-likelihood method.
 
bool Fit (const UnBinData &data, bool extended=false, const ROOT::EExecutionPolicy &executionPolicy=ROOT::EExecutionPolicy::kSequential)
 Fit an un-binned data set using the negative log-likelihood method.
 
bool FitFCN ()
 Perform a fit with the previously set FCN function.
 
bool FitFCN (const ROOT::Math::FitMethodFunction &fcn, const double *params=nullptr)
 Fit using a FitMethodFunction interface.
 
bool FitFCN (const ROOT::Math::FitMethodGradFunction &fcn, const double *params=nullptr)
 Fit using a FitMethodGradFunction interface.
 
bool FitFCN (const ROOT::Math::IMultiGenFunction &fcn, const double *params=nullptr, unsigned int dataSize=0, bool chi2fit=false)
 Fit using the given FCN function represented by a multi-dimensional function interface (ROOT::Math::IMultiGenFunction).
 
bool FitFCN (MinuitFCN_t fcn, int npar=0, const double *params=nullptr, unsigned int dataSize=0, bool chi2fit=false)
 
template<class Function >
bool FitFCN (unsigned int npar, Function &fcn, const double *params=nullptr, unsigned int dataSize=0, bool chi2fit=false)
 Fit using the a generic FCN function as a C++ callable object implementing double () (const double *) Note that the function dimension (i.e.
 
ROOT::Math::IMultiGenFunctionGetFCN () const
 return pointer to last used objective function (is NULL in case fit is not yet done) This pointer will be valid as far as the fitter class has not been deleted.
 
ROOT::Math::MinimizerGetMinimizer () const
 return pointer to last used minimizer (is NULL in case fit is not yet done) This pointer is guaranteed to be valid as far as the fitter class is valid and a new fit is not redone.
 
bool IsBinFit () const
 query if fit is binned.
 
bool LeastSquareFit (const BinData &data, const ROOT::EExecutionPolicy &executionPolicy=ROOT::EExecutionPolicy::kSequential)
 Fit a binned data set using a least square fit copying the input data.
 
bool LeastSquareFit (const std::shared_ptr< BinData > &data, const ROOT::EExecutionPolicy &executionPolicy=ROOT::EExecutionPolicy::kSequential)
 Fit a binned data set using a least square fit NOT copying the input data.
 
bool LikelihoodFit (const BinData &data, bool extended=true, const ROOT::EExecutionPolicy &executionPolicy=ROOT::EExecutionPolicy::kSequential)
 Binned Likelihood fit copying the input data.
 
template<class Data , class Function >
bool LikelihoodFit (const Data &data, const Function &func, bool extended)
 Likelihood fit given a data set (Binned or Un-binned) using any generic model function.
 
bool LikelihoodFit (const std::shared_ptr< BinData > &data, bool extended=true, const ROOT::EExecutionPolicy &executionPolicy=ROOT::EExecutionPolicy::kSequential)
 Binned Likelihood fit using a shared_ptr for NOT copying the input data.
 
bool LikelihoodFit (const std::shared_ptr< UnBinData > &data, bool extended=false, const ROOT::EExecutionPolicy &executionPolicy=ROOT::EExecutionPolicy::kSequential)
 Un-binned Likelihood fit using a shared_ptr for NOT copying the input data.
 
bool LikelihoodFit (const UnBinData &data, bool extended=false, const ROOT::EExecutionPolicy &executionPolicy=ROOT::EExecutionPolicy::kSequential)
 Un-binned Likelihood fit copying the input data Default is NOT extended.
 
bool LinearFit (const BinData &data)
 Do a linear fit copying the input data.
 
bool LinearFit (const std::shared_ptr< BinData > &data)
 Do a linear fit using a shared_ptr for NOT copying the input data.
 
Fitteroperator= (const Fitter &)=delete
 Assignment operator (disabled, class is not copyable)
 
const FitResultResult () const
 get fit result
 
bool SetFCN (const ROOT::Math::FitMethodFunction &fcn, const double *params=nullptr)
 Set the objective function (FCN) using a FitMethodFunction interface.
 
bool SetFCN (const ROOT::Math::FitMethodGradFunction &fcn, const double *params=nullptr)
 Set the objective function (FCN) using a FitMethodGradFunction interface.
 
bool SetFCN (const ROOT::Math::IMultiGenFunction &fcn, const double *params=nullptr, unsigned int dataSize=0, bool chi2fit=false)
 Set the FCN function represented by a multi-dimensional function interface (ROOT::Math::IMultiGenFunction) and optionally the initial parameters See also note above for the initial parameters for FitFCN.
 
bool SetFCN (const ROOT::Math::IMultiGenFunction &fcn, const IModelFunction &func, const double *params=nullptr, unsigned int dataSize=0, bool chi2fit=false)
 Set the FCN function represented by a multi-dimensional function interface (ROOT::Math::IMultiGenFunction) and optionally the initial parameters See also note above for the initial parameters for FitFCN With this interface we pass in addition a ModelFunction that will be attached to the FitResult and used to compute confidence interval of the fit.
 
bool SetFCN (MinuitFCN_t fcn, int npar=0, const double *params=nullptr, unsigned int dataSize=0, bool chi2fit=false)
 set objective function using user provided FCN with Minuit-like interface If npar = 0 it is assumed that the parameters are specified in the parameter settings created before For the options same consideration as in the previous method
 
template<class Function >
bool SetFCN (unsigned int npar, Function &fcn, const double *params=nullptr, unsigned int dataSize=0, bool chi2fit=false)
 Set a generic FCN function as a C++ callable object implementing double () (const double *) Note that the function dimension (i.e.
 
void SetFitType (int type)
 Set the type of fit when using an external FCN possible types are : 1 (least-square), 2 (unbinned-likelihood), 3 (binned-likelihood) Note that in case of binned likelihood fit the chi2 will be computed as 2 * MinFCN() Note this function should be called before fitting to have effect on th FitResult.
 
void SetFunction (const IGradModel1DFunction &func, bool useGradient=true)
 Set the fitted function from 1D gradient parametric function interface.
 
void SetFunction (const IGradModelFunction &func, bool useGradient=true)
 Set the fitted function (model function) from a parametric gradient function interface.
 
void SetFunction (const IModel1DFunction &func, bool useGradient=false)
 Set the fitted function (model function) from a vectorized parametric function interface.
 
void SetFunction (const IModelFunction &func, bool useGradient=false)
 Set the fitted function (model function) from a parametric function interface.
 
void SetNumberOfFitPoints (unsigned int npoints)
 Set number of fit points when using an external FCN function This function can be called after Fit to set the correct number of Ndf in FitResult.
 

Protected Member Functions

bool DoBinnedLikelihoodFit (bool extended=true, const ROOT::EExecutionPolicy &executionPolicy=ROOT::EExecutionPolicy::kSequential)
 binned likelihood fit
 
bool DoInitMinimizer ()
 
bool DoLeastSquareFit (const ROOT::EExecutionPolicy &executionPolicy=ROOT::EExecutionPolicy::kSequential)
 least square fit
 
bool DoLinearFit ()
 linear least square fit
 
bool DoMinimization (const ROOT::Math::IMultiGenFunction *chifunc=nullptr)
 
template<class ObjFunc_t >
bool DoMinimization (std::unique_ptr< ObjFunc_t > f, const ROOT::Math::IMultiGenFunction *chifunc=nullptr)
 do minimization
 
bool DoSetFCN (bool useExtFCN, const ROOT::Math::IMultiGenFunction &fcn, const double *params, unsigned int dataSize, bool chi2fit)
 Set Objective function.
 
bool DoUnbinnedLikelihoodFit (bool extended=false, const ROOT::EExecutionPolicy &executionPolicy=ROOT::EExecutionPolicy::kSequential)
 un-binned likelihood fit
 
void DoUpdateFitConfig ()
 
bool DoUpdateMinimizerOptions (bool canDifferentMinim=true)
 
template<class ObjFunc_t >
bool DoWeightMinimization (std::unique_ptr< ObjFunc_t > f, const ROOT::Math::IMultiGenFunction *chifunc=nullptr)
 
void ExamineFCN ()
 look at the user provided FCN and get data and model function is they derive from ROOT::Fit FCN classes
 
template<class ObjFuncType >
bool GetDataFromFCN ()
 internal functions to get data set and model function from FCN useful for fits done with customized FCN classes
 
int GetNCallsFromFCN ()
 
const ROOT::Math::IBaseFunctionMultiDimTempl< double > * ObjFunction () const
 Return pointer to the used objective function for fitting.
 
template<class Data >
void SetData (const Data &data)
 Set the input data for the fit (Copying the given data object)
 
template<class Data >
void SetData (const std::shared_ptr< Data > &data)
 Set the input data for the fit using a shared ptr (No Copying)
 

Private Attributes

bool fBinFit = false
 flag to indicate if fit is binned in case of false the fit is unbinned or undefined) flag it is used to compute chi2 for binned likelihood fit
 
FitConfig fConfig
 fitter configuration (options and parameter settings)
 
std::shared_ptr< ROOT::Fit::FitDatafData
 ! pointer to the fit data (binned or unbinned data)
 
int fDataSize = 0
 size of data sets (need for Fumili or LM fitters)
 
const ROOT::Math::IMultiGenFunctionfExtObjFunction = nullptr
 ! pointer to an external FCN
 
int fFitType = 0
 type of fit (0 undefined, 1 least square, 2 likelihood, 3 binned likelihood)
 
std::shared_ptr< IModelFunctionfFunc
 ! copy of the fitted function containing on output the fit result
 
std::shared_ptr< IModelFunction_vfFunc_v
 ! copy of the fitted function containing on output the fit result
 
std::shared_ptr< ROOT::Math::MinimizerfMinimizer
 ! pointer to used minimizer
 
std::shared_ptr< ROOT::Math::IMultiGenFunctionfObjFunction
 ! pointer to used objective function
 
std::shared_ptr< ROOT::Fit::FitResultfResult
 ! pointer to the object containing the result of the fit
 
bool fUseGradient = false
 flag to indicate if using gradient or not
 

#include <Fit/Fitter.h>

Member Typedef Documentation

◆ BaseFunc

◆ BaseGradFunc

◆ IGradModel1DFunction

◆ IGradModelFunction

◆ IGradModelFunction_v

◆ IModel1DFunction

◆ IModelFunction

◆ IModelFunction_v

◆ IModelFunctionTempl

Definition at line 83 of file Fitter.h.

◆ MinuitFCN_t

typedef void(* ROOT::Fit::Fitter::MinuitFCN_t) (int &npar, double *gin, double &f, double *u, int flag)

fit using user provided FCN with Minuit-like interface If npar = 0 it is assumed that the parameters are specified in the parameter settings created before For the options same consideration as in the previous method

Definition at line 338 of file Fitter.h.

Constructor & Destructor Documentation

◆ Fitter() [1/3]

ROOT::Fit::Fitter::Fitter ( )
inline

Default constructor.

Definition at line 102 of file Fitter.h.

◆ Fitter() [2/3]

ROOT::Fit::Fitter::Fitter ( const std::shared_ptr< FitResult > &  result)

Constructor from a result.

Definition at line 51 of file Fitter.cxx.

◆ ~Fitter()

virtual ROOT::Fit::Fitter::~Fitter ( )
inlinevirtual

Destructor.

Make it virtual in case users derive from Fitter class to extend it by adding new methods. This is needed to avoid a warning seen when doing from Python (see ROOT issue #12391 ). Note that the Fitter class does not provide virtual functions to be re-implemented by derived classes.

Definition at line 117 of file Fitter.h.

◆ Fitter() [3/3]

ROOT::Fit::Fitter::Fitter ( const Fitter )
delete

Copy constructor (disabled, class is not copyable)

Member Function Documentation

◆ ApplyWeightCorrection()

bool ROOT::Fit::Fitter::ApplyWeightCorrection ( const ROOT::Math::IMultiGenFunction loglw2,
bool  minimizeW2L = false 
)

apply correction in the error matrix for the weights for likelihood fits This method can be called only after a fit.

The passed function (loglw2) is a log-likelihood function implemented using the sum of weight squared When using FitConfig.SetWeightCorrection() this correction is applied automatically when doing a likelihood fit (binned or unbinned)

Definition at line 888 of file Fitter.cxx.

◆ CalculateHessErrors()

bool ROOT::Fit::Fitter::CalculateHessErrors ( )

perform an error analysis on the result using the Hessian Errors are obtained from the inverse of the Hessian matrix To be called only after fitting and when a minimizer supporting the Hessian calculations is used otherwise an error (false) is returned.

A new FitResult with the Hessian result will be produced

Definition at line 532 of file Fitter.cxx.

◆ CalculateMinosErrors()

bool ROOT::Fit::Fitter::CalculateMinosErrors ( )

perform an error analysis on the result using MINOS To be called only after fitting and when a minimizer supporting MINOS is used otherwise an error (false) is returned.

The result will be appended in the fit result class Optionally a vector of parameter indices can be passed for selecting the parameters to analyse using FitConfig::SetMinosErrors

Definition at line 595 of file Fitter.cxx.

◆ Config() [1/2]

FitConfig & ROOT::Fit::Fitter::Config ( )
inline

access to the configuration (non const method)

Definition at line 426 of file Fitter.h.

◆ Config() [2/2]

const FitConfig & ROOT::Fit::Fitter::Config ( ) const
inline

access to the fit configuration (const method)

Definition at line 421 of file Fitter.h.

◆ DoBinnedLikelihoodFit()

bool ROOT::Fit::Fitter::DoBinnedLikelihoodFit ( bool  extended = true,
const ROOT::EExecutionPolicy executionPolicy = ROOT::EExecutionPolicy::kSequential 
)
protected

binned likelihood fit

Definition at line 362 of file Fitter.cxx.

◆ DoInitMinimizer()

bool ROOT::Fit::Fitter::DoInitMinimizer ( )
protected

Definition at line 694 of file Fitter.cxx.

◆ DoLeastSquareFit()

bool ROOT::Fit::Fitter::DoLeastSquareFit ( const ROOT::EExecutionPolicy executionPolicy = ROOT::EExecutionPolicy::kSequential)
protected

least square fit

Definition at line 311 of file Fitter.cxx.

◆ DoLinearFit()

bool ROOT::Fit::Fitter::DoLinearFit ( )
protected

linear least square fit

Definition at line 515 of file Fitter.cxx.

◆ DoMinimization() [1/2]

bool ROOT::Fit::Fitter::DoMinimization ( const ROOT::Math::IMultiGenFunction chifunc = nullptr)
protected

Definition at line 797 of file Fitter.cxx.

◆ DoMinimization() [2/2]

template<class ObjFunc_t >
bool ROOT::Fit::Fitter::DoMinimization ( std::unique_ptr< ObjFunc_t >  f,
const ROOT::Math::IMultiGenFunction chifunc = nullptr 
)
protected

do minimization

Definition at line 838 of file Fitter.cxx.

◆ DoSetFCN()

bool ROOT::Fit::Fitter::DoSetFCN ( bool  useExtFCN,
const ROOT::Math::IMultiGenFunction fcn,
const double params,
unsigned int  dataSize,
bool  chi2fit 
)
protected

Set Objective function.

Definition at line 137 of file Fitter.cxx.

◆ DoUnbinnedLikelihoodFit()

bool ROOT::Fit::Fitter::DoUnbinnedLikelihoodFit ( bool  extended = false,
const ROOT::EExecutionPolicy executionPolicy = ROOT::EExecutionPolicy::kSequential 
)
protected

un-binned likelihood fit

Definition at line 442 of file Fitter.cxx.

◆ DoUpdateFitConfig()

void ROOT::Fit::Fitter::DoUpdateFitConfig ( )
protected

Definition at line 862 of file Fitter.cxx.

◆ DoUpdateMinimizerOptions()

bool ROOT::Fit::Fitter::DoUpdateMinimizerOptions ( bool  canDifferentMinim = true)
protected

Definition at line 765 of file Fitter.cxx.

◆ DoWeightMinimization()

template<class ObjFunc_t >
bool ROOT::Fit::Fitter::DoWeightMinimization ( std::unique_ptr< ObjFunc_t >  f,
const ROOT::Math::IMultiGenFunction chifunc = nullptr 
)
protected

Definition at line 847 of file Fitter.cxx.

◆ EvalFCN()

bool ROOT::Fit::Fitter::EvalFCN ( )

Perform a simple FCN evaluation.

FitResult will be modified and contain the value of the FCN

Definition at line 290 of file Fitter.cxx.

◆ ExamineFCN()

void ROOT::Fit::Fitter::ExamineFCN ( )
protected

look at the user provided FCN and get data and model function is they derive from ROOT::Fit FCN classes

Definition at line 981 of file Fitter.cxx.

◆ Fit() [1/5]

bool ROOT::Fit::Fitter::Fit ( const BinData data,
const ROOT::EExecutionPolicy executionPolicy = ROOT::EExecutionPolicy::kSequential 
)
inline

Fit a binned data set using a least square fit.

Note that the provided input data are copied in the Fitter class. Use the next function (passing a shared_ptr to the BinData class if you want to avoid copying.

Definition at line 157 of file Fitter.h.

◆ Fit() [2/5]

template<class Data , class Function , class cond = typename std::enable_if<!(std::is_same<Function, ROOT::EExecutionPolicy>::value || std::is_same<Function, int>::value), Function>::type>
bool ROOT::Fit::Fitter::Fit ( const Data &  data,
const Function func,
const ROOT::EExecutionPolicy executionPolicy = ROOT::EExecutionPolicy::kSequential 
)
inline

fit a data set using any generic model function If data set is binned a least square fit is performed If data set is unbinned a maximum likelihood fit (not extended) is done Pre-requisite on the function: it must implement the 1D or multidimensional parametric function interface.

Note that both the input data and the function object are copied by the Fitter.

Definition at line 144 of file Fitter.h.

◆ Fit() [3/5]

bool ROOT::Fit::Fitter::Fit ( const std::shared_ptr< BinData > &  data,
const ROOT::EExecutionPolicy executionPolicy = ROOT::EExecutionPolicy::kSequential 
)
inline

Fit a binned data set using a least square fit.

Pass the input data using a shared_ptr for NOT copying the input data.

Definition at line 165 of file Fitter.h.

◆ Fit() [4/5]

bool ROOT::Fit::Fitter::Fit ( const std::shared_ptr< UnBinData > &  data,
bool  extended = false,
const ROOT::EExecutionPolicy executionPolicy = ROOT::EExecutionPolicy::kSequential 
)
inline

Fit an un-binned data set using the negative log-likelihood method.

This function uses a shared_ptr to avoid copying the input data.

Definition at line 195 of file Fitter.h.

◆ Fit() [5/5]

bool ROOT::Fit::Fitter::Fit ( const UnBinData data,
bool  extended = false,
const ROOT::EExecutionPolicy executionPolicy = ROOT::EExecutionPolicy::kSequential 
)
inline

Fit an un-binned data set using the negative log-likelihood method.

This function copies the input data.

Definition at line 188 of file Fitter.h.

◆ FitFCN() [1/6]

bool ROOT::Fit::Fitter::FitFCN ( )

Perform a fit with the previously set FCN function.

Require SetFCN before

Definition at line 271 of file Fitter.cxx.

◆ FitFCN() [2/6]

bool ROOT::Fit::Fitter::FitFCN ( const ROOT::Math::FitMethodFunction fcn,
const double params = nullptr 
)

Fit using a FitMethodFunction interface.

Same as method above, but now extra information can be taken from the function class

Definition at line 228 of file Fitter.cxx.

◆ FitFCN() [3/6]

bool ROOT::Fit::Fitter::FitFCN ( const ROOT::Math::FitMethodGradFunction fcn,
const double params = nullptr 
)

Fit using a FitMethodGradFunction interface.

Same as method above, but now extra information can be taken from the function class

◆ FitFCN() [4/6]

bool ROOT::Fit::Fitter::FitFCN ( const ROOT::Math::IMultiGenFunction fcn,
const double params = nullptr,
unsigned int  dataSize = 0,
bool  chi2fit = false 
)

Fit using the given FCN function represented by a multi-dimensional function interface (ROOT::Math::IMultiGenFunction).

Give optionally the initial parameter values, data size to have the fit Ndf correctly set in the FitResult and flag specifying if it is a chi2 fit. Note that if the parameters values are not given (params=0) the current parameter settings are used. The parameter settings can be created before by using the FitConfig::SetParamsSetting. If they have not been created they are created automatically when the params pointer is not zero. Note that passing a params != 0 will set the parameter settings to the new value AND also the step sizes to some pre-defined value (stepsize = 0.3 * abs(parameter_value) )

Definition at line 219 of file Fitter.cxx.

◆ FitFCN() [5/6]

bool ROOT::Fit::Fitter::FitFCN ( MinuitFCN_t  fcn,
int  npar = 0,
const double params = nullptr,
unsigned int  dataSize = 0,
bool  chi2fit = false 
)

Definition at line 261 of file Fitter.cxx.

◆ FitFCN() [6/6]

template<class Function >
bool ROOT::Fit::Fitter::FitFCN ( unsigned int  npar,
Function fcn,
const double params = nullptr,
unsigned int  dataSize = 0,
bool  chi2fit = false 
)

Fit using the a generic FCN function as a C++ callable object implementing double () (const double *) Note that the function dimension (i.e.

the number of parameter) is needed in this case For the options see documentation for following methods FitFCN(IMultiGenFunction & fcn,..)

Definition at line 649 of file Fitter.h.

◆ GetDataFromFCN()

template<class ObjFuncType >
bool ROOT::Fit::Fitter::GetDataFromFCN
protected

internal functions to get data set and model function from FCN useful for fits done with customized FCN classes

Definition at line 583 of file Fitter.h.

◆ GetFCN()

ROOT::Math::IMultiGenFunction * ROOT::Fit::Fitter::GetFCN ( ) const
inline

return pointer to last used objective function (is NULL in case fit is not yet done) This pointer will be valid as far as the fitter class has not been deleted.

To be used after the fitting. The pointer should not be stored and will be invalided after performing a new fitting. In this case a new instance of the function pointer will be re-created and can be obtained calling again GetFCN()

Definition at line 454 of file Fitter.h.

◆ GetMinimizer()

ROOT::Math::Minimizer * ROOT::Fit::Fitter::GetMinimizer ( ) const
inline

return pointer to last used minimizer (is NULL in case fit is not yet done) This pointer is guaranteed to be valid as far as the fitter class is valid and a new fit is not redone.

To be used only after fitting. The pointer should not be stored and will be invalided after performing a new fitting. In this case a new instance of ROOT::Math::Minimizer will be re-created and can be obtained calling again GetMinimizer()

Definition at line 443 of file Fitter.h.

◆ GetNCallsFromFCN()

int ROOT::Fit::Fitter::GetNCallsFromFCN ( )
protected

Definition at line 872 of file Fitter.cxx.

◆ IsBinFit()

bool ROOT::Fit::Fitter::IsBinFit ( ) const
inline

query if fit is binned.

In cse of false the fit can be unbinned or is not defined (like in case of fitting through a ROOT::Fit::Fitter::FitFCN)

Definition at line 432 of file Fitter.h.

◆ LeastSquareFit() [1/2]

bool ROOT::Fit::Fitter::LeastSquareFit ( const BinData data,
const ROOT::EExecutionPolicy executionPolicy = ROOT::EExecutionPolicy::kSequential 
)
inline

Fit a binned data set using a least square fit copying the input data.

Definition at line 172 of file Fitter.h.

◆ LeastSquareFit() [2/2]

bool ROOT::Fit::Fitter::LeastSquareFit ( const std::shared_ptr< BinData > &  data,
const ROOT::EExecutionPolicy executionPolicy = ROOT::EExecutionPolicy::kSequential 
)
inline

Fit a binned data set using a least square fit NOT copying the input data.

Definition at line 179 of file Fitter.h.

◆ LikelihoodFit() [1/5]

bool ROOT::Fit::Fitter::LikelihoodFit ( const BinData data,
bool  extended = true,
const ROOT::EExecutionPolicy executionPolicy = ROOT::EExecutionPolicy::kSequential 
)
inline

Binned Likelihood fit copying the input data.

Default is extended.

Definition at line 203 of file Fitter.h.

◆ LikelihoodFit() [2/5]

template<class Data , class Function >
bool ROOT::Fit::Fitter::LikelihoodFit ( const Data &  data,
const Function func,
bool  extended 
)
inline

Likelihood fit given a data set (Binned or Un-binned) using any generic model function.

This interface copies the input data and the model function object

Definition at line 239 of file Fitter.h.

◆ LikelihoodFit() [3/5]

bool ROOT::Fit::Fitter::LikelihoodFit ( const std::shared_ptr< BinData > &  data,
bool  extended = true,
const ROOT::EExecutionPolicy executionPolicy = ROOT::EExecutionPolicy::kSequential 
)
inline

Binned Likelihood fit using a shared_ptr for NOT copying the input data.

Default is extended.

Definition at line 212 of file Fitter.h.

◆ LikelihoodFit() [4/5]

bool ROOT::Fit::Fitter::LikelihoodFit ( const std::shared_ptr< UnBinData > &  data,
bool  extended = false,
const ROOT::EExecutionPolicy executionPolicy = ROOT::EExecutionPolicy::kSequential 
)
inline

Un-binned Likelihood fit using a shared_ptr for NOT copying the input data.

Default is NOT extended

Definition at line 229 of file Fitter.h.

◆ LikelihoodFit() [5/5]

bool ROOT::Fit::Fitter::LikelihoodFit ( const UnBinData data,
bool  extended = false,
const ROOT::EExecutionPolicy executionPolicy = ROOT::EExecutionPolicy::kSequential 
)
inline

Un-binned Likelihood fit copying the input data Default is NOT extended.

Definition at line 221 of file Fitter.h.

◆ LinearFit() [1/2]

bool ROOT::Fit::Fitter::LinearFit ( const BinData data)
inline

Do a linear fit copying the input data.

Definition at line 247 of file Fitter.h.

◆ LinearFit() [2/2]

bool ROOT::Fit::Fitter::LinearFit ( const std::shared_ptr< BinData > &  data)
inline

Do a linear fit using a shared_ptr for NOT copying the input data.

Definition at line 254 of file Fitter.h.

◆ ObjFunction()

const ROOT::Math::IBaseFunctionMultiDimTempl< double > * ROOT::Fit::Fitter::ObjFunction ( ) const
inlineprotected

Return pointer to the used objective function for fitting.

If using an external function (e.g. given in SetFCN), return the cached pointer, otherwise use the one stored as shared ptr and managed by the Fitter class

Definition at line 543 of file Fitter.h.

◆ operator=()

Fitter & ROOT::Fit::Fitter::operator= ( const Fitter )
delete

Assignment operator (disabled, class is not copyable)

◆ Result()

const FitResult & ROOT::Fit::Fitter::Result ( ) const
inline

get fit result

Definition at line 393 of file Fitter.h.

◆ SetData() [1/2]

template<class Data >
void ROOT::Fit::Fitter::SetData ( const Data &  data)
inlineprotected

Set the input data for the fit (Copying the given data object)

Definition at line 525 of file Fitter.h.

◆ SetData() [2/2]

template<class Data >
void ROOT::Fit::Fitter::SetData ( const std::shared_ptr< Data > &  data)
inlineprotected

Set the input data for the fit using a shared ptr (No Copying)

Definition at line 519 of file Fitter.h.

◆ SetFCN() [1/6]

bool ROOT::Fit::Fitter::SetFCN ( const ROOT::Math::FitMethodFunction fcn,
const double params = nullptr 
)

Set the objective function (FCN) using a FitMethodFunction interface.

Same as method above, but now extra information can be taken from the function class

Definition at line 195 of file Fitter.cxx.

◆ SetFCN() [2/6]

bool ROOT::Fit::Fitter::SetFCN ( const ROOT::Math::FitMethodGradFunction fcn,
const double params = nullptr 
)

Set the objective function (FCN) using a FitMethodGradFunction interface.

Same as method above, but now extra information can be taken from the function class

◆ SetFCN() [3/6]

bool ROOT::Fit::Fitter::SetFCN ( const ROOT::Math::IMultiGenFunction fcn,
const double params = nullptr,
unsigned int  dataSize = 0,
bool  chi2fit = false 
)

Set the FCN function represented by a multi-dimensional function interface (ROOT::Math::IMultiGenFunction) and optionally the initial parameters See also note above for the initial parameters for FitFCN.

Definition at line 178 of file Fitter.cxx.

◆ SetFCN() [4/6]

bool ROOT::Fit::Fitter::SetFCN ( const ROOT::Math::IMultiGenFunction fcn,
const IModelFunction func,
const double params = nullptr,
unsigned int  dataSize = 0,
bool  chi2fit = false 
)

Set the FCN function represented by a multi-dimensional function interface (ROOT::Math::IMultiGenFunction) and optionally the initial parameters See also note above for the initial parameters for FitFCN With this interface we pass in addition a ModelFunction that will be attached to the FitResult and used to compute confidence interval of the fit.

Definition at line 182 of file Fitter.cxx.

◆ SetFCN() [5/6]

bool ROOT::Fit::Fitter::SetFCN ( MinuitFCN_t  fcn,
int  npar = 0,
const double params = nullptr,
unsigned int  dataSize = 0,
bool  chi2fit = false 
)

set objective function using user provided FCN with Minuit-like interface If npar = 0 it is assumed that the parameters are specified in the parameter settings created before For the options same consideration as in the previous method

Definition at line 244 of file Fitter.cxx.

◆ SetFCN() [6/6]

template<class Function >
bool ROOT::Fit::Fitter::SetFCN ( unsigned int  npar,
Function fcn,
const double params = nullptr,
unsigned int  dataSize = 0,
bool  chi2fit = false 
)

Set a generic FCN function as a C++ callable object implementing double () (const double *) Note that the function dimension (i.e.

the number of parameter) is needed in this case For the options see documentation for following methods FitFCN(IMultiGenFunction & fcn,..)

Definition at line 656 of file Fitter.h.

◆ SetFitType()

void ROOT::Fit::Fitter::SetFitType ( int  type)
inline

Set the type of fit when using an external FCN possible types are : 1 (least-square), 2 (unbinned-likelihood), 3 (binned-likelihood) Note that in case of binned likelihood fit the chi2 will be computed as 2 * MinFCN() Note this function should be called before fitting to have effect on th FitResult.

Definition at line 480 of file Fitter.h.

◆ SetFunction() [1/4]

void ROOT::Fit::Fitter::SetFunction ( const IGradModel1DFunction func,
bool  useGradient = true 
)

Set the fitted function from 1D gradient parametric function interface.

Definition at line 124 of file Fitter.cxx.

◆ SetFunction() [2/4]

void ROOT::Fit::Fitter::SetFunction ( const IGradModelFunction func,
bool  useGradient = true 
)

Set the fitted function (model function) from a parametric gradient function interface.

Definition at line 110 of file Fitter.cxx.

◆ SetFunction() [3/4]

void ROOT::Fit::Fitter::SetFunction ( const IModel1DFunction func,
bool  useGradient = false 
)

Set the fitted function (model function) from a vectorized parametric function interface.

Set the fitted function from a parametric 1D function interface

Definition at line 86 of file Fitter.cxx.

◆ SetFunction() [4/4]

void ROOT::Fit::Fitter::SetFunction ( const IModelFunction func,
bool  useGradient = false 
)

Set the fitted function (model function) from a parametric function interface.

Definition at line 59 of file Fitter.cxx.

◆ SetNumberOfFitPoints()

void ROOT::Fit::Fitter::SetNumberOfFitPoints ( unsigned int  npoints)
inline

Set number of fit points when using an external FCN function This function can be called after Fit to set the correct number of Ndf in FitResult.

Definition at line 471 of file Fitter.h.

Member Data Documentation

◆ fBinFit

bool ROOT::Fit::Fitter::fBinFit = false
private

flag to indicate if fit is binned in case of false the fit is unbinned or undefined) flag it is used to compute chi2 for binned likelihood fit

Definition at line 553 of file Fitter.h.

◆ fConfig

FitConfig ROOT::Fit::Fitter::fConfig
private

fitter configuration (options and parameter settings)

Definition at line 561 of file Fitter.h.

◆ fData

std::shared_ptr<ROOT::Fit::FitData> ROOT::Fit::Fitter::fData
private

! pointer to the fit data (binned or unbinned data)

Definition at line 571 of file Fitter.h.

◆ fDataSize

int ROOT::Fit::Fitter::fDataSize = 0
private

size of data sets (need for Fumili or LM fitters)

Definition at line 559 of file Fitter.h.

◆ fExtObjFunction

const ROOT::Math::IMultiGenFunction* ROOT::Fit::Fitter::fExtObjFunction = nullptr
private

! pointer to an external FCN

Definition at line 575 of file Fitter.h.

◆ fFitType

int ROOT::Fit::Fitter::fFitType = 0
private

type of fit (0 undefined, 1 least square, 2 likelihood, 3 binned likelihood)

Definition at line 557 of file Fitter.h.

◆ fFunc

std::shared_ptr<IModelFunction> ROOT::Fit::Fitter::fFunc
private

! copy of the fitted function containing on output the fit result

Definition at line 565 of file Fitter.h.

◆ fFunc_v

std::shared_ptr<IModelFunction_v> ROOT::Fit::Fitter::fFunc_v
private

! copy of the fitted function containing on output the fit result

Definition at line 563 of file Fitter.h.

◆ fMinimizer

std::shared_ptr<ROOT::Math::Minimizer> ROOT::Fit::Fitter::fMinimizer
private

! pointer to used minimizer

Definition at line 569 of file Fitter.h.

◆ fObjFunction

std::shared_ptr<ROOT::Math::IMultiGenFunction> ROOT::Fit::Fitter::fObjFunction
private

! pointer to used objective function

Definition at line 573 of file Fitter.h.

◆ fResult

std::shared_ptr<ROOT::Fit::FitResult> ROOT::Fit::Fitter::fResult
private

! pointer to the object containing the result of the fit

Definition at line 567 of file Fitter.h.

◆ fUseGradient

bool ROOT::Fit::Fitter::fUseGradient = false
private

flag to indicate if using gradient or not

Definition at line 551 of file Fitter.h.

Libraries for ROOT::Fit::Fitter:

The documentation for this class was generated from the following files: