Version: SMASH-3.4
smash::PdgCode Class Reference

#include <pdgcode.h>

PdgCode stores a Particle Data Group Particle Numbering Scheme particle type number.

See also
http://pdg.lbl.gov/2014/reviews/rpp2014-rev-monte-carlo-numbering.pdf

Usage:

#include "include/pdgcode.h"
// initialize with an integer: make sure it is hex-encoded!
PdgCode pi_plus(0x211);
// you can also initialize from a string:
PdgCode pi_minus("-211");
// initialize a PDG Code that knows it is not set yet:
PdgCode other_particle();
// this is true:
if (other_particle == PdgCode::invalid()) {
printf("Invalid particle! Please enter PDG Code: ");
// fill from stringstream:
std::cin >> other_particle;
}
// is this a Kaon?
if (other_particle.code() == 0x311) {
printf("The particle is a K plus\n");
}
// what baryon number does the particle have?
printf("The particle has a baryon number of %d\n",
other_particle.baryon_number());
PdgCode()
Standard initializer.
Definition: pdgcode.h:125
static PdgCode invalid()
PdgCode 0x0 is guaranteed not to be valid by the PDG standard, but it passes all tests here,...
Definition: pdgcode.h:841

This class contains a collection of smart accessors to the PDG code so that quantum numbers etc can easily be read off.

Internals

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.).

Representing nuclei

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.

Limitations:

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.

Definition at line 108 of file pdgcode.h.

Collaboration diagram for smash::PdgCode:
[legend]

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
 
bool is_neutrino () const
 
bool is_charmonia () 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_Sigmastar () const
 
bool is_kaon () const
 
bool is_pion () const
 
bool is_eta () const
 
bool is_omega () const
 
bool is_rho () const
 
bool is_Dmeson () const
 
bool is_Dstar2007 () const
 
bool is_deuteron () const
 
bool is_triton () const
 
bool has_antiparticle () const
 
int isospin3 () const
 
double frac_strange () const
 
double frac_charm () const
 
double frac_bottom () const
 
bool is_heavy_flavor () 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...
 
bool contains_quark (int quark) const
 Checks whether this hadron contains a quark (or antiquark) of a given flavour. 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...
 

Constructor & Destructor Documentation

◆ PdgCode() [1/5]

smash::PdgCode::PdgCode ( )
inline

Standard initializer.

Definition at line 125 of file pdgcode.h.

125 : dump_(0x0) {}
std::uint32_t dump_
The bitfield dumped into a single integer.
Definition: pdgcode.h:994

◆ PdgCode() [2/5]

smash::PdgCode::PdgCode ( const std::string &  codestring)
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 131 of file pdgcode.h.

131  {
132  set_from_string(codestring);
133  }
void set_from_string(const std::string &codestring)
Set the PDG code from the given string.
Definition: pdgcode.h:1085
Here is the call graph for this function:

◆ PdgCode() [3/5]

smash::PdgCode::PdgCode ( std::int32_t  codenumber)
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.

Parameters
[in]codenumbera 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 143 of file pdgcode.h.

143  : dump_(0x0) { // NOLINT(runtime/explicit)
144  digits_.antiparticle_ = false;
145  if (codenumber < 0) {
146  digits_.antiparticle_ = true;
147  codenumber = -codenumber;
148  }
149  set_fields(codenumber);
150  }
struct smash::PdgCode::@0::@2 digits_
The single digits collection of the code.
void set_fields(std::uint32_t abscode)
Sets the bitfield from an unsigned integer.
Definition: pdgcode.h:1190
Here is the call graph for this function:

◆ PdgCode() [4/5]

smash::PdgCode::PdgCode ( const std::uint32_t  abscode)
inlineexplicit

Receive an unsigned integer and process it into a PDG Code.

The first bit is taken and used as antiparticle boolean.

Definition at line 155 of file pdgcode.h.

155  : dump_(0x0) {
156  // use the first bit for the antiparticle_ boolean.
157  digits_.antiparticle_ = ((abscode & 0x80000000u) != 0);
158  set_fields(abscode);
159  }
Here is the call graph for this function:

◆ PdgCode() [5/5]

template<typename T >
smash::PdgCode::PdgCode ( codenumber)
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.

Note
One might wonder why a function template has been used instead of e.g. adding a constructor taking a 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
PdgCode deuteron(0x1000010020);
constexpr int64_t deuteron
Deuteron.
to work and not oblige the user to write
PdgCode deuteron(INT64_C(0x1000010020));
just because the constructor takes an 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.
Warning
In C++, it is more common to enable constructors template via a non-type template parameter, i.e.
template <typename T,
template <typename T,
typename std::enable_if_t<
std::is_integral_v<T> && 4 < sizeof(T), bool
> = true>
PdgCode(T codenumber) // ...
but this breaks Doxygen documentation, because apparently multiple "nested" template parameters are not able to be correctly handled (possibly because of the additional less-than symbol). This limitation has been detected using Doxygen 1.9.X and might be solved in future versions.
Parameters
[in]codenumberThe hexadecimal PDG code
Template Parameters
TThe type of the PDG code, irrelevant for the user and deduced by the compiler

Definition at line 217 of file pdgcode.h.

220  : PdgCode{std::invoke([&codenumber]() {
221  std::stringstream stream;
222  char sign = '+';
223  if (codenumber < 0) {
224  sign = '-';
225  codenumber = -codenumber;
226  }
227  stream << sign << std::hex << codenumber;
228  return stream.str();
229  })} {}

Member Function Documentation

◆ test_code()

int smash::PdgCode::test_code ( ) const
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.

Returns
a bitmask indicating the offending digits. In the above example, 221 = 0xd3, the second-to-last-digit is the offending one, to the return value is 0b10 = 0x2 = 2.

Definition at line 250 of file pdgcode.h.

250  {
251  int fail = 0;
252  if (digits_.n_ > 9) {
253  fail |= 1 << 6;
254  }
255  if (digits_.n_R_ > 9) {
256  fail |= 1 << 5;
257  }
258  if (digits_.n_L_ > 9) {
259  fail |= 1 << 4;
260  }
261  if (digits_.n_q1_ > 6) {
262  fail |= 1 << 3;
263  }
264  if (digits_.n_q2_ > 6) {
265  fail |= 1 << 2;
266  }
267  if (digits_.n_q3_ > 6) {
268  fail |= 1 << 1;
269  }
270  if (digits_.n_J_ > 15) {
271  fail |= 1;
272  }
273  return fail;
274  }

◆ check()

void smash::PdgCode::check ( ) const
inline

Do all sorts of validity checks.

Exceptions
InvalidPdgCodeif meson has even n_J_ (fermionic spin)
InvalidPdgCodeif baryon has odd n_J_ (bosonic spin)
InvalidPdgCodeif n_J_ is 0 (spin is not defined.)
InvalidPdgCodeif particle does not have antiparticle when it is supposed to do.

Definition at line 284 of file pdgcode.h.

