13#ifndef ROOT_Fit_Fitter
14#define ROOT_Fit_Fitter
40 template<
class FunctionType>
class BasicFitMethodFunction;
140 template <
class Data,
class Function,
141 class cond =
typename std::enable_if<!(std::is_same<Function, ROOT::EExecutionPolicy>::value ||
142 std::is_same<Function, int>::value),
148 return Fit(
data, executionPolicy);
238 template <
class Data ,
class Function>
265 template <
class Function>
266 bool FitFCN(
unsigned int npar,
Function & fcn,
const double * params =
nullptr,
unsigned int dataSize = 0,
int fitType = 0);
274 template <
class Function>
275 bool SetFCN(
unsigned int npar,
Function & fcn,
const double * params =
nullptr,
unsigned int dataSize = 0,
int fitType = 0);
313 unsigned int dataSize = 0,
int fitType = 0);
339 typedef void (*
MinuitFCN_t )(
int &npar,
double *gin,
double &
f,
double *u,
int flag);
340 bool FitFCN(
MinuitFCN_t fcn,
int npar = 0,
const double *params =
nullptr,
unsigned int dataSize = 0,
int fitType = 0);
347 bool SetFCN(
MinuitFCN_t fcn,
int npar = 0,
const double *params =
nullptr,
unsigned int dataSize = 0,
int fitType = 0);
370 template <
class NotCompileIfScalarBackend = std::enable_if<!(std::is_same<
double, ROOT::Double_v>::value)>>
373 template <
class NotCompileIfScalarBackend = std::enable_if<!(std::is_same<
double, ROOT::Double_v>::value)>>
504 template<
class ObjFunc_t>
507 template<
class ObjFunc_t>
519 template <
class Data>
521 fData = std::static_pointer_cast<Data>(
data);
525 template <
class Data>
527 auto dataClone = std::make_shared<Data>(
data);
538 template <
class ObjFuncType>
566 std::shared_ptr<IModelFunction>
fFunc;
568 std::shared_ptr<ROOT::Fit::FitResult>
fResult;
572 std::shared_ptr<ROOT::Fit::FitData>
fData;
583template <
class ObjFuncType>
585 const ObjFuncType * objfunc =
dynamic_cast<const ObjFuncType*
>(
ObjFunction());
587 fFunc = objfunc->ModelFunctionPtr();
588 fData = objfunc->DataPtr();
597template <
class NotCompileIfScalarBackend>
608 "Requested function does not provide gradient - use it as non-gradient function ");
623template <
class NotCompileIfScalarBackend>
648template<
class Function>
651 if (!
DoSetFCN(
false, wf, par, datasize, fitType))
655template<
class Function>
658 return DoSetFCN(
false, wf, par, datasize, fitType);
#define MATH_WARN_MSG(loc, str)
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void data
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void char Point_t Rectangle_t WindowAttributes_t Float_t Float_t Float_t Int_t Int_t UInt_t UInt_t Rectangle_t result
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void char Point_t Rectangle_t WindowAttributes_t Float_t Float_t Float_t Int_t Int_t UInt_t UInt_t Rectangle_t Int_t Int_t Window_t TString Int_t GCValues_t GetPrimarySelectionOwner GetDisplay GetScreen GetColormap GetNativeEvent const char const char dpyName wid window const char font_name cursor keysym reg const char only_if_exist regb h Point_t winding char text const char depth char const char Int_t count const char ColorStruct_t color const char Pixmap_t Pixmap_t PictureAttributes_t attr const char char ret_data h unsigned char height h Atom_t Int_t ULong_t ULong_t unsigned char prop_list Atom_t Atom_t Atom_t Time_t type
Double_t(* Function)(Double_t)
Class describing the binned data sets : vectors of x coordinates, y values and optionally error on y ...
Class describing the configuration of the fit, options and parameter settings using the ROOT::Fit::Pa...
void CreateParamsSettings(const ROOT::Math::IParamMultiFunctionTempl< T > &func)
set the parameter settings from a model function.
class containing the result of the fit and all the related information (fitted parameter values,...
Fitter class, entry point for performing all type of fits.
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 LinearFit(const BinData &data)
Do a linear 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 EvalFCN()
Perform a simple FCN evaluation.
const ROOT::Math::IMultiGenFunction * fExtObjFunction
! pointer to an external FCN
Fitter & operator=(const Fitter &)=delete
Assignment operator (disabled, class is not copyable)
bool FitFCN()
Perform a fit with the previously set FCN function.
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, int fitType)
Set Objective function.
int fDataSize
size of data sets (need for Fumili or LM fitters)
bool DoUnbinnedLikelihoodFit(bool extended=false, const ROOT::EExecutionPolicy &executionPolicy=ROOT::EExecutionPolicy::kSequential)
un-binned likelihood fit
void SetData(const Data &data)
Set the input data for the fit (Copying the given data object)
const ROOT::Math::IBaseFunctionMultiDimTempl< double > * ObjFunction() const
Return pointer to the used objective function for fitting.
ROOT::Math::IParamMultiFunction IModelFunction_v
bool Fit(const BinData &data, const ROOT::EExecutionPolicy &executionPolicy=ROOT::EExecutionPolicy::kSequential)
Fit a binned data set using a least square fit.
std::shared_ptr< ROOT::Math::Minimizer > fMinimizer
! pointer to used minimizer
bool DoWeightMinimization(std::unique_ptr< ObjFunc_t > f, const ROOT::Math::IMultiGenFunction *chifunc=nullptr)
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 DoBinnedLikelihoodFit(bool extended=true, const ROOT::EExecutionPolicy &executionPolicy=ROOT::EExecutionPolicy::kSequential)
binned likelihood fit
int fFitType
type of fit (0 undefined, 1 least square, 2 likelihood, 3 binned likelihood)
ROOT::Math::IMultiGenFunction * GetFCN() const
return pointer to last used objective function (is NULL in case fit is not yet done) This pointer wil...
ROOT::Math::IParamGradFunction IGradModel1DFunction
std::shared_ptr< ROOT::Fit::FitData > fData
! pointer to the fit data (binned or unbinned data)
ROOT::Math::Minimizer * GetMinimizer() const
return pointer to last used minimizer (is NULL in case fit is not yet done) This pointer is guarantee...
ROOT::Math::IMultiGenFunction BaseFunc
FitConfig & Config()
access to the configuration (non const method)
bool fUseGradient
flag to indicate if using gradient or not
void SetNumberOfFitPoints(unsigned int npoints)
Set number of fit points when using an external FCN function This function can be called after Fit to...
bool fBinFit
flag to indicate if fit is binned in case of false the fit is unbinned or undefined) flag it is used ...
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 ...
bool IsBinFit() const
query if fit is binned.
bool LinearFit(const std::shared_ptr< BinData > &data)
Do a linear fit using a shared_ptr for NOT copying the input data.
std::shared_ptr< ROOT::Math::IMultiGenFunction > fObjFunction
! pointer to used objective function
void SetFitType(int type)
Set the type of fit when using an external FCN possible types are : 1 (least-square),...
virtual ~Fitter()
Destructor.
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.
const FitResult & Result() const
get fit result
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 on...
ROOT::Math::IMultiGradFunction BaseGradFunc
void ExamineFCN()
look at the user provided FCN and get data and model function is they derive from ROOT::Fit FCN class...
const FitConfig & Config() const
access to the fit configuration (const method)
void SetData(const std::shared_ptr< Data > &data)
Set the input data for the fit using a shared ptr (No Copying)
bool DoLeastSquareFit(const ROOT::EExecutionPolicy &executionPolicy=ROOT::EExecutionPolicy::kSequential)
least square fit
ROOT::Math::IParamMultiFunction IModelFunction
ROOT::Math::IParamFunction IModel1DFunction
bool SetFCN(unsigned int npar, Function &fcn, const double *params=nullptr, unsigned int dataSize=0, int fitType=0)
Set a generic FCN function as a C++ callable object implementing double () (const double *) Note that...
bool LikelihoodFit(const BinData &data, bool extended=true, const ROOT::EExecutionPolicy &executionPolicy=ROOT::EExecutionPolicy::kSequential)
Binned Likelihood fit copying the input data.
std::shared_ptr< IModelFunction_v > fFunc_v
! copy of the fitted function containing on output the fit result
ROOT::Math::IParamMultiGradFunction IGradModelFunction_v
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.
std::shared_ptr< ROOT::Fit::FitResult > fResult
! pointer to the object containing the result of the fit
bool GetDataFromFCN()
internal functions to get data set and model function from FCN useful for fits done with customized F...
ROOT::Math::IParamMultiGradFunction IGradModelFunction
bool CalculateMinosErrors()
perform an error analysis on the result using MINOS To be called only after fitting and when a minimi...
Fitter(const Fitter &)=delete
Copy constructor (disabled, class is not copyable)
bool DoUpdateMinimizerOptions(bool canDifferentMinim=true)
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...
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.
void SetFunction(const IModelFunction &func, bool useGradient=false)
Set the fitted function (model function) from a parametric function interface.
bool CalculateHessErrors()
perform an error analysis on the result using the Hessian Errors are obtained from the inverse of the...
FitConfig fConfig
fitter configuration (options and parameter settings)
Fitter()
Default constructor.
std::shared_ptr< IModelFunction > fFunc
! copy of the fitted function containing on output the fit result
bool SetFCN(const ROOT::Math::FitMethodGradFunction &fcn, const double *params=nullptr)
Set the objective function (FCN) using a FitMethodGradFunction interface.
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 FitFCN(const ROOT::Math::FitMethodGradFunction &fcn, const double *params=nullptr)
Fit using a FitMethodGradFunction interface.
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 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 DoLinearFit()
linear least square fit
Class describing the un-binned data sets (just x coordinates values) of any dimensions.
FitMethodFunction class Interface for objective functions (like chi2 and likelihood used in the fit) ...
Documentation for the abstract class IBaseFunctionMultiDim.
Interface (abstract class) for multi-dimensional functions providing a gradient calculation.
Specialized IParamFunction interface (abstract class) for one-dimensional parametric functions It is ...
Interface (abstract class) for parametric gradient multi-dimensional functions providing in addition ...
Interface (abstract class) for parametric one-dimensional gradient functions providing in addition to...
Abstract Minimizer class, defining the interface for the various minimizer (like Minuit2,...
Template class to wrap any C++ callable object implementing operator() (const double * x) in a multi-...
RooCmdArg Minimizer(const char *type, const char *alg=nullptr)
Namespace for new Math classes and functions.
BasicFitMethodFunction< ROOT::Math::IMultiGenFunction > FitMethodFunction
BasicFitMethodFunction< ROOT::Math::IMultiGradFunction > FitMethodGradFunction
tbb::task_arena is an alias of tbb::interface7::task_arena, which doesn't allow to forward declare tb...