38 for (
unsigned int i = 0; i <
n; i++)
43 if (
fcn.HasGradient()) {
71 if (
st.Gradient().IsAnalytical()) {
73 if (
mfcn.Fcn().HasGradient() &&
mfcn.Fcn().HasHessian()) {
82 unsigned int n =
st.Parameters().Vec().size();
89 std::unique_ptr<AnalyticalGradientCalculator>
hc;
93 hc = std::make_unique<AnalyticalGradientCalculator>(
fcn,
trafo);
98 print.
Error(
"Error computing analytical Hessian. MnHesse fails and will return a null matrix");
103 for (
unsigned int i = 0; i <
n; i++)
120 print.
Warn(
"Matrix inversion fails; will return diagonal matrix");
123 for (
unsigned int j = 0;
j <
n;
j++) {
133 if (
tmpErr.IsMadePosDef()) {
135 double edm =
estim.Estimate(
gr, err);
142 double edm =
estim.Estimate(
gr, err);
144 print.
Debug(
"Hessian is ACCURATE. New state:",
"\n First derivative:",
st.Gradient().Grad(),
145 "\n Covariance matrix:",
vhmat,
"\n Edm:", edm);
165 unsigned int n =
st.Parameters().Vec().size();
178 if (
st.Gradient().IsAnalytical()) {
179 print.
Info(
"Using analytical gradient but a numerical Hessian calculator - it could be not optimal");
186 print.
Warn(
"Analytical calculator ",
grd,
" numerical ",tmp.Grad(),
" g2 ",
g2);
191 print.
Debug(
"Gradient is",
st.Gradient().IsAnalytical() ?
"analytical" :
"numerical",
"\n point:",
x,
192 "\n fcn :",
amin,
"\n grad :",
grd,
"\n step :",
gst,
"\n g2 :",
g2);
194 for (
unsigned int i = 0; i <
n; i++) {
198 double d = std::fabs(
gst(i));
202 print.
Debug(
"Derivative parameter", i,
"d =",
d,
"dmin =",
dmin);
221 if (
trafo.Parameter(i).HasLimits()) {
235 print.
Warn(
"2nd derivative zero for parameter",
trafo.Name(
trafo.ExtOfInt(i)),
236 "; MnHesse fails and will return diagonal matrix");
238 for (
unsigned int j = 0;
j <
n;
j++) {
239 double tmp =
g2(
j) <
prec.Eps2() ? 1. : 1. /
g2(
j);
254 d = std::sqrt(2. *
aimsag / std::fabs(
g2(i)));
255 if (
trafo.Parameter(i).HasLimits())
256 d = std::min(0.5,
d);
260 print.
Debug(
"g1 =",
grd(i),
"g2 =",
g2(i),
"step =",
gst(i),
"d =",
d,
"diffd =", std::fabs(
d -
dlast) /
d,
261 "diffg2 =", std::fabs(
g2(i) -
g2bfor) /
g2(i));
275 print.
Warn(
"Maximum number of allowed function calls exhausted; will return diagonal matrix");
277 for (
unsigned int j = 0;
j <
n;
j++) {
278 double tmp =
g2(
j) <
prec.Eps2() ? 1. : 1. /
g2(
j);
283 st.Edm(),
mfcn.NumOfCalls());
287 print.
Debug(
"Second derivatives",
g2);
363 print.
Warn(
"Matrix inversion fails; will return diagonal matrix");
366 for (
unsigned int j = 0;
j <
n;
j++) {
367 double tmp =
g2(
j) <
prec.Eps2() ? 1. : 1. /
g2(
j);
379 if (
tmpErr.IsMadePosDef()) {
381 double edm =
estim.Estimate(
gr, err);
387 double edm =
estim.Estimate(
gr, err);
389 print.
Debug(
"Hessian is ACCURATE. New state:",
"\n First derivative:",
grd,
"\n Second derivative:",
g2,
390 "\n Gradient step:",
gst,
"\n Covariance matrix:",
vhmat,
"\n Edm:", edm);
ROOT::Detail::TRangeCast< T, true > TRangeDynCast
TRangeDynCast is an adapter class that allows the typed iteration through a TCollection.
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void gc
Similar to the AnalyticalGradientCalculator, the ExternalInternalGradientCalculator supplies Minuit w...
Interface (abstract class) defining the function to be minimized, which has to be implemented by the ...
class holding the full result of the minimization; both internal and external (MnUserParameterState) ...
HessianGradientCalculator: class to calculate Gradient for Hessian.
Class describing a symmetric matrix of size n.
MinimumError keeps the inv.
MinimumState keeps the information (position, Gradient, 2nd deriv, etc) after one minimization step (...
Wrapper class to FCNBase interface used internally by Minuit.
MinimumState ComputeAnalytical(const FCNBase &, const MinimumState &, const MnUserTransformation &) const
internal function to compute the Hessian using an analytical computation or externally provided in th...
MnUserParameterState operator()(const FCNBase &, const MnUserParameterState &, unsigned int maxcalls=0) const
FCN + MnUserParameterState.
unsigned int Ncycles() const
forward interface of MnStrategy
MinimumState ComputeNumerical(const MnFcn &, const MinimumState &, const MnUserTransformation &, unsigned int maxcalls) const
internal function to compute the Hessian using numerical derivative computation
Sets the relative floating point (double) arithmetic precision.
Force the covariance matrix to be positive defined by adding extra terms in the diagonal.
void Debug(const Ts &... args)
void Error(const Ts &... args)
void Info(const Ts &... args)
void Warn(const Ts &... args)
unsigned int Strategy() const
unsigned int HessianCentralFDMixedDerivatives() const
unsigned int HessianForcePosDef() const
Wrapper used by Minuit of FCN interface containing a reference to the transformation object.
class which holds the external user and/or internal Minuit representation of the parameters and error...
unsigned int NFcn() const
unsigned int VariableParameters() const
const std::vector< double > & IntParameters() const
const MnUserTransformation & Trafo() const
class performing the numerical gradient calculation
int Invert(LASymMatrix &)
LASymMatrix MnAlgebraicSymMatrix
tbb::task_arena is an alias of tbb::interface7::task_arena, which doesn't allow to forward declare tb...