TMinuitMinimizer class: ROOT::Math::Minimizer implementation based on TMinuit.
Definition at line 51 of file TMinuitMinimizer.h.
Public Member Functions | |
TMinuitMinimizer (const char *type, unsigned int ndim=0) | |
Constructor from a char * (used by PM) | |
TMinuitMinimizer (ROOT::Minuit::EMinimizerType type=ROOT::Minuit::kMigrad, unsigned int ndim=0) | |
Default constructor. | |
~TMinuitMinimizer () override | |
Destructor (no operations) | |
bool | Contour (unsigned int i, unsigned int j, unsigned int &npoints, double *xi, double *xj) override |
find the contour points (xi,xj) of the function for parameter i and j around the minimum The contour will be find for value of the function = Min + ErrorUp(); | |
double | CovMatrix (unsigned int i, unsigned int j) const override |
return covariance matrices elements if the variable is fixed the matrix is zero The ordering of the variables is the same as in errors | |
int | CovMatrixStatus () const override |
return status of covariance matrix | |
double | Edm () const override |
return expected distance reached from the minimum | |
const double * | Errors () const override |
return errors at the minimum | |
bool | FixVariable (unsigned int) override |
fix an existing variable | |
bool | GetCovMatrix (double *cov) const override |
Fill the passed array with the covariance matrix elements if the variable is fixed or const the value is zero. | |
bool | GetHessianMatrix (double *h) const override |
Fill the passed array with the Hessian matrix elements The Hessian matrix is the matrix of the second derivatives and is the inverse of the covariance matrix If the variable is fixed or const the values for that variables are zero. | |
bool | GetMinosError (unsigned int i, double &errLow, double &errUp, int=0) override |
minos error for variable i, return false if Minos failed | |
bool | GetVariableSettings (unsigned int, ROOT::Fit::ParameterSettings &) const override |
get variable settings in a variable object (like ROOT::Fit::ParamsSettings) | |
double | GlobalCC (unsigned int) const override |
global correlation coefficient for variable i | |
bool | Hesse () override |
perform a full calculation of the Hessian matrix for error calculation | |
virtual TClass * | IsA () const |
bool | IsFixedVariable (unsigned int) const override |
query if an existing variable is fixed (i.e. | |
const double * | MinGradient () const override |
return pointer to gradient values at the minimum | |
bool | Minimize () override |
method to perform the minimization | |
int | MinosStatus () const override |
minos status code of last Minos run minos status = -1 : Minos is not run = 0 : last MINOS run was successful > 0 : some problems encountered when running MINOS | |
double | MinValue () const override |
return minimum function value | |
unsigned int | NCalls () const override |
number of function calls to reach the minimum | |
unsigned int | NDim () const override |
this is <= Function().NDim() which is the total number of variables (free+ constrained ones) | |
unsigned int | NFree () const override |
number of free variables (real dimension of the problem) this is <= Function().NDim() which is the total | |
void | PrintResults () override |
return reference to the objective function virtual const ROOT::Math::IGenFunction & Function() const = 0; | |
bool | ProvidesError () const override |
minimizer provides error and error matrix | |
bool | ReleaseVariable (unsigned int) override |
release an existing variable | |
bool | Scan (unsigned int i, unsigned int &nstep, double *x, double *y, double xmin=0, double xmax=0) override |
scan a parameter i around the minimum. | |
bool | SetDebug (bool on=true) |
set debug mode. Return true if setting was successful | |
bool | SetFixedVariable (unsigned int, const std::string &, double) override |
set fixed variable (override if minimizer supports them ) | |
void | SetFunction (const ROOT::Math::IMultiGenFunction &func) override |
set the function to minimize | |
bool | SetLimitedVariable (unsigned int ivar, const std::string &name, double val, double step, double, double) override |
set upper/lower limited variable (override if minimizer supports them ) | |
bool | SetLowerLimitedVariable (unsigned int ivar, const std::string &name, double val, double step, double lower) override |
set lower limit variable (override if minimizer supports them ) | |
bool | SetUpperLimitedVariable (unsigned int ivar, const std::string &name, double val, double step, double upper) override |
set upper limit variable (override if minimizer supports them ) | |
bool | SetVariable (unsigned int ivar, const std::string &name, double val, double step) override |
set free variable | |
bool | SetVariableLimits (unsigned int ivar, double lower, double upper) override |
set the limits of an existing variable | |
bool | SetVariableLowerLimit (unsigned int, double) override |
set the lower-limit of an existing variable | |
bool | SetVariableStepSize (unsigned int, double) override |
set the step size of an existing variable | |
bool | SetVariableUpperLimit (unsigned int, double) override |
set the upper-limit of an existing variable | |
bool | SetVariableValue (unsigned int, double) override |
set the value of an existing variable | |
virtual void | Streamer (TBuffer &) |
void | StreamerNVirtual (TBuffer &ClassDef_StreamerNVirtual_b) |
void | SuppressMinuitWarnings (bool nowarn=true) |
suppress the minuit warnings (if called with false will enable them) By default they are suppressed only when the printlevel is <= 0 | |
int | VariableIndex (const std::string &name) const override |
get index of variable given a variable given a name return always -1 . | |
std::string | VariableName (unsigned int ivar) const override |
return reference to the objective function virtual const ROOT::Math::IGenFunction & Function() const; | |
const double * | X () const override |
return pointer to X values at the minimum | |
Public Member Functions inherited from ROOT::Math::Minimizer | |
Minimizer () | |
Default constructor. | |
Minimizer (Minimizer &&)=delete | |
Minimizer (Minimizer const &)=delete | |
virtual | ~Minimizer () |
Destructor (no operations). | |
virtual void | Clear () |
reset for consecutive minimization - implement if needed | |
virtual double | Correlation (unsigned int i, unsigned int j) const |
return correlation coefficient between variable i and j. | |
double | ErrorDef () const |
return the statistical scale used for calculate the error is typically 1 for Chi2 and 0.5 for likelihood minimization | |
bool | IsValidError () const |
return true if Minimizer has performed a detailed error validation (e.g. run Hesse for Minuit) | |
unsigned int | MaxFunctionCalls () const |
max number of function calls | |
unsigned int | MaxIterations () const |
max iterations | |
virtual unsigned int | NIterations () const |
number of iterations to reach the minimum | |
Minimizer & | operator= (Minimizer &&)=delete |
Minimizer & | operator= (Minimizer const &)=delete |
virtual MinimizerOptions | Options () const |
retrieve the minimizer options (implement derived class if needed) | |
double | Precision () const |
precision of minimizer in the evaluation of the objective function ( a value <=0 corresponds to the let the minimizer choose its default one) | |
int | PrintLevel () const |
minimizer configuration parameters | |
virtual bool | SetCovariance (std::span< const double > cov, unsigned int nrow) |
set initial covariance matrix | |
virtual bool | SetCovarianceDiag (std::span< const double > d2, unsigned int n) |
set initial second derivatives | |
void | SetDefaultOptions () |
reset the default options (defined in MinimizerOptions) | |
void | SetErrorDef (double up) |
set scale for calculating the errors | |
void | SetExtraOptions (const IOptions &extraOptions) |
set only the extra options | |
virtual void | SetHessianFunction (std::function< bool(std::span< const double >, double *)>) |
set the function implementing Hessian computation (re-implemented by Minimizer using it) | |
void | SetMaxFunctionCalls (unsigned int maxfcn) |
set maximum of function calls | |
void | SetMaxIterations (unsigned int maxiter) |
set maximum iterations (one iteration can have many function calls) | |
void | SetOptions (const MinimizerOptions &opt) |
set all options in one go | |
void | SetPrecision (double prec) |
set in the minimizer the objective function evaluation precision ( a value <=0 means the minimizer will choose its optimal value automatically, i.e. | |
void | SetPrintLevel (int level) |
set print level | |
void | SetStrategy (int strategyLevel) |
set the strategy | |
void | SetTolerance (double tol) |
set the tolerance | |
void | SetValidError (bool on) |
flag to check if minimizer needs to perform accurate error analysis (e.g. run Hesse for Minuit) | |
virtual bool | SetVariableInitialRange (unsigned int, double, double) |
set the initial range of an existing variable | |
template<class VariableIterator > | |
int | SetVariables (const VariableIterator &begin, const VariableIterator &end) |
add variables . Return number of variables successfully added | |
virtual bool | SetVariableValues (const double *x) |
set the values of all existing variables (array must be dimensioned to the size of the existing parameters) | |
int | Status () const |
status code of minimizer | |
int | Strategy () const |
strategy | |
double | Tolerance () const |
absolute tolerance | |
Static Public Member Functions | |
static TClass * | Class () |
static const char * | Class_Name () |
static constexpr Version_t | Class_Version () |
static const char * | DeclFileName () |
static bool | UseStaticMinuit (bool on=true) |
static function to switch on/off usage of static global TMinuit instance (gMinuit) By default it is used (i.e. | |
Protected Member Functions | |
bool | CheckMinuitInstance () const |
check TMinuit instance | |
bool | CheckVarIndex (unsigned int ivar) const |
check parameter | |
void | DoClear () |
reset | |
void | DoReleaseFixParameter (int ivar) |
release a parameter that is fixed when it is redefined | |
void | InitTMinuit (int ndim) |
initialize the TMinuit instance | |
void | RetrieveErrorMatrix () |
retrieve error matrix from TMinuit | |
void | RetrieveParams () |
retrieve minimum parameters and errors from TMinuit | |
Static Protected Member Functions | |
static void | Fcn (int &, double *, double &f, double *, int) |
implementation of FCN for Minuit | |
static void | FcnGrad (int &, double *g, double &f, double *, int) |
implementation of FCN for Minuit when user provided gradient is used | |
Private Attributes | |
std::vector< double > | fCovar |
unsigned int | fDim |
std::vector< double > | fErrors |
bool | fMinosRun |
int | fMinosStatus = -1 |
TMinuit * | fMinuit |
std::vector< double > | fParams |
ROOT::Minuit::EMinimizerType | fType |
bool | fUsed |
Static Private Attributes | |
static TMinuit * | fgMinuit = nullptr |
static bool | fgUsed = false |
static bool | fgUseStaticMinuit = true |
Additional Inherited Members | |
Protected Attributes inherited from ROOT::Math::Minimizer | |
MinimizerOptions | fOptions |
minimizer options | |
int | fStatus = -1 |
status of minimizer | |
bool | fValidError = false |
flag to control if errors have been validated (Hesse has been run in case of Minuit) | |
#include <TMinuitMinimizer.h>
TMinuitMinimizer::TMinuitMinimizer | ( | ROOT::Minuit::EMinimizerType | type = ROOT::Minuit::kMigrad , |
unsigned int | ndim = 0 |
||
) |
Default constructor.
Definition at line 57 of file TMinuitMinimizer.cxx.
TMinuitMinimizer::TMinuitMinimizer | ( | const char * | type, |
unsigned int | ndim = 0 |
||
) |
Constructor from a char * (used by PM)
Definition at line 73 of file TMinuitMinimizer.cxx.
|
override |
Destructor (no operations)
Definition at line 101 of file TMinuitMinimizer.cxx.
|
protected |
check TMinuit instance
Definition at line 290 of file TMinuitMinimizer.cxx.
check parameter
Definition at line 299 of file TMinuitMinimizer.cxx.
|
static |
|
inlinestaticconstexpr |
Definition at line 272 of file TMinuitMinimizer.h.
|
overridevirtual |
find the contour points (xi,xj) of the function for parameter i and j around the minimum The contour will be find for value of the function = Min + ErrorUp();
Reimplemented from ROOT::Math::Minimizer.
Definition at line 884 of file TMinuitMinimizer.cxx.
return covariance matrices elements if the variable is fixed the matrix is zero The ordering of the variables is the same as in errors
Reimplemented from ROOT::Math::Minimizer.
Definition at line 146 of file TMinuitMinimizer.h.
|
overridevirtual |
return status of covariance matrix
Reimplemented from ROOT::Math::Minimizer.
Definition at line 721 of file TMinuitMinimizer.cxx.
|
inlinestatic |
Definition at line 272 of file TMinuitMinimizer.h.
|
protected |
reset
Definition at line 826 of file TMinuitMinimizer.cxx.
|
protected |
release a parameter that is fixed when it is redefined
Definition at line 841 of file TMinuitMinimizer.cxx.
|
overridevirtual |
return expected distance reached from the minimum
Reimplemented from ROOT::Math::Minimizer.
Definition at line 654 of file TMinuitMinimizer.cxx.
|
inlineoverridevirtual |
return errors at the minimum
Reimplemented from ROOT::Math::Minimizer.
Definition at line 140 of file TMinuitMinimizer.h.
implementation of FCN for Minuit
Definition at line 224 of file TMinuitMinimizer.cxx.
|
staticprotected |
implementation of FCN for Minuit when user provided gradient is used
Definition at line 230 of file TMinuitMinimizer.cxx.
fix an existing variable
Reimplemented from ROOT::Math::Minimizer.
Definition at line 388 of file TMinuitMinimizer.cxx.
Fill the passed array with the covariance matrix elements if the variable is fixed or const the value is zero.
The array will be filled as cov[i *ndim + j] The ordering of the variables is the same as in errors and parameter value. This is different from the direct interface of Minuit2 or TMinuit where the values were obtained only to variable parameters
Reimplemented from ROOT::Math::Minimizer.
Definition at line 670 of file TMinuitMinimizer.cxx.
Fill the passed array with the Hessian matrix elements The Hessian matrix is the matrix of the second derivatives and is the inverse of the covariance matrix If the variable is fixed or const the values for that variables are zero.
The array will be filled as h[i *ndim + j]
Reimplemented from ROOT::Math::Minimizer.
Definition at line 682 of file TMinuitMinimizer.cxx.
|
overridevirtual |
minos error for variable i, return false if Minos failed
Reimplemented from ROOT::Math::Minimizer.
Definition at line 746 of file TMinuitMinimizer.cxx.
|
overridevirtual |
get variable settings in a variable object (like ROOT::Fit::ParamsSettings)
Reimplemented from ROOT::Math::Minimizer.
Definition at line 411 of file TMinuitMinimizer.cxx.
global correlation coefficient for variable i
Reimplemented from ROOT::Math::Minimizer.
Definition at line 734 of file TMinuitMinimizer.cxx.
|
overridevirtual |
perform a full calculation of the Hessian matrix for error calculation
Reimplemented from ROOT::Math::Minimizer.
Definition at line 1004 of file TMinuitMinimizer.cxx.
|
protected |
initialize the TMinuit instance
Definition at line 117 of file TMinuitMinimizer.cxx.
|
inlinevirtual |
Definition at line 272 of file TMinuitMinimizer.h.
query if an existing variable is fixed (i.e.
considered constant in the minimization) note that by default all variables are not fixed
Reimplemented from ROOT::Math::Minimizer.
Definition at line 404 of file TMinuitMinimizer.cxx.
|
inlineoverridevirtual |
return pointer to gradient values at the minimum
Reimplemented from ROOT::Math::Minimizer.
Definition at line 123 of file TMinuitMinimizer.h.
|
overridevirtual |
method to perform the minimization
Implements ROOT::Math::Minimizer.
Definition at line 440 of file TMinuitMinimizer.cxx.
|
inlineoverridevirtual |
minos status code of last Minos run minos status = -1 : Minos is not run = 0 : last MINOS run was successful > 0 : some problems encountered when running MINOS
Reimplemented from ROOT::Math::Minimizer.
Definition at line 182 of file TMinuitMinimizer.h.
|
overridevirtual |
return minimum function value
Implements ROOT::Math::Minimizer.
Definition at line 644 of file TMinuitMinimizer.cxx.
|
overridevirtual |
number of function calls to reach the minimum
Reimplemented from ROOT::Math::Minimizer.
Definition at line 638 of file TMinuitMinimizer.cxx.
|
inlineoverridevirtual |
this is <= Function().NDim() which is the total number of variables (free+ constrained ones)
Implements ROOT::Math::Minimizer.
Definition at line 130 of file TMinuitMinimizer.h.
|
overridevirtual |
number of free variables (real dimension of the problem) this is <= Function().NDim() which is the total
Reimplemented from ROOT::Math::Minimizer.
Definition at line 663 of file TMinuitMinimizer.cxx.
|
overridevirtual |
return reference to the objective function virtual const ROOT::Math::IGenFunction & Function() const = 0;
print the result according to set level (implemented for TMinuit for maintaining Minuit-style printing)
Reimplemented from ROOT::Math::Minimizer.
Definition at line 862 of file TMinuitMinimizer.cxx.
|
inlineoverridevirtual |
minimizer provides error and error matrix
Reimplemented from ROOT::Math::Minimizer.
Definition at line 137 of file TMinuitMinimizer.h.
release an existing variable
Reimplemented from ROOT::Math::Minimizer.
Definition at line 396 of file TMinuitMinimizer.cxx.
|
protected |
retrieve error matrix from TMinuit
Definition at line 601 of file TMinuitMinimizer.cxx.
|
protected |
retrieve minimum parameters and errors from TMinuit
Definition at line 587 of file TMinuitMinimizer.cxx.
|
overridevirtual |
scan a parameter i around the minimum.
A minimization must have been done before, return false if it is not the case
Reimplemented from ROOT::Math::Minimizer.
Definition at line 932 of file TMinuitMinimizer.cxx.
set debug mode. Return true if setting was successful
Definition at line 1049 of file TMinuitMinimizer.cxx.
|
overridevirtual |
set fixed variable (override if minimizer supports them )
Reimplemented from ROOT::Math::Minimizer.
Definition at line 309 of file TMinuitMinimizer.cxx.
|
overridevirtual |
set the function to minimize
Implements ROOT::Math::Minimizer.
Definition at line 192 of file TMinuitMinimizer.cxx.
|
overridevirtual |
set upper/lower limited variable (override if minimizer supports them )
Reimplemented from ROOT::Math::Minimizer.
Definition at line 259 of file TMinuitMinimizer.cxx.
|
overridevirtual |
set lower limit variable (override if minimizer supports them )
Reimplemented from ROOT::Math::Minimizer.
Definition at line 275 of file TMinuitMinimizer.cxx.
|
overridevirtual |
set upper limit variable (override if minimizer supports them )
Reimplemented from ROOT::Math::Minimizer.
Definition at line 282 of file TMinuitMinimizer.cxx.
|
overridevirtual |
set free variable
Implements ROOT::Math::Minimizer.
Definition at line 243 of file TMinuitMinimizer.cxx.
|
overridevirtual |
set the limits of an existing variable
Reimplemented from ROOT::Math::Minimizer.
Definition at line 371 of file TMinuitMinimizer.cxx.
set the lower-limit of an existing variable
Reimplemented from ROOT::Math::Minimizer.
Definition at line 358 of file TMinuitMinimizer.cxx.
set the step size of an existing variable
Reimplemented from ROOT::Math::Minimizer.
Definition at line 342 of file TMinuitMinimizer.cxx.
set the upper-limit of an existing variable
Reimplemented from ROOT::Math::Minimizer.
Definition at line 364 of file TMinuitMinimizer.cxx.
set the value of an existing variable
Reimplemented from ROOT::Math::Minimizer.
Definition at line 328 of file TMinuitMinimizer.cxx.
|
virtual |
|
inline |
Definition at line 272 of file TMinuitMinimizer.h.
void TMinuitMinimizer::SuppressMinuitWarnings | ( | bool | nowarn = true | ) |
suppress the minuit warnings (if called with false will enable them) By default they are suppressed only when the printlevel is <= 0
Definition at line 873 of file TMinuitMinimizer.cxx.
static function to switch on/off usage of static global TMinuit instance (gMinuit) By default it is used (i.e.
is on). Method returns the previous state
Definition at line 110 of file TMinuitMinimizer.cxx.
|
overridevirtual |
get index of variable given a variable given a name return always -1 .
(It is Not implemented)
Reimplemented from ROOT::Math::Minimizer.
Definition at line 434 of file TMinuitMinimizer.cxx.
|
overridevirtual |
return reference to the objective function virtual const ROOT::Math::IGenFunction & Function() const;
get name of variables (override if minimizer support storing of variable names)
Reimplemented from ROOT::Math::Minimizer.
Definition at line 427 of file TMinuitMinimizer.cxx.
|
inlineoverridevirtual |
return pointer to X values at the minimum
Implements ROOT::Math::Minimizer.
Definition at line 120 of file TMinuitMinimizer.h.
|
private |
Definition at line 262 of file TMinuitMinimizer.h.
|
private |
Definition at line 258 of file TMinuitMinimizer.h.
|
private |
Definition at line 261 of file TMinuitMinimizer.h.
|
staticprivate |
Definition at line 267 of file TMinuitMinimizer.h.
|
staticprivate |
Definition at line 269 of file TMinuitMinimizer.h.
|
staticprivate |
Definition at line 270 of file TMinuitMinimizer.h.
|
private |
Definition at line 257 of file TMinuitMinimizer.h.
|
private |
Definition at line 259 of file TMinuitMinimizer.h.
|
private |
Definition at line 265 of file TMinuitMinimizer.h.
|
private |
Definition at line 260 of file TMinuitMinimizer.h.
|
private |
Definition at line 264 of file TMinuitMinimizer.h.
|
private |
Definition at line 256 of file TMinuitMinimizer.h.