284  {
285  // n_J must be odd for mesons and even for baryons (and cannot be zero)
286  if (is_hadron()) {
287  if (baryon_number() == 0) {
288  // mesons: special cases K0_L=0x130 and K0_S=0x310
289  if ((digits_.n_J_ % 2 == 0) && dump() != 0x130 && dump() != 0x310) {
290  throw InvalidPdgCode("Invalid PDG code " + string() +
291  " (meson with even n_J)");
292  }
293  } else {
294  if ((digits_.n_J_ % 2 != 0) || digits_.n_J_ == 0) {
295  throw InvalidPdgCode("Invalid PDG code " + string() +
296  " (baryon with odd n_J)");
297  }
298  }
299  } else {
300  if (digits_.n_J_ == 0 && dump() != 0x0) {
301  throw InvalidPdgCode("Invalid PDG code " + string() + " (n_J==0)");
302  }
303  }
304  /* The antiparticle flag only makes sense for particle types
305  * that have an antiparticle. */
306  if (digits_.antiparticle_ && !has_antiparticle()) {
307  throw InvalidPdgCode("Invalid PDG code " + string() +
308  " (cannot be negative)");
309  }
310  }
int baryon_number() const
Definition: pdgcode.h:388
std::uint32_t dump() const
Dumps the bitfield into an unsigned integer.
Definition: pdgcode.h:313
bool is_hadron() const
Definition: pdgcode.h:367
bool has_antiparticle() const
Definition: pdgcode.h:519

◆ dump()

std::uint32_t smash::PdgCode::dump ( ) const
inline

Dumps the bitfield into an unsigned integer.

Definition at line 313 of file pdgcode.h.

313  {
314  // this cuts the three unused bits.
315  return (dump_ & 0x8fffffff);
316  }

◆ code()

std::int32_t smash::PdgCode::code ( ) const
inline
Returns
a signed integer with the PDG code in hexadecimal.

Definition at line 319 of file pdgcode.h.

319 { return antiparticle_sign() * ucode(); }
int antiparticle_sign() const
Definition: pdgcode.h:734
std::uint32_t ucode() const
Definition: pdgcode.h:1039
Here is the caller graph for this function:

◆ string()

std::string smash::PdgCode::string ( ) const
inline
Returns
the PDG Code as a decimal string.

Definition at line 322 of file pdgcode.h.

322  {
323  std::stringstream ss;
324  ss << get_decimal();
325  return ss.str();
326  }
int32_t get_decimal() const
Definition: pdgcode.h:852
Here is the caller graph for this function:

◆ get_antiparticle()

PdgCode smash::PdgCode::get_antiparticle ( ) const
inline

Construct the antiparticle to a given PDG code.

Definition at line 329 of file pdgcode.h.

329  {
330  PdgCode result = *this;
331  result.digits_.antiparticle_ = !digits_.antiparticle_;
332  return result;
333  }
Here is the caller graph for this function:

◆ from_decimal()

static PdgCode smash::PdgCode::from_decimal ( const int  pdgcode_decimal)
inlinestatic

Construct PDG code from decimal number.

Parameters
[in]pdgcode_decimaldecimal integer representing the PDG code

Definition at line 339 of file pdgcode.h.

339  {
340  // Nucleus and special codes with 2J+1 > 9
341  if (std::abs(pdgcode_decimal) > 1E7) {
342  return PdgCode(std::to_string(pdgcode_decimal));
343  }
344  int a = pdgcode_decimal;
345  int hex_pdg = 0, tmp = 1;
346  while (a) {
347  hex_pdg += (a % 10) * tmp;
348  tmp *= 16;
349  a = a / 10;
350  }
351  return PdgCode(hex_pdg);
352  }
std::string to_string(ThermodynamicQuantity quantity)
Convert a ThermodynamicQuantity enum value to its corresponding string.
Definition: stringify.cc:26
Here is the call graph for this function:
Here is the caller graph for this function:

◆ is_nucleus()

bool smash::PdgCode::is_nucleus ( ) const
inline
Returns
true if this is a nucleus, false otherwise

Definition at line 361 of file pdgcode.h.

361  {
362  assert(digits_.is_nucleus_ == nucleus_.is_nucleus_);
363  return nucleus_.is_nucleus_;
364  }
struct smash::PdgCode::@0::@4 nucleus_
Structure for the nuclei.
Here is the caller graph for this function:

◆ is_hadron()

bool smash::PdgCode::is_hadron ( ) const
inline
Returns
true if this is a baryon, antibaryon or meson.

Definition at line 367 of file pdgcode.h.

367  {
368  return (digits_.n_q3_ != 0 && digits_.n_q2_ != 0 && !is_nucleus());
369  }
bool is_nucleus() const
Definition: pdgcode.h:361
Here is the caller graph for this function:

◆ is_lepton()

bool smash::PdgCode::is_lepton ( ) const
inline
Returns
true if this is a lepton.

Definition at line 372 of file pdgcode.h.

372  {
373  return (digits_.n_q1_ == 0 && digits_.n_q2_ == 0 && digits_.n_q3_ == 1 &&
374  !is_nucleus());
375  }
Here is the caller graph for this function:

◆ is_neutrino()

bool smash::PdgCode::is_neutrino ( ) const
inline
Returns
true if this is a neutrino.

Definition at line 378 of file pdgcode.h.

378  {
379  return (is_lepton() && digits_.n_J_ % 2 == 0);
380  }
bool is_lepton() const
Definition: pdgcode.h:372
Here is the caller graph for this function:

◆ is_charmonia()

bool smash::PdgCode::is_charmonia ( ) const
inline
Returns
whether this is a charmonia

Definition at line 383 of file pdgcode.h.

383  {
384  return is_meson() && digits_.n_q2_ == 4 && digits_.n_q3_ == 4;
385  }
bool is_meson() const
Definition: pdgcode.h:401
Here is the caller graph for this function:

◆ baryon_number()

int smash::PdgCode::baryon_number ( ) const
inline
Returns
the baryon number of the particle.

Definition at line 388 of file pdgcode.h.

388  {
389  if (is_nucleus()) {
390  return static_cast<int>(nucleus_.A_) * antiparticle_sign();
391  }
392  if (!is_hadron() || digits_.n_q1_ == 0) {
393  return 0;
394  }
395  return antiparticle_sign();
396  }
Here is the caller graph for this function:

◆ is_baryon()

bool smash::PdgCode::is_baryon ( ) const
inline
Returns
whether this PDG code identifies a baryon.

Definition at line 398 of file pdgcode.h.

398 { return is_hadron() && digits_.n_q1_ != 0; }
Here is the caller graph for this function:

◆ is_meson()

bool smash::PdgCode::is_meson ( ) const
inline
Returns
whether this PDG code identifies a meson.

Definition at line 401 of file pdgcode.h.

401 { return is_hadron() && digits_.n_q1_ == 0; }
Here is the caller graph for this function:

◆ is_nucleon()

bool smash::PdgCode::is_nucleon ( ) const
inline
Returns
whether this is a nucleon/anti-nucleon (p, n, -p, -n)

