SLIC  6.1.1
Simulation for the Linear Collider (SLIC) - Geant4 simulation application
PrimaryGeneratorAction.cc
Go to the documentation of this file.
1 // SLIC
2 #include "EventSourceManager.hh"
3 #include "LcioManager.hh"
4 #include "MCParticleManager.hh"
6 #include "TrackManager.hh"
7 #include "RunManager.hh"
8 #include "SlicApplication.hh"
9 
10 // LCDD
11 #include "lcdd/util/StringUtil.hh"
12 
13 // LCIO
14 #include "IMPL/MCParticleImpl.h"
15 #include "EVENT/LCCollection.h"
16 
17 namespace slic {
18 
20  Module("PrimaryGeneratorAction", false) {
22 }
23 
25 }
26 
28 
29  /* Print begin of event message. */
30  //printBeginEventMessage(anEvent);
31 
32  /* Reset the TrackManager's state from previous event. */
33  TrackManager::instance()->reset();
34 
35  /* Reset the MCParticleManager's state from previous event. */
36  MCParticleManager::instance()->reset();
37 
38  /* Check if run needs to be aborted before generating events. */
39  if (RunManager::instance()->isRunAborted()) {
40  G4RunManager::GetRunManager()->AbortRun();
41  log() << LOG::warning << LOG::name << LOG::sep << "Run was aborted. Events will not be generated." << LOG::done;
42  } else {
43  /* Begin event hook of EventSourceManager which will read the next input event if applicable. */
44  _manager->beginEvent(anEvent);
45 
46  /* Generate primary vertices using the event generator's (previously read) current event. */
47  _manager->generateNextEvent(anEvent);
48  }
49 
50  /* If the event source hit the end of file, then abort the run. */
51  if (_manager->isEOF()) {
52  SlicApplication::instance()->setAborting(true);
53  }
54 
56 }
57 
58 /*void PrimaryGeneratorAction::printBeginEventMessage(G4Event* anEvent) {
59  log() << LOG::okay << ">>>> BeginEvent <" << StringUtil::toString(anEvent->GetEventID()) << ">" << LOG::done;
60 }*/
61 }
static EventSourceManager * instance()
void generateNextEvent(G4Event *evt)
void beginEvent(const G4Event *event)
Base class for slic code modules that provides common functionality, such as logging to an output str...
Definition: Module.hh:25
LogStream & log()
Definition: Module.hh:99
void generatePrimary(G4Event *anEvent)
virtual void GeneratePrimaries(G4Event *anEvent)
static RunManager * instance()
Definition: RunManager.hh:38
@ warning
Definition: LogStream.hh:33
@ name
Definition: LogStream.hh:26
@ done
Definition: LogStream.hh:26
@ sep
Definition: LogStream.hh:26