Skip to content

Commit 8e49d4e

Browse files
[mini] initialize (empty) secondary vector (#444)
This initializes an empty secondary vector when returning a GPU step to the CPU. This is needed such that the access to the secondary does not crash: ``` const std::vector<const G4Track*> *secondaryVector = aStep->GetSecondaryInCurrentStep(); secondaryVector->size(); <- currently crashes as it is a nullPtr ``` With this PR the secondary vector is available, just empty. This PR is needed to run Athena with the `Sim_tf` transform.
1 parent 3f9b775 commit 8e49d4e

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

src/AdePTGeant4Integration.cpp

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -481,6 +481,9 @@ void AdePTGeant4Integration::ProcessGPUStep(GPUHit const &hit, bool const callUs
481481
if (aSensitiveDetector != nullptr && hit.fStepCounter != 0) {
482482
aSensitiveDetector->Hit(fScoringObjects->fG4Step);
483483
}
484+
485+
// cleanup of the secondary vector that is created in FillG4Step above
486+
fScoringObjects->fG4Step->DeleteSecondaryVector();
484487
}
485488

486489
void AdePTGeant4Integration::FillG4NavigationHistory(vecgeom::NavigationState aNavState,
@@ -555,6 +558,9 @@ void AdePTGeant4Integration::FillG4Step(GPUHit const *aGPUHit, G4Step *aG4Step,
555558
if (aGPUHit->fStepCounter == 1) aG4Step->SetFirstStepFlag(); // Real data
556559
if (aGPUHit->fLastStepOfTrack) aG4Step->SetLastStepFlag(); // Real data
557560
// aG4Step->SetPointerToVectorOfAuxiliaryPoints(nullptr); // Missing data
561+
// initialize secondary vector (although it is empty for now)
562+
// Note: we own this vector, we are responsible for deleting it!
563+
aG4Step->NewSecondaryVector();
558564
// aG4Step->SetSecondary(nullptr); // Missing data
559565

560566
// G4Track

0 commit comments

Comments
 (0)