|
||||
File indexing completed on 2025-01-18 10:10:23
0001 // @(#)root/minuit2:$Id$ 0002 // Authors: M. Winkler, F. James, L. Moneta, A. Zsenei 2003-2005 0003 0004 /********************************************************************** 0005 * * 0006 * Copyright (c) 2005 LCG ROOT Math team, CERN/PH-SFT * 0007 * * 0008 **********************************************************************/ 0009 0010 #ifndef ROOT_Minuit2_FumiliChi2FCN 0011 #define ROOT_Minuit2_FumiliChi2FCN 0012 0013 #include "FumiliFCNBase.h" 0014 #include <vector> 0015 #include "Minuit2/ParametricFunction.h" 0016 0017 namespace ROOT { 0018 0019 namespace Minuit2 { 0020 0021 /** 0022 0023 Extension of the FCNBase for the Fumili method. Fumili applies only to 0024 minimization problems used for fitting. The method is based on a 0025 linearization of the model function negleting second derivatives. 0026 User needs to provide the model function. The figure-of-merit describing 0027 the difference between the model function and the actual measurements in 0028 the case of chi-square is the sum of the squares of the figures-of-merit 0029 calculated for each measurement point, which is implemented by the 0030 operator() member function. The user still has to implement the calculation 0031 of the individual figures-of-merit (which in the majority of the cases 0032 will be the (measured Value - the Value predicted by the model)/standard deviation 0033 implemented by the FumiliStandardChi2FCN; 0034 however this form can become more complicated (see for an example Numerical Recipes' 0035 section on "Straight-Line Data with Errors in Both Coordinates")). 0036 0037 0038 @author Andras Zsenei and Lorenzo Moneta, Creation date: 24 Aug 2004 0039 0040 @see <A HREF="http://www.cern.ch/winkler/minuit/tutorial/mntutorial.pdf">MINUIT Tutorial</A> on function minimization, 0041 section 5 0042 0043 @see FumiliStandardChi2FCN 0044 0045 @ingroup Minuit 0046 0047 */ 0048 0049 class FumiliChi2FCN : public FumiliFCNBase { 0050 0051 public: 0052 FumiliChi2FCN() {} 0053 0054 ~FumiliChi2FCN() override {} 0055 0056 /** 0057 0058 Sets the model function for the data (for example gaussian+linear for a peak) 0059 0060 @param modelFCN a reference to the model function. 0061 0062 */ 0063 0064 void SetModelFunction(const ParametricFunction &modelFCN) { fModelFunction = &modelFCN; } 0065 0066 /** 0067 0068 Returns the model function used for the data. 0069 0070 @return Returns a pointer to the model function. 0071 0072 */ 0073 0074 const ParametricFunction *ModelFunction() const { return fModelFunction; } 0075 0076 /** 0077 0078 Evaluates the model function for the different measurement points and 0079 the Parameter values supplied, calculates a figure-of-merit for each 0080 measurement and returns a vector containing the result of this 0081 evaluation. 0082 0083 @param par vector of Parameter values to feed to the model function. 0084 0085 @return A vector containing the figures-of-merit for the model function evaluated 0086 for each set of measurements. 0087 0088 */ 0089 0090 virtual std::vector<double> Elements(const std::vector<double> &par) const = 0; 0091 0092 /** 0093 0094 Accessor to the parameters of a given measurement. For example in the 0095 case of a chi-square fit with a one-dimensional Gaussian, the Parameter 0096 characterizing the measurement will be the position. It is the Parameter 0097 that is passed to the model function. 0098 0099 @param Index Index of the measueremnt the parameters of which to return 0100 @return A reference to a vector containing the values characterizing a measurement 0101 0102 */ 0103 0104 virtual const std::vector<double> &GetMeasurement(int Index) const = 0; 0105 0106 /** 0107 0108 Accessor to the number of measurements used for calculating the 0109 present figure of merit. 0110 0111 @return the number of measurements 0112 0113 */ 0114 0115 virtual int GetNumberOfMeasurements() const = 0; 0116 0117 /** 0118 0119 Calculates the sum of Elements squared, ie the chi-square. The user must 0120 implement in a class which inherits from FumiliChi2FCN the member function 0121 Elements() which will supply the Elements for the sum. 0122 0123 0124 @param par vector containing the Parameter values for the model function 0125 0126 @return The sum of Elements squared 0127 0128 @see FumiliFCNBase#elements 0129 0130 */ 0131 0132 double operator()(const std::vector<double> &par) const override 0133 { 0134 0135 double chiSquare = 0.0; 0136 std::vector<double> vecElements = Elements(par); 0137 unsigned int vecElementsSize = vecElements.size(); 0138 0139 for (unsigned int i = 0; i < vecElementsSize; ++i) 0140 chiSquare += vecElements[i] * vecElements[i]; 0141 0142 return chiSquare; 0143 } 0144 0145 /** 0146 0147 !!!!!!!!!!!! to be commented 0148 0149 */ 0150 0151 double Up() const override { return 1.0; } 0152 0153 private: 0154 // A pointer to the model function which describes the data 0155 const ParametricFunction *fModelFunction = nullptr; 0156 }; 0157 0158 } // namespace Minuit2 0159 0160 } // namespace ROOT 0161 0162 #endif // ROOT_Minuit2_FumiliChi2FCN
[ Source navigation ] | [ Diff markup ] | [ Identifier search ] | [ general search ] |
This page was automatically generated by the 2.3.7 LXR engine. The LXR team |