Jpp  18.0.0
the software that should make you happy
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
JPowerLawFlux.hh
Go to the documentation of this file.
1 #ifndef __JAANET__JPOWERLAWFLUX__
2 #define __JAANET__JPOWERLAWFLUX__
3 
5 
6 
7 /**
8  * \author bjung
9  */
10 
11 namespace JAANET {
12 
13  /**
14  * Example function object for computing power-law flux.
15  */
17  {
18  /**
19  * Default constructor.
20  */
22  normalisation(1.0),
23  spectralIndex(0.0)
24  {}
25 
26 
27  /**
28  * Constructor.
29  *
30  * \param normalisation normalisation [GeV * m^-2 * sr^-1 * s^-1]
31  * \param spectralIndex spectral index
32  */
34  const double spectralIndex) :
35  normalisation(normalisation),
36  spectralIndex(spectralIndex)
37  {}
38 
39 
40  /**
41  * Get flux of given event.
42  *
43  * \param evt event
44  * \return flux [GeV * m^-2 * sr^-1 * s^-1]
45  */
46  double operator()(const Evt& evt) const
47  {
48  using namespace std;
49  using namespace JPP;
50 
51  if (has_neutrino(evt)) {
52 
53  const Trk& neutrino = get_neutrino(evt);
54 
55  return normalisation * pow(neutrino.E, -spectralIndex);
56 
57  } else {
58 
59  THROW(JNullPointerException, "JPowerLawFlux::operator(): No neutrino for event " << evt.id << '.' << endl);
60  }
61  }
62 
63 
64  /**
65  * Stream input.
66  *
67  * \param in input stream
68  * \param object power-law flux
69  * \return input stream
70  */
71  inline friend std::istream& operator>>(std::istream& in,
72  JPowerLawFlux& object)
73  {
74  return in >> object.normalisation
75  >> object.spectralIndex;
76  }
77 
78 
79  /**
80  * Write power-law parameters to output stream.
81  *
82  * \param out output stream
83  * \param object power-law flux
84  * \return output stream
85  */
86  inline friend std::ostream& operator<<(std::ostream& out,
87  const JPowerLawFlux& object)
88  {
89  const JFormat format(out);
90 
91  out << FIXED(5,3) << object.normalisation << ' '
92  << FIXED(5,3) << object.spectralIndex;
93 
94  return out;
95  }
96 
97 
98  double normalisation; //!< normalisation [GeV * m^-2 * sr^-1 * s^-1]
99  double spectralIndex; //!< spectral index >= 0
100  };
101 
102 
103  /**
104  * Auxiliary method for creating an interface to a power-law flux function.
105  *
106  * \param normalisation normalisation [GeV * m^-2 * sr^-1 * s^-1]
107  * \param spectralIndex spectral index
108  */
110  const double spectralIndex) {
111 
112  const JPowerLawFlux flux(normalisation, spectralIndex);
113 
114  return make_fluxFunction(flux);
115  }
116 }
117 
118 #endif
double normalisation
normalisation [GeV * m^-2 * sr^-1 * s^-1]
bool has_neutrino(const Evt &evt)
Test whether given event has an incoming neutrino.
#define THROW(JException_t, A)
Marco for throwing exception with std::ostream compatible message.
Definition: JException.hh:696
Implementation of event-weight factor interface.
Auxiliary data structure for floating point format specification.
Definition: JManip.hh:446
JEvtWeightFactorFunction< JFunction_t, JFlux > make_fluxFunction(const JFunction_t &flux)
Auxiliary method for creating an interface to a flux function.
double E
Energy [GeV] (either MC truth or reconstructed)
Definition: Trk.hh:20
friend std::istream & operator>>(std::istream &in, JPowerLawFlux &object)
Stream input.
double spectralIndex
spectral index &gt;= 0
Auxiliary class to temporarily define format specifications.
Definition: JManip.hh:632
Exception for null pointer operation.
Definition: JException.hh:216
friend std::ostream & operator<<(std::ostream &out, const JPowerLawFlux &object)
Write power-law parameters to output stream.
Neutrino flux.
Definition: JHead.hh:893
T pow(const T &x, const double y)
Power .
Definition: JMath.hh:97
Example function object for computing power-law flux.
JEvtWeightFactorFunction< JPowerLawFlux, JFlux > make_powerLawFluxFunction(const double normalisation, const double spectralIndex)
Auxiliary method for creating an interface to a power-law flux function.
double operator()(const Evt &evt) const
Get flux of given event.
int id
offline event identifier
Definition: Evt.hh:22
const Trk & get_neutrino(const Evt &evt)
Get incoming neutrino.
then fatal Wrong number of arguments fi set_variable DETECTOR $argv[1] set_variable INPUT_FILE $argv[2] eval JPrintDetector a $DETECTOR O IDENTIFIER eval JPrintDetector a $DETECTOR O SUMMARY JAcoustics sh $DETECTOR_ID source JAcousticsToolkit sh CHECK_EXIT_CODE typeset A EMITTERS get_tripods $WORKDIR tripod txt EMITTERS get_transmitters $WORKDIR transmitter txt EMITTERS for EMITTER in
Definition: JCanberra.sh:46
The Trk class represents a Monte Carlo (MC) particle as well as a reconstructed track/shower.
Definition: Trk.hh:14
JPowerLawFlux()
Default constructor.
JPowerLawFlux(const double normalisation, const double spectralIndex)
Constructor.
The Evt class respresent a Monte Carlo (MC) event as well as an offline event.
Definition: Evt.hh:20