Logo ROOT  
Reference Guide
FitMethodFunction.h
Go to the documentation of this file.
1// @(#)root/mathcore:$Id$
2// Author: L. Moneta Thu Aug 16 15:40:28 2007
3
4/**********************************************************************
5 * *
6 * Copyright (c) 2007 LCG ROOT Math Team, CERN/PH-SFT *
7 * *
8 * *
9 **********************************************************************/
10
11// Header file for class FitMethodFunction
12
13#ifndef ROOT_Math_FitMethodFunction
14#define ROOT_Math_FitMethodFunction
15
16#include "Math/IFunction.h"
17
18// #ifndef ROOT_Math_IParamFunctionfwd
19// #include "Math/IParamFunctionfwd.h"
20// #endif
21
22namespace ROOT {
23
24 namespace Math {
25
26//______________________________________________________________________________________
27/**
28 FitMethodFunction class
29 Interface for objective functions (like chi2 and likelihood used in the fit)
30 In addition to normal function interface provide interface for calculating each
31 data contribution to the function which is required by some algorithm (like Fumili)
32
33 @ingroup FitMethodFunc
34*/
35template<class FunctionType>
37
38public:
39
40
41 typedef typename FunctionType::BaseFunc BaseFunction;
42
43 /// enumeration specifying the possible fit method types
45
46
47 BasicFitMethodFunction(int dim, int npoint) :
48 fNDim(dim),
49 fNPoints(npoint),
50 fNCalls(0)
51 {}
52
53 /**
54 Virtual Destructor (no operations)
55 */
57
58 /**
59 Number of dimension (parameters) . From IGenMultiFunction interface
60 */
61 virtual unsigned int NDim() const { return fNDim; }
62
63 /**
64 method returning the data i-th contribution to the fit objective function
65 For example the residual for the least square functions or the pdf element for the
66 likelihood functions.
67 Estimating eventually also the gradient of the data element if the passed pointer is not null
68 */
69 virtual double DataElement(const double *x, unsigned int i, double *g = nullptr) const = 0;
70
71
72 /**
73 return the number of data points used in evaluating the function
74 */
75 virtual unsigned int NPoints() const { return fNPoints; }
76
77 /**
78 return the type of method, override if needed
79 */
80 virtual Type_t Type() const { return kUndefined; }
81
82 /**
83 return the total number of function calls (override if needed)
84 */
85 virtual unsigned int NCalls() const { return fNCalls; }
86
87 /**
88 update number of calls
89 */
90 virtual void UpdateNCalls() const { fNCalls++; }
91
92 /**
93 reset number of function calls
94 */
95 virtual void ResetNCalls() { fNCalls = 0; }
96
97 /**
98 Static function to indicate if a function is supporting gradient
99 */
100 static bool IsAGradFCN() {
101 return false;
102 }
103
104private:
105
106 unsigned int fNDim; // function dimension
107 unsigned int fNPoints; // size of the data
108 mutable unsigned int fNCalls; // number of function calls
109
110
111};
112
113template<>
115 return true;
116}
117
118// define the normal and gradient function
121
122
123
124} // end namespace Math
125
126} // end namespace ROOT
127
128
129
130
131
132
133#endif /* ROOT_Math_FitMethodFunction */
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 g
FitMethodFunction class Interface for objective functions (like chi2 and likelihood used in the fit) ...
virtual Type_t Type() const
return the type of method, override if needed
Type_t
enumeration specifying the possible fit method types
BasicFitMethodFunction(int dim, int npoint)
virtual unsigned int NPoints() const
return the number of data points used in evaluating the function
virtual double DataElement(const double *x, unsigned int i, double *g=nullptr) const =0
method returning the data i-th contribution to the fit objective function For example the residual fo...
static bool IsAGradFCN()
Static function to indicate if a function is supporting gradient.
virtual void ResetNCalls()
reset number of function calls
virtual unsigned int NCalls() const
return the total number of function calls (override if needed)
virtual ~BasicFitMethodFunction()
Virtual Destructor (no operations)
FunctionType::BaseFunc BaseFunction
virtual unsigned int NDim() const
Number of dimension (parameters) .
virtual void UpdateNCalls() const
update number of calls
Double_t x[n]
Definition: legend1.C:17
Namespace for new Math classes and functions.
BasicFitMethodFunction< ROOT::Math::IMultiGenFunction > FitMethodFunction
Definition: Fitter.h:43
BasicFitMethodFunction< ROOT::Math::IMultiGradFunction > FitMethodGradFunction
Definition: Fitter.h:44
This file contains a specialised ROOT message handler to test for diagnostic in unit tests.