50 MnPrint print(
"MnSeedGenerator");
53 const unsigned int n =
st.VariableParameters();
56 print.
Info(
"Computing seed using NumericalGradient calculator");
58 print.
Debug(
n,
"free parameters, FCN pointer", &
fcn);
62 for (
unsigned int i = 0; i <
n; i++)
63 x(i) =
st.IntParameters()[i];
70 auto timingScope = std::make_unique<ROOT::Math::Util::TimingScope>([&print](std::string
const &s) { print.
Info(s); },
71 "Evaluated function and gradient in");
78 if (
st.HasCovariance()) {
79 for (
unsigned int i = 0; i <
n; i++) {
80 mat(i, i) =
st.IntCovariance()(i, i) >
prec.Eps() ?
st.IntCovariance()(i, i)
83 for (
unsigned int j = i + 1;
j <
n;
j++)
84 mat(i,
j) =
st.IntCovariance()(i,
j);
88 for (
unsigned int i = 0; i <
n; i++)
99 if (!
st.HasCovariance()) {
102 print.
Debug(
"Negative G2 Found",
"\n point:",
x,
"\n grad :",
dgrad.Grad(),
"\n g2 :",
dgrad.G2());
106 print.
Info(
"Negative G2 found - new state:", state);
110 if (
stra.Strategy() == 2 && !
st.HasCovariance()) {
113 print.
Debug(
"calling MnHesse");
117 print.
Info(
"run Hesse - Initial seeding state:", tmp);
122 print.
Info(
"Initial state ",state);
131 MnPrint print(
"MnSeedGenerator");
138 if (!
gc.CanComputeG2()) {
139 print.
Info(
"Using analytical (external) gradient calculator but cannot compute G2 - use then numerical gradient for G2");
146 if (
gc.CanComputeHessian())
147 print.
Info(
"Computing seed using analytical (external) gradients and Hessian calculator");
149 print.
Info(
"Computing seed using analytical (external) gradients and G2 calculator");
154 unsigned int n =
st.VariableParameters();
173 print.
Error(
"Cannot compute G2 and Hessian");
178 for (
unsigned int i = 0; i <
n; i++)
182 print.
Debug(
"Computed analytical G2",
g2);
190 print.
Info(
"Use full Hessian as seed");
192 print.
Debug(
"computed Error matrix (H^-1)",
mat);
199 if (
st.HasCovariance()) {
200 print.
Info(
"Using existing covariance matrix");
201 for (
unsigned int i = 0; i <
n; i++) {
202 mat(i, i) =
st.IntCovariance()(i, i) >
prec.Eps() ?
st.IntCovariance()(i, i)
203 : grad.
G2()(i) >
prec.Eps() ? 1. / grad.
G2()(i)
205 for (
unsigned int j = i + 1;
j <
n;
j++)
206 mat(i,
j) =
st.IntCovariance()(i,
j);
210 for (
unsigned int i = 0; i <
n; i++) {
212 mat(i, i) = grad.
G2()(i) >
prec.Eps() ? 1. / grad.
G2()(i) : 1.0;
217 print.
Info(
"Computing seed using full Hessian");
224 print.
Error(
"Cannot compute seed because G2 is not computed");
228 if (!
st.HasCovariance()) {
241 print.
Info(
"Compute full Hessian: Initial seeding state is ",
tmpState);
245 print.
Info(
"Initial seeding state ",state);
266 std::pair<FunctionGradient, MnAlgebraicVector>
hgrd =
hgc.DeltaGradient(
pa,
dgrad);
267 for (
unsigned int i = 0; i <
n; i++) {
268 if (std::fabs(
hgrd.first.Grad()(i) -
grd.Grad()(i)) >
hgrd.second(i)) {
271 print.Warn(
"Gradient discrepancy of external Parameter too large:"
278 print.Error(
"Minuit does not accept user specified Gradient. To force acceptance, override 'virtual bool "
279 "CheckGradient() const' of FCNGradientBase.h in the derived class.");
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
const MnAlgebraicVector & Grad() const
const MnAlgebraicVector & G2() const
interface class for gradient calculators
HessianGradientCalculator: class to calculate Gradient for Hessian.
Class to calculate an initial estimate of the gradient.
Class describing a symmetric matrix of size n.
MinimumError keeps the inv.
static MnAlgebraicSymMatrix InvertMatrix(const MnAlgebraicSymMatrix &matrix, int &ifail)
MinimumState keeps the information (position, Gradient, 2nd deriv, etc) after one minimization step (...
Wrapper class to FCNBase interface used internally by Minuit.
API class for calculating the numerical covariance matrix (== 2x Inverse Hessian == 2x Inverse 2nd de...
Sets the relative floating point (double) arithmetic precision.
void Debug(const Ts &... args)
void Error(const Ts &... args)
void Info(const Ts &... args)
MinimumSeed CallWithAnalyticalGradientCalculator(const MnFcn &, const AnalyticalGradientCalculator &, const MnUserParameterState &, const MnStrategy &) const
MinimumSeed operator()(const MnFcn &, const GradientCalculator &, const MnUserParameterState &, const MnStrategy &) const override
API class for defining four levels of strategies: low (0), medium (1), high (2), very high (>=3); act...
class which holds the external user and/or internal Minuit representation of the parameters and error...
In case that one of the components of the second derivative g2 calculated by the numerical Gradient c...
class performing the numerical gradient calculation
double Estimate(const FunctionGradient &, const MinimumError &) const
tbb::task_arena is an alias of tbb::interface7::task_arena, which doesn't allow to forward declare tb...