From 651dd4337ba5e2d9c53e7403c0d25df551868fbe Mon Sep 17 00:00:00 2001
From: Maximilian Reininghaus <maximilian.reininghaus@tu-dortmund.de>
Date: Fri, 2 Oct 2020 18:38:47 +0200
Subject: [PATCH] fixed setting of event type

---
 Framework/Cascade/Cascade.h | 12 +++++++-----
 1 file changed, 7 insertions(+), 5 deletions(-)

diff --git a/Framework/Cascade/Cascade.h b/Framework/Cascade/Cascade.h
index c4f07d647..29c99d28e 100644
--- a/Framework/Cascade/Cascade.h
+++ b/Framework/Cascade/Cascade.h
@@ -327,9 +327,7 @@ namespace corsika::cascade {
       units::si::InverseTimeType inv_decay_count = units::si::InverseTimeType::zero();
       auto const returnCode =
           fProcessSequence.SelectDecay(particle, view, sample_process, inv_decay_count);
-      if constexpr (TStackView::has_event) {
-        view.GetProjectile().GetEvent()->setEventType(history::EventType::Decay);
-      }
+      SetEventType(view, history::EventType::Decay);
       return returnCode;
     }
 
@@ -345,10 +343,14 @@ namespace corsika::cascade {
       auto inv_lambda_count = units::si::InverseGrammageType::zero();
       auto const returnCode = fProcessSequence.SelectInteraction(
           particle, view, sample_process, inv_lambda_count);
+      SetEventType(view, history::EventType::Interaction);
+      return returnCode;
+    }
+
+    void SetEventType(TStackView& view, history::EventType eventType) {
       if constexpr (TStackView::has_event) {
-        view.GetProjectile().GetEvent()->setEventType(history::EventType::Interaction);
+        for (auto&& sec : view) { sec.GetEvent()->setEventType(eventType); }
       }
-      return returnCode;
     }
 
     // but this here temporarily. Should go into dedicated file later:
-- 
GitLab