Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

G4TransportationWithMsc: Always update momentum direction #76

Merged
merged 1 commit into from
Oct 27, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -372,8 +372,7 @@ G4double G4TransportationWithMsc::AlongStepGetPhysicalInteractionLength(
// 2) Call SampleScattering(), which *may* change it.
const G4ThreeVector displacement =
mscModel->SampleScattering(fTransportEndMomentumDir, minSafety);
// 3) Get the changed direction and inform G4Transportation.
fMomentumChanged = true;
// 3) Get the changed direction.
fTransportEndMomentumDir = *fParticleChangeForMSC->GetProposedMomentumDirection();

const G4double r2 = displacement.mag2();
@@ -469,6 +468,12 @@ G4double G4TransportationWithMsc::AlongStepGetPhysicalInteractionLength(

fParticleChange.ProposeTrueStepLength(totalTruePathLength);

// Inform G4Transportation that the momentum might have changed due
// to scattering. We do this unconditionally to avoid the situation
// where the last step is done without MSC and G4Transportation reset
// the flag, for example when running without field.
fMomentumChanged = true;

return totalGeometryStepLength;
}
}