Geant4 11.2.2
Toolkit for the simulation of the passage of particles through matter
Loading...
Searching...
No Matches
G4EventManager Class Reference

#include <G4EventManager.hh>

Public Types

using ProfilerConfig = G4ProfilerConfig<G4ProfileType::Event>
 

Public Member Functions

 G4EventManager ()
 
 ~G4EventManager ()
 
 G4EventManager (const G4EventManager &right)=delete
 
G4EventManageroperator= (const G4EventManager &right)=delete
 
void ProcessOneEvent (G4Event *anEvent)
 
void ProcessOneEvent (G4TrackVector *trackVector, G4Event *anEvent=nullptr)
 
void StackTracks (G4TrackVector *trackVector, G4bool IDhasAlreadySet=false)
 
const G4EventGetConstCurrentEvent ()
 
G4EventGetNonconstCurrentEvent ()
 
void AbortCurrentEvent ()
 
void SetUserAction (G4UserEventAction *userAction)
 
void SetUserAction (G4UserStackingAction *userAction)
 
void SetUserAction (G4UserTrackingAction *userAction)
 
void SetUserAction (G4UserSteppingAction *userAction)
 
G4UserEventActionGetUserEventAction ()
 
G4UserStackingActionGetUserStackingAction ()
 
G4UserTrackingActionGetUserTrackingAction ()
 
G4UserSteppingActionGetUserSteppingAction ()
 
void KeepTheCurrentEvent ()
 
G4StackManagerGetStackManager () const
 
G4TrackingManagerGetTrackingManager () const
 
G4int GetVerboseLevel ()
 
void SetVerboseLevel (G4int value)
 
void SetUserInformation (G4VUserEventInformation *anInfo)
 
G4VUserEventInformationGetUserInformation ()
 
G4PrimaryTransformerGetPrimaryTransformer () const
 
void SetPrimaryTransformer (G4PrimaryTransformer *tf)
 
void StoreRandomNumberStatusToG4Event (G4int vl)
 
void UseSubEventParallelism ()
 
G4SubEventPopSubEvent (G4int ty)
 
void TerminateSubEvent (const G4SubEvent *se, const G4Event *evt)
 

Static Public Member Functions

static G4EventManagerGetEventManager ()
 

Detailed Description

Definition at line 56 of file G4EventManager.hh.

Member Typedef Documentation

◆ ProfilerConfig

Constructor & Destructor Documentation

◆ G4EventManager() [1/2]

G4EventManager::G4EventManager ( )

Definition at line 64 of file G4EventManager.cc.

65{
66 if(fpEventManager != nullptr)
67 {
68 G4Exception("G4EventManager::G4EventManager", "Event0001", FatalException,
69 "G4EventManager::G4EventManager() has already been made.");
70 }
71 else
72 {
73 trackManager = new G4TrackingManager;
74 transformer = new G4PrimaryTransformer;
75 trackContainer = new G4StackManager;
76 theMessenger = new G4EvManMessenger(this);
78 stateManager = G4StateManager::GetStateManager();
79 fpEventManager = this;
80 }
81}
@ FatalException
void G4Exception(const char *originOfException, const char *exceptionCode, G4ExceptionSeverity severity, const char *description)
static G4SDManager * GetSDMpointerIfExist()
static G4StateManager * GetStateManager()

◆ ~G4EventManager()

G4EventManager::~G4EventManager ( )

Definition at line 83 of file G4EventManager.cc.

84{
85 delete trackContainer;
86 delete transformer;
87 delete trackManager;
88 delete theMessenger;
89 delete userEventAction;
90 fpEventManager = nullptr;
91}

◆ G4EventManager() [2/2]

G4EventManager::G4EventManager ( const G4EventManager & right)
delete

Member Function Documentation

◆ AbortCurrentEvent()

void G4EventManager::AbortCurrentEvent ( )

Definition at line 506 of file G4EventManager.cc.

507{
508 abortRequested = true;
509 trackContainer->clear();
510 if(tracking) trackManager->EventAborted();
511}

