From 2495a1098ad74bf277d62e126525bd63fa4464bd Mon Sep 17 00:00:00 2001 From: ralfulrich <ralf.ulrich@kit.edu> Date: Thu, 6 May 2021 09:06:38 +0200 Subject: [PATCH] also added getPDG getter to handle nuclear codes --- corsika/detail/stack/NuclearStackExtension.inl | 8 ++++++++ corsika/stack/NuclearStackExtension.hpp | 5 +++++ corsika/stack/VectorStack.hpp | 2 ++ examples/vertical_EAS.cpp | 2 +- 4 files changed, 16 insertions(+), 1 deletion(-) diff --git a/corsika/detail/stack/NuclearStackExtension.inl b/corsika/detail/stack/NuclearStackExtension.inl index 9bb5843d1..fa0d5941f 100644 --- a/corsika/detail/stack/NuclearStackExtension.inl +++ b/corsika/detail/stack/NuclearStackExtension.inl @@ -193,6 +193,14 @@ namespace corsika::nuclear_stack { (isNucleus() ? fmt::format("A={}, Z={}", getNuclearA(), getNuclearZ()) : "n/a")); } + template <template <typename> class InnerParticleInterface, + typename StackIteratorInterface> + inline PDGCode NuclearParticleInterface<InnerParticleInterface, + StackIteratorInterface>::getPDG() const { + return (isNucleus() ? PDGCode(1000000000 + getNuclearZ() * 10000 + getNuclearA() * 10) + : super_type::getPDG()); + } + template <template <typename> class InnerParticleInterface, typename StackIteratorInterface> inline void diff --git a/corsika/stack/NuclearStackExtension.hpp b/corsika/stack/NuclearStackExtension.hpp index 0f14c68e9..6c9286566 100644 --- a/corsika/stack/NuclearStackExtension.hpp +++ b/corsika/stack/NuclearStackExtension.hpp @@ -142,6 +142,11 @@ namespace corsika::nuclear_stack { } /// @} + /** + * Overwrite normal getPDG function with nuclear version + */ + PDGCode getPDG() const; + /** * Overwrite normal setMomentum function with nuclear version */ diff --git a/corsika/stack/VectorStack.hpp b/corsika/stack/VectorStack.hpp index 47b503c8f..223d651f9 100644 --- a/corsika/stack/VectorStack.hpp +++ b/corsika/stack/VectorStack.hpp @@ -130,6 +130,8 @@ namespace corsika { Code getPID() const { return super_type::getStackData().getPID(super_type::getIndex()); } + //! Get PDG code + PDGCode getPDG() const { return get_PDG(getPID()); } //! Get kinetic energy HEPEnergyType getKineticEnergy() const { return super_type::getStackData().getKineticEnergy(super_type::getIndex()); diff --git a/examples/vertical_EAS.cpp b/examples/vertical_EAS.cpp index d6f5e98f5..a8916b55e 100644 --- a/examples/vertical_EAS.cpp +++ b/examples/vertical_EAS.cpp @@ -394,7 +394,7 @@ int main(int argc, char** argv) { Plane const obsPlane(showerCore, DirectionVector(rootCS, {0., 0., 1.})); ObservationPlane observationLevel(obsPlane, DirectionVector(rootCS, {1., 0., 0.})); // register the observation plane with the output - output.add("obsplane", observationLevel); + output.add("particles", observationLevel); auto sequence = make_sequence(stackInspect, hadronSequence, reset_particle_mass, decaySequence, -- GitLab