Skip to content

Commit 9529402

Browse files
sawenzelclaude
andcommitted
Tell the exited volume by its path in the VecGeom navigator
This fixes tracks stopping in the mother when they leave a volume into another copy of its container. - After an exit through coinciding faces the locate must not descend back into the volume just left. - That volume was recognised by its placement alone, which also sits in every other copy of its mother. - A track going from a tile in one EMCAL tower to the same tile in the neighbouring tower was therefore left in the air around the towers, with a zero-length step. - The volume is now recognised by its whole path. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
1 parent ca01776 commit 9529402

2 files changed

Lines changed: 10 additions & 8 deletions

File tree

‎Detectors/gconfig/src/VecGeomG4Navigator.cxx‎

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -213,7 +213,7 @@ G4double VecGeomG4Navigator::ComputeStep(const G4ThreeVector& globalPoint, const
213213
/// under a field is the momentum. Nor does it descend back into `avoid`, the volume the crossing
214214
/// exited: on a face a helix touches tangentially chord and momentum disagree about the side.
215215
void VecGeomG4Navigator::leaveFlushVolumes(const V3& point, const V3& dir, int minLevel,
216-
vecgeom::VPlacedVolume const* avoid)
216+
vecgeom::NavigationState const* avoid)
217217
{
218218
for (int round = 0; round < 4; ++round) {
219219
vecgeom::VPlacedVolume const* left = nullptr;
@@ -247,12 +247,14 @@ void VecGeomG4Navigator::leaveFlushVolumes(const V3& point, const V3& dir, int m
247247
return; // no daughter holds the point
248248
}
249249
if (avoid != nullptr && mCurState.GetCurrentLevel() > level) {
250-
// Undo a descent into the volume the crossing exited, at whatever depth the search put it.
251-
mPathScratch = mCurState;
252-
while (mPathScratch.GetCurrentLevel() > level && mPathScratch.Top() != avoid) {
253-
mPathScratch.Pop();
250+
// Undo a descent into the volume the crossing exited. It is told by its whole path: the same
251+
// placement also sits in every other copy of its mother, where the track may well go.
252+
const int exited = avoid->GetCurrentLevel();
253+
bool back = static_cast<int>(mCurState.GetCurrentLevel()) >= exited;
254+
for (int l = exited - 1; back && l > 0; --l) {
255+
back = mCurState.At(l) == avoid->At(l);
254256
}
255-
if (mPathScratch.GetCurrentLevel() > level) {
257+
if (back) {
256258
while (mCurState.GetCurrentLevel() > level) {
257259
mCurState.Pop();
258260
}
@@ -369,7 +371,7 @@ G4VPhysicalVolume* VecGeomG4Navigator::LocateGlobalPointAndSetup(const G4ThreeVe
369371
}
370372
if (crossing) {
371373
leaveFlushVolumes(q, dir, entering ? static_cast<int>(mNextState.GetCurrentLevel()) : 0,
372-
entering ? nullptr : topOf(mReloScratch));
374+
entering || topOf(mReloScratch) == nullptr ? nullptr : &mReloScratch);
373375
updateCrossingFlags(entering);
374376
}
375377
mWouldEnter = false;

‎Detectors/gconfig/src/VecGeomG4Navigator.h‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ class VecGeomG4Navigator : public VecGeomG4NavigatorBase
6565
G4VPhysicalVolume* updateG4History();
6666
void locateFromWorld(const V3& point);
6767
/// Go up past every volume the point is on the surface of and heading out of, then down again.
68-
void leaveFlushVolumes(const V3& point, const V3& dir, int minLevel, vecgeom::VPlacedVolume const* avoid);
68+
void leaveFlushVolumes(const V3& point, const V3& dir, int minLevel, vecgeom::NavigationState const* avoid);
6969
/// Sets fEnteredDaughter and fExitedMother from the paths before (mReloScratch) and after a crossing.
7070
void updateCrossingFlags(bool entering);
7171
void clearLastExited()

0 commit comments

Comments
 (0)