RooCFunction1Binding.cxx

Go to the documentation of this file.
00001 /*****************************************************************************
00002  * Project: RooFit                                                           *
00003  * Package: RooFitCore                                                       *
00004  *    File: $Id: RooCFunction1Binding.cxx 25185 2008-08-20 14:00:42Z wouter $
00005  * Authors:                                                                  *
00006  *   WV, Wouter Verkerke, NIKHEF, verkerke@nikhef.nl                         *
00007  *                                                                           *
00008  * Copyright (c) 2000-2008, NIKHEF, Regents of the University of California  *
00009  *                          and Stanford University. All rights reserved.    *
00010  *                                                                           *
00011  *****************************************************************************/
00012 
00013 //////////////////////////////////////////////////////////////////////////////
00014 // 
00015 // BEGIN_HTML
00016 // RooCFunction1Binding is a templated implementation of class RooAbsReal that binds 
00017 // generic C(++) functions to a RooAbsReal argument thus allowing generic C++
00018 // functions to be used as RooFit functions. Instances of function binding
00019 // classes are fully functional RooFit function objects with one exception:
00020 // if the bound function is _not_ a standard TMath or MathMore function the
00021 // class cannot be persisted in a RooWorkspace without registering the function
00022 // pointer first using RooCFunction1Binding<T1,T2>::register().
00023 // END_HTML
00024 //
00025 
00026 #include "Riostream.h" 
00027 #include "RooCFunction1Binding.h" 
00028 #include "RooCintUtils.h"
00029 
00030 using namespace std ;
00031 
00032 #ifndef ROOFIT_R__NO_CLASS_TEMPLATE_SPECIALIZATION
00033 #define ROOFIT_R__NO_CLASS_TEMPLATE_SPECIALIZATION
00034 templateClassImp(RooCFunction1Binding) 
00035 templateClassImp(RooCFunction1Ref) 
00036 #endif 
00037 
00038 
00039 template<> RooCFunction1Map<double,double>* RooCFunction1Ref<double,double>::_fmap = 0 ;
00040 template<> RooCFunction1Map<double,int>* RooCFunction1Ref<double,int>::_fmap = 0 ;
00041 
00042 
00043 
00044 namespace RooFit {
00045 
00046   RooAbsReal* bindFunction(const char* name,void* func,RooAbsReal& x) 
00047   {
00048     // This function is for use in CINT, which does not properly handly
00049     // overloading on function pointer types, so we do it here explicitly
00050     if (RooCintUtils::matchFuncPtrArgs(func,"int")) return new RooCFunction1Binding<Double_t,Int_t>(name,name,(CFUNCD1I)func,x) ;
00051     if (RooCintUtils::matchFuncPtrArgs(func,"double")) return new RooCFunction1Binding<Double_t,Double_t>(name,name,(CFUNCD1D)func,x) ;
00052     oocoutE((TObject*)0,InputArguments) << "bindFunction::ERROR No matching RooCFunction1Binding<> class found for function " << RooCintUtils::functionName(func) << endl ;
00053     return 0 ;
00054   }
00055 
00056 
00057   RooAbsReal* bindFunction(const char* name,CFUNCD1D func,RooAbsReal& x) {
00058     return new RooCFunction1Binding<Double_t,Double_t>(name,name,func,x) ;
00059   }
00060 
00061   RooAbsReal* bindFunction(const char* name,CFUNCD1I func,RooAbsReal& x) {
00062     return new RooCFunction1Binding<Double_t,Int_t>(name,name,func,x) ;
00063   }
00064 
00065   RooAbsPdf* bindPdf(const char* name,void* func,RooAbsReal& x) 
00066   {
00067     // This function is for use in CINT, which does not properly handly
00068     // overloading on function pointer types, so we do it here explicitly
00069     if (RooCintUtils::matchFuncPtrArgs(func,"int")) return new RooCFunction1PdfBinding<Double_t,Int_t>(name,name,(CFUNCD1I)func,x) ;
00070     if (RooCintUtils::matchFuncPtrArgs(func,"double")) return new RooCFunction1PdfBinding<Double_t,Double_t>(name,name,(CFUNCD1D)func,x) ;
00071     oocoutE((TObject*)0,InputArguments) << "bindFunction::ERROR No matching RooCFunction1PdfBinding<> class found for function " << RooCintUtils::functionName(func) << endl ;
00072     return 0 ;
00073   }
00074 
00075 
00076   RooAbsPdf* bindPdf(const char* name,CFUNCD1D func,RooAbsReal& x) {
00077     return new RooCFunction1PdfBinding<Double_t,Double_t>(name,name,func,x) ;
00078   }
00079 
00080   RooAbsPdf* bindPdf(const char* name,CFUNCD1I func,RooAbsReal& x) {
00081     return new RooCFunction1PdfBinding<Double_t,Int_t>(name,name,func,x) ;
00082   }
00083 
00084 }
00085 
00086 
00087 

Generated on Tue Jul 5 14:54:39 2011 for ROOT_528-00b_version by  doxygen 1.5.1