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 a new upper/lower limited variable (override if minimizer supports them ) otherwise as default set an unlimited
14/// variable
15bool Minimizer::SetLimitedVariable(unsigned int ivar, const std::string &name, double val, double step, double lower,
16 double upper)
17{
18 MATH_WARN_MSG("Minimizer::SetLimitedVariable", "Setting of limited variable not implemented - set as unlimited");
19 MATH_UNUSED(lower);
20 MATH_UNUSED(upper);
21 return SetVariable(ivar, name, val, step);
22}
23
24/// set a new fixed variable (override if minimizer supports them )
25bool Minimizer::SetFixedVariable(unsigned int ivar, const std::string &name, double val)
26{
27 MATH_ERROR_MSG("Minimizer::SetFixedVariable", "Setting of fixed variable not implemented");
28 MATH_UNUSED(ivar);
30 MATH_UNUSED(val);
31 return false;
32}
33/// set the value of an already existing variable
34bool Minimizer::SetVariableValue(unsigned int ivar, double value)
35{
36 MATH_ERROR_MSG("Minimizer::SetVariableValue", "Set of a variable value not implemented");
37 MATH_UNUSED(ivar);
39 return false;
40}
41
42/// set the step size of an already existing variable
43bool Minimizer::SetVariableStepSize(unsigned int ivar, double value)
44{
45 MATH_ERROR_MSG("Minimizer::SetVariableStepSize", "Setting an existing variable step size not implemented");
46 MATH_UNUSED(ivar);
48 return false;
49}
50/// set the lower-limit of an already existing variable
51bool Minimizer::SetVariableLowerLimit(unsigned int ivar, double lower)
52{
53 MATH_ERROR_MSG("Minimizer::SetVariableLowerLimit", "Setting an existing variable limit not implemented");
54 MATH_UNUSED(ivar);
55 MATH_UNUSED(lower);
56 return false;
57}
58/// set the upper-limit of an already existing variable
59bool Minimizer::SetVariableUpperLimit(unsigned int ivar, double upper)
60{
61 MATH_ERROR_MSG("Minimizer::SetVariableUpperLimit", "Setting an existing variable limit not implemented");
62 MATH_UNUSED(ivar);
63 MATH_UNUSED(upper);
64 return false;
65}
66
67/// fix an existing variable
68bool Minimizer::FixVariable(unsigned int ivar)
69{
70 MATH_ERROR_MSG("Minimizer::FixVariable", "Fixing an existing variable not implemented");
71 MATH_UNUSED(ivar);
72 return false;
73}
74/// release an existing variable
75bool Minimizer::ReleaseVariable(unsigned int ivar)
76{
77 MATH_ERROR_MSG("Minimizer::ReleaseVariable", "Releasing an existing variable not implemented");
78 MATH_UNUSED(ivar);
79 return false;
80}
81/// query if an existing variable is fixed (i.e. considered constant in the minimization)
82/// note that by default all variables are not fixed
83bool Minimizer::IsFixedVariable(unsigned int ivar) const
84{
85 MATH_ERROR_MSG("Minimizer::IsFixedVariable", "Querying an existing variable not implemented");
86 MATH_UNUSED(ivar);
87 return false;
88}
89/// get variable settings in a variable object (like ROOT::Fit::ParamsSettings)
91{
92 MATH_ERROR_MSG("Minimizer::GetVariableSettings", "Querying an existing variable not implemented");
93 MATH_UNUSED(ivar);
94 MATH_UNUSED(pars);
95 return false;
96}
97/** return covariance matrices element for variables ivar,jvar
98 if the variable is fixed the return value is zero
99 The ordering of the variables is the same as in the parameter and errors vectors
100*/
101double Minimizer::CovMatrix(unsigned int ivar, unsigned int jvar) const
102{
103 MATH_UNUSED(ivar);
104 MATH_UNUSED(jvar);
105 return 0;
106}
107
108/**
109 Fill the passed array with the covariance matrix elements
110 if the variable is fixed or const the value is zero.
111 The array will be filled as cov[i *ndim + j]
112 The ordering of the variables is the same as in errors and parameter value.
113 This is different from the direct interface of Minuit2 or TMinuit where the
114 values were obtained only to variable parameters
115*/
116bool Minimizer::GetCovMatrix(double *covMat) const
117{
118 MATH_UNUSED(covMat);
119 return false;
120}
121
122/**
123 Fill the passed array with the Hessian matrix elements
124 The Hessian matrix is the matrix of the second derivatives
125 and is the inverse of the covariance matrix
126 If the variable is fixed or const the values for that variables are zero.
127 The array will be filled as h[i *ndim + j]
128*/
129bool Minimizer::GetHessianMatrix(double *hMat) const
130{
131 MATH_UNUSED(hMat);
132 return false;
133}
134
135/**
136 return global correlation coefficient for variable i
137 This is a number between zero and one which gives
138 the correlation between the i-th parameter and that linear combination of all
139 other parameters which is most strongly correlated with i.
140 Minimizer must overload method if implemented
141 */
142double Minimizer::GlobalCC(unsigned int ivar) const
143{
144 MATH_UNUSED(ivar);
145 return -1;
146}
147
148/**
149 minos error for variable i, return false if Minos failed or not supported
150 and the lower and upper errors are returned in errLow and errUp
151 An extra flag specifies if only the lower (option=-1) or the upper (option=+1) error calculation is run
152*/
153bool Minimizer::GetMinosError(unsigned int ivar, double &errLow, double &errUp, int option)
154{
155 MATH_ERROR_MSG("Minimizer::GetMinosError", "Minos Error not implemented");
156 MATH_UNUSED(ivar);
157 MATH_UNUSED(errLow);
158 MATH_UNUSED(errUp);
160 return false;
161}
162
163/**
164 perform a full calculation of the Hessian matrix for error calculation
165 */
167{
168 MATH_ERROR_MSG("Minimizer::Hesse", "Hesse not implemented");
169 return false;
170}
171
172/**
173 scan function minimum for variable i. Variable and function must be set before using Scan
174 Return false if an error or if minimizer does not support this functionality
175 */
176bool Minimizer::Scan(unsigned int ivar, unsigned int &nstep, double *x, double *y, double xmin, double xmax)
177{
178 MATH_ERROR_MSG("Minimizer::Scan", "Scan not implemented");
179 MATH_UNUSED(ivar);
180 MATH_UNUSED(nstep);
181 MATH_UNUSED(x);
182 MATH_UNUSED(y);
185 return false;
186}
187
188/**
189 find the contour points (xi, xj) of the function for parameter ivar and jvar around the minimum
190 The contour will be find for value of the function = Min + ErrorUp();
191 */
192bool Minimizer::Contour(unsigned int ivar, unsigned int jvar, unsigned int &npoints, double *xi, double *xj)
193{
194 MATH_ERROR_MSG("Minimizer::Contour", "Contour not implemented");
195 MATH_UNUSED(ivar);
196 MATH_UNUSED(jvar);
197 MATH_UNUSED(npoints);
198 MATH_UNUSED(xi);
199 MATH_UNUSED(xj);
200 return false;
201}
202
203/// get name of variables (override if minimizer support storing of variable names)
204/// return an empty string if variable is not found
205std::string Minimizer::VariableName(unsigned int ivar) const
206{
207 MATH_UNUSED(ivar);
208 return std::string(); // return empty string
209}
210
211/// get index of variable given a variable given a name
212/// return -1 if variable is not found
213int Minimizer::VariableIndex(const std::string &name) const
214{
215 MATH_ERROR_MSG("Minimizer::VariableIndex", "Getting variable index from name not implemented");
217 return -1;
218}
219
220} // namespace Math
221} // 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:15
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:43
virtual bool GetVariableSettings(unsigned int ivar, ROOT::Fit::ParameterSettings &pars) const
get variable settings in a variable object (like ROOT::Fit::ParamsSettings)
Definition Minimizer.cxx:90
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:34
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:59
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:68
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:25
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:51
virtual bool IsFixedVariable(unsigned int ivar) const
query if an existing variable is fixed (i.e.
Definition Minimizer.cxx:83
virtual bool ReleaseVariable(unsigned int ivar)
release an existing variable
Definition Minimizer.cxx:75
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
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...