Referenced by G4RunManager::AbortEvent(), G4RunManager::AbortRun(), and G4EvManMessenger::SetNewValue().

◆ GetConstCurrentEvent()

const G4Event * G4EventManager::GetConstCurrentEvent ( )
inline

Definition at line 95 of file G4EventManager.hh.

96 { return currentEvent; }

Referenced by G4VisManager::Draw().

◆ GetEventManager()

◆ GetNonconstCurrentEvent()

G4Event * G4EventManager::GetNonconstCurrentEvent ( )
inline

Definition at line 97 of file G4EventManager.hh.

98 { return currentEvent; }

◆ GetPrimaryTransformer()

G4PrimaryTransformer * G4EventManager::GetPrimaryTransformer ( ) const
inline

Definition at line 150 of file G4EventManager.hh.

151 { return transformer; }

Referenced by G4RunManagerKernel::GetPrimaryTransformer().

◆ GetStackManager()

G4StackManager * G4EventManager::GetStackManager ( ) const
inline

Definition at line 129 of file G4EventManager.hh.

130 { return trackContainer; }

Referenced by G4RunManagerKernel::GetStackManager(), and G4RunManager::SetNumberOfAdditionalWaitingStacks().

◆ GetTrackingManager()

G4TrackingManager * G4EventManager::GetTrackingManager ( ) const
inline

◆ GetUserEventAction()

G4UserEventAction * G4EventManager::GetUserEventAction ( )
inline

Definition at line 113 of file G4EventManager.hh.

114 { return userEventAction; }

Referenced by G4TheRayTracer::StoreUserActions().

◆ GetUserInformation()

G4VUserEventInformation * G4EventManager::GetUserInformation ( )

Definition at line 490 of file G4EventManager.cc.

491{
492 G4ApplicationState currentState = stateManager->GetCurrentState();
493 if(currentState != G4State_EventProc || currentEvent == nullptr)
494 {
495 return nullptr;
496 }
497
498 return currentEvent->GetUserInformation();
499}
G4ApplicationState
@ G4State_EventProc
G4VUserEventInformation * GetUserInformation() const
Definition G4Event.hh:178
const G4ApplicationState & GetCurrentState() const

◆ GetUserStackingAction()

G4UserStackingAction * G4EventManager::GetUserStackingAction ( )
inline

Definition at line 115 of file G4EventManager.hh.

116 { return userStackingAction; }

Referenced by G4TheRayTracer::StoreUserActions().

◆ GetUserSteppingAction()

G4UserSteppingAction * G4EventManager::GetUserSteppingAction ( )
inline

Definition at line 119 of file G4EventManager.hh.

120 { return userSteppingAction; }

Referenced by G4TheRayTracer::StoreUserActions().

◆ GetUserTrackingAction()

G4UserTrackingAction * G4EventManager::GetUserTrackingAction ( )
inline

◆ GetVerboseLevel()

G4int G4EventManager::GetVerboseLevel ( )
inline

Definition at line 134 of file G4EventManager.hh.

135 { return verboseLevel; }

Referenced by G4EvManMessenger::GetCurrentValue().

◆ KeepTheCurrentEvent()

void G4EventManager::KeepTheCurrentEvent ( )

Definition at line 501 of file G4EventManager.cc.

502{
503 if(currentEvent != nullptr) { currentEvent->KeepTheEvent(); }
504}
void KeepTheEvent(G4bool vl=true)
Definition G4Event.hh:105

Referenced by G4EvManMessenger::SetNewValue().

◆ operator=()

G4EventManager & G4EventManager::operator= ( const G4EventManager & right)
delete

◆ PopSubEvent()

G4SubEvent * G4EventManager::PopSubEvent ( G4int ty)

Definition at line 348 of file G4EventManager.cc.

349{
350 G4AutoLock lock(&EventMgrMutex);
351 if(currentEvent==nullptr) return nullptr;
352 return currentEvent->PopSubEvent(ty);
353}
G4SubEvent * PopSubEvent(G4int)
Definition G4Event.cc:173

