#ifndef ROOCFUNCTION4BINDING
#define ROOCFUNCTION4BINDING
#include "TString.h"
#include "RooAbsReal.h"
#include "RooAbsPdf.h"
#include "RooRealProxy.h"
#include "RooMsgService.h"
#include <string>
#include <map>
#include <vector>
namespace RooFit {
typedef Double_t (*CFUNCD4DDDD)(Double_t,Double_t,Double_t,Double_t) ;
typedef Double_t (*CFUNCD4DDDI)(Double_t,Double_t,Double_t,Int_t) ;
typedef Double_t (*CFUNCD4DDDB)(Double_t,Double_t,Double_t,Bool_t) ;
RooAbsReal* bindFunction(const char* name,void* func,RooAbsReal& x, RooAbsReal& y, RooAbsReal& z, RooAbsReal& w) ;
RooAbsPdf* bindPdf(const char* name,void* func,RooAbsReal& x, RooAbsReal& y, RooAbsReal& z, RooAbsReal& w) ;
#ifndef __CINT__
RooAbsReal* bindFunction(const char* name,CFUNCD4DDDD func,RooAbsReal& x, RooAbsReal& y, RooAbsReal& z, RooAbsReal& w) ;
RooAbsReal* bindFunction(const char* name,CFUNCD4DDDI func,RooAbsReal& x, RooAbsReal& y, RooAbsReal& z, RooAbsReal& w) ;
RooAbsReal* bindFunction(const char* name,CFUNCD4DDDB func,RooAbsReal& x, RooAbsReal& y, RooAbsReal& z, RooAbsReal& w) ;
RooAbsPdf* bindPdf(const char* name,CFUNCD4DDDD func,RooAbsReal& x, RooAbsReal& y, RooAbsReal& z, RooAbsReal& w) ;
RooAbsPdf* bindPdf(const char* name,CFUNCD4DDDI func,RooAbsReal& x, RooAbsReal& y, RooAbsReal& z, RooAbsReal& w) ;
RooAbsPdf* bindPdf(const char* name,CFUNCD4DDDB func,RooAbsReal& x, RooAbsReal& y, RooAbsReal& z, RooAbsReal& w) ;
#endif
}
template<class VO, class VI1, class VI2, class VI3, class VI4>
class RooCFunction4Map {
public:
RooCFunction4Map() {} ;
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") {
_ptrmap[name] = ptr ;
_namemap[ptr] = name ;
_argnamemap[ptr].push_back(arg1name) ;
_argnamemap[ptr].push_back(arg2name) ;
_argnamemap[ptr].push_back(arg3name) ;
_argnamemap[ptr].push_back(arg4name) ;
}
const char* lookupName(VO (*ptr)(VI1,VI2,VI3,VI4)) {
return _namemap[ptr].c_str() ;
}
VO (*lookupPtr(const char* name))(VI1,VI2,VI3,VI4) {
return _ptrmap[name] ;
}
const char* lookupArgName(VO (*ptr)(VI1,VI2,VI3,VI4), 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" ;
case 3: return "w" ;
}
return "v" ;
}
private:
#ifndef __CINT__
std::map<std::string,VO (*)(VI1,VI2,VI3,VI4)> _ptrmap ;
std::map<VO (*)(VI1,VI2,VI3,VI4),std::string> _namemap ;
std::map<VO (*)(VI1,VI2,VI3,VI4),std::vector<std::string> > _argnamemap ;
#endif
} ;
template<class VO, class VI1, class VI2, class VI3, class VI4>
class RooCFunction4Ref : public TObject {
public:
RooCFunction4Ref(VO (*ptr)(VI1,VI2,VI3,VI4)=0) : _ptr(ptr) {
} ;
~RooCFunction4Ref() {} ;
VO operator()(VI1 x,VI2 y,VI3 z,VI4 w) const {
return (*_ptr)(x,y,z,w) ;
}
const char* name() const {
const char* result = fmap().lookupName(_ptr) ;
if (result && strlen(result)) {
return result ;
}
union {
void *_ptr;
func_t _funcptr;
} temp;
temp._funcptr = _ptr;
return Form("(%p)",temp._ptr) ;
}
const char* argName(Int_t iarg) {
return fmap().lookupArgName(_ptr,iarg) ;
}
static RooCFunction4Map<VO,VI1,VI2,VI3,VI4>& fmap() {
if (!_fmap) {
_fmap = new RooCFunction4Map<VO,VI1,VI2,VI3,VI4> ;
}
return *_fmap ;
}
private:
static VO dummyFunction(VI1,VI2,VI3,VI4) {
return 0 ;
}
typedef VO (*func_t)(VI1,VI2,VI3,VI4);
func_t _ptr;
static RooCFunction4Map<VO,VI1,VI2,VI3,VI4>* _fmap ;
ClassDef(RooCFunction4Ref,1)
} ;
template<class VO, class VI1, class VI2, class VI3, class VI4>
void RooCFunction4Ref<VO,VI1,VI2,VI3,VI4>::Streamer(TBuffer &R__b)
{
typedef ::RooCFunction4Ref<VO,VI1,VI2,VI3,VI4> 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%lx",(ULong_t)_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 VI4>
class RooCFunction4Binding : public RooAbsReal {
public:
RooCFunction4Binding() {
} ;
RooCFunction4Binding(const char *name, const char *title, VO (*_func)(VI1,VI2,VI3,VI4), RooAbsReal& _x, RooAbsReal& _y, RooAbsReal& _z, RooAbsReal& _w);
RooCFunction4Binding(const RooCFunction4Binding& other, const char* name=0) ;
virtual TObject* clone(const char* newname) const { return new RooCFunction4Binding(*this,newname); }
inline virtual ~RooCFunction4Binding() { }
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:
RooCFunction4Ref<VO,VI1,VI2,VI3,VI4> func ;
RooRealProxy x ;
RooRealProxy y ;
RooRealProxy z ;
RooRealProxy w ;
Double_t evaluate() const {
return func(x,y,z,w) ;
}
private:
ClassDef(RooCFunction4Binding,1)
};
template<class VO,class VI1, class VI2, class VI3, class VI4>
RooCFunction4Binding<VO,VI1,VI2,VI3,VI4>::RooCFunction4Binding(const char *name, const char *title, VO (*_func)(VI1,VI2,VI3,VI4),
RooAbsReal& _x, RooAbsReal& _y, RooAbsReal& _z, RooAbsReal& _w) :
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),
w(func.argName(3),func.argName(3),this,_w)
{
}
template<class VO,class VI1, class VI2, class VI3, class VI4>
RooCFunction4Binding<VO,VI1,VI2,VI3,VI4>::RooCFunction4Binding(const RooCFunction4Binding& 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),
w("w",this,other.w)
{
}
template<class VO,class VI1, class VI2, class VI3, class VI4>
class RooCFunction4PdfBinding : public RooAbsPdf {
public:
RooCFunction4PdfBinding() {
} ;
RooCFunction4PdfBinding(const char *name, const char *title, VO (*_func)(VI1,VI2,VI3,VI4), RooAbsReal& _x, RooAbsReal& _y, RooAbsReal& _z, RooAbsReal& _w);
RooCFunction4PdfBinding(const RooCFunction4PdfBinding& other, const char* name=0) ;
virtual TObject* clone(const char* newname) const { return new RooCFunction4PdfBinding(*this,newname); }
inline virtual ~RooCFunction4PdfBinding() { }
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:
RooCFunction4Ref<VO,VI1,VI2,VI3,VI4> func ;
RooRealProxy x ;
RooRealProxy y ;
RooRealProxy z ;
RooRealProxy w ;
Double_t evaluate() const {
return func(x,y,z,w) ;
}
private:
ClassDef(RooCFunction4PdfBinding,1)
};
template<class VO,class VI1, class VI2, class VI3, class VI4>
RooCFunction4PdfBinding<VO,VI1,VI2,VI3,VI4>::RooCFunction4PdfBinding(const char *name, const char *title, VO (*_func)(VI1,VI2,VI3,VI4),
RooAbsReal& _x, RooAbsReal& _y, RooAbsReal& _z, RooAbsReal& _w) :
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),
w(func.argName(3),func.argName(3),this,_w)
{
}
template<class VO,class VI1, class VI2, class VI3, class VI4>
RooCFunction4PdfBinding<VO,VI1,VI2,VI3,VI4>::RooCFunction4PdfBinding(const RooCFunction4PdfBinding& 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),
w("w",this,other.w)
{
}
#endif
RooCFunction4Binding.h:10 RooCFunction4Binding.h:11 RooCFunction4Binding.h:12 RooCFunction4Binding.h:13 RooCFunction4Binding.h:14 RooCFunction4Binding.h:15 RooCFunction4Binding.h:16 RooCFunction4Binding.h:17 RooCFunction4Binding.h:18 RooCFunction4Binding.h:19 RooCFunction4Binding.h:20 RooCFunction4Binding.h:21 RooCFunction4Binding.h:22 RooCFunction4Binding.h:23 RooCFunction4Binding.h:24 RooCFunction4Binding.h:25 RooCFunction4Binding.h:26 RooCFunction4Binding.h:27 RooCFunction4Binding.h:28 RooCFunction4Binding.h:29 RooCFunction4Binding.h:30 RooCFunction4Binding.h:31 RooCFunction4Binding.h:32 RooCFunction4Binding.h:33 RooCFunction4Binding.h:34 RooCFunction4Binding.h:35 RooCFunction4Binding.h:36 RooCFunction4Binding.h:37 RooCFunction4Binding.h:38 RooCFunction4Binding.h:39 RooCFunction4Binding.h:40 RooCFunction4Binding.h:41 RooCFunction4Binding.h:42 RooCFunction4Binding.h:43 RooCFunction4Binding.h:44 RooCFunction4Binding.h:45 RooCFunction4Binding.h:46 RooCFunction4Binding.h:47 RooCFunction4Binding.h:48 RooCFunction4Binding.h:49 RooCFunction4Binding.h:50 RooCFunction4Binding.h:51 RooCFunction4Binding.h:52 RooCFunction4Binding.h:53 RooCFunction4Binding.h:54 RooCFunction4Binding.h:55 RooCFunction4Binding.h:56 RooCFunction4Binding.h:57 RooCFunction4Binding.h:58 RooCFunction4Binding.h:59 RooCFunction4Binding.h:60 RooCFunction4Binding.h:61 RooCFunction4Binding.h:62 RooCFunction4Binding.h:63 RooCFunction4Binding.h:64 RooCFunction4Binding.h:65 RooCFunction4Binding.h:66 RooCFunction4Binding.h:67 RooCFunction4Binding.h:68 RooCFunction4Binding.h:69 RooCFunction4Binding.h:70 RooCFunction4Binding.h:71 RooCFunction4Binding.h:72 RooCFunction4Binding.h:73 RooCFunction4Binding.h:74 RooCFunction4Binding.h:75 RooCFunction4Binding.h:76 RooCFunction4Binding.h:77 RooCFunction4Binding.h:78 RooCFunction4Binding.h:79 RooCFunction4Binding.h:80 RooCFunction4Binding.h:81 RooCFunction4Binding.h:82 RooCFunction4Binding.h:83 RooCFunction4Binding.h:84 RooCFunction4Binding.h:85 RooCFunction4Binding.h:86 RooCFunction4Binding.h:87 RooCFunction4Binding.h:88 RooCFunction4Binding.h:89 RooCFunction4Binding.h:90 RooCFunction4Binding.h:91 RooCFunction4Binding.h:92 RooCFunction4Binding.h:93 RooCFunction4Binding.h:94 RooCFunction4Binding.h:95 RooCFunction4Binding.h:96 RooCFunction4Binding.h:97 RooCFunction4Binding.h:98 RooCFunction4Binding.h:99 RooCFunction4Binding.h:100 RooCFunction4Binding.h:101 RooCFunction4Binding.h:102 RooCFunction4Binding.h:103 RooCFunction4Binding.h:104 RooCFunction4Binding.h:105 RooCFunction4Binding.h:106 RooCFunction4Binding.h:107 RooCFunction4Binding.h:108 RooCFunction4Binding.h:109 RooCFunction4Binding.h:110 RooCFunction4Binding.h:111 RooCFunction4Binding.h:112 RooCFunction4Binding.h:113 RooCFunction4Binding.h:114 RooCFunction4Binding.h:115 RooCFunction4Binding.h:116 RooCFunction4Binding.h:117 RooCFunction4Binding.h:118 RooCFunction4Binding.h:119 RooCFunction4Binding.h:120 RooCFunction4Binding.h:121 RooCFunction4Binding.h:122 RooCFunction4Binding.h:123 RooCFunction4Binding.h:124 RooCFunction4Binding.h:125 RooCFunction4Binding.h:126 RooCFunction4Binding.h:127 RooCFunction4Binding.h:128 RooCFunction4Binding.h:129 RooCFunction4Binding.h:130 RooCFunction4Binding.h:131 RooCFunction4Binding.h:132 RooCFunction4Binding.h:133 RooCFunction4Binding.h:134 RooCFunction4Binding.h:135 RooCFunction4Binding.h:136 RooCFunction4Binding.h:137 RooCFunction4Binding.h:138 RooCFunction4Binding.h:139 RooCFunction4Binding.h:140 RooCFunction4Binding.h:141 RooCFunction4Binding.h:142 RooCFunction4Binding.h:143 RooCFunction4Binding.h:144 RooCFunction4Binding.h:145 RooCFunction4Binding.h:146 RooCFunction4Binding.h:147 RooCFunction4Binding.h:148 RooCFunction4Binding.h:149 RooCFunction4Binding.h:150 RooCFunction4Binding.h:151 RooCFunction4Binding.h:152 RooCFunction4Binding.h:153 RooCFunction4Binding.h:154 RooCFunction4Binding.h:155 RooCFunction4Binding.h:156 RooCFunction4Binding.h:157 RooCFunction4Binding.h:158 RooCFunction4Binding.h:159 RooCFunction4Binding.h:160 RooCFunction4Binding.h:161 RooCFunction4Binding.h:162 RooCFunction4Binding.h:163 RooCFunction4Binding.h:164 RooCFunction4Binding.h:165 RooCFunction4Binding.h:166 RooCFunction4Binding.h:167 RooCFunction4Binding.h:168 RooCFunction4Binding.h:169 RooCFunction4Binding.h:170 RooCFunction4Binding.h:171 RooCFunction4Binding.h:172 RooCFunction4Binding.h:173 RooCFunction4Binding.h:174 RooCFunction4Binding.h:175 RooCFunction4Binding.h:176 RooCFunction4Binding.h:177 RooCFunction4Binding.h:178 RooCFunction4Binding.h:179 RooCFunction4Binding.h:180 RooCFunction4Binding.h:181 RooCFunction4Binding.h:182 RooCFunction4Binding.h:183 RooCFunction4Binding.h:184 RooCFunction4Binding.h:185 RooCFunction4Binding.h:186 RooCFunction4Binding.h:187 RooCFunction4Binding.h:188 RooCFunction4Binding.h:189 RooCFunction4Binding.h:190 RooCFunction4Binding.h:191 RooCFunction4Binding.h:192 RooCFunction4Binding.h:193 RooCFunction4Binding.h:194 RooCFunction4Binding.h:195 RooCFunction4Binding.h:196 RooCFunction4Binding.h:197 RooCFunction4Binding.h:198 RooCFunction4Binding.h:199 RooCFunction4Binding.h:200 RooCFunction4Binding.h:201 RooCFunction4Binding.h:202 RooCFunction4Binding.h:203 RooCFunction4Binding.h:204 RooCFunction4Binding.h:205 RooCFunction4Binding.h:206 RooCFunction4Binding.h:207 RooCFunction4Binding.h:208 RooCFunction4Binding.h:209 RooCFunction4Binding.h:210 RooCFunction4Binding.h:211 RooCFunction4Binding.h:212 RooCFunction4Binding.h:213 RooCFunction4Binding.h:214 RooCFunction4Binding.h:215 RooCFunction4Binding.h:216 RooCFunction4Binding.h:217 RooCFunction4Binding.h:218 RooCFunction4Binding.h:219 RooCFunction4Binding.h:220 RooCFunction4Binding.h:221 RooCFunction4Binding.h:222 RooCFunction4Binding.h:223 RooCFunction4Binding.h:224 RooCFunction4Binding.h:225 RooCFunction4Binding.h:226 RooCFunction4Binding.h:227 RooCFunction4Binding.h:228 RooCFunction4Binding.h:229 RooCFunction4Binding.h:230 RooCFunction4Binding.h:231 RooCFunction4Binding.h:232 RooCFunction4Binding.h:233 RooCFunction4Binding.h:234 RooCFunction4Binding.h:235 RooCFunction4Binding.h:236 RooCFunction4Binding.h:237 RooCFunction4Binding.h:238 RooCFunction4Binding.h:239 RooCFunction4Binding.h:240 RooCFunction4Binding.h:241 RooCFunction4Binding.h:242 RooCFunction4Binding.h:243 RooCFunction4Binding.h:244 RooCFunction4Binding.h:245 RooCFunction4Binding.h:246 RooCFunction4Binding.h:247 RooCFunction4Binding.h:248 RooCFunction4Binding.h:249 RooCFunction4Binding.h:250 RooCFunction4Binding.h:251 RooCFunction4Binding.h:252 RooCFunction4Binding.h:253 RooCFunction4Binding.h:254 RooCFunction4Binding.h:255 RooCFunction4Binding.h:256 RooCFunction4Binding.h:257 RooCFunction4Binding.h:258 RooCFunction4Binding.h:259 RooCFunction4Binding.h:260 RooCFunction4Binding.h:261 RooCFunction4Binding.h:262 RooCFunction4Binding.h:263 RooCFunction4Binding.h:264 RooCFunction4Binding.h:265 RooCFunction4Binding.h:266 RooCFunction4Binding.h:267 RooCFunction4Binding.h:268 RooCFunction4Binding.h:269 RooCFunction4Binding.h:270 RooCFunction4Binding.h:271 RooCFunction4Binding.h:272 RooCFunction4Binding.h:273 RooCFunction4Binding.h:274 RooCFunction4Binding.h:275 RooCFunction4Binding.h:276 RooCFunction4Binding.h:277 RooCFunction4Binding.h:278 RooCFunction4Binding.h:279 RooCFunction4Binding.h:280 RooCFunction4Binding.h:281 RooCFunction4Binding.h:282 RooCFunction4Binding.h:283 RooCFunction4Binding.h:284 RooCFunction4Binding.h:285 RooCFunction4Binding.h:286 RooCFunction4Binding.h:287 RooCFunction4Binding.h:288 RooCFunction4Binding.h:289 RooCFunction4Binding.h:290 RooCFunction4Binding.h:291 RooCFunction4Binding.h:292 RooCFunction4Binding.h:293 RooCFunction4Binding.h:294 RooCFunction4Binding.h:295 RooCFunction4Binding.h:296 RooCFunction4Binding.h:297 RooCFunction4Binding.h:298 RooCFunction4Binding.h:299 RooCFunction4Binding.h:300 RooCFunction4Binding.h:301 RooCFunction4Binding.h:302 RooCFunction4Binding.h:303 RooCFunction4Binding.h:304 RooCFunction4Binding.h:305 RooCFunction4Binding.h:306 RooCFunction4Binding.h:307 RooCFunction4Binding.h:308 RooCFunction4Binding.h:309 RooCFunction4Binding.h:310 RooCFunction4Binding.h:311 RooCFunction4Binding.h:312 RooCFunction4Binding.h:313 RooCFunction4Binding.h:314 RooCFunction4Binding.h:315 RooCFunction4Binding.h:316 RooCFunction4Binding.h:317 RooCFunction4Binding.h:318 RooCFunction4Binding.h:319 RooCFunction4Binding.h:320 RooCFunction4Binding.h:321 RooCFunction4Binding.h:322 RooCFunction4Binding.h:323 RooCFunction4Binding.h:324 RooCFunction4Binding.h:325 RooCFunction4Binding.h:326 RooCFunction4Binding.h:327 RooCFunction4Binding.h:328 RooCFunction4Binding.h:329 RooCFunction4Binding.h:330 RooCFunction4Binding.h:331 RooCFunction4Binding.h:332 RooCFunction4Binding.h:333 RooCFunction4Binding.h:334 RooCFunction4Binding.h:335 RooCFunction4Binding.h:336 RooCFunction4Binding.h:337 RooCFunction4Binding.h:338 RooCFunction4Binding.h:339 RooCFunction4Binding.h:340 RooCFunction4Binding.h:341 RooCFunction4Binding.h:342 RooCFunction4Binding.h:343 RooCFunction4Binding.h:344 RooCFunction4Binding.h:345 RooCFunction4Binding.h:346 RooCFunction4Binding.h:347 RooCFunction4Binding.h:348 RooCFunction4Binding.h:349 RooCFunction4Binding.h:350 RooCFunction4Binding.h:351 RooCFunction4Binding.h:352 RooCFunction4Binding.h:353 RooCFunction4Binding.h:354 RooCFunction4Binding.h:355 RooCFunction4Binding.h:356 RooCFunction4Binding.h:357 RooCFunction4Binding.h:358 RooCFunction4Binding.h:359 RooCFunction4Binding.h:360 RooCFunction4Binding.h:361 RooCFunction4Binding.h:362 RooCFunction4Binding.h:363 RooCFunction4Binding.h:364 RooCFunction4Binding.h:365 RooCFunction4Binding.h:366 RooCFunction4Binding.h:367 RooCFunction4Binding.h:368 RooCFunction4Binding.h:369 RooCFunction4Binding.h:370