13#ifndef ROOT_Fit_Fitter
14#define ROOT_Fit_Fitter
40 template<
class FunctionType>
class BasicFitMethodFunction;
135 template <
class Data,
class Function,
143 return Fit(
data, executionPolicy);
204 template <
class Data ,
class Function>
229 template <
class Function>
230 bool FitFCN(
unsigned int npar,
Function & fcn,
const double * params = 0,
unsigned int dataSize = 0,
bool chi2fit =
false);
238 template <
class Function>
239 bool SetFCN(
unsigned int npar,
Function & fcn,
const double * params = 0,
unsigned int dataSize = 0,
bool chi2fit =
false);
276 unsigned int dataSize = 0,
bool chi2fit =
false);
313 unsigned int dataSize = 0,
bool chi2fit =
false);
328 bool FitFCN(
MinuitFCN_t fcn,
int npar = 0,
const double * params = 0,
unsigned int dataSize = 0,
bool chi2fit =
false);
335 bool SetFCN(
MinuitFCN_t fcn,
int npar = 0,
const double * params = 0,
unsigned int dataSize = 0,
bool chi2fit =
false);
358 template <
class NotCompileIfScalarBackend = std::enable_if<!(std::is_same<
double, ROOT::Double_v>::value)>>
361 template <
class NotCompileIfScalarBackend = std::enable_if<!(std::is_same<
double, ROOT::Double_v>::value)>>
477 template<
class ObjFunc_t>
480 template<
class ObjFunc_t>
503 template <
class Data>
505 fData = std::static_pointer_cast<Data>(
data);
515 template <
class ObjFuncType>
541 std::shared_ptr<IModelFunction>
fFunc;
543 std::shared_ptr<ROOT::Fit::FitResult>
fResult;
547 std::shared_ptr<ROOT::Fit::FitData>
fData;
558template <
class ObjFuncType>
560 const ObjFuncType * objfunc =
dynamic_cast<const ObjFuncType*
>(
ObjFunction());
562 fFunc = objfunc->ModelFunctionPtr();
563 fData = objfunc->DataPtr();
572template <
class NotCompileIfScalarBackend>
583 "Requested function does not provide gradient - use it as non-gradient function ");
598template <
class NotCompileIfScalarBackend>
624template<
class Function>
627 if (!
DoSetFCN(
false, wf, par, datasize, chi2fit))
631template<
class Function>
634 return DoSetFCN(
false, wf, par, datasize, chi2fit);
#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 value
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.
Base class for all the fit data types: Stores the coordinates and the DataOptions.
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)
bool LinearFit(const BinData &data)
do a linear fit on a set of bin-data
void SetData(const FitData &data)
bool DoSetFCN(bool useExtFCN, const ROOT::Math::IMultiGenFunction &fcn, const double *params, unsigned int dataSize, bool chi2fit)
Set Objective function.
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.
const ROOT::Math::IMultiGenFunction * ObjFunction() const
return pointer to used objective function if using an external one use external, otherwise use the on...
bool DoMinimization(std::unique_ptr< ObjFunc_t > f, const ROOT::Math::IMultiGenFunction *chifunc=nullptr)
do minimization
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
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 (default method)
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)
fit a data set using any generic model function Pre-requisite on the 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)
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 LeastSquareFit(const BinData &data)
Fit a binned data set using a least square fit.
bool fUseGradient
flag to indicate if using gradient or not
bool fBinFit
flag to indicate if fit is binned in case of false the fit is unbinned or undefined) flag it is used ...
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 LinearFit(const std::shared_ptr< BinData > &data)
std::shared_ptr< ROOT::Math::IMultiGenFunction > fObjFunction
! pointer to used objective function
bool Fit(const std::shared_ptr< BinData > &data, const ROOT::EExecutionPolicy &executionPolicy=ROOT::EExecutionPolicy::kSequential)
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)
bool DoLeastSquareFit(const ROOT::EExecutionPolicy &executionPolicy=ROOT::EExecutionPolicy::kSequential)
least square fit
ROOT::Math::IParamMultiFunction IModelFunction
ROOT::Math::IParamFunction IModel1DFunction
bool LikelihoodFit(const BinData &data, bool extended=true, const ROOT::EExecutionPolicy &executionPolicy=ROOT::EExecutionPolicy::kSequential)
Binned Likelihood fit.
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)
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 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 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 unbinned data set using loglikelihood 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 LikelihoodFit(const UnBinData &data, bool extended=false, const ROOT::EExecutionPolicy &executionPolicy=ROOT::EExecutionPolicy::kSequential)
Unbinned Likelihood fit.
bool FitFCN(const ROOT::Math::FitMethodGradFunction &fcn, const double *params=0)
Fit using a FitMethodGradFunction interface.
bool DoLinearFit()
linear 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-...
RooCmdArg Minimizer(const char *type, const char *alg=0)
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.
void(off) SmallVectorTemplateBase< T
BasicFitMethodFunction< ROOT::Math::IMultiGenFunction > FitMethodFunction
BasicFitMethodFunction< ROOT::Math::IMultiGradFunction > FitMethodGradFunction
This file contains a specialised ROOT message handler to test for diagnostic in unit tests.