41 : fAlwaysExactlyMimicMinuit2(always_exactly_mimic_minuit2)
46 double error_level,
bool always_exactly_mimic_minuit2)
47 : fStepTolerance(step_tolerance), fGradTolerance(grad_tolerance), fUp(error_level), fNCycles(ncycles),
48 fAlwaysExactlyMimicMinuit2(always_exactly_mimic_minuit2)
58 const std::vector<ROOT::Fit::ParameterSettings> ¶meters)
60 assert(
function !=
nullptr &&
"function is a nullptr");
68 for (
unsigned i = 0; i <
function->NDim(); i++) {
83 const std::vector<ROOT::Fit::ParameterSettings> ¶meters,
92 const std::vector<ROOT::Fit::ParameterSettings> ¶meters,
97 double xtf =
fVx[i_component];
101 for (
unsigned int j = 0; j <
fNCycles; ++j) {
102 double optstp = std::sqrt(
fDfmin / (std::abs(deriv.second_derivative) + epspri));
103 double step = std::max(optstp, std::abs(0.1 * deriv.step_size));
105 if (parameters[i_component].IsBound()) {
110 double stpmax = 10. * std::abs(deriv.step_size);
120 deriv.step_size = step;
122 fVx[i_component] = xtf + step;
126 fVx[i_component] = xtf - step;
130 fVx[i_component] = xtf;
133 double fGrd_old = deriv.derivative;
134 deriv.derivative = 0.5 * (fs1 - fs2) / step;
136 deriv.second_derivative = (fs1 + fs2 - 2. *
fVal) / step / step;
138 if (std::abs(fGrd_old - deriv.derivative) / (std::abs(deriv.derivative) +
fDfmin / step) <
fGradTolerance) {
146 const std::vector<ROOT::Fit::ParameterSettings> ¶meters,
152std::vector<DerivatorElement>
154 const std::vector<ROOT::Fit::ParameterSettings> ¶meters,
155 const std::vector<DerivatorElement> &previous_gradient)
159 std::vector<DerivatorElement> gradient;
162 for (
unsigned int ix = 0; ix <
function->NDim(); ++ix) {
225 const std::vector<ROOT::Fit::ParameterSettings> ¶meters,
226 std::vector<DerivatorElement> &gradient)
234 for (
auto parameter = parameters.begin(); parameter != parameters.end(); ++parameter, ++ix) {
236 double werr = parameter->StepSize();
240 double extParVal = parameter->Value();
243 double var =
Ext2int(*parameter, extParVal);
247 extParVal =
Int2ext(*parameter, var);
250 double extParVal2 = extParVal + werr;
252 if (parameter->HasUpperLimit() && extParVal2 > parameter->UpperLimit()) {
253 extParVal2 = parameter->UpperLimit();
256 double var2 =
Ext2int(*parameter, extParVal2);
257 double vplu = var2 - var;
259 extParVal2 = extParVal - werr;
261 if (parameter->HasLowerLimit() && extParVal2 < parameter->LowerLimit()) {
262 extParVal2 = parameter->LowerLimit();
265 var2 =
Ext2int(*parameter, extParVal2);
266 double vmin = var2 - var;
267 double gsmin = 8. * eps2 * (std::abs(var) + eps2);
269 double dirin = std::max(0.5 * (std::abs(vplu) + std::abs(vmin)), gsmin);
270 double g2 = 2.0 *
fUp / (dirin * dirin);
271 double gstep = std::max(gsmin, 0.1 * dirin);
272 double grd = g2 * dirin;
274 if (parameter->IsBound()) {
275 gstep = std::min(gstep, 0.5);
278 gradient[ix].derivative = grd;
279 gradient[ix].second_derivative = g2;
280 gradient[ix].step_size = gstep;
286 return out <<
"(derivative: " <<
value.derivative <<
", second_derivative: " <<
value.second_derivative
287 <<
", step_size: " <<
value.step_size <<
")";
TBuffer & operator<<(TBuffer &buf, const Tmpl *obj)
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void value
Class, describing value, limits and step size of the parameters Provides functionality also to set/re...
bool HasUpperLimit() const
check if parameter has upper limit
double LowerLimit() const
return lower limit value
bool HasLowerLimit() const
check if parameter has lower limit
double UpperLimit() const
return upper limit value
bool IsDoubleBound() const
check if is double bound (upper AND lower limit)
bool IsBound() const
check if is bound
double Eps() const
eps returns the smallest possible number so that 1.+eps > 1.
double Eps2() const
eps2 returns 2*sqrt(eps)
DerivatorElement operator()(const ROOT::Math::IBaseFunctionMultiDim *function, const double *x, const std::vector< ROOT::Fit::ParameterSettings > ¶meters, unsigned int i_component, const DerivatorElement &previous)
std::vector< double > fVxFValCache
bool fAlwaysExactlyMimicMinuit2
double Int2ext(const ROOT::Fit::ParameterSettings ¶meter, double val) const
ROOT::Minuit2::SqrtUpParameterTransformation fUpperLimTrafo
ROOT::Minuit2::MnMachinePrecision fPrecision
DerivatorElement PartialDerivative(const ROOT::Math::IBaseFunctionMultiDim *function, const double *x, const std::vector< ROOT::Fit::ParameterSettings > ¶meters, unsigned int i_component, DerivatorElement previous)
void SetupDifferentiate(const ROOT::Math::IBaseFunctionMultiDim *function, const double *cx, const std::vector< ROOT::Fit::ParameterSettings > ¶meters)
This function sets internal state based on input parameters.
void SetInitialGradient(const ROOT::Math::IBaseFunctionMultiDim *function, const std::vector< ROOT::Fit::ParameterSettings > ¶meters, std::vector< DerivatorElement > &gradient)
This function was not implemented as in Minuit2.
NumericalDerivator(bool always_exactly_mimic_minuit2=true)
double DInt2Ext(const ROOT::Fit::ParameterSettings ¶meter, double val) const
double Ext2int(const ROOT::Fit::ParameterSettings ¶meter, double val) const
std::vector< double > fVx
ROOT::Minuit2::SinParameterTransformation fDoubleLimTrafo
DerivatorElement FastPartialDerivative(const ROOT::Math::IBaseFunctionMultiDim *function, const std::vector< ROOT::Fit::ParameterSettings > ¶meters, unsigned int i_component, const DerivatorElement &previous)
ROOT::Minuit2::SqrtLowParameterTransformation fLowerLimTrafo
std::vector< double > fVxExternal
std::vector< DerivatorElement > Differentiate(const ROOT::Math::IBaseFunctionMultiDim *function, const double *x, const std::vector< ROOT::Fit::ParameterSettings > ¶meters, const std::vector< DerivatorElement > &previous_gradient)
tbb::task_arena is an alias of tbb::interface7::task_arena, which doesn't allow to forward declare tb...