CLHEP/GenericFunctions/ParamToArgAdaptor.hh

00001 // -*- C++ -*-
00002 // $Id: ParamToArgAdaptor.hh,v 1.4 2002/04/12 15:02:40 evc Exp $
00003 //-----------------------Class ParaToArgAdaptor-----------------------------//
00004 //                                                                          //
00005 //  Joe Boudreau                                                            //
00006 //  January 2000                                                            //
00007 //                                                                          //
00008 //  This class changes the interpretation of a function's PARAMETER and     //
00009 //  turns it into an argument.  In other words it makes a function like     //
00010 //                                                                          //
00011 //  F(a_0, a_1, a_2; x)                                                     //
00012 //                                                                          //
00013 //  and reinterprets it as                                                  //
00014 //                                                                          //
00015 //  F(a_0, a_2; x, a_1)                                                     //
00016 //                                                                          //
00017 //                                                                          //
00018 //--------------------------------------------------------------------------//
00019 #ifndef ParamToArgAdaptor_h_
00020 #define ParamToArgAdaptor_h_
00021 
00022 #include <functional>
00023 #include "CLHEP/config/CLHEP.h"
00024 #include "CLHEP/config/iostream.h"
00025 #include <string>
00026 #include "CLHEP/GenericFunctions/Parameter.hh"
00027 #include "CLHEP/GenericFunctions/AbsFunction.hh"
00028 
00029 namespace Genfun {
00030 
00035   template <class F> 
00036   class ParamToArgAdaptor : public AbsFunction  {
00037 
00038     FUNCTION_OBJECT_DEF(ParamToArgAdaptor)
00039 
00040       public:
00041 
00042     // ScopedMethodName
00043     typedef Parameter & (F::*ScopedMethodPtr) ();
00044 
00045     // Constructor
00046     ParamToArgAdaptor(const F & function,
00047                      ScopedMethodPtr parameterFetchMethod);
00048 
00049     // Copy constructor
00050     ParamToArgAdaptor(const ParamToArgAdaptor &right);
00051   
00052     // Destructor
00053     virtual ~ParamToArgAdaptor();
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     // Get the mean of the ParamToArgAdaptor
00063     Parameter & scaleFactor(); 
00064     const Parameter & scaleFactor() const; 
00065 
00066   
00067   private:
00068 
00069     // It is illegal to assign an adjustable constant
00070     const ParamToArgAdaptor & operator=(const ParamToArgAdaptor &right);
00071 
00072     // Here is the sigma
00073     Parameter _scaleFactor;
00074 
00075     // Here is the function being adapted;
00076     F *_function;
00077 
00078     // Here is the recipe for fetching the parameter from the function:
00079     std::mem_fun_ref_t<Parameter &, F> _parameterFetchMethod;
00080 
00081   };
00082 } // namespace Genfun
00083   #include "CLHEP/GenericFunctions/ParamToArgAdaptor.icc"
00084 #endif

Class Library for High Energy Physics (version 1.8)