/*****************************************************************************
 * Project: RooFit                                                           *
 * Package: RooFitCore                                                       *
 *    File: $Id$
 * Authors:                                                                  *
 *   WV, Wouter Verkerke, NIKHEF, verkerke@nikhef.nl                         *
 *                                                                           *
 * Copyright (c) 2000-2008, NIKHEF, Regents of the University of California  *
 *                          and Stanford University. All rights reserved.    *
 *                                                                           *
 *****************************************************************************/

#ifndef ROOFUNCTORBINDING
#define ROOFUNCTORBINDING

#include "TString.h"
#include "RooAbsReal.h"
#include "RooArgList.h"
#include "RooListProxy.h"
#include "RooAbsPdf.h"
#include "RooRealProxy.h"
#include "RooMsgService.h"
#include <string>
#include <map>
#include <vector>
#include "Math/IFunction.h"


namespace RooFit {

RooAbsReal* bindFunction(const char* name, const ROOT::Math::IBaseFunctionMultiDim& ftor,const RooArgList& vars) ;
RooAbsPdf*  bindPdf(const char* name, const ROOT::Math::IBaseFunctionMultiDim& ftor, const RooArgList& vars) ;

}


class RooFunctorBinding : public RooAbsReal {
public:
  RooFunctorBinding() : func(0), x(0) {
    // Default constructor
  } ; 
  RooFunctorBinding(const char *name, const char *title, const ROOT::Math::IBaseFunctionMultiDim& ftor, const RooArgList& vars);
  RooFunctorBinding(const RooFunctorBinding& other, const char* name=0) ;
  virtual TObject* clone(const char* newname) const { return new RooFunctorBinding(*this,newname); }
  inline virtual ~RooFunctorBinding() { delete[] x ; }
  void printArgs(std::ostream& os) const ;

protected:

  Double_t evaluate() const ;

  const ROOT::Math::IBaseFunctionMultiDim* func ;    // Functor
  RooListProxy                       vars ;    // Argument reference
  Double_t*                           x ; // Argument value array
  

private:

  ClassDef(RooFunctorBinding,1) // RooAbsReal binding to a ROOT::Math::IBaseFunctionMultiDim
};



class RooFunctorPdfBinding : public RooAbsPdf {
public:
  RooFunctorPdfBinding() : func(0), x(0) {
    // Default constructor
  } ; 
  RooFunctorPdfBinding(const char *name, const char *title, const ROOT::Math::IBaseFunctionMultiDim& ftor, const RooArgList& vars);
  RooFunctorPdfBinding(const RooFunctorPdfBinding& other, const char* name=0) ;
  virtual TObject* clone(const char* newname) const { return new RooFunctorPdfBinding(*this,newname); }
  inline virtual ~RooFunctorPdfBinding() { delete[] x ; }
  void printArgs(std::ostream& os) const ;

protected:

  Double_t evaluate() const ;

  const ROOT::Math::IBaseFunctionMultiDim* func ;    // Functor
  RooListProxy                       vars ;    // Argument reference
  Double_t*                             x ; // Argument value array
  

private:

  ClassDef(RooFunctorPdfBinding,1) // RooAbsPdf binding to a ROOT::Math::IBaseFunctionMultiDim
};


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