Logo ROOT   6.18/05
Reference Guide
RooDerivative.cxx
Go to the documentation of this file.
1/*****************************************************************************
2 * Project: RooFit *
3 * Package: RooFitCore *
4 * @(#)root/roofitcore:$Id$
5 * Authors: *
6 * WV, Wouter Verkerke, UC Santa Barbara, verkerke@slac.stanford.edu *
7 * DK, David Kirkby, UC Irvine, dkirkby@uci.edu *
8 * *
9 * Copyright (c) 2000-2005, Regents of the University of California *
10 * and Stanford University. All rights reserved. *
11 * *
12 * Redistribution and use in source and binary forms, *
13 * with or without modification, are permitted according to the terms *
14 * listed in LICENSE (http://roofit.sourceforge.net/license.txt) *
15 *****************************************************************************/
16
17/**
18\file RooDerivative.cxx
19\class RooDerivative
20\ingroup Roofitcore
21
22RooDerivative represents the first, second, or third order derivative
23of any RooAbsReal as calculated (numerically) by the MathCore Richardson
24derivator class.
25**/
26
27
28#include "RooFit.h"
29
30#include "Riostream.h"
31#include "Riostream.h"
32#include <math.h>
33
34#include "RooDerivative.h"
35#include "RooAbsReal.h"
36#include "RooAbsPdf.h"
37#include "RooErrorHandler.h"
38#include "RooArgSet.h"
39#include "RooMsgService.h"
40#include "RooRealVar.h"
41#include "RooFunctor.h"
42
45
46using namespace std;
47
49;
50
51
52////////////////////////////////////////////////////////////////////////////////
53/// Default constructor
54
55RooDerivative::RooDerivative() : _order(1), _eps(1e-7), _ftor(0), _rd(0)
56{
57}
58
59
60
61////////////////////////////////////////////////////////////////////////////////
62
63RooDerivative::RooDerivative(const char* name, const char* title, RooAbsReal& func, RooRealVar& x, Int_t orderIn, Double_t epsIn) :
64 RooAbsReal(name, title),
65 _order(orderIn),
66 _eps(epsIn),
67 _nset("nset","nset",this,kFALSE,kFALSE),
68 _func("function","function",this,func),
69 _x("x","x",this,x),
70 _ftor(0),
71 _rd(0)
72{
73 if (_order<0 || _order>3 ) {
74 throw std::string(Form("RooDerivative::ctor(%s) ERROR, derivation order must be 1,2 or 3",name)) ;
75 }
76}
77
78////////////////////////////////////////////////////////////////////////////////
79
80RooDerivative::RooDerivative(const char* name, const char* title, RooAbsReal& func, RooRealVar& x, const RooArgSet& nset, Int_t orderIn, Double_t epsIn) :
81 RooAbsReal(name, title),
82 _order(orderIn),
83 _eps(epsIn),
84 _nset("nset","nset",this,kFALSE,kFALSE),
85 _func("function","function",this,func),
86 _x("x","x",this,x),
87 _ftor(0),
88 _rd(0)
89{
90 if (_order<0 || _order>3) {
91 throw std::string(Form("RooDerivative::ctor(%s) ERROR, derivation order must be 1,2 or 3",name)) ;
92 }
93 _nset.add(nset) ;
94}
95
96
97
98////////////////////////////////////////////////////////////////////////////////
99
101 RooAbsReal(other, name),
102 _order(other._order),
103 _eps(other._eps),
104 _nset("nset",this,other._nset),
105 _func("function",this,other._func),
106 _x("x",this,other._x),
107 _ftor(0),
108 _rd(0)
109{
110}
111
112
113
114////////////////////////////////////////////////////////////////////////////////
115/// Destructor
116
118{
119 if (_rd) delete _rd ;
120 if (_ftor) delete _ftor ;
121}
122
123
124
125////////////////////////////////////////////////////////////////////////////////
126/// Calculate value
127
129{
130 if (!_ftor) {
134 }
135
136 switch (_order) {
137 case 1: return _rd->Derivative1(_x);
138 case 2: return _rd->Derivative2(_x);
139 case 3: return _rd->Derivative3(_x);
140 }
141 return 0 ;
142}
143
144
145
146////////////////////////////////////////////////////////////////////////////////
147/// Zap functor and derivator ;
148
149Bool_t RooDerivative::redirectServersHook(const RooAbsCollection& /*newServerList*/, Bool_t /*mustReplaceAll*/, Bool_t /*nameChange*/, Bool_t /*isRecursive*/)
150{
151 delete _ftor ;
152 delete _rd ;
153 _ftor = 0 ;
154 _rd = 0 ;
155 return kFALSE ;
156}
#define e(i)
Definition: RSha256.hxx:103
int Int_t
Definition: RtypesCore.h:41
const Bool_t kFALSE
Definition: RtypesCore.h:88
bool Bool_t
Definition: RtypesCore.h:59
double Double_t
Definition: RtypesCore.h:55
const Bool_t kTRUE
Definition: RtypesCore.h:87
#define ClassImp(name)
Definition: Rtypes.h:365
char name[80]
Definition: TGX11.cxx:109
char * Form(const char *fmt,...)
User class for calculating the derivatives of a function.
double Derivative2(double x)
Returns the second derivative of the function at point x, computed by Richardson's extrapolation meth...
double Derivative3(double x)
Returns the third derivative of the function at point x, computed by Richardson's extrapolation metho...
double Derivative1(double x)
Returns the first derivative of the function at point x, computed by Richardson's extrapolation metho...
Template class to wrap any C++ callable object which takes one argument i.e.
RooAbsCollection is an abstract container object that can hold multiple RooAbsArg objects.
RooAbsReal is the common abstract base class for objects that represent a real value and implements f...
Definition: RooAbsReal.h:53
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.
Definition: RooArgSet.h:28
RooDerivative represents the first, second, or third order derivative of any RooAbsReal as calculated...
Definition: RooDerivative.h:31
virtual ~RooDerivative()
Destructor.
Double_t _eps
Definition: RooDerivative.h:51
ROOT::Math::RichardsonDerivator * _rd
Functor binding of RooAbsReal.
Definition: RooDerivative.h:56
RooFunctor * _ftor
Definition: RooDerivative.h:55
Double_t evaluate() const
Derivator
RooDerivative()
Default constructor.
RooSetProxy _nset
Definition: RooDerivative.h:52
Bool_t redirectServersHook(const RooAbsCollection &, Bool_t, Bool_t, Bool_t)
Zap functor and derivator ;.
RooRealProxy _func
Definition: RooDerivative.h:53
RooRealProxy _x
Definition: RooDerivative.h:54
Double_t min(const char *rname=0) const
Definition: RooRealProxy.h:56
const RooAbsReal & arg() const
Definition: RooRealProxy.h:43
Double_t max(const char *rname=0) const
Definition: RooRealProxy.h:57
RooRealVar represents a fundamental (non-derived) real valued object.
Definition: RooRealVar.h:36
virtual Bool_t add(const RooAbsArg &var, Bool_t silent=kFALSE)
Overloaded RooArgSet::add() method inserts 'var' into set and registers 'var' as server to owner with...
Double_t x[n]
Definition: legend1.C:17