From f24b9ea20b3a311d62e7ec9ddb57dd8676c6148b Mon Sep 17 00:00:00 2001
From: Nikos Karastathis <n.karastathis@kit.edu>
Date: Thu, 21 Oct 2021 15:34:33 +0200
Subject: [PATCH] Only time update should be after .doContinuous()

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

diff --git a/corsika/detail/framework/core/Cascade.inl b/corsika/detail/framework/core/Cascade.inl
index 0f4e9dae3..07ec49546 100644
--- a/corsika/detail/framework/core/Cascade.inl
+++ b/corsika/detail/framework/core/Cascade.inl
@@ -147,6 +147,10 @@ namespace corsika {
     // move particle along the trajectory to new position
     // also update momentum/direction/time
     step.setLength(min_distance);
+    vParticle.setPosition(step.getPosition(1));
+    // assumption: tracking does not change absolute momentum (continuous physics can and
+    // will):
+    vParticle.setMomentum(step.getDirection(1) * vParticle.getMomentum().getNorm());
 
     // apply all continuous processes on particle + track
     if (sequence_.doContinuous(vParticle, step, limitingId) ==
@@ -162,10 +166,6 @@ namespace corsika {
       }
       return;
     }
-    vParticle.setPosition(step.getPosition(1));
-    // assumption: tracking does not change absolute momentum (continuous physics can and
-    // will):
-    vParticle.setMomentum(step.getDirection(1) * vParticle.getMomentum().getNorm());
     vParticle.setTime(vParticle.getTime() + step.getDuration());
     if (isContinuous) {
       return; // there is nothing further, step is finished
-- 
GitLab