ROOT  6.06/09
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 
64  Sets the model function for the data (for example gaussian+linear for a peak)
65 
66  @param modelFunction a reference to the model function.
67 
68  */
69 
70  void SetModelFunction(const ParametricFunction& modelFCN) { fModelFunction = &modelFCN; }
71 
72 
73 
74  /**
75 
76  Returns the model function used for the data.
77 
78  @return Returns a pointer to the model function.
79 
80  */
81 
82  const ParametricFunction * ModelFunction() const { return fModelFunction; }
83 
84 
85 
86  /**
87 
88  Evaluates the model function for the different measurement points and
89  the Parameter values supplied, calculates a figure-of-merit for each
90  measurement and returns a vector containing the result of this
91  evaluation.
92 
93  @param par vector of Parameter values to feed to the model function.
94 
95  @return A vector containing the figures-of-merit for the model function evaluated
96  for each set of measurements.
97 
98  */
99 
100  virtual std::vector<double> Elements(const std::vector<double>& par) const = 0;
101 
102 
103 
104  /**
105 
106  Accessor to the parameters of a given measurement. For example in the
107  case of a chi-square fit with a one-dimensional Gaussian, the Parameter
108  characterizing the measurement will be the position. It is the Parameter
109  that is feeded to the model function.
110 
111  @param Index Index of the measueremnt the parameters of which to return
112  @return A reference to a vector containing the values characterizing a measurement
113 
114  */
115 
116  virtual const std::vector<double> & GetMeasurement(int Index) const = 0;
117 
118 
119  /**
120 
121  Accessor to the number of measurements used for calculating the
122  present figure of merit.
123 
124  @return the number of measurements
125 
126  */
127 
128  virtual int GetNumberOfMeasurements() const = 0;
129 
130 
131 
132  /**
133 
134  Calculates the sum of Elements squared, ie the chi-square. The user must
135  implement in a class which inherits from FumiliChi2FCN the member function
136  Elements() which will supply the Elements for the sum.
137 
138 
139  @param par vector containing the Parameter values for the model function
140 
141  @return The sum of Elements squared
142 
143  @see FumiliFCNBase#elements
144 
145  */
146 
147  double operator()(const std::vector<double>& par) const {
148 
149  double chiSquare = 0.0;
150  std::vector<double> vecElements = Elements(par);
151  unsigned int vecElementsSize = vecElements.size();
152 
153  for (unsigned int i = 0; i < vecElementsSize; ++i)
154  chiSquare += vecElements[i]*vecElements[i];
155 
156  return chiSquare;
157  }
158 
159 
160 
161  /**
162 
163  !!!!!!!!!!!! to be commented
164 
165  */
166 
167  virtual double Up() const { return 1.0; }
168 
169  private:
170 
171  // A pointer to the model function which describes the data
173 
174 
175 
176 };
177 
178  } // namespace Minuit2
179 
180 } // namespace ROOT
181 
182 #endif // ROOT_Minuit2_FumiliChi2FCN
double par[1]
Definition: unuranDistr.cxx:38
const ParametricFunction * ModelFunction() const
Returns the model function used for the data.
Definition: FumiliChi2FCN.h:82
Namespace for new ROOT classes and functions.
Definition: ROOT.py:1
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...
virtual double Up() const
!!!!!!!!!!!! to be commented
const ParametricFunction * fModelFunction
double operator()(const std::vector< double > &par) const
Calculates the sum of Elements squared, ie the chi-square.
Extension of the FCNBase for the Fumili method.
Definition: FumiliChi2FCN.h:52
Function which has parameters.
RooCmdArg Index(RooCategory &icat)
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:70
Extension of the FCNBase for the Fumili method.
Definition: FumiliFCNBase.h:47