SetMomentumDirection question

Hello~
I have found two functions in Geant4.
The first one is this :
if(aStep->GetTrack()->GetNextVolume()->GetName() == “DetectorOptic”) {
G4ThreeVector particlePosition = aStep->GetPostStepPoint()->GetPosition();
G4ThreeVector detectorPosition = detector->GetOptic()->GetObjectTranslation();
G4ThreeVector newDirection = detectorPosition - particlePosition;
aStep->GetPostStepPoint()->SetMomentumDirection(newDirection);
}

The other one is this:
G4Track* theTrack = const_cast<G4Track*>(aTrack);

theTrack->SetMomentumDirection(momentumDir);
theTrack->SetVelocity(velocity);
theTrack->UseGivenVelocity(true);

So I’m wondering the difference between the two “setmomentumdirection” methods, If I set the momentumdirection in a step using the 2nd method, can I set the next step direction successfully (just as the first method)?
Thank you sincerely,
Jincai.

1 Like