50 return fpEventManager;
55 if(fpEventManager !=
nullptr)
58 "G4EventManager::G4EventManager() has already been made.");
68 fpEventManager =
this;
74 delete trackContainer;
78 delete userEventAction;
79 fpEventManager =
nullptr;
82void G4EventManager::DoProcessing(
G4Event* anEvent)
84 abortRequested =
false;
89 "IllegalState -- Geometry not closed: cannot process an event.");
92 currentEvent = anEvent;
94 if(storetRandomNumberStatusToG4Event > 1)
96 std::ostringstream oss;
98 randomNumberStatusToG4Event = oss.str();
113 if ( verboseLevel > 0 )
115 G4cout <<
"=====================================" <<
G4endl;
116 G4cout <<
" G4EventManager::ProcessOneEvent() " <<
G4endl;
117 G4cout <<
"=====================================" <<
G4endl;
123#ifdef G4_STORE_TRAJECTORY
124 trajectoryContainer =
nullptr;
128 if(sdManager !=
nullptr)
133#if defined(GEANT4_USE_TIMEMORY)
138 if ( verboseLevel > 1 )
141 <<
" vertices passed from G4Event." <<
G4endl;
147 StackTracks(transformer->
GimmePrimaries(currentEvent,trackIDCounter),
true);
151 if ( verboseLevel > 0 )
154 <<
"are passed from G4EventTransformer." <<
G4endl;
155 G4cout <<
"!!!!!!! Now start processing an event !!!!!!!" <<
G4endl;
160 while( (track=trackContainer->
PopNextTrack(&previousTrajectory)) !=
nullptr )
164 if ( verboseLevel > 1 )
168 <<
") is passed to G4TrackingManager." <<
G4endl;
178 if ( verboseLevel > 0 )
182 <<
") is processed with stopping code " << istop <<
G4endl;
187#ifdef G4_STORE_TRAJECTORY
190 if(previousTrajectory !=
nullptr)
194 aTrajectory = previousTrajectory;
198 if(trajectoryContainer ==
nullptr)
203 trajectoryContainer->
insert(aTrajectory);
213 StackTracks( secondaries );
218 StackTracks( secondaries );
222 StackTracks( secondaries );
228 "Illegal trackstatus returned from G4TrackingManager."\
229 " Continue with simulation.");
234 for(std::size_t i=0; i<secondaries->size(); ++i)
235 {
delete (*secondaries)[i]; }
236 secondaries->clear();
244 if ( verboseLevel > 0 )
246 G4cout <<
"NULL returned from G4StackManager." <<
G4endl;
247 G4cout <<
"Terminate current event processing." <<
G4endl;
251 if(sdManager !=
nullptr)
256#if defined(GEANT4_USE_TIMEMORY)
257 eventProfiler.reset();
266 currentEvent =
nullptr;
267 abortRequested =
false;
273 if( trackVector !=
nullptr )
275 if( trackVector->size() == 0 )
return;
276 for(
auto newTrack : *trackVector )
281 newTrack->SetTrackID( trackIDCounter );
282 if(newTrack->GetDynamicParticle()->GetPrimaryParticle())
286 pp->SetTrackID(trackIDCounter);
289 newTrack->SetOriginTouchableHandle(newTrack->GetTouchableHandle());
292 if ( verboseLevel > 1 )
294 G4cout <<
"A new track " << newTrack
295 <<
" (trackID " << newTrack->GetTrackID()
296 <<
", parentID " << newTrack->GetParentID()
297 <<
") is passed to G4StackManager." <<
G4endl;
301 trackVector->clear();
307 userEventAction = userAction;
308 if(userEventAction !=
nullptr)
316 userStackingAction = userAction;
322 userTrackingAction = userAction;
328 userSteppingAction = userAction;
335 DoProcessing(anEvent);
342 if (randStat ==
nullptr) randStat =
new G4String;
345 if(anEvent ==
nullptr)
350 if (storetRandomNumberStatusToG4Event==1
351 || storetRandomNumberStatusToG4Event==3)
353 std::ostringstream oss;
357 StackTracks(trackVector,
false);
358 DoProcessing(anEvent);
359 if(tempEvent) {
delete anEvent; }
369 "G4VUserEventInformation cannot be set because of absence "\
390 if(currentEvent !=
nullptr) { currentEvent->
KeepTheEvent(); }
395 abortRequested =
true;
396 trackContainer->
clear();
void G4Exception(const char *originOfException, const char *exceptionCode, G4ExceptionSeverity severity, const char *description)
@ fKillTrackAndSecondaries
std::vector< G4Track * > G4TrackVector
G4GLOB_DLL std::ostream G4cout
static std::ostream & saveFullState(std::ostream &os)
void SetUserAction(G4UserEventAction *userAction)
void SetUserInformation(G4VUserEventInformation *anInfo)
void KeepTheCurrentEvent()
G4ProfilerConfig< G4ProfileType::Event > ProfilerConfig
static G4EventManager * GetEventManager()
void ProcessOneEvent(G4Event *anEvent)
G4VUserEventInformation * GetUserInformation()
G4int GetNumberOfPrimaryVertex() const
void SetRandomNumberStatus(G4String &st)
void KeepTheEvent(G4bool vl=true)
G4HCofThisEvent * GetHCofThisEvent() const
void SetRandomNumberStatusForProcessing(G4String &st)
void SetHCofThisEvent(G4HCofThisEvent *value)
void SetUserInformation(G4VUserEventInformation *anInfo)
G4VUserEventInformation * GetUserInformation() const
void SetTrajectoryContainer(G4TrajectoryContainer *value)
virtual G4VPhysicalVolume * LocateGlobalPointAndSetup(const G4ThreeVector &point, const G4ThreeVector *direction=nullptr, const G4bool pRelativeSearch=true, const G4bool ignoreDirection=true)
void TerminateCurrentEvent(G4HCofThisEvent *HCE)
G4HCofThisEvent * PrepareNewEvent()
static G4SDManager * GetSDMpointerIfExist()
G4int GetNTotalTrack() const
G4Track * PopNextTrack(G4VTrajectory **newTrajectory)
G4int PushOneTrack(G4Track *newTrack, G4VTrajectory *newTrajectory=nullptr)
void SetUserStackingAction(G4UserStackingAction *value)
const G4ApplicationState & GetCurrentState() const
static G4StateManager * GetStateManager()
G4bool SetNewState(const G4ApplicationState &requestedState)
G4TrackStatus GetTrackStatus() const
G4int GetParentID() const
void SetUserAction(G4UserTrackingAction *apAction)
G4TrackVector * GimmeSecondaries() const
void ProcessOneTrack(G4Track *apValueG4Track)
G4VTrajectory * GimmeTrajectory() const
G4bool insert(G4VTrajectory *p)
static G4TransportationManager * GetTransportationManager()
G4Navigator * GetNavigatorForTracking() const
virtual void SetEventManager(G4EventManager *value)
virtual void BeginOfEventAction(const G4Event *anEvent)
virtual void EndOfEventAction(const G4Event *anEvent)
virtual void MergeTrajectory(G4VTrajectory *secondTrajectory)=0