25 double DerivPrecision(
double eps)
27 static double gEPs = 0.001;
33 TF1 *CopyTF1Ptr(
const TF1 *funcToCopy)
35 TF1 *fnew = (TF1 *) funcToCopy->IsA()->New();
36 funcToCopy->Copy(*fnew);
41 WrappedTF1::WrappedTF1(TF1 &f) :
52 if (fFunc->GetMethodCall()) fFunc->InitArgs(fX, 0);
54 if (fFunc->GetNumber() >= 300 && fFunc->GetNumber() < 310) {
59 if (fFunc->IsLinear()) {
62 while (fLinear && ip < fFunc->GetNpar()) {
63 fLinear &= (fFunc->GetLinearPart(ip) != 0) ;
69 WrappedTF1::WrappedTF1(
const WrappedTF1 &rhs) :
74 fPolynomial(rhs.fPolynomial),
80 fFunc->InitArgs(fX, 0);
83 WrappedTF1 &WrappedTF1::operator = (
const WrappedTF1 &rhs)
86 if (
this == &rhs)
return *
this;
87 fLinear = rhs.fLinear;
88 fPolynomial = rhs.fPolynomial;
90 fFunc->InitArgs(fX, 0);
95 void WrappedTF1::ParameterGradient(
double x,
const double *par,
double *grad)
const
100 fFunc->SetParameters(par);
102 fFunc->GradientPar(&x, grad, GetDerivPrecision());
104 unsigned int np = NPar();
105 for (
unsigned int i = 0; i < np; ++i)
106 grad[i] = DoParameterDerivative(x, par, i);
110 double WrappedTF1::DoDerivative(
double x)
const
116 return fFunc->Derivative(x, (
double *) 0, GetDerivPrecision());
119 double WrappedTF1::DoParameterDerivative(
double x,
const double *p,
unsigned int ipar)
const
127 fFunc->SetParameters(p);
128 return fFunc->GradientPar(ipar, &x, GetDerivPrecision());
129 }
else if (fPolynomial) {
131 return std::pow(x, static_cast<int>(ipar));
134 const TFormula *df =
dynamic_cast<const TFormula *
>(fFunc->GetLinearPart(ipar));
138 return (const_cast<TFormula *>(df))->Eval(x) ;
142 void WrappedTF1::SetDerivPrecision(
double eps)
144 ::ROOT::Math::Internal::DerivPrecision(eps);
147 double WrappedTF1::GetDerivPrecision()
149 return ::ROOT::Math::Internal::DerivPrecision(-1);