Jpp  16.0.1
the software that should make you happy
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
JOscProbInterpolator2D.hh
Go to the documentation of this file.
1 #ifndef __JOSCPROB__JOSCPROBINTERPOLATOR2D__
2 #define __JOSCPROB__JOSCPROBINTERPOLATOR2D__
3 
4 #include <string>
5 
7 
8 #include "Jeep/JMessage.hh"
9 
10 #include "JLang/JException.hh"
11 
12 #include "JTools/JDistance.hh"
13 
17 #include "JOscProb/JOscChannel.hh"
19 
20 
21 namespace JOSCPROB {};
22 namespace JPP { using namespace JOSCPROB; }
23 
24 namespace JOSCPROB {
25 
28 
30 
31 
32  /**
33  * Auxiliary class for interpolating an oscillation probability table in 2 dimensions\n
34  * (in terms of the energy and cosine zenith angle).
35  */
36  template<class JDistance_t = JTOOLS::JDistance<typename JOscProbTable2D_t::JFunction2D_t::argument_type> >
38  {
40  typedef typename table_type::data_type data_type;
41 
42 
43  /**
44  * Default constructor.
45  */
47  pTable()
48  {}
49 
50 
51  /**
52  * Constructor.
53  *
54  * \param pTable pointer to 2D oscillation probability table
55  */
57  pTable(pTable)
58  {}
59 
60 
61  /**
62  * Get oscillation probability for given oscillation channel.
63  *
64  * \param channel oscillation channel
65  * \param log10E logarithmic neutrino energy
66  * \param costh cosine zenith angle
67  * \return oscillation probability
68  */
69  double operator()(const JOscChannel& channel,
70  const double log10E,
71  const double costh) const
72  {
73  using namespace std;
74  using namespace JPP;
75 
76  const JOscChannel* p = find(getOscChannel, getOscChannel + NUMBER_OF_OSCCHANNELS, channel);
77 
78  if (pTable != NULL) {
79 
80  if (p != end(getOscChannel)) {
81 
82  const size_t index = distance(getOscChannel, p);
83  const data_type& probabilities = (*pTable)(log10E, costh);
84 
85  return probabilities[index];
86 
87  } else {
88 
89  THROW(JValueOutOfRange, "JOscProbInterpolator2D::operator(): Invalid oscillation channel " << channel << endl);
90  }
91 
92  } else {
93 
94  THROW(JNullPointerException, "JOscProbInterpolator2D::operator(): Unspecified oscillation probability table." << endl);
95  }
96  }
97 
98 
99  private:
100 
101  const table_type* pTable; //!< Pointer to 2D oscillation probability table
102  };
103 }
104 
105 
106 #endif
Exceptions.
double operator()(const JOscChannel &channel, const double log10E, const double costh) const
Get oscillation probability for given oscillation channel.
Neutrino oscillation channel.
Definition: JOscChannel.hh:29
Auxiliary class for interpolating an oscillation probability table in 2 dimensions (in terms of the e...
std::vector< T >::difference_type distance(typename std::vector< T >::const_iterator first, typename PhysicsEvent::const_iterator< T > second)
Specialisation of STL distance.
#define THROW(JException_t, A)
Marco for throwing exception with std::ostream compatible message.
Definition: JException.hh:696
JOscProbInterpolator2D(const table_type *pTable)
Constructor.
JOscProbInterpolator2D()
Default constructor.
JOscProbTable2D< JDistance_t > table_type
Exception for null pointer operation.
Definition: JException.hh:216
static const JOscChannel getOscChannel[]
Declare group of neutrino oscillation channels.
Definition: JOscChannel.hh:340
General purpose messaging.
Explicit template specialization for 2D interpolation table in: .
const table_type * pTable
Pointer to 2D oscillation probability table.
Exception for accessing a value in a collection that is outside of its range.
Definition: JException.hh:162
static const int NUMBER_OF_OSCCHANNELS
Number of neutrino oscillation channels.
Definition: JOscChannel.hh:365