 |
Version: SMASH-2.0
|
|
Go to the documentation of this file.
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;
155 explicit PdgCode(
const std::uint32_t abscode) :
dump_(0x0) {
157 digits_.antiparticle_ = ((abscode & 0x80000000u) != 0);
220 throw InvalidPdgCode(
"Invalid PDG code " +
string() +
221 " (meson with even n_J)");
225 throw InvalidPdgCode(
"Invalid PDG code " +
string() +
226 " (baryon with odd n_J)");
231 throw InvalidPdgCode(
"Invalid PDG code " +
string() +
" (n_J==0)");
237 throw InvalidPdgCode(
"Invalid PDG code " +
string() +
238 " (cannot be negative)");
243 inline std::uint32_t
dump()
const {
245 return (
dump_ & 0x8fffffff);
252 inline std::string
string()
const {
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());
363 inline bool is_Xi()
const {
379 const auto abs_code = std::abs(
code());
385 const auto c =
code();
390 inline bool is_rho()
const {
391 const auto c =
code();
490 for (
int i = 1; i < 7; i++) {
507 if ((
dump_ & 0x0000ffff) == 0x24) {
521 inline unsigned int spin()
const {
553 inline std::int32_t
quarks()
const {
570 std::array<int, 3> result = {static_cast<int>(
digits_.n_q1_),
571 static_cast<int>(
digits_.n_q2_),
572 static_cast<int>(
digits_.n_q3_)};
576 for (
size_t i = 0; i < 3; i++) {
577 result[i] = -result[i];
584 result[2] = -result[2];
588 result[1] = -result[1];
591 result[2] = -result[2];
596 for (
int i = 1; i <= 2; i++) {
597 result[i] = -result[i];
630 return dump_ < rhs.dump_;
645 return code() == -rhs.code();
672 10000000 *
nucleus_.n_Lambda_ + 1000000000);
712 #if defined(__GNUC__) && (defined(__x86_64__) || defined(__i386__)) || \
714 #define SMASH_BITFIELD_ORDER_ 1
717 #elif defined(__OTHER_COMPILER__)
718 #define SMASH_BITFIELD_ORDER_ 2
720 #error "Please determine the correct bit-field order for your target/compiler"
733 #if SMASH_BITFIELD_ORDER_ == 1
734 std::uint32_t
n_J_ : 4;
745 std::uint32_t
n_R_ : 4;
747 std::uint32_t
n_ : 4, : 2;
752 #else // reverse ordering
755 std::uint32_t
n_ : 4;
756 std::uint32_t
n_R_ : 4;
757 std::uint32_t
n_L_ : 4;
758 std::uint32_t
n_q1_ : 4;
759 std::uint32_t
n_q2_ : 4;
760 std::uint32_t
n_q3_ : 4;
761 std::uint32_t
n_J_ : 4;
774 #if SMASH_BITFIELD_ORDER_ == 1
781 std::uint32_t : 4, excitation_ : 12;
782 std::uint32_t
quarks_ : 12, : 4;
787 #if SMASH_BITFIELD_ORDER_ == 1
789 std::uint32_t
Z_ : 10;
790 std::uint32_t
A_ : 10;
791 std::uint32_t
I_ : 4;
794 #else // Reverse ordering
797 std::uint32_t
I_ : 4;
798 std::uint32_t
A_ : 10;
799 std::uint32_t
Z_ : 10;
809 inline std::uint32_t
ucode()
const {
return (
dump_ & 0x0fffffff); }
819 if (48 <= inp && inp <= 57) {
823 if (65 <= inp && inp <= 70) {
824 return inp - 65 + 10;
827 if (97 <= inp && inp <= 102) {
828 return inp - 97 + 10;
830 throw InvalidPdgCode(
"PdgCode: Invalid character " + std::string(&inp, 1) +
860 size_t length = codestring.size();
862 throw InvalidPdgCode(
"Empty string does not contain PDG Code\n");
867 if (codestring[c] ==
'-') {
870 }
else if (codestring[c] ==
'+') {
875 unsigned int sign = c;
878 if (length == 10 + sign) {
880 if (codestring[c] !=
'1' || codestring[c + 1] !=
'0') {
881 throw InvalidPdgCode(
"Pdg code of nucleus \"" + codestring +
882 "\" should start with 10\n");
886 std::array<int, 8> digits;
887 for (
int i = 0; i < 8; i++) {
891 nucleus_.Z_ = 100 * digits[1] + 10 * digits[2] + digits[3];
892 nucleus_.A_ = 100 * digits[4] + 10 * digits[5] + digits[6];
898 if (length > 8 + sign) {
899 throw InvalidPdgCode(
"String \"" + codestring +
900 "\" too long for PDG Code\n");
904 if (length > 7 + sign) {
908 if (length > 6 + sign) {
912 if (length > 5 + sign) {
916 if (length > 4 + sign) {
920 if (length > 3 + sign) {
923 throw InvalidPdgCode(
"Invalid PDG code " + codestring +
" (n_q1>6)");
927 if (length > 2 + sign) {
930 throw InvalidPdgCode(
"Invalid PDG code " + codestring +
" (n_q2>6)");
934 if (length > 1 + sign) {
937 throw InvalidPdgCode(
"Invalid PDG code " + codestring +
" (n_q3>6)");
944 throw InvalidPdgCode(
945 "String \"" + codestring +
946 "\" only consists of a sign, that is no valid PDG Code\n");
960 inline void set_fields(std::uint32_t abscode) {
963 bool ap =
digits_.antiparticle_;
964 dump_ = abscode & 0x0fffffff;
968 throw InvalidPdgCode(
"Invalid digits " + std::to_string(test) +
969 " in PDG Code " +
string());
975 static_assert(
sizeof(PdgCode) == 4,
"should fit into 32 bit integer");
983 std::istream&
operator>>(std::istream& is, PdgCode& code);
989 std::ostream&
operator<<(std::ostream& is,
const PdgCode& code);
993 const auto c1 = pdg1.
code();
994 const auto c2 = pdg2.
code();
995 const auto min = std::min(c1, c2);
996 const auto max = std::max(c1, c2);
997 return (max == 0x11 && min == -0x11) || (max == 0x13 && min == -0x13);
1012 #endif // SRC_INCLUDE_SMASH_PDGCODE_H_
int net_quark_number(const int quark) const
Returns the net number of quarks with given flavour number For public use, see strangeness(),...
double frac_strange() const
PdgCode get_antiparticle() const
Construct the antiparticle to a given PDG code.
std::uint32_t excitation_
The excitation digits n_, n_R_, n_L_.
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
std::uint32_t n_J_
spin quantum number .
int baryon_number() const
static PdgCode from_decimal(const int pdgcode_decimal)
Construct PDG code from decimal number.
unsigned int spin() const
unsigned int spin_degeneracy() const
std::uint32_t n_L_
"angular momentum"
std::uint32_t n_R_
"radial excitation"
std::ostream & operator<<(std::ostream &out, const ActionPtr &action)
int antiparticle_sign() const
std::uint32_t n_q2_
second quark field
struct smash::PdgCode::@0::@4 nucleus_
Structure for the nuclei.
bool operator<(const PdgCode rhs) const
Sorts PDG Codes according to their numeric value.
struct smash::PdgCode::@0::@3 chunks_
Chunk collection: here, the chunks with and are directly accessible.
std::uint32_t dump() const
Dumps the bitfield into an unsigned integer.
struct smash::PdgCode::@0::@2 digits_
The single digits collection of the code.
constexpr int N1535_p
N(1535)⁺.
int32_t get_decimal() const
void set_fields(std::uint32_t abscode)
Sets the bitfield from an unsigned integer.
std::uint32_t ucode() const
std::string string() const
std::uint32_t bool is_nucleus_
1 for nuclei, 0 for the rest
void deexcite()
Remove all excitation, except spin. Sign and quark content remains.
void set_from_string(const std::string &codestring)
Set the PDG code from the given string.
int charge() const
The charge of the particle.
constexpr int decimal_antid
Anti-deuteron in decimal digits.
std::uint32_t quarks_
The quark digits n_q{1,2,3}_.
constexpr int N1535_z
N(1535)⁰.
constexpr int decimal_d
Deuteron in decimal digits.
std::istream & operator>>(std::istream &is, PdgCode &code)
Sets the PDG code from the textual representation in the input stream.
std::uint32_t n_
first field: "counter"
bool is_antiparticle_of(const PdgCode rhs) const
friend std::istream & operator>>(std::istream &is, PdgCode &code)
istream >> PdgCode assigns the PDG Code from an istream.
std::uint32_t dump_
The bitfield dumped into a single integer.
int test_code() const
Checks the integer for invalid hex digits.
std::uint32_t n_q1_
first quark field. 0 for mesons.
constexpr int Delta_pp
Δ⁺⁺.
bool operator==(const PdgCode rhs) const
std::int32_t quarks() const
bool has_lepton_pair(const PdgCode pdg1, const PdgCode pdg2, const PdgCode pdg3)
bool operator!=(const PdgCode rhs) const
void check() const
Do all sorts of validity checks.
static PdgCode invalid()
PdgCode 0x0 is guaranteed not to be valid by the PDG standard, but it passes all tests here,...
PdgCode()
Standard initializer.
bool contains_enough_valence_quarks(int valence_quarks_required) const
bool antiparticle_
first bit: stores the sign.
std::uint32_t get_digit_from_char(const char inp) const
bool has_antiparticle() const
std::int32_t code() const
bool is_dilepton(const PdgCode pdg1, const PdgCode pdg2)
bool is_Nstar1535() const