#ifndef ROOCFUNCTION3BINDING
#define ROOCFUNCTION3BINDING
#include "TString.h"
#include "RooAbsReal.h"
#include "RooRealProxy.h"
#include "RooMsgService.h"
#include "RooAbsPdf.h"
#include <string>
#include <map>
#include <vector>
namespace RooFit {
typedef Double_t (*CFUNCD3DDD)(Double_t,Double_t,Double_t) ;
typedef Double_t (*CFUNCD3DDB)(Double_t,Double_t,Bool_t) ;
typedef Double_t (*CFUNCD3DII)(Double_t,Int_t,Int_t) ;
typedef Double_t (*CFUNCD3UDU)(UInt_t,Double_t,UInt_t) ;
typedef Double_t (*CFUNCD3UDD)(UInt_t,Double_t,Double_t) ;
typedef Double_t (*CFUNCD3UUD)(UInt_t,UInt_t,Double_t) ;
RooAbsReal* bindFunction(const char* name,void* func,RooAbsReal& x, RooAbsReal& y, RooAbsReal& z) ;
RooAbsPdf* bindPdf(const char* name,void* func,RooAbsReal& x, RooAbsReal& y, RooAbsReal& z) ;
#ifndef __CINT__
RooAbsReal* bindFunction(const char* name,CFUNCD3DDD func,RooAbsReal& x, RooAbsReal& y, RooAbsReal& z) ;
RooAbsReal* bindFunction(const char* name,CFUNCD3DDB func,RooAbsReal& x, RooAbsReal& y, RooAbsReal& z) ;
RooAbsReal* bindFunction(const char* name,CFUNCD3DII func,RooAbsReal& x, RooAbsReal& y, RooAbsReal& z) ;
RooAbsReal* bindFunction(const char* name,CFUNCD3UDU func,RooAbsReal& x, RooAbsReal& y, RooAbsReal& z) ;
RooAbsReal* bindFunction(const char* name,CFUNCD3UDD func,RooAbsReal& x, RooAbsReal& y, RooAbsReal& z) ;
RooAbsReal* bindFunction(const char* name,CFUNCD3UUD func,RooAbsReal& x, RooAbsReal& y, RooAbsReal& z) ;
RooAbsPdf* bindPdf(const char* name,CFUNCD3DDD func,RooAbsReal& x, RooAbsReal& y, RooAbsReal& z) ;
RooAbsPdf* bindPdf(const char* name,CFUNCD3DDB func,RooAbsReal& x, RooAbsReal& y, RooAbsReal& z) ;
RooAbsPdf* bindPdf(const char* name,CFUNCD3DII func,RooAbsReal& x, RooAbsReal& y, RooAbsReal& z) ;
RooAbsPdf* bindPdf(const char* name,CFUNCD3UDU func,RooAbsReal& x, RooAbsReal& y, RooAbsReal& z) ;
RooAbsPdf* bindPdf(const char* name,CFUNCD3UDD func,RooAbsReal& x, RooAbsReal& y, RooAbsReal& z) ;
RooAbsPdf* bindPdf(const char* name,CFUNCD3UUD func,RooAbsReal& x, RooAbsReal& y, RooAbsReal& z) ;
#endif
}
template<class VO, class VI1, class VI2, class VI3>
class RooCFunction3Map {
public:
RooCFunction3Map() {} ;
void add(const char* name, VO (*ptr)(VI1,VI2,VI3), const char* arg1name="x", const char* arg2name="y", const char* arg3name="z") {
_ptrmap[name] = ptr ;
_namemap[ptr] = name ;
_argnamemap[ptr].push_back(arg1name) ;
_argnamemap[ptr].push_back(arg2name) ;
_argnamemap[ptr].push_back(arg3name) ;
}
const char* lookupName(VO (*ptr)(VI1,VI2,VI3)) {
return _namemap[ptr].c_str() ;
}
VO (*lookupPtr(const char* name))(VI1,VI2,VI3) {
return _ptrmap[name] ;
}
const char* lookupArgName(VO (*ptr)(VI1,VI2,VI3), UInt_t iarg) {
if (iarg<_argnamemap[ptr].size()) {
return (_argnamemap[ptr])[iarg].c_str() ;
}
switch (iarg) {
case 0: return "x" ;
case 1: return "y" ;
case 2: return "z" ;
}
return "w" ;
}
private:
#ifndef __CINT__
std::map<std::string,VO (*)(VI1,VI2,VI3)> _ptrmap ;
std::map<VO (*)(VI1,VI2,VI3),std::string> _namemap ;
std::map<VO (*)(VI1,VI2,VI3),std::vector<std::string> > _argnamemap ;
#endif
} ;
template<class VO, class VI1, class VI2, class VI3>
class RooCFunction3Ref : public TObject {
public:
RooCFunction3Ref(VO (*ptr)(VI1,VI2,VI3)=0) : _ptr(ptr) {
} ;
~RooCFunction3Ref() {} ;
VO operator()(VI1 x,VI2 y, VI3 z) const {
return (*_ptr)(x,y,z) ;
}
const char* name() const {
const char* result = fmap().lookupName(_ptr) ;
if (result && strlen(result)) {
return result ;
}
return Form("(0x%08x)",_ptr) ;
}
const char* argName(Int_t iarg) {
return fmap().lookupArgName(_ptr,iarg) ;
}
static RooCFunction3Map<VO,VI1,VI2,VI3>& fmap() {
if (!_fmap) {
_fmap = new RooCFunction3Map<VO,VI1,VI2,VI3> ;
}
return *_fmap ;
}
private:
static VO dummyFunction(VI1,VI2,VI3) {
return 0 ;
}
VO (*_ptr)(VI1,VI2,VI3) ;
static RooCFunction3Map<VO,VI1,VI2,VI3>* _fmap ;
ClassDef(RooCFunction3Ref,1)
} ;
template<class VO, class VI1, class VI2, class VI3>
void RooCFunction3Ref<VO,VI1,VI2,VI3>::Streamer(TBuffer &R__b)
{
typedef ::RooCFunction3Ref<VO,VI1,VI2,VI3> thisClass;
if (R__b.IsReading()) {
UInt_t R__s, R__c;
R__b.ReadVersion(&R__s, &R__c);
TString tmpName ;
tmpName.Streamer(R__b) ;
if (tmpName=="UNKNOWN") {
coutW(ObjectHandling) << "WARNING: Objected embeds function pointer to unknown function, object will not be functional" << endl ;
_ptr = dummyFunction ;
} else {
_ptr = fmap().lookupPtr(tmpName.Data()) ;
if (_ptr==0) {
coutW(ObjectHandling) << "ERROR: Objected embeds pointer to function named " << tmpName
<< " but no such function is registered, object will not be functional" << endl ;
}
}
R__b.CheckByteCount(R__s, R__c, thisClass::IsA());
} else {
UInt_t R__c;
R__c = R__b.WriteVersion(thisClass::IsA(), kTRUE);
TString tmpName = fmap().lookupName(_ptr) ;
if (tmpName.Length()==0) {
coutW(ObjectHandling) << "WARNING: Cannot persist unknown function pointer " << Form("0x%08x",_ptr)
<< " written object will not be functional when read back" << endl ;
tmpName="UNKNOWN" ;
}
tmpName.Streamer(R__b) ;
R__b.SetByteCount(R__c, kTRUE);
}
}
template<class VO,class VI1, class VI2, class VI3>
class RooCFunction3Binding : public RooAbsReal {
public:
RooCFunction3Binding() {
} ;
RooCFunction3Binding(const char *name, const char *title, VO (*_func)(VI1,VI2,VI3), RooAbsReal& _x, RooAbsReal& _y, RooAbsReal& _z);
RooCFunction3Binding(const RooCFunction3Binding& other, const char* name=0) ;
virtual TObject* clone(const char* newname) const { return new RooCFunction3Binding(*this,newname); }
inline virtual ~RooCFunction3Binding() { }
void printArgs(ostream& os) const {
os << "[ function=" << func.name() << " " ;
for (Int_t i=0 ; i<numProxies() ; i++) {
RooAbsProxy* p = getProxy(i) ;
if (!TString(p->name()).BeginsWith("!")) {
p->print(os) ;
os << " " ;
}
}
os << "]" ;
}
protected:
RooCFunction3Ref<VO,VI1,VI2,VI3> func ;
RooRealProxy x ;
RooRealProxy y ;
RooRealProxy z ;
Double_t evaluate() const {
return func(x,y,z) ;
}
private:
ClassDef(RooCFunction3Binding,1)
};
template<class VO,class VI1, class VI2, class VI3>
RooCFunction3Binding<VO,VI1,VI2,VI3>::RooCFunction3Binding(const char *name, const char *title, VO (*_func)(VI1,VI2,VI3),
RooAbsReal& _x, RooAbsReal& _y, RooAbsReal& _z) :
RooAbsReal(name,title),
func(_func),
x(func.argName(0),func.argName(0),this,_x),
y(func.argName(1),func.argName(1),this,_y),
z(func.argName(2),func.argName(2),this,_z)
{
}
template<class VO,class VI1, class VI2, class VI3>
RooCFunction3Binding<VO,VI1,VI2,VI3>::RooCFunction3Binding(const RooCFunction3Binding& other, const char* name) :
RooAbsReal(other,name),
func(other.func),
x("x",this,other.x),
y("y",this,other.y),
z("z",this,other.z)
{
}
template<class VO,class VI1, class VI2, class VI3>
class RooCFunction3PdfBinding : public RooAbsPdf {
public:
RooCFunction3PdfBinding() {
} ;
RooCFunction3PdfBinding(const char *name, const char *title, VO (*_func)(VI1,VI2,VI3), RooAbsReal& _x, RooAbsReal& _y, RooAbsReal& _z);
RooCFunction3PdfBinding(const RooCFunction3PdfBinding& other, const char* name=0) ;
virtual TObject* clone(const char* newname) const { return new RooCFunction3PdfBinding(*this,newname); }
inline virtual ~RooCFunction3PdfBinding() { }
void printArgs(ostream& os) const {
os << "[ function=" << func.name() << " " ;
for (Int_t i=0 ; i<numProxies() ; i++) {
RooAbsProxy* p = getProxy(i) ;
if (!TString(p->name()).BeginsWith("!")) {
p->print(os) ;
os << " " ;
}
}
os << "]" ;
}
protected:
RooCFunction3Ref<VO,VI1,VI2,VI3> func ;
RooRealProxy x ;
RooRealProxy y ;
RooRealProxy z ;
Double_t evaluate() const {
return func(x,y,z) ;
}
private:
ClassDef(RooCFunction3PdfBinding,1)
};
template<class VO,class VI1, class VI2, class VI3>
RooCFunction3PdfBinding<VO,VI1,VI2,VI3>::RooCFunction3PdfBinding(const char *name, const char *title, VO (*_func)(VI1,VI2,VI3),
RooAbsReal& _x, RooAbsReal& _y, RooAbsReal& _z) :
RooAbsPdf(name,title),
func(_func),
x(func.argName(0),func.argName(0),this,_x),
y(func.argName(1),func.argName(1),this,_y),
z(func.argName(2),func.argName(2),this,_z)
{
}
template<class VO,class VI1, class VI2, class VI3>
RooCFunction3PdfBinding<VO,VI1,VI2,VI3>::RooCFunction3PdfBinding(const RooCFunction3PdfBinding& other, const char* name) :
RooAbsPdf(other,name),
func(other.func),
x("x",this,other.x),
y("y",this,other.y),
z("z",this,other.z)
{
}
template <> void RooCFunction3Ref<Double_t,Double_t,Double_t,Double_t>::ShowMembers(TMemberInspector &R__insp, char *R__parent) ;
template <> void RooCFunction3Binding<Double_t,Double_t,Double_t,Double_t>::ShowMembers(TMemberInspector &R__insp, char *R__parent) ;
template <> void RooCFunction3PdfBinding<Double_t,Double_t,Double_t,Double_t>::ShowMembers(TMemberInspector &R__insp, char *R__parent) ;
template <> void RooCFunction3Ref<Double_t,Double_t,Double_t,Bool_t>::ShowMembers(TMemberInspector &R__insp, char *R__parent) ;
template <> void RooCFunction3Binding<Double_t,Double_t,Double_t,Bool_t>::ShowMembers(TMemberInspector &R__insp, char *R__parent) ;
template <> void RooCFunction3PdfBinding<Double_t,Double_t,Double_t,Bool_t>::ShowMembers(TMemberInspector &R__insp, char *R__parent) ;
template <> void RooCFunction3Ref<Double_t,Double_t,Int_t,Int_t>::ShowMembers(TMemberInspector &R__insp, char *R__parent) ;
template <> void RooCFunction3Binding<Double_t,Double_t,Int_t,Int_t>::ShowMembers(TMemberInspector &R__insp, char *R__parent) ;
template <> void RooCFunction3PdfBinding<Double_t,Double_t,Int_t,Int_t>::ShowMembers(TMemberInspector &R__insp, char *R__parent) ;
template <> void RooCFunction3Ref<Double_t,UInt_t,Double_t,UInt_t>::ShowMembers(TMemberInspector &R__insp, char *R__parent) ;
template <> void RooCFunction3Binding<Double_t,UInt_t,Double_t,UInt_t>::ShowMembers(TMemberInspector &R__insp, char *R__parent) ;
template <> void RooCFunction3PdfBinding<Double_t,UInt_t,Double_t,UInt_t>::ShowMembers(TMemberInspector &R__insp, char *R__parent) ;
template <> void RooCFunction3Ref<Double_t,UInt_t,Double_t,Double_t>::ShowMembers(TMemberInspector &R__insp, char *R__parent) ;
template <> void RooCFunction3Binding<Double_t,UInt_t,Double_t,Double_t>::ShowMembers(TMemberInspector &R__insp, char *R__parent) ;
template <> void RooCFunction3PdfBinding<Double_t,UInt_t,Double_t,Double_t>::ShowMembers(TMemberInspector &R__insp, char *R__parent) ;
template <> void RooCFunction3Ref<Double_t,UInt_t,UInt_t,Double_t>::ShowMembers(TMemberInspector &R__insp, char *R__parent) ;
template <> void RooCFunction3Binding<Double_t,UInt_t,UInt_t,Double_t>::ShowMembers(TMemberInspector &R__insp, char *R__parent) ;
template <> void RooCFunction3PdfBinding<Double_t,UInt_t,UInt_t,Double_t>::ShowMembers(TMemberInspector &R__insp, char *R__parent) ;
#endif
Last change: Mon Aug 25 11:35:56 2008
Last generated: 2008-08-25 11:35
This page has been automatically generated. If you have any comments or suggestions about the page layout send a mail to ROOT support, or contact the developers with any questions or problems regarding ROOT.