Jpp  17.1.0
the software that should make you happy
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
JOscChannel.hh
Go to the documentation of this file.
1 #ifndef __JOSCPROB__JOSCCHANNEL__
2 #define __JOSCPROB__JOSCCHANNEL__
3 
5 
6 #include "JLang/JException.hh"
7 #include "JLang/JComparable.hh"
8 
9 #include "Jeep/JProperties.hh"
10 
11 
12 /**
13  * \author bjung
14  * \file
15  * Oscillation parameters and auxiliary methods.
16  */
17 
18 namespace JOSCPROB {}
19 namespace JPP { using namespace JOSCPROB; }
20 
21 namespace JOSCPROB {
22 
24 
25 
26  /**
27  * Neutrino oscillation channel.
28  */
29  struct JOscChannel :
30  public JLANG::JComparable<JOscChannel>
31  {
32  /**
33  * Neutrino flavours.
34  */
35  enum JFlavour_t { ELECTRON = 12,
36  MUON = 14,
37  TAU = 16,
39 
40  /**
41  * Charge parities.
42  */
44  PARTICLE = +1,
46 
47 
48  /**
49  * Default constructor.
50  */
55  {}
56 
57 
58  /**
59  * Constructor.
60  *
61  * \param in input flavour
62  * \param out output flavour
63  * \param Cparity charge parity
64  */
66  const JFlavour_t out,
67  const JChargeParity_t Cparity) :
68  in (in),
69  out(out),
70  Cparity(Cparity)
71  {}
72 
73 
74  /**
75  * Less-than method
76  *
77  * \param channel channel
78  * \return true this channel less than given channel; else false
79  */
80  inline bool less(const JOscChannel& channel) const
81  {
82  if (this->Cparity == channel.Cparity) {
83 
84  if (this->in == channel.in) {
85 
86  return this->out < channel.out;
87 
88  } else {
89 
90  return this->in < channel.in;
91  }
92 
93  } else {
94 
95  return this->Cparity < channel.Cparity;
96  }
97  }
98 
99 
100  /**
101  * Write channel to output.
102  *
103  * \param out output stream
104  * \param object oscillation channel
105  * \return output stream
106  */
107  friend inline std::ostream& operator<<(std::ostream& out, const JOscChannel& object)
108  {
109  return out << object.getProperties();
110  }
111 
112 
113  /**
114  * Read channel from input.
115  *
116  * \param in input stream
117  * \param object oscillation channel
118  * \return input stream
119  */
120  friend inline std::istream& operator>>(std::istream& in, JOscChannel& object)
121  {
122 
123  JProperties properties(object.getProperties());
124 
125  in >> properties;
126 
127  object.setProperties(properties);
128 
129  return in;
130  }
131 
132 
133  /**
134  * Get flavour of neutrino.
135  *
136  * \param pdgID PDG identifier
137  * \return flavour
138  */
139  static inline JFlavour_t getFlavour(const int pdgID)
140  {
141  using namespace JPP;
142 
143  switch(abs(pdgID)) {
144  case (int) ELECTRON:
145  return ELECTRON;
146  case (int) MUON:
147  return MUON;
148  case (int) TAU:
149  return TAU;
150  default:
151  return FLAVOUR_UNDEFINED;
152  }
153  }
154 
155 
156  /**
157  * Get flavour of neutrino.
158  *
159  * \param neutrino neutrino track
160  */
161  static inline JFlavour_t getFlavour(const Trk& neutrino)
162  {
163  return getFlavour(neutrino.type);
164  }
165 
166 
167  /**
168  * Get charge-parity of given neutrino.
169  *
170  * \param Cparity charge parity (1 for neutrinos; -1 for anti-neutrinos)
171  * \return oscillation channel charge parity
172  */
173  static inline JChargeParity_t getChargeParity(const int Cparity)
174  {
175  switch (Cparity) {
176  case ((int) PARTICLE):
177  return PARTICLE;
178  case ((int) ANTIPARTICLE):
179  return ANTIPARTICLE;
180  default:
181  return CPARITY_UNDEFINED;
182  }
183  }
184 
185 
186  /**
187  * Get charge-parity of given neutrino.
188  *
189  * \param neutrino neutrino track
190  * \return charge-parity (1 for neutrinos; -1 for anti-neutrinos)
191  */
192  static inline JChargeParity_t getChargeParity(const Trk& neutrino)
193  {
194  return getChargeParity(neutrino.type / abs(neutrino.type));
195  }
196 
197 
198  /**
199  * Auxiliary function to retrieve incoming neutrino PDG type.
200  *
201  * \param channel oscillation channel
202  * \return incoming neutrino PDG type
203  */
204  static inline int getIncomingNeutrinoType(const JOscChannel& channel)
205  {
206  switch (channel.in) {
207  case ELECTRON:
208  return (int)channel.Cparity * (int)ELECTRON;
209  case MUON:
210  return (int)channel.Cparity * (int)MUON;
211  case TAU:
212  return (int)channel.Cparity * (int)TAU;
213  default:
214  THROW(JLANG::JValueOutOfRange, "getIncomingNeutrinoType(): Invalid oscillation channel " << channel);
215  }
216  }
217 
218 
219  /**
220  * Auxiliary function to retrieve outgoing neutrino PDG type.
221  *
222  * \param channel oscillation channel
223  * \return outgoing neutrino PDG type
224  */
225  static inline int getOutgoingNeutrinoType(const JOscChannel& channel)
226  {
227  switch (channel.out) {
228  case ELECTRON:
229  return (int)channel.Cparity * (int)ELECTRON;
230  case MUON:
231  return (int)channel.Cparity * (int)MUON;
232  case TAU:
233  return (int)channel.Cparity * (int)TAU;
234  default:
235  THROW(JLANG::JValueOutOfRange, "getOutgoingNeutrinoType(): Invalid oscillation channel " << channel);
236  }
237  }
238 
239 
240  /**
241  * Get equation parameters.
242  *
243  * \return equation parameters
244  */
246  {
247  static JEquationParameters equation("=", "\n\r;,", "./", "#");
248 
249  return equation;
250  }
251 
252 
253  /**
254  * Set equation parameters.
255  *
256  * \param equation equation parameters
257  */
258  static inline void setEquationParameters(const JEquationParameters& equation)
259  {
260  getEquationParameters() = equation;
261  }
262 
263 
264  /**
265  * Get properties of this class.
266  *
267  * \param equation equation parameters
268  */
270  {
271  return JOscChannelHelper(*this, equation);
272  }
273 
274 
275  /**
276  * Get properties of this class.
277  *
278  * \param equation equation parameters
279  */
281  {
282  return JOscChannelHelper(*this, equation);
283  }
284 
285 
286  /**
287  * Set properties of this class
288  *
289  * \param properties properties
290  */
291  void setProperties(const JProperties& properties)
292  {
293  this->in = JOscChannel::getFlavour (properties.getValue<int>("in"));
294  this->out = JOscChannel::getFlavour (properties.getValue<int>("out"));
295  this->Cparity = JOscChannel::getChargeParity(properties.getValue<int>("Cparity"));
296  }
297 
298 
299  JFlavour_t in; //!< Incoming flavour
300  JFlavour_t out; //!< Outcoming flavour
301  JChargeParity_t Cparity; //!< Charge-parity
302 
303 
304  private:
305  /**
306  * Auxiliary class for I/O of oscillation channel.
307  */
309  public JProperties
310  {
311  /**
312  * Constructor.
313  *
314  * \param object oscillation channel
315  * \param equation equation parameters
316  */
317  template<class JOscChannel_t>
318  JOscChannelHelper(JOscChannel_t& object,
319  const JEquationParameters& equation) :
320  JProperties(equation, 1),
321  in (object.in),
322  out (object.out),
323  Cparity (object.Cparity)
324  {
325  this->insert(gmake_property(in));
326  this->insert(gmake_property(out));
327  this->insert(gmake_property(Cparity));
328  }
329 
330  int in;
331  int out;
332  int Cparity;
333  };
334  };
335 
336 
337  /**
338  * Declare group of neutrino oscillation channels.
339  */
340  static const JOscChannel getOscChannel[] = {
359  };
360 
361 
362  /**
363  * Number of neutrino oscillation channels.
364  */
365  static const int NUMBER_OF_OSCCHANNELS = sizeof(getOscChannel) / sizeof(JOscChannel);
366 }
367 
368 #endif
JOscChannel(const JFlavour_t in, const JFlavour_t out, const JChargeParity_t Cparity)
Constructor.
Definition: JOscChannel.hh:65
static JEquationParameters & getEquationParameters()
Get equation parameters.
Definition: JOscChannel.hh:245
Exceptions.
JFlavour_t
Neutrino flavours.
Definition: JOscChannel.hh:35
JOscChannel()
Default constructor.
Definition: JOscChannel.hh:51
JChargeParity_t
Charge parities.
Definition: JOscChannel.hh:43
static JChargeParity_t getChargeParity(const int Cparity)
Get charge-parity of given neutrino.
Definition: JOscChannel.hh:173
Neutrino oscillation channel.
Definition: JOscChannel.hh:29
static void setEquationParameters(const JEquationParameters &equation)
Set equation parameters.
Definition: JOscChannel.hh:258
JOscChannelHelper(JOscChannel_t &object, const JEquationParameters &equation)
Constructor.
Definition: JOscChannel.hh:318
#define gmake_property(A)
macro to convert (template) parameter to JPropertiesElement object
friend std::ostream & operator<<(std::ostream &out, const JOscChannel &object)
Write channel to output.
Definition: JOscChannel.hh:107
JFlavour_t in
Incoming flavour.
Definition: JOscChannel.hh:299
#define THROW(JException_t, A)
Marco for throwing exception with std::ostream compatible message.
Definition: JException.hh:696
Utility class to parse parameter values.
Definition: JProperties.hh:496
Simple data structure to support I/O of equations (see class JLANG::JEquation).
friend std::istream & operator>>(std::istream &in, JOscChannel &object)
Read channel from input.
Definition: JOscChannel.hh:120
Utility class to parse parameter values.
void setProperties(const JProperties &properties)
Set properties of this class.
Definition: JOscChannel.hh:291
JProperties getProperties(const JEquationParameters &equation=JOscChannel::getEquationParameters())
Get properties of this class.
Definition: JOscChannel.hh:269
const T & getValue(const std::string &key) const
Get value.
Definition: JProperties.hh:974
static int getIncomingNeutrinoType(const JOscChannel &channel)
Auxiliary function to retrieve incoming neutrino PDG type.
Definition: JOscChannel.hh:204
static const JOscChannel getOscChannel[]
Declare group of neutrino oscillation channels.
Definition: JOscChannel.hh:340
JChargeParity_t Cparity
Charge-parity.
Definition: JOscChannel.hh:301
static JFlavour_t getFlavour(const int pdgID)
Get flavour of neutrino.
Definition: JOscChannel.hh:139
static JFlavour_t getFlavour(const Trk &neutrino)
Get flavour of neutrino.
Definition: JOscChannel.hh:161
Template definition of auxiliary base class for comparison of data structures.
Definition: JComparable.hh:24
int type
MC: particle type in PDG encoding.
Definition: Trk.hh:24
static JChargeParity_t getChargeParity(const Trk &neutrino)
Get charge-parity of given neutrino.
Definition: JOscChannel.hh:192
Auxiliary class for I/O of oscillation channel.
Definition: JOscChannel.hh:308
static int getOutgoingNeutrinoType(const JOscChannel &channel)
Auxiliary function to retrieve outgoing neutrino PDG type.
Definition: JOscChannel.hh:225
Exception for accessing a value in a collection that is outside of its range.
Definition: JException.hh:162
The Trk class represents a Monte Carlo (MC) particle as well as a reconstructed track/shower.
Definition: Trk.hh:14
JProperties getProperties(const JEquationParameters &equation=JOscChannel::getEquationParameters()) const
Get properties of this class.
Definition: JOscChannel.hh:280
JFlavour_t out
Outcoming flavour.
Definition: JOscChannel.hh:300
static const int NUMBER_OF_OSCCHANNELS
Number of neutrino oscillation channels.
Definition: JOscChannel.hh:365
bool less(const JOscChannel &channel) const
Less-than method.
Definition: JOscChannel.hh:80