63 const auto offset =
this - std::addressof(
list_all()[0]);
68 assert(offset >= 0 && offset < 0xffff);
94 const auto found = std::lower_bound(
148 std::string basename,
charge;
150 if (name.find(
"⁺⁺") != std::string::npos) {
151 basename = name.substr(0, name.length() -
sizeof(
"⁺⁺") + 1);
153 }
else if (name.find(
"⁺") != std::string::npos) {
154 basename = name.substr(0, name.length() -
sizeof(
"⁺") + 1);
156 }
else if (name.find(
"⁻⁻") != std::string::npos) {
157 basename = name.substr(0, name.length() -
sizeof(
"⁻⁻") + 1);
159 }
else if (name.find(
"⁻") != std::string::npos) {
160 basename = name.substr(0, name.length() -
sizeof(
"⁻") + 1);
162 }
else if (name.find(
"⁰") != std::string::npos) {
163 basename = name.substr(0, name.length() -
sizeof(
"⁰") + 1);
172 constexpr
char bar[] =
"\u0305";
199 throw std::runtime_error(
"Invalid charge " + std::to_string(charge));
204 const auto &log = logger<LogArea::ParticleType>();
205 static ParticleTypeList type_list;
209 std::istringstream lineinput(line.text);
212 std::string parity_string;
213 std::vector<std::string> pdgcode_strings;
215 pdgcode_strings.reserve(4);
216 lineinput >> name >> mass >> width >> parity_string;
219 if (parity_string ==
"+") {
221 }
else if (parity_string ==
"-") {
226 if (lineinput.fail() || fail) {
228 "While loading the ParticleType data:\nFailed to convert the input " 229 "string to the expected data types.",
233 while (!lineinput.eof()) {
234 pdgcode_strings.push_back(
"");
235 lineinput >> pdgcode_strings.back();
236 if (lineinput.fail()) {
238 "While loading the ParticleType data:\nFailed to convert the input " 239 "string to the expected data types.",
243 if (pdgcode_strings.size() < 1) {
245 "While loading the ParticleType data:\nFailed to convert the input " 246 "string due to missing PDG code.",
250 pdgcode.resize(pdgcode_strings.size());
251 std::transform(pdgcode_strings.begin(), pdgcode_strings.end(),
253 [](
const std::string &s) {
return PdgCode(s); });
259 throw std::runtime_error(
260 "Nucleon mass in input file different from 0.938");
263 throw std::runtime_error(
"Kaon mass in input file different from 0.494");
266 throw std::runtime_error(
"Delta mass in input file different from 1.232");
269 throw std::runtime_error(
"d mass in input file different from 1.8756");
273 for (
size_t i = 0; i < pdgcode.size(); i++) {
274 std::string full_name =
name;
275 if (pdgcode.size() > 1) {
279 type_list.emplace_back(full_name, mass, width, parity, pdgcode[i]);
280 log.debug() <<
"Setting particle type: " << type_list.back();
283 PdgCode anti = pdgcode[i].get_antiparticle();
285 const auto anti_parity = (anti.
spin() % 2 == 0) ? parity : -parity;
286 full_name =
antiname(full_name, pdgcode[i]);
287 type_list.emplace_back(full_name, mass, width, anti_parity, anti);
288 log.debug() <<
"Setting antiparticle type: " << type_list.back();
292 type_list.shrink_to_fit();
295 std::sort(type_list.begin(), type_list.end());
299 for (
const auto &t : type_list) {
300 if (t.pdgcode() == prev_pdg) {
302 t.pdgcode().string());
304 prev_pdg = t.pdgcode();
308 throw std::runtime_error(
"Error: Type list was already built!");
315 for (
const auto &t : type_list) {
319 for (
auto &t : type_list) {
342 if (type_resonance.is_stable() ||
343 type_resonance.pdgcode().baryon_number() != 1) {
351 if (type.is_nucleus()) {
363 for (
const auto &mode :
decay_modes().decay_mode_list()) {
382 const double m_step = 0.01;
383 double right_bound_bis;
384 for (
unsigned int i = 0;; i++) {
391 const double precision = 1E-6;
392 double left_bound_bis = right_bound_bis - m_step;
393 while (right_bound_bis - left_bound_bis > precision) {
394 const double mid = (left_bound_bis + right_bound_bis) / 2.0;
396 right_bound_bis = mid;
398 left_bound_bis = mid;
418 if (m < mode->threshold()) {
426 const auto offset =
this - std::addressof(
list_all()[0]);
427 const auto &modes = (*DecayModes::all_decay_modes)[offset];
428 assert(
is_stable() || !modes.is_empty());
439 for (
unsigned int i = 0; i < modes.size(); i++) {
450 if (!ptype.is_stable() && ptype.decay_modes().is_empty()) {
451 throw std::runtime_error(
"Unstable particle " + ptype.name() +
452 " has no decay chanels!");
484 throw std::runtime_error(
485 "Problem in selecting decaymodes in wanted_decaymode()");
493 if (decay_mode_list.size() == 0 ||
509 DecayBranchList partial;
510 partial.reserve(decay_mode_list.size());
511 for (
unsigned int i = 0; i < decay_mode_list.size(); i++) {
513 const auto FinalTypes = decay_mode_list[i]->type().particle_types();
514 double scale_B = 0.0;
515 double scale_I3 = 0.0;
519 for (
const auto finaltype : FinalTypes) {
522 finaltype->isospin3_rel();
525 double sqrt_s = (p + UB * scale_B + UI3 * scale_I3).abs();
527 const double w =
partial_width(sqrt_s, decay_mode_list[i].
get());
531 make_unique<DecayBranch>(decay_mode_list[i]->type(), w));
545 for (
const auto &mode : decaymodes) {
546 double partial_width_at_pole =
width_at_pole() * mode->weight();
547 const ParticleTypePtrList l = {&t_a, &t_b};
548 if (mode->type().has_particles(l)) {
549 w += mode->type().width(
mass(), partial_width_at_pole, m);
563 for (
const auto &mode : decaymodes) {
564 double partial_width_at_pole =
width_at_pole() * mode->weight();
565 const ParticleTypePtrList l = {&p_a.
type(), &p_b.
type()};
566 if (mode->type().has_particles(l)) {
567 w += mode->type().in_width(
mass(), partial_width_at_pole, m,
580 const double m_pole =
mass();
585 const double tanx = std::tan(x);
586 const double m_x = m_pole + width * tanx;
587 const double jacobian = width * (1.0 + tanx * tanx);
620 const double cms_energy,
624 const double max_mass = std::nextafter(cms_energy - mass_stable, 0.);
628 assert(min_mass < max_mass);
631 const double pcm_max =
pCM(cms_energy, mass_stable, min_mass);
638 const double sf_ratio_max =
642 double mass_res, val;
646 const double max = blw_max * q_max;
653 const double pcm =
pCM(cms_energy, mass_stable, mass_res);
663 const auto &log = logger<LogArea::Resonances>();
664 log.debug(
"maximum is being increased in sample_resonance_mass: ",
665 this->max_factor1_,
" ", val / max,
" ", this->
pdgcode(),
" ",
666 mass_stable,
" ", cms_energy,
" ", mass_res);
667 this->max_factor1_ *= val / max;
678 const ParticleType &t2,
const double cms_energy,
int L)
const {
682 const double max_mass_1 =
684 const double max_mass_2 =
687 const double pcm_max =
691 double mass_1, mass_2, val;
704 const double pcm =
pCM(cms_energy, mass_1, mass_2);
715 const auto &log = logger<LogArea::Resonances>();
716 log.debug(
"maximum is being increased in sample_resonance_masses: ",
718 t2.
pdgcode(),
" ", cms_energy,
" ", mass_1,
" ", mass_2);
725 return {mass_1, mass_2};
730 std::stringstream err;
731 err <<
"Particle " << *
this <<
" is stable, so it makes no" 732 <<
" sense to print its spectral function, etc.";
733 throw std::runtime_error(err.str());
736 double rightmost_pole = 0.0;
738 for (
const auto &mode : decaymodes) {
739 double pole_mass_sum = 0.0;
741 pole_mass_sum +=
p->mass();
743 if (pole_mass_sum > rightmost_pole) {
744 rightmost_pole = pole_mass_sum;
748 std::cout <<
"# mass m[GeV], width w(m) [GeV]," 749 <<
" spectral function(m^2)*m [GeV^-1] of " << *
this << std::endl;
750 constexpr
double m_step = 0.02;
754 constexpr
double spectral_function_threshold = 8.e-3;
755 std::cout << std::fixed << std::setprecision(5);
756 for (
unsigned int i = 0;; i++) {
757 const double m = m_min + m_step * i;
759 if (m > rightmost_pole * 2 && sf < spectral_function_threshold) {
762 std::cout << m <<
" " << w <<
" " << sf << std::endl;
768 return out << type.
name() << std::setfill(
' ') << std::right
769 <<
"[ mass:" << field<6> << type.
mass()
771 <<
", PDG:" << field<6> << pdg
772 <<
", charge:" << field<3> << pdg.
charge()
773 <<
", spin:" << field<2> << pdg.
spin() <<
"/2 ]";
static const IsoParticleType & find(const std::string &name)
Returns the IsoParticleType object for the given name.
int charge() const
The charge of the particle.
Potentials * pot_pointer
Pointer to a Potential class.
double breit_wigner_nonrel(double m, double pole, double width)
Returns a non-relativistic Breit-Wigner distribution, which is essentially a Cauchy distribution with...
int I3_
Isospin projection of the particle; filled automatically from pdgcode_.
static ParticleTypePtrList & list_baryon_resonances()
The ThreeVector class represents a physical three-vector with the components .
static ParticleTypePtrList & list_Deltas()
bool has_antiparticle() const
static bool exists(PdgCode pdgcode)
constexpr double really_small
Numerical error tolerance.
bool almost_equal(const N x, const N y)
Checks two numbers for relative approximate equality.
PdgCode pdgcode_
PDG Code of the particle.
int isospin() const
Returns twice the isospin vector length .
Parity parity_
Parity of the particle.
RectangularLattice< FourVector > * UI3_lat_pointer
Pointer to the symmmetry potential on the lattice.
static ParticleTypePtrList & list_light_nuclei()
static void check_consistency()
bool is_dilepton(const PdgCode pdg1, const PdgCode pdg2)
DecayBranchList get_partial_widths(const FourVector p, const ThreeVector x, WhichDecaymodes wh) const
Get all the mass-dependent partial decay widths of a particle with mass m.
Collection of useful constants that are known at compile time.
static ParticleTypePtrList & list_anti_nucleons()
virtual unsigned int particle_number() const =0
int baryon_number() const
bool has_lepton_pair(const PdgCode pdg1, const PdgCode pdg2, const PdgCode pdg3)
ParticleTypePtrList anti_deltas_list
Global pointer to the Particle Type list of anti-deltas.
ParticleTypePtrList nucleons_list
Global pointer to the Particle Type list of nucleons.
int isospin() const
Returns twice the total isospin of the multiplet.
double max_factor2_
Maximum factor for double-res mass sampling, cf. sample_resonance_masses.
unsigned int spin() const
double sample_resonance_mass(const double mass_stable, const double cms_energy, int L=0) const
Resonance mass sampling for 2-particle final state with one resonance (type given by 'this') and one ...
Parity
Represent the parity of a particle type.
constexpr double nucleon_mass
Nucleon mass in GeV.
const DecayType & type() const
std::string name_
name of the particle
double spectral_function(double m) const
Full spectral function of the resonance (relativistic Breit-Wigner distribution with mass-dependent ...
Generic numerical functions.
double mass_
pole mass of the particle
double blatt_weisskopf_sqr(const double p_ab, const int L)
const DecayBranchList & decay_mode_list() const
DecayType is the abstract base class for all decay types.
friend std::ostream & operator<<(std::ostream &out, const ParticleType &type)
Writes all information about the particle type to the output stream.
double effective_mass() const
Get the particle's effective mass.
static bool exists(const std::string &name)
Returns whether the ParticleType with the given pdgcode exists.
static constexpr double width_cutoff
Decay width cutoff for considering a particle as stable.
static std::string chargestr(int charge)
Construct a charge string, given the charge as integer.
static const ParticleType & find(PdgCode pdgcode)
Returns the ParticleType object for the given pdgcode.
ParticleTypePtr operator&() const
Returns an object that acts like a pointer, except that it requires only 2 bytes and inhibits pointer...
double total_width(const double m) const
Get the mass-dependent total width of a particle with mass m.
RectangularLattice< FourVector > * UB_lat_pointer
Pointer to the skyrme potential on the lattice.
static const ParticleTypeList & list_all()
double min_mass_kinematic() const
The minimum mass of the resonance that is kinematically allowed.
virtual double width(double m0, double G0, double m) const =0
const std::string & name() const
ParticleTypePtrList deltas_list
Global pointer to the Particle Type list of deltas.
Particle type contains the static properties of a particle species.
WhichDecaymodes
Decide which decay mode widths are returned in get partical widths.
double breit_wigner(double m, double pole, double width)
Returns a relativistic Breit-Wigner distribution.
double min_mass_spectral() const
The minimum mass of the resonance, where the spectral function is non-zero.
Ignore dilepton decay modes widths.
constexpr double deuteron_mass
Deuteron mass in GeV.
ParticleTypePtrList anti_nucs_list
Global pointer to the Particle Type list of anti-nucleons.
PdgCode stores a Particle Data Group Particle Numbering Scheme particle type number.
static void create_multiplet(const ParticleType &type)
Add a new multiplet to the global list of IsoParticleTypes, which contains type.
double spectral_function_const_width(double m) const
double min_mass_spectral_
minimum mass, where the spectral function is non-zero Mutable, because it is initialized at first cal...
Only return dilepton decays widths.
const ParticleType & type() const
Get the type of the particle.
constexpr double kaon_mass
Kaon mass in GeV.
double max_factor1_
Maximum factor for single-res mass sampling, cf. sample_resonance_mass.
T cauchy(T pole, T width, T min, T max)
Draws a random number from a Cauchy distribution (sometimes also called Lorentz or non-relativistic B...
int32_t charge() const
The charge of the particle.
DecayBranch is a derivative of ProcessBranch, which is used to represent decay channels.
static void create_type_list(const std::string &particles)
Initialize the global ParticleType list (list_all) from the given input data.
ParticleTypePtrList baryon_resonances_list
Global pointer to the Particle Type list of baryon resonances.
ParticleTypePtrList light_nuclei_list
Global pointer to the Particle Type list of light nuclei.
double norm_factor_
This normalization factor ensures that the spectral function is normalized to unity, when integrated over its full domain.
std::pair< double, int > force_scale(const ParticleType &data) const
Evaluates the scaling factor of the forces acting on the particles.
build_vector_< Line > line_parser(const std::string &input)
Helper function for parsing particles.txt and decaymodes.txt.
const ParticleTypeList * all_particle_types
Global pointer to the Particle Type list.
static std::string antiname(const std::string &name, PdgCode code)
Construct an antiparticle name-string from the given name-string for the particle and its PDG code...
double width_at_pole() const
static const ParticleTypePtr try_find(PdgCode pdgcode)
Returns the ParticleTypePtr for the given pdgcode.
A C++ interface for numerical integration in one dimension with the GSL CQUAD integration functions...
IsoParticleType * iso_multiplet_
Container for the isospin multiplet information.
ParticleTypePtrList get_states() const
Returns list of states that form part of the multiplet.
int32_t charge_
Charge of the particle; filled automatically from pdgcode_.
#define unlikely(x)
Tell the branch predictor that this expression is likely false.
std::iterator_traits< octet_iterator >::difference_type sequence_length(octet_iterator lead_it)
Given an iterator to the beginning of a UTF-8 sequence, return the length of the next UTF-8 code poin...
int isospin_
Isospin of the particle; filled automatically from pdgcode_.
A pointer-like interface to global references to ParticleType objects.
std::pair< double, double > sample_resonance_masses(const ParticleType &t2, const double cms_energy, int L=0) const
Resonance mass sampling for 2-particle final state with two resonances.
double width_
width of the particle
double isospin3_rel() const
static ParticleTypePtrList & list_nucleons()
double spectral_function_no_norm(double m) const
Full spectral function without normalization factor.
double get_partial_in_width(const double m, const ParticleData &p_a, const ParticleData &p_b) const
Get the mass-dependent partial in-width of a resonance with mass m, decaying into two given daughter ...
double get_partial_width(const double m, const ParticleType &t_a, const ParticleType &t_b) const
Get the mass-dependent partial width of a resonance with mass m, decaying into two given daughter par...
double min_mass_kinematic_
minimum kinematically allowed mass of the particle Mutable, because it is initialized at first call o...
void ensure_all_read(std::istream &input, const Line &line)
Makes sure that nothing is left to read from this line.
constexpr double delta_mass
Delta mass in GeV.
void dump_width_and_spectral_function() const
Prints out width and spectral function versus mass to the standard output.
const DecayModes & decay_modes() const
The DecayModes class is used to store and update information about decay branches (i...
T pCM(const T sqrts, const T mass_a, const T mass_b) noexcept
The FourVector class holds relevant values in Minkowski spacetime with (+, −, −, −) metric signature.
ParticleType(std::string n, double m, double w, Parity p, PdgCode id)
Creates a fully initialized ParticleType object.
double spectral_function_simple(double m) const
This one is the most simple form of the spectral function, using a Cauchy distribution (non-relativis...
std::string build_error_string(std::string message, const Line &line)
Builds a meaningful error message.
ParticleData contains the dynamic information of a certain particle.
Line consists of a line number and the contents of that line.
static ParticleTypePtrList & list_anti_Deltas()
const ParticleTypePtrList & particle_types() const
std::string string() const
static Integrator integrate
bool wanted_decaymode(const DecayType &t, WhichDecaymodes wh) const
Helper Function that containes the if-statement logic that decides if a decay mode is either a hadron...
double partial_width(const double m, const DecayBranch *mode) const
Get the mass-dependent partial decay width of a particle with mass m in a particular decay mode...