00001
00002
00003
00004
00005
00006
00007
00008
00009 #include "Riostream.h"
00010
00011 #include "RooTFnPdfBinding.h"
00012 #include "RooAbsReal.h"
00013 #include "RooAbsCategory.h"
00014 #include "TF3.h"
00015
00016 ClassImp(RooTFnPdfBinding)
00017
00018 RooTFnPdfBinding::RooTFnPdfBinding(const char *name, const char *title, TF1* _func, const RooArgList& _list) :
00019 RooAbsPdf(name,title),
00020 list("params","params",this),
00021 func(_func)
00022 {
00023 list.add(_list) ;
00024 }
00025
00026
00027 RooTFnPdfBinding::RooTFnPdfBinding(const RooTFnPdfBinding& other, const char* name) :
00028 RooAbsPdf(other,name),
00029 list("params",this,other.list),
00030 func(other.func)
00031 {
00032 }
00033
00034
00035
00036 Double_t RooTFnPdfBinding::evaluate() const
00037 {
00038 Double_t x = list.at(0) ? ((RooAbsReal*)list.at(0))->getVal() : 0 ;
00039 Double_t y = list.at(1) ? ((RooAbsReal*)list.at(1))->getVal() : 0 ;
00040 Double_t z = list.at(2) ? ((RooAbsReal*)list.at(2))->getVal() : 0 ;
00041 return func->Eval(x,y,z) ;
00042 }
00043
00044
00045
00046 void RooTFnPdfBinding::printArgs(ostream& os) const
00047 {
00048
00049 os << "[ TFn={" << func->GetName() << "=" << func->GetTitle() << "} " ;
00050 for (Int_t i=0 ; i<numProxies() ; i++) {
00051 RooAbsProxy* p = getProxy(i) ;
00052 if (!TString(p->name()).BeginsWith("!")) {
00053 p->print(os) ;
00054 os << " " ;
00055 }
00056 }
00057 os << "]" ;
00058 }
00059
00060
00061
00062
00063 namespace RooFit {
00064
00065 RooAbsPdf* bindPdf(TF1* func,RooAbsReal& x) {
00066 return new RooTFnPdfBinding(func->GetName(),func->GetName(),func,x) ;
00067 }
00068
00069 RooAbsPdf* bindPdf(TF2* func,RooAbsReal& x, RooAbsReal& y) {
00070 return new RooTFnPdfBinding(func->GetName(),func->GetName(),func,RooArgList(x,y)) ;
00071 }
00072
00073 RooAbsPdf* bindPdf(TF3* func,RooAbsReal& x, RooAbsReal& y, RooAbsReal& z) {
00074 return new RooTFnPdfBinding(func->GetName(),func->GetName(),func,RooArgList(x,y,z)) ;
00075 }
00076
00077 }