Jpp  16.0.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 first first channel
78  * \param second second channel
79  * \return true if channels are equal; else false
80  */
81  inline bool less(const JOscChannel& channel) const
82  {
83  if (this->Cparity == channel.Cparity) {
84 
85  if (this->in == channel.in) {
86 
87  return this->out < channel.out;
88 
89  } else {
90 
91  return this->in < channel.in;
92  }
93 
94  } else {
95 
96  return this->Cparity < channel.Cparity;
97  }
98  }
99 
100 
101  /**
102  * Write channel to output.
103  *
104  * \param out output stream
105  * \param object oscillation channel
106  * \return output stream
107  */
108  friend inline std::ostream& operator<<(std::ostream& out, const JOscChannel& object)
109  {
110  return out << object.getProperties();
111  }
112 
113 
114  /**
115  * Read channel from input.
116  *
117  * \param in input stream
118  * \param object oscillation channel
119  * \return input stream
120  */
121  friend inline std::istream& operator>>(std::istream& in, JOscChannel& object)
122  {
123 
124  JProperties properties(object.getProperties());
125 
126  in >> properties;
127 
128  object.setProperties(properties);
129 
130  return in;
131  }
132 
133 
134  /**
135  * Get flavour of neutrino.
136  *
137  * \param pdgID PDG identifier
138  * \return flavour
139  */
140  static inline JFlavour_t getFlavour(const int pdgID)
141  {
142  using namespace JPP;
143 
144  switch(abs(pdgID)) {
145  case (int) ELECTRON:
146  return ELECTRON;
147  case (int) MUON:
148  return MUON;
149  case (int) TAU:
150  return TAU;
151  default:
152  return FLAVOUR_UNDEFINED;
153  }
154  }
155 
156 
157  /**
158  * Get flavour of neutrino.
159  *
160  * \param neutrino neutrino track
161  */
162  static inline JFlavour_t getFlavour(const Trk& neutrino)
163  {
164  return getFlavour(neutrino.type);
165  }
166 
167 
168  /**
169  * Get charge-parity of given neutrino.
170  *
171  * \param Cparity charge parity (1 for neutrinos; -1 for anti-neutrinos)
172  * \return oscillation channel charge parity
173  */
174  static inline JChargeParity_t getChargeParity(const int Cparity)
175  {
176  switch (Cparity) {
177  case ((int) PARTICLE):
178  return PARTICLE;
179  case ((int) ANTIPARTICLE):
180  return ANTIPARTICLE;
181  default:
182  return CPARITY_UNDEFINED;
183  }
184  }
185 
186 
187  /**
188  * Get charge-parity of given neutrino.
189  *
190  * \param neutrino neutrino track
191  * \return charge-parity (1 for neutrinos; -1 for anti-neutrinos)
192  */
193  static inline JChargeParity_t getChargeParity(const Trk& neutrino)
194  {
195  return getChargeParity(neutrino.type / abs(neutrino.type));
196  }
197 
198 
199  /**
200  * Auxiliary function to retrieve incoming neutrino PDG type.
201  *
202  * \param channel oscillation channel
203  * \return incoming neutrino PDG type
204  */
205  static inline int getIncomingNeutrinoType(const JOscChannel& channel)
206  {
207  switch (channel.in) {
208  case ELECTRON:
209  return (int)channel.Cparity * (int)ELECTRON;
210  case MUON:
211  return (int)channel.Cparity * (int)MUON;
212  case TAU:
213  return (int)channel.Cparity * (int)TAU;
214  default:
215  THROW(JLANG::JValueOutOfRange, "getIncomingNeutrinoType(): Invalid oscillation channel " << channel);
216  }
217  }
218 
219 
220  /**
221  * Auxiliary function to retrieve outgoing neutrino PDG type.
222  *
223  * \param channel oscillation channel
224  * \return outgoing neutrino PDG type
225  */
226  static inline int getOutgoingNeutrinoType(const JOscChannel& channel)
227  {
228  switch (channel.out) {
229  case ELECTRON:
230  return (int)channel.Cparity * (int)ELECTRON;
231  case MUON:
232  return (int)channel.Cparity * (int)MUON;
233  case TAU:
234  return (int)channel.Cparity * (int)TAU;
235  default:
236  THROW(JLANG::JValueOutOfRange, "getOutgoingNeutrinoType(): Invalid oscillation channel " << channel);
237  }
238  }
239 
240 
241  /**
242  * Get equation parameters.
243  *
244  * \return equation parameters
245  */
247  {
248  static JEquationParameters equation("=", "\n\r;,", "./", "#");
249 
250  return equation;
251  }
252 
253 
254  /**
255  * Set equation parameters.
256  *
257  * \param equation equation parameters
258  */
259  static inline void setEquationParameters(const JEquationParameters& equation)
260  {
261  getEquationParameters() = equation;
262  }
263 
264 
265  /**
266  * Get properties of this class.
267  *
268  * \param equation equation parameters
269  */
271  {
272  return JOscChannelHelper(*this, equation);
273  }
274 
275 
276  /**
277  * Get properties of this class.
278  *
279  * \param equation equation parameters
280  */
282  {
283  return JOscChannelHelper(*this, equation);
284  }
285 
286 
287  /**
288  * Set properties of this class
289  *
290  * \param properties properties
291  * \param equation equation parameters
292  */
293  void setProperties(const JProperties& properties)
294  {
295  this->in = JOscChannel::getFlavour (properties.getValue<int>("in"));
296  this->out = JOscChannel::getFlavour (properties.getValue<int>("out"));
297  this->Cparity = JOscChannel::getChargeParity(properties.getValue<int>("Cparity"));
298  }
299 
300 
301  JFlavour_t in; //!< Incoming flavour
302  JFlavour_t out; //!< Outcoming flavour
303  JChargeParity_t Cparity; //!< Charge-parity
304 
305 
306  private:
307  /**
308  * Auxiliary class for I/O of oscillation channel.
309  */
311  public JProperties
312  {
313  /**
314  * Constructor.
315  *
316  * \param object oscillation channel
317  * \param equation equation parameters
318  */
319  template<class JOscChannel_t>
320  JOscChannelHelper(JOscChannel_t& object,
321  const JEquationParameters& equation) :
322  JProperties(equation, 1),
323  in (object.in),
324  out (object.out),
325  Cparity (object.Cparity)
326  {
327  this->insert(gmake_property(in));
328  this->insert(gmake_property(out));
329  this->insert(gmake_property(Cparity));
330  }
331 
332  int in;
333  int out;
334  int Cparity;
335  };
336  };
337 
338 
339  /**
340  * Declare group of neutrino oscillation channels.
341  */
342  static const JOscChannel getOscChannel[] = {
361  };
362 
363 
364  /**
365  * Number of neutrino oscillation channels.
366  */
367  static const int NUMBER_OF_OSCCHANNELS = sizeof(getOscChannel) / sizeof(JOscChannel);
368 }
369 
370 #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:246
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:174
Neutrino oscillation channel.
Definition: JOscChannel.hh:29
static void setEquationParameters(const JEquationParameters &equation)
Set equation parameters.
Definition: JOscChannel.hh:259
JOscChannelHelper(JOscChannel_t &object, const JEquationParameters &equation)
Constructor.
Definition: JOscChannel.hh:320
#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:108
JFlavour_t in
Incoming flavour.
Definition: JOscChannel.hh:301
#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:121
Utility class to parse parameter values.
void setProperties(const JProperties &properties)
Set properties of this class.
Definition: JOscChannel.hh:293
JProperties getProperties(const JEquationParameters &equation=JOscChannel::getEquationParameters())
Get properties of this class.
Definition: JOscChannel.hh:270
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:205
static const JOscChannel getOscChannel[]
Declare group of neutrino oscillation channels.
Definition: JOscChannel.hh:342
JChargeParity_t Cparity
Charge-parity.
Definition: JOscChannel.hh:303
static JFlavour_t getFlavour(const int pdgID)
Get flavour of neutrino.
Definition: JOscChannel.hh:140
static JFlavour_t getFlavour(const Trk &neutrino)
Get flavour of neutrino.
Definition: JOscChannel.hh:162
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:193
Auxiliary class for I/O of oscillation channel.
Definition: JOscChannel.hh:310
static int getOutgoingNeutrinoType(const JOscChannel &channel)
Auxiliary function to retrieve outgoing neutrino PDG type.
Definition: JOscChannel.hh:226
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:281
JFlavour_t out
Outcoming flavour.
Definition: JOscChannel.hh:302
static const int NUMBER_OF_OSCCHANNELS
Number of neutrino oscillation channels.
Definition: JOscChannel.hh:367
bool less(const JOscChannel &channel) const
Less-than method.
Definition: JOscChannel.hh:81