Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-01-18 09:54:35

0001 // -*- C++ -*-
0002 // $Id: ParamToArgAdaptor.hh,v 1.2 2003/09/06 14:04:13 boudreau Exp $
0003 //-----------------------Class ParaToArgAdaptor-----------------------------//
0004 //                                                                          //
0005 //  Joe Boudreau                                                            //
0006 //  January 2000                                                            //
0007 //                                                                          //
0008 //  This class changes the interpretation of a function's PARAMETER and     //
0009 //  turns it into an argument.  In other words it makes a function like     //
0010 //                                                                          //
0011 //  F(a_0, a_1, a_2; x)                                                     //
0012 //                                                                          //
0013 //  and reinterprets it as                                                  //
0014 //                                                                          //
0015 //  F(a_0, a_2; x, a_1)                                                     //
0016 //                                                                          //
0017 //                                                                          //
0018 //--------------------------------------------------------------------------//
0019 #ifndef ParamToArgAdaptor_h_
0020 #define ParamToArgAdaptor_h_
0021 
0022 #include <functional>
0023 #include <iostream>
0024 #include <string>
0025 #include "CLHEP/GenericFunctions/Parameter.hh"
0026 #include "CLHEP/GenericFunctions/AbsFunction.hh"
0027 
0028 namespace Genfun {
0029 
0030   /**
0031    * @author
0032    * @ingroup genfun
0033    */
0034   template <class F> 
0035   class ParamToArgAdaptor : public AbsFunction  {
0036 
0037     FUNCTION_OBJECT_DEF(ParamToArgAdaptor)
0038 
0039       public:
0040 
0041     // ScopedMethodName
0042     typedef Parameter & (F::*ScopedMethodPtr) ();
0043 
0044     // Constructor
0045     ParamToArgAdaptor(const F & function,
0046              ScopedMethodPtr parameterFetchMethod);
0047 
0048     // Copy constructor
0049     ParamToArgAdaptor(const ParamToArgAdaptor &right);
0050   
0051     // Destructor
0052     virtual ~ParamToArgAdaptor();
0053   
0054     // Retreive function value
0055     virtual double operator ()(double argument) const override;    // Gives an error.
0056     virtual double operator ()(const Argument & a) const override; // Must use this one
0057 
0058     // Dimensionality
0059     virtual unsigned int dimensionality() const override;
0060 
0061     // Get the mean of the ParamToArgAdaptor
0062     Parameter & scaleFactor(); 
0063     const Parameter & scaleFactor() const; 
0064 
0065   
0066   private:
0067 
0068     // It is illegal to assign an adjustable constant
0069     const ParamToArgAdaptor & operator=(const ParamToArgAdaptor &right);
0070 
0071     // Here is the sigma
0072     Parameter _scaleFactor;
0073 
0074     // Here is the function being adapted;
0075     F *_function;
0076 
0077     // Here is the recipe for fetching the parameter from the function:
0078     std::mem_fun_ref_t<Parameter &, F> _parameterFetchMethod;
0079 
0080   };
0081 } // namespace Genfun
0082   #include "CLHEP/GenericFunctions/ParamToArgAdaptor.icc"
0083 #endif