Definition at line 404 of file pdgcode.h.

404  {
405  const auto abs_code = std::abs(code());
406  return (abs_code == pdg::p || abs_code == pdg::n);
407  }
std::int32_t code() const
Definition: pdgcode.h:319
constexpr int p
Proton.
constexpr int n
Neutron.
Here is the caller graph for this function:

◆ is_proton()

bool smash::PdgCode::is_proton ( ) const
inline
Returns
whether this is a proton/anti-proton

Definition at line 410 of file pdgcode.h.

410  {
411  const auto abs_code = std::abs(code());
412  return (abs_code == pdg::p);
413  }
Here is the caller graph for this function:

◆ is_neutron()

bool smash::PdgCode::is_neutron ( ) const
inline
Returns
whether this is a neutron/anti-neutron

Definition at line 416 of file pdgcode.h.

416  {
417  const auto abs_code = std::abs(code());
418  return (abs_code == pdg::n);
419  }
Here is the caller graph for this function:

◆ is_Nstar1535()

bool smash::PdgCode::is_Nstar1535 ( ) const
inline
Returns
whether this is a N*(1535) (+/0)

Definition at line 422 of file pdgcode.h.

422  {
423  const auto abs_code = std::abs(code());
424  return (abs_code == pdg::N1535_p || abs_code == pdg::N1535_z);
425  }
constexpr int N1535_z
N(1535)⁰.
constexpr int N1535_p
N(1535)⁺.
Here is the caller graph for this function:

◆ is_Delta()

bool smash::PdgCode::is_Delta ( ) const
inline
Returns
whether this is a Delta(1232) (with anti-delta)

Definition at line 428 of file pdgcode.h.

428  {
429  const auto abs_code = std::abs(code());
430  return (abs_code == pdg::Delta_pp || abs_code == pdg::Delta_p ||
431  abs_code == pdg::Delta_z || abs_code == pdg::Delta_m);
432  }
constexpr int Delta_p
Δ⁺.
constexpr int Delta_pp
Δ⁺⁺.
constexpr int Delta_m
Δ⁻.
constexpr int Delta_z
Δ⁰.
Here is the caller graph for this function:

◆ is_hyperon()

bool smash::PdgCode::is_hyperon ( ) const
inline
Returns
whether this is a hyperon (Lambda, Sigma, Xi, Omega)

Definition at line 435 of file pdgcode.h.

435 { return is_hadron() && digits_.n_q1_ == 3; }
Here is the caller graph for this function:

◆ is_Omega()

bool smash::PdgCode::is_Omega ( ) const
inline
Returns
whether this is a Omega baryon

Definition at line 438 of file pdgcode.h.

438  {
439  return is_hyperon() && digits_.n_q2_ == 3 && digits_.n_q3_ == 3;
440  }
bool is_hyperon() const
Definition: pdgcode.h:435

◆ is_Xi()

bool smash::PdgCode::is_Xi ( ) const
inline
Returns
whether this is a Xi baryon

Definition at line 443 of file pdgcode.h.

443  {
444  return is_hyperon() && digits_.n_q2_ == 3 && digits_.n_q3_ != 3;
445  }

◆ is_Lambda()

bool smash::PdgCode::is_Lambda ( ) const
inline
Returns
whether this is a Lambda baryon

Definition at line 448 of file pdgcode.h.

448  {
449  return is_hyperon() && digits_.n_q2_ == 1 && digits_.n_q3_ == 2;
450  }
Here is the caller graph for this function:

◆ is_Sigma()

bool smash::PdgCode::is_Sigma ( ) const
inline
Returns
whether this is a Sigma baryon

Definition at line 453 of file pdgcode.h.

453  {
454  return is_hyperon() && digits_.n_q2_ != 3 && !is_Lambda();
455  }
bool is_Lambda() const
Definition: pdgcode.h:448

◆ is_Sigmastar()

bool smash::PdgCode::is_Sigmastar ( ) const
inline
Returns
whether this is a Sigma* with pdgcodes 3224, 3214, 3114

Definition at line 458 of file pdgcode.h.

458  {
459  const auto abs_code = std::abs(code());
460  return (abs_code == pdg::Sigma_star_m || abs_code == pdg::Sigma_star_z ||
461  abs_code == pdg::Sigma_star_p);
462  }
constexpr int Sigma_star_z
Σ*⁰
constexpr int Sigma_star_p
Σ*⁺
constexpr int Sigma_star_m
Σ*⁻
Here is the caller graph for this function:

◆ is_kaon()

bool smash::PdgCode::is_kaon ( ) const
inline
Returns
whether this is a kaon (K+, K-, K0, Kbar0)

Definition at line 465 of file pdgcode.h.

465  {
466  const auto abs_code = std::abs(code());
467  return (abs_code == pdg::K_p) || (abs_code == pdg::K_z);
468  }
constexpr int K_p
K⁺.
constexpr int K_z
K⁰.
Here is the caller graph for this function:

◆ is_pion()

bool smash::PdgCode::is_pion ( ) const
inline
Returns
whether this is a pion (pi+/pi0/pi-)

Definition at line 471 of file pdgcode.h.

471  {
472  const auto c = code();
473  return (c == pdg::pi_z) || (c == pdg::pi_p) || (c == pdg::pi_m);
474  }
constexpr int pi_p
π⁺.
constexpr int pi_z
π⁰.
constexpr int pi_m
π⁻.
Here is the caller graph for this function:

◆ is_eta()

bool smash::PdgCode::is_eta ( ) const
inline
Returns
whether this is an eta meson

Definition at line 477 of file pdgcode.h.

477 { return code() == pdg::eta; }
constexpr int eta
η.
Here is the caller graph for this function:

◆ is_omega()

bool smash::PdgCode::is_omega ( ) const
inline
Returns
whether this is an omega meson

Definition at line 480 of file pdgcode.h.

480 { return code() == pdg::omega; }
constexpr int omega
ω.

◆ is_rho()

bool smash::PdgCode::is_rho ( ) const
inline
Returns
whether this is a rho meson (rho+/rho0/rho-)

Definition at line 483 of file pdgcode.h.

483  {
484  const auto c = code();
485  return (c == pdg::rho_z) || (c == pdg::rho_p) || (c == pdg::rho_m);
486  }
constexpr int rho_p
ρ⁺.
constexpr int rho_m
ρ⁻.
constexpr int rho_z
ρ⁰.
Here is the caller graph for this function:

◆ is_Dmeson()

bool smash::PdgCode::is_Dmeson ( ) const
inline
Returns
whether this is a D meson (D+, D-, D0, Dbar0)

Definition at line 489 of file pdgcode.h.

489  {
490  const auto abs_code = std::abs(code());
491  return (abs_code == pdg::D_p) || (abs_code == pdg::D_z);
492  }
constexpr int D_z
D⁰.
constexpr int D_p
D⁺.
Here is the caller graph for this function:

◆ is_Dstar2007()

