Back to home page

EIC code displayed by LXR

 
 

    


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

0001 // -*- C++ -*-
0002 // $Id: DoubleParamToArgAdaptor.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 two  PARAMETERs to a function  //
0009 //  connects them to a single argument, with scale factors controlling how  //
0010 //  the argument is increased before it is used to adjust the parameter.    //
0011 //  In other words it makes a function like     //
0012 //                                                                          //
0013 //  F(a_0, a_1, a_2; x)                                                     //
0014 //                                                                          //
0015 //  and reinterprets it as                                                  //
0016 //                                                                          //
0017 //  F(a_0; x, a_1)                                                          //
0018 //                                                                          //
0019 //                                                                          //
0020 //--------------------------------------------------------------------------//
0021 #ifndef DoubleParamToArgAdaptor_h_
0022 #define DoubleParamToArgAdaptor_h_
0023 
0024 #include <functional>
0025 #include <iostream>
0026 #include <string>
0027 #include "CLHEP/GenericFunctions/Parameter.hh"
0028 #include "CLHEP/GenericFunctions/AbsFunction.hh"
0029 
0030 namespace Genfun {
0031 
0032   /**
0033    * @author
0034    * @ingroup genfun
0035    */
0036   template <class F> 
0037   class DoubleParamToArgAdaptor : public AbsFunction  {
0038 
0039     FUNCTION_OBJECT_DEF(DoubleParamToArgAdaptor)
0040 
0041       public:
0042 
0043     // ScopedMethodName
0044     typedef Parameter & (F::*ScopedMethodPtr) ();
0045 
0046     // Constructor
0047     DoubleParamToArgAdaptor(const F & function,
0048              ScopedMethodPtr parameterFetchMethod0,
0049                      ScopedMethodPtr paraemterFetchMethod1);
0050 
0051     // Copy constructor
0052     DoubleParamToArgAdaptor(const DoubleParamToArgAdaptor &right);
0053   
0054     // Destructor
0055     virtual ~DoubleParamToArgAdaptor();
0056   
0057     // Retreive function value
0058     virtual double operator ()(double argument) const override;    // Gives an error.
0059     virtual double operator ()(const Argument & a) const override; // Must use this one
0060 
0061     // Dimensionality
0062     virtual unsigned int dimensionality() const override;
0063 
0064     // Get the mean of the DoubleParamToArgAdaptor
0065     Parameter & scaleFactor0(); 
0066     const Parameter & scaleFactor0() const; 
0067 
0068     // Get the mean of the DoubleParamToArgAdaptor
0069     Parameter & scaleFactor1(); 
0070     const Parameter & scaleFactor1() const; 
0071 
0072   
0073   private:
0074 
0075     // It is illegal to assign an adjustable constant
0076     const DoubleParamToArgAdaptor & operator=(const DoubleParamToArgAdaptor &right);
0077 
0078     // Here is the scale:
0079     Parameter _scaleFactor0;
0080     Parameter _scaleFactor1;
0081 
0082     // Here is the function being adapted;
0083     F *_function;
0084 
0085     // Here is the recipe for fetching the parameter from the function:
0086     std::mem_fun_ref_t<Parameter &, F> _parameterFetchMethod0;
0087     std::mem_fun_ref_t<Parameter &, F> _parameterFetchMethod1;
0088 
0089   };
0090 } // namespace Genfun
0091   #include "CLHEP/GenericFunctions/DoubleParamToArgAdaptor.icc"
0092 #endif