Moving track off boundary to find next volume

Dear all,

I’m using a user-developed kind of GDML based geometry configuration and it appears to be causing problems with importance biasing, because the boundaries between volumes are defined as the world volume. Whenever a step hits the exact boundary, the resulting volume is the world volume and therefore the importance is 1. So instead of the process seeing two adjacent volumes with importance of for example 5000 and 6000 and doing splitting, it sees 5000 and 1 and kills off the track with high likelihood.

All I need for this to work, is to know the volume that is just a tiny bit further along the momentum direction of the current track, because then I could get the correct importance and proceed from there.

Playing around with the G4Navigator and LocateGlobalPointAndSetup so far only yielded it giving me still the world volume despite the position being moved, or warnings.

I have found old answers about this problem like for example by Peter Gumplinger in 2013 (somehow it doesn’t let me post a link):

I suggest you do not modify the current track in such a radical way as to transpose its position - far away. I am afraid that the G4Navigator will be ‘confused’. It’s better to clone it, give the clone a position, and then the G4Navigator ‘knows’ that it needs to re-seed its geometry memory.

So I have been trying to do that. I’ve got so far:
G4StepPoint postpoint = step->GetPostStepPoint();
G4ThreeVector pos = postpoint->GetPosition();
G4ThreeVector mom = postpoint->GetMomentum();
mom * = 0.01; // not sure if a good value for that
G4ThreeVector pos2 = pos+mom;
G4Track
clone = new G4Track(*track);
clone->SetPosition(pos2);

But when I try to retrieve a volume via clone->GetVolume() I get a seg fault. I’m assuming this is because the transportation manager hasn’t figured out where this new track is supposed to be? So how do I get G4Navigator to “re-seed its geometry memory”?

I intend to use
fParticleChange.Initialize(*clone);
fParticleChange.ProposeTrackStatus(fStopAndKill);
to kill the clone again just like for the russian roulette of the importance sampling, after I have retrieved the volume and importance information so that it doesn’t interfere in the tracking. Does that make sense?

I am having a similar “issue”.
I want to know, at a boundary A, how far the next boundary is.
If I use ComputeStep, I should get the distance to boundary A not the next one.
If I change my position with a simple startPosition+=1e-6*startMomentumDir;, I also get an angry Geant4:
`-------- WWWW ------- G4Exception-START -------- WWWW -------
*** G4Exception : GeomNav1002
issued by : G4Navigator::ComputeStep()
Accuracy error or slightly inaccurate position shift.
The Step’s starting point has moved 1e-06 mm
since the last call to a Locate method.
This has resulted in moving 1e-06 mm from the last point at which the safety was calculated
which is more than the computed safety= 7.03617e-07 mm at that point.
This difference is 2.96383e-07 mm.
The tolerated accuracy is 1e-06 mm.

*** This is just a warning message. ***
-------- WWWW -------- G4Exception-END --------- WWWW -------`.
Does anyone have a solution, or an idea for a solution, to any of the two problems?