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:
52 /**
53
54 Sets the model function for the data (for example gaussian+linear for a peak)
55
56 @param modelFCN a reference to the model function.
57
58 */
59
61
62 /**
63
64 Returns the model function used for the data.
65
66 @return Returns a pointer to the model function.
67
68 */
69
71
72 /**
73
74 Evaluates the model function for the different measurement points and
75 the Parameter values supplied, calculates a figure-of-merit for each
76 measurement and returns a vector containing the result of this
77 evaluation.
78
79 @param par vector of Parameter values to feed to the model function.
80
81 @return A vector containing the figures-of-merit for the model function evaluated
82 for each set of measurements.
83
84 */
85
86 virtual std::vector<double> Elements(std::vector<double> const &par) const = 0;
87
88 /**
89
90 Accessor to the parameters of a given measurement. For example in the
91 case of a chi-square fit with a one-dimensional Gaussian, the Parameter
92 characterizing the measurement will be the position. It is the Parameter
93 that is passed to the model function.
94
95 @param Index Index of the measueremnt the parameters of which to return
96 @return A reference to a vector containing the values characterizing a measurement
97
98 */
99
100 virtual const std::vector<double> &GetMeasurement(int Index) const = 0;
101
102 /**
103
104 Accessor to the number of measurements used for calculating the
105 present figure of merit.
106
107 @return the number of measurements
108
109 */
110
111 virtual int GetNumberOfMeasurements() const = 0;
112
113 /**
114
115 Calculates the sum of Elements squared, ie the chi-square. The user must
116 implement in a class which inherits from FumiliChi2FCN the member function
117 Elements() which will supply the Elements for the sum.
118
119
120 @param par vector containing the Parameter values for the model function
121
122 @return The sum of Elements squared
123
124 @see FumiliFCNBase#elements
125
126 */
127
128 double operator()(std::vector<double> const &par) const override
129 {
130
131 double chiSquare = 0.0;
132 std::vector<double> vecElements = Elements(par);
133 unsigned int vecElementsSize = vecElements.size();
134
135 for (unsigned int i = 0; i < vecElementsSize; ++i)
136 chiSquare += vecElements[i] * vecElements[i];
137
138 return chiSquare;
139 }
140
141 /**
142
143 !!!!!!!!!!!! to be commented
144
145 */
146
147 double Up() const override { return 1.0; }
148
149private:
150 // A pointer to the model function which describes the data
152};
153
154} // namespace Minuit2
155
156} // namespace ROOT
157
158#endif // ROOT_Minuit2_FumiliChi2FCN
ROOT::Detail::TRangeCast< T, true > TRangeDynCast
TRangeDynCast is an adapter class that allows the typed iteration through a TCollection.
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)
double operator()(std::vector< double > const &par) const override
Calculates the sum of Elements squared, ie the chi-square.
const ParametricFunction * fModelFunction
const ParametricFunction * ModelFunction() const
Returns the model function used for the data.
virtual std::vector< double > Elements(std::vector< double > const &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.
Namespace for new ROOT classes and functions.