Jpp 21.0.0
the software that should make you happy
Loading...
Searching...
No Matches
JPHYSICS::JElectricCharge Struct Reference

Auxiliary class for electric charges of SM fields. More...

#include <JCharges.hh>

Public Types

enum  JElectricCharge_t {
  MINUS_SIX = -6 , MINUS_FOUR = -4 , MINUS_THREE = -3 , MINUS_TWO = -2 ,
  MINUS_ONE = -1 , ZERO = 0 , PLUS_ONE = +1 , PLUS_TWO = +2 ,
  PLUS_THREE = +3 , PLUS_FOUR = +4 , PLUS_SIX = +6
}
 Enumeration of SM field electric charges in units [e/3]. More...
 

Public Member Functions

 JElectricCharge (const JElectricCharge_t &charge)
 Constructor.
 
template<typename T , std::enable_if_t< std::is_integral_v< T >, bool > = true>
 JElectricCharge (const T charge)
 Constructor.
 
template<typename T , std::enable_if_t< std::is_floating_point_v< T >, bool > = true>
 JElectricCharge (const T charge)
 Constructor.
 
 operator int () const
 Conversion operator.
 
 operator double () const
 Conversion operator.
 

Public Attributes

JElectricCharge_t charge
 Electric charge.
 

Detailed Description

Auxiliary class for electric charges of SM fields.

Definition at line 27 of file JCharges.hh.

Member Enumeration Documentation

◆ JElectricCharge_t

Enumeration of SM field electric charges in units [e/3].

Enumerator
MINUS_SIX 
MINUS_FOUR 
MINUS_THREE 
MINUS_TWO 
MINUS_ONE 
ZERO 
PLUS_ONE 
PLUS_TWO 
PLUS_THREE 
PLUS_FOUR 
PLUS_SIX 

Definition at line 32 of file JCharges.hh.

32 {
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 };

Constructor & Destructor Documentation

◆ JElectricCharge() [1/3]

JPHYSICS::JElectricCharge::JElectricCharge ( const JElectricCharge_t & charge)
inline

Constructor.

Parameters
chargeelectric charge [e/3]

Definition at line 52 of file JCharges.hh.

52 :
54 {}
JElectricCharge_t charge
Electric charge.
Definition JCharges.hh:118

◆ JElectricCharge() [2/3]

template<typename T , std::enable_if_t< std::is_integral_v< T >, bool > = true>
JPHYSICS::JElectricCharge::JElectricCharge ( const T charge)
inline

Constructor.

Parameters
chargeelectric charge [e/3]

Definition at line 63 of file JCharges.hh.

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 }
#define THROW(JException_t, A)
Marco for throwing exception with std::ostream compatible message.
JElectricCharge_t
Enumeration of SM field electric charges in units [e/3].
Definition JCharges.hh:32

◆ JElectricCharge() [3/3]

template<typename T , std::enable_if_t< std::is_floating_point_v< T >, bool > = true>
JPHYSICS::JElectricCharge::JElectricCharge ( const T charge)
inline

Constructor.

Parameters
chargeelectric charge [e]

Definition at line 81 of file JCharges.hh.

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 }
JElectricCharge(const JElectricCharge_t &charge)
Constructor.
Definition JCharges.hh:52

Member Function Documentation

◆ operator int()

JPHYSICS::JElectricCharge::operator int ( ) const
inlineexplicit

Conversion operator.

Returns
electric charge [e/3]

Definition at line 101 of file JCharges.hh.

102 {
103 return this->charge;
104 }

◆ operator double()

JPHYSICS::JElectricCharge::operator double ( ) const
inline

Conversion operator.

Returns
electric charge [e]

Definition at line 112 of file JCharges.hh.

113 {
114 return static_cast<double>(static_cast<int>(this->charge)) / 3.0;
115 }

Member Data Documentation

◆ charge

JElectricCharge_t JPHYSICS::JElectricCharge::charge

Electric charge.

Definition at line 118 of file JCharges.hh.


The documentation for this struct was generated from the following file: