22 #include <G4ParticleTable.hh>
23 #include <EVENT/MCParticle.h>
24 #include <EVENT/LCCollection.h>
39 inline int GET_ENTRY(
const map<EVENT::MCParticle*,int>& mcparts, EVENT::MCParticle* part) {
40 map<EVENT::MCParticle*,int>::const_iterator ip=mcparts.find(part);
41 if ( ip == mcparts.end() ) {
42 throw runtime_error(
"Unknown particle identifier look-up!");
50 LCIOEventReader::LCIOEventReader(
const string& nam)
64 vector<Particle*>& particles)
66 EVENT::LCCollection* primaries = 0;
67 map<EVENT::MCParticle*,int> mcparts;
68 vector<EVENT::MCParticle*> mcpcoll;
73 int NHEP = primaries->getNumberOfElements();
77 mcpcoll.resize(NHEP,0);
78 for(
int i=0; i<NHEP; ++i ) {
79 EVENT::MCParticle* p =
dynamic_cast<EVENT::MCParticle*
>(primaries->getElementAt(i));
85 for(
int i=0; i<NHEP; ++i ) {
86 EVENT::MCParticle* mcp = mcpcoll[i];
88 const double *mom = mcp->getMomentum();
89 const double *vsx = mcp->getVertex();
90 const double *vex = mcp->getEndpoint();
91 const float *spin = mcp->getSpin();
92 const int *color = mcp->getColorFlow();
93 const int pdg = mcp->getPDG();
95 p->
charge = int(mcp->getCharge()*3.0);
96 p->
psx = mom[0]*CLHEP::GeV;
97 p->
psy = mom[1]*CLHEP::GeV;
98 p->
psz = mom[2]*CLHEP::GeV;
99 p->
time = mcp->getTime()*CLHEP::ns;
101 p->
vsx = vsx[0]*CLHEP::mm;
102 p->
vsy = vsx[1]*CLHEP::mm;
103 p->
vsz = vsx[2]*CLHEP::mm;
104 p->
vex = vex[0]*CLHEP::mm;
105 p->
vey = vex[1]*CLHEP::mm;
106 p->
vez = vex[2]*CLHEP::mm;
108 p->
spin[0] = spin[0];
109 p->
spin[1] = spin[1];
110 p->
spin[2] = spin[2];
113 p->
mass = mcp->getMass()*CLHEP::GeV;
114 const EVENT::MCParticleVec &par = mcp->getParents(), &dau=mcp->getDaughters();
115 for(
int num=dau.size(),k=0; k<num; ++k)
116 p->
daughters.insert(GET_ENTRY(mcparts,dau[k]));
117 for(
int num=par.size(),k=0; k<num; ++k)
118 p->
parents.insert(GET_ENTRY(mcparts,par[k]));
121 int genStatus = mcp->getGeneratorStatus();
134 if ( p->
parents.size() == 0 ) {
137 vertices.emplace_back( vtx );
143 vtx->
out.insert(p->
id) ;
154 particles.emplace_back(p);