Go to the documentation of this file.00001 #ifndef PhysicsTools_Utilities_RootFunctionHelper_h
00002 #define PhysicsTools_Utilities_RootFunctionHelper_h
00003
00004
00005
00006
00007
00008 #include "PhysicsTools/Utilities/interface/RootFunctionAdapter.h"
00009
00010 namespace root {
00011 namespace helper {
00012 struct null_t;
00013
00014 template<typename F, unsigned int args, typename Tag = null_t>
00015 struct RootFunctionHelper {
00016 typedef double (*root_function)(const double *, const double *);
00017 static root_function fun(F& f) {
00018 adapter_ = RootFunctionAdapter<F, args>(f);
00019 return &fun_;
00020 }
00021 static void addParameter(const boost::shared_ptr<double> & par) {
00022 adapter_.addParameter(par);
00023 }
00024 private:
00025 static double fun_(const double * x, const double * par) {
00026 adapter_.setParameters(par);
00027 return adapter_(x);
00028 }
00029 static RootFunctionAdapter<F, args> adapter_;
00030 };
00031
00032 template<typename F, unsigned int args, typename Tag>
00033 RootFunctionAdapter<F, args> RootFunctionHelper<F, args, Tag>::adapter_;
00034 }
00035 }
00036
00037 #endif