13#ifndef ROOT_Fit_Fitter
14#define ROOT_Fit_Fitter
40 template<
class FunctionType>
class BasicFitMethodFunction;
107 Fitter (
const std::shared_ptr<FitResult> & result);
137 template <
class Data,
class Function,
138 class cond =
typename std::enable_if<!(std::is_same<Function, ROOT::Fit::ExecutionPolicy>::value ||
139 std::is_same<Function, int>::value),
145 return Fit(data, executionPolicy);
184 bool LikelihoodFit(
const std::shared_ptr<BinData> &data,
bool extended =
true,
206 template <
class Data ,
class Function>
231 template <
class Function>
232 bool FitFCN(
unsigned int npar,
Function & fcn,
const double * params = 0,
unsigned int dataSize = 0,
bool chi2fit =
false);
240 template <
class Function>
241 bool SetFCN(
unsigned int npar,
Function & fcn,
const double * params = 0,
unsigned int dataSize = 0,
bool chi2fit =
false);
278 unsigned int dataSize = 0,
bool chi2fit =
false);
315 unsigned int dataSize = 0,
bool chi2fit =
false);
330 bool FitFCN(
MinuitFCN_t fcn,
int npar = 0,
const double * params = 0,
unsigned int dataSize = 0,
bool chi2fit =
false);
337 bool SetFCN(
MinuitFCN_t fcn,
int npar = 0,
const double * params = 0,
unsigned int dataSize = 0,
bool chi2fit =
false);
360 template <
class NotCompileIfScalarBackend = std::enable_if<!(std::is_same<
double, ROOT::Double_v>::value)>>
363 template <
class NotCompileIfScalarBackend = std::enable_if<!(std::is_same<
double, ROOT::Double_v>::value)>>
496 template <
class Data>
497 void SetData(
const std::shared_ptr<Data> & data) {
498 fData = std::static_pointer_cast<Data>(data);
508 template <
class ObjFuncType>
528 std::shared_ptr<IModelFunction>
fFunc;
530 std::shared_ptr<ROOT::Fit::FitResult>
fResult;
534 std::shared_ptr<ROOT::Fit::FitData>
fData;
543template <
class ObjFuncType>
545 ObjFuncType * objfunc =
dynamic_cast<ObjFuncType*
>(
fObjFunction.get() );
547 fFunc = objfunc->ModelFunctionPtr();
548 fData = objfunc->DataPtr();
557template <
class NotCompileIfScalarBackend>
568 "Requested function does not provide gradient - use it as non-gradient function ");
583template <
class NotCompileIfScalarBackend>
609template<
class Function>
612 return FitFCN(wf,par,datasize,chi2fit);
614template<
class Function>
617 return SetFCN(wf,par,datasize,chi2fit);
#define MATH_WARN_MSG(loc, str)
typedef void((*Func_t)())
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.
Base class for all the fit data types: Stores the coordinates and the DataOptions.
class containg the result of the fit and all the related information (fitted parameter values,...
Fitter class, entry point for performing all type of fits.
bool LinearFit(const BinData &data)
do a linear fit on a set of bin-data
void SetData(const FitData &data)
bool EvalFCN()
Perform a simple FCN evaluation.
bool FitFCN()
Perform a fit with the previously set FCN function.
ROOT::Math::IParamMultiFunction IModelFunction_v
std::shared_ptr< ROOT::Math::Minimizer > fMinimizer
pointer to the object containing the result of the fit
bool LikelihoodFit(const Data &data, const Function &func, bool extended)
fit a data set using any generic model function Pre-requisite on the function:
ROOT::Math::IMultiGenFunction * GetFCN() const
return pointer to last used objective function (is NULL in case fit is not yet done) This pointer wil...
bool DoBinnedLikelihoodFit(bool extended=true, const ROOT::Fit::ExecutionPolicy &executionPolicy=ROOT::Fit::ExecutionPolicy::kSerial)
binned likelihood fit
ROOT::Math::IParamGradFunction IGradModel1DFunction
std::shared_ptr< ROOT::Fit::FitData > fData
pointer to used minimizer
ROOT::Math::Minimizer * GetMinimizer() const
return pointer to last used minimizer (is NULL in case fit is not yet done) This pointer is guranteed...
ROOT::Math::IMultiGenFunction BaseFunc
FitConfig & Config()
access to the configuration (non const method)
bool LeastSquareFit(const BinData &data)
Fit a binned data set using a least square fit.
bool LikelihoodFit(const std::shared_ptr< UnBinData > &data, bool extended=false, const ROOT::Fit::ExecutionPolicy &executionPolicy=ROOT::Fit::ExecutionPolicy::kSerial)
bool SetFCN(unsigned int npar, Function &fcn, const double *params=0, unsigned int dataSize=0, bool chi2fit=false)
Set a generic FCN function as a C++ callable object implementing double () (const double *) Note that...
void SetFunctionAndData(const IModelFunctionTempl< T > &func, const FitData &data)
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 LikelihoodFit(const BinData &data, bool extended=true, const ROOT::Fit::ExecutionPolicy &executionPolicy=ROOT::Fit::ExecutionPolicy::kSerial)
Binned Likelihood fit.
bool DoMinimization(const BaseFunc &f, const ROOT::Math::IMultiGenFunction *chifunc=0)
do minimization
bool LinearFit(const std::shared_ptr< BinData > &data)
std::shared_ptr< ROOT::Math::IMultiGenFunction > fObjFunction
pointer to the fit data (binned or unbinned data)
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...
bool Fit(const std::shared_ptr< BinData > &data, const ROOT::Fit::ExecutionPolicy &executionPolicy=ROOT::Fit::ExecutionPolicy::kSerial)
bool Fit(const UnBinData &data, bool extended=false, const ROOT::Fit::ExecutionPolicy &executionPolicy=ROOT::Fit::ExecutionPolicy::kSerial)
fit an unbinned data set using loglikelihood method
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)
bool LikelihoodFit(const UnBinData &data, bool extended=false, const ROOT::Fit::ExecutionPolicy &executionPolicy=ROOT::Fit::ExecutionPolicy::kSerial)
Unbinned Likelihood fit.
ROOT::Math::IParamMultiFunction IModelFunction
ROOT::Math::IParamFunction IModel1DFunction
std::shared_ptr< IModelFunction_v > fFunc_v
ROOT::Math::IParamMultiGradFunction IGradModelFunction_v
bool DoUnbinnedLikelihoodFit(bool extended=false, const ROOT::Fit::ExecutionPolicy &executionPolicy=ROOT::Fit::ExecutionPolicy::kSerial)
un-binned likelihood fit
Fitter & operator=(const Fitter &rhs)
Assignment operator (disabled, class is not copyable)
std::shared_ptr< ROOT::Fit::FitResult > fResult
copy of the fitted function containing on output the fit result
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...
bool SetFCN(const ROOT::Math::FitMethodGradFunction &fcn, const double *params=0)
Set the objective function (FCN) using a FitMethodGradFunction interface.
bool DoUpdateMinimizerOptions(bool canDifferentMinim=true)
bool LikelihoodFit(const std::shared_ptr< BinData > &data, bool extended=true, const ROOT::Fit::ExecutionPolicy &executionPolicy=ROOT::Fit::ExecutionPolicy::kSerial)
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 obtaied from the inverse of the ...
Fitter()
Default constructor.
bool Fit(const BinData &data, const ROOT::Fit::ExecutionPolicy &executionPolicy=ROOT::Fit::ExecutionPolicy::kSerial)
Fit a binned data set using a least square fit (default method)
bool Fit(const Data &data, const Function &func, const ROOT::Fit::ExecutionPolicy &executionPolicy=ROOT::Fit::ExecutionPolicy::kSerial)
fit a data set using any generic model function If data set is binned a least square fit is performed...
std::shared_ptr< IModelFunction > fFunc
copy of the fitted function containing on output the fit result
bool FitFCN(const ROOT::Math::FitMethodGradFunction &fcn, const double *params=0)
Fit using a FitMethodGradFunction interface.
bool DoLinearFit()
linear least square fit
bool DoLeastSquareFit(const ROOT::Fit::ExecutionPolicy &executionPolicy=ROOT::Fit::ExecutionPolicy::kSerial)
least square fit
Class describing the unbinned 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-...
TFitResultPtr Fit(FitObject *h1, TF1 *f1, Foption_t &option, const ROOT::Math::MinimizerOptions &moption, const char *goption, ROOT::Fit::DataRange &range)
Namespace for new Math classes and functions.
BasicFitMethodFunction< ROOT::Math::IMultiGenFunction > FitMethodFunction
BasicFitMethodFunction< ROOT::Math::IMultiGradFunction > FitMethodGradFunction
RooCmdArg Minimizer(const char *type, const char *alg=0)