Routine ID: GEOM310 | |
---|---|
Author(s): | Submitted: 01.06.83 |
Origin: R.Brun, A.C.McPherson | Revised: 15.12.93 |
CALL GNEXT (X,SNEXT*,SAFETY*) CALL GTNEXT (X,SNEXT*,SAFETY*) Finds distance to the next boundary. It takes explicit account of shape content and uniqueness.
This routine evaluates the two distances which are needed by the GEANT tracking routines. GTNEXT and GNEXT perform the same function, but GNEXT is a static routine which can be called by the user, while GTNEXT is the routines used internally by GEANT during tracking, and it should not be called by the user.
If INFROM (common /GCVOLU/) is different from 0, GTNEXT interprets it as the daughter out of which the particle just came, and uses the list of daughters stored with that volume, possibly modified by GSNEXT/GSNEAR to calculate the distance to the next boundary.
The first action of GTNEXT is to calculate the SAFETY distance. If this is larger than the current step candidate, no other calculation is performed and the IGNEXT flag (common /GCTRAK/) is set to 0, indicating that no change of volume is occurring at the end of the current step. If the step is smaller than safety, then SNEXT is computed. If the step is smaller than SNEXT, again there will not be any change of volume during the step and IGNEXT is set to 0. If on the contrary the candidate step is larger than SNEXT, a change of volume will occur at the end of the step, and IGNEXT is set to 1 and INGOTO (common /GCTRAK/) is set to the number of the daughter where the particle is entering, if any.
Charged particles in magnetic field are transported with a similar logic. However, even if the candidate step is smaller than SNEXT, the particle can still cross into another volume due to its bent path. When tracking in magnetic field, after every step greater than SAFETY it is checked whether the particle is still in the same volume. If this is not the case, the step is divided by two and transport is tried again. Conversely a charged particle in magnetic field may still be in the current volume even after having travelled the distance to the nearest boundary along a straight line. So boundary crossing is declared only when IGNEXT is different from 0 and the difference between the real trajectory and the bent one is smaller than EPSIL (common /GCTMED/).