From d04b4fe877207601a8db78a0e9e1c971a80480ff Mon Sep 17 00:00:00 2001 From: Andrii Verbytskyi <andrii.verbytskyi@mpp.mpg.de> Date: Wed, 2 Sep 2020 17:05:34 +0200 Subject: [PATCH] Cleanup of the GeneratorObjectsTPCnv: removed wrong comments and moved copypasted code into a separate include --- .../src/GenEventCnv_p1.cxx | 7 +-- .../src/GeneratorObjectsTPCnv.cxx | 2 +- .../src/HepMcParticleLinkCnv_p1.cxx | 6 --- .../src/HepMcParticleLinkCnv_p2.cxx | 12 ----- .../src/McEventCollectionCnv_p1.cxx | 20 ++------ .../src/McEventCollectionCnv_p2.cxx | 39 ++------------- .../src/McEventCollectionCnv_p3.cxx | 39 ++------------- .../src/McEventCollectionCnv_p4.cxx | 38 ++------------- .../src/McEventCollectionCnv_p5.cxx | 47 ++----------------- .../src/McEventCollectionCnv_utils.h | 23 +++++++++ 10 files changed, 45 insertions(+), 188 deletions(-) create mode 100644 Generators/GeneratorObjectsTPCnv/src/McEventCollectionCnv_utils.h diff --git a/Generators/GeneratorObjectsTPCnv/src/GenEventCnv_p1.cxx b/Generators/GeneratorObjectsTPCnv/src/GenEventCnv_p1.cxx index a6532e9c29c..fd88e5a0df0 100755 --- a/Generators/GeneratorObjectsTPCnv/src/GenEventCnv_p1.cxx +++ b/Generators/GeneratorObjectsTPCnv/src/GenEventCnv_p1.cxx @@ -1,7 +1,7 @@ ///////////////////////// -*- C++ -*- ///////////////////////////// /* - Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration + Copyright (C) 2002-2020 CERN for the benefit of the ATLAS collaboration */ // GenEventCnv_p1.cxx @@ -36,11 +36,6 @@ void GenEventCnv_p1::setDataPool( HepMC::DataPool* pool ) m_pool = pool; } -/////////////////////////////////////////////////////////////////// -/// Const methods: -/////////////////////////////////////////////////////////////////// - - void GenEventCnv_p1::persToTrans( const GenEvent_p1* persObj, HepMC::GenEvent* transObj, MsgStream& msg ) diff --git a/Generators/GeneratorObjectsTPCnv/src/GeneratorObjectsTPCnv.cxx b/Generators/GeneratorObjectsTPCnv/src/GeneratorObjectsTPCnv.cxx index 16b881e69b2..51f6d535ee0 100644 --- a/Generators/GeneratorObjectsTPCnv/src/GeneratorObjectsTPCnv.cxx +++ b/Generators/GeneratorObjectsTPCnv/src/GeneratorObjectsTPCnv.cxx @@ -1,5 +1,5 @@ /* - Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration + Copyright (C) 2002-2020 CERN for the benefit of the ATLAS collaboration */ // generate the T/P converter entries diff --git a/Generators/GeneratorObjectsTPCnv/src/HepMcParticleLinkCnv_p1.cxx b/Generators/GeneratorObjectsTPCnv/src/HepMcParticleLinkCnv_p1.cxx index 06809d4a802..ed285631259 100755 --- a/Generators/GeneratorObjectsTPCnv/src/HepMcParticleLinkCnv_p1.cxx +++ b/Generators/GeneratorObjectsTPCnv/src/HepMcParticleLinkCnv_p1.cxx @@ -17,9 +17,6 @@ /// Public methods: /////////////////////////////////////////////////////////////////// -/////////////////////////////////////////////////////////////////// -/// Const methods: -/////////////////////////////////////////////////////////////////// // In the 21.0 branch an eventIndex of zero means that the transient // HepMcParticleLink looks at the first event in the @@ -74,6 +71,3 @@ void HepMcParticleLinkCnv_p1::transToPers( const HepMcParticleLink* transObj, return; } -/////////////////////////////////////////////////////////////////// -// Protected methods: -/////////////////////////////////////////////////////////////////// diff --git a/Generators/GeneratorObjectsTPCnv/src/HepMcParticleLinkCnv_p2.cxx b/Generators/GeneratorObjectsTPCnv/src/HepMcParticleLinkCnv_p2.cxx index d448d8cca25..d2a6262ace9 100755 --- a/Generators/GeneratorObjectsTPCnv/src/HepMcParticleLinkCnv_p2.cxx +++ b/Generators/GeneratorObjectsTPCnv/src/HepMcParticleLinkCnv_p2.cxx @@ -9,17 +9,8 @@ #include "GaudiKernel/ThreadLocalContext.h" #include "AthenaKernel/ExtendedEventContext.h" -// GeneratorObjectsAthenaPool includes #include "GeneratorObjectsTPCnv/HepMcParticleLinkCnv_p2.h" -/////////////////////////////////////////////////////////////////// -/// Public methods: -/////////////////////////////////////////////////////////////////// - -/////////////////////////////////////////////////////////////////// -/// Const methods: -/////////////////////////////////////////////////////////////////// - void HepMcParticleLinkCnv_p2::persToTrans( const HepMcParticleLink_p2* persObj, HepMcParticleLink* transObj, @@ -69,6 +60,3 @@ void HepMcParticleLinkCnv_p2::transToPers( const HepMcParticleLink* transObj, return; } -/////////////////////////////////////////////////////////////////// -// Protected methods: -/////////////////////////////////////////////////////////////////// diff --git a/Generators/GeneratorObjectsTPCnv/src/McEventCollectionCnv_p1.cxx b/Generators/GeneratorObjectsTPCnv/src/McEventCollectionCnv_p1.cxx index ebf282b7414..028db5415a7 100755 --- a/Generators/GeneratorObjectsTPCnv/src/McEventCollectionCnv_p1.cxx +++ b/Generators/GeneratorObjectsTPCnv/src/McEventCollectionCnv_p1.cxx @@ -1,7 +1,7 @@ ///////////////////////// -*- C++ -*- ///////////////////////////// /* - Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration + Copyright (C) 2002-2020 CERN for the benefit of the ATLAS collaboration */ // McEventCollectionCnv_p1.cxx @@ -19,11 +19,9 @@ #include "HepMcDataPool.h" /////////////////////////////////////////////////////////////////// -// Public methods: +// Constructors /////////////////////////////////////////////////////////////////// -// Constructors -//////////////// McEventCollectionCnv_p1::McEventCollectionCnv_p1() : Base_t( ) {} @@ -41,16 +39,14 @@ McEventCollectionCnv_p1::operator=( const McEventCollectionCnv_p1& rhs ) return *this; } +/////////////////////////////////////////////////////////////////// // Destructor -/////////////// +/////////////////////////////////////////////////////////////////// McEventCollectionCnv_p1::~McEventCollectionCnv_p1() { } -/////////////////////////////////////////////////////////////////// -// Const methods: -/////////////////////////////////////////////////////////////////// void McEventCollectionCnv_p1::persToTrans( const McEventCollection_p1* persObj, McEventCollection* transObj, @@ -110,11 +106,3 @@ void McEventCollectionCnv_p1::transToPers( const McEventCollection*, throw std::runtime_error( "Retired McEventCollectionCnv_p1::transToPers() !!" ); return; } - -/////////////////////////////////////////////////////////////////// -// Non-const methods: -/////////////////////////////////////////////////////////////////// - -/////////////////////////////////////////////////////////////////// -// Protected methods: -/////////////////////////////////////////////////////////////////// diff --git a/Generators/GeneratorObjectsTPCnv/src/McEventCollectionCnv_p2.cxx b/Generators/GeneratorObjectsTPCnv/src/McEventCollectionCnv_p2.cxx index db91483e3fd..aa4cb45c00d 100755 --- a/Generators/GeneratorObjectsTPCnv/src/McEventCollectionCnv_p2.cxx +++ b/Generators/GeneratorObjectsTPCnv/src/McEventCollectionCnv_p2.cxx @@ -1,7 +1,7 @@ ///////////////////////// -*- C++ -*- ///////////////////////////// /* - Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration + Copyright (C) 2002-2020 CERN for the benefit of the ATLAS collaboration */ // McEventCollectionCnv_p2.cxx @@ -17,33 +17,11 @@ #include "GeneratorObjectsTPCnv/McEventCollectionCnv_p2.h" #include "HepMcDataPool.h" -#if 0 -namespace { - // helper method to compute the number of particles and vertices in a - // whole McEventCollection - std::pair<unsigned int,unsigned int> - nbrParticlesAndVertices( const McEventCollection* mcEvents ) { - unsigned int nParts = 0; - unsigned int nVerts = 0; - const McEventCollection::const_iterator itrEnd = mcEvents->end(); - for ( McEventCollection::const_iterator itr = mcEvents->begin(); - itr != itrEnd; - ++itr ) { - nParts += (*itr)->particles_size(); - nVerts += (*itr)->vertices_size(); - } - - return std::make_pair( nParts, nVerts ); - } -} -#endif /////////////////////////////////////////////////////////////////// -// Public methods: +// Constructors /////////////////////////////////////////////////////////////////// -// Constructors -//////////////// McEventCollectionCnv_p2::McEventCollectionCnv_p2() : Base_t( ) {} @@ -61,16 +39,14 @@ McEventCollectionCnv_p2::operator=( const McEventCollectionCnv_p2& rhs ) return *this; } +/////////////////////////////////////////////////////////////////// // Destructor -/////////////// +/////////////////////////////////////////////////////////////////// McEventCollectionCnv_p2::~McEventCollectionCnv_p2() { } -/////////////////////////////////////////////////////////////////// -// Const methods: -/////////////////////////////////////////////////////////////////// void McEventCollectionCnv_p2::persToTrans( const McEventCollection_p2* persObj, McEventCollection* transObj, @@ -178,13 +154,6 @@ void McEventCollectionCnv_p2::transToPers( const McEventCollection*, return; } -/////////////////////////////////////////////////////////////////// -// Non-const methods: -/////////////////////////////////////////////////////////////////// - -/////////////////////////////////////////////////////////////////// -// Protected methods: -/////////////////////////////////////////////////////////////////// HepMC::GenVertexPtr McEventCollectionCnv_p2::createGenVertex( const McEventCollection_p2& persEvt, diff --git a/Generators/GeneratorObjectsTPCnv/src/McEventCollectionCnv_p3.cxx b/Generators/GeneratorObjectsTPCnv/src/McEventCollectionCnv_p3.cxx index 20ada766f82..6a6383de3e9 100755 --- a/Generators/GeneratorObjectsTPCnv/src/McEventCollectionCnv_p3.cxx +++ b/Generators/GeneratorObjectsTPCnv/src/McEventCollectionCnv_p3.cxx @@ -1,7 +1,7 @@ ///////////////////////// -*- C++ -*- ///////////////////////////// /* - Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration + Copyright (C) 2002-2020 CERN for the benefit of the ATLAS collaboration */ // McEventCollectionCnv_p3.cxx @@ -18,33 +18,11 @@ #include "GeneratorObjectsTPCnv/McEventCollectionCnv_p3.h" #include "HepMcDataPool.h" -#if 0 -namespace { - // helper method to compute the number of particles and vertices in a - // whole McEventCollection - std::pair<unsigned int,unsigned int> - nbrParticlesAndVertices( const McEventCollection* mcEvents ) { - unsigned int nParts = 0; - unsigned int nVerts = 0; - const McEventCollection::const_iterator itrEnd = mcEvents->end(); - for ( McEventCollection::const_iterator itr = mcEvents->begin(); - itr != itrEnd; - ++itr ) { - nParts += (*itr)->particles_size(); - nVerts += (*itr)->vertices_size(); - } - - return std::make_pair( nParts, nVerts ); - } -} -#endif /////////////////////////////////////////////////////////////////// -// Public methods: +// Constructors /////////////////////////////////////////////////////////////////// -// Constructors -//////////////// McEventCollectionCnv_p3::McEventCollectionCnv_p3() : Base_t( ) @@ -63,16 +41,14 @@ McEventCollectionCnv_p3::operator=( const McEventCollectionCnv_p3& rhs ) return *this; } +/////////////////////////////////////////////////////////////////// // Destructor -/////////////// +/////////////////////////////////////////////////////////////////// McEventCollectionCnv_p3::~McEventCollectionCnv_p3() { } -/////////////////////////////////////////////////////////////////// -// Const methods: -/////////////////////////////////////////////////////////////////// void McEventCollectionCnv_p3::persToTrans( const McEventCollection_p3* persObj, McEventCollection* transObj, @@ -180,13 +156,6 @@ void McEventCollectionCnv_p3::transToPers( const McEventCollection* /*transObj*/ return; } -/////////////////////////////////////////////////////////////////// -// Non-const methods: -/////////////////////////////////////////////////////////////////// - -/////////////////////////////////////////////////////////////////// -// Protected methods: -/////////////////////////////////////////////////////////////////// HepMC::GenVertexPtr McEventCollectionCnv_p3::createGenVertex( const McEventCollection_p3& persEvt, diff --git a/Generators/GeneratorObjectsTPCnv/src/McEventCollectionCnv_p4.cxx b/Generators/GeneratorObjectsTPCnv/src/McEventCollectionCnv_p4.cxx index 75a8fa2a8bf..db580216dad 100755 --- a/Generators/GeneratorObjectsTPCnv/src/McEventCollectionCnv_p4.cxx +++ b/Generators/GeneratorObjectsTPCnv/src/McEventCollectionCnv_p4.cxx @@ -1,7 +1,7 @@ ///////////////////////// -*- C++ -*- ///////////////////////////// /* - Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration + Copyright (C) 2002-2020 CERN for the benefit of the ATLAS collaboration */ // McEventCollectionCnv_p4.cxx @@ -21,34 +21,12 @@ #include "GenInterfaces/IHepMCWeightSvc.h" -namespace -{ - // helper method to compute the number of particles and vertices in a - // whole McEventCollection - std::pair<unsigned int,unsigned int> - nbrParticlesAndVertices( const McEventCollection* mcEvents ) - { - unsigned int nParts = 0; - unsigned int nVerts = 0; - const McEventCollection::const_iterator itrEnd = mcEvents->end(); - for ( McEventCollection::const_iterator itr = mcEvents->begin(); - itr != itrEnd; - ++itr ) - { - nParts += (*itr)->particles_size(); - nVerts += (*itr)->vertices_size(); - } - - return std::make_pair( nParts, nVerts ); - } -} +#include "McEventCollectionCnv_utils.h" /////////////////////////////////////////////////////////////////// -// Public methods: +// Constructors /////////////////////////////////////////////////////////////////// -// Constructors -//////////////// McEventCollectionCnv_p4::McEventCollectionCnv_p4() : Base_t( ), @@ -280,13 +258,6 @@ void McEventCollectionCnv_p4::transToPers( const McEventCollection* transObj, return; } -/////////////////////////////////////////////////////////////////// -// Non-const methods: -/////////////////////////////////////////////////////////////////// - -/////////////////////////////////////////////////////////////////// -// Protected methods: -/////////////////////////////////////////////////////////////////// HepMC::GenVertexPtr McEventCollectionCnv_p4::createGenVertex( const McEventCollection_p4& persEvt, @@ -465,9 +436,6 @@ int McEventCollectionCnv_p4::writeGenParticle( const HepMC::GenParticle& p, (m2 < 0) && // isSpacelike !(std::abs(m2) < 2.0*DBL_EPSILON*ene*ene); // !isLightlike - // const bool useP2M2 = !isTimelike () && - // mom.isSpacelike() && - // !mom.isLightlike(); const short recoMethod = ( !useP2M2 ? 0 : ( ene >= 0. //*GeV diff --git a/Generators/GeneratorObjectsTPCnv/src/McEventCollectionCnv_p5.cxx b/Generators/GeneratorObjectsTPCnv/src/McEventCollectionCnv_p5.cxx index 8b866604942..a769cb98d3f 100755 --- a/Generators/GeneratorObjectsTPCnv/src/McEventCollectionCnv_p5.cxx +++ b/Generators/GeneratorObjectsTPCnv/src/McEventCollectionCnv_p5.cxx @@ -1,7 +1,7 @@ ///////////////////////// -*- C++ -*- ///////////////////////////// /* - Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration + Copyright (C) 2002-2020 CERN for the benefit of the ATLAS collaboration */ // McEventCollectionCnv_p5.cxx @@ -17,34 +17,13 @@ // GeneratorObjectsTPCnv includes #include "GeneratorObjectsTPCnv/McEventCollectionCnv_p5.h" #include "HepMcDataPool.h" - #include "GenInterfaces/IHepMCWeightSvc.h" +#include "McEventCollectionCnv_utils.h" -namespace { - // helper method to compute the number of particles and vertices in a - // whole McEventCollection - std::pair<unsigned int,unsigned int> - nbrParticlesAndVertices( const McEventCollection* mcEvents ) { - unsigned int nParts = 0; - unsigned int nVerts = 0; - const McEventCollection::const_iterator itrEnd = mcEvents->end(); - for ( McEventCollection::const_iterator itr = mcEvents->begin(); - itr != itrEnd; - ++itr ) { - nParts += (*itr)->particles_size(); - nVerts += (*itr)->vertices_size(); - } - - return std::make_pair( nParts, nVerts ); - } -} /////////////////////////////////////////////////////////////////// -// Public methods: -/////////////////////////////////////////////////////////////////// - // Constructors -//////////////// +/////////////////////////////////////////////////////////////////// McEventCollectionCnv_p5::McEventCollectionCnv_p5() : Base_t( ), @@ -66,16 +45,14 @@ McEventCollectionCnv_p5::operator=( const McEventCollectionCnv_p5& rhs ) return *this; } +/////////////////////////////////////////////////////////////////// // Destructor -/////////////// +/////////////////////////////////////////////////////////////////// McEventCollectionCnv_p5::~McEventCollectionCnv_p5() { } -/////////////////////////////////////////////////////////////////// -// Const methods: -/////////////////////////////////////////////////////////////////// void McEventCollectionCnv_p5::persToTrans( const McEventCollection_p5* persObj, McEventCollection* transObj, @@ -365,13 +342,6 @@ void McEventCollectionCnv_p5::transToPers( const McEventCollection* transObj, return; } -/////////////////////////////////////////////////////////////////// -// Non-const methods: -/////////////////////////////////////////////////////////////////// - -/////////////////////////////////////////////////////////////////// -// Protected methods: -/////////////////////////////////////////////////////////////////// HepMC::GenVertexPtr McEventCollectionCnv_p5::createGenVertex( const McEventCollection_p5& persEvt, @@ -444,10 +414,6 @@ McEventCollectionCnv_p5::createGenParticle( const GenParticle_p5& persPart, // optimization. (If this is a performance issue for platforms // other than x86, one could change to double for those platforms.) if ( 0 == persPart.m_recoMethod ) { - // p->m_momentum.setVectM(Hep4Vector( persPart.m_px, - // persPart.m_py, - // persPart.m_pz ), - // persPart.m_m ); p->m_momentum.setPx( persPart.m_px); p->m_momentum.setPy( persPart.m_py); @@ -535,9 +501,6 @@ int McEventCollectionCnv_p5::writeGenParticle( const HepMC::GenParticle& p, (m2 < 0) && // isSpacelike !(std::abs(m2) < 2.0*DBL_EPSILON*ene*ene); // !isLightlike - // const bool useP2M2 = !isTimelike () && - // mom.isSpacelike() && - // !mom.isLightlike(); const short recoMethod = ( !useP2M2 ? 0 : ( ene >= 0. //*GeV diff --git a/Generators/GeneratorObjectsTPCnv/src/McEventCollectionCnv_utils.h b/Generators/GeneratorObjectsTPCnv/src/McEventCollectionCnv_utils.h new file mode 100644 index 00000000000..982693b593a --- /dev/null +++ b/Generators/GeneratorObjectsTPCnv/src/McEventCollectionCnv_utils.h @@ -0,0 +1,23 @@ +namespace { + // helper method to compute the number of particles and vertices in a + // whole McEventCollection + std::pair<unsigned int,unsigned int> + nbrParticlesAndVertices( const McEventCollection* mcEvents ) { + unsigned int nParts = 0; + unsigned int nVerts = 0; + const McEventCollection::const_iterator itrEnd = mcEvents->end(); + for ( McEventCollection::const_iterator itr = mcEvents->begin(); + itr != itrEnd; + ++itr ) { +#ifdef HEPMC3 + nParts += (*itr)->particles().size(); + nVerts += (*itr)->vertices().size(); +#else + nParts += (*itr)->particles_size(); + nVerts += (*itr)->vertices_size(); +#endif + } + + return std::make_pair( nParts, nVerts ); + } +} \ No newline at end of file -- GitLab