Skip to content

Commit 0004184

Browse files
sawenzelclaude
andcommitted
Block the mother left in a multi-level exit in the VecGeom navigator
This fixes the volume blocked after a step that leaves a daughter and its mother at once. - The blocked volume was the deepest volume left, a grandchild of the new volume, which VecGeom's navigators never match. - It is now the volume left that is a daughter of the deepest volume the old and new paths share, as in G4Navigator. - This is the fix of G4VecGeomNav for the same code. https://gitlab.cern.ch/VecGeom/g4vecgeomnav/-/merge_requests/28 Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
1 parent 347d3b1 commit 0004184

1 file changed

Lines changed: 13 additions & 2 deletions

File tree

‎Detectors/gconfig/src/VecGeomG4Navigator.cxx‎

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -336,8 +336,19 @@ G4VPhysicalVolume* VecGeomG4Navigator::LocateGlobalPointAndSetup(const G4ThreeVe
336336
vecgeom::Transformation3D m;
337337
mCurState.TopMatrix(m);
338338
vecgeom::GlobalLocator::RelocatePointFromPathForceDifferent(m.Transform(q), mCurState);
339-
mReloScratch.SetLastExited();
340-
mCurState.SetLastExited(mReloScratch.GetLastExitedState());
339+
// As G4Navigator, block the volume left that is a daughter of the deepest volume both paths share.
340+
int shared = 0;
341+
while (!mCurState.IsOutside() && shared + 1 < static_cast<int>(mCurState.GetCurrentLevel()) &&
342+
shared + 1 < static_cast<int>(mReloScratch.GetCurrentLevel()) &&
343+
mCurState.At(shared + 1) == mReloScratch.At(shared + 1)) {
344+
++shared;
345+
}
346+
mPathScratch = mReloScratch;
347+
while (static_cast<int>(mPathScratch.GetCurrentLevel()) > shared + 2) {
348+
mPathScratch.Pop();
349+
}
350+
mPathScratch.SetLastExited();
351+
mCurState.SetLastExited(mPathScratch.GetLastExitedState());
341352
setExited(mReloScratch, true);
342353
}
343354
mLocatedOnBoundary = true;

0 commit comments

Comments
 (0)