From 4741d1703ae62f964bc2a080642fdad74e019d7f Mon Sep 17 00:00:00 2001 From: SeverinDiederichs Date: Fri, 3 Oct 2025 11:56:41 +0200 Subject: [PATCH 1/2] initialize (empty) secondary vector --- src/AdePTGeant4Integration.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/AdePTGeant4Integration.cpp b/src/AdePTGeant4Integration.cpp index a89f3ec7..347d3868 100644 --- a/src/AdePTGeant4Integration.cpp +++ b/src/AdePTGeant4Integration.cpp @@ -487,6 +487,8 @@ void AdePTGeant4Integration::FillG4Step(GPUHit const *aGPUHit, G4Step *aG4Step, if (aGPUHit->fStepCounter == 1) aG4Step->SetFirstStepFlag(); // Real data if (aGPUHit->fLastStepOfTrack) aG4Step->SetLastStepFlag(); // Real data // aG4Step->SetPointerToVectorOfAuxiliaryPoints(nullptr); // Missing data + // initialize secondary vector (although it is empty for now) + aG4Step->NewSecondaryVector(); // aG4Step->SetSecondary(nullptr); // Missing data // G4Track From 16487abb2b518a85891d41fe375b36b1ea1e6892 Mon Sep 17 00:00:00 2001 From: SeverinDiederichs Date: Fri, 3 Oct 2025 14:24:39 +0200 Subject: [PATCH 2/2] delete secondary vector after use --- src/AdePTGeant4Integration.cpp | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/AdePTGeant4Integration.cpp b/src/AdePTGeant4Integration.cpp index 347d3868..94f0986f 100644 --- a/src/AdePTGeant4Integration.cpp +++ b/src/AdePTGeant4Integration.cpp @@ -413,6 +413,9 @@ void AdePTGeant4Integration::ProcessGPUStep(GPUHit const &hit, bool const callUs if (aSensitiveDetector != nullptr && hit.fStepCounter != 0) { aSensitiveDetector->Hit(fScoringObjects->fG4Step); } + + // cleanup of the secondary vector that is created in FillG4Step above + fScoringObjects->fG4Step->DeleteSecondaryVector(); } void AdePTGeant4Integration::FillG4NavigationHistory(vecgeom::NavigationState aNavState, @@ -488,6 +491,7 @@ void AdePTGeant4Integration::FillG4Step(GPUHit const *aGPUHit, G4Step *aG4Step, if (aGPUHit->fLastStepOfTrack) aG4Step->SetLastStepFlag(); // Real data // aG4Step->SetPointerToVectorOfAuxiliaryPoints(nullptr); // Missing data // initialize secondary vector (although it is empty for now) + // Note: we own this vector, we are responsible for deleting it! aG4Step->NewSecondaryVector(); // aG4Step->SetSecondary(nullptr); // Missing data