Particles' step counting as last step in the volume without leaving the volume

Hi all,

I want to count the primary particles that succeed in passing through my sensitive detector, but I get a number greater than the number of initial particles !

As you will see in this tracking output ;

*********************************************************************************************************
* G4Track Information:   Particle = e-,   Track ID = 1,   Parent ID = 0
*********************************************************************************************************

Step#    X(mm)    Y(mm)    Z(mm) KinE(MeV)  dE(MeV) StepLeng TrackLeng  NextVolume ProcName
    0        0        0     -950        10        0        0         0       World initStep
    1        0        0     -902        10 1.27e-24       48        48      Target Transportation
    2        0        0     -900      8.89     1.11      2.1      50.1       World Transportation
    3        0        0     -900      8.89        0        0      50.1      Target Transportation
    4    -1.91    0.219     -902      6.95     1.94     3.04      53.1       World Transportation
    5     -162    -17.5   -1e+03      6.95 4.81e-24      189       242  OutOfWorld Transportation

*********************************************************************************************************

the 2nd step says that the next volume is the WorldVolume while this primary particle will change direction in step 3, and will propagate the whole step 4 in my sensitive detector before leaving it in step 5.
So it counts twice.

.
What can I do to eliminate these steps? (I used the IsLastStepInVolume() condition but I get the same result, as the next volume information remains the same.)

Is there a better way to count particles at a volume boundary ?
.

Thank you !
Younes

I managed to get out of this issue by imposing a condition on the position of the Track. But I am not sure if this is the best solution…

Younes