61 std::vector<Particle*>& particles);
85 #include <CLHEP/Units/SystemOfUnits.h>
86 #include <CLHEP/Units/PhysicalConstants.h>
104 virtual ~Geant4EventReaderHepEvtShort() {}
111 virtual ~Geant4EventReaderHepEvtLong() {}
126 m_input.open(nam.c_str(), std::ifstream::in);
127 if ( !m_input.good() ) {
128 except(
"Geant4EventReaderHepEvt",
"+++ Failed to open input stream: %s Error:%s",
129 nam.c_str(), ::strerror(errno));
134 Geant4EventReaderHepEvt::~Geant4EventReaderHepEvt() {
142 printout(INFO,
"EventReaderHepEvt::moveToEvent",
"Skipping the first %d events ", event_number );
143 printout(INFO,
"EventReaderHepEvt::moveToEvent",
"Event number before skipping: %d",
m_currEvent );
145 std::vector<Particle*> particles;
148 for_each(vertices.begin(), vertices.end(), detail::deleteObject<Vertex>);
149 for_each(particles.begin(), particles.end(), detail::deleteObject<Particle>);
155 printout(INFO,
"EventReaderHepEvt::moveToEvent",
"Event number after skipping: %d",
m_currEvent );
163 std::vector<Particle*>& particles) {
187 printout(ERROR,
"EventReaderHepEvt::readParticles",
"Cannot read in too many particles, %d requested but an arbitrary limit has been set to 50 M", NHEP );
209 std::vector<int> daughter1;
210 std::vector<int> daughter2;
212 for(
unsigned IHEP=0; IHEP<NHEP; IHEP++ ) {
214 m_input >> ISTHEP >> IDHEP >> JDAHEP1 >> JDAHEP2
215 >> PHEP1 >> PHEP2 >> PHEP3 >> PHEP5;
218 >> JMOHEP1 >> JMOHEP2
219 >> JDAHEP1 >> JDAHEP2
220 >> PHEP1 >> PHEP2 >> PHEP3
222 >> VHEP1 >> VHEP2 >> VHEP3
241 p->pex = p->psx = PHEP1*CLHEP::GeV;
242 p->pey = p->psy = PHEP2*CLHEP::GeV;
243 p->pez = p->psz = PHEP3*CLHEP::GeV;
246 p->mass = PHEP5*CLHEP::GeV;
249 p->vsx = VHEP1*CLHEP::mm;
250 p->vsy = VHEP2*CLHEP::mm;
251 p->vsz = VHEP3*CLHEP::mm;
258 p->time = VHEP4 * CLHEP::mm / CLHEP::c_light;
259 p->properTime = VHEP4 * CLHEP::mm / CLHEP::c_light;
274 daughter1.emplace_back(JDAHEP1);
275 daughter2.emplace_back(JDAHEP2);
278 particles.emplace_back(p);
288 for(
unsigned IHEP=0; IHEP<NHEP; IHEP++ ) {
289 struct ParticleHandler {
291 ParticleHandler(
Particle* p) : m_part(p) {}
293 m_part->parents.insert(p->id);
295 void addDaughter(
const Particle* p) {
296 if(m_part->daughters.find(p->id) == m_part->daughters.end()) {
297 m_part->daughters.insert(p->id);
301 return m_part->
parents.find(p->id)==m_part->parents.end() ? 0 : m_part;
309 ParticleHandler theParticle(mcp);
314 int fd = daughter1[IHEP] - 1;
315 int ld = daughter2[IHEP] - 1;
320 if( (fd > -1) && (fd <
int(particles.size())) && (ld > -1) && (ld <
int(particles.size())) ) {
322 for(
int id=fd;
id<ld+1;
id++) {
327 ParticleHandler part(particles[
id]);
328 if ( !part.findParent(mcp) ) part.addParent(mcp);
329 theParticle.addDaughter(particles[
id]);
333 ParticleHandler part_fd(particles[fd]);
334 if ( !part_fd.findParent(mcp) ) part_fd.addParent(mcp);
335 theParticle.addDaughter(particles[fd]);
337 ParticleHandler part_ld(particles[ld]);
338 if ( !part_ld.findParent(mcp) ) part_ld.addParent(mcp);
339 theParticle.addDaughter(particles[ld]);
342 else if(fd > -1 && fd <
int(particles.size())) {
343 ParticleHandler part(particles[fd]);
344 if ( !part.findParent(mcp) ) part.addParent(mcp);
346 else if(ld > -1 && ld <
int(particles.size())) {
347 ParticleHandler part(particles[ld]);
348 if ( !part.findParent(mcp) ) part.addParent(mcp);
361 for( std::size_t i=0; i < particles.size(); ++i ) {
363 if ( p->parents.size() == 0 ) {
365 vertices.emplace_back( vtx );
371 vtx->
out.insert(p->id) ;