fix circular module dep: thread trackID counter via pointer instead of include
G4tracking cannot include G4EventManager.hh because G4event already depends on G4tracking, creating a circular dependency. Fix: pass a raw G4int* pointer to the event-level trackIDCounter from G4EventManager through G4TrackingManager::SetTrackIDCounter into G4SteppingManager, where ProcessSecondariesFromParticleChange uses it to pre-assign track IDs without any new include. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -59,9 +59,6 @@ class G4EventManager
|
|||||||
static G4EventManager* GetEventManager();
|
static G4EventManager* GetEventManager();
|
||||||
// This method returns the singleton pointer of G4EventManager.
|
// This method returns the singleton pointer of G4EventManager.
|
||||||
|
|
||||||
G4int ReserveNextTrackID();
|
|
||||||
// Pre-assign the next sequential track ID to a secondary being born inside
|
|
||||||
// G4SteppingManager, so that its ID is available in UserSteppingAction.
|
|
||||||
|
|
||||||
G4EventManager();
|
G4EventManager();
|
||||||
~G4EventManager();
|
~G4EventManager();
|
||||||
|
|||||||
@@ -172,6 +172,8 @@ void G4EventManager::DoProcessing(G4Event* anEvent,
|
|||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
trackManager->SetTrackIDCounter(&trackIDCounter);
|
||||||
|
|
||||||
std::unordered_set<G4VTrackingManager *> trackingManagersToFlush;
|
std::unordered_set<G4VTrackingManager *> trackingManagersToFlush;
|
||||||
|
|
||||||
do
|
do
|
||||||
@@ -401,11 +403,6 @@ G4int G4EventManager::StoreSubEvent(G4Event* evt, G4int& subEvtType, G4SubEvent*
|
|||||||
return evt->StoreSubEvent(subEvtType,se);
|
return evt->StoreSubEvent(subEvtType,se);
|
||||||
}
|
}
|
||||||
|
|
||||||
G4int G4EventManager::ReserveNextTrackID()
|
|
||||||
{
|
|
||||||
return ++trackIDCounter;
|
|
||||||
}
|
|
||||||
|
|
||||||
void G4EventManager::StackTracks(G4TrackVector* trackVector,
|
void G4EventManager::StackTracks(G4TrackVector* trackVector,
|
||||||
G4bool IDhasAlreadySet)
|
G4bool IDhasAlreadySet)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -90,6 +90,7 @@ class G4SteppingManager
|
|||||||
void SetUserAction(G4UserSteppingAction* apAction);
|
void SetUserAction(G4UserSteppingAction* apAction);
|
||||||
G4Track* GetTrack() const;
|
G4Track* GetTrack() const;
|
||||||
void SetVerboseLevel(G4int vLevel);
|
void SetVerboseLevel(G4int vLevel);
|
||||||
|
void SetTrackIDCounter(G4int* counter) { fTrackIDCounter = counter; }
|
||||||
void SetVerbose(G4VSteppingVerbose*);
|
void SetVerbose(G4VSteppingVerbose*);
|
||||||
G4Step* GetStep() const;
|
G4Step* GetStep() const;
|
||||||
void SetNavigator(G4Navigator* value);
|
void SetNavigator(G4Navigator* value);
|
||||||
@@ -195,6 +196,8 @@ class G4SteppingManager
|
|||||||
|
|
||||||
G4double sumEnergyChange = 0.0;
|
G4double sumEnergyChange = 0.0;
|
||||||
|
|
||||||
|
G4int* fTrackIDCounter = nullptr; // pointer into G4EventManager::trackIDCounter, set via SetTrackIDCounter
|
||||||
|
|
||||||
G4VParticleChange* fParticleChange = nullptr;
|
G4VParticleChange* fParticleChange = nullptr;
|
||||||
G4Track* fTrack = nullptr;
|
G4Track* fTrack = nullptr;
|
||||||
G4TrackVector* fSecondary = nullptr;
|
G4TrackVector* fSecondary = nullptr;
|
||||||
|
|||||||
@@ -78,6 +78,7 @@ class G4TrackingManager
|
|||||||
void SetStoreTrajectory(G4int value);
|
void SetStoreTrajectory(G4int value);
|
||||||
|
|
||||||
G4SteppingManager* GetSteppingManager() const;
|
G4SteppingManager* GetSteppingManager() const;
|
||||||
|
void SetTrackIDCounter(G4int* counter) { fpSteppingManager->SetTrackIDCounter(counter); }
|
||||||
|
|
||||||
G4UserTrackingAction* GetUserTrackingAction() const;
|
G4UserTrackingAction* GetUserTrackingAction() const;
|
||||||
|
|
||||||
|
|||||||
@@ -32,7 +32,6 @@
|
|||||||
// --------------------------------------------------------------------
|
// --------------------------------------------------------------------
|
||||||
|
|
||||||
#include "G4SteppingManager.hh"
|
#include "G4SteppingManager.hh"
|
||||||
#include "G4EventManager.hh"
|
|
||||||
|
|
||||||
#include "G4ForceCondition.hh"
|
#include "G4ForceCondition.hh"
|
||||||
#include "G4GPILSelection.hh"
|
#include "G4GPILSelection.hh"
|
||||||
@@ -603,7 +602,9 @@ G4int G4SteppingManager::ProcessSecondariesFromParticleChange()
|
|||||||
|
|
||||||
// Pre-assign track ID so it is visible in UserSteppingAction via
|
// Pre-assign track ID so it is visible in UserSteppingAction via
|
||||||
// GetSecondaryInCurrentStep(); G4EventManager::StackTracks skips re-assignment.
|
// GetSecondaryInCurrentStep(); G4EventManager::StackTracks skips re-assignment.
|
||||||
tempSecondaryTrack->SetTrackID(G4EventManager::GetEventManager()->ReserveNextTrackID());
|
if (fTrackIDCounter) {
|
||||||
|
tempSecondaryTrack->SetTrackID(++(*fTrackIDCounter));
|
||||||
|
}
|
||||||
|
|
||||||
// If this 2ndry particle has 'zero' kinetic energy, make sure
|
// If this 2ndry particle has 'zero' kinetic energy, make sure
|
||||||
// it invokes a rest process at the beginning of the tracking
|
// it invokes a rest process at the beginning of the tracking
|
||||||
|
|||||||
Reference in New Issue
Block a user