From bd9b62948b5b6371f0f76c85460ac88eac5132e3 Mon Sep 17 00:00:00 2001
From: ralfulrich <ralf.ulrich@kit.edu>
Date: Sat, 26 Sep 2020 18:23:44 +0200
Subject: [PATCH] slight cleanup of SetupStack

---
 Setup/SetupStack.h                     | 41 ++++++++++++++++++--------
 Stack/History/HistorySecondaryView.hpp |  1 +
 Stack/History/HistoryStackExtension.h  |  7 -----
 3 files changed, 29 insertions(+), 20 deletions(-)

diff --git a/Setup/SetupStack.h b/Setup/SetupStack.h
index 2d68a982a..fce58ce07 100644
--- a/Setup/SetupStack.h
+++ b/Setup/SetupStack.h
@@ -58,28 +58,43 @@ namespace corsika::setup {
 
   // ---------------------------------------
   // this is the FINAL stack we use in C8:
+  
+  // the version without history
   // using Stack = detail::StackWithGeometry;
+
+  // the version with history
   using Stack = detail::StackWithHistory;
 
-  /*
-    See Issue 161
-
-    unfortunately clang does not support this in the same way (yet) as
-    gcc, so we have to distinguish here. If clang cataches up, we
-    could remove the clang branch here and also in
-    corsika::Cascade. The gcc code is much more generic and
-    universal. If we could do the gcc version, we won't had to define
-    StackView globally, we could do it with MakeView whereever it is
-    actually needed. Keep an eye on this!
-  */
+  namespace detail {
+    /*
+      See Issue 161
+      
+      unfortunately clang does not support this in the same way (yet) as
+      gcc, so we have to distinguish here. If clang cataches up, we
+      could remove the clang branch here and also in
+      corsika::Cascade. The gcc code is much more generic and
+      universal. If we could do the gcc version, we won't had to define
+      StackView globally, we could do it with MakeView whereever it is
+      actually needed. Keep an eye on this!
+    */
 #if defined(__clang__)
-  using StackView = corsika::stack::SecondaryView<
+    using TheStackView = corsika::stack::SecondaryView<
       typename corsika::setup::Stack::StackImpl,
       // CHECK with CLANG: corsika::setup::Stack::PIType>;
       // corsika::setup::detail::StackWithGeometryInterface>;
       corsika::setup::detail::StackWithHistoryInterface>;
 #elif defined(__GNUC__) || defined(__GNUG__)
-  using StackView = corsika::history::HistorySecondaryView<corsika::stack::MakeView<corsika::setup::Stack>::type>;
+    using TheStackView = corsika::stack::MakeView<corsika::setup::Stack>::type;
 #endif
+  }
+
+  // ---------------------------------------
+  // this is the FINAL stackitertor (particle type) we use in C8:
+
+  // the version without history
+  //using StackView = detail::StackView;
+
+  // the one with history
+  using StackView = corsika::history::HistorySecondaryView<detail::TheStackView>;
 
 } // namespace corsika::setup
diff --git a/Stack/History/HistorySecondaryView.hpp b/Stack/History/HistorySecondaryView.hpp
index 235566b5e..e4a36cc1c 100644
--- a/Stack/History/HistorySecondaryView.hpp
+++ b/Stack/History/HistorySecondaryView.hpp
@@ -24,6 +24,7 @@ namespace corsika::history {
 
     EventPtr event_;
 
+  public:
     using StackIteratorValue = typename TView::StackIteratorValue;
     using StackIterator = typename TView::StackIterator;
 
diff --git a/Stack/History/HistoryStackExtension.h b/Stack/History/HistoryStackExtension.h
index 92b3fd025..798eb1004 100644
--- a/Stack/History/HistoryStackExtension.h
+++ b/Stack/History/HistoryStackExtension.h
@@ -90,13 +90,6 @@ namespace corsika::history {
     void SetParticleData(HistoryDataInterface& /*parent*/) {
             C8LOG_TRACE("HistoyDatatInterface::SetParticleData(parnt)");
 	    SetParticleData();
-
-
-      // store particles at production time in Event here
-      auto const sec_index = event_->addSecondary(
-          stack_sec.GetEnergy(), stack_sec.GetMomentum(), stack_sec.GetPID());
-      stack_sec.SetParentEventIndex(sec_index);
-      stack_sec.SetEvent(event_);
     }
 
     void SetEvent(const std::shared_ptr<TEvent>& v) {
-- 
GitLab