CLHEP VERSION Reference Documentation
   
CLHEP Home Page     CLHEP Documentation     CLHEP Bug Reports

GenericFunctions/SymToArgAdaptor.hh
Go to the documentation of this file.
1 // -*- C++ -*-
2 // $Id:
3 //-----------------------Class ParaToArgAdaptor-----------------------------//
4 // //
5 // Joe Boudreau //
6 // June 2004 //
7 // //
8 // The purpose of this adaptor is to be able to create, starting FROM //
9 // a function F of several variables and controlled by several parameters: //
10 // //
11 // F(alpha, beta, gamma....; x, y, z) //
12 // //
13 // a new function of several variables in which the parameter values are //
14 // set by some of the variables. Application: event-per-event errors. //
15 // //
16 // Arguments to the adaptor: //
17 // 1) The original generic function to adapt. //
18 // 2) The symbolic expression to apply it to. //
19 // 3) The name of a parameter to tweak. //
20 // 4) The symbolic expression to tweak it with //
21 // //
22 //--------------------------------------------------------------------------//
23 #ifndef _SYMTOARGADAPTOR_
24 #define _SYMTOARGADAPTOR_
25 #include <functional>
26 #include <iostream>
27 #include <string>
30 
31 namespace Genfun {
32 
33  template <class F>
34  class SymToArgAdaptor : public AbsFunction {
35 
37 
38  public:
39 
40  // ScopedMethodName
41  typedef Parameter & (F::*ScopedMethodPtr) ();
42 
43  // Constructor
44  SymToArgAdaptor( F & function, // A function.
45  const AbsFunction & f_expression, // An expression to apply it to
46  ScopedMethodPtr parameterFetchMethod, // A parameter.
47  const AbsFunction * p_expression); // An expression for the parameter
48 
49  // Copy constructor
50  SymToArgAdaptor(const SymToArgAdaptor &right);
51 
52  // Destructor
53  virtual ~SymToArgAdaptor();
54 
55  // Retreive function value
56  virtual double operator ()(double argument) const; // Gives an error.
57  virtual double operator ()(const Argument & a) const; // Must use this one
58 
59  // Dimensionality
60  virtual unsigned int dimensionality() const;
61 
62  private:
63 
64  // It is illegal to assign an adjustable constant
65  const SymToArgAdaptor & operator=(const SymToArgAdaptor &right);
66 
67  // Here is the function being adapted;
68  F *_function;
69 
70  // A Variable (int an argument) to which the function is going to apply:
71  const AbsFunction *_f_expression;
72 
73  // Here is the recipe for fetching the parameter from the function:
74  std::mem_fun_ref_t<Parameter &, F> _parameterFetchMethod;
75 
76  // Here is the symbol to be connect to the parameter:
77  const AbsFunction *_p_expression;
78 
79  };
80 } // namespace Genfun
81  #include "CLHEP/GenericFunctions/SymToArgAdaptor.icc"
82 #endif
83 
Genfun::SymToArgAdaptor::SymToArgAdaptor
SymToArgAdaptor(F &function, const AbsFunction &f_expression, ScopedMethodPtr parameterFetchMethod, const AbsFunction *p_expression)
a
@ a
Definition: testCategories.cc:125
Parameter.hh
Genfun::AbsFunction
Definition: CLHEP/GenericFunctions/AbsFunction.hh:48
AbsFunction.hh
Genfun::Argument
Definition: CLHEP/GenericFunctions/Argument.hh:17
Genfun::SymToArgAdaptor::~SymToArgAdaptor
virtual ~SymToArgAdaptor()
Genfun::SymToArgAdaptor::ScopedMethodPtr
Parameter &(F::* ScopedMethodPtr)()
Definition: GenericFunctions/SymToArgAdaptor.hh:41
Genfun::SymToArgAdaptor::dimensionality
virtual unsigned int dimensionality() const
Genfun::SymToArgAdaptor
Definition: CLHEP/GenericFunctions/SymToArgAdaptor.hh:34
Genfun::Parameter
Definition: CLHEP/GenericFunctions/Parameter.hh:35
FUNCTION_OBJECT_DEF
#define FUNCTION_OBJECT_DEF(classname)
Definition: CLHEP/GenericFunctions/AbsFunction.hh:144
Genfun::SymToArgAdaptor::operator()
virtual double operator()(double argument) const
Genfun
Definition: CLHEP/GenericFunctions/Abs.hh:14