48 ClassImp(RooDerivative);
55 RooDerivative::RooDerivative() : _order(1), _eps(1e-7), _ftor(0), _rd(0)
63 RooDerivative::RooDerivative(
const char* name,
const char* title, RooAbsReal& func, RooRealVar& x, Int_t orderIn, Double_t epsIn) :
64 RooAbsReal(name, title),
67 _nset(
"nset",
"nset",this,kFALSE,kFALSE),
68 _func(
"function",
"function",this,func),
73 if (_order<0 || _order>3 ) {
74 throw std::string(Form(
"RooDerivative::ctor(%s) ERROR, derivation order must be 1,2 or 3",name)) ;
80 RooDerivative::RooDerivative(
const char* name,
const char* title, RooAbsReal& func, RooRealVar& x,
const RooArgSet& nset, Int_t orderIn, Double_t epsIn) :
81 RooAbsReal(name, title),
84 _nset(
"nset",
"nset",this,kFALSE,kFALSE),
85 _func(
"function",
"function",this,func),
90 if (_order<0 || _order>3) {
91 throw std::string(Form(
"RooDerivative::ctor(%s) ERROR, derivation order must be 1,2 or 3",name)) ;
100 RooDerivative::RooDerivative(
const RooDerivative& other,
const char* name) :
101 RooAbsReal(other, name),
102 _order(other._order),
104 _nset(
"nset",this,other._nset),
105 _func(
"function",this,other._func),
106 _x(
"x",this,other._x),
117 RooDerivative::~RooDerivative()
119 if (_rd)
delete _rd ;
120 if (_ftor)
delete _ftor ;
128 Double_t RooDerivative::evaluate()
const
131 _ftor = _func.arg().functor(_x.arg(),RooArgSet(),_nset) ;
132 ROOT::Math::WrappedFunction<RooFunctor&> wf(*_ftor);
133 _rd =
new ROOT::Math::RichardsonDerivator(wf,_eps*(_x.max()-_x.min()),kTRUE) ;
137 case 1:
return _rd->Derivative1(_x);
138 case 2:
return _rd->Derivative2(_x);
139 case 3:
return _rd->Derivative3(_x);
149 Bool_t RooDerivative::redirectServersHook(
const RooAbsCollection& , Bool_t , Bool_t , Bool_t )