![]() |
|
|||
File indexing completed on 2025-09-16 09:08:15
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 /** 0053 0054 Sets the model function for the data (for example gaussian+linear for a peak) 0055 0056 @param modelFCN a reference to the model function. 0057 0058 */ 0059 0060 void SetModelFunction(const ParametricFunction &modelFCN) { fModelFunction = &modelFCN; } 0061 0062 /** 0063 0064 Returns the model function used for the data. 0065 0066 @return Returns a pointer to the model function. 0067 0068 */ 0069 0070 const ParametricFunction *ModelFunction() const { return fModelFunction; } 0071 0072 /** 0073 0074 Evaluates the model function for the different measurement points and 0075 the Parameter values supplied, calculates a figure-of-merit for each 0076 measurement and returns a vector containing the result of this 0077 evaluation. 0078 0079 @param par vector of Parameter values to feed to the model function. 0080 0081 @return A vector containing the figures-of-merit for the model function evaluated 0082 for each set of measurements. 0083 0084 */ 0085 0086 virtual std::vector<double> Elements(std::vector<double> const &par) const = 0; 0087 0088 /** 0089 0090 Accessor to the parameters of a given measurement. For example in the 0091 case of a chi-square fit with a one-dimensional Gaussian, the Parameter 0092 characterizing the measurement will be the position. It is the Parameter 0093 that is passed to the model function. 0094 0095 @param Index Index of the measueremnt the parameters of which to return 0096 @return A reference to a vector containing the values characterizing a measurement 0097 0098 */ 0099 0100 virtual const std::vector<double> &GetMeasurement(int Index) const = 0; 0101 0102 /** 0103 0104 Accessor to the number of measurements used for calculating the 0105 present figure of merit. 0106 0107 @return the number of measurements 0108 0109 */ 0110 0111 virtual int GetNumberOfMeasurements() const = 0; 0112 0113 /** 0114 0115 Calculates the sum of Elements squared, ie the chi-square. The user must 0116 implement in a class which inherits from FumiliChi2FCN the member function 0117 Elements() which will supply the Elements for the sum. 0118 0119 0120 @param par vector containing the Parameter values for the model function 0121 0122 @return The sum of Elements squared 0123 0124 @see FumiliFCNBase#elements 0125 0126 */ 0127 0128 double operator()(std::vector<double> const &par) const override 0129 { 0130 0131 double chiSquare = 0.0; 0132 std::vector<double> vecElements = Elements(par); 0133 unsigned int vecElementsSize = vecElements.size(); 0134 0135 for (unsigned int i = 0; i < vecElementsSize; ++i) 0136 chiSquare += vecElements[i] * vecElements[i]; 0137 0138 return chiSquare; 0139 } 0140 0141 /** 0142 0143 !!!!!!!!!!!! to be commented 0144 0145 */ 0146 0147 double Up() const override { return 1.0; } 0148 0149 private: 0150 // A pointer to the model function which describes the data 0151 const ParametricFunction *fModelFunction = nullptr; 0152 }; 0153 0154 } // namespace Minuit2 0155 0156 } // namespace ROOT 0157 0158 #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 |
![]() ![]() |