Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-01-30 10:22:13

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_MnHesse
0011 #define ROOT_Minuit2_MnHesse
0012 
0013 #include "Minuit2/MnConfig.h"
0014 #include "Minuit2/MnStrategy.h"
0015 
0016 #include <vector>
0017 
0018 namespace ROOT {
0019 
0020 namespace Minuit2 {
0021 
0022 class FCNBase;
0023 class MnUserParameterState;
0024 class MnUserParameters;
0025 class MnUserCovariance;
0026 class MnUserTransformation;
0027 class MinimumState;
0028 class MnMachinePrecision;
0029 class MnFcn;
0030 class FunctionMinimum;
0031 class FCNGradientBase;
0032 
0033 //_______________________________________________________________________
0034 /**
0035     API class for calculating the numerical covariance matrix
0036     (== 2x Inverse Hessian == 2x Inverse 2nd derivative); can be used by the
0037     user or Minuit itself
0038  */
0039 
0040 class MnHesse {
0041 
0042 public:
0043    /// default constructor with default strategy
0044    MnHesse() : fStrategy(MnStrategy(1)) {}
0045 
0046    /// constructor with user-defined strategy level
0047    MnHesse(unsigned int stra) : fStrategy(MnStrategy(stra)) {}
0048 
0049    /// conctructor with specific strategy
0050    MnHesse(const MnStrategy &stra) : fStrategy(stra) {}
0051 
0052    ~MnHesse() {}
0053 
0054    ///
0055    /// low-level API
0056    ///
0057    /// FCN + parameters + errors
0058    MnUserParameterState operator()(const FCNBase &, const std::vector<double> &, const std::vector<double> &,
0059                                    unsigned int maxcalls = 0) const;
0060    /// FCN + parameters + covariance
0061    MnUserParameterState operator()(const FCNBase &, const std::vector<double> &, unsigned int nrow,
0062                                    const std::vector<double> &, unsigned int maxcalls = 0) const;
0063    /// FCN + parameters + MnUserCovariance
0064    MnUserParameterState
0065    operator()(const FCNBase &, const std::vector<double> &, const MnUserCovariance &, unsigned int maxcalls = 0) const;
0066    ///
0067    /// high-level API
0068    ///
0069    /// FCN + MnUserParameters
0070    MnUserParameterState operator()(const FCNBase &, const MnUserParameters &, unsigned int maxcalls = 0) const;
0071    /// FCN + MnUserParameters + MnUserCovariance
0072    MnUserParameterState
0073    operator()(const FCNBase &, const MnUserParameters &, const MnUserCovariance &, unsigned int maxcalls = 0) const;
0074    /// FCN + MnUserParameterState
0075    MnUserParameterState operator()(const FCNBase &, const MnUserParameterState &, unsigned int maxcalls = 0) const;
0076    ///
0077    /// API to use MnHesse after minimization when function minimum is avalilable, otherwise information on the last
0078    /// state will be lost. (It would be needed to re-call the gradient and spend extra useless function calls) The
0079    /// Function Minimum is updated (modified) by adding the Hesse results as last state of minimization
0080    ///
0081    void operator()(const FCNBase &, FunctionMinimum &, unsigned int maxcalls = 0) const;
0082 
0083    /// internal interface
0084    ///
0085    MinimumState
0086    operator()(const MnFcn &, const MinimumState &, const MnUserTransformation &, unsigned int maxcalls = 0) const;
0087 
0088    /// forward interface of MnStrategy
0089    unsigned int Ncycles() const { return fStrategy.HessianNCycles(); }
0090    double Tolerstp() const { return fStrategy.HessianStepTolerance(); }
0091    double TolerG2() const { return fStrategy.HessianG2Tolerance(); }
0092 
0093 private:
0094 
0095    /// internal function to compute the Hessian using numerical derivative computation
0096    MinimumState ComputeNumerical(const MnFcn &, const MinimumState &, const MnUserTransformation &, unsigned int maxcalls) const;
0097 
0098    /// internal function to compute the Hessian using an analytical computation or externally provided in the FCNGradientBase class
0099    MinimumState ComputeAnalytical(const FCNGradientBase &, const MinimumState &, const MnUserTransformation &) const;
0100 
0101    MnStrategy fStrategy;
0102 };
0103 
0104 } // namespace Minuit2
0105 
0106 } // namespace ROOT
0107 
0108 #endif // ROOT_Minuit2_MnHesse