#include <pdgcode.h>
PdgCode stores a Particle Data Group Particle Numbering Scheme particle type number.
This class contains a collection of smart accessors to the PDG code so that quantum numbers etc can easily be read off.
The content is stored in hexadecimal digits, i.e., the number '545' is interpreted as '0x221', i.e., an eta-meson. To check if a given particle is of a given type, make sure that you give the type in hex digits as well (see example above).
The reason for that is that the concept of PdgCodes, especially for Hadrons, is not one of wholesale numbers, but one of concatenated digits. Using hexadecimally interpreted digits makes it numerically very easy to access the separate digits (there's no arithmetic involved with successive divisions by 10 and taking the remainder etc.).
Following PDG standard, nuclei are represented by codes ±10LZZZAAAI, where L is number of Lambdas inside the nucleus, ZZZ is charge, AAA is mass number and I is used for excitations. Internally nuclei are represented in a different way from hadrons, but all accessors (charge, baryon number, etc) work in the same way.
Normally nuclei in SMASH are simulated as a collection of protons and neutrons, so there is no need in their PDG codes. However, it is interesting to study light nuclei production, considering them as single pointlike hadrons. This justifies introduction of nuclear PDG codes here.
The code is tuned to non-colored objects at the moment. That means that colored objects (Diquarks and Quarks) are not easily useable with this class; the behaviour of functions baryon_number, charge, is_hadron etc. is undefined. (This is mostly because these things are not well-defined, and/or because the charge and baryon number is not an integer anymore.)
Also, tetra- and pentaquarks cannot be represented; that, though, is a problem of the PDG Numbering Scheme rather than of this class.
Classes | |
struct | InvalidPdgCode |
thrown for invalid inputs More... | |
Public Member Functions | |
PdgCode () | |
Standard initializer. More... | |
PdgCode (const std::string &codestring) | |
Initialize using a string The string is interpreted as a hexadecimal number, i.e., 211 is interpreted as 0x211 = \(529_{10}\). More... | |
PdgCode (std::int32_t codenumber) | |
Receive a signed integer and process it into a PDG Code. More... | |
PdgCode (const std::uint32_t abscode) | |
Receive an unsigned integer and process it into a PDG Code. More... | |
template<typename T > | |
PdgCode (T codenumber, typename std::enable_if_t< std::is_integral_v< T > &&4< sizeof(T), bool >=true) | |
The creation of PdgCode instances for nuclei that have a 10-digits code cannot be done using the integer constructors above, since a 10-digits hexadecimal number like 0x1000020030 exceeds the int32_t capacity. More... | |
int | test_code () const |
Checks the integer for invalid hex digits. More... | |
void | check () const |
Do all sorts of validity checks. More... | |
std::uint32_t | dump () const |
Dumps the bitfield into an unsigned integer. More... | |
std::int32_t | code () const |
std::string | string () const |
PdgCode | get_antiparticle () const |
Construct the antiparticle to a given PDG code. More... | |
bool | is_nucleus () const |
bool | is_hadron () const |
bool | is_lepton () const |
int | baryon_number () const |
bool | is_baryon () const |
bool | is_meson () const |
bool | is_nucleon () const |
bool | is_proton () const |
bool | is_neutron () const |
bool | is_Nstar1535 () const |
bool | is_Delta () const |
bool | is_hyperon () const |
bool | is_Omega () const |
bool | is_Xi () const |
bool | is_Lambda () const |
bool | is_Sigma () const |
bool | is_kaon () const |
bool | is_pion () const |
bool | is_omega () const |
bool | is_rho () const |
bool | is_deuteron () const |
bool | is_triton () const |
bool | has_antiparticle () const |
int | isospin3 () const |
double | frac_strange () const |
int | strangeness () const |
int | charmness () const |
int | bottomness () const |
int | charge () const |
The charge of the particle. More... | |
unsigned int | spin () const |
unsigned int | spin_degeneracy () const |
int | antiparticle_sign () const |
std::int32_t | quarks () const |
std::array< int, 3 > | quark_content () const |
The return is always an array of three numbers, which are pdgcodes of quarks: 1 - d, 2 - u, 3 - s, 4 - c, 5 - b. More... | |
bool | contains_enough_valence_quarks (int valence_quarks_required) const |
bool | operator< (const PdgCode rhs) const |
Sorts PDG Codes according to their numeric value. More... | |
bool | operator== (const PdgCode rhs) const |
bool | operator!= (const PdgCode rhs) const |
bool | is_antiparticle_of (const PdgCode rhs) const |
int32_t | get_decimal () const |
void | deexcite () |
Remove all excitation, except spin. Sign and quark content remains. More... | |
int | net_quark_number (const int quark) const |
Returns the net number of quarks with given flavour number For public use, see strangeness(), charmness(), bottomness() and isospin3(). More... | |
int | nucleus_p () const |
Number of protons in nucleus. More... | |
int | nucleus_n () const |
Number of neutrons in nucleus. More... | |
int | nucleus_La () const |
Number of Lambdas in nucleus. More... | |
int | nucleus_ap () const |
Number of antiprotons in nucleus. More... | |
int | nucleus_an () const |
Number of antineutrons in nucleus. More... | |
int | nucleus_aLa () const |
Number of anti-Lambdas in nucleus. More... | |
int | nucleus_A () const |
Nucleus mass number. More... | |
Static Public Member Functions | |
static PdgCode | from_decimal (const int pdgcode_decimal) |
Construct PDG code from decimal number. More... | |
static PdgCode | invalid () |
PdgCode 0x0 is guaranteed not to be valid by the PDG standard, but it passes all tests here, so we can use it to show some code is not yet set. More... | |
Private Member Functions | |
std::uint32_t | ucode () const |
std::uint32_t | get_digit_from_char (const char inp) const |
void | set_from_string (const std::string &codestring) |
Set the PDG code from the given string. More... | |
void | set_fields (std::uint32_t abscode) |
Sets the bitfield from an unsigned integer. More... | |
Private Attributes | |
union { | |
struct { | |
std::uint32_t n_J_: 4 | |
spin quantum number \(n_J = 2 J + 1\). More... | |
std::uint32_t n_q3_: 4 | |
third quark field More... | |
std::uint32_t n_q2_: 4 | |
second quark field More... | |
std::uint32_t n_q1_: 4 | |
first quark field. 0 for mesons. More... | |
std::uint32_t n_L_: 4 | |
"angular momentum" More... | |
std::uint32_t n_R_: 4 | |
"radial excitation" More... | |
std::uint32_t n_: 4 | |
first field: "counter" More... | |
std::uint32_t bool is_nucleus_: 2: 1 | |
1 for nuclei, 0 for the rest More... | |
bool antiparticle_: 1 | |
first bit: stores the sign. More... | |
} digits_ | |
The single digits collection of the code. More... | |
std::uint32_t dump_ | |
The bitfield dumped into a single integer. More... | |
struct { | |
std::uint32_t __pad0__: 4 | |
std::uint32_t quarks_: 12 | |
The quark digits n_q{1,2,3}_. More... | |
std::uint32_t excitation_: 12 | |
The excitation digits n_, n_R_, n_L_. More... | |
} chunks_ | |
Chunk collection: here, the chunks with \(nn_Rn_L\) and \(n_{q_1}n_{q_2}n_{q_3}\) are directly accessible. More... | |
struct { | |
std::uint32_t n_Lambda_: 6 | |
std::uint32_t Z_: 10 | |
std::uint32_t A_: 10 | |
std::uint32_t I_: 4 | |
bool is_nucleus_: 1 | |
bool antiparticle_: 1 | |
} nucleus_ | |
Structure for the nuclei. More... | |
}; | |
The union holds the data; either as a single integer dump_, as a single-digit bitfield digits_ or as a multiple-digits bitfield chunks_. More... | |
Friends | |
std::istream & | operator>> (std::istream &is, PdgCode &code) |
istream >> PdgCode assigns the PDG Code from an istream. More... | |
|
inline |
Standard initializer.
Definition at line 128 of file pdgcode.h.
|
inlineexplicit |
Initialize using a string The string is interpreted as a hexadecimal number, i.e., 211
is interpreted as 0x211
= \(529_{10}\).
Definition at line 134 of file pdgcode.h.
|
inline |
Receive a signed integer and process it into a PDG Code.
The sign is taken as antiparticle boolean, while the absolute value of the integer is used as hexdigits.
[in] | codenumber | a signed integer which represent the PDG code The number 0x221 is interpreted as an η meson, -0x211 is a "charged pi antiparticle", i.e., a \(\pi^-\). |
Definition at line 146 of file pdgcode.h.
|
inlineexplicit |
|
inline |
The creation of PdgCode
instances for nuclei that have a 10-digits code cannot be done using the integer constructors above, since a 10-digits hexadecimal number like 0x1000020030 exceeds the int32_t capacity.
Nuclei instances can in principle either be created with the string constructor or via the PdgCode::from_decimal()
static member, but offering a uniform interface for all cases is definitely user-friendly.
Since the string constructor works, we delegate here the construction to it. In order to execute the needed code to built the string in the member initializer list, we use a common lambda idiom (IIFE) that consists in immediately invoking a lambda function. Using std::invoke
makes it more explicit than using () after the lambda braces.
int64_t
argument. The reason is to facilitate the class usage. Having a fixed type would have required the users of this class to exactly match the argument type (and for int64_t
there is no standard literal suffix), otherwise the call would have been ambiguous and compilation would have failed. Said differently, we would like int64_t
number. The idea here is to offer a better matching to the compiler when the constructor is called with an integer type with size larger than 4 bytes. Type-traits are used to limit the template instantiation to reasonable cases, only.[in] | codenumber | The hexadecimal PDG code |
T | The type of the PDG code, irrelevant for the user and deduced by the compiler |
Definition at line 220 of file pdgcode.h.
|
inline |
Checks the integer for invalid hex digits.
Usually all digits are at least <= 9. The n_q digits are even <= 6 (because there are only six quarks). The only exception is n_J, where we allow f = 15, which is the largest hexadecimal digit. If one of the hex digits is not also a valid decimal digit, something possibly went wrong - maybe some user of this class forgot to prefix the input with '0x' and thus passed 221 instead of 0x221.
Definition at line 253 of file pdgcode.h.
|
inline |
Do all sorts of validity checks.
InvalidPdgCode | if meson has even n_J_ (fermionic spin) |
InvalidPdgCode | if baryon has odd n_J_ (bosonic spin) |
InvalidPdgCode | if n_J_ is 0 (spin is not defined.) |
InvalidPdgCode | if particle does not have antiparticle when it is supposed to do. |
Definition at line 287 of file pdgcode.h.
|
inline |
|
inline |
|
inline |
|
inline |
|
inlinestatic |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
This is calculated from the sum of net_quark_number of up and down.
Definition at line 506 of file pdgcode.h.
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
The charge of the particle.
The charge is calculated from the quark content (for hadrons) or basically tabulated; currently leptons, neutrinos and the standard model gauge bosons are known; unknown particles return a charge of 0.
Definition at line 567 of file pdgcode.h.
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
The return is always an array of three numbers, which are pdgcodes of quarks: 1 - d, 2 - u, 3 - s, 4 - c, 5 - b.
Antiquarks get a negative sign. For mesons the first number in array is always 0. There is a difficulty with mesons that are a superposition, for example \( \pi^0 = \frac{1}{\sqrt{2}}(u \bar{u} + d \bar{d}) \). Currently for \( \pi^0 \) just {0, 1, -1} is returned.
Definition at line 671 of file pdgcode.h.
bool smash::PdgCode::contains_enough_valence_quarks | ( | int | valence_quarks_required | ) | const |
[in] | valence_quarks_required | number of valence quarks that particle is supposed to contain. |
std::runtime_error | if it is not a hadron |
This is necessary for string fragmentation.
Definition at line 92 of file pdgcode.cc.
|
inline |
|
inline |
|
inline |
|
inline |
|
inlinestatic |
|
inline |
InvalidPdgCode | if the spin degeneracy is larger than 9 |
Definition at line 769 of file pdgcode.h.
|
inline |
int smash::PdgCode::net_quark_number | ( | const int | quark | ) | const |
Returns the net number of quarks with given flavour number For public use, see strangeness(), charmness(), bottomness() and isospin3().
[in] | quark | PDG Code of quark: (1..6) = (d,u,s,c,b,t) |
std::invalid_argument | if quark is not any of d, u, s, c, b and t quarks |
Definition at line 31 of file pdgcode.cc.
|
inline |
Number of protons in nucleus.
|
inline |
|
inline |
Number of Lambdas in nucleus.
|
inline |
Number of antiprotons in nucleus.
|
inline |
|
inline |
Number of anti-Lambdas in nucleus.
|
inline |
|
inlineprivate |
|
inlineprivate |
[in] | inp | character which is translated into digit |
InvalidPdgCode | if character does not correspond to digit |
Definition at line 942 of file pdgcode.h.
|
inlineprivate |
Set the PDG code from the given string.
This supports hexdecimal digits. If the last digit is not enough to represent the spin, a digit can be added at the beginning which will be added to the total spin.
[in] | codestring | string which is translated into PdgCode |
InvalidPdgCode | if the input string is empty |
InvalidPdgCode | if it is a nucleus whose PDG code does not begin with 10 |
InvalidPdgCode | if it is not a nucleus while number of digits is more than 8 |
InvalidPdgCode | if the 1st quark field is not any of d, u, s, c, b and t quarks |
InvalidPdgCode | if the 2nd quark field is not any of d, u, s, c, b and t quarks |
InvalidPdgCode | if the 3rd quark field is not any of d, u, s, c, b and t quarks |
InvalidPdgCode | if there is nothing else but sign |
Definition at line 980 of file pdgcode.h.
|
inlineprivate |
Sets the bitfield from an unsigned integer.
Usually called from the constructors.
[in] | abscode | integer which replace PDG code except sign |
InvalidPdgCode | if input is not a valid PDG code |
Definition at line 1085 of file pdgcode.h.
|
friend |
istream >> PdgCode assigns the PDG Code from an istream.
[in] | is | input string |
[out] | code | PdgCode to be set |
Definition at line 14 of file pdgcode.cc.
std::uint32_t smash::PdgCode::n_J_ |
std::uint32_t smash::PdgCode::n_q1_ |
std::uint32_t bool smash::PdgCode::is_nucleus_ |
bool smash::PdgCode::antiparticle_ |
struct { ... } smash::PdgCode::digits_ |
The single digits collection of the code.
Here, every PDG code digits is directly accessible.
std::uint32_t smash::PdgCode::dump_ |
std::uint32_t smash::PdgCode::quarks_ |
std::uint32_t smash::PdgCode::excitation_ |
struct { ... } smash::PdgCode::chunks_ |
Chunk collection: here, the chunks with \(nn_Rn_L\) and \(n_{q_1}n_{q_2}n_{q_3}\) are directly accessible.
struct { ... } smash::PdgCode::nucleus_ |
Structure for the nuclei.
union { ... } |
The union holds the data; either as a single integer dump_, as a single-digit bitfield digits_ or as a multiple-digits bitfield chunks_.