SLIC  6.1.1
Simulation for the Linear Collider (SLIC) - Geant4 simulation application
MCParticleGenerator.cc
Go to the documentation of this file.
1 #include "MCParticleGenerator.hh"
2 
3 // SLIC
4 #include "MCParticleManager.hh"
5 
6 // LCIO
7 #include "IOIMPL/LCFactory.h"
8 #include "IMPL/MCParticleImpl.h"
9 #include "EVENT/LCEvent.h"
10 #include "EVENT/LCIO.h"
11 
12 // Geant4
13 #include "G4SystemOfUnits.hh"
14 
15 using EVENT::MCParticle;
16 using EVENT::LCCollection;
17 using EVENT::LCEvent;
18 using IMPL::MCParticleImpl;
19 using IOIMPL::LCFactory;
20 
21 namespace slic {
22 
24  _lcevent(0) {
25 
27 
31  LCFactory* factory = LCFactory::getInstance();
32  _reader = factory->createLCReader();
33  _reader->open(eventFile);
34 }
35 
37  _reader->close();
38 }
39 
41  _lcevent = _reader->readNextEvent(EVENT::LCIO::UPDATE);
42 }
43 
45  return _lcevent;
46 }
47 
48 void MCParticleGenerator::generateEvent(G4Event* event) {
49 
50  /* Get collection of MCParticles. */
51  LCCollectionVec* particles = (LCCollectionVec*) _lcevent->takeCollection("MCParticle");
52 
53  /* Generate the Geant4 event using the MCParticleManager. */
54  _particleManager->generateEvent(particles, event);
55 }
56 
57 } /* namespace slic */
static MCParticleManager * instance()
MCParticleGenerator(G4String eventFile)
MCParticleManager * _particleManager
void generateEvent(G4Event *event)
void generateEvent(LCCollectionVec *mcparticles, G4Event *event)