hepmc - Diff between revs 240 and 442
Subversion Repositories:
| Rev 240 | Rev 442 | |||
|---|---|---|---|---|
| Line 35... | Line 35... | |||
| 35 | 35 | |||
| 36 | TempMapIterator begin() { return m_particle_to_end_vertex.begin(); } | 36 | TempMapIterator begin() { return m_particle_to_end_vertex.begin(); } | |
| 37 | TempMapIterator end() { return m_particle_to_end_vertex.end(); } | 37 | TempMapIterator end() { return m_particle_to_end_vertex.end(); } | |
| 38 | orderIterator order_begin() { return m_particle_order.begin(); } | 38 | orderIterator order_begin() { return m_particle_order.begin(); } | |
| 39 | orderIterator order_end() { return m_particle_order.end(); } | 39 | orderIterator order_end() { return m_particle_order.end(); } | |
| - | 40 | bool empty() const; | ||
| 40 | 41 | |||
| 41 | int end_vertex( GenParticle* ); | 42 | int end_vertex( GenParticle* ); | |
| 42 | 43 | |||
| 43 | void addEndParticle( GenParticle*, int& ); | 44 | void addEndParticle( GenParticle*, int& ); | |
| - | 45 | |||
| - | 46 | void clear_temp_map(); | ||
| 44 | 47 | |||
| 45 | private: | 48 | private: | |
| 46 | TempMap m_particle_to_end_vertex; | 49 | TempMap m_particle_to_end_vertex; | |
| 47 | TempOrderMap m_particle_order; | 50 | TempOrderMap m_particle_order; | |
| 48 | }; | 51 | }; | |
| Line 58... | Line 61... | |||
| 58 | inline void TempParticleMap::addEndParticle( GenParticle* p, int& end_vtx_code ) | 61 | inline void TempParticleMap::addEndParticle( GenParticle* p, int& end_vtx_code ) | |
| 59 | { | 62 | { | |
| 60 | m_particle_order[p->barcode()] = p; | 63 | m_particle_order[p->barcode()] = p; | |
| 61 | m_particle_to_end_vertex[p] = end_vtx_code; | 64 | m_particle_to_end_vertex[p] = end_vtx_code; | |
| 62 | } | 65 | } | |
| - | 66 | |||
| - | 67 | inline bool TempParticleMap::empty() const { | ||
| - | 68 | return (bool)m_particle_to_end_vertex.empty(); | ||
| - | 69 | } | ||
| - | 70 | |||
| - | 71 | inline void TempParticleMap::clear_temp_map() { | ||
| - | 72 | // this method is used if corrupt data is encountered when reading an event | ||
| - | 73 | // have to be careful, can't just call clear() on the map | ||
| - | 74 | while( !empty() ) { | ||
| - | 75 | GenParticle* p = m_particle_order.begin()->second; | ||
| - | 76 | // empty the maps | ||
| - | 77 | m_particle_order.erase( m_particle_order.begin() ); | ||
| - | 78 | m_particle_to_end_vertex.erase( p ); | ||
| - | 79 | // delete particles only if they are not already owned by the event | ||
| - | 80 | if( p->production_vertex() ) { | ||
| - | 81 | } else if( p->parent_event() ) { | ||
| - | 82 | } else { | ||
| - | 83 | delete p; | ||
| - | 84 | } | ||
| - | 85 | } | ||
| - | 86 | } | ||
| - | 87 | |||
| 63 | 88 | |||
| 64 | } // HepMC | 89 | } // HepMC | |
| 65 | 90 | |||
| 66 | #endif // HEPMC_TempParticleMap_H | 91 | #endif // HEPMC_TempParticleMap_H | |
| 67 | //-------------------------------------------------------------------------- | 92 | //-------------------------------------------------------------------------- | |
