CLHEP VERSION Reference Documentation
CLHEP Home Page CLHEP Documentation CLHEP Bug Reports |
00001 // -*- C++ -*- 00002 // $Id: 00003 //-----------------------Class ParaToArgAdaptor-----------------------------// 00004 // // 00005 // Joe Boudreau // 00006 // June 2004 // 00007 // // 00008 // The purpose of this adaptor is to be able to create, starting FROM // 00009 // a function F of several variables and controlled by several parameters: // 00010 // // 00011 // F(alpha, beta, gamma....; x, y, z) // 00012 // // 00013 // a new function of several variables in which the parameter values are // 00014 // set by some of the variables. Application: event-per-event errors. // 00015 // // 00016 // Arguments to the adaptor: // 00017 // 1) The original generic function to adapt. // 00018 // 2) The symbolic expression to apply it to. // 00019 // 3) The name of a parameter to tweak. // 00020 // 4) The symbolic expression to tweak it with // 00021 // // 00022 //--------------------------------------------------------------------------// 00023 #ifndef _SYMTOARGADAPTOR_ 00024 #define _SYMTOARGADAPTOR_ 00025 #include <functional> 00026 #include <iostream> 00027 #include <string> 00028 #include "CLHEP/GenericFunctions/Parameter.hh" 00029 #include "CLHEP/GenericFunctions/AbsFunction.hh" 00030 00031 namespace Genfun { 00032 00033 template <class F> 00034 class SymToArgAdaptor : public AbsFunction { 00035 00036 FUNCTION_OBJECT_DEF(SymToArgAdaptor) 00037 00038 public: 00039 00040 // ScopedMethodName 00041 typedef Parameter & (F::*ScopedMethodPtr) (); 00042 00043 // Constructor 00044 SymToArgAdaptor( F & function, // A function. 00045 const AbsFunction & f_expression, // An expression to apply it to 00046 ScopedMethodPtr parameterFetchMethod, // A parameter. 00047 const AbsFunction * p_expression); // An expression for the parameter 00048 00049 // Copy constructor 00050 SymToArgAdaptor(const SymToArgAdaptor &right); 00051 00052 // Destructor 00053 virtual ~SymToArgAdaptor(); 00054 00055 // Retreive function value 00056 virtual double operator ()(double argument) const; // Gives an error. 00057 virtual double operator ()(const Argument & a) const; // Must use this one 00058 00059 // Dimensionality 00060 virtual unsigned int dimensionality() const; 00061 00062 private: 00063 00064 // It is illegal to assign an adjustable constant 00065 const SymToArgAdaptor & operator=(const SymToArgAdaptor &right); 00066 00067 // Here is the function being adapted; 00068 F *_function; 00069 00070 // A Variable (int an argument) to which the function is going to apply: 00071 const AbsFunction *_f_expression; 00072 00073 // Here is the recipe for fetching the parameter from the function: 00074 std::mem_fun_ref_t<Parameter &, F> _parameterFetchMethod; 00075 00076 // Here is the symbol to be connect to the parameter: 00077 const AbsFunction *_p_expression; 00078 00079 }; 00080 } // namespace Genfun 00081 #include "CLHEP/GenericFunctions/SymToArgAdaptor.icc" 00082 #endif 00083