bool smash::PdgCode::is_Dstar2007 ( ) const
inline
Returns
whether this is a D* meson (D*(2010)⁺, D*(2010)⁻, D*(2007)⁰, D̄*(2007)⁰)

Definition at line 498 of file pdgcode.h.

498  {
499  const auto abs_code = std::abs(code());
500  return (abs_code == pdg::Dstar_p) || (abs_code == pdg::Dstar_z);
501  }
constexpr int Dstar_p
D*(2010)⁺.
constexpr int Dstar_z
D*(2007)⁰.
Here is the caller graph for this function:

◆ is_deuteron()

bool smash::PdgCode::is_deuteron ( ) const
inline
Returns
whether this is (anti-)deuteron

Definition at line 504 of file pdgcode.h.

504  {
505  return is_nucleus() && nucleus_.A_ == 2 && nucleus_.Z_ == 1 &&
506  nucleus_.n_Lambda_ == 0 && nucleus_.I_ == 0;
507  }
Here is the caller graph for this function:

◆ is_triton()

bool smash::PdgCode::is_triton ( ) const
inline
Returns
whether this is (anti-)triton

Definition at line 510 of file pdgcode.h.

510  {
511  return is_nucleus() && nucleus_.A_ == 3 && nucleus_.Z_ == 1 &&
512  nucleus_.n_Lambda_ == 0 && nucleus_.I_ == 0;
513  }
Here is the caller graph for this function:

◆ has_antiparticle()

bool smash::PdgCode::has_antiparticle ( ) const
inline
Returns
whether a particle has a distinct antiparticle (or whether it is its own antiparticle).

Definition at line 519 of file pdgcode.h.

519  {
520  if (is_nucleus()) {
521  return true;
522  }
523  if (is_hadron()) {
524  return (baryon_number() != 0) || (digits_.n_q2_ != digits_.n_q3_);
525  } else {
526  return digits_.n_q3_ == 1; // leptons!
527  }
528  }
Here is the caller graph for this function:

◆ isospin3()

int smash::PdgCode::isospin3 ( ) const
inline
Returns
twice the isospin-3 component \(I_3\).

This is calculated from the sum of net_quark_number of up and down.

Definition at line 535 of file pdgcode.h.

535  {
536  /* net_quark_number(2) is the number of u quarks,
537  * net_quark_number(1) is the number of d quarks. */
538  return net_quark_number(2) - net_quark_number(1);
539  }
int net_quark_number(const int quark) const
Returns the net number of quarks with given flavour number For public use, see strangeness(),...
Definition: pdgcode.cc:62
Here is the caller graph for this function:

◆ frac_strange()

double smash::PdgCode::frac_strange ( ) const
inline
Returns
the fraction number of strange quarks (strange + anti-strange) / total

This is useful for the AQM cross-section scaling, and needs to be positive definite.

Definition at line 548 of file pdgcode.h.

548  {
549  if (is_baryon()) {
550  return std::abs(strangeness()) / 3.;
551  } else if (is_meson()) {
552  /* The quarkonium state has 0 net strangeness
553  * but there are actually 2 strange quarks out of 2 total */
554  if (digits_.n_q3_ == 3 && digits_.n_q2_ == 3) {
555  return 1.;
556  } else {
557  return std::abs(strangeness()) / 2.;
558  }
559  } else {
560  /* If not baryon or meson, this should be 0, as AQM does not
561  * extend to non-hadrons */
562  return 0.;
563  }
564  }
int strangeness() const
Definition: pdgcode.h:626
bool is_baryon() const
Definition: pdgcode.h:398
Here is the caller graph for this function:

◆ frac_charm()

double smash::PdgCode::frac_charm ( ) const
inline
Returns
the fraction number of charm quarks (charm + anti-charm) / total

This is useful for the AQM cross-section scaling, and needs to be positive definite.

Definition at line 573 of file pdgcode.h.

573  {
574  if (is_baryon()) {
575  return std::abs(charmness()) / 3.;
576  } else if (is_meson()) {
577  /* The charmonium state has 0 net charmness
578  * but there are actually 2 charm quarks out of 2 total */
579  if (digits_.n_q3_ == 4 && digits_.n_q2_ == 4) {
580  return 1.;
581  } else {
582  return std::abs(charmness()) / 2.;
583  }
584  } else {
585  /* If not baryon or meson, this should be 0, as AQM does not
586  * extend to non-hadrons */
587  return 0.;
588  }
589  }
int charmness() const
Definition: pdgcode.h:633
Here is the caller graph for this function:

◆ frac_bottom()

double smash::PdgCode::frac_bottom ( ) const
inline
Returns
the fraction number of bottom quarks (bottom + anti-bottom) / total

This is useful for the AQM cross-section scaling, and needs to be positive definite.

Definition at line 598 of file pdgcode.h.

598  {
599  if (is_baryon()) {
600  return std::abs(bottomness()) / 3.;
601  } else if (is_meson()) {
602  /* The bottomonium state has 0 net bottomness
603  * but there are actually 2 bottom quarks out of 2 total */
604  if (digits_.n_q3_ == 5 && digits_.n_q2_ == 5) {
605  return 1.;
606  } else {
607  return std::abs(bottomness()) / 2.;
608  }
609  } else {
610  /* If not baryon or meson, this should be 0, as AQM does not
611  * extend to non-hadrons */
612  return 0.;
613  }
614  }
int bottomness() const
Definition: pdgcode.h:640
Here is the caller graph for this function:

◆ is_heavy_flavor()

bool smash::PdgCode::is_heavy_flavor ( ) const
inline
Returns
whether the hadron contains a charm or bottom quark

Definition at line 617 of file pdgcode.h.

617  {
618  return (frac_charm() != 0) || (frac_bottom() != 0);
619  }
double frac_charm() const
Definition: pdgcode.h:573
double frac_bottom() const
Definition: pdgcode.h:598
Here is the caller graph for this function:

◆ strangeness()

int smash::PdgCode::strangeness ( ) const
inline
Returns
the net number of \(\bar s\) quarks.

For particles with one strange quark, -1 is returned.

Definition at line 626 of file pdgcode.h.

626 { return -net_quark_number(3); }
Here is the caller graph for this function:

◆ charmness()

int smash::PdgCode::charmness ( ) const
inline
Returns
the net number of \(c\) quarks

For particles with one charm quark, +1 is returned.

Definition at line 633 of file pdgcode.h.

633 { return +net_quark_number(4); }
Here is the caller graph for this function:

◆ bottomness()

int smash::PdgCode::bottomness ( ) const
inline
Returns
the net number of \(\bar b\) quarks

For particles with one bottom quark, -1 is returned.

Definition at line 640 of file pdgcode.h.

640 { return -net_quark_number(5); }

◆ charge()

int smash::PdgCode::charge ( ) const
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.

Returns
charge of the particle

Definition at line 650 of file pdgcode.h.

