29 const std::vector<double> &err,
unsigned int maxcalls)
const
36 const std::vector<double> &cov,
unsigned int maxcalls)
const
70 for (
unsigned int i = 0; i <
n; i++)
72 double amin = mfcn(
x);
78 state.
Trafo(), maxcalls);
102 double amin = mfcn(st.
Vec());
103 double aimsag = std::sqrt(prec.
Eps2()) * (std::fabs(amin) + mfcn.
Up());
109 maxcalls = 200 + 100 *
n + 5 *
n *
n;
131 "\n fcn :", amin,
"\n grad :", grd,
"\n step :", gst,
"\n g2 :", g2);
133 for (
unsigned int i = 0; i <
n; i++) {
136 double dmin = 8. * prec.
Eps2() * (std::fabs(xtf) + prec.
Eps2());
137 double d = std::fabs(gst(i));
141 print.
Debug(
"Derivative parameter", i,
"d =",
d,
"dmin =", dmin);
143 for (
unsigned int icyc = 0; icyc <
Ncycles(); icyc++) {
147 for (
unsigned int multpy = 0; multpy < 5; multpy++) {
153 sag = 0.5 * (fs1 + fs2 - 2. * amin);
155 print.
Debug(
"cycle", icyc,
"mul", multpy,
"\tsag =", sag,
"d =",
d);
174 print.
Warn(
"2nd derivative zero for parameter", trafo.
Name(trafo.
ExtOfInt(i)),
175 "; MnHesse fails and will return diagonal matrix");
177 for (
unsigned int j = 0; j <
n; j++) {
178 double tmp = g2(j) < prec.
Eps2() ? 1. : 1. / g2(j);
179 vhmat(j, j) = tmp < prec.
Eps2() ? 1. : tmp;
186 double g2bfor = g2(i);
187 g2(i) = 2. * sag / (
d *
d);
188 grd(i) = (fs1 - fs2) / (2. *
d);
193 d = std::sqrt(2. * aimsag / std::fabs(g2(i)));
195 d = std::min(0.5,
d);
199 print.
Debug(
"g1 =", grd(i),
"g2 =", g2(i),
"step =", gst(i),
"d =",
d,
"diffd =", std::fabs(
d - dlast) /
d,
200 "diffg2 =", std::fabs(g2(i) - g2bfor) / g2(i));
205 if (std::fabs((g2(i) - g2bfor) / g2(i)) <
TolerG2())
207 d = std::min(
d, 10. * dlast);
208 d = std::max(
d, 0.1 * dlast);
214 print.
Warn(
"Maximum number of allowed function calls exhausted; will return diagonal matrix");
216 for (
unsigned int j = 0; j <
n; j++) {
217 double tmp = g2(j) < prec.
Eps2() ? 1. : 1. / g2(j);
218 vhmat(j, j) = tmp < prec.
Eps2() ? 1. : tmp;
226 print.
Debug(
"Second derivatives", g2);
242 unsigned int endParIndexOffDiagonal = mpiprocOffDiagonal.
EndElementIndex();
244 unsigned int offsetVect = 0;
245 for (
unsigned int in = 0; in < startParIndexOffDiagonal; in++)
246 if ((in + offsetVect) % (
n - 1) == 0)
247 offsetVect += (in + offsetVect) / (
n - 1);
249 for (
unsigned int in = startParIndexOffDiagonal; in < endParIndexOffDiagonal; in++) {
251 int i = (in + offsetVect) / (
n - 1);
252 if ((in + offsetVect) % (
n - 1) == 0)
254 int j = (in + offsetVect) % (
n - 1) + 1;
256 if ((i + 1) == j || in == startParIndexOffDiagonal)
261 double fs1 = mfcn(
x);
262 double elem = (fs1 + amin - yy(i) - yy(j)) / (dirin(i) * dirin(j));
267 if (j % (
n - 1) == 0 || in == endParIndexOffDiagonal - 1)
276 print.
Debug(
"Original error matrix", vhmat);
281 print.
Debug(
"PosDef error matrix", vhmat);
283 int ifail =
Invert(vhmat);
286 print.
Warn(
"Matrix inversion fails; will return diagonal matrix");
289 for (
unsigned int j = 0; j <
n; j++) {
290 double tmp = g2(j) < prec.
Eps2() ? 1. : 1. / g2(j);
291 tmpsym(j, j) = tmp < prec.
Eps2() ? 1. : tmp;
312 print.
Debug(
"Hessian is ACCURATE. New state:",
"\n First derivative:", grd,
"\n Second derivative:", g2,
313 "\n Gradient step:", gst,
"\n Covariance matrix:", vhmat,
"\n Edm:", edm);
Interface (abstract class) defining the function to be minimized, which has to be implemented by the ...
virtual double Up() const =0
Error definition of the function.
bool IsAnalytical() const
const MnAlgebraicVector & Gstep() const
const MnAlgebraicVector & Grad() const
const MnAlgebraicVector & G2() const
class holding the full result of the minimization; both internal and external (MnUserParameterState) ...
void Add(const MinimumState &state)
const MnUserParameterState & UserState() const
const MinimumState & State() const
HessianGradientCalculator: class to calculate Gradient for Hessian.
Class describing a symmetric matrix of size n.
unsigned int Nrow() const
unsigned int size() const
unsigned int StartElementIndex() const
bool SyncSymMatrixOffDiagonal(ROOT::Minuit2::MnAlgebraicSymMatrix &mnmatrix)
unsigned int EndElementIndex() const
MinimumError keeps the inv.
const MnAlgebraicSymMatrix & InvHessian() const
bool IsMadePosDef() const
const MnAlgebraicVector & Vec() const
MinimumState keeps the information (position, Gradient, 2nd deriv, etc) after one minimization step (...
const MnAlgebraicVector & Vec() const
const MinimumParameters & Parameters() const
const FunctionGradient & Gradient() const
Wrapper class to FCNBase interface used internally by Minuit.
unsigned int NumOfCalls() const
unsigned int Ncycles() const
forward interface of MnStrategy
MnUserParameterState operator()(const FCNBase &, const std::vector< double > &, const std::vector< double > &, unsigned int maxcalls=0) const
low-level API
Sets the relative floating point (double) arithmetic precision.
double Eps2() const
eps2 returns 2*sqrt(eps)
Force the covariance matrix to be positive defined by adding extra terms in the diagonal.
void Debug(const Ts &... args)
void Warn(const Ts &... args)
unsigned int Strategy() const
Class containing the covariance matrix data represented as a vector of size n*(n+1)/2 Used to hide in...
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
API class for the user interaction with the parameters; serves as input to the minimizer as well as o...
class performing the numerical gradient calculation
double Estimate(const FunctionGradient &, const MinimumError &) const
int Invert(LASymMatrix &)
LASymMatrix MnAlgebraicSymMatrix
tbb::task_arena is an alias of tbb::interface7::task_arena, which doesn't allow to forward declare tb...