Back to home page

EIC code displayed by LXR

 
 

    


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

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_VariableMetricBuilder
0011 #define ROOT_Minuit2_VariableMetricBuilder
0012 
0013 #include "Minuit2/MnConfig.h"
0014 #include "Minuit2/MinimumBuilder.h"
0015 #include "Minuit2/VariableMetricEDMEstimator.h"
0016 #include "Minuit2/DavidonErrorUpdator.h"
0017 #include "Minuit2/BFGSErrorUpdator.h"
0018 
0019 #include <vector>
0020 #include <memory>
0021 
0022 namespace ROOT {
0023 
0024 namespace Minuit2 {
0025 
0026 /**
0027    Build (find) function minimum using the Variable Metric method (MIGRAD)
0028    Two possible error updators can be chosen
0029     - Davidon : this is the standard formula used in Migrad
0030     - BFGS this is the new formula based on BFGS algorithm
0031       (see Broyden–Fletcher–Goldfarb–Shanno algorithm
0032       https://en.wikipedia.org/wiki/Broyden–Fletcher–Goldfarb–Shanno_algorithm )
0033  */
0034 class VariableMetricBuilder : public MinimumBuilder {
0035 
0036 public:
0037    enum ErrorUpdatorType { kDavidon, kBFGS };
0038 
0039    VariableMetricBuilder(ErrorUpdatorType type = kDavidon) : fEstimator(VariableMetricEDMEstimator())
0040    {
0041       if (type == kBFGS)
0042          fErrorUpdator = std::unique_ptr<MinimumErrorUpdator>(new BFGSErrorUpdator());
0043       else
0044          fErrorUpdator = std::unique_ptr<MinimumErrorUpdator>(new DavidonErrorUpdator());
0045    }
0046 
0047    ~VariableMetricBuilder() override {}
0048 
0049    FunctionMinimum Minimum(const MnFcn &, const GradientCalculator &, const MinimumSeed &, const MnStrategy &,
0050                                    unsigned int, double) const override;
0051 
0052    FunctionMinimum Minimum(const MnFcn &, const GradientCalculator &, const MinimumSeed &, std::vector<MinimumState> &,
0053                            unsigned int, double) const;
0054 
0055    const VariableMetricEDMEstimator &Estimator() const { return fEstimator; }
0056    const MinimumErrorUpdator &ErrorUpdator() const { return *fErrorUpdator; }
0057 
0058    void AddResult(std::vector<MinimumState> &result, const MinimumState &state) const;
0059 
0060 private:
0061    VariableMetricEDMEstimator fEstimator;
0062    std::shared_ptr<MinimumErrorUpdator> fErrorUpdator;
0063 };
0064 
0065 } // namespace Minuit2
0066 
0067 } // namespace ROOT
0068 
0069 #endif // ROOT_Minuit2_VariableMetricBuilder