Back to home page

EIC code displayed by LXR

 
 

    


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_FumiliStandardMaximumLikelihoodFCN
0011 #define ROOT_Minuit2_FumiliStandardMaximumLikelihoodFCN
0012 
0013 #include "Minuit2/FumiliMaximumLikelihoodFCN.h"
0014 #include "Minuit2/ParametricFunction.h"
0015 #include <vector>
0016 
0017 namespace ROOT {
0018 
0019 namespace Minuit2 {
0020 
0021 /**
0022 
0023 Class implementing the Elements member function for the standard
0024 maximum likelihood method.
0025 
0026 @author Andras Zsenei and Lorenzo Moneta, Creation date: 4 Sep 2004
0027 
0028 @see FumiliMaximumLikelihoodFCN
0029 
0030 @ingroup Minuit
0031 
0032 */
0033 
0034 class FumiliStandardMaximumLikelihoodFCN : public FumiliMaximumLikelihoodFCN {
0035 
0036 public:
0037    /**
0038 
0039    Constructor which initializes the measurement points for the one dimensional model function.
0040 
0041    @param modelFCN the model function used for describing the data.
0042 
0043    @param pos vector containing the x values corresponding to the
0044    measurements
0045 
0046    */
0047 
0048    FumiliStandardMaximumLikelihoodFCN(const ParametricFunction &modelFCN, const std::vector<double> &pos)
0049    {
0050       this->SetModelFunction(modelFCN);
0051       unsigned int n = pos.size();
0052       fPositions.reserve(n);
0053       std::vector<double> x(1);
0054       for (unsigned int i = 0; i < n; ++i) {
0055          x[0] = pos[i];
0056          fPositions.push_back(x);
0057       }
0058    }
0059 
0060    /**
0061 
0062    Constructor which initializes the measurement points for the multi dimensional model function.
0063 
0064    @param modelFCN the model function used for describing the data.
0065 
0066    @param pos vector containing the x values corresponding to the
0067    measurements
0068 
0069    */
0070 
0071    FumiliStandardMaximumLikelihoodFCN(const ParametricFunction &modelFCN, const std::vector<std::vector<double>> &pos)
0072    {
0073       this->SetModelFunction(modelFCN);
0074       fPositions = pos;
0075    }
0076 
0077    ~FumiliStandardMaximumLikelihoodFCN() override {}
0078 
0079    /**
0080 
0081    Evaluates the model function for the different measurement points and
0082    the Parameter values supplied.
0083 
0084    @param par vector of Parameter values to feed to the model function.
0085 
0086    @return A vector containing the model function evaluated
0087    for each measurement point.
0088 
0089    */
0090 
0091    std::vector<double> Elements(const std::vector<double> &par) const override;
0092 
0093    /**
0094 
0095    Accessor to the position of the measurement (x coordinate).
0096 
0097    @param Index Index of the measuerement the position of which to return.
0098 
0099    @return the position of the measurement.
0100 
0101    */
0102 
0103    const std::vector<double> &GetMeasurement(int Index) const override;
0104 
0105    /**
0106 
0107    Accessor to the number of measurements used for calculating
0108    the maximum likelihood.
0109 
0110    @return the number of measurements.
0111 
0112    */
0113 
0114    int GetNumberOfMeasurements() const override;
0115 
0116    /**
0117 
0118    Evaluate function Value, Gradient and Hessian using Fumili approximation, for values of parameters p
0119    The result is cached inside and is return from the FumiliFCNBase::Value ,  FumiliFCNBase::Gradient and
0120    FumiliFCNBase::Hessian methods
0121 
0122    @param par vector of parameters
0123 
0124    **/
0125 
0126    void EvaluateAll(const std::vector<double> &par) override;
0127 
0128 private:
0129    std::vector<std::vector<double>> fPositions;
0130 };
0131 
0132 } // namespace Minuit2
0133 
0134 } // namespace ROOT
0135 
0136 #endif // ROOT_Minuit2_FumiliStandardMaximumLikelihoodFCN