Jpp  master_rocky
the software that should make you happy
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 /**
12  * \author bjung
13  */
14 
15 namespace JAANET {}
16 namespace JPP { using namespace JAANET; }
17 
18 namespace JAANET {
19 
20  /**
21  * Helper class for flux function.
22  */
23  struct JFluxHelper :
25  {
27 
28 
29  /**
30  * Default constructor.
31  */
33  {}
34 
35 
36  /**
37  * Constructor.
38  *
39  * \param flux flux function
40  */
43  {}
44 
45 
46  /**
47  * Constructor.
48  *
49  * \param flux flux function
50  */
52  {
53  configure(flux);
54  }
55 
56 
57  /**
58  * Get reference to flux function.
59  *
60  * \return reference to flux function
61  */
62  JFlux& getFlux() const
63  {
64  using namespace JPP;
65 
66  JEvtWeightFactor& factor = this->getFactor();
67 
68  JFlux* p = dynamic_cast<JFlux*>(&factor);
69 
70  if (p != NULL) {
71  return *p;
72  } else {
73  THROW(JNullPointerException, "JFluxHelper::getFlux(): Cannot convert event-weight factor to flux function.");
74  }
75  }
76 
77 
78  /**
79  * Get flux of given event.
80  *
81  * \param evt event
82  * \return flux [GeV^-1 * m^-2 * sr^-1 * s^-1]
83  */
84  double getFlux(const Evt& evt) const
85  {
86  return getFactor(evt);
87  }
88  };
89 }
90 
91 #endif
#define THROW(JException_t, A)
Marco for throwing exception with std::ostream compatible message.
Definition: JException.hh:712
Exception for null pointer operation.
Definition: JException.hh:234
Extensions to Evt data format.
This name space includes all other name spaces (except KM3NETDAQ, KM3NET and ANTARES).
The Evt class respresent a Monte Carlo (MC) event as well as an offline event.
Definition: Evt.hh:21
Helper class for event-weight factor.
void configure(const pointer_type &p)
Configure event-weight factor.
std::shared_ptr< JEvtWeightFactor > pointer_type
JEvtWeightFactor & getFactor() const
Get reference to event-weight factor.
Abstract base class for specifiable event-weight factors.
Helper class for flux function.
Definition: JFluxHelper.hh:25
JFluxHelper()
Default constructor.
Definition: JFluxHelper.hh:32
JFluxHelper(const JFlux &flux)
Constructor.
Definition: JFluxHelper.hh:51
JFluxHelper(const pointer_type &flux)
Constructor.
Definition: JFluxHelper.hh:41
JEvtWeightFactorHelper::pointer_type pointer_type
Definition: JFluxHelper.hh:26
double getFlux(const Evt &evt) const
Get flux of given event.
Definition: JFluxHelper.hh:84
JFlux & getFlux() const
Get reference to flux function.
Definition: JFluxHelper.hh:62
Low-level interface for retrieving the flux corresponding to a given event.
Definition: JFlux.hh:23
Neutrino flux.
Definition: JHead.hh:906