/***************************************************************************** 
 * Project: RooFit                                                           * 
 *                                                                           * 
 * This code was autogenerated by RooClassFactory                            * 
 *****************************************************************************/ 

// Your description goes here...

#include "Riostream.h" 

#include "RooTFnPdfBinding.h" 
#include "RooAbsReal.h" 
#include "RooAbsCategory.h" 
#include "TF3.h"

using namespace std;

ClassImp(RooTFnPdfBinding) 

RooTFnPdfBinding::RooTFnPdfBinding(const char *name, const char *title, TF1* func, const RooArgList& list) :
  RooAbsPdf(name,title), 
  _list("params","params",this),
  _func(func)
{ 
  _list.add(list) ;
} 


RooTFnPdfBinding::RooTFnPdfBinding(const RooTFnPdfBinding& other, const char* name) :  
  RooAbsPdf(other,name), 
  _list("params",this,other._list),
  _func(other._func)
{ 
} 



Double_t RooTFnPdfBinding::evaluate() const 
{ 
  Double_t x = _list.at(0) ? ((RooAbsReal*)_list.at(0))->getVal() : 0 ;
  Double_t y = _list.at(1) ? ((RooAbsReal*)_list.at(1))->getVal() : 0 ;
  Double_t z = _list.at(2) ? ((RooAbsReal*)_list.at(2))->getVal() : 0 ;
  return _func->Eval(x,y,z) ;
} 



void RooTFnPdfBinding::printArgs(ostream& os) const 
{
  // Print object arguments and name/address of function pointer
  os << "[ TFn={" << _func->GetName() << "=" << _func->GetTitle() << "} " ;    
  for (Int_t i=0 ; i<numProxies() ; i++) {
    RooAbsProxy* p = getProxy(i) ;
    if (!TString(p->name()).BeginsWith("!")) {
      p->print(os) ;
      os << " " ;
    }
  }    
  os << "]" ;  
}




namespace RooFit {

  RooAbsPdf* bindPdf(TF1* func,RooAbsReal& x) {
    return new RooTFnPdfBinding(func->GetName(),func->GetName(),func,x) ;
  }

  RooAbsPdf* bindPdf(TF2* func,RooAbsReal& x, RooAbsReal& y) {
    return new RooTFnPdfBinding(func->GetName(),func->GetName(),func,RooArgList(x,y)) ;
  }

  RooAbsPdf* bindPdf(TF3* func,RooAbsReal& x, RooAbsReal& y, RooAbsReal& z) {
    return new RooTFnPdfBinding(func->GetName(),func->GetName(),func,RooArgList(x,y,z)) ;
  }

}
