13 #ifndef ROOT_Fit_Fitter 14 #define ROOT_Fit_Fitter 128 template <
class Data ,
class Function>
139 return DoLeastSquareFit();
141 bool Fit(
const std::shared_ptr<BinData> &
data) {
143 return DoLeastSquareFit();
158 return DoUnbinnedLikelihoodFit(extended);
166 return DoBinnedLikelihoodFit(extended);
170 return DoBinnedLikelihoodFit(extended);
177 return DoUnbinnedLikelihoodFit(extended);
181 return DoUnbinnedLikelihoodFit(extended);
189 template <
class Data ,
class Function>
192 return LikelihoodFit(data, extended);
200 return DoLinearFit();
204 return DoLinearFit();
214 template <
class Function>
215 bool FitFCN(
unsigned int npar,
Function & fcn,
const double * params = 0,
unsigned int dataSize = 0,
bool chi2fit =
false);
223 template <
class Function>
224 bool SetFCN(
unsigned int npar,
Function & fcn,
const double * params = 0,
unsigned int dataSize = 0,
bool chi2fit =
false);
293 typedef void (* MinuitFCN_t )(
int &npar,
double *gin,
double &
f,
double *u,
int flag);
294 bool FitFCN( MinuitFCN_t fcn,
int npar = 0,
const double * params = 0,
unsigned int dataSize = 0,
bool chi2fit =
false);
301 bool SetFCN( MinuitFCN_t fcn,
int npar = 0,
const double * params = 0,
unsigned int dataSize = 0,
bool chi2fit =
false);
318 void SetFunction(
const IModelFunction &
func,
bool useGradient =
false);
322 void SetFunction(
const IModel1DFunction &
func,
bool useGradient =
false);
327 void SetFunction(
const IGradModelFunction &
func,
bool useGradient =
true);
331 void SetFunction(
const IGradModel1DFunction &
func,
bool useGradient =
true);
338 assert( fResult.get() );
350 bool CalculateHessErrors();
360 bool CalculateMinosErrors();
416 bool DoLeastSquareFit();
418 bool DoBinnedLikelihoodFit(
bool extended =
true);
420 bool DoUnbinnedLikelihoodFit(
bool extended =
false);
425 bool DoInitMinimizer();
431 void DoUpdateFitConfig();
433 int GetNCallsFromFCN();
447 template <
class Data>
449 fData = std::static_pointer_cast<
Data>(
data);
459 template <
class ObjFuncType>
460 bool GetDataFromFCN();
477 std::shared_ptr<IModelFunction>
fFunc;
479 std::shared_ptr<ROOT::Fit::FitResult>
fResult;
483 std::shared_ptr<ROOT::Fit::FitData>
fData;
492 template <
class ObjFuncType>
493 bool Fitter::GetDataFromFCN() {
494 ObjFuncType * objfunc =
dynamic_cast<ObjFuncType*
>(fObjFunction.get() );
496 fFunc = objfunc->ModelFunctionPtr();
497 fData = objfunc->DataPtr();
517 template<
class Function>
520 return FitFCN(wf,par,datasize,chi2fit);
522 template<
class Function>
525 return SetFCN(wf,par,datasize,chi2fit);
531 #endif // endif __CINT__ ROOT::Math::IParamFunction IModel1DFunction
Interface (abstract class) for multi-dimensional functions providing a gradient calculation.
Namespace for new ROOT classes and functions.
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: Stores the coordinates and the DataOptions.
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.
Interface (abstract class) for parametric gradient multi-dimensional functions providing in addition ...
bool Fit(const UnBinData &data, bool extended=false)
fit an unbinned data set using loglikelihood method
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.
const FitResult & Result() const
get fit result
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.
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
const FitConfig & Config() const
access to the fit configuration (const method)
Documentation for the abstract class IBaseFunctionMultiDim.
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...
Double_t(* Function)(Double_t)
bool IsBinFit() const
query if fit is binned.
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)
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 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 ...
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...
IParamFunction interface (abstract class) describing multi-dimensional parameteric functions It is a ...
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)
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.
Binding & operator=(OUT(*fun)(void))
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...
ROOT::Math::Minimizer * GetMinimizer() const
return pointer to last used minimizer (is NULL in case fit is not yet done) This pointer is guranteed...
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)
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