650  {
651  if (is_hadron() || is_nucleus()) {
652  // Q will accumulate 3*charge (please excuse the upper case. I
653  // want to distinguish this from q which might be interpreted as
654  // shorthand for "quark".)
655  int Q = 0;
656  /* This loops over d,u,s,c,b,t quarks (the latter can be safely ignored,
657  * but I don't think this will be a bottle neck. */
658  for (int i = 1; i < 7; i++) {
659  /* u,c,t quarks have charge = 2/3 e, while d,s,b quarks have -1/3 e.
660  * The antiparticle sign is already in net_quark_number. */
661  Q += (i % 2 == 0 ? 2 : -1) * net_quark_number(i);
662  }
663  return Q / 3;
664  }
665  /* non-hadron:
666  * Leptons: 11, 13, 15 are e, μ, τ and have a charge -1, while
667  * 12, 14, 16 are the neutrinos that have no charge. */
668  if (digits_.n_q3_ == 1) {
669  return -1 * (digits_.n_J_ % 2) * antiparticle_sign();
670  }
671  /* Bosons: 24 is the W+, all else is uncharged.
672  * we ignore the first digits so that this also finds strange gauge
673  * boson "resonances" (in particular, \f$\tilde \chi_1^+\f$ with PDG
674  * Code 1000024). */
675  if ((dump_ & 0x0000ffff) == 0x24) {
676  return antiparticle_sign();
677  }
678  // default (this includes all other Bosons) is 0.
679  return 0;
680  }
Here is the caller graph for this function:

◆ spin()

unsigned int smash::PdgCode::spin ( ) const
inline
Returns
twice the spin of a particle.

The code is good for hadrons, leptons and spin-1-bosons. It returns 2 (meaning spin=1) for the Higgs, though.

Exceptions
runtime_errorif a spin of a nucleus is not coded in and has to be guessed

Definition at line 691 of file pdgcode.h.

691  {
692  if (is_nucleus()) {
693  // Generally spin of a nucleus cannot be simply guessed, it should be
694  // provided from some table. However, here we only care about a
695  // limited set of light nuclei with A <= 4.
696  if (nucleus_.A_ == 2) {
697  // Deuteron spin is 1
698  return 2;
699  } else if (nucleus_.A_ == 3) {
700  // Tritium and He-3 spin are 1/2
701  // Hypertriton spin is not firmly determined, but decay branching ratios
702  // indicate spin 1/2
703  return 1;
704  } else if (nucleus_.A_ == 4) {
705  // He-4 spin is 0
706  return 0;
707  }
708  throw std::runtime_error("Unknown spin of nucleus.");
709  // Alternative possibility is to guess 1/2 for fermions and 0 for bosons
710  // as 2 * (nucleus_.A_ % 2).
711  }
712 
713  if (is_hadron()) {
714  if (digits_.n_J_ == 0) {
715  return 0; // special cases: K0_L=0x130 & K0_S=0x310
716  } else {
717  return digits_.n_J_ - 1;
718  }
719  }
720  /* this assumes that we only have white particles (no single
721  * quarks): Electroweak fermions have 11-17, so the
722  * second-to-last-digit is the spin. The same for the Bosons: they
723  * have 21-29 and 2spin = 2 (this fails for the Higgs). */
724  return digits_.n_q3_;
725  }
Here is the caller graph for this function:

◆ spin_degeneracy()

unsigned int smash::PdgCode::spin_degeneracy ( ) const
inline
Returns
the spin degeneracy \(2s + 1\) of a particle.

Definition at line 727 of file pdgcode.h.

727  {
728  if (is_hadron() && digits_.n_J_ > 0) {
729  return digits_.n_J_;
730  }
731  return spin() + 1;
732  }
unsigned int spin() const
Definition: pdgcode.h:691
Here is the caller graph for this function:

◆ antiparticle_sign()

int smash::PdgCode::antiparticle_sign ( ) const
inline
Returns
-1 for antiparticles and +1 for particles.

Definition at line 734 of file pdgcode.h.

734  {
735  return (digits_.antiparticle_ ? -1 : +1);
736  }
Here is the caller graph for this function:

◆ quarks()

std::int32_t smash::PdgCode::quarks ( ) const
inline
Returns
an integer with only the quark numbers set.

Definition at line 738 of file pdgcode.h.

738  {
739  if (!is_hadron() || is_nucleus()) {
740  return 0;
741  }
742  return chunks_.quarks_;
743  }
struct smash::PdgCode::@0::@3 chunks_
Chunk collection: here, the chunks with and are directly accessible.

◆ quark_content()

std::array<int, 3> smash::PdgCode::quark_content ( ) const
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.

Returns
quark content as an array.

Definition at line 754 of file pdgcode.h.

754  {
755  std::array<int, 3> result = {static_cast<int>(digits_.n_q1_),
756  static_cast<int>(digits_.n_q2_),
757  static_cast<int>(digits_.n_q3_)};
758  if (is_hadron()) {
759  // Antibaryons
760  if (digits_.n_q1_ != 0 && digits_.antiparticle_) {
761  for (size_t i = 0; i < 3; i++) {
762  result[i] = -result[i];
763  }
764  }
765  // Mesons
766  if (digits_.n_q1_ == 0) {
767  // Own antiparticle
768  if (digits_.n_q2_ == digits_.n_q3_) {
769  result[2] = -result[2];
770  } else {
771  // Like pi-
772  if (digits_.antiparticle_) {
773  result[1] = -result[1];
774  // Like pi+
775  } else {
776  result[2] = -result[2];
777  }
778  }
779  // add extra minus sign according to the pdg convention
780  if (digits_.n_q2_ != digits_.n_q3_ && digits_.n_q2_ % 2 == 1) {
781  for (int i = 1; i <= 2; i++) {
782  result[i] = -result[i];
783  }
784  }
785  }
786  } else {
787  result = {0, 0, 0};
788  }
789  return result;
790  }
Here is the caller graph for this function:

◆ contains_enough_valence_quarks()

bool smash::PdgCode::contains_enough_valence_quarks ( int  valence_quarks_required) const
Returns
whether a particle contains at least the given number of valence quarks.
Parameters
[in]valence_quarks_requirednumber of valence quarks that particle is supposed to contain.
Exceptions
std::runtime_errorif it is not a hadron

This is necessary for string fragmentation.

Definition at line 123 of file pdgcode.cc.

124  {
125  if (is_meson()) {
126  return valence_quarks_required == 1 || valence_quarks_required == -1;
127  }
128  if (is_baryon()) {
129  if (baryon_number() == 1) {
130  return valence_quarks_required == 1 || valence_quarks_required == 2;
131  }
132  if (baryon_number() == -1) {
133  return valence_quarks_required == -1 || valence_quarks_required == -2;
134  }
135  }
136  throw std::runtime_error("String fragment is neither baryon nor meson");
137 }
Here is the call graph for this function:

◆ operator<()

bool smash::PdgCode::operator< ( const PdgCode  rhs) const
inline

Sorts PDG Codes according to their numeric value.

This is used by std::map

Definition at line 814 of file pdgcode.h.

