00001 #include "GeneratorObject/HepMcParticleLink.h" 00002 #include "GeneratorObject/McEventCollection.h" 00003 #include "StoreGate/StoreGate.h" 00004 #include "CLHEP/HepMC/GenParticle.h" 00005 #include "CLHEP/HepMC/GenEvent.h" 00006 #include <cassert> 00007 00008 HepMcParticleLink::HepMcParticleLink(const HepMC::GenParticle* part, 00009 index_type eventIndex) : 00010 m_particle(const_cast<HepMC::GenParticle*>(part)), 00011 m_extBarcode((0 != part) ? part->barcode() : 0, eventIndex) { 00012 assert(part); 00013 } 00014 00015 const HepMC::GenParticle* HepMcParticleLink::cptr() const { 00016 if (!m_particle) { 00017 const McEventCollection* pEvtColl; 00018 if ((StoreGate::instance().retrieve(pEvtColl)).isSuccess()) { //FIXME SLOW 00019 m_particle = pEvtColl->at(eventIndex())->barcode_to_particle(barcode()); 00020 } 00021 } 00022 return m_particle; 00023 }