10 #ifndef SRC_INCLUDE_PDGCODE_H_ 11 #define SRC_INCLUDE_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());
337 const auto abs_code = std::abs(
code());
367 const auto abs_code = std::abs(
code());
373 const auto c =
code();
379 const auto c =
code();
478 for (
int i = 1; i < 7; i++) {
495 if ((
dump_ & 0x0000ffff) == 0x24) {
509 inline unsigned int spin()
const {
538 return (
digits_.antiparticle_ ? -1 : +1);
558 std::array<int, 3> result = {
static_cast<int>(
digits_.n_q1_),
559 static_cast<int>(
digits_.n_q2_),
560 static_cast<int>(
digits_.n_q3_)};
564 for (
size_t i = 0; i < 3; i++) {
565 result[i] = -result[i];
572 result[2] = -result[2];
576 result[1] = -result[1];
579 result[2] = -result[2];
584 for (
int i = 1; i <= 2; i++) {
585 result[i] = -result[i];
660 10000000 *
nucleus_.n_Lambda_ + 1000000000);
700 #if defined(__GNUC__) && (defined(__x86_64__) || defined(__i386__)) || \ 702 #define SMASH_BITFIELD_ORDER_ 1 705 #elif defined(__OTHER_COMPILER__) 706 #define SMASH_BITFIELD_ORDER_ 2 708 #error "Please determine the correct bit-field order for your target/compiler" 721 #if SMASH_BITFIELD_ORDER_ == 1 722 std::uint32_t
n_J_ : 4;
735 std::uint32_t
n_ : 4, : 2;
740 #else // reverse ordering 743 std::uint32_t
n_ : 4;
744 std::uint32_t
n_R_ : 4;
745 std::uint32_t
n_L_ : 4;
746 std::uint32_t
n_q1_ : 4;
747 std::uint32_t
n_q2_ : 4;
748 std::uint32_t
n_q3_ : 4;
749 std::uint32_t
n_J_ : 4;
762 #if SMASH_BITFIELD_ORDER_ == 1 769 std::uint32_t : 4, excitation_ : 12; 770 std::uint32_t
quarks_ : 12, : 4;
775 #if SMASH_BITFIELD_ORDER_ == 1 777 std::uint32_t
Z_ : 10;
778 std::uint32_t
A_ : 10;
779 std::uint32_t
I_ : 4;
782 #else // Reverse ordering 785 std::uint32_t
I_ : 4;
786 std::uint32_t
A_ : 10;
787 std::uint32_t
Z_ : 10;
797 inline std::uint32_t
ucode()
const {
return (
dump_ & 0x0fffffff); }
807 if (48 <= inp && inp <= 57) {
811 if (65 <= inp && inp <= 70) {
812 return inp - 65 + 10;
815 if (97 <= inp && inp <= 102) {
816 return inp - 97 + 10;
818 throw InvalidPdgCode(
"PdgCode: Invalid character " + std::string(&inp, 1) +
848 size_t length = codestring.size();
855 if (codestring[c] ==
'-') {
858 }
else if (codestring[c] ==
'+') {
863 unsigned int sign = c;
866 if (length == 10 + sign) {
868 if (codestring[c] !=
'1' || codestring[c + 1] !=
'0') {
870 "\" should start with 10\n");
874 std::array<int, 8> digits;
875 for (
int i = 0; i < 8; i++) {
879 nucleus_.Z_ = 100 * digits[1] + 10 * digits[2] + digits[3];
880 nucleus_.A_ = 100 * digits[4] + 10 * digits[5] + digits[6];
886 if (length > 8 + sign) {
888 "\" too long for PDG Code\n");
892 if (length > 7 + sign) {
896 if (length > 6 + sign) {
900 if (length > 5 + sign) {
904 if (length > 4 + sign) {
908 if (length > 3 + sign) {
911 throw InvalidPdgCode(
"Invalid PDG code " + codestring +
" (n_q1>6)");
915 if (length > 2 + sign) {
918 throw InvalidPdgCode(
"Invalid PDG code " + codestring +
" (n_q2>6)");
922 if (length > 1 + sign) {
925 throw InvalidPdgCode(
"Invalid PDG code " + codestring +
" (n_q3>6)");
933 "String \"" + codestring +
934 "\" only consists of a sign, that is no valid PDG Code\n");
951 bool ap =
digits_.antiparticle_;
952 dump_ = abscode & 0x0fffffff;
957 " in PDG Code " +
string());
963 static_assert(
sizeof(
PdgCode) == 4,
"should fit into 32 bit integer");
981 const auto c1 = pdg1.
code();
982 const auto c2 = pdg2.
code();
983 const auto min = std::min(c1, c2);
984 const auto max = std::max(c1, c2);
985 return (max == 0x11 && min == -0x11) || (max == 0x13 && min == -0x13);
1000 #endif // SRC_INCLUDE_PDGCODE_H_ static PdgCode from_decimal(const int pdgcode_decimal)
Construct PDG code from decimal number.
int charge() const
The charge of the particle.
std::uint32_t n_q3_
third quark field
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().
std::uint32_t excitation_
The excitation digits n_, n_R_, n_L_.
unsigned int spin_degeneracy() const
bool is_dilepton(const PdgCode pdg1, const PdgCode pdg2)
PdgCode(std::int32_t codenumber)
Receive a signed integer and process it into a PDG Code.
std::uint32_t n_J_
spin quantum number .
int baryon_number() const
bool has_lepton_pair(const PdgCode pdg1, const PdgCode pdg2, const PdgCode pdg3)
struct smash::PdgCode::@0::@4 nucleus_
Structure for the nuclei.
PdgCode(const std::uint32_t abscode)
receive an unsigned integer and process it into a PDG Code.
unsigned int spin() const
bool operator==(const PdgCode rhs) const
void check() const
Do all sorts of validity checks.
std::uint32_t n_R_
"radial excitation"
bool is_Nstar1535() const
void set_fields(std::uint32_t abscode)
Sets the bitfield from an unsigned integer.
int test_code() const
Checks the integer for invalid hex digits.
PdgCode get_antiparticle() const
Construct the antiparticle to a given PDG code.
std::int32_t quarks() const
bool operator!=(const PdgCode rhs) const
struct smash::PdgCode::@0::@3 chunks_
Chunk collection: here, the chunks with and are directly accessible.
bool has_antiparticle() const
std::uint32_t n_L_
"angular momentum"
thrown for invalid inputs
constexpr int N1535_p
N(1535)⁺.
std::uint32_t n_q2_
second quark field
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 dump() const
Dumps the bitfield into an unsigned integer.
int antiparticle_sign() const
struct smash::PdgCode::@0::@2 digits_
The single digits collection of the code.
void deexcite()
Remove all excitation, except spin. Sign and quark content remains.
std::uint32_t ucode() const
constexpr int decimal_d
Deuteron in decimal digits.
constexpr int Delta_pp
Δ⁺⁺.
std::uint32_t n_q1_
first quark field. 0 for mesons.
constexpr int N1535_z
N(1535)⁰.
constexpr int decimal_antid
Anti-deuteron in decimal digits.
std::uint32_t n_
first field: "counter"
PdgCode stores a Particle Data Group Particle Numbering Scheme particle type number.
PdgCode(const std::string &codestring)
Initialize using a string The string is interpreted as a hexadecimal number, i.e., 211 is interpreted as 0x211 = .
std::uint32_t bool is_nucleus_
1 for nuclei, 0 for the rest
friend std::istream & operator>>(std::istream &is, PdgCode &code)
istream >> PdgCode assigns the PDG Code from an istream.
void set_from_string(const std::string &codestring)
Set the PDG code from the given string.
bool operator<(const PdgCode rhs) const
Sorts PDG Codes according to their numeric value.
std::uint32_t quarks_
The quark digits n_q{1,2,3}_.
std::uint32_t get_digit_from_char(const char inp) const
std::uint32_t dump_
The bitfield dumped into a single integer.
std::int32_t code() const
bool contains_enough_valence_quarks(int valence_quarks_required) const
bool is_antiparticle_of(const PdgCode rhs) const
std::ostream & operator<<(std::ostream &out, const ActionPtr &action)
Convenience: dereferences the ActionPtr to Action.
bool antiparticle_
first bit: stores the sign.
int32_t get_decimal() const
static PdgCode invalid()
PdgCode 0x0 is guaranteed not to be valid by the PDG standard, but it passes all tests here...
PdgCode()
Standard initializer.
std::string string() const
double frac_strange() const