diff --git a/Generators/GeneratorObjectsTPCnv/GeneratorObjectsTPCnv/McEventCollectionCnv_p2.h b/Generators/GeneratorObjectsTPCnv/GeneratorObjectsTPCnv/McEventCollectionCnv_p2.h index a3a6fe90bba2870e8665c50da969861460eb09ee..084c72730ba61d01cc485f19b275bd1c5e61ffaa 100755 --- a/Generators/GeneratorObjectsTPCnv/GeneratorObjectsTPCnv/McEventCollectionCnv_p2.h +++ b/Generators/GeneratorObjectsTPCnv/GeneratorObjectsTPCnv/McEventCollectionCnv_p2.h @@ -109,7 +109,7 @@ class McEventCollectionCnv_p2 : public T_AthenaPoolTPCnvBase< createGenVertex( const McEventCollection_p2& persEvts, const GenVertex_p2& vtx, ParticlesMap_t& bcToPart, - HepMC::DataPool& datapools ) const; + HepMC::DataPool& datapools,HepMC::GenEvent* parent=nullptr ) const; /** @brief Create a transient @c GenParticle from a persistent one (vers.1) * It returns the new @c GenParticle. Note that the map being passed as an @@ -119,7 +119,7 @@ class McEventCollectionCnv_p2 : public T_AthenaPoolTPCnvBase< HepMC::GenParticlePtr createGenParticle( const GenParticle_p2& p, ParticlesMap_t& partToEndVtx, - HepMC::DataPool& datapools ) const; + HepMC::DataPool& datapools,HepMC::GenVertexPtr parent=nullptr ) const; }; #endif //> GENERATOROBJECTSTPCNV_MCEVENTCOLLECTIONCNV_P2_H diff --git a/Generators/GeneratorObjectsTPCnv/GeneratorObjectsTPCnv/McEventCollectionCnv_p3.h b/Generators/GeneratorObjectsTPCnv/GeneratorObjectsTPCnv/McEventCollectionCnv_p3.h index 2e1556cb3f0c887ac97dcbd5cada6a5f25d3b7f6..78f89d6c687e0c410c17e448a0fcd08c2549ec77 100755 --- a/Generators/GeneratorObjectsTPCnv/GeneratorObjectsTPCnv/McEventCollectionCnv_p3.h +++ b/Generators/GeneratorObjectsTPCnv/GeneratorObjectsTPCnv/McEventCollectionCnv_p3.h @@ -108,7 +108,7 @@ class McEventCollectionCnv_p3 : public T_AthenaPoolTPCnvBase< createGenVertex( const McEventCollection_p3& persEvts, const GenVertex_p3& vtx, ParticlesMap_t& bcToPart, - HepMC::DataPool& datapools ) const; + HepMC::DataPool& datapools, HepMC::GenEvent* parent=nullptr ) const; /** @brief Create a transient @c GenParticle from a persistent one (vers.1) * It returns the new @c GenParticle. Note that the map being passed as an @@ -118,7 +118,7 @@ class McEventCollectionCnv_p3 : public T_AthenaPoolTPCnvBase< HepMC::GenParticlePtr createGenParticle( const GenParticle_p3& p, ParticlesMap_t& partToEndVtx, - HepMC::DataPool& datapools ) const; + HepMC::DataPool& datapools, HepMC::GenVertexPtr parent=nullptr ) const; }; #endif //> GENERATOROBJECTSTPCNV_MCEVENTCOLLECTIONCNV_P3_H diff --git a/Generators/GeneratorObjectsTPCnv/GeneratorObjectsTPCnv/McEventCollectionCnv_p4.h b/Generators/GeneratorObjectsTPCnv/GeneratorObjectsTPCnv/McEventCollectionCnv_p4.h index 35f2343664cf1e2c1adf31ee6a4d2024e7acc6cb..4828f682825d5fc150045e0aa801ec1326cc771b 100755 --- a/Generators/GeneratorObjectsTPCnv/GeneratorObjectsTPCnv/McEventCollectionCnv_p4.h +++ b/Generators/GeneratorObjectsTPCnv/GeneratorObjectsTPCnv/McEventCollectionCnv_p4.h @@ -113,7 +113,7 @@ class McEventCollectionCnv_p4 : public T_AthenaPoolTPCnvBase< createGenVertex( const McEventCollection_p4& persEvts, const GenVertex_p4& vtx, ParticlesMap_t& bcToPart, - HepMC::DataPool& datapools ) const; + HepMC::DataPool& datapools,HepMC::GenEvent* parent=nullptr ) const; /** @brief Create a transient @c GenParticle from a persistent one (vers.1) * It returns the new @c GenParticle. Note that the map being passed as an @@ -123,7 +123,7 @@ class McEventCollectionCnv_p4 : public T_AthenaPoolTPCnvBase< HepMC::GenParticlePtr createGenParticle( const GenParticle_p4& p, ParticlesMap_t& partToEndVtx, - HepMC::DataPool& datapools ) const; + HepMC::DataPool& datapools,HepMC::GenVertexPtr parent=nullptr ) const; /** @brief Method to write a persistent @c GenVertex object. The persistent * vertex is added to the persistent is added to the persistent diff --git a/Generators/GeneratorObjectsTPCnv/GeneratorObjectsTPCnv/McEventCollectionCnv_p5.h b/Generators/GeneratorObjectsTPCnv/GeneratorObjectsTPCnv/McEventCollectionCnv_p5.h index 79e176ff4f41816ae81bd95a2aa9fb5145bf39af..dfae1c8c7ab4b194917e125ac556f9f67ca1a901 100755 --- a/Generators/GeneratorObjectsTPCnv/GeneratorObjectsTPCnv/McEventCollectionCnv_p5.h +++ b/Generators/GeneratorObjectsTPCnv/GeneratorObjectsTPCnv/McEventCollectionCnv_p5.h @@ -114,7 +114,7 @@ class McEventCollectionCnv_p5 : public T_AthenaPoolTPCnvBase< createGenVertex( const McEventCollection_p5& persEvts, const GenVertex_p5& vtx, ParticlesMap_t& bcToPart, - HepMC::DataPool& datapools ) const; + HepMC::DataPool& datapools, HepMC::GenEvent* parent=nullptr ) const; /** @brief Create a transient @c GenParticle from a persistent one (vers.1) * It returns the new @c GenParticle. Note that the map being passed as an @@ -124,7 +124,7 @@ class McEventCollectionCnv_p5 : public T_AthenaPoolTPCnvBase< HepMC::GenParticlePtr createGenParticle( const GenParticle_p5& p, ParticlesMap_t& partToEndVtx, - HepMC::DataPool& datapools ) const; + HepMC::DataPool& datapools, HepMC::GenVertexPtr parent=nullptr ) const; /** @brief Method to write a persistent @c GenVertex object. The persistent * vertex is added to the persistent is added to the persistent diff --git a/Generators/GeneratorObjectsTPCnv/src/McEventCollectionCnv_p2.cxx b/Generators/GeneratorObjectsTPCnv/src/McEventCollectionCnv_p2.cxx index 27ec95ae96cc804c582c70453b3b970730d418aa..1918f155e1c82af4987bf52a5ccb64d99f9cbb48 100755 --- a/Generators/GeneratorObjectsTPCnv/src/McEventCollectionCnv_p2.cxx +++ b/Generators/GeneratorObjectsTPCnv/src/McEventCollectionCnv_p2.cxx @@ -89,10 +89,6 @@ void McEventCollectionCnv_p2::persToTrans( const McEventCollection_p2* persObj, transObj->push_back( genEvt ); - // create a temporary map associating the barcode of an end-vtx to its - // particle. - // As not all particles are stable (d'oh!) we take 50% of the number of - // particles as an initial size of the hash-map (to prevent re-hash) ParticlesMap_t partToEndVtx( (persEvt.m_particlesEnd-persEvt.m_particlesBegin)/2 ); // create the vertices @@ -198,30 +194,26 @@ void McEventCollectionCnv_p2::transToPers( const McEventCollection*, HepMC::GenVertexPtr McEventCollectionCnv_p2::createGenVertex( const McEventCollection_p2& persEvt, const GenVertex_p2& persVtx, - ParticlesMap_t& partToEndVtx, HepMC::DataPool& datapools ) const + ParticlesMap_t& partToEndVtx, HepMC::DataPool& datapools, HepMC::GenEvent* parent ) const { HepMC::GenVertexPtr vtx = datapools.getGenVertex(); + if (parent) parent->add_vertex(vtx); #ifdef HEPMC3 vtx->set_position( HepMC::FourVector(persVtx.m_x,persVtx.m_y, persVtx.m_z, persVtx.m_t) ); - //AV ID cannot be assigned in HepMC3. And its meaning in HepMC2 is not clear. - // vtx->m_id = persVtx.m_id; + vtx->set_status(persVtx.m_id); vtx->add_attribute("weights",std::make_shared<HepMC3::VectorFloatAttribute>(persVtx.m_weights)); vtx->add_attribute("barcode",std::make_shared<HepMC3::IntAttribute>(persVtx.m_barcode)); // handle the in-going (orphans) particles const unsigned int nPartsIn = persVtx.m_particlesIn.size(); for ( unsigned int i = 0; i != nPartsIn; ++i ) { - createGenParticle( persEvt.m_genParticles[persVtx.m_particlesIn[i]], - partToEndVtx, - datapools ); + createGenParticle( persEvt.m_genParticles[persVtx.m_particlesIn[i]], partToEndVtx, datapools ); } // now handle the out-going particles const unsigned int nPartsOut = persVtx.m_particlesOut.size(); for ( unsigned int i = 0; i != nPartsOut; ++i ) { - vtx->add_particle_out( createGenParticle( persEvt.m_genParticles[persVtx.m_particlesOut[i]], - partToEndVtx, - datapools ) ); + createGenParticle( persEvt.m_genParticles[persVtx.m_particlesOut[i]], partToEndVtx, datapools, vtx ); } #else vtx->m_position.setX( persVtx.m_x ); @@ -259,10 +251,11 @@ McEventCollectionCnv_p2::createGenVertex( const McEventCollection_p2& persEvt, HepMC::GenParticlePtr McEventCollectionCnv_p2::createGenParticle( const GenParticle_p2& persPart, - ParticlesMap_t& partToEndVtx, HepMC::DataPool& datapools ) const + ParticlesMap_t& partToEndVtx, HepMC::DataPool& datapools, HepMC::GenVertexPtr parent ) const { HepMC::GenParticlePtr p = datapools.getGenParticle(); + if (parent) parent->add_particle_out(p); #ifdef HEPMC3 p->set_momentum( HepMC::FourVector(persPart.m_px,persPart.m_py,persPart.m_pz, persPart.m_ene )); p->set_pdg_id( persPart.m_pdgId); diff --git a/Generators/GeneratorObjectsTPCnv/src/McEventCollectionCnv_p3.cxx b/Generators/GeneratorObjectsTPCnv/src/McEventCollectionCnv_p3.cxx index f88dc00c190f13d0f65a34ff1a72ebe2ba108b23..db3e6b74e11ea73718f459c38031697143ee470f 100755 --- a/Generators/GeneratorObjectsTPCnv/src/McEventCollectionCnv_p3.cxx +++ b/Generators/GeneratorObjectsTPCnv/src/McEventCollectionCnv_p3.cxx @@ -90,7 +90,15 @@ void McEventCollectionCnv_p3::persToTrans( const McEventCollection_p3* persObj, genEvt->add_attribute("alphaQED",std::make_shared<HepMC3::DoubleAttribute>(persEvt.m_alphaQED)); genEvt->weights()= persEvt.m_weights; genEvt->add_attribute("random_states",std::make_shared<HepMC3::VectorLongIntAttribute>(persEvt.m_randomStates)); + transObj->push_back( genEvt ); + + ParticlesMap_t partToEndVtx( (persEvt.m_particlesEnd- persEvt.m_particlesBegin)/2 ); + // create the vertices + const unsigned int endVtx = persEvt.m_verticesEnd; + for ( unsigned int iVtx= persEvt.m_verticesBegin; iVtx != endVtx; ++iVtx ) { + createGenVertex( *persObj, persObj->m_genVertices[iVtx],partToEndVtx, datapools, genEvt ); + } #else genEvt->m_signal_process_id = persEvt.m_signalProcessId; genEvt->m_event_number = persEvt.m_eventNbr; @@ -103,7 +111,6 @@ void McEventCollectionCnv_p3::persToTrans( const McEventCollection_p3* persObj, genEvt->m_vertex_barcodes.clear(); genEvt->m_particle_barcodes.clear(); genEvt->m_pdf_info = 0; //> not available at that time... -#endif transObj->push_back( genEvt ); @@ -122,6 +129,7 @@ void McEventCollectionCnv_p3::persToTrans( const McEventCollection_p3* persObj, partToEndVtx, datapools ) ); } //> end loop over vertices +#endif // set the signal process vertex const int sigProcVtx = persEvt.m_signalProcessVtx; @@ -171,16 +179,27 @@ HepMC::GenVertexPtr McEventCollectionCnv_p3::createGenVertex( const McEventCollection_p3& persEvt, const GenVertex_p3& persVtx, ParticlesMap_t& partToEndVtx, - HepMC::DataPool& datapools ) const + HepMC::DataPool& datapools, HepMC::GenEvent* parent ) const { HepMC::GenVertexPtr vtx = datapools.getGenVertex(); + if (parent) parent->add_vertex(vtx); #ifdef HEPMC3 vtx->set_position( HepMC::FourVector(persVtx.m_x,persVtx.m_y,persVtx.m_z,persVtx.m_t) ); - //AV ID cannot be assigned in HepMC3. And its meaning in HepMC2 is not clear. - // vtx->m_id = persVtx.m_id; + vtx->set_status(persVtx.m_id); vtx->add_attribute("weights",std::make_shared<HepMC3::VectorFloatAttribute>(persVtx.m_weights)); vtx->add_attribute("barcode",std::make_shared<HepMC3::IntAttribute>(persVtx.m_barcode)); + // handle the in-going (orphans) particles + //Is this needed for HEPMC3? + const unsigned int nPartsIn = persVtx.m_particlesIn.size(); + for ( unsigned int i = 0; i != nPartsIn; ++i ) { + createGenParticle( persEvt.m_genParticles[persVtx.m_particlesIn[i]], partToEndVtx, datapools ); + } + // now handle the out-going particles + const unsigned int nPartsOut = persVtx.m_particlesOut.size(); + for ( unsigned int i = 0; i != nPartsOut; ++i ) { + createGenParticle( persEvt.m_genParticles[persVtx.m_particlesOut[i]], partToEndVtx, datapools, vtx ); + } #else vtx->m_position.setX( persVtx.m_x ); vtx->m_position.setY( persVtx.m_y ); @@ -194,7 +213,6 @@ McEventCollectionCnv_p3::createGenVertex( const McEventCollection_p3& persEvt, persVtx.m_weights.end() ); vtx->m_event = 0; vtx->m_barcode = persVtx.m_barcode; -#endif // handle the in-going (orphans) particles const unsigned int nPartsIn = persVtx.m_particlesIn.size(); @@ -211,6 +229,7 @@ McEventCollectionCnv_p3::createGenVertex( const McEventCollection_p3& persEvt, partToEndVtx, datapools ) ); } +#endif return vtx; } @@ -218,9 +237,10 @@ McEventCollectionCnv_p3::createGenVertex( const McEventCollection_p3& persEvt, HepMC::GenParticlePtr McEventCollectionCnv_p3::createGenParticle( const GenParticle_p3& persPart, ParticlesMap_t& partToEndVtx, - HepMC::DataPool& datapools ) const + HepMC::DataPool& datapools, HepMC::GenVertexPtr parent ) const { HepMC::GenParticlePtr p = datapools.getGenParticle(); + if (parent) parent->add_particle_out(p); #ifdef HEPMC3 p->set_pdg_id(persPart.m_pdgId); diff --git a/Generators/GeneratorObjectsTPCnv/src/McEventCollectionCnv_p4.cxx b/Generators/GeneratorObjectsTPCnv/src/McEventCollectionCnv_p4.cxx index 7a244e80585d156022d276e833d2ba63f381cf72..10fabe6d8a8cd2a299fb7822777fe009d1d3eae6 100755 --- a/Generators/GeneratorObjectsTPCnv/src/McEventCollectionCnv_p4.cxx +++ b/Generators/GeneratorObjectsTPCnv/src/McEventCollectionCnv_p4.cxx @@ -347,7 +347,7 @@ HepMC::GenVertexPtr McEventCollectionCnv_p4::createGenVertex( const McEventCollection_p4& persEvt, const GenVertex_p4& persVtx, ParticlesMap_t& partToEndVtx, - HepMC::DataPool& datapools ) const + HepMC::DataPool& datapools, HepMC::GenEvent* parent ) const { HepMC::GenVertexPtr vtx(0); if(m_isPileup) @@ -358,13 +358,27 @@ McEventCollectionCnv_p4::createGenVertex( const McEventCollection_p4& persEvt, { vtx = datapools.getGenVertex(); } + if (parent) parent->add_vertex(vtx); #ifdef HEPMC3 vtx->set_position(HepMC::FourVector( persVtx.m_x , persVtx.m_y , persVtx.m_z ,persVtx.m_t )); - //AV ID cannot be assigned in HepMC3. And its meaning in HepMC2 is not clear. - // vtx->m_id = persVtx.m_id; + vtx->set_status(persVtx.m_id); vtx->add_attribute("weights",std::make_shared<HepMC3::VectorFloatAttribute>(persVtx.m_weights)); vtx->add_attribute("barcode",std::make_shared<HepMC3::IntAttribute>(persVtx.m_barcode)); + // handle the in-going (orphans) particles + //Is this needed in HepMC3? + const unsigned int nPartsIn = persVtx.m_particlesIn.size(); + for ( unsigned int i = 0; i != nPartsIn; ++i ) + { + createGenParticle( persEvt.m_genParticles[persVtx.m_particlesIn[i]], partToEndVtx, datapools ); + } + + // now handle the out-going particles + const unsigned int nPartsOut = persVtx.m_particlesOut.size(); + for ( unsigned int i = 0; i != nPartsOut; ++i ) + { + createGenParticle( persEvt.m_genParticles[persVtx.m_particlesOut[i]], partToEndVtx, datapools, vtx ); + } #else vtx->m_position.setX( persVtx.m_x ); vtx->m_position.setY( persVtx.m_y ); @@ -378,7 +392,6 @@ McEventCollectionCnv_p4::createGenVertex( const McEventCollection_p4& persEvt, persVtx.m_weights.end() ); vtx->m_event = 0; vtx->m_barcode = persVtx.m_barcode; -#endif // handle the in-going (orphans) particles const unsigned int nPartsIn = persVtx.m_particlesIn.size(); @@ -397,6 +410,7 @@ McEventCollectionCnv_p4::createGenVertex( const McEventCollection_p4& persEvt, partToEndVtx, datapools ) ); } +#endif return vtx; } @@ -404,7 +418,7 @@ McEventCollectionCnv_p4::createGenVertex( const McEventCollection_p4& persEvt, HepMC::GenParticlePtr McEventCollectionCnv_p4::createGenParticle( const GenParticle_p4& persPart, ParticlesMap_t& partToEndVtx, - HepMC::DataPool& datapools ) const + HepMC::DataPool& datapools, HepMC::GenVertexPtr parent ) const { HepMC::GenParticlePtr p(0); if (m_isPileup) @@ -415,6 +429,7 @@ McEventCollectionCnv_p4::createGenParticle( const GenParticle_p4& persPart, { p = datapools.getGenParticle(); } + if (parent) parent->add_particle_out(p); #ifdef HEPMC3 p->set_pdg_id( persPart.m_pdgId); p->set_status( persPart.m_status); diff --git a/Generators/GeneratorObjectsTPCnv/src/McEventCollectionCnv_p5.cxx b/Generators/GeneratorObjectsTPCnv/src/McEventCollectionCnv_p5.cxx index 8190ac045d17aac5e55688f4983aafd5378302d5..06b5ba58330b519f946969a58c7b13dfd033b86d 100755 --- a/Generators/GeneratorObjectsTPCnv/src/McEventCollectionCnv_p5.cxx +++ b/Generators/GeneratorObjectsTPCnv/src/McEventCollectionCnv_p5.cxx @@ -163,16 +163,12 @@ void McEventCollectionCnv_p5::persToTrans( const McEventCollection_p5* persObj, // particle. // As not all particles are stable (d'oh!) we take 50% of the number of // particles as an initial size of the hash-map (to prevent re-hash) - ParticlesMap_t partToEndVtx( (persEvt.m_particlesEnd- - persEvt.m_particlesBegin)/2 ); + ParticlesMap_t partToEndVtx( (persEvt.m_particlesEnd- persEvt.m_particlesBegin)/2 ); // create the vertices const unsigned int endVtx = persEvt.m_verticesEnd; for ( unsigned int iVtx= persEvt.m_verticesBegin; iVtx != endVtx; ++iVtx ) { - genEvt->add_vertex( createGenVertex( *persObj, - persObj->m_genVertices[iVtx], - partToEndVtx, - datapools ) ); + createGenVertex( *persObj, persObj->m_genVertices[iVtx], partToEndVtx,datapools, genEvt ); } //> end loop over vertices // set the signal process vertex @@ -552,20 +548,34 @@ HepMC::GenVertexPtr McEventCollectionCnv_p5::createGenVertex( const McEventCollection_p5& persEvt, const GenVertex_p5& persVtx, ParticlesMap_t& partToEndVtx, HepMC::DataPool& datapools + ,HepMC::GenEvent* parent ) const { - HepMC::GenVertexPtr vtx(0); + HepMC::GenVertexPtr vtx(nullptr); if(m_isPileup) { vtx=HepMC::newGenVertexPtr(); } else { vtx = datapools.getGenVertex(); } + if (parent ) parent->add_vertex(vtx); #ifdef HEPMC3 vtx->set_position(HepMC::FourVector( persVtx.m_x , persVtx.m_y , persVtx.m_z ,persVtx.m_t )); //AV ID cannot be assigned in HepMC3. And its meaning in HepMC2 is not clear. - // vtx->m_id = persVtx.m_id; + vtx->set_status(persVtx.m_id); vtx->add_attribute("weights",std::make_shared<HepMC3::VectorFloatAttribute>(persVtx.m_weights)); vtx->add_attribute("barcode",std::make_shared<HepMC3::IntAttribute>(persVtx.m_barcode)); + // handle the in-going (orphans) particles + const unsigned int nPartsIn = persVtx.m_particlesIn.size(); + for ( unsigned int i = 0; i != nPartsIn; ++i ) { + createGenParticle( persEvt.m_genParticles[persVtx.m_particlesIn[i]], partToEndVtx, datapools ); + } + + HepMC::suggest_barcode(vtx,persVtx.m_barcode); + // now handle the out-going particles + const unsigned int nPartsOut = persVtx.m_particlesOut.size(); + for ( unsigned int i = 0; i != nPartsOut; ++i ) { + createGenParticle( persEvt.m_genParticles[persVtx.m_particlesOut[i]], partToEndVtx, datapools, vtx ); + } #else vtx->m_position.setX( persVtx.m_x ); vtx->m_position.setY( persVtx.m_y ); @@ -579,7 +589,6 @@ McEventCollectionCnv_p5::createGenVertex( const McEventCollection_p5& persEvt, persVtx.m_weights.end() ); vtx->m_event = 0; vtx->m_barcode = persVtx.m_barcode; -#endif // handle the in-going (orphans) particles const unsigned int nPartsIn = persVtx.m_particlesIn.size(); @@ -596,20 +605,22 @@ McEventCollectionCnv_p5::createGenVertex( const McEventCollection_p5& persEvt, partToEndVtx, datapools ) ); } +#endif return vtx; } HepMC::GenParticlePtr McEventCollectionCnv_p5::createGenParticle( const GenParticle_p5& persPart, - ParticlesMap_t& partToEndVtx, HepMC::DataPool& datapools ) const + ParticlesMap_t& partToEndVtx, HepMC::DataPool& datapools ,HepMC::GenVertexPtr parent ) const { - HepMC::GenParticlePtr p(0); + HepMC::GenParticlePtr p(nullptr); if (m_isPileup) { p = HepMC::newGenParticlePtr(); } else { p = datapools.getGenParticle(); } + if (parent) parent->add_particle_out(p); #ifdef HEPMC3 p->set_pdg_id( persPart.m_pdgId); p->set_status( persPart.m_status);