814  {
815  return dump_ < rhs.dump_;
816  /* the complex thing to do here is to calculate:
817  * code() < rhs.code()
818  * but for getting a total order that's overkill. The uint32_t value in
819  * dump_ works just fine. */
820  }

◆ operator==()

bool smash::PdgCode::operator== ( const PdgCode  rhs) const
inline
Returns
if the codes are equal

Definition at line 823 of file pdgcode.h.

823 { return dump_ == rhs.dump_; }

◆ operator!=()

bool smash::PdgCode::operator!= ( const PdgCode  rhs) const
inline
Returns
if the codes are not equal.

Definition at line 826 of file pdgcode.h.

826 { return !(*this == rhs); }

◆ is_antiparticle_of()

bool smash::PdgCode::is_antiparticle_of ( const PdgCode  rhs) const
inline
Returns
if the code of rhs is the inverse of this one.

Definition at line 829 of file pdgcode.h.

829  {
830  return code() == -rhs.code();
831  }
Here is the call graph for this function:
Here is the caller graph for this function:

◆ invalid()

static PdgCode smash::PdgCode::invalid ( )
inlinestatic

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.

Definition at line 841 of file pdgcode.h.

841 { return PdgCode(0x0); }
Here is the caller graph for this function:

◆ get_decimal()

int32_t smash::PdgCode::get_decimal ( ) const
inline
Returns
an integer with decimal representation of the code. If the spin is too large for the last digit, an additional digit at the beginning will be used, so that the sum of the first and the last digit is the spin. This is used for binary and ROOT output.
Exceptions
InvalidPdgCodeif the spin degeneracy is larger than 9

Definition at line 852 of file pdgcode.h.

852  {
853  if (is_nucleus()) {
854  // ±10LZZZAAAI
855  return antiparticle_sign() *
856  (nucleus_.I_ + 10 * nucleus_.A_ + 10000 * nucleus_.Z_ +
857  10000000 * nucleus_.n_Lambda_ + 1000000000);
858  }
859  int n_J_1 = 0;
860  int n_J_2 = digits_.n_J_;
861  if (n_J_2 > 9) {
862  n_J_1 = n_J_2 - 9;
863  n_J_2 = 9;
864  }
865  return antiparticle_sign() *
866  (n_J_2 + digits_.n_q3_ * 10 + digits_.n_q2_ * 100 +
867  digits_.n_q1_ * 1000 + digits_.n_L_ * 10000 +
868  digits_.n_R_ * 100000 + digits_.n_ * 1000000 + n_J_1 * 10000000);
869  }
Here is the caller graph for this function:

◆ deexcite()

void smash::PdgCode::deexcite ( )
inline

Remove all excitation, except spin. Sign and quark content remains.

Definition at line 872 of file pdgcode.h.

872  {
873  if (!is_nucleus()) {
874  chunks_.excitation_ = 0;
875  } else {
876  nucleus_.I_ = 0;
877  }
878  }

◆ contains_quark()

bool smash::PdgCode::contains_quark ( int  quark) const

Checks whether this hadron contains a quark (or antiquark) of a given flavour.

The check is true if:

  • the particle is a hadron, and
  • the hadron contains at least one quark or antiquark of the specified flavour.

For flavour-neutral mesons (e.g. π⁰, η, φ, J/ψ, ϒ), this returns true because such states contain a quark–antiquark pair of that flavour, even though the net flavour is zero.

For baryons, only the net (valence) quark content is considered.

Parameters
[in]quarkSigned PDG quark code.
Returns
true if the hadron contains at least one quark (or antiquark) of the requested flavour with the requested sign; false otherwise.

Definition at line 31 of file pdgcode.cc.

31  {
32  if (!is_hadron())
33  return false;
34 
35  const int absQuark = std::abs(signedQuark);
36  if (absQuark < 1 || absQuark > 6)
37  return false;
38 
39  const int pdgId = get_decimal();
40  const int absPdgId = std::abs(pdgId);
41 
42  if (absPdgId == 111 || absPdgId == 113 || absPdgId == 223) {
43  return (absQuark == 1 || absQuark == 2);
44  }
45  if (absPdgId == 221 || absPdgId == 331) {
46  return (absQuark == 1 || absQuark == 2 || absQuark == 3);
47  }
48 
49  const int netFlavor = net_quark_number(absQuark);
50  if (netFlavor != 0) {
51  return signedQuark > 0 ? (netFlavor > 0) : (netFlavor < 0);
52  }
53 
54  if (baryon_number() != 0)
55  return false;
56 
57  const int flavorDigit1 = digits_.n_q2_;
58  const int flavorDigit2 = digits_.n_q3_;
59  return (absQuark == flavorDigit1 || absQuark == flavorDigit2);
60 }
Here is the call graph for this function:

◆ net_quark_number()

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().

