ROOT   Reference Guide
Searching...
No Matches
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 contrinution 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 specyfing 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 = 0) 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 (overrided 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
99public:
100
101
102protected:
103
104
105private:
106
107 unsigned int fNDim; // function dimension
108 unsigned int fNPoints; // size of the data
109 mutable unsigned int fNCalls; // number of function calls
110
111
112};
113
114 // define the normal and gradient function
117
118
119 // useful template definition to use these interface in
120 // generic programming
121 // (comment them out since they are not used anymore)
122/*
123 template<class FunType>
124 struct ParamFunctionTrait {
125 typedef IParamMultiFunction PFType;
126 };
127
128 // specialization for the gradient param functions
129 template<>
132 };
133*/
134
135
136 } // end namespace Math
137
138} // end namespace ROOT
139
140
141
142
143
144
145#endif /* ROOT_Math_FitMethodFunction */
#define g(i)
Definition RSha256.hxx:105
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 specyfing the possible fit method types
BasicFitMethodFunction(int dim, int npoint)
virtual double DataElement(const double *x, unsigned int i, double *g=0) const =0
method returning the data i-th contribution to the fit objective function For example the residual fo...
virtual unsigned int NPoints() const
return the number of data points used in evaluating the function
virtual void ResetNCalls()
reset number of function calls
virtual unsigned int NCalls() const
return the total number of function calls (overrided if needed)
virtual ~BasicFitMethodFunction()
Virtual Destructor (no operations)
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