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

// Your description goes here...

#include "Riostream.h" 

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

using namespace std;

ClassImp(RooTFnBinding) 

RooTFnBinding::RooTFnBinding(const char *name, const char *title, TF1* func, const RooArgList& list) :
  RooAbsReal(name,title), 
  _olist("obs","obs",this),
  _func(func)
{ 
  _olist.add(list) ;
} 


RooTFnBinding::RooTFnBinding(const char *name, const char *title, TF1* func, const RooArgList& obsList, const RooArgList& paramList) :
  RooAbsReal(name,title), 
  _olist("obs","obs",this),
  _plist("params","params",this),
  _func(func)
{ 
  _olist.add(obsList) ;
  _plist.add(paramList) ;
} 


RooTFnBinding::RooTFnBinding(const RooTFnBinding& other, const char* name) :  
  RooAbsReal(other,name), 
  _olist("obs",this,other._olist),
  _plist("params",this,other._plist),
  _func(other._func)
{ 
} 



Double_t RooTFnBinding::evaluate() const 
{ 
  Double_t x = _olist.at(0) ? ((RooAbsReal*)_olist.at(0))->getVal() : 0 ;
  Double_t y = _olist.at(1) ? ((RooAbsReal*)_olist.at(1))->getVal() : 0 ;
  Double_t z = _olist.at(2) ? ((RooAbsReal*)_olist.at(2))->getVal() : 0 ;
  for (Int_t i=0 ; i<_func->GetNpar() ; i++) {
    _func->SetParameter(i,_plist.at(i)?((RooAbsReal*)_plist.at(i))->getVal() : 0) ;
  }
  return _func->Eval(x,y,z) ;
} 



void RooTFnBinding::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 {

  RooAbsReal* bindFunction(TF1* func,RooAbsReal& x) {
    return new RooTFnBinding(func->GetName(),func->GetTitle(),func,x) ;
  }

  RooAbsReal* bindFunction(TF2* func,RooAbsReal& x, RooAbsReal& y) {
    return new RooTFnBinding(func->GetName(),func->GetTitle(),func,RooArgList(x,y)) ;
  }

  RooAbsReal* bindFunction(TF3* func,RooAbsReal& x, RooAbsReal& y, RooAbsReal& z) {
    return new RooTFnBinding(func->GetName(),func->GetTitle(),func,RooArgList(x,y,z)) ;
  }

  RooAbsReal* bindFunction(TF1* func,RooAbsReal& x, const RooArgList& params) {
    return new RooTFnBinding(func->GetName(),func->GetTitle(),func,x,params) ;
  }

  RooAbsReal* bindFunction(TF2* func,RooAbsReal& x, RooAbsReal& y, const RooArgList& params) {
    return new RooTFnBinding(func->GetName(),func->GetTitle(),func,RooArgList(x,y),params) ;
  }

  RooAbsReal* bindFunction(TF3* func,RooAbsReal& x, RooAbsReal& y, RooAbsReal& z, const RooArgList& params) {
    return new RooTFnBinding(func->GetName(),func->GetTitle(),func,RooArgList(x,y,z),params) ;
  }

}
 RooTFnBinding.cxx:1
 RooTFnBinding.cxx:2
 RooTFnBinding.cxx:3
 RooTFnBinding.cxx:4
 RooTFnBinding.cxx:5
 RooTFnBinding.cxx:6
 RooTFnBinding.cxx:7
 RooTFnBinding.cxx:8
 RooTFnBinding.cxx:9
 RooTFnBinding.cxx:10
 RooTFnBinding.cxx:11
 RooTFnBinding.cxx:12
 RooTFnBinding.cxx:13
 RooTFnBinding.cxx:14
 RooTFnBinding.cxx:15
 RooTFnBinding.cxx:16
 RooTFnBinding.cxx:17
 RooTFnBinding.cxx:18
 RooTFnBinding.cxx:19
 RooTFnBinding.cxx:20
 RooTFnBinding.cxx:21
 RooTFnBinding.cxx:22
 RooTFnBinding.cxx:23
 RooTFnBinding.cxx:24
 RooTFnBinding.cxx:25
 RooTFnBinding.cxx:26
 RooTFnBinding.cxx:27
 RooTFnBinding.cxx:28
 RooTFnBinding.cxx:29
 RooTFnBinding.cxx:30
 RooTFnBinding.cxx:31
 RooTFnBinding.cxx:32
 RooTFnBinding.cxx:33
 RooTFnBinding.cxx:34
 RooTFnBinding.cxx:35
 RooTFnBinding.cxx:36
 RooTFnBinding.cxx:37
 RooTFnBinding.cxx:38
 RooTFnBinding.cxx:39
 RooTFnBinding.cxx:40
 RooTFnBinding.cxx:41
 RooTFnBinding.cxx:42
 RooTFnBinding.cxx:43
 RooTFnBinding.cxx:44
 RooTFnBinding.cxx:45
 RooTFnBinding.cxx:46
 RooTFnBinding.cxx:47
 RooTFnBinding.cxx:48
 RooTFnBinding.cxx:49
 RooTFnBinding.cxx:50
 RooTFnBinding.cxx:51
 RooTFnBinding.cxx:52
 RooTFnBinding.cxx:53
 RooTFnBinding.cxx:54
 RooTFnBinding.cxx:55
 RooTFnBinding.cxx:56
 RooTFnBinding.cxx:57
 RooTFnBinding.cxx:58
 RooTFnBinding.cxx:59
 RooTFnBinding.cxx:60
 RooTFnBinding.cxx:61
 RooTFnBinding.cxx:62
 RooTFnBinding.cxx:63
 RooTFnBinding.cxx:64
 RooTFnBinding.cxx:65
 RooTFnBinding.cxx:66
 RooTFnBinding.cxx:67
 RooTFnBinding.cxx:68
 RooTFnBinding.cxx:69
 RooTFnBinding.cxx:70
 RooTFnBinding.cxx:71
 RooTFnBinding.cxx:72
 RooTFnBinding.cxx:73
 RooTFnBinding.cxx:74
 RooTFnBinding.cxx:75
 RooTFnBinding.cxx:76
 RooTFnBinding.cxx:77
 RooTFnBinding.cxx:78
 RooTFnBinding.cxx:79
 RooTFnBinding.cxx:80
 RooTFnBinding.cxx:81
 RooTFnBinding.cxx:82
 RooTFnBinding.cxx:83
 RooTFnBinding.cxx:84
 RooTFnBinding.cxx:85
 RooTFnBinding.cxx:86
 RooTFnBinding.cxx:87
 RooTFnBinding.cxx:88
 RooTFnBinding.cxx:89
 RooTFnBinding.cxx:90
 RooTFnBinding.cxx:91
 RooTFnBinding.cxx:92
 RooTFnBinding.cxx:93
 RooTFnBinding.cxx:94
 RooTFnBinding.cxx:95
 RooTFnBinding.cxx:96
 RooTFnBinding.cxx:97
 RooTFnBinding.cxx:98
 RooTFnBinding.cxx:99
 RooTFnBinding.cxx:100
 RooTFnBinding.cxx:101
 RooTFnBinding.cxx:102
 RooTFnBinding.cxx:103
 RooTFnBinding.cxx:104