Two GetMomentumDirection() and two SetMomentumDirection()

I found the GetMomentumDirection() and SetMomentumDirection(const G4ThreeVector& aValue) in G4Track.hh file. I also found the GetMomentumDirection() and SetMomentumDirection(const G4ThreeVector& aValue) in G4StepPoint.hh file. I’m wondering the difference between them.
In other words, when I want to set the momentum direction of a step, which one should I use? If I should use the one in G4StepPoint.hh, what can the SetmomentumDirection(…) in G4Track.hh be used to do?
If I want to know the momentumdirection of a step, which GetMomentumDirection should I use? What is the difference between the momentumdirection of presteppoint and poststeppoint ?

Thank you,


in Geant4 we recommend change parameters of the track in G4VProcess class and not in user actions. Normally in user actions you get const pointer to G4Track, soit is protected from modifications.


Thank you, VI.
I found that the momentumdirection is changed when I use thetrack->SetmomentumDirection(…) in usersteppingaction class. However, it seems that the momentumdirection changes to a constant vector and cannot be reset again. Maybe I don’t express clearly, because it is more complicated.

Best regards,


one of possibilities to manually specify what happens to the track is to use G4VFastSimulationManagerProcess (and as Vladimir says - it’s a process so it will be able to modify the track).
It would allow you to alter the momentum direction of the track based on whatever you implement in the class derived from G4VFastSimulationModel. In the ::DoIt(const G4FastTrack&, G4FastStep& aFastStep) method you would need to call aFastStep.ProposePrimaryTrackFinalMomentumDirection (const G4ThreeVector&).
For more information consult the application developer’s guide and the examples.


Thank you, Anna.
The way I set the track momentum direction is wrong and thank you for your explanation.

Best regards,