◆ ProcessOneEvent() [1/2]

void G4EventManager::ProcessOneEvent ( G4Event * anEvent)

Definition at line 444 of file G4EventManager.cc.

445{
446 trackIDCounter = 0;
447 DoProcessing(anEvent);
448}

Referenced by G4TheRayTracer::CreateBitMap(), G4RunManager::ProcessOneEvent(), G4WorkerRunManager::ProcessOneEvent(), and G4WorkerTaskRunManager::ProcessOneEvent().

◆ ProcessOneEvent() [2/2]

void G4EventManager::ProcessOneEvent ( G4TrackVector * trackVector,
G4Event * anEvent = nullptr )

Definition at line 450 of file G4EventManager.cc.

452{
453 static G4ThreadLocal G4String* randStat = nullptr;
454 if (randStat == nullptr) randStat = new G4String;
455 trackIDCounter = 0;
456 G4bool tempEvent = false;
457 if(anEvent == nullptr)
458 {
459 anEvent = new G4Event();
460 tempEvent = true;
461 }
462 if (storetRandomNumberStatusToG4Event==1
463 || storetRandomNumberStatusToG4Event==3)
464 {
465 std::ostringstream oss;
467 (*randStat) = oss.str();
468 anEvent->SetRandomNumberStatus(*randStat);
469 }
470 StackTracks(trackVector,false);
471 DoProcessing(anEvent);
472 if(tempEvent) { delete anEvent; }
473}
bool G4bool
Definition G4Types.hh:86
static std::ostream & saveFullState(std::ostream &os)
Definition Random.cc:288
void StackTracks(G4TrackVector *trackVector, G4bool IDhasAlreadySet=false)
void SetRandomNumberStatus(G4String &st)
Definition G4Event.hh:95
#define G4ThreadLocal
Definition tls.hh:77

◆ SetPrimaryTransformer()

void G4EventManager::SetPrimaryTransformer ( G4PrimaryTransformer * tf)
inline

Definition at line 152 of file G4EventManager.hh.

153 { transformer = tf; }

Referenced by G4RunManagerKernel::SetPrimaryTransformer().

◆ SetUserAction() [1/4]

◆ SetUserAction() [2/4]

void G4EventManager::SetUserAction ( G4UserStackingAction * userAction)

Definition at line 426 of file G4EventManager.cc.

427{
428 userStackingAction = userAction;
429 trackContainer->SetUserStackingAction(userAction);
430}
void SetUserStackingAction(G4UserStackingAction *value)

◆ SetUserAction() [3/4]

void G4EventManager::SetUserAction ( G4UserSteppingAction * userAction)

Definition at line 438 of file G4EventManager.cc.

439{
440 userSteppingAction = userAction;
441 trackManager->SetUserAction(userAction);
442}
void SetUserAction(G4UserTrackingAction *apAction)

◆ SetUserAction() [4/4]

void G4EventManager::SetUserAction ( G4UserTrackingAction * userAction)

Definition at line 432 of file G4EventManager.cc.

433{
434 userTrackingAction = userAction;
435 trackManager->SetUserAction(userAction);
436}

◆ SetUserInformation()

void G4EventManager::SetUserInformation ( G4VUserEventInformation * anInfo)

Definition at line 475 of file G4EventManager.cc.

476{
477 G4ApplicationState currentState = stateManager->GetCurrentState();
478 if(currentState != G4State_EventProc || currentEvent == nullptr)
479 {
480 G4Exception("G4EventManager::SetUserInformation",
481 "Event0003", JustWarning,
482 "G4VUserEventInformation cannot be set because of absence "\
483 "of G4Event.");
484 return;
485 }
486
487 currentEvent->SetUserInformation(anInfo);
488}
@ JustWarning
void SetUserInformation(G4VUserEventInformation *anInfo)
Definition G4Event.hh:176

◆ SetVerboseLevel()

void G4EventManager::SetVerboseLevel ( G4int value)
inline

Definition at line 136 of file G4EventManager.hh.

