Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-09-17 09:14:06

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, std::span<const 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, std::span<const std::vector<double>> pos)
0072    {
0073       this->SetModelFunction(modelFCN);
0074       fPositions.assign(pos.begin(), pos.end());
0075    }
0076 
0077    /**
0078 
0079    Evaluates the model function for the different measurement points and
0080    the Parameter values supplied.
0081 
0082    @param par vector of Parameter values to feed to the model function.
0083 
0084    @return A vector containing the model function evaluated
0085    for each measurement point.
0086 
0087    */
0088 
0089    std::vector<double> Elements(std::vector<double> const &par) const override;
0090 
0091    /**
0092 
0093    Accessor to the position of the measurement (x coordinate).
0094 
0095    @param Index Index of the measuerement the position of which to return.
0096 
0097    @return the position of the measurement.
0098 
0099    */
0100 
0101    const std::vector<double> &GetMeasurement(int Index) const override;
0102 
0103    /**
0104 
0105    Accessor to the number of measurements used for calculating
0106    the maximum likelihood.
0107 
0108    @return the number of measurements.
0109 
0110    */
0111 
0112    int GetNumberOfMeasurements() const override;
0113 
0114    /**
0115 
0116    Evaluate function Value, Gradient and Hessian using Fumili approximation, for values of parameters p
0117    The result is cached inside and is return from the FumiliFCNBase::Value ,  FumiliFCNBase::Gradient and
0118    FumiliFCNBase::Hessian methods
0119 
0120    @param par vector of parameters
0121 
0122    **/
0123 
0124    void EvaluateAll(std::vector<double> const &par) override;
0125 
0126 private:
0127    std::vector<std::vector<double>> fPositions;
0128 };
0129 
0130 } // namespace Minuit2
0131 
0132 } // namespace ROOT
0133 
0134 #endif // ROOT_Minuit2_FumiliStandardMaximumLikelihoodFCN