diff --git a/src/AdePTGeant4Integration.cpp b/src/AdePTGeant4Integration.cpp index a89f3ec7..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, @@ -487,6 +490,9 @@ 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) + // Note: we own this vector, we are responsible for deleting it! + aG4Step->NewSecondaryVector(); // aG4Step->SetSecondary(nullptr); // Missing data // G4Track