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_MnMigrad
0011 #define ROOT_Minuit2_MnMigrad
0012 
0013 #include "Minuit2/MnApplication.h"
0014 #include "Minuit2/VariableMetricMinimizer.h"
0015 
0016 #include <vector>
0017 
0018 namespace ROOT {
0019 
0020 namespace Minuit2 {
0021 
0022 class FCNBase;
0023 
0024 //_____________________________________________________________________________
0025 /**
0026    API class for minimization using Variable Metric technology ("MIGRAD");
0027     allows for user interaction: set/change parameters, do minimization,
0028     change parameters, re-do minimization etc.;
0029     also used by MnMinos and MnContours;
0030  */
0031 
0032 class MnMigrad : public MnApplication {
0033 
0034 public:
0035    /// construct from FCNBase + std::vector for parameters and errors
0036    MnMigrad(const FCNBase &fcn, const std::vector<double> &par, const std::vector<double> &err, unsigned int stra = 1)
0037       : MnApplication(fcn, MnUserParameterState(par, err), MnStrategy(stra)), fMinimizer(VariableMetricMinimizer())
0038    {
0039    }
0040 
0041    /// construct from FCNBase + std::vector for parameters and covariance
0042    MnMigrad(const FCNBase &fcn, const std::vector<double> &par, unsigned int nrow, const std::vector<double> &cov,
0043             unsigned int stra = 1)
0044       : MnApplication(fcn, MnUserParameterState(par, cov, nrow), MnStrategy(stra)),
0045         fMinimizer(VariableMetricMinimizer())
0046    {
0047    }
0048 
0049    /// construct from FCNBase + std::vector for parameters and MnUserCovariance
0050    MnMigrad(const FCNBase &fcn, const std::vector<double> &par, const MnUserCovariance &cov, unsigned int stra = 1)
0051       : MnApplication(fcn, MnUserParameterState(par, cov), MnStrategy(stra)), fMinimizer(VariableMetricMinimizer())
0052    {
0053    }
0054 
0055    /// construct from FCNBase + MnUserParameters
0056    MnMigrad(const FCNBase &fcn, const MnUserParameters &par, unsigned int stra = 1)
0057       : MnApplication(fcn, MnUserParameterState(par), MnStrategy(stra)), fMinimizer(VariableMetricMinimizer())
0058    {
0059    }
0060 
0061    /// construct from FCNBase + MnUserParameters + MnUserCovariance
0062    MnMigrad(const FCNBase &fcn, const MnUserParameters &par, const MnUserCovariance &cov, unsigned int stra = 1)
0063       : MnApplication(fcn, MnUserParameterState(par, cov), MnStrategy(stra)), fMinimizer(VariableMetricMinimizer())
0064    {
0065    }
0066 
0067    /// construct from FCNBase + MnUserParameterState + MnStrategy
0068    MnMigrad(const FCNBase &fcn, const MnUserParameterState &par, const MnStrategy &str)
0069       : MnApplication(fcn, MnUserParameterState(par), str), fMinimizer(VariableMetricMinimizer())
0070    {
0071    }
0072 
0073    // constructs from gradient FCN
0074 
0075    /// construct from FCNGradientBase + std::vector for parameters and errors
0076    MnMigrad(const FCNGradientBase &fcn, const std::vector<double> &par, const std::vector<double> &err,
0077             unsigned int stra = 1)
0078       : MnApplication(fcn, MnUserParameterState(par, err), MnStrategy(stra)), fMinimizer(VariableMetricMinimizer())
0079    {
0080    }
0081 
0082    /// construct from FCNGradientBase + std::vector for parameters and covariance
0083    MnMigrad(const FCNGradientBase &fcn, const std::vector<double> &par, unsigned int nrow,
0084             const std::vector<double> &cov, unsigned int stra = 1)
0085       : MnApplication(fcn, MnUserParameterState(par, cov, nrow), MnStrategy(stra)),
0086         fMinimizer(VariableMetricMinimizer())
0087    {
0088    }
0089 
0090    /// construct from FCNGradientBase + std::vector for parameters and MnUserCovariance
0091    MnMigrad(const FCNGradientBase &fcn, const std::vector<double> &par, const MnUserCovariance &cov,
0092             unsigned int stra = 1)
0093       : MnApplication(fcn, MnUserParameterState(par, cov), MnStrategy(stra)), fMinimizer(VariableMetricMinimizer())
0094    {
0095    }
0096 
0097    /// construct from FCNGradientBase + MnUserParameters
0098    MnMigrad(const FCNGradientBase &fcn, const MnUserParameters &par, unsigned int stra = 1)
0099       : MnApplication(fcn, MnUserParameterState(par), MnStrategy(stra)), fMinimizer(VariableMetricMinimizer())
0100    {
0101    }
0102 
0103    /// construct from FCNGradientBase + MnUserParameters + MnUserCovariance
0104    MnMigrad(const FCNGradientBase &fcn, const MnUserParameters &par, const MnUserCovariance &cov, unsigned int stra = 1)
0105       : MnApplication(fcn, MnUserParameterState(par, cov), MnStrategy(stra)), fMinimizer(VariableMetricMinimizer())
0106    {
0107    }
0108 
0109    /// construct from FCNGradientBase + MnUserParameterState + MnStrategy
0110    MnMigrad(const FCNGradientBase &fcn, const MnUserParameterState &par, const MnStrategy &str)
0111       : MnApplication(fcn, MnUserParameterState(par), str), fMinimizer(VariableMetricMinimizer())
0112    {
0113    }
0114 
0115    ~MnMigrad() override {}
0116 
0117    /// Copy constructor, copy shares the reference to the same FCNBase in MnApplication
0118    MnMigrad(const MnMigrad &) = default;
0119 
0120    // Copy assignment deleted, since MnApplication has unassignable reference to FCNBase
0121    MnMigrad &operator=(const MnMigrad &) = delete;
0122 
0123    ModularFunctionMinimizer &Minimizer() override { return fMinimizer; }
0124    const ModularFunctionMinimizer &Minimizer() const override { return fMinimizer; }
0125 
0126 private:
0127    VariableMetricMinimizer fMinimizer;
0128 };
0129 
0130 } // namespace Minuit2
0131 
0132 } // namespace ROOT
0133 
0134 #endif // ROOT_Minuit2_MnMigrad