pre-assign secondary track IDs in ProcessSecondariesFromParticleChange
Add G4EventManager::ReserveNextTrackID() to atomically increment and return the next track ID counter. Call it from G4SteppingManager:: ProcessSecondariesFromParticleChange() so that each secondary has its track ID set before UserSteppingAction fires. G4EventManager::StackTracks is updated to skip re-assignment when GetTrackID() != 0 (pre-assigned). Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -32,6 +32,7 @@
|
||||
// --------------------------------------------------------------------
|
||||
|
||||
#include "G4SteppingManager.hh"
|
||||
#include "G4EventManager.hh"
|
||||
|
||||
#include "G4ForceCondition.hh"
|
||||
#include "G4GPILSelection.hh"
|
||||
@@ -600,6 +601,10 @@ G4int G4SteppingManager::ProcessSecondariesFromParticleChange()
|
||||
// Set the process pointer which created this track
|
||||
tempSecondaryTrack->SetCreatorProcess(creatorProcess);
|
||||
|
||||
// Pre-assign track ID so it is visible in UserSteppingAction via
|
||||
// GetSecondaryInCurrentStep(); G4EventManager::StackTracks skips re-assignment.
|
||||
tempSecondaryTrack->SetTrackID(G4EventManager::GetEventManager()->ReserveNextTrackID());
|
||||
|
||||
// If this 2ndry particle has 'zero' kinetic energy, make sure
|
||||
// it invokes a rest process at the beginning of the tracking
|
||||
//
|
||||
|
||||
Reference in New Issue
Block a user