Logo ROOT  
Reference Guide
 
Loading...
Searching...
No Matches
Minimizer.cxx
Go to the documentation of this file.
1/*
2 * Copyright (c) 2023, CERN
3 */
4
5#include <Math/Minimizer.h>
6
7#include <Math/Error.h>
8#include <Math/Util.h>
9
10namespace ROOT {
11namespace Math {
12
13/** set initial second derivatives
14 */
15bool Minimizer::SetCovarianceDiag(std::span<const double> g2, unsigned int n)
16{
19 return false;
20}
21
22/** set initial values for covariance/error matrix
23 The covariance matrix must be provided in compressed form (row-major ordered upper traingular part)
24*/
25bool Minimizer::SetCovariance(std::span<const double> cov, unsigned int nrow)
26{
29 return false;
30}
31
32/// set a new upper/lower limited variable (override if minimizer supports them ) otherwise as default set an unlimited
33/// variable
34bool Minimizer::SetLimitedVariable(unsigned int ivar, const std::string &name, double val, double step, double lower,
35 double upper)
36{
37 MATH_WARN_MSG("Minimizer::SetLimitedVariable", "Setting of limited variable not implemented - set as unlimited");
40 return SetVariable(ivar, name, val, step);
41}
42
43/// set a new fixed variable (override if minimizer supports them )
44bool Minimizer::SetFixedVariable(unsigned int ivar, const std::string &name, double val)
45{
46 MATH_ERROR_MSG("Minimizer::SetFixedVariable", "Setting of fixed variable not implemented");
49 MATH_UNUSED(val);
50 return false;
51}
52/// set the value of an already existing variable
53bool Minimizer::SetVariableValue(unsigned int ivar, double value)
54{
55 MATH_ERROR_MSG("Minimizer::SetVariableValue", "Set of a variable value not implemented");
58 return false;
59}
60
61/// set the step size of an already existing variable
62bool Minimizer::SetVariableStepSize(unsigned int ivar, double value)
63{
64 MATH_ERROR_MSG("Minimizer::SetVariableStepSize", "Setting an existing variable step size not implemented");
67 return false;
68}
69/// set the lower-limit of an already existing variable
71{
72 MATH_ERROR_MSG("Minimizer::SetVariableLowerLimit", "Setting an existing variable limit not implemented");
75 return false;
76}
77/// set the upper-limit of an already existing variable
79{
80 MATH_ERROR_MSG("Minimizer::SetVariableUpperLimit", "Setting an existing variable limit not implemented");
83 return false;
84}
85
86/// fix an existing variable
87bool Minimizer::FixVariable(unsigned int ivar)
88{
89 MATH_ERROR_MSG("Minimizer::FixVariable", "Fixing an existing variable not implemented");
91 return false;
92}
93/// release an existing variable
95{
96 MATH_ERROR_MSG("Minimizer::ReleaseVariable", "Releasing an existing variable not implemented");
98 return false;
99}
100/// query if an existing variable is fixed (i.e. considered constant in the minimization)
101/// note that by default all variables are not fixed
102bool Minimizer::IsFixedVariable(unsigned int ivar) const
103{
104 MATH_ERROR_MSG("Minimizer::IsFixedVariable", "Querying an existing variable not implemented");
106 return false;
107}
108/// get variable settings in a variable object (like ROOT::Fit::ParamsSettings)
110{
111 MATH_ERROR_MSG("Minimizer::GetVariableSettings", "Querying an existing variable not implemented");
113 MATH_UNUSED(pars);
114 return false;
115}
116/** return covariance matrices element for variables ivar,jvar
117 if the variable is fixed the return value is zero
118 The ordering of the variables is the same as in the parameter and errors vectors
119*/
120double Minimizer::CovMatrix(unsigned int ivar, unsigned int jvar) const
121{
124 return 0;
125}
126
127/**
128 Fill the passed array with the covariance matrix elements
129 if the variable is fixed or const the value is zero.
130 The array will be filled as cov[i *ndim + j]
131 The ordering of the variables is the same as in errors and parameter value.
132 This is different from the direct interface of Minuit2 or TMinuit where the
133 values were obtained only to variable parameters
134*/
136{
138 return false;
139}
140
141/**
142 Fill the passed array with the Hessian matrix elements
143 The Hessian matrix is the matrix of the second derivatives
144 and is the inverse of the covariance matrix
145 If the variable is fixed or const the values for that variables are zero.
146 The array will be filled as h[i *ndim + j]
147*/
149{
151 return false;
152}
153
154/**
155 return global correlation coefficient for variable i
156 This is a number between zero and one which gives
157 the correlation between the i-th parameter and that linear combination of all
158 other parameters which is most strongly correlated with i.
159 Minimizer must overload method if implemented
160 */
161double Minimizer::GlobalCC(unsigned int ivar) const
162{
164 return -1;
165}
166
167/**
168 minos error for variable i, return false if Minos failed or not supported
169 and the lower and upper errors are returned in errLow and errUp
170 An extra flag specifies if only the lower (option=-1) or the upper (option=+1) error calculation is run
171*/
172bool Minimizer::GetMinosError(unsigned int ivar, double &errLow, double &errUp, int option)
173{
174 MATH_ERROR_MSG("Minimizer::GetMinosError", "Minos Error not implemented");
179 return false;
180}
181
182/**
183 perform a full calculation of the Hessian matrix for error calculation
184 */
186{
187 MATH_ERROR_MSG("Minimizer::Hesse", "Hesse not implemented");
188 return false;
189}
190
191/**
192 scan function minimum for variable i. Variable and function must be set before using Scan
193 Return false if an error or if minimizer does not support this functionality
194 */
195bool Minimizer::Scan(unsigned int ivar, unsigned int &nstep, double *x, double *y, double xmin, double xmax)
196{
197 MATH_ERROR_MSG("Minimizer::Scan", "Scan not implemented");
200 MATH_UNUSED(x);
201 MATH_UNUSED(y);
204 return false;
205}
206
207/**
208 find the contour points (xi, xj) of the function for parameter ivar and jvar around the minimum
209 The contour will be find for value of the function = Min + ErrorUp();
210 */
211bool Minimizer::Contour(unsigned int ivar, unsigned int jvar, unsigned int &npoints, double *xi, double *xj)
212{
213 MATH_ERROR_MSG("Minimizer::Contour", "Contour not implemented");
217 MATH_UNUSED(xi);
219 return false;
220}
221
222/// get name of variables (override if minimizer support storing of variable names)
223/// return an empty string if variable is not found
224std::string Minimizer::VariableName(unsigned int ivar) const
225{
227 return std::string(); // return empty string
228}
229
230/// get index of variable given a variable given a name
231/// return -1 if variable is not found
232int Minimizer::VariableIndex(const std::string &name) const
233{
234 MATH_ERROR_MSG("Minimizer::VariableIndex", "Getting variable index from name not implemented");
236 return -1;
237}
238
239} // namespace Math
240} // namespace ROOT
#define MATH_ERROR_MSG(loc, str)
Definition Error.h:83
#define MATH_WARN_MSG(loc, str)
Definition Error.h:80
Option_t Option_t option
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void value
char name[80]
Definition TGX11.cxx:110
float xmin
float xmax
#define MATH_UNUSED(var)
Definition Util.h:34
Class, describing value, limits and step size of the parameters Provides functionality also to set/re...
virtual bool SetLimitedVariable(unsigned int ivar, const std::string &name, double val, double step, double lower, double upper)
set a new upper/lower limited variable (override if minimizer supports them ) otherwise as default se...
Definition Minimizer.cxx:34
virtual int VariableIndex(const std::string &name) const
get index of variable given a variable given a name return -1 if variable is not found
virtual bool GetCovMatrix(double *covMat) const
Fill the passed array with the covariance matrix elements if the variable is fixed or const the value...
virtual bool SetVariableStepSize(unsigned int ivar, double value)
set the step size of an already existing variable
Definition Minimizer.cxx:62
virtual bool SetCovarianceDiag(std::span< const double > d2, unsigned int n)
set initial second derivatives
Definition Minimizer.cxx:15
virtual bool GetVariableSettings(unsigned int ivar, ROOT::Fit::ParameterSettings &pars) const
get variable settings in a variable object (like ROOT::Fit::ParamsSettings)
virtual double GlobalCC(unsigned int ivar) const
return global correlation coefficient for variable i This is a number between zero and one which give...
virtual bool SetVariableValue(unsigned int ivar, double value)
set the value of an already existing variable
Definition Minimizer.cxx:53
virtual bool Scan(unsigned int ivar, unsigned int &nstep, double *x, double *y, double xmin=0, double xmax=0)
scan function minimum for variable i.
virtual bool SetVariableUpperLimit(unsigned int ivar, double upper)
set the upper-limit of an already existing variable
Definition Minimizer.cxx:78
virtual bool SetCovariance(std::span< const double > cov, unsigned int nrow)
set initial covariance matrix
Definition Minimizer.cxx:25
virtual std::string VariableName(unsigned int ivar) const
get name of variables (override if minimizer support storing of variable names) return an empty strin...
virtual double CovMatrix(unsigned int ivar, unsigned int jvar) const
return covariance matrices element for variables ivar,jvar if the variable is fixed the return value ...
virtual bool GetHessianMatrix(double *hMat) const
Fill the passed array with the Hessian matrix elements The Hessian matrix is the matrix of the second...
virtual bool SetVariable(unsigned int ivar, const std::string &name, double val, double step)=0
set a new free variable
virtual bool FixVariable(unsigned int ivar)
fix an existing variable
Definition Minimizer.cxx:87
virtual bool SetFixedVariable(unsigned int ivar, const std::string &name, double val)
set a new fixed variable (override if minimizer supports them )
Definition Minimizer.cxx:44
virtual bool GetMinosError(unsigned int ivar, double &errLow, double &errUp, int option=0)
minos error for variable i, return false if Minos failed or not supported and the lower and upper err...
virtual bool SetVariableLowerLimit(unsigned int ivar, double lower)
set the lower-limit of an already existing variable
Definition Minimizer.cxx:70
virtual bool IsFixedVariable(unsigned int ivar) const
query if an existing variable is fixed (i.e.
virtual bool ReleaseVariable(unsigned int ivar)
release an existing variable
Definition Minimizer.cxx:94
virtual bool Hesse()
perform a full calculation of the Hessian matrix for error calculation
virtual bool Contour(unsigned int ivar, unsigned int jvar, unsigned int &npoints, double *xi, double *xj)
find the contour points (xi, xj) of the function for parameter ivar and jvar around the minimum The c...
Double_t y[n]
Definition legend1.C:17
Double_t x[n]
Definition legend1.C:17
const Int_t n
Definition legend1.C:16
Namespace for new Math classes and functions.
tbb::task_arena is an alias of tbb::interface7::task_arena, which doesn't allow to forward declare tb...