ROOT logo
/*****************************************************************************
 * Project: RooFit                                                           *
 * Package: RooFitCore                                                       *
 *    File: $Id: RooCFunction2Binding.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
// RooCFunction2Binding 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 RooCFunction2Binding<T1,T2,T3>::register().
// END_HTML
//

#include "Riostream.h" 
#include "RooCFunction2Binding.h" 
#include "RooCintUtils.h"

using namespace std ;

#ifndef ROOFIT_R__NO_CLASS_TEMPLATE_SPECIALIZATION
#define ROOFIT_R__NO_CLASS_TEMPLATE_SPECIALIZATION
templateClassImp(RooCFunction2Binding) 
templateClassImp(RooCFunction2Ref) 
#endif 


template<> RooCFunction2Map<double,double,double>* RooCFunction2Ref<double,double,double>::_fmap = 0 ;
template<> RooCFunction2Map<double,int,double> *RooCFunction2Ref<double,int,double>::_fmap = 0 ;
template<> RooCFunction2Map<double,unsigned int,double> *RooCFunction2Ref<double,unsigned int,double>::_fmap = 0 ;
template<> RooCFunction2Map<double,double,int> *RooCFunction2Ref<double,double,int>::_fmap = 0 ;
template<> RooCFunction2Map<double,int,int> *RooCFunction2Ref<double,int,int>::_fmap = 0 ;


namespace RooFit {

  RooAbsReal* bindFunction(const char* name,void* func,RooAbsReal& x, RooAbsReal& y) {
    // 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")) return new RooCFunction2Binding<Double_t,Double_t,Double_t>(name,name,(CFUNCD2DD)func,x,y) ;
    if (RooCintUtils::matchFuncPtrArgs(func,"int,double")) return new RooCFunction2Binding<Double_t,Int_t,Double_t>(name,name,(CFUNCD2ID)func,x,y) ;
    if (RooCintUtils::matchFuncPtrArgs(func,"unsigned int,double")) return new RooCFunction2Binding<Double_t,UInt_t,Double_t>(name,name,(CFUNCD2UD)func,x,y) ;
    if (RooCintUtils::matchFuncPtrArgs(func,"double,int")) return new RooCFunction2Binding<Double_t,Double_t,Int_t>(name,name,(CFUNCD2DI)func,x,y) ;
    if (RooCintUtils::matchFuncPtrArgs(func,"int,int")) return new RooCFunction2Binding<Double_t,Int_t,Int_t>(name,name,(CFUNCD2II)func,x,y) ;
    oocoutE((TObject*)0,InputArguments) << "bindFunction::ERROR No matching RooCFunction2Binding<> class found for function " << RooCintUtils::functionName(func) << endl ;
    return 0 ;
  }

  RooAbsReal* bindFunction(const char* name,CFUNCD2DD func,RooAbsReal& x, RooAbsReal& y) {
    return new RooCFunction2Binding<Double_t,Double_t,Double_t>(name,name,func,x,y) ;
  }

  RooAbsReal* bindFunction(const char* name,CFUNCD2ID func,RooAbsReal& x, RooAbsReal& y) {
    return new RooCFunction2Binding<Double_t,Int_t,Double_t>(name,name,func,x,y) ;
  }

  RooAbsReal* bindFunction(const char* name,CFUNCD2UD func,RooAbsReal& x, RooAbsReal& y) {
    return new RooCFunction2Binding<Double_t,UInt_t,Double_t>(name,name,func,x,y) ;
  }

  RooAbsReal* bindFunction(const char* name,CFUNCD2DI func,RooAbsReal& x, RooAbsReal& y) {
    return new RooCFunction2Binding<Double_t,Double_t,Int_t>(name,name,func,x,y) ;
  }

  RooAbsReal* bindFunction(const char* name,CFUNCD2II func,RooAbsReal& x, RooAbsReal& y) {
    return new RooCFunction2Binding<Double_t,Int_t,Int_t>(name,name,func,x,y) ;
  }

  RooAbsPdf* bindPdf(const char* name,void* func,RooAbsReal& x, RooAbsReal& y) {
    // 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")) return new RooCFunction2PdfBinding<Double_t,Double_t,Double_t>(name,name,(CFUNCD2DD)func,x,y) ;
    if (RooCintUtils::matchFuncPtrArgs(func,"int,double")) return new RooCFunction2PdfBinding<Double_t,Int_t,Double_t>(name,name,(CFUNCD2ID)func,x,y) ;
    if (RooCintUtils::matchFuncPtrArgs(func,"unsigned int,double")) return new RooCFunction2PdfBinding<Double_t,UInt_t,Double_t>(name,name,(CFUNCD2UD)func,x,y) ;
    if (RooCintUtils::matchFuncPtrArgs(func,"double,int")) return new RooCFunction2PdfBinding<Double_t,Double_t,Int_t>(name,name,(CFUNCD2DI)func,x,y) ;
    if (RooCintUtils::matchFuncPtrArgs(func,"int,int")) return new RooCFunction2PdfBinding<Double_t,Int_t,Int_t>(name,name,(CFUNCD2II)func,x,y) ;
    oocoutE((TObject*)0,InputArguments) << "bindPdf::ERROR No matching RooCFunction2PdfBinding<> class found for function " << RooCintUtils::functionName(func) << endl ;
    return 0 ;
  }

  RooAbsPdf* bindPdf(const char* name,CFUNCD2DD func,RooAbsReal& x, RooAbsReal& y) {
    return new RooCFunction2PdfBinding<Double_t,Double_t,Double_t>(name,name,func,x,y) ;
  }

  RooAbsPdf* bindPdf(const char* name,CFUNCD2ID func,RooAbsReal& x, RooAbsReal& y) {
    return new RooCFunction2PdfBinding<Double_t,Int_t,Double_t>(name,name,func,x,y) ;
  }

  RooAbsPdf* bindPdf(const char* name,CFUNCD2UD func,RooAbsReal& x, RooAbsReal& y) {
    return new RooCFunction2PdfBinding<Double_t,UInt_t,Double_t>(name,name,func,x,y) ;
  }

  RooAbsPdf* bindPdf(const char* name,CFUNCD2DI func,RooAbsReal& x, RooAbsReal& y) {
    return new RooCFunction2PdfBinding<Double_t,Double_t,Int_t>(name,name,func,x,y) ;
  }

  RooAbsPdf* bindPdf(const char* name,CFUNCD2II func,RooAbsReal& x, RooAbsReal& y) {
    return new RooCFunction2PdfBinding<Double_t,Int_t,Int_t>(name,name,func,x,y) ;
  }

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