From 635ee0b185a459a1823fbf2cee15c65a259fe6db Mon Sep 17 00:00:00 2001 From: Maximilian Reininghaus <maximilian.reininghaus@tu-dortmund.de> Date: Sat, 4 Jun 2022 01:05:42 +0200 Subject: [PATCH] new get_name() function for printing nuclear A,Z --- corsika/detail/framework/core/ParticleProperties.inl | 8 ++++++++ corsika/framework/core/ParticleProperties.hpp | 5 ++++- 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/corsika/detail/framework/core/ParticleProperties.inl b/corsika/detail/framework/core/ParticleProperties.inl index af41af0fc..14cfee9a2 100644 --- a/corsika/detail/framework/core/ParticleProperties.inl +++ b/corsika/detail/framework/core/ParticleProperties.inl @@ -92,6 +92,14 @@ namespace corsika { return particle::detail::names[static_cast<CodeIntType>(code)]; } + inline std::string get_name(Code code, full_name) { + if (is_nucleus(code)) { + return fmt::format("nucleus ({},{})", get_nucleus_A(code), get_nucleus_Z(code)); + } + + return std::string{get_name(code)}; + } + inline TimeType constexpr get_lifetime(Code const p) { return particle::detail::lifetime[static_cast<CodeIntType>(p)] * second; } diff --git a/corsika/framework/core/ParticleProperties.hpp b/corsika/framework/core/ParticleProperties.hpp index be6772f7a..227b633c8 100644 --- a/corsika/framework/core/ParticleProperties.hpp +++ b/corsika/framework/core/ParticleProperties.hpp @@ -108,6 +108,7 @@ namespace corsika { namespace corsika { // forward declarations to be used in GeneratedParticleProperties + struct full_name {}; //!< tag class for get_name() int16_t constexpr get_charge_number(Code const); //!< electric charge in units of e ElectricChargeType constexpr get_charge(Code const); //!< electric charge @@ -146,7 +147,9 @@ namespace corsika { PDGCode constexpr get_PDG(Code const); PDGCode constexpr get_PDG(unsigned int const A, unsigned int const Z); std::string_view constexpr get_name(Code const); //!< name of the particle as string - TimeType constexpr get_lifetime(Code const); //!< lifetime + std::string get_name(Code, + full_name); //!< get name of particle, including (A,Z) for nuclei + TimeType constexpr get_lifetime(Code const); //!< lifetime bool constexpr is_hadron(Code const); //!< true if particle is hadron bool constexpr is_em(Code const); //!< true if particle is electron, positron or photon -- GitLab