Jpp 21.0.0
the software that should make you happy
Loading...
Searching...
No Matches
JCharges.hh
Go to the documentation of this file.
1#ifndef __JPHYSICS__JCHARGES__
2#define __JPHYSICS__JCHARGES__
3
4#include <cmath>
5#include <type_traits>
6
7#include "JLang/JException.hh"
8
9
10/**
11 * \file
12 * Auxiliary methods and classes for handling Standard Model charges.
13 * \author bjjung
14 */
15
16namespace JPHYSICS {}
17namespace JPP { using namespace JPHYSICS; }
18
19namespace JPHYSICS {
20
22
23
24 /**
25 * Auxiliary class for electric charges of SM fields.
26 */
28 {
29 /**
30 * Enumeration of SM field electric charges in units [e/3]
31 */
33 MINUS_SIX = -6, // E.g. Delta-- baryon
34 MINUS_FOUR = -4, // E.g. (anti-up)-(anti-up) diquark
35 MINUS_THREE = -3, // E.g. electron
36 MINUS_TWO = -2, // E.g. anti-up quark
37 MINUS_ONE = -1, // E.g. down quark
38 ZERO = 0, // E.g. photon
39 PLUS_ONE = +1, // E.g. anti-down quark
40 PLUS_TWO = +2, // E.g. up quark
41 PLUS_THREE = +3, // E.g. positron
42 PLUS_FOUR = +4, // E.g. up-up diquark
43 PLUS_SIX = +6 // E.g. Delta++ baryon
44 };
45
46
47 /**
48 * Constructor.
49 *
50 * \param charge electric charge [e/3]
51 */
55
56
57 /**
58 * Constructor.
59 *
60 * \param charge electric charge [e/3]
61 */
62 template<typename T, std::enable_if_t<std::is_integral_v<T>, bool> = true>
64 {
65 const int Qabs = std::abs(charge);
66
67 if (Qabs <= (int) PLUS_FOUR || Qabs == (int) PLUS_SIX) {
68 this->charge = static_cast<JElectricCharge_t>(charge);
69 } else {
70 THROW(JValueOutOfRange, "JElectricCharge::JElectricCharge(): Invalid charge " << charge << " [e/3]");
71 }
72 }
73
74
75 /**
76 * Constructor.
77 *
78 * \param charge electric charge [e]
79 */
80 template<typename T, std::enable_if_t<std::is_floating_point_v<T>, bool> = true>
82 {
83 static const double epsilon = 1e-3;
84
85 const double Q = charge * 3.0;
86 const int q = std::round(Q);
87
88 if (fabs(Q - q) > epsilon) {
89 THROW(JValueOutOfRange, "JElectricCharge::JElectricCharge(): Invalid charge " << charge << " [e]");
90 }
91
92 *this = JElectricCharge(q);
93 }
94
95
96 /**
97 * Conversion operator.
98 *
99 * \return electric charge [e/3]
100 */
101 inline explicit operator int() const
102 {
103 return this->charge;
104 }
105
106
107 /**
108 * Conversion operator.
109 *
110 * \return electric charge [e]
111 */
112 inline operator double() const
113 {
114 return static_cast<double>(static_cast<int>(this->charge)) / 3.0;
115 }
116
117
118 JElectricCharge_t charge; //!< Electric charge
119 };
120
121
122 /**
123 * Auxiliary class for weak hypercharges of SM fields.
124 */
126 {
127 /**
128 * Enumeration of SM field weak hypercharges in units [1/3]
129 */
131 MINUS_SIX = -6, // right-chiral leptons
132 MINUS_FOUR = -4, // right-chiral up-type anti-quarks
133 MINUS_THREE = -3, // neutrinos and left-chiral leptons
134 MINUS_TWO = -2, // right-chiral down-type quarks
135 MINUS_ONE = -1, // left-chiral anti-quarks
136 ZERO = 0, // photon, gluon, weak bosons
137 PLUS_ONE = +1, // left-chiral quarks
138 PLUS_TWO = +2, // right-chiral anti-type anti-quarks
139 PLUS_THREE = +3, // left-chiral anti-leptons, Higgs boson
140 PLUS_FOUR = +4, // right-chiral up-type quarks
141 PLUS_SIX = +6, // right-chiral anti-leptons
142 };
143
144
145 /**
146 * Constructor.
147 *
148 * \param Yw weak hypercharge [1/3]
149 */
153
154
155 /**
156 * Constructor.
157 *
158 * \param Yw weak hypercharge [1/3]
159 */
160 template<typename T, std::enable_if_t<std::is_integral_v<T>, bool> = true>
162 {
163 const int Yabs = std::abs(Yw);
164
165 if (Yabs <= (int) PLUS_FOUR || Yabs == (int) PLUS_SIX) {
166 this->Yw = static_cast<JWeakHyperCharge_t>(Yw);
167 } else {
168 THROW(JValueOutOfRange, "JWeakHyperCharge::JWeakHyperCharge(): Invalid weak hypercharge " << Yw << " [1/3]");
169 }
170 }
171
172
173 /**
174 * Constructor.
175 *
176 * \param Yw weak hypercharge
177 */
178 template<typename T, std::enable_if_t<std::is_floating_point_v<T>, bool> = true>
180 {
181 static const double epsilon = 1e-3;
182
183 const double Y = Yw * 3.0;
184 const int y = std::round(Y);
185
186 if (fabs(Y - y) > epsilon) {
187 THROW(JValueOutOfRange, "JWeakHyperCharge::JWeakHyperCharge(): Invalid weak hypercharge " << Yw);
188 }
189
190 *this = JWeakHyperCharge(y);
191 }
192
193
194 /**
195 * Conversion operator.
196 *
197 * \return weak hypercharge [1/3]
198 */
199 inline explicit operator int() const
200 {
201 return this->Yw;
202 }
203
204
205 /**
206 * Conversion operator.
207 *
208 * \return weak hypercharge
209 */
210 inline operator double() const
211 {
212 return static_cast<double>(static_cast<int>(this->Yw)) / 3.0;
213 }
214
215
216 JWeakHyperCharge_t Yw; //!< Weak hypercharge
217 };
218
219
220 /**
221 * Auxiliary class for weak isospin projections of SM fields.
222 */
224 {
225 /**
226 * Enumeration of SM field weak isospin projections in units [1/2]
227 */
229 MINUS_TWO = -2, //!< W^- boson weak isospin projection
231 ZERO = 0,
233 PLUS_TWO = +2 //!< W^+ boson weak isospin projection
234 };
235
236
237 /**
238 * Constructor.
239 *
240 * \param I3 weak isospin projection [1/2]
241 */
245
246
247 /**
248 * Constructor.
249 *
250 * \param I3 weak isospin projection [1/2]
251 */
252 template<typename T, std::enable_if_t<std::is_integral_v<T>, bool> = true>
254 {
255 const int I3abs = std::abs(I3);
256
257 if (I3abs <= (int) PLUS_TWO) {
258 this->I3 = static_cast<JWeakIsospinProjection_t>(I3);
259 } else {
260 THROW(JValueOutOfRange, "JWeakIsospinProjection::JWeakIsospinProjection(): Invalid weak isospin projection " << I3 << " [1/2]");
261 }
262 }
263
264
265 /**
266 * Constructor.
267 *
268 * \param I3 weak isospin projection
269 */
270 template<typename T, std::enable_if_t<std::is_floating_point_v<T>, bool> = true>
272 {
273 static const double epsilon = 1e-3;
274
275 const double I = I3 * 2.0;
276 const int i = std::round(I);
277
278 if (fabs(I - i) > epsilon) {
279 THROW(JValueOutOfRange, "JWeakIsospinProjection::JWeakIsospinProjection(): Invalid weak isospin projection " << I3);
280 }
281
282 *this = JWeakIsospinProjection(i);
283 }
284
285
286 /**
287 * Conversion operator.
288 *
289 * \return weak isospin projection
290 */
291 inline explicit operator int() const
292 {
293 return this->I3;
294 }
295
296
297 /**
298 * Conversion operator.
299 *
300 * \return weak isospin projection
301 */
302 inline operator double() const
303 {
304 return static_cast<double>(static_cast<int>(I3)) / 2.0;
305 }
306
307
308 JWeakIsospinProjection_t I3; //!< Weak isospin projection
309 };
310
311
312 /**
313 * Auxiliary class for color factors of SM fields.
314 */
316 {
317 /**
318 * Enumeration of SM field color factors.
319 */
321 ONE = 1, //!< leptons, weak bosons, photon
322 THREE = 3, //!< quarks
323 EIGHT = 8 //!< gluon
324 };
325
326
327 /**
328 * Constructor.
329 *
330 * \param C color factor
331 */
333 C(C)
334 {}
335
336
337 /**
338 * Constructor.
339 *
340 * \param C color factor
341 */
342 template<typename T, std::enable_if_t<std::is_integral_v<T>, bool> = true>
343 JColorFactor(const T C)
344 {
345 switch (C) {
346 case ONE:
347 case THREE:
348 case EIGHT:
349 this->C = static_cast<JColorFactor_t>(C);
350 break;
351 default:
352 THROW(JValueOutOfRange, "JColorFactor::JColorFactor(): Invalid color factor " << C);
353 }
354 }
355
356
357 /**
358 * Conversion operator.
359 *
360 * \return color factor
361 */
362 inline operator int() const
363 {
364 return this->C;
365 }
366
367
368 JColorFactor_t C; //!< Color factor
369 };
370
371
372 /**
373 * Enumeration for color factors of SM fields.
374 */
375 enum class JColorFactor_t : int {
376 ZERO = 0,
377 ONE = 1,
378 THREE = 3
379 };
380
381
382 /**
383 * Enumeration for color charges of SM fields.
384 */
385 enum class JColorCharge_t : char {
386 RED = 'r',
387 BLUE = 'b',
388 GREEN = 'g'
389 };
390}
391
392#endif
Exceptions.
#define THROW(JException_t, A)
Marco for throwing exception with std::ostream compatible message.
Exception for accessing a value in a collection that is outside of its range.
Auxiliary methods for light properties of deep-sea water.
JColorFactor_t
Enumeration for color factors of SM fields.
Definition JCharges.hh:375
JColorCharge_t
Enumeration for color charges of SM fields.
Definition JCharges.hh:385
This name space includes all other name spaces (except KM3NETDAQ, KM3NET and ANTARES).
Auxiliary class for color factors of SM fields.
Definition JCharges.hh:316
JColorFactor(const JColorFactor_t &C)
Constructor.
Definition JCharges.hh:332
JColorFactor(const T C)
Constructor.
Definition JCharges.hh:343
JColorFactor_t
Enumeration of SM field color factors.
Definition JCharges.hh:320
@ ONE
leptons, weak bosons, photon
Definition JCharges.hh:321
JColorFactor_t C
Color factor.
Definition JCharges.hh:368
Auxiliary class for electric charges of SM fields.
Definition JCharges.hh:28
JElectricCharge_t charge
Electric charge.
Definition JCharges.hh:118
JElectricCharge_t
Enumeration of SM field electric charges in units [e/3].
Definition JCharges.hh:32
JElectricCharge(const T charge)
Constructor.
Definition JCharges.hh:63
JElectricCharge(const JElectricCharge_t &charge)
Constructor.
Definition JCharges.hh:52
Auxiliary class for weak hypercharges of SM fields.
Definition JCharges.hh:126
JWeakHyperCharge_t Yw
Weak hypercharge.
Definition JCharges.hh:216
JWeakHyperCharge(const JWeakHyperCharge_t &Yw)
Constructor.
Definition JCharges.hh:150
JWeakHyperCharge_t
Enumeration of SM field weak hypercharges in units [1/3].
Definition JCharges.hh:130
JWeakHyperCharge(const T Yw)
Constructor.
Definition JCharges.hh:161
Auxiliary class for weak isospin projections of SM fields.
Definition JCharges.hh:224
JWeakIsospinProjection(const JWeakIsospinProjection_t &I3)
Constructor.
Definition JCharges.hh:242
JWeakIsospinProjection_t
Enumeration of SM field weak isospin projections in units [1/2].
Definition JCharges.hh:228
@ PLUS_TWO
W^+ boson weak isospin projection.
Definition JCharges.hh:233
@ MINUS_TWO
W^- boson weak isospin projection.
Definition JCharges.hh:229
JWeakIsospinProjection(const T I3)
Constructor.
Definition JCharges.hh:253
JWeakIsospinProjection_t I3
Weak isospin projection.
Definition JCharges.hh:308