Geant4 Version: 11.3.0
Operating System: Mac OSX
Compiler/Version: Clang++ 16
I am attempting to do a very simple simulation of shooting a thermal neutron into a block of pure boron 10 and measuring the distance the resulting alpha particle travels. To do this, during the program I am checking in UserSteppingAction for each step if the particle definition is G4Alpha and if the track status is fStopAndKill. I then calculate and store the information I want in a histogram. My intention being that I only want to see alpha particles which are actually stopped. When doing this simulation for one single neutron, I am seeing multiple entries in my histograms. Shouldn’t the track status fStopAndKill be true for only one single step per particle track? My only conclusion is that for some reason it is being set true for multiple steps. Here is the relevant portion of the code. After running the simulation, h1 should have 1 entry but it has for instance 36 entries:
void SteppingAction::UserSteppingAction(const G4Step *step){
auto track = step->GetTrack();
auto particleDef = track->GetParticleDefinition();
if (track->GetParticleDefinition() == G4Alpha::AlphaDefinition()) {
if (track->GetTrackStatus() == fStopAndKill) {
G4ThreeVector finalPosition = track->GetPosition();
G4ThreeVector vertexPosition = track->GetVertexPosition();
G4double relativeDisplacement = (finalPosition - vertexPosition).mag();
h1->Fill(relativeDisplacement / um);
}
}