13 #ifndef ROOT_Fit_Fitter 14 #define ROOT_Fit_Fitter 28 #ifndef ROOT_Fit_BinData 31 #ifndef ROOT_Fit_UnBinData 35 #ifndef ROOT_Fit_FitConfig 39 #ifndef ROOT_Fit_FitResult 43 #ifndef ROOT_Math_IParamFunctionfwd 145 template <
class Data ,
class Function>
156 return DoLeastSquareFit();
158 bool Fit(
const std::shared_ptr<BinData> & data) {
160 return DoLeastSquareFit();
175 return DoUnbinnedLikelihoodFit(extended);
183 return DoBinnedLikelihoodFit(extended);
185 bool LikelihoodFit(
const std::shared_ptr<BinData> & data,
bool extended =
true) {
187 return DoBinnedLikelihoodFit(extended);
194 return DoUnbinnedLikelihoodFit(extended);
196 bool LikelihoodFit(
const std::shared_ptr<UnBinData> & data,
bool extended =
false) {
198 return DoUnbinnedLikelihoodFit(extended);
206 template <
class Data ,
class Function>
209 return LikelihoodFit(data, extended);
217 return DoLinearFit();
221 return DoLinearFit();
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);
310 typedef void (* MinuitFCN_t )(
int &npar,
double *gin,
double &
f,
double *u,
int flag);
311 bool FitFCN( MinuitFCN_t fcn,
int npar = 0,
const double * params = 0,
unsigned int dataSize = 0,
bool chi2fit =
false);
318 bool SetFCN( MinuitFCN_t fcn,
int npar = 0,
const double * params = 0,
unsigned int dataSize = 0,
bool chi2fit =
false);
335 void SetFunction(
const IModelFunction &
func,
bool useGradient =
false);
339 void SetFunction(
const IModel1DFunction &
func,
bool useGradient =
false);
344 void SetFunction(
const IGradModelFunction &
func,
bool useGradient =
true);
348 void SetFunction(
const IGradModel1DFunction &
func,
bool useGradient =
true);
355 assert( fResult.get() );
367 bool CalculateHessErrors();
377 bool CalculateMinosErrors();
433 bool DoLeastSquareFit();
435 bool DoBinnedLikelihoodFit(
bool extended =
true);
437 bool DoUnbinnedLikelihoodFit(
bool extended =
false);
442 bool DoInitMinimizer();
448 void DoUpdateFitConfig();
450 int GetNCallsFromFCN();
464 template <
class Data>
465 void SetData(
const std::shared_ptr<Data> & data) {
466 fData = std::static_pointer_cast<
Data>(data);
476 template <
class ObjFuncType>
477 bool GetDataFromFCN();
494 std::shared_ptr<IModelFunction>
fFunc;
496 std::shared_ptr<ROOT::Fit::FitResult>
fResult;
500 std::shared_ptr<ROOT::Fit::FitData>
fData;
509 template <
class ObjFuncType>
510 bool Fitter::GetDataFromFCN() {
511 ObjFuncType * objfunc =
dynamic_cast<ObjFuncType*
>(fObjFunction.get() );
513 fFunc = objfunc->ModelFunctionPtr();
514 fData = objfunc->DataPtr();
533 #ifndef ROOT_Math_WrappedFunction 537 template<
class Function>
540 return FitFCN(wf,par,datasize,chi2fit);
542 template<
class Function>
545 return SetFCN(wf,par,datasize,chi2fit);
551 #endif // endif __CINT__ ROOT::Math::IParamFunction IModel1DFunction
const FitConfig & Config() const
access to the fit configuration (const method)
Interface (abstract class) for multi-dimensional functions providing a gradient calculation.
This namespace contains pre-defined functions to be used in conjuction with TExecutor::Map and TExecu...
FitConfig & Config()
access to the configuration (non const method)
bool Fit(const std::shared_ptr< BinData > &data)
bool LikelihoodFit(const UnBinData &data, bool extended=false)
Unbinned Likelihood fit.
Base class for all the fit data types.
void SetData(const FitData &data)
ROOT::Math::IMultiGenFunction BaseFunc
std::shared_ptr< IModelFunction > fFunc
Class describing the unbinned data sets (just x coordinates values) of any dimensions.
bool Fit(const UnBinData &data, bool extended=false)
fit an unbinned data set using loglikelihood method
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 LikelihoodFit(const std::shared_ptr< UnBinData > &data, bool extended=false)
std::shared_ptr< ROOT::Fit::FitResult > fResult
copy of the fitted function containing on output the fit result
bool LeastSquareFit(const BinData &data)
Fit a binned data set using a least square fit.
ROOT::Math::IParamMultiGradFunction IGradModelFunction
Abstract Minimizer class, defining the interface for the various minimizer (like Minuit2, Minuit, GSL, etc..) Plug-in's exist in ROOT to be able to instantiate the derived classes like ROOT::Math::GSLMinimizer or ROOT::Math::Minuit2Minimizer via the plug-in manager.
const FitResult & Result() const
get fit result
ROOT::Math::IParamGradFunction IGradModel1DFunction
std::vector< std::vector< double > > Data
bool LinearFit(const BinData &data)
do a linear fit on a set of bin-data
std::shared_ptr< ROOT::Fit::FitData > fData
pointer to used minimizer
bool Fit(const Data &data, const Function &func)
fit a data set using any generic model function If data set is binned a least square fit is performed...
IParamFunction interface (abstract class) describing multi-dimensional parameteric functions It is a ...
RooCmdArg Minimizer(const char *type, const char *alg=0)
Fitter class, entry point for performing all type of fits.
bool Fit(const BinData &data)
Fit a binned data set using a least square fit (default method)
bool FitFCN()
Perform a fit with the previously set FCN function.
Class describing the binned data sets : vectors of x coordinates, y values and optionally error on y ...
bool IsBinFit() const
query if fit is binned.
std::shared_ptr< ROOT::Math::Minimizer > fMinimizer
pointer to the object containing the result of the fit
bool LikelihoodFit(const BinData &data, bool extended=true)
Binned Likelihood fit.
Interface (abstract class) for parametric one-dimensional gradient functions providing in addition to...
bool LikelihoodFit(const std::shared_ptr< BinData > &data, bool extended=true)
class containg the result of the fit and all the related information (fitted parameter values...
Specialized IParamFunction interface (abstract class) for one-dimensional parametric functions It is ...
FitMethodFunction class Interface for objective functions (like chi2 and likelihood used in the fit) ...
TFitResultPtr Fit(FitObject *h1, TF1 *f1, Foption_t &option, const ROOT::Math::MinimizerOptions &moption, const char *goption, ROOT::Fit::DataRange &range)
Interface (abstract class) for parametric gradient multi-dimensional functions providing in addition ...
double func(double *x, double *p)
ROOT::Math::IMultiGradFunction BaseGradFunc
std::shared_ptr< ROOT::Math::IMultiGenFunction > fObjFunction
pointer to the fit data (binned or unbinned data)
Template class to wrap any C++ callable object implementing operator() (const double * x) in a multi-...
Namespace for new Math classes and functions.
BasicFitMethodFunction< ROOT::Math::IMultiGradFunction > FitMethodGradFunction
typedef void((*Func_t)())
void SetFunctionAndData(const IModelFunction &func, const FitData &data)
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...
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 LinearFit(const std::shared_ptr< BinData > &data)
Documentation for the abstract class IBaseFunctionMultiDim.
void SetData(const std::shared_ptr< Data > &data)
ROOT::Math::IParamMultiFunction IModelFunction
Class describing the configuration of the fit, options and parameter settings using the ROOT::Fit::Pa...
BasicFitMethodFunction< ROOT::Math::IMultiGenFunction > FitMethodFunction
ROOT::Math::Minimizer * GetMinimizer() const
return pointer to last used minimizer (is NULL in case fit is not yet done) This pointer is guranteed...