Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Minuit2] Reduce boilerplate code by removing redundant overloads #16443

Merged
merged 2 commits into from
Sep 19, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions README/ReleaseNotes/v634/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -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<T>`. 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

Expand Down
1 change: 0 additions & 1 deletion math/minuit2/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
1 change: 0 additions & 1 deletion math/minuit2/inc/LinkDef.h
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
2 changes: 0 additions & 2 deletions math/minuit2/inc/Minuit2/ContoursError.h
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
2 changes: 0 additions & 2 deletions math/minuit2/inc/Minuit2/FumiliMinimizer.h
Original file line number Diff line number Diff line change
Expand Up @@ -60,8 +60,6 @@ class FumiliMinimizer : public ModularFunctionMinimizer {

FumiliMinimizer() : fMinSeedGen(MnSeedGenerator()), fMinBuilder(FumiliBuilder()) {}

~FumiliMinimizer() override {}

/**

Accessor to the seed generator of the minimizer.
Expand Down
55 changes: 0 additions & 55 deletions math/minuit2/inc/Minuit2/FunctionMinimizer.h

This file was deleted.

39 changes: 1 addition & 38 deletions math/minuit2/inc/Minuit2/MnFumiliMinimize.h
Original file line number Diff line number Diff line change
Expand Up @@ -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<const double> par, std::span<const double> 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<const double> par, unsigned int nrow,
std::span<const double> 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<const double> 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)
{
}
Expand All @@ -85,8 +50,6 @@ class MnFumiliMinimize : public MnApplication {
{
}

~MnFumiliMinimize() override {}

FumiliMinimizer &Minimizer() override { return fMinimizer; }
const FumiliMinimizer &Minimizer() const override { return fMinimizer; }

Expand Down
22 changes: 0 additions & 22 deletions math/minuit2/inc/Minuit2/MnHesse.h
Original file line number Diff line number Diff line change
Expand Up @@ -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<const double>, std::span<const double>,
unsigned int maxcalls = 0) const;
/// FCN + parameters + covariance
MnUserParameterState operator()(const FCNBase &, std::span<const double>, unsigned int nrow,
std::span<const double>, unsigned int maxcalls = 0) const;
/// FCN + parameters + MnUserCovariance
MnUserParameterState
operator()(const FCNBase &, std::span<const double>, 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;
///
Expand Down
38 changes: 2 additions & 36 deletions math/minuit2/inc/Minuit2/MnMigrad.h
Original file line number Diff line number Diff line change
Expand Up @@ -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<const double> par, std::span<const double> 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<const double> par, unsigned int nrow, std::span<const double> 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<const double> 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;

Expand Down
37 changes: 2 additions & 35 deletions math/minuit2/inc/Minuit2/MnMinimize.h
Original file line number Diff line number Diff line change
Expand Up @@ -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<const double> par, std::span<const double> 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<const double> par, unsigned int nrow, std::span<const double> 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<const double> 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())
{
}

Expand All @@ -72,8 +41,6 @@ class MnMinimize : public MnApplication {
{
}

~MnMinimize() override {}

ModularFunctionMinimizer &Minimizer() override { return fMinimizer; }
const ModularFunctionMinimizer &Minimizer() const override { return fMinimizer; }

Expand Down
2 changes: 0 additions & 2 deletions math/minuit2/inc/Minuit2/MnParameterScan.h
Original file line number Diff line number Diff line change
Expand Up @@ -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<std::pair<double, double>>
operator()(unsigned int par, unsigned int maxsteps = 41, double low = 0., double high = 0.);
Expand Down
36 changes: 1 addition & 35 deletions math/minuit2/inc/Minuit2/MnScan.h
Original file line number Diff line number Diff line change
Expand Up @@ -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<const double> par, std::span<const double> 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<const double> par, unsigned int nrow, std::span<const double> 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<const double> 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())
{
}
Expand All @@ -75,8 +44,6 @@ class MnScan : public MnApplication {
{
}

~MnScan() override {}

ModularFunctionMinimizer &Minimizer() override { return fMinimizer; }
const ModularFunctionMinimizer &Minimizer() const override { return fMinimizer; }

Expand All @@ -86,7 +53,6 @@ class MnScan : public MnApplication {
private:
ScanMinimizer fMinimizer;

private:
/// forbidden assignment (const FCNBase& = )
MnScan &operator=(const MnScan &) { return *this; }
};
Expand Down
35 changes: 1 addition & 34 deletions math/minuit2/inc/Minuit2/MnSimplex.h
Original file line number Diff line number Diff line change
Expand Up @@ -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<const double> par, std::span<const double> 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<const double> par, unsigned int nrow, std::span<const double> 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<const double> 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())
{
}
Expand All @@ -77,8 +46,6 @@ class MnSimplex : public MnApplication {
{
}

~MnSimplex() override {}

ModularFunctionMinimizer &Minimizer() override { return fMinimizer; }
const ModularFunctionMinimizer &Minimizer() const override { return fMinimizer; }

Expand Down
Loading
Loading