13 #ifndef ROOCFUNCTION4BINDING 14 #define ROOCFUNCTION4BINDING 41 template<
class VO,
class VI1,
class VI2,
class VI3,
class VI4>
46 void add(
const char* name, VO (*ptr)(VI1,VI2,VI3,VI4),
const char* arg1name=
"x",
const char* arg2name=
"y",
47 const char* arg3name=
"z",
const char* arg4name=
"w") {
50 _namemap[ptr] =
name ;
51 _argnamemap[ptr].push_back(arg1name) ;
52 _argnamemap[ptr].push_back(arg2name) ;
53 _argnamemap[ptr].push_back(arg3name) ;
54 _argnamemap[ptr].push_back(arg4name) ;
60 return _namemap[ptr].c_str() ;
63 VO (*
lookupPtr(
const char* name))(VI1,VI2,VI3,VI4) {
65 return _ptrmap[
name] ;
71 if (iarg<_argnamemap[ptr].size()) {
72 return (_argnamemap[ptr])[iarg].c_str() ;
86 std::map<std::string,VO (*)(VI1,VI2,VI3,VI4)>
_ptrmap ;
87 std::map<VO (*)(VI1,VI2,VI3,VI4),std::string>
_namemap ;
88 std::map<VO (*)(VI1,VI2,VI3,VI4),std::vector<std::string> >
_argnamemap ;
94 template<
class VO,
class VI1,
class VI2,
class VI3,
class VI4>
104 return (*_ptr)(
x,
y,z,w) ;
111 const char*
result = fmap().lookupName(_ptr) ;
112 if (result && strlen(result)) {
120 temp._funcptr = _ptr;
121 return Form(
"(%p)",temp._ptr) ;
126 return fmap().lookupArgName(_ptr,iarg) ;
145 typedef VO (*func_t)(VI1,VI2,VI3,VI4);
155 template<
class VO,
class VI1,
class VI2,
class VI3,
class VI4>
167 typedef ::RooCFunction4Ref<VO,VI1,VI2,VI3,VI4> thisClass;
177 tmpName.Streamer(R__b) ;
179 if (tmpName==
"UNKNOWN" && R__v>0) {
181 coutW(
ObjectHandling) <<
"WARNING: Objected embeds function pointer to unknown function, object will not be functional" << std::endl ;
182 _ptr = dummyFunction ;
187 _ptr = fmap().lookupPtr(tmpName.
Data()) ;
191 <<
" but no such function is registered, object will not be functional" << std::endl ;
204 TString tmpName = fmap().lookupName(_ptr) ;
205 if (tmpName.
Length()==0) {
207 <<
" written object will not be functional when read back" << std::endl ;
212 tmpName.Streamer(R__b) ;
221 template<
class VO,
class VI1,
class VI2,
class VI3,
class VI4>
234 os <<
"[ function=" <<
func.name() <<
" " ;
235 for (
Int_t i=0 ; i<numProxies() ; i++) {
255 return func(x,y,z,w) ;
264 template<
class VO,
class VI1,
class VI2,
class VI3,
class VI4>
265 RooCFunction4Binding<VO,VI1,VI2,VI3,VI4>::RooCFunction4Binding(
const char *name,
const char *title, VO (*_func)(VI1,VI2,VI3,VI4),
269 x(
func.argName(0),
func.argName(0),this,_x),
270 y(
func.argName(1),
func.argName(1),this,_y),
271 z(
func.argName(2),
func.argName(2),this,_z),
272 w(
func.argName(3),
func.argName(3),this,_w)
281 template<
class VO,
class VI1,
class VI2,
class VI3,
class VI4>
294 template<
class VO,
class VI1,
class VI2,
class VI3,
class VI4>
307 os <<
"[ function=" <<
func.name() <<
" " ;
328 return func(x,y,z,w) ;
337 template<
class VO,
class VI1,
class VI2,
class VI3,
class VI4>
338 RooCFunction4PdfBinding<VO,VI1,VI2,VI3,VI4>::RooCFunction4PdfBinding(
const char *name,
const char *title, VO (*_func)(VI1,VI2,VI3,VI4),
342 x(
func.argName(0),
func.argName(0),this,_x),
343 y(
func.argName(1),
func.argName(1),this,_y),
344 z(
func.argName(2),
func.argName(2),this,_z),
345 w(
func.argName(3),
func.argName(3),this,_w)
354 template<
class VO,
class VI1,
class VI2,
class VI3,
class VI4>
void add(const char *name, VO(*ptr)(VI1, VI2, VI3, VI4), const char *arg1name="x", const char *arg2name="y", const char *arg3name="z", const char *arg4name="w")
VO operator()(VI1 x, VI2 y, VI3 z, VI4 w) const
static VO dummyFunction(VI1, VI2, VI3, VI4)
virtual const char * name() const
const char * lookupName(VO(*ptr)(VI1, VI2, VI3, VI4))
RooAbsPdf * bindPdf(const char *name, CFUNCD1D func, RooAbsReal &x)
Double_t(* CFUNCD4DDDB)(Double_t, Double_t, Double_t, Bool_t)
static RooCFunction4Map< VO, VI1, VI2, VI3, VI4 > * _fmap
Pointer to embedded function.
Double_t evaluate() const
Buffer base class used for serializing objects.
virtual Int_t CheckByteCount(UInt_t startpos, UInt_t bcnt, const TClass *clss)=0
Double_t(* CFUNCD4DDDI)(Double_t, Double_t, Double_t, Int_t)
const char * argName(Int_t iarg)
virtual UInt_t WriteVersion(const TClass *cl, Bool_t useBcnt=kFALSE)=0
std::map< VO(*)(VI1, VI2, VI3, VI4), std::string > _namemap
std::map< std::string, VO(*)(VI1, VI2, VI3, VI4)> _ptrmap
RooAbsReal * bindFunction(const char *name, CFUNCD1D func, RooAbsReal &x)
const char * name() const
#define ClassDef(name, id)
virtual ~RooCFunction4PdfBinding()
RooCFunction4Ref< VO, VI1, VI2, VI3, VI4 > func
void printArgs(std::ostream &os) const
Print object arguments, ie its proxies.
RooCFunction4Ref(VO(*ptr)(VI1, VI2, VI3, VI4)=0)
std::map< VO(*)(VI1, VI2, VI3, VI4), std::vector< std::string > > _argnamemap
char * Form(const char *fmt,...)
virtual void SetByteCount(UInt_t cntpos, Bool_t packInVersion=kFALSE)=0
Double_t(* CFUNCD4DDDD)(Double_t, Double_t, Double_t, Double_t)
static RooCFunction4Map< VO, VI1, VI2, VI3, VI4 > & fmap()
virtual TObject * clone(const char *newname) const
virtual ~RooCFunction4Binding()
RooAbsReal is the common abstract base class for objects that represent a real value and implements f...
VO(*)(VI1, VI2, VI3, VI4) lookupPtr(const char *name)
double func(double *x, double *p)
void printArgs(std::ostream &os) const
Print object arguments, ie its proxies.
const char * lookupArgName(VO(*ptr)(VI1, VI2, VI3, VI4), UInt_t iarg)
RooAbsProxy * getProxy(Int_t index) const
Return the nth proxy from the proxy list.
Mother of all ROOT objects.
Int_t numProxies() const
Return the number of registered proxies.
RooCFunction4Ref< VO, VI1, VI2, VI3, VI4 > func
RooAbsPdf is the abstract interface for all probability density functions The class provides hybrid a...
RooCFunction4PdfBinding()
virtual TObject * clone(const char *newname) const
virtual void print(std::ostream &os, Bool_t addContents=kFALSE) const
Print proxy name.
virtual Version_t ReadVersion(UInt_t *start=0, UInt_t *bcnt=0, const TClass *cl=0)=0
Double_t evaluate() const
const char * Data() const