Get particle position at the end of a step

I have 2 methods to get the particle position at the end of a simulation step:

G4ThreeVector position  = track->GetPosition() - step->GetDeltaPosition();

G4ThreeVector position  = step->GetPostStepPoint()->GetPosition();

In my code, I invoke these 2 methods in SteppingAction::UserSteppingAction() method, but these 2 methods returns different results.

Are these 2 methods different?

Please fill out the following information to help in answering your question, and also see tips for posting code snippets. If you don’t provide this information it will take more time to help with your problem!

_Geant4 Version:_4.11.0.p01
_Operating System:_windows subsystem linux (wsl2)
CMake Version:

Dear Saluta,

Yes, they calculate different things. When UserSteppingAction() is called, track->GetPosition() gives already the post-step point position. If you want them to give the same result, you do not need to substract the step delta position.


Thank you so much for your answer.

So in UserSteppingAction() any information from track, say,
will return identical result as from

Yes, that should be correct. My understanding is that step->GetDeltaPosition() is a “convenience function”, so you don’t have to manually do GetPostStepPoint()->GetPosition() - GetPreStepPoint()->GetPosition().

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.