From 9e5e3bbc275026f1b235925c5cd57bb26d239129 Mon Sep 17 00:00:00 2001
From: ralfulrich <ralf.ulrich@kit.edu>
Date: Thu, 18 Feb 2021 19:53:16 +0100
Subject: [PATCH] do not prematurely delete particles!

---
 corsika/detail/framework/process/ProcessSequence.inl | 8 +++-----
 corsika/detail/modules/ObservationPlane.inl          | 1 -
 corsika/detail/modules/ParticleCut.inl               | 1 -
 3 files changed, 3 insertions(+), 7 deletions(-)

diff --git a/corsika/detail/framework/process/ProcessSequence.inl b/corsika/detail/framework/process/ProcessSequence.inl
index 7a0d6409f..b93331d05 100644
--- a/corsika/detail/framework/process/ProcessSequence.inl
+++ b/corsika/detail/framework/process/ProcessSequence.inl
@@ -67,12 +67,10 @@ namespace corsika {
     }
 
     if constexpr (t2ProcSeq) {
-      if (!isAbsorbed(ret)) { ret |= B_.doContinuous(particle, vT, limitId); }
+      ret |= B_.doContinuous(particle, vT, limitId);
     } else if constexpr (is_continuous_process_v<process2_type>) {
-      if (!isAbsorbed(ret)) {
-        ret |= B_.doContinuous(particle, vT,
-                               limitId == ContinuousProcessIndex(IndexProcess2));
-      }
+      ret |=
+          B_.doContinuous(particle, vT, limitId == ContinuousProcessIndex(IndexProcess2));
     }
 
     return ret;
diff --git a/corsika/detail/modules/ObservationPlane.inl b/corsika/detail/modules/ObservationPlane.inl
index 33cb556ec..c4da50e94 100644
--- a/corsika/detail/modules/ObservationPlane.inl
+++ b/corsika/detail/modules/ObservationPlane.inl
@@ -48,7 +48,6 @@ namespace corsika {
     if (deleteOnHit_) {
       count_ground_++;
       energy_ground_ += energy;
-      particle.erase();
       return ProcessReturn::ParticleAbsorbed;
     } else {
       return ProcessReturn::Ok;
diff --git a/corsika/detail/modules/ParticleCut.inl b/corsika/detail/modules/ParticleCut.inl
index f4d756675..ffbbbed8d 100644
--- a/corsika/detail/modules/ParticleCut.inl
+++ b/corsika/detail/modules/ParticleCut.inl
@@ -153,7 +153,6 @@ namespace corsika {
     CORSIKA_LOG_TRACE("ParticleCut::DoContinuous");
     if (checkCutParticle(particle)) {
       CORSIKA_LOG_TRACE("removing during continuous");
-      particle.erase();
       // signal to upstream code that this particle was deleted
       return ProcessReturn::ParticleAbsorbed;
     }
-- 
GitLab