Jpp - the software that should make you happy
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
JFluxFunction.hh
Go to the documentation of this file.
1 #ifndef __JAANET__JFLUXFUNCTION__
2 #define __JAANET__JFLUXFUNCTION__
3 
5 
6 #include "JLang/JClonable.hh"
7 
8 #include "JAAnet/JFlux.hh"
9 
10 /**
11  * \author bjung
12  */
13 
14 namespace JAANET {
15 
16  using JLANG::JClonable;
17 
18 
19  /**
20  * Implementation of flux function.\n
21  * Note that the template argument refers to a function of which the copy constuctor needs to be defined.
22  */
23  template<class JFunction_t>
24  struct JFluxFunction :
25  public JClonable<JFlux, JFluxFunction<JFunction_t> >
26  {
27  /**
28  * Constructor.
29  *
30  * \param function flux function
31  */
32  JFluxFunction(const JFunction_t& function) :
34  {}
35 
36 
37  /**
38  * Get flux for given event.
39  *
40  * \param evt event
41  * \return flux [GeV * m^-2 * sr^-1 * s^-1]
42  */
43  double getFlux(const Evt& evt) const override
44  {
45  return function(evt);
46  }
47 
48  private:
49 
50  JFunction_t function;
51  };
52 
53 
54  /**
55  * Type definition of pointer to flux function.
56  */
57  typedef double (*pFlux)(const Evt&);
58 
59 
60  /**
61  * Implementation of C-style flux function.\n
62  */
63  template<>
64  struct JFluxFunction<pFlux> :
65  public JClonable<JFlux, JFluxFunction<pFlux> >
66  {
67  /**
68  * Constructor.
69  *
70  * \param function flux function
71  */
72  JFluxFunction(pFlux function) :
74  {}
75 
76 
77  /**
78  * Get flux for given event.
79  *
80  * \param evt event
81  * \return flux [GeV * m^-2 * sr^-1 * s^-1]
82  */
83  double getFlux(const Evt& evt) const override
84  {
85  return (*function)(evt);
86  }
87 
88  private:
89 
90  pFlux function;
91  };
92 
93 
94  /**
95  * Auxiliary method for creating flux function.
96  *
97  * \param function function
98  * \return flux function
99  */
100  template<class JFunction_t>
101  inline JFluxFunction<JFunction_t> make_fluxFunction(const JFunction_t& function) {
102  return JFluxFunction<JFunction_t>(function);
103  }
104 
105 
106  /**
107  * Auxiliary method for creating flux function.
108  *
109  * \param function function
110  * \return flux function
111  */
113  return JFluxFunction<pFlux>(function);
114  }
115 }
116 
117 #endif
double(* pFlux)(const Evt &)
Type definition of pointer to flux function.
double getFlux(const Evt &evt) const override
Get flux for given event.
Template class for object cloning.
Definition: JClonable.hh:20
double getFlux(const Evt &evt) const override
Get flux for given event.
JFluxFunction< JFunction_t > make_fluxFunction(const JFunction_t &function)
Auxiliary method for creating flux function.
Implementation of flux function.
JFluxFunction(pFlux function)
Constructor.
Implementation of C-style flux function.
JFluxFunction(const JFunction_t &function)
Constructor.
The Evt class respresent a Monte Carlo (MC) event as well as an offline event.
Definition: Evt.hh:19