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

#include <G4EventManager.hh>

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 (G4bool worker=false)
G4SubEventPopSubEvent (G4int ty)
void TerminateSubEvent (const G4SubEvent *se, const G4Event *evt)
G4int StoreSubEvent (G4Event *, G4int &, G4SubEvent *)
G4EventRetrieveCompletedSubEvent ()
G4int GetNumberOfRemainingSubEvents ()

Static Public Member Functions

static G4EventManagerGetEventManager ()

Detailed Description

Definition at line 56 of file G4EventManager.hh.

Constructor & Destructor Documentation

◆ G4EventManager() [1/2]

G4EventManager::G4EventManager ( )

Definition at line 62 of file G4EventManager.cc.

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

Referenced by G4EventManager(), GetEventManager(), and operator=().

◆ ~G4EventManager()

G4EventManager::~G4EventManager ( )

Definition at line 81 of file G4EventManager.cc.

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

◆ G4EventManager() [2/2]

G4EventManager::G4EventManager ( const G4EventManager & right)
delete

Member Function Documentation

◆ AbortCurrentEvent()

void G4EventManager::AbortCurrentEvent ( )

Definition at line 535 of file G4EventManager.cc.

536{
537 abortRequested = true;
538 trackContainer->clear();
539 if(tracking) trackManager->EventAborted();
540}

◆ GetConstCurrentEvent()

const G4Event * G4EventManager::GetConstCurrentEvent ( )
inline

Definition at line 92 of file G4EventManager.hh.

93 { return currentEvent; }

Referenced by G4VisManager::Draw().

◆ GetEventManager()

◆ GetNonconstCurrentEvent()

G4Event * G4EventManager::GetNonconstCurrentEvent ( )
inline

Definition at line 94 of file G4EventManager.hh.

95 { return currentEvent; }

◆ GetNumberOfRemainingSubEvents()

G4int G4EventManager::GetNumberOfRemainingSubEvents ( )
inline

Definition at line 227 of file G4EventManager.hh.

228 { return (G4int)processingEvents.size(); }
int G4int
Definition G4Types.hh:85

◆ GetPrimaryTransformer()

G4PrimaryTransformer * G4EventManager::GetPrimaryTransformer ( ) const
inline

Definition at line 147 of file G4EventManager.hh.

148 { return transformer; }

◆ GetStackManager()

G4StackManager * G4EventManager::GetStackManager ( ) const
inline

Definition at line 126 of file G4EventManager.hh.

127 { return trackContainer; }

◆ GetTrackingManager()

G4TrackingManager * G4EventManager::GetTrackingManager ( ) const
inline

Definition at line 128 of file G4EventManager.hh.

129 { return trackManager; }

Referenced by G4ErrorPropagator::G4ErrorPropagator(), and G4ErrorPropagatorManager::SetSteppingManagerVerboseLevel().

◆ GetUserEventAction()

G4UserEventAction * G4EventManager::GetUserEventAction ( )
inline

Definition at line 110 of file G4EventManager.hh.

111 { return userEventAction; }

◆ GetUserInformation()

G4VUserEventInformation * G4EventManager::GetUserInformation ( )

Definition at line 519 of file G4EventManager.cc.

520{
521 G4ApplicationState currentState = stateManager->GetCurrentState();
522 if(currentState != G4State_EventProc || currentEvent == nullptr)
523 {
524 return nullptr;
525 }
526
527 return currentEvent->GetUserInformation();
528}
G4ApplicationState
@ G4State_EventProc

◆ GetUserStackingAction()

G4UserStackingAction * G4EventManager::GetUserStackingAction ( )
inline

Definition at line 112 of file G4EventManager.hh.

113 { return userStackingAction; }

◆ GetUserSteppingAction()

G4UserSteppingAction * G4EventManager::GetUserSteppingAction ( )
inline

Definition at line 116 of file G4EventManager.hh.

117 { return userSteppingAction; }

◆ GetUserTrackingAction()

G4UserTrackingAction * G4EventManager::GetUserTrackingAction ( )
inline

Definition at line 114 of file G4EventManager.hh.

115 { return userTrackingAction; }

Referenced by G4ErrorPropagator::InvokePostUserTrackingAction(), and G4ErrorPropagator::InvokePreUserTrackingAction().

◆ GetVerboseLevel()

G4int G4EventManager::GetVerboseLevel ( )
inline

Definition at line 131 of file G4EventManager.hh.

132 { return verboseLevel; }

◆ KeepTheCurrentEvent()

void G4EventManager::KeepTheCurrentEvent ( )

Definition at line 530 of file G4EventManager.cc.

