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