Jpp test-rotations-old
the software that should make you happy
Loading...
Searching...
No Matches
JOscChannel.hh
Go to the documentation of this file.
1#ifndef __JOSCPROB__JOSCCHANNEL__
2#define __JOSCPROB__JOSCCHANNEL__
3
4#include <iostream>
5
8
10
11#include "Jeep/JProperties.hh"
12
13
14/**
15 * \author bjung
16 * \file
17 * Oscillation channels and auxiliary methods.
18 */
19
20namespace JOSCPROB {}
21namespace JPP { using namespace JOSCPROB; }
22
23namespace JOSCPROB {
24
26
27
28 /**
29 * Neutrino flavours.
30 */
31 enum class JFlavour_t { ELECTRON = 12,
32 MUON = 14,
33 TAU = 16,
35
36
37 /**
38 * Charge parities.
39 */
40 enum class JChargeParity_t { ANTIPARTICLE = -1,
41 PARTICLE = +1,
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:
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) {
87 } else if (pdgType > 0) {
89 } else {
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 */
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 */
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),
136 {}
137
138
139 /**
140 * Constructor.
141 *
142 * \param in input flavour
143 * \param out output flavour
144 * \param Cparity charge parity
145 */
146 JOscChannel(const int in,
147 const int out,
148 const int Cparity) :
149 in (getFlavour(in)),
152 {}
153
154
155 /**
156 * Check validity of this oscillation channel.
157 *
158 * \return true if this oscillation channel is valid; else false.
159 */
166
167
168 /**
169 * Less-than method
170 *
171 * \param channel channel
172 * \return true this channel less than given channel; else false
173 */
174 inline bool less(const JOscChannel& channel) const
175 {
176 if (this->Cparity == channel.Cparity) {
177
178 if (this->in == channel.in) {
179
180 return this->out < channel.out;
181
182 } else {
183
184 return this->in < channel.in;
185 }
186
187 } else {
188
189 return this->Cparity < channel.Cparity;
190 }
191 }
192
193
194 /**
195 * Write channel to output.
196 *
197 * \param out output stream
198 * \param object oscillation channel
199 * \return output stream
200 */
201 friend inline std::ostream& operator<<(std::ostream& out, const JOscChannel& object)
202 {
203 return out << object.getProperties();
204 }
205
206
207 /**
208 * Read channel from input.
209 *
210 * \param in input stream
211 * \param object oscillation channel
212 * \return input stream
213 */
214 friend inline std::istream& operator>>(std::istream& in, JOscChannel& object)
215 {
216 JProperties properties(object.getProperties());
217
218 in >> properties;
219
220 object.setProperties(properties);
221
222 return in;
223 }
224
225
226 /**
227 * Get equation parameters.
228 *
229 * \return equation parameters
230 */
232 {
233 static JEquationParameters equation("=", "\n\r;,", "./", "#");
234
235 return equation;
236 }
237
238
239 /**
240 * Set equation parameters.
241 *
242 * \param equation equation parameters
243 */
244 static inline void setEquationParameters(const JEquationParameters& equation)
245 {
246 getEquationParameters() = equation;
247 }
248
249
250 /**
251 * Get properties of this class.
252 *
253 * \param equation equation parameters
254 */
256 {
257 return JOscChannelHelper(*this, equation);
258 }
259
260
261 /**
262 * Get properties of this class.
263 *
264 * \param equation equation parameters
265 */
267 {
268 return JOscChannelHelper(*this, equation);
269 }
270
271
272 /**
273 * Set properties of this class
274 *
275 * \param properties properties
276 */
277 void setProperties(const JProperties& properties)
278 {
279 this->in = getFlavour (properties.getValue<int>("in"));
280 this->out = getFlavour (properties.getValue<int>("out"));
281 this->Cparity = getChargeParity(properties.getValue<int>("Cparity"));
282 }
283
284
285 JFlavour_t in; //!< Incoming flavour
286 JFlavour_t out; //!< Outcoming flavour
287 JChargeParity_t Cparity; //!< Charge-parity
288
289
290 private:
291 /**
292 * Auxiliary class for I/O of oscillation channel.
293 */
295 public JProperties
296 {
297 /**
298 * Constructor.
299 *
300 * \param object oscillation channel
301 * \param equation equation parameters
302 */
303 template<class JOscChannel_t>
304 JOscChannelHelper(JOscChannel_t& object,
305 const JEquationParameters& equation) :
306 JProperties(equation, 1),
307 in ((int) object.in),
308 out ((int) object.out),
309 Cparity ((int) object.Cparity)
310 {
311 this->insert(gmake_property(in));
312 this->insert(gmake_property(out));
313 this->insert(gmake_property(Cparity));
314 }
315
316 int in;
317 int out;
319 };
320 };
321
322
323 /**
324 * Declare group of neutrino oscillation channels.
325 */
326 static const JOscChannel getOscChannel[] = {
345 };
346
347
348 /**
349 * Number of neutrino oscillation channels.
350 */
351 static const unsigned int NUMBER_OF_OSCCHANNELS = sizeof(getOscChannel) / sizeof(JOscChannel);
352}
353
354#endif
Utility class to parse parameter values.
#define gmake_property(A)
macros to convert (template) parameter to JPropertiesElement object
Utility class to parse parameter values.
const T & getValue(const std::string &key) const
Get value.
Simple data structure to support I/O of equations (see class JLANG::JEquation).
JChargeParity_t
Charge parities.
JFlavour_t
Neutrino flavours.
static const JOscChannel getOscChannel[]
Declare group of neutrino oscillation channels.
static const unsigned int NUMBER_OF_OSCCHANNELS
Number of neutrino oscillation channels.
JChargeParity_t getChargeParity(const int pdgType)
Auxiliary function for retrieving the charge-parity of a given PDG type.
JFlavour_t getFlavour(const int pdgType)
Auxiliary function for retrieving the flavour corresponding to a given PDG identifier.
This name space includes all other name spaces (except KM3NETDAQ, KM3NET and ANTARES).
Template definition of auxiliary base class for comparison of data structures.
Auxiliary class for I/O of oscillation channel.
JOscChannelHelper(JOscChannel_t &object, const JEquationParameters &equation)
Constructor.
Neutrino oscillation channel.
friend std::ostream & operator<<(std::ostream &out, const JOscChannel &object)
Write channel to output.
JOscChannel(const JFlavour_t in, const JFlavour_t out, const JChargeParity_t Cparity)
Constructor.
void setProperties(const JProperties &properties)
Set properties of this class.
JProperties getProperties(const JEquationParameters &equation=JOscChannel::getEquationParameters()) const
Get properties of this class.
static void setEquationParameters(const JEquationParameters &equation)
Set equation parameters.
friend std::istream & operator>>(std::istream &in, JOscChannel &object)
Read channel from input.
JChargeParity_t Cparity
Charge-parity.
JProperties getProperties(const JEquationParameters &equation=JOscChannel::getEquationParameters())
Get properties of this class.
JFlavour_t in
Incoming flavour.
static JEquationParameters & getEquationParameters()
Get equation parameters.
bool less(const JOscChannel &channel) const
Less-than method.
JFlavour_t out
Outcoming flavour.
bool is_valid() const
Check validity of this oscillation channel.
JOscChannel()
Default constructor.
JOscChannel(const int in, const int out, const int Cparity)
Constructor.
The Trk class represents a Monte Carlo (MC) particle as well as a reconstructed track/shower.
Definition Trk.hh:15
int type
MC: particle type in PDG encoding.
Definition Trk.hh:24