CLHEP/GenericFunctions/DoubleParamToArgAdaptor.hh

00001 // -*- C++ -*-
00002 // $Id: DoubleParamToArgAdaptor.hh,v 1.4 2002/04/12 15:02:39 evc Exp $
00003 //-----------------------Class ParaToArgAdaptor-----------------------------//
00004 //                                                                          //
00005 //  Joe Boudreau                                                            //
00006 //  January 2000                                                            //
00007 //                                                                          //
00008 //  This class changes the interpretation of two  PARAMETERs to a function  //
00009 //  connects them to a single argument, with scale factors controlling how  //
00010 //  the argument is increased before it is used to adjust the parameter.    //
00011 //  In other words it makes a function like     //
00012 //                                                                          //
00013 //  F(a_0, a_1, a_2; x)                                                     //
00014 //                                                                          //
00015 //  and reinterprets it as                                                  //
00016 //                                                                          //
00017 //  F(a_0; x, a_1)                                                          //
00018 //                                                                          //
00019 //                                                                          //
00020 //--------------------------------------------------------------------------//
00021 #ifndef DoubleParamToArgAdaptor_h_
00022 #define DoubleParamToArgAdaptor_h_
00023 
00024 #include <functional>
00025 #include "CLHEP/config/CLHEP.h"
00026 #include "CLHEP/config/iostream.h"
00027 #include <string>
00028 #include "CLHEP/GenericFunctions/Parameter.hh"
00029 #include "CLHEP/GenericFunctions/AbsFunction.hh"
00030 
00031 namespace Genfun {
00032 
00037   template <class F> 
00038   class DoubleParamToArgAdaptor : public AbsFunction  {
00039 
00040     FUNCTION_OBJECT_DEF(DoubleParamToArgAdaptor)
00041 
00042       public:
00043 
00044     // ScopedMethodName
00045     typedef Parameter & (F::*ScopedMethodPtr) ();
00046 
00047     // Constructor
00048     DoubleParamToArgAdaptor(const F & function,
00049                      ScopedMethodPtr parameterFetchMethod0,
00050                      ScopedMethodPtr paraemterFetchMethod1);
00051 
00052     // Copy constructor
00053     DoubleParamToArgAdaptor(const DoubleParamToArgAdaptor &right);
00054   
00055     // Destructor
00056     virtual ~DoubleParamToArgAdaptor();
00057   
00058     // Retreive function value
00059     virtual double operator ()(double argument) const;    // Gives an error.
00060     virtual double operator ()(const Argument & a) const; // Must use this one
00061 
00062     // Dimensionality
00063     virtual unsigned int dimensionality() const;
00064 
00065     // Get the mean of the DoubleParamToArgAdaptor
00066     Parameter & scaleFactor0(); 
00067     const Parameter & scaleFactor0() const; 
00068 
00069     // Get the mean of the DoubleParamToArgAdaptor
00070     Parameter & scaleFactor1(); 
00071     const Parameter & scaleFactor1() const; 
00072 
00073   
00074   private:
00075 
00076     // It is illegal to assign an adjustable constant
00077     const DoubleParamToArgAdaptor & operator=(const DoubleParamToArgAdaptor &right);
00078 
00079     // Here is the scale:
00080     Parameter _scaleFactor0;
00081     Parameter _scaleFactor1;
00082 
00083     // Here is the function being adapted;
00084     F *_function;
00085 
00086     // Here is the recipe for fetching the parameter from the function:
00087     std::mem_fun_ref_t<Parameter &, F> _parameterFetchMethod0;
00088     std::mem_fun_ref_t<Parameter &, F> _parameterFetchMethod1;
00089 
00090   };
00091 } // namespace Genfun
00092   #include "CLHEP/GenericFunctions/DoubleParamToArgAdaptor.icc"
00093 #endif

Class Library for High Energy Physics (version 1.8)