53 _nset(
"nset",
"nset",this,false,false),
54 _func(
"function",
"function",this,func),
57 if (_order<0 || _order>3 ) {
58 throw std::runtime_error(
Form(
"RooDerivative::ctor(%s) ERROR, derivation order must be 1,2 or 3",
name)) ;
77 _nset(
"nset",this,other._nset),
78 _func(
"function",this,other._func),
93 _rd = std::make_unique<ROOT::Math::RichardsonDerivator>(wf,
_eps,
true);
99 double valMin = xVar.
getMin();
100 double valMax = xVar.getMax();
101 bool isCloseLo = val - valMin <
_eps;
102 bool isCloseHi = valMax - val <
_eps;
105 if (isCloseLo && isCloseHi) {
106 std::stringstream errMsg;
107 errMsg <<
"error in numerical derivator: 2 * epsilon is larger than the variable range!";
108 coutE(Eval) << errMsg.str() << std::endl;
109 throw std::runtime_error(errMsg.str());
113 if (isCloseLo || isCloseHi) {
118 return isCloseLo ?
_rd->DerivativeForward(val) :
_rd->DerivativeBackward(val);
122 const double eps = std::numeric_limits<double>::epsilon();
123 const double yval1 =
_ftor->eval(val);
125 if (std::abs(yval2 - yval1) <=
eps) {
130 std::stringstream errMsg;
131 errMsg <<
"error in numerical derivator: variable value is to close to limits to compute finite differences";
132 coutE(Eval) << errMsg.str() << std::endl;
133 throw std::runtime_error(errMsg.str());
137 case 1:
return _rd->Derivative1(val);
138 case 2:
return _rd->Derivative2(val);
139 case 3:
return _rd->Derivative3(val);
char * Form(const char *fmt,...)
Formats a string in a circular formatting buffer.
Template class to wrap any C++ callable object which takes one argument i.e.
Abstract container object that can hold multiple RooAbsArg objects.
virtual double getMin(const char *name=nullptr) const
Get minimum of currently defined range.
Abstract base class for objects that represent a real value and implements functionality common to al...
bool redirectServersHook(const RooAbsCollection &newServerList, bool mustReplaceAll, bool nameChange, bool isRecursiveStep) override
Function that is called at the end of redirectServers().
RooFunctor * functor(const RooArgList &obs, const RooArgList &pars=RooArgList(), const RooArgSet &nset=RooArgSet()) const
Return a RooFunctor object bound to this RooAbsReal with given definition of observables and paramete...
RooArgSet is a container object that can hold multiple RooAbsArg objects.
bool add(const RooAbsArg &var, bool valueServer, bool shapeServer, bool silent)
Overloaded RooCollection_t::add() method insert object into set and registers object as server to own...
Represents the first, second, or third order derivative of any RooAbsReal as calculated (numerically)...
std::unique_ptr< ROOT::Math::RichardsonDerivator > _rd
! Derivator
~RooDerivative() override
RooDerivative()
Default constructor.
std::unique_ptr< RooFunctor > _ftor
! Functor binding of RooAbsReal
RooSetProxy _nset
Normalization set (optional)
bool redirectServersHook(const RooAbsCollection &, bool, bool, bool) override
Zap functor and derivator ;.
Int_t _order
Derivation order.
double evaluate() const override
Calculate value.
RooRealProxy _func
Input function.
RooRealProxy _x
Observable.
Variable that can be changed from the outside.
const T & arg() const
Return reference to object held in proxy.