From 31d2c4a15f2229f4496ef5ae0059fc69af54746c Mon Sep 17 00:00:00 2001 From: Josh Bendavid Date: Tue, 17 Jan 2023 00:52:24 +0100 Subject: [PATCH] re-initialize geometry in g4e propagator as required at beginning of propagation and for each step --- TrackPropagation/Geant4e/src/Geant4ePropagator.cc | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/TrackPropagation/Geant4e/src/Geant4ePropagator.cc b/TrackPropagation/Geant4e/src/Geant4ePropagator.cc index 54852ac133027..42f1418322925 100644 --- a/TrackPropagation/Geant4e/src/Geant4ePropagator.cc +++ b/TrackPropagation/Geant4e/src/Geant4ePropagator.cc @@ -30,6 +30,7 @@ #include "G4TransportationManager.hh" #include "G4Tubs.hh" #include "G4UImanager.hh" +#include "G4ErrorPropagationNavigator.hh" // CLHEP #include "CLHEP/Units/GlobalSystemOfUnits.h" @@ -311,11 +312,18 @@ std::pair Geant4ePropagator::propagateGeneric( theG4eManager->InitTrackPropagation(); + // re-initialize navigator to avoid mismatches and/or segfaults + theG4eManager->GetErrorPropagationNavigator()->LocateGlobalPointAndSetup( + g4InitPos, &g4InitMom, /*pRelativeSearch = */ false, /*ignoreDirection = */ false); + bool continuePropagation = true; while (continuePropagation) { iterations++; LogDebug("Geant4e") << std::endl << "step count " << iterations << " step length " << finalPathLength; + // re-initialize navigator to avoid mismatches and/or segfaults + theG4eManager->GetErrorPropagationNavigator()->LocateGlobalPointWithinVolume(g4eTrajState.GetPosition()); + const int ierr = theG4eManager->PropagateOneStep(&g4eTrajState, mode); if (ierr != 0) {