How to get the distance of a particle until the end of a phantom in ComputeStep?

Hello all,

I hope you’re fine.

I would like to get the distance that separates a particle present in a G4PhantomParameterisation from the end of said phantom (and not from the voxel) in accordance with the direction of said particle within a G4(Regular or other)Navigation::ComputeStep that gives us a G4NavigationHistory& history. For that, I do:

  const G4VPhysicalVolume* motherPhysical = history.GetTopVolume();
  const G4LogicalVolume* motherLogical = motherPhysical->GetLogicalVolume();
  const G4VSolid* motherSolid = motherLogical->GetSolid();

  G4double motherStep = motherSolid->DistanceToOut(localPoint,
                                                   localDirection,
                                                   true);

Is that correct?

For information :
Geant4 Version: 11.2.2
Operating System: Windows and Linux

Thanks a lot,