137 {
138 verboseLevel = value;
139 trackContainer->SetVerboseLevel( value );
140 transformer->SetVerboseLevel( value );
141 }
void SetVerboseLevel(G4int const value)

Referenced by G4EvManMessenger::SetNewValue().

◆ StackTracks()

void G4EventManager::StackTracks ( G4TrackVector * trackVector,
G4bool IDhasAlreadySet = false )

Definition at line 382 of file G4EventManager.cc.

384{
385 if( trackVector != nullptr )
386 {
387 if( trackVector->empty() ) return;
388 for( auto newTrack : *trackVector )
389 {
390 ++trackIDCounter;
391 if(!IDhasAlreadySet)
392 {
393 newTrack->SetTrackID( trackIDCounter );
394 if(newTrack->GetDynamicParticle()->GetPrimaryParticle() != nullptr)
395 {
396 auto* pp
397 = (G4PrimaryParticle*)(newTrack->GetDynamicParticle()->GetPrimaryParticle());
398 pp->SetTrackID(trackIDCounter);
399 }
400 }
401 newTrack->SetOriginTouchableHandle(newTrack->GetTouchableHandle());
402 trackContainer->PushOneTrack( newTrack );
403#ifdef G4VERBOSE
404 if ( verboseLevel > 1 )
405 {
406 G4cout << "A new track " << newTrack
407 << " (trackID " << newTrack->GetTrackID()
408 << ", parentID " << newTrack->GetParentID()
409 << ") is passed to G4StackManager." << G4endl;
410 }
411#endif
412 }
413 trackVector->clear();
414 }
415}
#define G4endl
Definition G4ios.hh:67
G4GLOB_DLL std::ostream G4cout
G4int PushOneTrack(G4Track *newTrack, G4VTrajectory *newTrajectory=nullptr)

Referenced by ProcessOneEvent().

◆ StoreRandomNumberStatusToG4Event()

void G4EventManager::StoreRandomNumberStatusToG4Event ( G4int vl)
inline

Definition at line 154 of file G4EventManager.hh.

155 { storetRandomNumberStatusToG4Event = vl; }

Referenced by G4RunManager::StoreRandomNumberStatusToG4Event().

◆ TerminateSubEvent()

void G4EventManager::TerminateSubEvent ( const G4SubEvent * se,
const G4Event * evt )

Definition at line 355 of file G4EventManager.cc.

356{
357 G4AutoLock lock(&EventMgrMutex);
358 auto ev = se->GetEvent();
359 ev->MergeSubEventResults(evt);
360 userEventAction->MergeSubEvent(ev,evt);
361#ifdef G4VERBOSE
362 // Capture this here because termination will delete subevent...
363 G4int seType = se->GetSubEventType();
364#endif
365 ev->TerminateSubEvent(const_cast<G4SubEvent*>(se));
366#ifdef G4VERBOSE
367 if ( verboseLevel > 1 )
368 {
369 G4cout << "A sub-event of type " << seType
370 << " is merged to the event " << ev->GetEventID() << G4endl;
371 if(ev->GetNumberOfRemainingSubEvents()>0)
372 {
373 G4cout << " ---- This event still has " << ev->GetNumberOfRemainingSubEvents()
374 << " sub-events to be processed." << G4endl;
375 }
376 else
377 { G4cout << " ---- This event has no more sub-event remaining." << G4endl; }
378 }
379#endif
380}
int G4int
Definition G4Types.hh:85
void MergeSubEventResults(const G4Event *se)
Definition G4Event.cc:204
G4int GetSubEventType() const
Definition G4SubEvent.hh:61
G4Event * GetEvent() const
Definition G4SubEvent.hh:69
virtual void MergeSubEvent(G4Event *masterEvent, const G4Event *subEvent)

◆ UseSubEventParallelism()

void G4EventManager::UseSubEventParallelism ( )
inline

Definition at line 157 of file G4EventManager.hh.

158 { subEventPara = true; }

The documentation for this class was generated from the following files: