Logo ROOT  
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 Extension of the FCNBase for the Fumili method. Fumili applies only to
24 minimization problems used for fitting. The method is based on a
25 linearization of the model function negleting second derivatives.
26 User needs to provide the model function. The figure-of-merit describing
27 the difference between the model function and the actual measurements in
28 the case of chi-square is the sum of the squares of the figures-of-merit
29 calculated for each measurement point, which is implemented by the
30 operator() member function. The user still has to implement the calculation
31 of the individual figures-of-merit (which in the majority of the cases
32 will be the (measured Value - the Value predicted by the model)/standard deviation
33 implemeted by the FumiliStandardChi2FCN;
34 however this form can become more complicated (see for an example Numerical Recipes'
35 section 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,
41 section 5
42 
43 @see FumiliStandardChi2FCN
44 
45 @ingroup Minuit
46 
47 */
48 
49 class FumiliChi2FCN : public FumiliFCNBase {
50 
51 public:
53 
54  virtual ~FumiliChi2FCN() {}
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 
74  const ParametricFunction *ModelFunction() const { return fModelFunction; }
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 feeded 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
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  virtual double Up() const { return 1.0; }
152 
153 private:
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
ROOT::Minuit2::FumiliChi2FCN::~FumiliChi2FCN
virtual ~FumiliChi2FCN()
Definition: FumiliChi2FCN.h:54
ROOT::Minuit2::FumiliChi2FCN::FumiliChi2FCN
FumiliChi2FCN()
Definition: FumiliChi2FCN.h:52
ROOT::Minuit2::FumiliFCNBase
Extension of the FCNBase for the Fumili method.
Definition: FumiliFCNBase.h:46
ROOT::Minuit2::FumiliChi2FCN::Elements
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,...
ROOT::Minuit2::ParametricFunction
Function which has parameters.
Definition: ParametricFunction.h:43
ROOT::Minuit2::FumiliChi2FCN
Extension of the FCNBase for the Fumili method.
Definition: FumiliChi2FCN.h:49
ROOT::Minuit2::FumiliChi2FCN::operator()
double operator()(const std::vector< double > &par) const
Calculates the sum of Elements squared, ie the chi-square.
Definition: FumiliChi2FCN.h:132
ROOT::Minuit2::FumiliChi2FCN::ModelFunction
const ParametricFunction * ModelFunction() const
Returns the model function used for the data.
Definition: FumiliChi2FCN.h:74
ROOT::Minuit2::FumiliChi2FCN::GetNumberOfMeasurements
virtual int GetNumberOfMeasurements() const =0
Accessor to the number of measurements used for calculating the present figure of merit.
ROOT::Minuit2::FumiliChi2FCN::GetMeasurement
virtual const std::vector< double > & GetMeasurement(int Index) const =0
Accessor to the parameters of a given measurement.
ROOT::Minuit2::FumiliChi2FCN::fModelFunction
const ParametricFunction * fModelFunction
Definition: FumiliChi2FCN.h:155
ROOT::Minuit2::FumiliChi2FCN::SetModelFunction
void SetModelFunction(const ParametricFunction &modelFCN)
Sets the model function for the data (for example gaussian+linear for a peak)
Definition: FumiliChi2FCN.h:64
ROOT::Minuit2::FumiliChi2FCN::Up
virtual double Up() const
!!!!!!!!!!!! to be commented
Definition: FumiliChi2FCN.h:151
ParametricFunction.h
RooFit::Index
RooCmdArg Index(RooCategory &icat)
Definition: RooGlobalFunc.cxx:98
FumiliFCNBase.h
ROOT
tbb::task_arena is an alias of tbb::interface7::task_arena, which doesn't allow to forward declare tb...
Definition: EExecutionPolicy.hxx:4