From 9fed7ec0beda41db1a766fa9c90bb4018c3e4485 Mon Sep 17 00:00:00 2001
From: Felix Riehn <felix@matilda>
Date: Tue, 29 Jan 2019 15:14:28 +0000
Subject: [PATCH] removed temporary nucleon stack

---
 Processes/Sibyll/NuclearInteraction.h | 15 +++++++--------
 1 file changed, 7 insertions(+), 8 deletions(-)

diff --git a/Processes/Sibyll/NuclearInteraction.h b/Processes/Sibyll/NuclearInteraction.h
index daf93a4a7..35ab127c9 100644
--- a/Processes/Sibyll/NuclearInteraction.h
+++ b/Processes/Sibyll/NuclearInteraction.h
@@ -459,19 +459,18 @@ namespace corsika::process::sibyll {
       }
 
       // create dummy stack, to store nucleon projectile
-      Stack inelasticNucleons;
+      //      Stack inelasticNucleons;
       // add one nucleon per inelastic interaction
       for(int j=0; j<nInelNucleons; ++j){	
 
 	// TODO: sample neutron or proton
 	auto pCode = corsika::particles::Proton::GetCode();
-	inelasticNucleons.AddParticle( pCode, PprojNucLab.GetTimeLikeComponent(), PprojNucLab.GetSpaceLikeComponents(), pOrig, tOrig );
-      }
-      
-      // process stack of inelastic nucleons
-      for(auto& nucl : inelasticNucleons)
-	// create inelastic nucleon-nucleon interaction
-	fHadronicInteraction.DoInteraction( nucl, s);
+	// temporarily add to stack, will be removed after interaction
+	auto inelasticNucleon = p.AddSecondary( pCode, PprojNucLab.GetTimeLikeComponent(),
+						PprojNucLab.GetSpaceLikeComponents(), pOrig, tOrig );
+	// create inelastic interaction
+	fHadronicInteraction.DoInteraction( inelasticNucleon, s);
+      }	
 	      
       // delete parent particle
       p.Delete();
-- 
GitLab