From 1f7a2c17bbc2c012d23836576c8a63a2be8a34f4 Mon Sep 17 00:00:00 2001
From: ralfulrich <ralf.ulrich@kit.edu>
Date: Thu, 18 Feb 2021 19:54:35 +0100
Subject: [PATCH] the one and only way to remove particles after doContinuous

---
 corsika/detail/framework/core/Cascade.inl | 8 +++++++-
 1 file changed, 7 insertions(+), 1 deletion(-)

diff --git a/corsika/detail/framework/core/Cascade.inl b/corsika/detail/framework/core/Cascade.inl
index 5f218b878..3c73d38c8 100644
--- a/corsika/detail/framework/core/Cascade.inl
+++ b/corsika/detail/framework/core/Cascade.inl
@@ -148,7 +148,13 @@ namespace corsika {
         ProcessReturn::ParticleAbsorbed) {
       CORSIKA_LOG_DEBUG("Cascade: delete absorbed particle PID={} E={} GeV",
                         vParticle.getPID(), vParticle.getEnergy() / 1_GeV);
-      if (!vParticle.isErased()) vParticle.erase();
+      if (vParticle.isErased()) {
+        CORSIKA_LOG_WARN(
+            "Particle marked as Absorbed in doContinuous, but prematurely erased. This "
+            "may be bug. Check.");
+      } else {
+        vParticle.erase();
+      }
       return;
     }
 
-- 
GitLab