Logo ROOT  
Reference Guide
 
Loading...
Searching...
No Matches
FumiliChi2FCN.h
Go to the documentation of this file.
1// @(#)root/minuit2:$Id$
2// Authors: M. Winkler, F. James, L. Moneta, A. Zsenei 2003-2005
3
4/**********************************************************************
5 * *
6 * Copyright (c) 2005 LCG ROOT Math team, CERN/PH-SFT *
7 * *
8 **********************************************************************/
9
10#ifndef ROOT_Minuit2_FumiliChi2FCN
11#define ROOT_Minuit2_FumiliChi2FCN
12
13#include "FumiliFCNBase.h"
14#include <vector>
16
17namespace ROOT {
18
19namespace Minuit2 {
20
21/**
22
23Extension of the FCNBase for the Fumili method. Fumili applies only to
24minimization problems used for fitting. The method is based on a
25linearization of the model function negleting second derivatives.
26User needs to provide the model function. The figure-of-merit describing
27the difference between the model function and the actual measurements in
28the case of chi-square is the sum of the squares of the figures-of-merit
29calculated for each measurement point, which is implemented by the
30operator() member function. The user still has to implement the calculation
31of the individual figures-of-merit (which in the majority of the cases
32will be the (measured Value - the Value predicted by the model)/standard deviation
33implemented by the FumiliStandardChi2FCN;
34however this form can become more complicated (see for an example Numerical Recipes'
35section on "Straight-Line Data with Errors in Both Coordinates")).
36
37
38@author Andras Zsenei and Lorenzo Moneta, Creation date: 24 Aug 2004
39
40@see <A HREF="http://www.cern.ch/winkler/minuit/tutorial/mntutorial.pdf">MINUIT Tutorial</A> on function minimization,
41section 5
42
43@see FumiliStandardChi2FCN
44
45@ingroup Minuit
46
47*/
48
50
51public:
53
54 ~FumiliChi2FCN() override {}
55
56 /**
57
58 Sets the model function for the data (for example gaussian+linear for a peak)
59
60 @param modelFCN a reference to the model function.
61
62 */
63
64 void SetModelFunction(const ParametricFunction &modelFCN) { fModelFunction = &modelFCN; }
65
66 /**
67
68 Returns the model function used for the data.
69
70 @return Returns a pointer to the model function.
71
72 */
73
75
76 /**
77
78 Evaluates the model function for the different measurement points and
79 the Parameter values supplied, calculates a figure-of-merit for each
80 measurement and returns a vector containing the result of this
81 evaluation.
82
83 @param par vector of Parameter values to feed to the model function.
84
85 @return A vector containing the figures-of-merit for the model function evaluated
86 for each set of measurements.
87
88 */
89
90 virtual std::vector<double> Elements(const std::vector<double> &par) const = 0;
91
92 /**
93
94 Accessor to the parameters of a given measurement. For example in the
95 case of a chi-square fit with a one-dimensional Gaussian, the Parameter
96 characterizing the measurement will be the position. It is the Parameter
97 that is passed to the model function.
98
99 @param Index Index of the measueremnt the parameters of which to return
100 @return A reference to a vector containing the values characterizing a measurement
101
102 */
103
104 virtual const std::vector<double> &GetMeasurement(int Index) const = 0;
105
106 /**
107
108 Accessor to the number of measurements used for calculating the
109 present figure of merit.
110
111 @return the number of measurements
112
113 */
114
115 virtual int GetNumberOfMeasurements() const = 0;
116
117 /**
118
119 Calculates the sum of Elements squared, ie the chi-square. The user must
120 implement in a class which inherits from FumiliChi2FCN the member function
121 Elements() which will supply the Elements for the sum.
122
123
124 @param par vector containing the Parameter values for the model function
125
126 @return The sum of Elements squared
127
128 @see FumiliFCNBase#elements
129
130 */
131
132 double operator()(const std::vector<double> &par) const override
133 {
134
135 double chiSquare = 0.0;
136 std::vector<double> vecElements = Elements(par);
137 unsigned int vecElementsSize = vecElements.size();
138
139 for (unsigned int i = 0; i < vecElementsSize; ++i)
140 chiSquare += vecElements[i] * vecElements[i];
141
142 return chiSquare;
143 }
144
145 /**
146
147 !!!!!!!!!!!! to be commented
148
149 */
150
151 double Up() const override { return 1.0; }
152
153private:
154 // A pointer to the model function which describes the data
156};
157
158} // namespace Minuit2
159
160} // namespace ROOT
161
162#endif // ROOT_Minuit2_FumiliChi2FCN
Extension of the FCNBase for the Fumili method.
void SetModelFunction(const ParametricFunction &modelFCN)
Sets the model function for the data (for example gaussian+linear for a peak)
const ParametricFunction * fModelFunction
double operator()(const std::vector< double > &par) const override
Calculates the sum of Elements squared, ie the chi-square.
const ParametricFunction * ModelFunction() const
Returns the model function used for the data.
virtual std::vector< double > Elements(const std::vector< double > &par) const =0
Evaluates the model function for the different measurement points and the Parameter values supplied,...
double Up() const override
!!!!!!!!!!!! to be commented
virtual const std::vector< double > & GetMeasurement(int Index) const =0
Accessor to the parameters of a given measurement.
virtual int GetNumberOfMeasurements() const =0
Accessor to the number of measurements used for calculating the present figure of merit.
Extension of the FCNBase for the Fumili method.
Function which has parameters.
tbb::task_arena is an alias of tbb::interface7::task_arena, which doesn't allow to forward declare tb...