ROOT logo
/*****************************************************************************
 * Project: RooFit                                                           *
 * Package: RooFitCore                                                       *
 *    File: $Id: RooCFunction4Binding.cxx 25185 2008-08-20 14:00:42Z wouter $
 * 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.    *
 *                                                                           *
 *****************************************************************************/

//////////////////////////////////////////////////////////////////////////////
// 
// BEGIN_HTML
// RooCFunction4Binding is a templated implementation of class RooAbsReal that binds 
// generic C(++) functions to a RooAbsReal argument thus allowing generic C++
// functions to be used as RooFit functions. Instances of function binding
// classes are fully functional RooFit function objects with one exception:
// if the bound function is _not_ a standard TMath or MathMore function the
// class cannot be persisted in a RooWorkspace without registering the function
// pointer first using RooCFunction4Binding<T1,T2,T3,T4>::register().
// END_HTML
//

#include "Riostream.h" 
#include "RooCFunction4Binding.h" 
#include "RooCintUtils.h"

using namespace std ;

#ifndef ROOFIT_R__NO_CLASS_TEMPLATE_SPECIALIZATION
#define ROOFIT_R__NO_CLASS_TEMPLATE_SPECIALIZATION
templateClassImp(RooCFunction4Binding) 
templateClassImp(RooCFunction4Ref) 
#endif 


template<> RooCFunction4Map<double,double,double,double,double>* RooCFunction4Ref<double,double,double,double,double>::_fmap = 0 ;
template<> RooCFunction4Map<double,double,double,double,int>* RooCFunction4Ref<double,double,double,double,int>::_fmap = 0 ;
template<> RooCFunction4Map<double,double,double,double,bool>* RooCFunction4Ref<double,double,double,double,bool>::_fmap = 0 ;


namespace RooFit {

  RooAbsReal* bindFunction(const char* name,void* func,RooAbsReal& x, RooAbsReal& y, RooAbsReal& z, RooAbsReal& w) {
    // This function is for use in CINT, which does not properly handly
    // overloading on function pointer types, so we do it here explicitly
    if (RooCintUtils::matchFuncPtrArgs(func,"double,double,double,double")) return new RooCFunction4Binding<Double_t,Double_t,Double_t,Double_t,Double_t>(name,name,(CFUNCD4DDDD)func,x,y,z,w) ;
    if (RooCintUtils::matchFuncPtrArgs(func,"double,double,double,int")) return new RooCFunction4Binding<Double_t,Double_t,Double_t,Double_t,Int_t>(name,name,(CFUNCD4DDDI)func,x,y,z,w) ;
    if (RooCintUtils::matchFuncPtrArgs(func,"double,double,double,bool")) return new RooCFunction4Binding<Double_t,Double_t,Double_t,Double_t,Bool_t>(name,name,(CFUNCD4DDDB)func,x,y,z,w) ;
    oocoutE((TObject*)0,InputArguments) << "bindFunction::ERROR No matching RooCFunction4Binding<> class found for function " << RooCintUtils::functionName(func) << endl ;
    return 0 ;
  }


  RooAbsReal* bindFunction(const char* name,CFUNCD4DDDD func,RooAbsReal& x, RooAbsReal& y, RooAbsReal& z, RooAbsReal& w) {
    return new RooCFunction4Binding<Double_t,Double_t,Double_t,Double_t,Double_t>(name,name,func,x,y,z,w) ;
  }

  RooAbsReal* bindFunction(const char* name,CFUNCD4DDDI func,RooAbsReal& x, RooAbsReal& y, RooAbsReal& z, RooAbsReal& w) {
    return new RooCFunction4Binding<Double_t,Double_t,Double_t,Double_t,Int_t>(name,name,func,x,y,z,w) ;
  }

  RooAbsReal* bindFunction(const char* name,CFUNCD4DDDB func,RooAbsReal& x, RooAbsReal& y, RooAbsReal& z, RooAbsReal& w) {
    return new RooCFunction4Binding<Double_t,Double_t,Double_t,Double_t,Bool_t>(name,name,func,x,y,z,w) ;
  }


  RooAbsPdf* bindPdf(const char* name,void* func,RooAbsReal& x, RooAbsReal& y, RooAbsReal& z, RooAbsReal& w) {
    // This function is for use in CINT, which does not properly handly
    // overloading on function pointer types, so we do it here explicitly
    if (RooCintUtils::matchFuncPtrArgs(func,"double,double,double,double")) return new RooCFunction4PdfBinding<Double_t,Double_t,Double_t,Double_t,Double_t>(name,name,(CFUNCD4DDDD)func,x,y,z,w) ;
    if (RooCintUtils::matchFuncPtrArgs(func,"double,double,double,int")) return new RooCFunction4PdfBinding<Double_t,Double_t,Double_t,Double_t,Int_t>(name,name,(CFUNCD4DDDI)func,x,y,z,w) ;
    if (RooCintUtils::matchFuncPtrArgs(func,"double,double,double,bool")) return new RooCFunction4PdfBinding<Double_t,Double_t,Double_t,Double_t,Bool_t>(name,name,(CFUNCD4DDDB)func,x,y,z,w) ;
    oocoutE((TObject*)0,InputArguments) << "bindPdf::ERROR No matching RooCFunction4PdfBinding<> class found for function " << RooCintUtils::functionName(func) << endl ;
    return 0 ;
  }


  RooAbsPdf* bindPdf(const char* name,CFUNCD4DDDD func,RooAbsReal& x, RooAbsReal& y, RooAbsReal& z, RooAbsReal& w) {
    return new RooCFunction4PdfBinding<Double_t,Double_t,Double_t,Double_t,Double_t>(name,name,func,x,y,z,w) ;
  }

  RooAbsPdf* bindPdf(const char* name,CFUNCD4DDDI func,RooAbsReal& x, RooAbsReal& y, RooAbsReal& z, RooAbsReal& w) {
    return new RooCFunction4PdfBinding<Double_t,Double_t,Double_t,Double_t,Int_t>(name,name,func,x,y,z,w) ;
  }

  RooAbsPdf* bindPdf(const char* name,CFUNCD4DDDB func,RooAbsReal& x, RooAbsReal& y, RooAbsReal& z, RooAbsReal& w) {
    return new RooCFunction4PdfBinding<Double_t,Double_t,Double_t,Double_t,Bool_t>(name,name,func,x,y,z,w) ;
  }

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