Parameters
[in]quarkPDG Code of quark: (1..6) = (d,u,s,c,b,t)
Returns
for the net number of quarks (#quarks - #antiquarks)
Exceptions
std::invalid_argumentif quark is not any of d, u, s, c, b and t quarks

Definition at line 62 of file pdgcode.cc.

62  {
63  // input sanitization: Only quark numbers 1 through 6 are allowed.
64  if (quark < 1 || quark > 6) {
65  throw std::invalid_argument(
66  std::string("PdgCode::net_quark_number(): ") +
67  std::string("Quark number must be in [1..6], received ") +
68  std::to_string(quark));
69  }
70  if (is_nucleus()) {
71  const int Np = nucleus_.Z_;
72  const int Nn = nucleus_.A_ - nucleus_.Z_ - nucleus_.n_Lambda_;
73  const int NL = nucleus_.n_Lambda_;
74  switch (quark) {
75  case 1:
76  return (2 * Nn + Np + NL) * antiparticle_sign();
77  case 2:
78  return (Nn + 2 * Np + NL) * antiparticle_sign();
79  case 3:
80  return NL * antiparticle_sign();
81  // Charmed nuclei may exist, but they are not foreseen by PDG standard
82  default:
83  return 0.0;
84  }
85  }
86  // non-hadrons and those that have none of this quark type: 0.
87  if (!is_hadron() || (digits_.n_q1_ != quark && digits_.n_q2_ != quark &&
88  digits_.n_q3_ != quark)) {
89  return 0;
90  }
91  // baryons: count quarks.
92  if (baryon_number() != 0) {
93  // for anti-baryons, the sign changes:
94  return antiparticle_sign() *
95  ((digits_.n_q1_ == quark) + (digits_.n_q2_ == quark) +
96  (digits_.n_q3_ == quark));
97  }
98 
99  // mesons.
100 
101  // quarkonium state? Not open net_quark_number.
102  if (digits_.n_q3_ == quark && digits_.n_q2_ == quark) {
103  return 0;
104  }
105  /* this has covered all the easy stuff
106  * get the "other" quark. (We know this must exist, since they are
107  * not both the right one and one of them is the right one). */
108  int otherquark = (digits_.n_q2_ == quark) ? digits_.n_q3_ : digits_.n_q2_;
109  /* "our" quark is the heavier one: 1 for u,c,t; -1 for d,s,b (and of
110  * course the antiparticle sign) */
111  if (quark > otherquark) {
112  return ((quark % 2 == 0) ? 1 : -1) * antiparticle_sign();
113  }
114  /* ours is the lighter: If the heavier particle is u,c,t, the lighter
115  * one (ours) is an antiquark. */
116  return ((otherquark % 2 == 0) ? -1 : 1) * antiparticle_sign();
117 }
Here is the call graph for this function:
Here is the caller graph for this function:

◆ nucleus_p()

int smash::PdgCode::nucleus_p ( ) const
inline

Number of protons in nucleus.

Definition at line 915 of file pdgcode.h.

915  {
916  return (is_nucleus() && !nucleus_.antiparticle_) ? nucleus_.Z_ : 0;
917  }
Here is the caller graph for this function:

◆ nucleus_n()

int smash::PdgCode::nucleus_n ( ) const
inline

Number of neutrons in nucleus.

Definition at line 919 of file pdgcode.h.

919  {
920  return (is_nucleus() && !nucleus_.antiparticle_)
921  ? nucleus_.A_ - nucleus_.Z_ - nucleus_.n_Lambda_
922  : 0;
923  }
Here is the caller graph for this function:

◆ nucleus_La()

int smash::PdgCode::nucleus_La ( ) const
inline

Number of Lambdas in nucleus.

Definition at line 925 of file pdgcode.h.

925  {
926  return (is_nucleus() && !nucleus_.antiparticle_) ? nucleus_.n_Lambda_ : 0;
927  }
Here is the caller graph for this function:

◆ nucleus_ap()

int smash::PdgCode::nucleus_ap ( ) const
inline

Number of antiprotons in nucleus.

Definition at line 929 of file pdgcode.h.

929  {
930  return (is_nucleus() && nucleus_.antiparticle_) ? nucleus_.Z_ : 0;
931  }
Here is the caller graph for this function:

◆ nucleus_an()

int smash::PdgCode::nucleus_an ( ) const
inline

Number of antineutrons in nucleus.

Definition at line 933 of file pdgcode.h.

933  {
934  return (is_nucleus() && nucleus_.antiparticle_)
935  ? nucleus_.A_ - nucleus_.Z_ - nucleus_.n_Lambda_
936  : 0;
937  }
Here is the caller graph for this function:

◆ nucleus_aLa()

int smash::PdgCode::nucleus_aLa ( ) const
inline

Number of anti-Lambdas in nucleus.

Definition at line 939 of file pdgcode.h.

939  {
940  return (is_nucleus() && nucleus_.antiparticle_) ? nucleus_.n_Lambda_ : 0;
941  }
Here is the caller graph for this function:

◆ nucleus_A()

int smash::PdgCode::nucleus_A ( ) const
inline

Nucleus mass number.

Definition at line 943 of file pdgcode.h.

943 { return is_nucleus() ? nucleus_.A_ : 0; }
Here is the caller graph for this function:

◆ ucode()

std::uint32_t smash::PdgCode::ucode ( ) const
inlineprivate
Returns
an unsigned integer with the PDG code in hexadecimal (disregarding the antiparticle flag).

Definition at line 1039 of file pdgcode.h.

1039 { return (dump_ & 0x0fffffff); }

◆ get_digit_from_char()

std::uint32_t smash::PdgCode::get_digit_from_char ( const char  inp) const
inlineprivate
Returns
digits from a hexadecimal character.
Parameters
[in]inpcharacter which is translated into digit
Exceptions
InvalidPdgCodeif character does not correspond to digit

Definition at line 1047 of file pdgcode.h.

1047  {
1048  // Decimal digit
1049  if (48 <= inp && inp <= 57) {
1050  return inp - 48;
1051  }
1052  // Hexdecimal digit, uppercase
1053  if (65 <= inp && inp <= 70) {
1054  return inp - 65 + 10;
1055  }
1056  // Hexdecimal digit, lowercase
1057  if (97 <= inp && inp <= 102) {
1058  return inp - 97 + 10;
1059  }
1060  throw InvalidPdgCode("PdgCode: Invalid character " + std::string(&inp, 1) +
1061  " found.\n");
1062  }

◆ set_from_string()

void smash::PdgCode::set_from_string ( const std::string &  codestring)
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.

Parameters
[in]codestringstring which is translated into PdgCode
Exceptions
InvalidPdgCodeif the input string is empty
InvalidPdgCodeif it is a nucleus whose PDG code does not begin with 10
InvalidPdgCodeif it is not a nucleus while number of digits is more than 8
InvalidPdgCodeif the 1st quark field is not any of d, u, s, c, b and t quarks
InvalidPdgCodeif the 2nd quark field is not any of d, u, s, c, b and t quarks
InvalidPdgCodeif the 3rd quark field is not any of d, u, s, c, b and t quarks
InvalidPdgCodeif there is nothing else but sign

Definition at line 1085 of file pdgcode.h.

1085  {
1086  dump_ = 0;
1087  // Implicit with the above: digits_.antiparticle_ = false;
1088  digits_.n_ = digits_.n_R_ = digits_.n_L_ = digits_.n_q1_ = digits_.n_q2_ =
1089  digits_.n_q3_ = digits_.n_J_ = digits_.is_nucleus_ = 0;
1090  size_t length = codestring.size();
1091  if (length < 1) {
1092  throw InvalidPdgCode("Empty string does not contain PDG Code\n");
1093  }
1094  int c = 0;
1095  /* Look at current character; if it is a + or minus sign, read it
1096  * and advance to next char. */
1097  if (codestring[c] == '-') {
1098  digits_.antiparticle_ = true;
1099  ++c;
1100  } else if (codestring[c] == '+') {
1101  digits_.antiparticle_ = false;
1102  ++c;
1103  }
1104  // Save if the first character was a sign:
1105  unsigned int sign = c;
1106 
1107  // Nucleus
1108  if (length == 10 + sign) {
1109  nucleus_.is_nucleus_ = true;
1110  if (codestring[c] != '1' || codestring[c + 1] != '0') {
1111  throw InvalidPdgCode("Pdg code of nucleus \"" + codestring +
1112  "\" should start with 10\n");
1113  }
1114  c += 2;
1115  // ±10LZZZAAAI is the standard for nuclei
1116  std::array<int, 8> digits;
1117  for (int i = 0; i < 8; i++) {
1118  digits[i] = get_digit_from_char(codestring[c + i]);
1119  }
1120  nucleus_.n_Lambda_ = digits[0];
1121  nucleus_.Z_ = 100 * digits[1] + 10 * digits[2] + digits[3];
1122  nucleus_.A_ = 100 * digits[4] + 10 * digits[5] + digits[6];
1123  nucleus_.I_ = digits[7];
1124  return;
1125  }
1126 
1127  // Codestring shouldn't be longer than 8 + sign, except for nuclei
1128  if (length > 8 + sign) {
1129  throw InvalidPdgCode("String \"" + codestring +
1130  "\" too long for PDG Code\n");
1131  }
1132  /* Please note that in what follows, we actually need c++, not ++c.
1133  * first digit is used for n_J if the last digit is not enough. */
1134  if (length > 7 + sign) {
1135  digits_.n_J_ += get_digit_from_char(codestring[c++]);
1136  }
1137  // Codestring has 7 digits? 7th from last goes in n_.
1138  if (length > 6 + sign) {
1139  digits_.n_ = get_digit_from_char(codestring[c++]);
1140  }
1141  // It has 6 or 7 digits? 6th from last is n_R_.
1142  if (length > 5 + sign) {
1143  digits_.n_R_ = get_digit_from_char(codestring[c++]);
1144  }
1145  // 5th from last is n_L_.
1146  if (length > 4 + sign) {
1147  digits_.n_L_ = get_digit_from_char(codestring[c++]);
1148  }
1149  // 4th from last is n_q1_.
1150  if (length > 3 + sign) {
1151  digits_.n_q1_ = get_digit_from_char(codestring[c++]);
1152  if (digits_.n_q1_ > 6) {
1153  throw InvalidPdgCode("Invalid PDG code " + codestring + " (n_q1>6)");
1154  }
1155  }
1156  // 3rd from last is n_q2_.
1157  if (length > 2 + sign) {
1158  digits_.n_q2_ = get_digit_from_char(codestring[c++]);
1159  if (digits_.n_q2_ > 6) {
1160  throw InvalidPdgCode("Invalid PDG code " + codestring + " (n_q2>6)");
1161  }
1162  }
1163  // Next to last is n_q3_.
1164  if (length > 1 + sign) {
1165  digits_.n_q3_ = get_digit_from_char(codestring[c++]);
1166  if (digits_.n_q3_ > 6) {
1167  throw InvalidPdgCode("Invalid PDG code " + codestring + " (n_q3>6)");
1168  }
1169  }
1170  // Last digit is the spin degeneracy.
1171  if (length > sign) {
1172  digits_.n_J_ += get_digit_from_char(codestring[c++]);
1173  } else {
1174  throw InvalidPdgCode(
1175  "String \"" + codestring +
1176  "\" only consists of a sign, that is no valid PDG Code\n");
1177  }
1178  check();
1179  }
void check() const
Do all sorts of validity checks.
Definition: pdgcode.h:284
std::uint32_t get_digit_from_char(const char inp) const
Definition: pdgcode.h:1047
Here is the caller graph for this function:

◆ set_fields()

void smash::PdgCode::set_fields ( std::uint32_t  abscode)
inlineprivate

Sets the bitfield from an unsigned integer.

Usually called from the constructors.

Parameters
[in]abscodeinteger which replace PDG code except sign
Exceptions
InvalidPdgCodeif input is not a valid PDG code
See also
PdgCode::test_code

Definition at line 1190 of file pdgcode.h.

1190  {
1191  /* "dump_ =" overwrites antiparticle_, but this needs to have been set
1192  * already, so we carry it around the assignment. */
1193  bool ap = digits_.antiparticle_;
1194  dump_ = abscode & 0x0fffffff;
1195  digits_.antiparticle_ = ap;
1196  int test = test_code();
1197  if (test > 0) {
1198  throw InvalidPdgCode("Invalid digits " + std::to_string(test) +
1199  " in PDG Code " + string());
1200  }
1201  check();
1202  }
int test_code() const
Checks the integer for invalid hex digits.
Definition: pdgcode.h:250
Here is the call graph for this function:
Here is the caller graph for this function:

Friends And Related Function Documentation

◆ operator>>

std::istream& operator>> ( std::istream &  is,
PdgCode code 
)
friend

istream >> PdgCode assigns the PDG Code from an istream.

Parameters
[in]isinput string
[out]codePdgCode to be set

Definition at line 14 of file pdgcode.cc.

14  {
15  std::string codestring("");
16  is >> codestring;
17  if (!is) {
19  return is;
20  }
21  try {
22  // set the fields from the string:
23  code.set_from_string(codestring);
24  } catch (PdgCode::InvalidPdgCode&) {
25  is.setstate(std::ios::failbit);
27  }
28  return is;
29 }

Member Data Documentation

◆ n_J_

std::uint32_t smash::PdgCode::n_J_

spin quantum number \(n_J = 2 J + 1\).

Definition at line 959 of file pdgcode.h.

◆ n_q3_

std::uint32_t smash::PdgCode::n_q3_

third quark field

Definition at line 961 of file pdgcode.h.

◆ n_q2_

std::uint32_t smash::PdgCode::n_q2_

second quark field

Definition at line 963 of file pdgcode.h.

◆ n_q1_

std::uint32_t smash::PdgCode::n_q1_

first quark field. 0 for mesons.

Definition at line 965 of file pdgcode.h.

◆ n_L_

std::uint32_t smash::PdgCode::n_L_

"angular momentum"

Definition at line 967 of file pdgcode.h.

◆ n_R_

std::uint32_t smash::PdgCode::n_R_

"radial excitation"

Definition at line 969 of file pdgcode.h.

◆ n_

std::uint32_t smash::PdgCode::n_

first field: "counter"

Definition at line 971 of file pdgcode.h.

◆ is_nucleus_ [1/2]

std::uint32_t bool smash::PdgCode::is_nucleus_

1 for nuclei, 0 for the rest

Definition at line 973 of file pdgcode.h.

◆ antiparticle_

bool smash::PdgCode::antiparticle_

first bit: stores the sign.

Definition at line 975 of file pdgcode.h.

◆ 

struct { ... } smash::PdgCode::digits_

The single digits collection of the code.

Here, every PDG code digits is directly accessible.

◆ dump_

std::uint32_t smash::PdgCode::dump_

The bitfield dumped into a single integer.

Please note that the 2nd, 3rd and 4th highest bits are possibly undefined.

Definition at line 994 of file pdgcode.h.

◆ __pad0__

std::uint32_t smash::PdgCode::__pad0__

Definition at line 1001 of file pdgcode.h.

◆ quarks_

std::uint32_t smash::PdgCode::quarks_

The quark digits n_q{1,2,3}_.

Definition at line 1003 of file pdgcode.h.

◆ excitation_

std::uint32_t smash::PdgCode::excitation_

The excitation digits n_, n_R_, n_L_.

Definition at line 1005 of file pdgcode.h.

◆ 

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.

◆ n_Lambda_

std::uint32_t smash::PdgCode::n_Lambda_

Definition at line 1016 of file pdgcode.h.

◆ Z_

std::uint32_t smash::PdgCode::Z_

Definition at line 1017 of file pdgcode.h.

◆ A_

std::uint32_t smash::PdgCode::A_

Definition at line 1018 of file pdgcode.h.

◆ I_

std::uint32_t smash::PdgCode::I_

Definition at line 1019 of file pdgcode.h.

◆ is_nucleus_ [2/2]

bool smash::PdgCode::is_nucleus_

Definition at line 1020 of file pdgcode.h.

◆ 

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_.


The documentation for this class was generated from the following files: