ParticleGun Momentum different to initial step momentum

Geant4 question:

Hi! I would like to retrieve from the B1SteppingAction, the initial momentum of a track.

Initially, I would have expected that the Momentum before the first step should be identical to the one I am giving in the G4ParticleGun (inside PrimaryGeneratorAction class). In fact it is not.

I found a couple of method to find the momentum of a track.

if ( theTrack -> GetCurrentStepNumber() == 1 && theTrack->GetParentID()==0 ) G4cout << " VertexMom: " <GetVertexMomentumDirection().getX() << " G4TrackMomentum " << theTrack->GetMomentum().getX()/GeV << " PreStepMom: " << theTrack ->GetStep()->GetPreStepPoint()->GetMomentumDirection().getX() << " PostStepMom: " << theTrack ->GetStep()->GetPostStepPoint()->GetMomentumDirection().getX() << "pdg code "<< theTrack->GetDefinition()->GetPDGEncoding() << G4endl;

1. VertexMom: -0.145659 G4TrackMomentum -0.282452 PreStepMom: -0.145659 PostStepMom: -0.145317pdg code 211
2. VertexMom: 0.26067902914328 G4TrackMomentum 0.20885139163474 PreStepMom: 0.26067902914328 PostStepMom: 0.26093791297248pdg code -211

This is what I am actually giving to the particle gun. x: -0.262733 mom y: 0.0633266 mom z: 1.78339 pdg: 211 x: 0.171599 mom y: -0.0157178 mom z: 0.635323 pdg: -211

i. What is the difference between theTrack->GetVertexMomentumDirection() and theTrack->GetMomentum() at step number1?

ii/ Why the momentum before step one is not the one I gave in ParticleGun?

Thank you so much! Regards, Robert Amarinei


It seems me, that in many cases you get the direction of the momentum, so the components are normalized with the absolute value of the (total) momentum.

Also i think the

gives you the momentum of the particle after the first step (although it seems greater than the original). If you want to be sure to get the momentum at the pre step point, you can use myTrack->GetStep()->GetMomentum().getX()

About the vertex, i’m not sure.

Hope it helps!
Regards, Gábor

HI! Thanks for your response!
Yeah indeed I use myTrack->GetStep()->GetPreStepPoint()->GetMomentumDircetion().getX() and I would expect this would correspond to the momentum I input in the G4ParticleGun. It does not.

Moreover, not even the momentum after the step does not correspond to the G4Track::GetMomentumDirection() …