diff --git a/README/ReleaseNotes/v634/index.md b/README/ReleaseNotes/v634/index.md index fb91f0a062115..227f88c56f826 100644 --- a/README/ReleaseNotes/v634/index.md +++ b/README/ReleaseNotes/v634/index.md @@ -74,6 +74,7 @@ The following people have contributed to this new version: - The `RooAbsReal::plotSliceOn()` function that was deprecated since at least ROOT 6 was removed. Use `plotOn(frame,Slice(...))` instead. - The `RooTemplateProxy` constructors that take a `proxyOwnsArg` parameter to manually pass ownership are deprecated and replaced by a new constructor that takes ownership via `std::unique_ptr`. They will be removed in ROOT 6.36. - Several RooFit legacy functions are deprecated and will be removed in ROOT 6.36 (see section "RooFit libraries") +- Multiple overloads of internal Minuit 2 constructors and functions have been removed. If your code fails to compile, you can easily change to another overload that takes a `MnUserParameterState`, which is a change backwards compatible with older ROOT versions. ## Core Libraries diff --git a/math/minuit2/CMakeLists.txt b/math/minuit2/CMakeLists.txt index 8b41d0af6f5c0..0f4f0bce9d204 100644 --- a/math/minuit2/CMakeLists.txt +++ b/math/minuit2/CMakeLists.txt @@ -43,7 +43,6 @@ if(CMAKE_PROJECT_NAME STREQUAL ROOT) Minuit2/FumiliStandardChi2FCN.h Minuit2/FumiliStandardMaximumLikelihoodFCN.h Minuit2/FunctionGradient.h - Minuit2/FunctionMinimizer.h Minuit2/FunctionMinimum.h Minuit2/GenericFunction.h Minuit2/GradientCalculator.h diff --git a/math/minuit2/inc/LinkDef.h b/math/minuit2/inc/LinkDef.h index 5e64116956b5b..f78ff0b5a9630 100644 --- a/math/minuit2/inc/LinkDef.h +++ b/math/minuit2/inc/LinkDef.h @@ -38,7 +38,6 @@ #pragma link C++ class ROOT::Minuit2::MnUserParameterState; #pragma link C++ class ROOT::Minuit2::MnUserParameters; #pragma link C++ class ROOT::Minuit2::MnStrategy; -#pragma link C++ class ROOT::Minuit2::FunctionMinimizer; #pragma link C++ class ROOT::Minuit2::ModularFunctionMinimizer; #pragma link C++ class ROOT::Minuit2::VariableMetricMinimizer; #pragma link C++ class ROOT::Minuit2::SimplexMinimizer; diff --git a/math/minuit2/inc/Minuit2/ContoursError.h b/math/minuit2/inc/Minuit2/ContoursError.h index 2fe2fbcacc34b..163ab4e3e591b 100644 --- a/math/minuit2/inc/Minuit2/ContoursError.h +++ b/math/minuit2/inc/Minuit2/ContoursError.h @@ -31,8 +31,6 @@ class ContoursError { { } - ~ContoursError() {} - ContoursError(const ContoursError &cont) : fParX(cont.fParX), fParY(cont.fParY), fPoints(cont.fPoints), fXMinos(cont.fXMinos), fYMinos(cont.fYMinos), fNFcn(cont.fNFcn) diff --git a/math/minuit2/inc/Minuit2/FumiliMinimizer.h b/math/minuit2/inc/Minuit2/FumiliMinimizer.h index 3c3b72c74e096..89976693a62da 100644 --- a/math/minuit2/inc/Minuit2/FumiliMinimizer.h +++ b/math/minuit2/inc/Minuit2/FumiliMinimizer.h @@ -60,8 +60,6 @@ class FumiliMinimizer : public ModularFunctionMinimizer { FumiliMinimizer() : fMinSeedGen(MnSeedGenerator()), fMinBuilder(FumiliBuilder()) {} - ~FumiliMinimizer() override {} - /** Accessor to the seed generator of the minimizer. diff --git a/math/minuit2/inc/Minuit2/FunctionMinimizer.h b/math/minuit2/inc/Minuit2/FunctionMinimizer.h deleted file mode 100644 index 6c0c5d2dc881f..0000000000000 --- a/math/minuit2/inc/Minuit2/FunctionMinimizer.h +++ /dev/null @@ -1,55 +0,0 @@ -// @(#)root/minuit2:$Id$ -// Authors: M. Winkler, F. James, L. Moneta, A. Zsenei 2003-2005 - -/********************************************************************** - * * - * Copyright (c) 2005 LCG ROOT Math team, CERN/PH-SFT * - * * - **********************************************************************/ - -#ifndef ROOT_Minuit2_FunctionMinimizer -#define ROOT_Minuit2_FunctionMinimizer - -#include "Minuit2/MnConfig.h" - -#include - -#include - -namespace ROOT { - -namespace Minuit2 { - -class FCNBase; -class FunctionMinimum; - -//_____________________________________________________________________________________ -/** base class for function minimizers; user may give FCN or FCN with Gradient, - Parameter starting values and initial Error guess (sigma) (or "step size"), - or Parameter starting values and initial covariance matrix; - covariance matrix is stored in Upper triangular packed storage format, - e.g. the Elements in the array are arranged like - {a(0,0), a(0,1), a(1,1), a(0,2), a(1,2), a(2,2), ...}, - the size is nrow*(nrow+1)/2 (see also MnUserCovariance.h); - */ - -class FunctionMinimizer { - -public: - virtual ~FunctionMinimizer() {} - - // starting values for parameters and errors - virtual FunctionMinimum Minimize(const FCNBase &, std::span par, std::span err, - unsigned int strategy, unsigned int maxfcn, double toler) const = 0; - - // starting values for parameters and covariance matrix - virtual FunctionMinimum Minimize(const FCNBase &, std::span par, unsigned int nrow, - std::span cov, unsigned int strategy, unsigned int maxfcn, - double toler) const = 0; -}; - -} // namespace Minuit2 - -} // namespace ROOT - -#endif // ROOT_Minuit2_FunctionMinimizer diff --git a/math/minuit2/inc/Minuit2/MnFumiliMinimize.h b/math/minuit2/inc/Minuit2/MnFumiliMinimize.h index 9de26c16574b3..285ae6c2e1350 100644 --- a/math/minuit2/inc/Minuit2/MnFumiliMinimize.h +++ b/math/minuit2/inc/Minuit2/MnFumiliMinimize.h @@ -38,43 +38,8 @@ also used by MnMinos and MnContours; class MnFumiliMinimize : public MnApplication { public: - /// construct from FumiliFCNBase + std::vector for parameters and errors - MnFumiliMinimize(const FumiliFCNBase &fcn, std::span par, std::span err, - unsigned int stra = 1) - : MnApplication(fcn, MnUserParameterState(par, err), MnStrategy(stra)), fMinimizer(FumiliMinimizer()), fFCN(fcn) - { - } - - /// construct from FumiliFCNBase + std::vector for parameters and covariance - MnFumiliMinimize(const FumiliFCNBase &fcn, std::span par, unsigned int nrow, - std::span cov, unsigned int stra = 1) - : MnApplication(fcn, MnUserParameterState(par, cov, nrow), MnStrategy(stra)), fMinimizer(FumiliMinimizer()), - fFCN(fcn) - { - } - - /// construct from FumiliFCNBase + std::vector for parameters and MnUserCovariance - MnFumiliMinimize(const FumiliFCNBase &fcn, std::span par, const MnUserCovariance &cov, - unsigned int stra = 1) - : MnApplication(fcn, MnUserParameterState(par, cov), MnStrategy(stra)), fMinimizer(FumiliMinimizer()), fFCN(fcn) - { - } - - /// construct from FumiliFCNBase + MnUserParameters - MnFumiliMinimize(const FumiliFCNBase &fcn, const MnUserParameters &par, unsigned int stra = 1) - : MnApplication(fcn, MnUserParameterState(par), MnStrategy(stra)), fMinimizer(FumiliMinimizer()), fFCN(fcn) - { - } - - /// construct from FumiliFCNBase + MnUserParameters + MnUserCovariance - MnFumiliMinimize(const FumiliFCNBase &fcn, const MnUserParameters &par, const MnUserCovariance &cov, - unsigned int stra = 1) - : MnApplication(fcn, MnUserParameterState(par, cov), MnStrategy(stra)), fMinimizer(FumiliMinimizer()), fFCN(fcn) - { - } - /// construct from FumiliFCNBase + MnUserParameterState + MnStrategy - MnFumiliMinimize(const FumiliFCNBase &fcn, const MnUserParameterState &par, const MnStrategy &str) + MnFumiliMinimize(const FumiliFCNBase &fcn, const MnUserParameterState &par, const MnStrategy &str = MnStrategy{1}) : MnApplication(fcn, MnUserParameterState(par), str), fMinimizer(FumiliMinimizer()), fFCN(fcn) { } @@ -85,8 +50,6 @@ class MnFumiliMinimize : public MnApplication { { } - ~MnFumiliMinimize() override {} - FumiliMinimizer &Minimizer() override { return fMinimizer; } const FumiliMinimizer &Minimizer() const override { return fMinimizer; } diff --git a/math/minuit2/inc/Minuit2/MnHesse.h b/math/minuit2/inc/Minuit2/MnHesse.h index 66a90efb2ec8c..0da7b7f8a7c10 100644 --- a/math/minuit2/inc/Minuit2/MnHesse.h +++ b/math/minuit2/inc/Minuit2/MnHesse.h @@ -50,28 +50,6 @@ class MnHesse { /// conctructor with specific strategy MnHesse(const MnStrategy &stra) : fStrategy(stra) {} - ~MnHesse() {} - - /// - /// low-level API - /// - /// FCN + parameters + errors - MnUserParameterState operator()(const FCNBase &, std::span, std::span, - unsigned int maxcalls = 0) const; - /// FCN + parameters + covariance - MnUserParameterState operator()(const FCNBase &, std::span, unsigned int nrow, - std::span, unsigned int maxcalls = 0) const; - /// FCN + parameters + MnUserCovariance - MnUserParameterState - operator()(const FCNBase &, std::span, const MnUserCovariance &, unsigned int maxcalls = 0) const; - /// - /// high-level API - /// - /// FCN + MnUserParameters - MnUserParameterState operator()(const FCNBase &, const MnUserParameters &, unsigned int maxcalls = 0) const; - /// FCN + MnUserParameters + MnUserCovariance - MnUserParameterState - operator()(const FCNBase &, const MnUserParameters &, const MnUserCovariance &, unsigned int maxcalls = 0) const; /// FCN + MnUserParameterState MnUserParameterState operator()(const FCNBase &, const MnUserParameterState &, unsigned int maxcalls = 0) const; /// diff --git a/math/minuit2/inc/Minuit2/MnMigrad.h b/math/minuit2/inc/Minuit2/MnMigrad.h index 4f891f72ced1b..d0181b6b90816 100644 --- a/math/minuit2/inc/Minuit2/MnMigrad.h +++ b/math/minuit2/inc/Minuit2/MnMigrad.h @@ -32,46 +32,12 @@ class FCNBase; class MnMigrad : public MnApplication { public: - /// construct from FCNBase + std::vector for parameters and errors - MnMigrad(const FCNBase &fcn, std::span par, std::span err, unsigned int stra = 1) - : MnApplication(fcn, MnUserParameterState(par, err), MnStrategy(stra)), fMinimizer(VariableMetricMinimizer()) - { - } - - /// construct from FCNBase + std::vector for parameters and covariance - MnMigrad(const FCNBase &fcn, std::span par, unsigned int nrow, std::span cov, - unsigned int stra = 1) - : MnApplication(fcn, MnUserParameterState(par, cov, nrow), MnStrategy(stra)), - fMinimizer(VariableMetricMinimizer()) - { - } - - /// construct from FCNBase + std::vector for parameters and MnUserCovariance - MnMigrad(const FCNBase &fcn, std::span par, const MnUserCovariance &cov, unsigned int stra = 1) - : MnApplication(fcn, MnUserParameterState(par, cov), MnStrategy(stra)), fMinimizer(VariableMetricMinimizer()) - { - } - - /// construct from FCNBase + MnUserParameters - MnMigrad(const FCNBase &fcn, const MnUserParameters &par, unsigned int stra = 1) - : MnApplication(fcn, MnUserParameterState(par), MnStrategy(stra)), fMinimizer(VariableMetricMinimizer()) - { - } - - /// construct from FCNBase + MnUserParameters + MnUserCovariance - MnMigrad(const FCNBase &fcn, const MnUserParameters &par, const MnUserCovariance &cov, unsigned int stra = 1) - : MnApplication(fcn, MnUserParameterState(par, cov), MnStrategy(stra)), fMinimizer(VariableMetricMinimizer()) - { - } - /// construct from FCNBase + MnUserParameterState + MnStrategy - MnMigrad(const FCNBase &fcn, const MnUserParameterState &par, const MnStrategy &str) - : MnApplication(fcn, MnUserParameterState(par), str), fMinimizer(VariableMetricMinimizer()) + MnMigrad(const FCNBase &fcn, const MnUserParameterState &par, const MnStrategy &str = MnStrategy{1}) + : MnApplication(fcn, {par}, str), fMinimizer(VariableMetricMinimizer()) { } - ~MnMigrad() override {} - /// Copy constructor, copy shares the reference to the same FCNBase in MnApplication MnMigrad(const MnMigrad &) = default; diff --git a/math/minuit2/inc/Minuit2/MnMinimize.h b/math/minuit2/inc/Minuit2/MnMinimize.h index 905e158bfb1d1..89f8d481d6495 100644 --- a/math/minuit2/inc/Minuit2/MnMinimize.h +++ b/math/minuit2/inc/Minuit2/MnMinimize.h @@ -30,40 +30,9 @@ class FCNBase; class MnMinimize : public MnApplication { public: - /// construct from FCNBase + std::vector for parameters and errors - MnMinimize(const FCNBase &fcn, std::span par, std::span err, unsigned int stra = 1) - : MnApplication(fcn, MnUserParameterState(par, err), MnStrategy(stra)), fMinimizer(CombinedMinimizer()) - { - } - - /// construct from FCNBase + std::vector for parameters and covariance - MnMinimize(const FCNBase &fcn, std::span par, unsigned int nrow, std::span cov, - unsigned int stra = 1) - : MnApplication(fcn, MnUserParameterState(par, cov, nrow), MnStrategy(stra)), fMinimizer(CombinedMinimizer()) - { - } - - /// construct from FCNBase + std::vector for parameters and MnUserCovariance - MnMinimize(const FCNBase &fcn, std::span par, const MnUserCovariance &cov, unsigned int stra = 1) - : MnApplication(fcn, MnUserParameterState(par, cov), MnStrategy(stra)), fMinimizer(CombinedMinimizer()) - { - } - - /// construct from FCNBase + MnUserParameters - MnMinimize(const FCNBase &fcn, const MnUserParameters &par, unsigned int stra = 1) - : MnApplication(fcn, MnUserParameterState(par), MnStrategy(stra)), fMinimizer(CombinedMinimizer()) - { - } - - /// construct from FCNBase + MnUserParameters + MnUserCovariance - MnMinimize(const FCNBase &fcn, const MnUserParameters &par, const MnUserCovariance &cov, unsigned int stra = 1) - : MnApplication(fcn, MnUserParameterState(par, cov), MnStrategy(stra)), fMinimizer(CombinedMinimizer()) - { - } - /// construct from FCNBase + MnUserParameterState + MnStrategy - MnMinimize(const FCNBase &fcn, const MnUserParameterState &par, const MnStrategy &str) - : MnApplication(fcn, MnUserParameterState(par), str), fMinimizer(CombinedMinimizer()) + MnMinimize(const FCNBase &fcn, const MnUserParameterState &par, const MnStrategy &str = MnStrategy{1}) + : MnApplication(fcn, {par}, str), fMinimizer(CombinedMinimizer()) { } @@ -72,8 +41,6 @@ class MnMinimize : public MnApplication { { } - ~MnMinimize() override {} - ModularFunctionMinimizer &Minimizer() override { return fMinimizer; } const ModularFunctionMinimizer &Minimizer() const override { return fMinimizer; } diff --git a/math/minuit2/inc/Minuit2/MnParameterScan.h b/math/minuit2/inc/Minuit2/MnParameterScan.h index babfc66afbc43..d024eb6e397fc 100644 --- a/math/minuit2/inc/Minuit2/MnParameterScan.h +++ b/math/minuit2/inc/Minuit2/MnParameterScan.h @@ -33,8 +33,6 @@ class MnParameterScan { MnParameterScan(const FCNBase &, const MnUserParameters &, double); - ~MnParameterScan() {} - // returns pairs of (x,y) points, x=parameter Value, y=function Value of FCN std::vector> operator()(unsigned int par, unsigned int maxsteps = 41, double low = 0., double high = 0.); diff --git a/math/minuit2/inc/Minuit2/MnScan.h b/math/minuit2/inc/Minuit2/MnScan.h index b8985a4ddc19a..7064ac08c3dfe 100644 --- a/math/minuit2/inc/Minuit2/MnScan.h +++ b/math/minuit2/inc/Minuit2/MnScan.h @@ -33,39 +33,8 @@ class FCNBase; class MnScan : public MnApplication { public: - /// construct from FCNBase + std::vector for parameters and errors - MnScan(const FCNBase &fcn, std::span par, std::span err, unsigned int stra = 1) - : MnApplication(fcn, MnUserParameterState(par, err), MnStrategy(stra)), fMinimizer(ScanMinimizer()) - { - } - - /// construct from FCNBase + std::vector for parameters and covariance - MnScan(const FCNBase &fcn, std::span par, unsigned int nrow, std::span cov, - unsigned int stra = 1) - : MnApplication(fcn, MnUserParameterState(par, cov, nrow), MnStrategy(stra)), fMinimizer(ScanMinimizer()) - { - } - - /// construct from FCNBase + std::vector for parameters and MnUserCovariance - MnScan(const FCNBase &fcn, std::span par, const MnUserCovariance &cov, unsigned int stra = 1) - : MnApplication(fcn, MnUserParameterState(par, cov), MnStrategy(stra)), fMinimizer(ScanMinimizer()) - { - } - - /// construct from FCNBase + MnUserParameters - MnScan(const FCNBase &fcn, const MnUserParameters &par, unsigned int stra = 1) - : MnApplication(fcn, MnUserParameterState(par), MnStrategy(stra)), fMinimizer(ScanMinimizer()) - { - } - - /// construct from FCNBase + MnUserParameters + MnUserCovariance - MnScan(const FCNBase &fcn, const MnUserParameters &par, const MnUserCovariance &cov, unsigned int stra = 1) - : MnApplication(fcn, MnUserParameterState(par, cov), MnStrategy(stra)), fMinimizer(ScanMinimizer()) - { - } - /// construct from FCNBase + MnUserParameterState + MnStrategy - MnScan(const FCNBase &fcn, const MnUserParameterState &par, const MnStrategy &str) + MnScan(const FCNBase &fcn, const MnUserParameterState &par, const MnStrategy &str = MnStrategy{}) : MnApplication(fcn, MnUserParameterState(par), str), fMinimizer(ScanMinimizer()) { } @@ -75,8 +44,6 @@ class MnScan : public MnApplication { { } - ~MnScan() override {} - ModularFunctionMinimizer &Minimizer() override { return fMinimizer; } const ModularFunctionMinimizer &Minimizer() const override { return fMinimizer; } @@ -86,7 +53,6 @@ class MnScan : public MnApplication { private: ScanMinimizer fMinimizer; -private: /// forbidden assignment (const FCNBase& = ) MnScan &operator=(const MnScan &) { return *this; } }; diff --git a/math/minuit2/inc/Minuit2/MnSimplex.h b/math/minuit2/inc/Minuit2/MnSimplex.h index 6fd6296a54737..bc341316cf1e3 100644 --- a/math/minuit2/inc/Minuit2/MnSimplex.h +++ b/math/minuit2/inc/Minuit2/MnSimplex.h @@ -35,39 +35,8 @@ class FCNBase; class MnSimplex : public MnApplication { public: - /// construct from FCNBase + std::vector for parameters and errors - MnSimplex(const FCNBase &fcn, std::span par, std::span err, unsigned int stra = 1) - : MnApplication(fcn, MnUserParameterState(par, err), MnStrategy(stra)), fMinimizer(SimplexMinimizer()) - { - } - - /// construct from FCNBase + std::vector for parameters and covariance - MnSimplex(const FCNBase &fcn, std::span par, unsigned int nrow, std::span cov, - unsigned int stra = 1) - : MnApplication(fcn, MnUserParameterState(par, cov, nrow), MnStrategy(stra)), fMinimizer(SimplexMinimizer()) - { - } - - /// construct from FCNBase + std::vector for parameters and MnUserCovariance - MnSimplex(const FCNBase &fcn, std::span par, const MnUserCovariance &cov, unsigned int stra = 1) - : MnApplication(fcn, MnUserParameterState(par, cov), MnStrategy(stra)), fMinimizer(SimplexMinimizer()) - { - } - - /// construct from FCNBase + MnUserParameters - MnSimplex(const FCNBase &fcn, const MnUserParameters &par, unsigned int stra = 1) - : MnApplication(fcn, MnUserParameterState(par), MnStrategy(stra)), fMinimizer(SimplexMinimizer()) - { - } - - /// construct from FCNBase + MnUserParameters + MnUserCovariance - MnSimplex(const FCNBase &fcn, const MnUserParameters &par, const MnUserCovariance &cov, unsigned int stra = 1) - : MnApplication(fcn, MnUserParameterState(par, cov), MnStrategy(stra)), fMinimizer(SimplexMinimizer()) - { - } - /// construct from FCNBase + MnUserParameterState + MnStrategy - MnSimplex(const FCNBase &fcn, const MnUserParameterState &par, const MnStrategy &str) + MnSimplex(const FCNBase &fcn, const MnUserParameterState &par, const MnStrategy &str = MnStrategy{1}) : MnApplication(fcn, MnUserParameterState(par), str), fMinimizer(SimplexMinimizer()) { } @@ -77,8 +46,6 @@ class MnSimplex : public MnApplication { { } - ~MnSimplex() override {} - ModularFunctionMinimizer &Minimizer() override { return fMinimizer; } const ModularFunctionMinimizer &Minimizer() const override { return fMinimizer; } diff --git a/math/minuit2/inc/Minuit2/MnUserCovariance.h b/math/minuit2/inc/Minuit2/MnUserCovariance.h index 9b8343cad4b5c..1374daf7d5767 100644 --- a/math/minuit2/inc/Minuit2/MnUserCovariance.h +++ b/math/minuit2/inc/Minuit2/MnUserCovariance.h @@ -29,7 +29,7 @@ namespace Minuit2 { class MnUserCovariance { public: - MnUserCovariance() : fData(std::vector()), fNRow(0) {} + MnUserCovariance() = default; // safe constructor using std::vector MnUserCovariance(std::span data, unsigned int nrow) : fData(data.begin(), data.end()), fNRow(nrow) @@ -45,19 +45,6 @@ class MnUserCovariance { MnUserCovariance(unsigned int n) : fData(std::vector(n * (n + 1) / 2, 0.)), fNRow(n) {} - ~MnUserCovariance() {} - - MnUserCovariance(const MnUserCovariance &cov) : fData(cov.fData), fNRow(cov.fNRow) {} - - MnUserCovariance &operator=(const MnUserCovariance &cov) - { - if (this != &cov) { - fData = cov.fData; - fNRow = cov.fNRow; - } - return *this; - } - double operator()(unsigned int row, unsigned int col) const { assert(row < fNRow && col < fNRow); @@ -91,7 +78,7 @@ class MnUserCovariance { private: std::vector fData; - unsigned int fNRow; + unsigned int fNRow = 0; }; } // namespace Minuit2 diff --git a/math/minuit2/inc/Minuit2/ModularFunctionMinimizer.h b/math/minuit2/inc/Minuit2/ModularFunctionMinimizer.h index 950a728d0c890..2cf3d8c2687eb 100644 --- a/math/minuit2/inc/Minuit2/ModularFunctionMinimizer.h +++ b/math/minuit2/inc/Minuit2/ModularFunctionMinimizer.h @@ -12,7 +12,7 @@ #include "Minuit2/MnConfig.h" -#include "Minuit2/FunctionMinimizer.h" +#include "Minuit2/MnStrategy.h" #include @@ -28,8 +28,9 @@ class GradientCalculator; class MnUserParameterState; class MnUserParameters; class MnUserCovariance; -class MnStrategy; +class FCNBase; class FumiliFCNBase; +class FunctionMinimum; //_____________________________________________________________ /** @@ -37,43 +38,15 @@ class FumiliFCNBase; Various Minimize methods are provided varying on the type of FCN function passesd and on the objects used for the parameters */ -class ModularFunctionMinimizer : public FunctionMinimizer { +class ModularFunctionMinimizer { public: - ~ModularFunctionMinimizer() override {} - // inherited interface - FunctionMinimum Minimize(const FCNBase &, std::span, std::span, - unsigned int stra = 1, unsigned int maxfcn = 0, double toler = 0.1) const override; + virtual ~ModularFunctionMinimizer() = default; - FunctionMinimum Minimize(const FCNBase &, std::span, unsigned int, - std::span, unsigned int stra = 1, unsigned int maxfcn = 0, - double toler = 0.1) const override; - - // extension - virtual FunctionMinimum Minimize(const FCNBase &, const MnUserParameters &, const MnStrategy &, + virtual FunctionMinimum Minimize(const FCNBase &, const MnUserParameterState &, const MnStrategy & = MnStrategy{1}, unsigned int maxfcn = 0, double toler = 0.1) const; - virtual FunctionMinimum Minimize(const FCNBase &, const MnUserParameters &, const MnUserCovariance &, - const MnStrategy &, unsigned int maxfcn = 0, double toler = 0.1) const; - - virtual FunctionMinimum Minimize(const FCNBase &, const MnUserParameterState &, const MnStrategy &, - unsigned int maxfcn = 0, double toler = 0.1) const; - - // for Fumili - - // virtual FunctionMinimum Minimize(const FumiliFCNBase&, const std::vector&, const std::vector&, - // unsigned int stra=1, unsigned int maxfcn = 0, double toler = 0.1) const; - - // virtual FunctionMinimum Minimize(const FumiliFCNBase&, const MnUserParameters&, const MnStrategy&, unsigned int - // maxfcn = 0, double toler = 0.1) const; - - // virtual FunctionMinimum Minimize(const FumiliFCNBase&, const MnUserParameters&, const MnUserCovariance&, const - // MnStrategy&, unsigned int maxfcn = 0, double toler = 0.1) const; - - // virtual FunctionMinimum Minimize(const FumiliFCNBase&, const MnUserParameterState&, const MnStrategy&, unsigned - // int maxfcn = 0, double toler = 0.1) const; - virtual const MinimumSeedGenerator &SeedGenerator() const = 0; virtual const MinimumBuilder &Builder() const = 0; virtual MinimumBuilder &Builder() = 0; diff --git a/math/minuit2/src/MnHesse.cxx b/math/minuit2/src/MnHesse.cxx index f1054a7fb1cfc..0e1e5a6535afc 100644 --- a/math/minuit2/src/MnHesse.cxx +++ b/math/minuit2/src/MnHesse.cxx @@ -27,40 +27,6 @@ namespace ROOT { namespace Minuit2 { -MnUserParameterState MnHesse::operator()(const FCNBase &fcn, std::span par, - std::span err, unsigned int maxcalls) const -{ - // interface from vector of params and errors - return (*this)(fcn, MnUserParameterState(par, err), maxcalls); -} - -MnUserParameterState MnHesse::operator()(const FCNBase &fcn, std::span par, unsigned int nrow, - std::span cov, unsigned int maxcalls) const -{ - // interface from vector of params and covariance - return (*this)(fcn, MnUserParameterState(par, cov, nrow), maxcalls); -} - -MnUserParameterState MnHesse::operator()(const FCNBase &fcn, std::span par, - const MnUserCovariance &cov, unsigned int maxcalls) const -{ - // interface from vector of params and covariance - return (*this)(fcn, MnUserParameterState(par, cov), maxcalls); -} - -MnUserParameterState MnHesse::operator()(const FCNBase &fcn, const MnUserParameters &par, unsigned int maxcalls) const -{ - // interface from MnUserParameters - return (*this)(fcn, MnUserParameterState(par), maxcalls); -} - -MnUserParameterState MnHesse::operator()(const FCNBase &fcn, const MnUserParameters &par, const MnUserCovariance &cov, - unsigned int maxcalls) const -{ - // interface from MnUserParameters and MnUserCovariance - return (*this)(fcn, MnUserParameterState(par, cov), maxcalls); -} - MnUserParameterState MnHesse::operator()(const FCNBase &fcn, const MnUserParameterState &state, unsigned int maxcalls) const { diff --git a/math/minuit2/src/ModularFunctionMinimizer.cxx b/math/minuit2/src/ModularFunctionMinimizer.cxx index 41c4c8c13a9bd..91e7457d2f197 100644 --- a/math/minuit2/src/ModularFunctionMinimizer.cxx +++ b/math/minuit2/src/ModularFunctionMinimizer.cxx @@ -31,50 +31,6 @@ namespace ROOT { namespace Minuit2 { -// #include "Minuit2/MnUserParametersPrint.h" - -FunctionMinimum ModularFunctionMinimizer::Minimize(const FCNBase &fcn, std::span par, - std::span err, unsigned int stra, - unsigned int maxfcn, double toler) const -{ - // minimize from FCNBase and std::vector of double's for parameter values and errors (step sizes) - MnUserParameterState st(par, err); - MnStrategy strategy(stra); - return Minimize(fcn, st, strategy, maxfcn, toler); -} - -// move nrow before cov to avoid ambiguities when using default parameters -FunctionMinimum ModularFunctionMinimizer::Minimize(const FCNBase &fcn, std::span par, - unsigned int nrow, std::span cov, unsigned int stra, - unsigned int maxfcn, double toler) const -{ - // minimize from FCNBase using std::vector for parameter error and - // an std::vector of size n*(n+1)/2 for the covariance matrix and n (rank of cov matrix) - - MnUserParameterState st(par, cov, nrow); - MnStrategy strategy(stra); - return Minimize(fcn, st, strategy, maxfcn, toler); -} - -FunctionMinimum ModularFunctionMinimizer::Minimize(const FCNBase &fcn, const MnUserParameters &upar, - const MnStrategy &strategy, unsigned int maxfcn, double toler) const -{ - // minimize from FCNBase and MnUserParameters object - - MnUserParameterState st(upar); - return Minimize(fcn, st, strategy, maxfcn, toler); -} - -FunctionMinimum ModularFunctionMinimizer::Minimize(const FCNBase &fcn, const MnUserParameters &upar, - const MnUserCovariance &cov, const MnStrategy &strategy, - unsigned int maxfcn, double toler) const -{ - // minimize from FCNBase and MnUserParameters and MnUserCovariance objects - - MnUserParameterState st(upar, cov); - return Minimize(fcn, st, strategy, maxfcn, toler); -} - FunctionMinimum ModularFunctionMinimizer::Minimize(const FCNBase &fcn, const MnUserParameterState &st, const MnStrategy &strategy, unsigned int maxfcn, double toler) const { diff --git a/math/minuit2/test/MnSim/DemoGaussSim.cxx b/math/minuit2/test/MnSim/DemoGaussSim.cxx index c846a99bd8917..262d1ac12a12f 100644 --- a/math/minuit2/test/MnSim/DemoGaussSim.cxx +++ b/math/minuit2/test/MnSim/DemoGaussSim.cxx @@ -72,7 +72,7 @@ int main() VariableMetricMinimizer fMinimizer; // Minimize - FunctionMinimum min = fMinimizer.Minimize(fFCN, init_par, init_err); + FunctionMinimum min = fMinimizer.Minimize(fFCN, {init_par, init_err}); // output std::cout << "minimum: " << min << std::endl; diff --git a/math/minuit2/test/MnSim/ParallelTest.cxx b/math/minuit2/test/MnSim/ParallelTest.cxx index 99e53206ea54f..7646bb87f5f7c 100644 --- a/math/minuit2/test/MnSim/ParallelTest.cxx +++ b/math/minuit2/test/MnSim/ParallelTest.cxx @@ -114,7 +114,7 @@ int doFit(int ndim, int ndata) VariableMetricMinimizer fMinimizer; // Minimize - FunctionMinimum min = fMinimizer.Minimize(fcn, init_par, init_err); + FunctionMinimum min = fMinimizer.Minimize(fcn, {init_par, init_err}); // output std::cout << "minimum: " << min << std::endl; diff --git a/math/minuit2/test/MnSim/PaulTest3.cxx b/math/minuit2/test/MnSim/PaulTest3.cxx index 5efcb50bfe3aa..3c5e8b596bb89 100644 --- a/math/minuit2/test/MnSim/PaulTest3.cxx +++ b/math/minuit2/test/MnSim/PaulTest3.cxx @@ -125,7 +125,7 @@ int main() if (!min.IsValid()) { // try with higher strategy std::cout << "FM is invalid, try with strategy = 2." << std::endl; - MnMigrad migrad2(fFCN, upar, 2); + MnMigrad migrad2(fFCN, upar, MnStrategy{2}); min = migrad2(); } std::cout << "minimum: " << min << std::endl; diff --git a/math/minuit2/test/MnSim/PaulTest4.cxx b/math/minuit2/test/MnSim/PaulTest4.cxx index 34518114016ec..d177296a5f9be 100644 --- a/math/minuit2/test/MnSim/PaulTest4.cxx +++ b/math/minuit2/test/MnSim/PaulTest4.cxx @@ -152,7 +152,7 @@ int main() if (!min.IsValid()) { // try with higher strategy std::cout << "FM is invalid, try with strategy = 2." << std::endl; - MnMigrad migrad2(fFCN, upar, 2); + MnMigrad migrad2(fFCN, upar, MnStrategy{2}); min = migrad2(); } std::cout << "minimum: " << min << std::endl; @@ -172,7 +172,7 @@ int main() if (!min.IsValid()) { // try with higher strategy std::cout << "FM is invalid, try with strategy = 2." << std::endl; - MnMigrad migrad2(fFCN, upar, 2); + MnMigrad migrad2(fFCN, upar, MnStrategy{2}); min = migrad2(); } std::cout << "minimum: " << min << std::endl; @@ -193,9 +193,9 @@ int main() SimplexMinimizer simplex; std::cout << "start simplex" << std::endl; - FunctionMinimum min = simplex.Minimize(chi2, par, err); + FunctionMinimum min = simplex.Minimize(chi2, {par, err}); std::cout << "minimum: " << min << std::endl; - FunctionMinimum min2 = simplex.Minimize(mlh, par, err); + FunctionMinimum min2 = simplex.Minimize(mlh, {par, err}); std::cout << "minimum: " << min2 << std::endl; } return 0; diff --git a/math/minuit2/test/MnSim/ReneTest.cxx b/math/minuit2/test/MnSim/ReneTest.cxx index 4e3af8ba3eefb..e06a719075dba 100644 --- a/math/minuit2/test/MnSim/ReneTest.cxx +++ b/math/minuit2/test/MnSim/ReneTest.cxx @@ -190,7 +190,7 @@ int main() { std::vector params(6, 1.); std::vector Error(6, 1.); - MnScan scan(fFCN, params, Error); + MnScan scan(fFCN, {params, Error}); std::cout << "scan parameters: " << scan.Parameters() << std::endl; MnPlot plot; for (unsigned int i = 0; i < upar.VariableParameters(); i++) { @@ -204,7 +204,7 @@ int main() { std::vector params(6, 1.); std::vector Error(6, 1.); - MnScan scan(fFCN, params, Error); + MnScan scan(fFCN, {params, Error}); std::cout << "scan parameters: " << scan.Parameters() << std::endl; FunctionMinimum min2 = scan(); // std::cout< par(1, 1.); std::vector err(1, 0.1); VariableMetricMinimizer mini; - FunctionMinimum min = mini.Minimize(fcn, par, err); + FunctionMinimum min = mini.Minimize(fcn, {par, err}); std::cout << "min= " << min << std::endl; } { @@ -45,7 +45,7 @@ int main() std::vector par(1, 1.); std::vector err(1, 0.1); VariableMetricMinimizer mini; - FunctionMinimum min = mini.Minimize(fcn, par, err); + FunctionMinimum min = mini.Minimize(fcn, {par, err}); MnMinos Minos(fcn, min); std::pair e0 = Minos(0); std::cout << "par0: " << min.UserState().Value(unsigned(0)) << " " << e0.first << " " << e0.second diff --git a/math/minuit2/test/testADMinim.cxx b/math/minuit2/test/testADMinim.cxx index 1f2c1401bcc91..fb2c51b921602 100644 --- a/math/minuit2/test/testADMinim.cxx +++ b/math/minuit2/test/testADMinim.cxx @@ -55,8 +55,6 @@ void RosenBrock(Int_t &, Double_t *, Double_t &f, Double_t *par, Int_t /*iflag*/ class RosenBrockFunction : public ROOT::Math::IMultiGenFunction { public: - ~RosenBrockFunction() override {} - unsigned int NDim() const override { return 2; } ROOT::Math::IMultiGenFunction *Clone() const override { return new RosenBrockFunction(); } diff --git a/math/minuit2/test/testMinimizer.cxx b/math/minuit2/test/testMinimizer.cxx index eb3d6517e3430..350df12d960cc 100644 --- a/math/minuit2/test/testMinimizer.cxx +++ b/math/minuit2/test/testMinimizer.cxx @@ -50,8 +50,6 @@ void RosenBrock(Int_t &, Double_t *, Double_t &f, Double_t *par, Int_t /*iflag*/ class RosenBrockFunction : public ROOT::Math::IMultiGenFunction { public: - ~RosenBrockFunction() override {} - unsigned int NDim() const override { return 2; } ROOT::Math::IMultiGenFunction *Clone() const override { return new RosenBrockFunction(); }