Jpp - the software that should make you happy
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
JFluxHelper.hh
Go to the documentation of this file.
1 #ifndef __JAANET__JFLUXHELPER__
2 #define __JAANET__JFLUXHELPER__
3 
5 
7 
8 #include "JAAnet/JFlux.hh"
9 
10 /**
11  * \author bjung
12  */
13 
14 namespace JAANET {
15 
18 
19 
20  /**
21  * Helper class for event weighing.
22  */
23  struct JFluxHelper :
24  public JSharedPointer<JFlux>
25  {
27 
28  /**
29  * Default constructor.
30  */
32  {}
33 
34 
35  /**
36  * Constructor.
37  *
38  * \param function flux function
39  */
40  JFluxHelper(const JFlux& function)
41  {
42  configure(function);
43  }
44 
45 
46  /**
47  * Flux configuration.
48  *
49  * \param function flux function
50  */
51  void configure(const JFlux& function)
52  {
53  reset(function.clone());
54  }
55 
56 
57  /**
58  * Get flux of given event.
59  *
60  * \param evt event
61  * \return flux [GeV * m^-2 * sr^-1 * s^-1]
62  */
63  double getFlux(const Evt& evt) const
64  {
65  if (is_valid()) {
66  return get()->getFlux(evt);
67  } else {
68  THROW(JNullPointerException, "JFluxHelper::getFlux(): Unspecified flux function.");
69  }
70  }
71  };
72 }
73 
74 #endif
void configure(const JFlux &function)
Flux configuration.
Definition: JFluxHelper.hh:51
#define THROW(JException_t, A)
Marco for throwing exception with std::ostream compatible message.
Definition: JException.hh:670
bool is_valid() const
Check validity of pointer.
JFluxHelper(const JFlux &function)
Constructor.
Definition: JFluxHelper.hh:40
The template JSharedPointer class can be used to share a pointer to an object.
Exception for null pointer operation.
Definition: JException.hh:216
Helper class for event weighing.
Definition: JFluxHelper.hh:23
double getFlux(const Evt &evt) const
Get flux of given event.
Definition: JFluxHelper.hh:63
JFluxHelper()
Default constructor.
Definition: JFluxHelper.hh:31
Low-level interface for retrieving flux corresponding to an event.
Definition: JFlux.hh:22
virtual void reset() override
Reset pointer.
The Evt class respresent a Monte Carlo (MC) event as well as an offline event.
Definition: Evt.hh:19