Jpp  17.0.0-rc.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 
29 
30  /**
31  * Auxiliary class for interpolating an oscillation probability table in 8 dimensions in terms of:
32  *
33  * 1. \f$ E \left[\mathrm{GeV}\right] \f$
34  * 2. \f$ \sin(\theta)\f$
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 E neutrino energy [GeV]
66  * \param costh cosine zenith angle
67  * \return oscillation probability
68  */
69  double operator()(const JOscChannel& channel,
70  const double E,
71  const double costh) const
72  {
73  using namespace std;
74  using namespace JPP;
75 
76  if (pTable != NULL) {
77 
78  const JOscChannel* p = find(getOscChannel, getOscChannel + NUMBER_OF_OSCCHANNELS, channel);
79 
80  if (p != end(getOscChannel)) {
81 
82  const double L = getL(costh);
83  const double sinth = (fabs(costh) < 1.0 ? sqrt((1 - costh) * (1 + costh)) : 0.0);
84 
85  const size_t index = distance(getOscChannel, p);
86  const data_type& probabilities = (*pTable)(L/E, sinth);
87 
88  return probabilities[index];
89 
90  } else {
91 
92  THROW(JValueOutOfRange, "JOscProbInterpolator2D::operator(): Invalid oscillation channel " << channel << endl);
93  }
94 
95  } else {
96 
97  THROW(JNullPointerException, "JOscProbInterpolator2D::operator(): Unspecified oscillation probability table." << endl);
98  }
99  }
100 
101 
102  private:
103 
104  const table_type* pTable; //!< Pointer to 2D oscillation probability table
105  };
106 }
107 
108 
109 #endif
Exceptions.
then usage E
Definition: JMuonPostfit.sh:35
Neutrino oscillation channel.
Definition: JOscChannel.hh:29
Auxiliary class for interpolating an oscillation probability table in 8 dimensions in terms of: ...
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
double getL(const double costh)
Get baseline for a given cosine zenith angle.
General purpose messaging.
Explicit template specialization for 2D interpolation table in:
const table_type * pTable
Pointer to 2D oscillation probability table.
double operator()(const JOscChannel &channel, const double E, const double costh) const
Get oscillation probability for given oscillation channel.
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