531{
532 if(currentEvent != nullptr) { currentEvent->KeepTheEvent(); }
533}

◆ operator=()

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

◆ PopSubEvent()

G4SubEvent * G4EventManager::PopSubEvent ( G4int ty)

Definition at line 360 of file G4EventManager.cc.

361{
362 G4AutoLock lock(&EventMgrMutex);
363 if(currentEvent==nullptr) return nullptr;
364 return currentEvent->PopSubEvent(ty);
365}
G4TemplateAutoLock< G4Mutex > G4AutoLock

◆ ProcessOneEvent() [1/2]

void G4EventManager::ProcessOneEvent ( G4Event * anEvent)

Definition at line 466 of file G4EventManager.cc.

467{
468 trackIDCounter = 0;
469 DoProcessing(anEvent);
470}

◆ ProcessOneEvent() [2/2]

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

Definition at line 472 of file G4EventManager.cc.

474{
475 static G4ThreadLocal G4String* randStat = nullptr;
476 if (randStat == nullptr) randStat = new G4String;
477 G4bool tempEvent = false;
478 G4bool newEvent = false;
479 if(anEvent == nullptr)
480 {
481 anEvent = new G4Event();
482 tempEvent = true;
483 newEvent = true;
484 } else {
485 if(evID_inSubEv != anEvent->GetEventID()) {
486 evID_inSubEv = anEvent->GetEventID();
487 newEvent = true;
488 }
489 }
490 if(newEvent) trackIDCounter = 0;
491
492 if (storetRandomNumberStatusToG4Event==1
493 || storetRandomNumberStatusToG4Event==3)
494 {
495 std::ostringstream oss;
497 (*randStat) = oss.str();
498 anEvent->SetRandomNumberStatus(*randStat);
499 }
500 DoProcessing(anEvent,trackVector,false);
501 if(tempEvent) { delete anEvent; }
502}
bool G4bool
Definition G4Types.hh:86
static std::ostream & saveFullState(std::ostream &os)
Definition Random.cc:288
void SetRandomNumberStatus(G4String &st)
Definition G4Event.hh:91
G4int GetEventID() const
Definition G4Event.hh:126
#define G4ThreadLocal
Definition tls.hh:77

◆ RetrieveCompletedSubEvent()

G4Event * G4EventManager::RetrieveCompletedSubEvent ( )
inline

Definition at line 217 of file G4EventManager.hh.

218 {
219 G4Event* evt = nullptr;
220 if(!completedEvents.empty())
221 {
222 evt = completedEvents.back();
223 completedEvents.pop_back();
224 }
225 return evt;
226 }

◆ SetPrimaryTransformer()

void G4EventManager::SetPrimaryTransformer ( G4PrimaryTransformer * tf)
inline

Definition at line 149 of file G4EventManager.hh.

150 { transformer = tf; }

◆ SetUserAction() [1/4]

void G4EventManager::SetUserAction ( G4UserEventAction * userAction)

Definition at line 439 of file G4EventManager.cc.

440{
441 userEventAction = userAction;
442 if(userEventAction != nullptr)
443 {
444 userEventAction->SetEventManager(this);
445 }
446}

Referenced by G4ErrorPropagatorManager::SetUserAction(), G4ErrorPropagatorManager::SetUserAction(), G4ErrorRunManagerHelper::SetUserAction(), and G4ErrorRunManagerHelper::SetUserAction().

◆ SetUserAction() [2/4]

void G4EventManager::SetUserAction ( G4UserStackingAction * userAction)

Definition at line 448 of file G4EventManager.cc.

449{
450 userStackingAction = userAction;
451 trackContainer->SetUserStackingAction(userAction);
452}

◆ SetUserAction() [3/4]

void G4EventManager::SetUserAction ( G4UserSteppingAction * userAction)

Definition at line 460 of file G4EventManager.cc.

461{
462 userSteppingAction = userAction;
463 trackManager->SetUserAction(userAction);
464}

◆ SetUserAction() [4/4]

void G4EventManager::SetUserAction ( G4UserTrackingAction * userAction)

Definition at line 454 of file G4EventManager.cc.

455{
456 userTrackingAction = userAction;
457 trackManager->SetUserAction(userAction);
458}

◆ SetUserInformation()

void G4EventManager::SetUserInformation ( G4VUserEventInformation * anInfo)

Definition at line 504 of file G4EventManager.cc.

