00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026 #include "Riostream.h"
00027 #include "RooFunctorBinding.h"
00028
00029 using namespace std ;
00030
00031 ClassImp(RooFunctorBinding)
00032 ClassImp(RooFunctorPdfBinding)
00033 ;
00034
00035
00036 RooFunctorBinding::RooFunctorBinding(const char *name, const char *title, const ROOT::Math::IBaseFunctionMultiDim& ftor, const RooArgList& v) :
00037 RooAbsReal(name,title),
00038 func(&ftor),
00039 vars("vars","vars",this)
00040 {
00041
00042 if (ftor.NDim()!=UInt_t(v.getSize())) {
00043 coutE(InputArguments) << "RooFunctorBinding::ctor(" << GetName() << ") ERROR number of provided variables (" << v.getSize()
00044 << ") does not match dimensionality of function (" << ftor.NDim() << ")" << endl ;
00045 throw string("RooFunctor::ctor ERROR") ;
00046 }
00047 x = new Double_t[func->NDim()] ;
00048 vars.add(v) ;
00049 }
00050
00051
00052 RooFunctorBinding::RooFunctorBinding(const RooFunctorBinding& other, const char* name) :
00053 RooAbsReal(other,name),
00054 func(other.func),
00055 vars("vars",this,other.vars)
00056 {
00057
00058 x = new Double_t[func->NDim()] ;
00059 }
00060
00061
00062
00063 void RooFunctorBinding::printArgs(ostream& os) const {
00064
00065 os << "[ function=" << func << " " ;
00066 for (Int_t i=0 ; i<numProxies() ; i++) {
00067 RooAbsProxy* p = getProxy(i) ;
00068 if (!TString(p->name()).BeginsWith("!")) {
00069 p->print(os) ;
00070 os << " " ;
00071 }
00072 }
00073 os << "]" ;
00074 }
00075
00076 Double_t RooFunctorBinding::evaluate() const {
00077
00078 for (int i=0 ; i<vars.getSize() ; i++) {
00079 x[i] = ((RooAbsReal*)vars.at(i))->getVal() ;
00080 }
00081 return (*func)(x) ;
00082 }
00083
00084
00085
00086 RooFunctorPdfBinding::RooFunctorPdfBinding(const char *name, const char *title, const ROOT::Math::IBaseFunctionMultiDim& ftor, const RooArgList& v) :
00087 RooAbsPdf(name,title),
00088 func(&ftor),
00089 vars("vars","vars",this)
00090 {
00091
00092 if (ftor.NDim()!=UInt_t(v.getSize())) {
00093 coutE(InputArguments) << "RooFunctorPdfBinding::ctor(" << GetName() << ") ERROR number of provided variables (" << v.getSize()
00094 << ") does not match dimensionality of function (" << ftor.NDim() << ")" << endl ;
00095 throw string("RooFunctor::ctor ERROR") ;
00096 }
00097 x = new Double_t[func->NDim()] ;
00098 vars.add(v) ;
00099 }
00100
00101
00102 RooFunctorPdfBinding::RooFunctorPdfBinding(const RooFunctorPdfBinding& other, const char* name) :
00103 RooAbsPdf(other,name),
00104 func(other.func),
00105 vars("vars",this,other.vars)
00106 {
00107
00108 x = new Double_t[func->NDim()] ;
00109 }
00110
00111
00112
00113 void RooFunctorPdfBinding::printArgs(ostream& os) const {
00114
00115 os << "[ function=" << func << " " ;
00116 for (Int_t i=0 ; i<numProxies() ; i++) {
00117 RooAbsProxy* p = getProxy(i) ;
00118 if (!TString(p->name()).BeginsWith("!")) {
00119 p->print(os) ;
00120 os << " " ;
00121 }
00122 }
00123 os << "]" ;
00124 }
00125
00126 Double_t RooFunctorPdfBinding::evaluate() const {
00127
00128 for (int i=0 ; i<vars.getSize() ; i++) {
00129 x[i] = ((RooAbsReal*)vars.at(i))->getVal() ;
00130 }
00131 return (*func)(x) ;
00132 }
00133
00134
00135
00136
00137 namespace RooFit {
00138
00139 RooAbsReal* bindFunction(const char* name, const ROOT::Math::IBaseFunctionMultiDim& ftor,const RooArgList& vars) {
00140 return new RooFunctorBinding(name,name,ftor,vars) ;
00141 }
00142
00143 RooAbsPdf* bindPdf(const char* name, const ROOT::Math::IBaseFunctionMultiDim& ftor, const RooArgList& vars) {
00144 return new RooFunctorPdfBinding(name,name,ftor,vars) ;
00145 }
00146
00147 }
00148
00149
00150