Logo ROOT   6.13/01
Reference Guide
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 
17 namespace ROOT {
18 
19  namespace Minuit2 {
20 
21 
22 
23 /**
24 
25 Extension of the FCNBase for the Fumili method. Fumili applies only to
26 minimization problems used for fitting. The method is based on a
27 linearization of the model function negleting second derivatives.
28 User needs to provide the model function. The figure-of-merit describing
29 the difference between the model function and the actual measurements in
30 the case of chi-square is the sum of the squares of the figures-of-merit
31 calculated for each measurement point, which is implemented by the
32 operator() member function. The user still has to implement the calculation
33 of the individual figures-of-merit (which in the majority of the cases
34 will be the (measured Value - the Value predicted by the model)/standard deviation
35 implemeted by the FumiliStandardChi2FCN;
36 however this form can become more complicated (see for an example Numerical Recipes'
37 section on "Straight-Line Data with Errors in Both Coordinates")).
38 
39 
40 @author Andras Zsenei and Lorenzo Moneta, Creation date: 24 Aug 2004
41 
42 @see <A HREF="http://www.cern.ch/winkler/minuit/tutorial/mntutorial.pdf">MINUIT Tutorial</A> on function minimization, section 5
43 
44 @see FumiliStandardChi2FCN
45 
46 @ingroup Minuit
47 
48 */
49 
50 
51 
52 class FumiliChi2FCN : public FumiliFCNBase {
53 
54 public:
55 
57 
58  virtual ~FumiliChi2FCN() {}
59 
60 
61  /**
62 
63  Sets the model function for the data (for example gaussian+linear for a peak)
64 
65  @param modelFunction a reference to the model function.
66 
67  */
68 
69  void SetModelFunction(const ParametricFunction& modelFCN) { fModelFunction = &modelFCN; }
70 
71 
72 
73  /**
74 
75  Returns the model function used for the data.
76 
77  @return Returns a pointer to the model function.
78 
79  */
80 
81  const ParametricFunction * ModelFunction() const { return fModelFunction; }
82 
83 
84 
85  /**
86 
87  Evaluates the model function for the different measurement points and
88  the Parameter values supplied, calculates a figure-of-merit for each
89  measurement and returns a vector containing the result of this
90  evaluation.
91 
92  @param par vector of Parameter values to feed to the model function.
93 
94  @return A vector containing the figures-of-merit for the model function evaluated
95  for each set of measurements.
96 
97  */
98 
99  virtual std::vector<double> Elements(const std::vector<double>& par) const = 0;
100 
101 
102 
103  /**
104 
105  Accessor to the parameters of a given measurement. For example in the
106  case of a chi-square fit with a one-dimensional Gaussian, the Parameter
107  characterizing the measurement will be the position. It is the Parameter
108  that is feeded to the model function.
109 
110  @param Index Index of the measueremnt the parameters of which to return
111  @return A reference to a vector containing the values characterizing a measurement
112 
113  */
114 
115  virtual const std::vector<double> & GetMeasurement(int Index) const = 0;
116 
117 
118  /**
119 
120  Accessor to the number of measurements used for calculating the
121  present figure of merit.
122 
123  @return the number of measurements
124 
125  */
126 
127  virtual int GetNumberOfMeasurements() const = 0;
128 
129 
130 
131  /**
132 
133  Calculates the sum of Elements squared, ie the chi-square. The user must
134  implement in a class which inherits from FumiliChi2FCN the member function
135  Elements() which will supply the Elements for the sum.
136 
137 
138  @param par vector containing the Parameter values for the model function
139 
140  @return The sum of Elements squared
141 
142  @see FumiliFCNBase#elements
143 
144  */
145 
146  double operator()(const std::vector<double>& par) const {
147 
148  double chiSquare = 0.0;
149  std::vector<double> vecElements = Elements(par);
150  unsigned int vecElementsSize = vecElements.size();
151 
152  for (unsigned int i = 0; i < vecElementsSize; ++i)
153  chiSquare += vecElements[i]*vecElements[i];
154 
155  return chiSquare;
156  }
157 
158 
159 
160  /**
161 
162  !!!!!!!!!!!! to be commented
163 
164  */
165 
166  virtual double Up() const { return 1.0; }
167 
168  private:
169 
170  // A pointer to the model function which describes the data
172 
173 
174 
175 };
176 
177  } // namespace Minuit2
178 
179 } // namespace ROOT
180 
181 #endif // ROOT_Minuit2_FumiliChi2FCN
Namespace for new ROOT classes and functions.
Definition: TFoamSampler.h:19
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...
const ParametricFunction * ModelFunction() const
Returns the model function used for the data.
Definition: FumiliChi2FCN.h:81
const ParametricFunction * fModelFunction
double operator()(const std::vector< double > &par) const
Calculates the sum of Elements squared, ie the chi-square.
virtual double Up() const
!!!!!!!!!!!! to be commented
Extension of the FCNBase for the Fumili method.
Definition: FumiliChi2FCN.h:52
Function which has parameters.
virtual int GetNumberOfMeasurements() const =0
Accessor to the number of measurements used for calculating the present figure of merit...
virtual const std::vector< double > & GetMeasurement(int Index) const =0
Accessor to the parameters of a given measurement.
void SetModelFunction(const ParametricFunction &modelFCN)
Sets the model function for the data (for example gaussian+linear for a peak)
Definition: FumiliChi2FCN.h:69
Extension of the FCNBase for the Fumili method.
Definition: FumiliFCNBase.h:47