505{
506 G4ApplicationState currentState = stateManager->GetCurrentState();
507 if(currentState != G4State_EventProc || currentEvent == nullptr)
508 {
509 G4Exception("G4EventManager::SetUserInformation",
510 "Event0003", JustWarning,
511 "G4VUserEventInformation cannot be set because of absence "\
512 "of G4Event.");
513 return;
514 }
515
516 currentEvent->SetUserInformation(anInfo);
517}
@ JustWarning

◆ SetVerboseLevel()

void G4EventManager::SetVerboseLevel ( G4int value)
inline

Definition at line 133 of file G4EventManager.hh.

134 {
135 verboseLevel = value;
136 trackContainer->SetVerboseLevel( value );
137 transformer->SetVerboseLevel( value );
138 }

◆ StackTracks()

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

Definition at line 404 of file G4EventManager.cc.

406{
407 if( trackVector != nullptr )
408 {
409 if( trackVector->empty() ) return;
410 for( auto newTrack : *trackVector )
411 {
412 ++trackIDCounter;
413 if(!IDhasAlreadySet)
414 {
415 newTrack->SetTrackID( trackIDCounter );
416 if(newTrack->GetDynamicParticle()->GetPrimaryParticle() != nullptr)
417 {
418 auto* pp
419 = (G4PrimaryParticle*)(newTrack->GetDynamicParticle()->GetPrimaryParticle());
420 pp->SetTrackID(trackIDCounter);
421 }
422 }
423 newTrack->SetOriginTouchableHandle(newTrack->GetTouchableHandle());
424 trackContainer->PushOneTrack( newTrack );
425#ifdef G4VERBOSE
426 if ( verboseLevel > 1 )
427 {
428 G4cout << "A new track " << newTrack
429 << " (trackID " << newTrack->GetTrackID()
430 << ", parentID " << newTrack->GetParentID()
431 << ") is passed to G4StackManager." << G4endl;
432 }
433#endif
434 }
435 trackVector->clear();
436 }
437}
#define G4endl
Definition G4ios.hh:67
G4GLOB_DLL std::ostream G4cout

◆ StoreRandomNumberStatusToG4Event()

void G4EventManager::StoreRandomNumberStatusToG4Event ( G4int vl)
inline

Definition at line 151 of file G4EventManager.hh.

152 { storetRandomNumberStatusToG4Event = vl; }

◆ StoreSubEvent()

G4int G4EventManager::StoreSubEvent ( G4Event * evt,
G4int & subEvtType,
G4SubEvent * se )

Definition at line 394 of file G4EventManager.cc.

395{
396 G4AutoLock lock(&EventMgrMutex);
397 if(evt != currentEvent) {
398 G4Exception("G4EventManager::StoreSubEvent","SubEvt1011", FatalException,
399 "StoreSubEvent is invoked with a G4Event that is not the current event. PANIC!");
400 }
401 return evt->StoreSubEvent(subEvtType,se);
402}
G4int StoreSubEvent(G4int, G4SubEvent *)
Definition G4Event.cc:174

Referenced by G4SubEventTrackStack::PushToStack(), and G4SubEventTrackStack::ReleaseSubEvent().

◆ TerminateSubEvent()

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

Definition at line 367 of file G4EventManager.cc.

368{
369 G4AutoLock lock(&EventMgrMutex);
370 auto ev = se->GetEvent();
371 ev->MergeSubEventResults(evt);
372 if(!subEventParaWorker && userEventAction!=nullptr) userEventAction->MergeSubEvent(ev,evt);
373#ifdef G4VERBOSE
374 // Capture this here because termination will delete subevent...
375 G4int seType = se->GetSubEventType();
376#endif
377 ev->TerminateSubEvent(const_cast<G4SubEvent*>(se));
378#ifdef G4VERBOSE
379 if ( verboseLevel > 1 )
380 {
381 G4cout << "A sub-event of type " << seType
382 << " is merged to the event " << ev->GetEventID() << G4endl;
383 if(ev->GetNumberOfRemainingSubEvents()>0)
384 {
385 G4cout << " ---- This event still has " << ev->GetNumberOfRemainingSubEvents()
386 << " sub-events to be processed." << G4endl;
387 }
388 else
389 { G4cout << " ---- This event has no more sub-event remaining." << G4endl; }
390 }
391#endif
392}
void MergeSubEventResults(const G4Event *se)
Definition G4Event.cc:225
G4int GetSubEventType() const
Definition G4SubEvent.hh:68
G4Event * GetEvent() const
Definition G4SubEvent.hh:76

◆ UseSubEventParallelism()

void G4EventManager::UseSubEventParallelism ( G4bool worker = false)
inline

Definition at line 154 of file G4EventManager.hh.

155 {
156 subEventPara = true;
157 subEventParaWorker = worker;
158 }

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