Jpp  18.2.1-ARCA-DF-PATCH
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 namespace JPP { using namespace JAANET; }
13 
14 namespace JAANET {
15 
16  /**
17  * Example function object for computing power-law flux.
18  */
20  {
21  /**
22  * Default constructor.
23  */
25  normalisation(1.0),
26  spectralIndex(0.0)
27  {}
28 
29 
30  /**
31  * Constructor.
32  *
33  * \param normalisation normalisation [GeV * m^-2 * sr^-1 * s^-1]
34  * \param spectralIndex spectral index
35  */
37  const double spectralIndex) :
38  normalisation(normalisation),
39  spectralIndex(spectralIndex)
40  {}
41 
42 
43  /**
44  * Get flux of given event.
45  *
46  * \param evt event
47  * \return flux [GeV * m^-2 * sr^-1 * s^-1]
48  */
49  double operator()(const Evt& evt) const
50  {
51  using namespace std;
52  using namespace JPP;
53 
54  if (has_neutrino(evt)) {
55 
56  const Trk& neutrino = get_neutrino(evt);
57 
58  return normalisation * pow(neutrino.E, -spectralIndex);
59 
60  } else {
61 
62  THROW(JNullPointerException, "JPowerLawFlux::operator(): No neutrino for event " << evt.id << '.' << endl);
63  }
64  }
65 
66 
67  /**
68  * Stream input.
69  *
70  * \param in input stream
71  * \param object power-law flux
72  * \return input stream
73  */
74  inline friend std::istream& operator>>(std::istream& in,
75  JPowerLawFlux& object)
76  {
77  return in >> object.normalisation
78  >> object.spectralIndex;
79  }
80 
81 
82  /**
83  * Write power-law parameters to output stream.
84  *
85  * \param out output stream
86  * \param object power-law flux
87  * \return output stream
88  */
89  inline friend std::ostream& operator<<(std::ostream& out,
90  const JPowerLawFlux& object)
91  {
92  const JFormat format(out);
93 
94  out << FIXED(5,3) << object.normalisation << ' '
95  << FIXED(5,3) << object.spectralIndex;
96 
97  return out;
98  }
99 
100 
101  double normalisation; //!< normalisation [GeV * m^-2 * sr^-1 * s^-1]
102  double spectralIndex; //!< spectral index >= 0
103  };
104 
105 
106  /**
107  * Auxiliary method for creating an interface to a power-law flux function.
108  *
109  * \param normalisation normalisation [GeV * m^-2 * sr^-1 * s^-1]
110  * \param spectralIndex spectral index
111  */
113  const double spectralIndex) {
114 
115  const JPowerLawFlux flux(normalisation, spectralIndex);
116 
117  return make_fluxFunction(flux);
118  }
119 }
120 
121 #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:712
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
friend std::ostream & operator<<(std::ostream &out, const JPowerLawFlux &object)
Write power-law parameters to output stream.
Neutrino flux.
Definition: JHead.hh:906
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