Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-01-18 10:10:24

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_MnApplication
0011 #define ROOT_Minuit2_MnApplication
0012 
0013 #include "Minuit2/MnUserParameterState.h"
0014 #include "Minuit2/MnStrategy.h"
0015 
0016 #include <vector>
0017 
0018 namespace ROOT {
0019 
0020 namespace Minuit2 {
0021 
0022 class FunctionMinimum;
0023 class MinuitParameter;
0024 class MnMachinePrecision;
0025 class ModularFunctionMinimizer;
0026 class FCNBase;
0027 class FCNGradientBase;
0028 
0029 //___________________________________________________________________________
0030 /**
0031     application interface class for minimizers (migrad, simplex, Minimize,
0032     Scan)
0033     User normally instantiates the derived class like ROOT::Minuit2::MnMigrad
0034     for using Migrad for minimization
0035  */
0036 
0037 class MnApplication {
0038 
0039 public:
0040    /// constructor from non-gradient functions
0041    MnApplication(const FCNBase &fcn, const MnUserParameterState &state, const MnStrategy &stra, unsigned int nfcn = 0);
0042 
0043    /// constructor from gradient function
0044    MnApplication(const FCNGradientBase &fcn, const MnUserParameterState &state, const MnStrategy &stra,
0045                  unsigned int nfcn = 0);
0046 
0047    virtual ~MnApplication() {}
0048 
0049    /**
0050       Minimize the function
0051       @param maxfcn : max number of function calls (if = 0) default is used which is set to
0052                      200 + 100 * npar + 5 * npar**2
0053       @param tolerance : value used for terminating iteration procedure.
0054              For example, MIGRAD will stop iterating when edm (expected distance from minimum) will be:
0055              edm < tolerance * 10**-3
0056              Default value of tolerance used is 0.1
0057    */
0058    virtual FunctionMinimum operator()(unsigned int maxfcn = 0, double tolerance = 0.1);
0059 
0060    virtual ModularFunctionMinimizer &Minimizer() = 0;
0061    virtual const ModularFunctionMinimizer &Minimizer() const = 0;
0062 
0063    const MnMachinePrecision &Precision() const { return fState.Precision(); }
0064    const MnUserParameterState &State() const { return fState; }
0065    const MnUserParameters &Parameters() const { return fState.Parameters(); }
0066    const MnUserCovariance &Covariance() const { return fState.Covariance(); }
0067    virtual const FCNBase &Fcnbase() const { return fFCN; }
0068    const MnStrategy &Strategy() const { return fStrategy; }
0069    unsigned int NumOfCalls() const { return fNumCall; }
0070 
0071 protected:
0072    const FCNBase &fFCN;
0073    MnUserParameterState fState;
0074    MnStrategy fStrategy;
0075    unsigned int fNumCall;
0076    bool fUseGrad;
0077 
0078 public:
0079    // facade: forward interface of MnUserParameters and MnUserTransformation
0080    // via MnUserParameterState
0081 
0082    // access to parameters (row-wise)
0083    const std::vector<ROOT::Minuit2::MinuitParameter> &MinuitParameters() const;
0084    // access to parameters and errors in column-wise representation
0085    std::vector<double> Params() const;
0086    std::vector<double> Errors() const;
0087 
0088    // access to single Parameter
0089    const MinuitParameter &Parameter(unsigned int i) const;
0090 
0091    // add free Parameter
0092    void Add(const char *Name, double val, double err);
0093    // add limited Parameter
0094    void Add(const char *Name, double val, double err, double, double);
0095    // add const Parameter
0096    void Add(const char *, double);
0097 
0098    // interaction via external number of Parameter
0099    void Fix(unsigned int);
0100    void Release(unsigned int);
0101    void SetValue(unsigned int, double);
0102    void SetError(unsigned int, double);
0103    void SetLimits(unsigned int, double, double);
0104    void RemoveLimits(unsigned int);
0105 
0106    double Value(unsigned int) const;
0107    double Error(unsigned int) const;
0108 
0109    // interaction via Name of Parameter
0110    void Fix(const char *);
0111    void Release(const char *);
0112    void SetValue(const char *, double);
0113    void SetError(const char *, double);
0114    void SetLimits(const char *, double, double);
0115    void RemoveLimits(const char *);
0116    void SetPrecision(double);
0117 
0118    double Value(const char *) const;
0119    double Error(const char *) const;
0120 
0121    // convert Name into external number of Parameter
0122    unsigned int Index(const char *) const;
0123    // convert external number into Name of Parameter
0124    const char *Name(unsigned int) const;
0125 
0126    // transformation internal <-> external
0127    double Int2ext(unsigned int, double) const;
0128    double Ext2int(unsigned int, double) const;
0129    unsigned int IntOfExt(unsigned int) const;
0130    unsigned int ExtOfInt(unsigned int) const;
0131    unsigned int VariableParameters() const;
0132 };
0133 
0134 } // namespace Minuit2
0135 
0136 } // namespace ROOT
0137 
0138 #endif // ROOT_Minuit2_MnApplication