From ddae3bdf4484d075e22018e5bcfdb599a94ce708 Mon Sep 17 00:00:00 2001 From: Maximilian Reininghaus <maximilian.reininghaus@kit.edu> Date: Mon, 13 May 2019 15:18:43 -0300 Subject: [PATCH] removed redundant isNucleus array --- Framework/Particles/ParticleProperties.h | 8 +++++--- Framework/Particles/pdxml_reader.py | 19 ++----------------- 2 files changed, 7 insertions(+), 20 deletions(-) diff --git a/Framework/Particles/ParticleProperties.h b/Framework/Particles/ParticleProperties.h index ba38e7383..c2da034c7 100644 --- a/Framework/Particles/ParticleProperties.h +++ b/Framework/Particles/ParticleProperties.h @@ -93,7 +93,7 @@ namespace corsika::particles { corsika::units::si::ElectricChargeType constexpr GetCharge(Code const p) { if (p == Code::Nucleus) throw std::runtime_error("Cannot GetCharge() of particle::Nucleus -> unspecified"); - return GetChargeNumber(p) * (corsika::units::constants::e); + return GetChargeNumber(p) * corsika::units::constants::e; } constexpr std::string const& GetName(Code const p) { @@ -131,11 +131,13 @@ namespace corsika::particles { return detail::nucleusZ[static_cast<CodeIntType>(p)]; } + bool constexpr IsNucleus(Code const p) { return GetNucleusA(p) != 0; } + /** - * the output operator for particles + * the output operator for humand-readable particle codes **/ - std::ostream& operator<<(std::ostream& stream, corsika::particles::Code const p); + std::ostream& operator<<(std::ostream&, corsika::particles::Code); Code ConvertFromPDG(PDGCode); diff --git a/Framework/Particles/pdxml_reader.py b/Framework/Particles/pdxml_reader.py index 5c6732475..ccb7dfc23 100755 --- a/Framework/Particles/pdxml_reader.py +++ b/Framework/Particles/pdxml_reader.py @@ -369,38 +369,23 @@ def gen_properties(particle_db): ### nuclear data ### - # is nucleus flag - string += "static constexpr std::array<bool, size> isNucleus = {\n" - for p in particle_db.values(): - value = 'false' - if p['isNucleus']: - value = 'true' - string += " {val},\n".format(val = value) - string += "};\n" - # nucleus mass number A string += "static constexpr std::array<int16_t, size> nucleusA = {\n" for p in particle_db.values(): - A = 0 - if p['isNucleus']: - A = p['A'] + A = p.get('A', 0) string += " {val},\n".format(val = A) string += "};\n" # nucleus charge number Z string += "static constexpr std::array<int16_t, size> nucleusZ = {\n" for p in particle_db.values(): - Z = 0 - if p['isNucleus']: - Z = p['Z'] + Z = p.get('Z', 0) string += " {val},\n".format(val = Z) string += "};\n" return string - - ############################################################### # # return string with a list of classes for all particles -- GitLab