10 #ifndef SRC_INCLUDE_SMASH_PDGCODE_H_
11 #define SRC_INCLUDE_SMASH_PDGCODE_H_
115 using std::invalid_argument::invalid_argument;
131 explicit PdgCode(
const std::string& codestring) {
145 if (codenumber < 0) {
147 codenumber = -codenumber;
157 digits_.antiparticle_ = ((abscode & 0x80000000u) != 0);
221 " (meson with even n_J)");
226 " (baryon with odd n_J)");
231 throw InvalidPdgCode(
"Invalid PDG code " +
string() +
" (n_J==0)");
238 " (cannot be negative)");
243 inline std::uint32_t
dump()
const {
245 return (
dump_ & 0x8fffffff);
253 std::stringstream ss;
271 if (std::abs(pdgcode_decimal) > 1E7) {
272 return PdgCode(std::to_string(pdgcode_decimal));
274 int a = pdgcode_decimal;
275 int hex_pdg = 0, tmp = 1;
277 hex_pdg += (a % 10) * tmp;
325 const auto abs_code = std::abs(
code());
331 const auto abs_code = std::abs(
code());
332 return (abs_code ==
pdg::p);
337 const auto abs_code = std::abs(
code());
338 return (abs_code ==
pdg::n);
343 const auto abs_code = std::abs(
code());
349 const auto abs_code = std::abs(
code());
379 const auto abs_code = std::abs(
code());
385 const auto c =
code();
391 const auto c =
code();
496 for (
int i = 1; i < 7; i++) {
513 if ((
dump_ & 0x0000ffff) == 0x24) {
529 inline unsigned int spin()
const {
546 throw std::runtime_error(
"Unknown spin of nucleus.");
573 return (
digits_.antiparticle_ ? -1 : +1);
593 std::array<int, 3> result = {
static_cast<int>(
digits_.n_q1_),
594 static_cast<int>(
digits_.n_q2_),
595 static_cast<int>(
digits_.n_q3_)};
599 for (
size_t i = 0; i < 3; i++) {
600 result[i] = -result[i];
607 result[2] = -result[2];
611 result[1] = -result[1];
614 result[2] = -result[2];
619 for (
int i = 1; i <= 2; i++) {
620 result[i] = -result[i];
695 10000000 *
nucleus_.n_Lambda_ + 1000000000);
773 #if defined(LITTLE_ENDIAN_ARCHITECTURE) || defined(DOXYGEN)
787 std::uint32_t
n_ : 4, : 2;
792 #elif defined(BIG_ENDIAN_ARCHITECTURE)
795 std::uint32_t
n_ : 4;
796 std::uint32_t
n_R_ : 4;
797 std::uint32_t
n_L_ : 4;
798 std::uint32_t
n_q1_ : 4;
799 std::uint32_t
n_q2_ : 4;
800 std::uint32_t
n_q3_ : 4;
801 std::uint32_t
n_J_ : 4;
803 #error Endianness macro of the machine not defined.
816 #if defined(LITTLE_ENDIAN_ARCHITECTURE) || defined(DOXYGEN)
822 #elif defined(BIG_ENDIAN_ARCHITECTURE)
824 std::uint32_t
quarks_ : 12, : 4;
826 #error Endianness macro of the machine not defined.
831 #if defined(LITTLE_ENDIAN_ARCHITECTURE) || defined(DOXYGEN)
833 std::uint32_t
Z_ : 10;
834 std::uint32_t
A_ : 10;
835 std::uint32_t
I_ : 4;
838 #elif defined(BIG_ENDIAN_ARCHITECTURE)
841 std::uint32_t
I_ : 4;
842 std::uint32_t
A_ : 10;
843 std::uint32_t
Z_ : 10;
846 #error Endianness macro of the machine not defined.
855 inline std::uint32_t
ucode()
const {
return (
dump_ & 0x0fffffff); }
865 if (48 <= inp && inp <= 57) {
869 if (65 <= inp && inp <= 70) {
870 return inp - 65 + 10;
873 if (97 <= inp && inp <= 102) {
874 return inp - 97 + 10;
876 throw InvalidPdgCode(
"PdgCode: Invalid character " + std::string(&inp, 1) +
906 size_t length = codestring.size();
913 if (codestring[c] ==
'-') {
916 }
else if (codestring[c] ==
'+') {
921 unsigned int sign = c;
924 if (length == 10 + sign) {
926 if (codestring[c] !=
'1' || codestring[c + 1] !=
'0') {
928 "\" should start with 10\n");
932 std::array<int, 8> digits;
933 for (
int i = 0; i < 8; i++) {
937 nucleus_.Z_ = 100 * digits[1] + 10 * digits[2] + digits[3];
938 nucleus_.A_ = 100 * digits[4] + 10 * digits[5] + digits[6];
944 if (length > 8 + sign) {
946 "\" too long for PDG Code\n");
950 if (length > 7 + sign) {
954 if (length > 6 + sign) {
958 if (length > 5 + sign) {
962 if (length > 4 + sign) {
966 if (length > 3 + sign) {
969 throw InvalidPdgCode(
"Invalid PDG code " + codestring +
" (n_q1>6)");
973 if (length > 2 + sign) {
976 throw InvalidPdgCode(
"Invalid PDG code " + codestring +
" (n_q2>6)");
980 if (length > 1 + sign) {
983 throw InvalidPdgCode(
"Invalid PDG code " + codestring +
" (n_q3>6)");
991 "String \"" + codestring +
992 "\" only consists of a sign, that is no valid PDG Code\n");
1009 bool ap =
digits_.antiparticle_;
1010 dump_ = abscode & 0x0fffffff;
1015 " in PDG Code " +
string());
1021 static_assert(
sizeof(PdgCode) == 4,
"should fit into 32 bit integer");
1029 std::istream&
operator>>(std::istream& is, PdgCode& code);
1035 std::ostream&
operator<<(std::ostream& is,
const PdgCode& code);
1039 const auto c1 = pdg1.
code();
1040 const auto c2 = pdg2.
code();
1041 const auto min = std::min(c1, c2);
1042 const auto max = std::max(c1, c2);
1043 return (max == 0x11 && min == -0x11) || (max == 0x13 && min == -0x13);
PdgCode stores a Particle Data Group Particle Numbering Scheme particle type number.
std::uint32_t quarks_
The quark digits n_q{1,2,3}_.
bool is_Nstar1535() const
std::int32_t code() const
int antiparticle_sign() const
bool operator!=(const PdgCode rhs) const
int nucleus_n() const
Number of neutrons in nucleus.
int baryon_number() const
PdgCode(const std::uint32_t abscode)
receive an unsigned integer and process it into a PDG Code.
std::uint32_t n_q1_
first quark field. 0 for mesons.
PdgCode(const std::string &codestring)
Initialize using a string The string is interpreted as a hexadecimal number, i.e.,...
int net_quark_number(const int quark) const
Returns the net number of quarks with given flavour number For public use, see strangeness(),...
int nucleus_ap() const
Number of antiprotons in nucleus.
int nucleus_an() const
Number of antineutrons in nucleus.
friend std::istream & operator>>(std::istream &is, PdgCode &code)
istream >> PdgCode assigns the PDG Code from an istream.
std::array< int, 3 > quark_content() const
The return is always an array of three numbers, which are pdgcodes of quarks: 1 - d,...
std::uint32_t n_q3_
third quark field
unsigned int spin() const
bool antiparticle_
first bit: stores the sign.
std::uint32_t dump() const
Dumps the bitfield into an unsigned integer.
std::uint32_t n_
first field: "counter"
std::uint32_t n_J_
spin quantum number .
static PdgCode from_decimal(const int pdgcode_decimal)
Construct PDG code from decimal number.
bool is_antiparticle_of(const PdgCode rhs) const
std::uint32_t bool is_nucleus_
1 for nuclei, 0 for the rest
struct smash::PdgCode::@0::@2 digits_
The single digits collection of the code.
int nucleus_p() const
Number of protons in nucleus.
int32_t get_decimal() const
void set_fields(std::uint32_t abscode)
Sets the bitfield from an unsigned integer.
void check() const
Do all sorts of validity checks.
std::string string() const
int test_code() const
Checks the integer for invalid hex digits.
PdgCode get_antiparticle() const
Construct the antiparticle to a given PDG code.
int nucleus_La() const
Number of Lambdas in nucleus.
bool operator==(const PdgCode rhs) const
PdgCode()
Standard initializer.
int nucleus_A() const
Nucleus mass number.
static PdgCode invalid()
PdgCode 0x0 is guaranteed not to be valid by the PDG standard, but it passes all tests here,...
int nucleus_aLa() const
Number of anti-Lambdas in nucleus.
bool contains_enough_valence_quarks(int valence_quarks_required) const
bool operator<(const PdgCode rhs) const
Sorts PDG Codes according to their numeric value.
PdgCode(std::int32_t codenumber)
Receive a signed integer and process it into a PDG Code.
void deexcite()
Remove all excitation, except spin. Sign and quark content remains.
std::uint32_t n_L_
"angular momentum"
void set_from_string(const std::string &codestring)
Set the PDG code from the given string.
std::uint32_t ucode() const
std::uint32_t n_R_
"radial excitation"
std::uint32_t dump_
The bitfield dumped into a single integer.
struct smash::PdgCode::@0::@4 nucleus_
Structure for the nuclei.
struct smash::PdgCode::@0::@3 chunks_
Chunk collection: here, the chunks with and are directly accessible.
double frac_strange() const
bool has_antiparticle() const
std::uint32_t get_digit_from_char(const char inp) const
std::int32_t quarks() const
std::uint32_t n_q2_
second quark field
unsigned int spin_degeneracy() const
std::uint32_t excitation_
The excitation digits n_, n_R_, n_L_.
int charge() const
The charge of the particle.
std::ostream & operator<<(std::ostream &out, const ActionPtr &action)
Convenience: dereferences the ActionPtr to Action.
constexpr int Delta_pp
Δ⁺⁺.
const PdgCode triton(PdgCode::from_decimal(1000010030))
Triton.
constexpr int N1535_z
N(1535)⁰.
const PdgCode d(PdgCode::from_decimal(1000010020))
Deuteron.
const PdgCode he3(PdgCode::from_decimal(1000020030))
He-3.
const PdgCode antihe3(PdgCode::from_decimal(-1000020030))
Anti-He-3.
const PdgCode antitriton(PdgCode::from_decimal(-1000010030))
Anti-triton.
constexpr int N1535_p
N(1535)⁺.
const PdgCode hypertriton(PdgCode::from_decimal(1010010030))
Hypertriton.
const PdgCode antid(PdgCode::from_decimal(-1000010020))
Anti-deuteron in decimal digits.
const PdgCode antihypertriton(PdgCode::from_decimal(-1010010030))
Anti-Hypertriton.
const PdgCode dprime(PdgCode::from_decimal(1000010021))
Deuteron-prime resonance.
bool is_dilepton(const PdgCode pdg1, const PdgCode pdg2)
std::istream & operator>>(std::istream &is, PdgCode &code)
Sets the PDG code from the textual representation in the input stream.
bool has_lepton_pair(const PdgCode pdg1, const PdgCode pdg2, const PdgCode pdg3)
thrown for invalid inputs