From e8e79749cf8d8e28a84daf1c63485edae8be45f3 Mon Sep 17 00:00:00 2001
From: Andrii Verbytskyi <averbyts@cern.ch>
Date: Sun, 6 Sep 2020 22:04:27 +0200
Subject: [PATCH 1/3] Initial commit

---
 Control/AthContainers/CMakeLists.txt          |   4 +
 Event/xAOD/xAODTruthCnv/CMakeLists.txt        |   3 +-
 .../GeneratorObjects/McEventDict.h            |  10 +-
 .../GeneratorObjects/selection.xml            |   2 +
 .../McEventCollectionCnv_p4.h                 |  10 +
 .../McEventCollectionCnv_p5.h                 |  10 +
 .../src/GenEventCnv_p1.cxx                    |  13 +-
 .../GeneratorObjectsTPCnv/src/HepMcDataPool.h |  55 ++++
 .../src/McEventCollectionCnv_p2.cxx           |  96 +++++-
 .../src/McEventCollectionCnv_p3.cxx           |  19 ++
 .../src/McEventCollectionCnv_p4.cxx           | 285 +++++++++++++++++-
 .../src/McEventCollectionCnv_p5.cxx           | 270 +++++++++++++++++
 .../AnalysisTest/CMakeLists.txt               |   1 +
 .../McParticleTools/src/McVtxFilterTool.cxx   |   6 +-
 .../src/OldSpclMcFilterTool.cxx               |   2 +-
 .../McParticleTools/src/PileupFilterTool.cxx  |   2 +-
 .../test/McVtxFilterTest_CppUnit.cxx          |  74 ++---
 Projects/AnalysisBase/CMakeLists.txt          |   6 +
 Projects/AthGeneration/CMakeLists.txt         |   5 +
 Projects/AthSimulation/CMakeLists.txt         |  11 +
 .../src/FastShowerCellBuilderTool.cxx         |   2 +-
 .../src/MultiParticleGunPileup.cxx            |   4 +-
 .../MCTruth/PrimaryParticleInformation.h      |  25 ++
 .../G4Sim/MCTruth/MCTruth/TrackInformation.h  |  23 ++
 .../G4Sim/MCTruth/MCTruth/VTrackInformation.h |  61 +++-
 .../src/PrimaryParticleInformation.cxx        |  58 ++++
 .../G4Sim/MCTruth/src/TrackInformation.cxx    |  45 ++-
 .../G4Sim/MCTruth/src/VTrackInformation.cxx   |  39 ++-
 .../src/AthenaTrackingAction.cxx              |   7 +
 .../src/MergeMcEventCollTool.cxx              |  18 +-
 .../MCTruthSimAlgs/src/MergeMcEventCollTool.h |   4 +-
 .../ISF_Event/ISF_Event/HepMCHelper.h         |   7 +
 .../ISF_Event/ISF_Event/HepMCHelper.icc       |  17 ++
 .../ISF_Event/ISF_Event/TruthBinding.icc      |   3 +
 .../ISF_Event/src/ISFTruthIncident.cxx        |  19 +-
 .../ISF_Services/src/InputConverter.cxx       |  94 +++++-
 .../ISF_Services/src/InputConverter.h         |  12 +
 .../ISF_Core/ISF_Services/src/TruthSvc.cxx    |  35 ++-
 .../ISF_Services/test/InputConverter_test.cxx |  10 +-
 .../ISF_Services/test/TruthSvc_test.cxx       |  72 ++---
 .../PRD_PlanarTruthTrajectoryBuilder.h        |   4 +-
 .../src/PRD_PlanarTruthTrajectoryBuilder.cxx  |  10 +-
 .../ISF_Geant4Event/src/ISFG4Helper.cxx       |   4 +
 .../ISF_Geant4Tools/src/ISFTrajectory.cxx     |   6 +-
 .../src/PhysicsValidationUserAction.cxx       |  13 +
 .../src/TrackProcessorUserActionBase.cxx      |  12 +-
 .../src/TrackProcessorUserActionPassBack.cxx  |   7 +-
 .../ISF_HepMC_Interfaces/IGenParticleFilter.h |   5 +
 .../src/GenParticleFinalStateFilter.cxx       |  12 +
 .../src/GenParticleFinalStateFilter.h         |   9 +
 .../src/GenParticleGenericFilter.cxx          |  20 +-
 .../src/GenParticleGenericFilter.h            |   8 +
 .../src/GenParticleInteractingFilter.cxx      |   9 +
 .../src/GenParticleInteractingFilter.h        |   6 +
 .../src/GenParticleLifetimeFilter.cxx         |  16 +-
 .../src/GenParticleLifetimeFilter.h           |   4 +
 .../src/GenParticlePositionFilter.cxx         |   7 +
 .../src/GenParticlePositionFilter.h           |   4 +
 .../src/GenParticleSimWhiteList.cxx           |  14 +
 .../src/GenParticleSimWhiteList.h             |   9 +
 .../test/GenParticleGenericFilter_test.cxx    |  10 +-
 .../src/ConeSimSelector.cxx                   |   5 +-
 .../src/TruthAssocSimSelector.cxx             |   9 +-
 .../src/McEventCollectionFilter.cxx           |  17 +-
 64 files changed, 1482 insertions(+), 177 deletions(-)

diff --git a/Control/AthContainers/CMakeLists.txt b/Control/AthContainers/CMakeLists.txt
index 1ee81e1b1790..2d7c2bee6c65 100644
--- a/Control/AthContainers/CMakeLists.txt
+++ b/Control/AthContainers/CMakeLists.txt
@@ -11,6 +11,10 @@ if( NOT XAOD_STANDALONE )
    set( extra_sources src/*.cxx )
 endif()
 
+atlas_depends_on_subdirs(
+   PUBLIC
+      Generators/AtlasHepMC )
+
 # External dependencies:
 find_package( Boost COMPONENTS thread )
 find_package( ROOT COMPONENTS Core )
diff --git a/Event/xAOD/xAODTruthCnv/CMakeLists.txt b/Event/xAOD/xAODTruthCnv/CMakeLists.txt
index e226116ad1ce..392f416834bc 100644
--- a/Event/xAOD/xAODTruthCnv/CMakeLists.txt
+++ b/Event/xAOD/xAODTruthCnv/CMakeLists.txt
@@ -26,13 +26,14 @@ atlas_depends_on_subdirs(
    Control/CxxUtils
    Control/AthToolSupport/AsgTools
    Event/xAOD/xAODTruth
+   Generators/AtlasHepMC
    ${extra_dep} )
 
 # Component(s) in the package:
 atlas_add_library( xAODTruthCnvLib
    xAODTruthCnv/*.h Root/*.cxx
    PUBLIC_HEADERS xAODTruthCnv
-   LINK_LIBRARIES AsgTools xAODTruth )
+   LINK_LIBRARIES AsgTools xAODTruth  AtlasHepMCLib)
 
 if( NOT XAOD_STANDALONE )
    atlas_add_component( xAODTruthCnv
diff --git a/Generators/GeneratorObjects/GeneratorObjects/McEventDict.h b/Generators/GeneratorObjects/GeneratorObjects/McEventDict.h
index 58b8b0605e44..2dc20551fff4 100644
--- a/Generators/GeneratorObjects/GeneratorObjects/McEventDict.h
+++ b/Generators/GeneratorObjects/GeneratorObjects/McEventDict.h
@@ -13,6 +13,7 @@
 #include "GeneratorObjects/HijingEventParams.h"
 #include "RootUtils/PyROOTIteratorFuncs.h"
 
+#include "AtlasHepMC/GenEvent.h"
 namespace GeneratorObjectsMcEventDict {
   
   struct tmp {
@@ -24,9 +25,12 @@ namespace GeneratorObjectsMcEventDict {
 
     std::iterator<std::forward_iterator_tag,HepMC::GenVertex*,int,HepMC::GenVertex**,HepMC::GenVertex*&> m_1;
     std::iterator<std::forward_iterator_tag,HepMC::GenParticle*,int,HepMC::GenParticle**,HepMC::GenParticle*&> m_2;
-    
-    RootUtils::PyROOTIteratorFuncs<
-      HepMC::GenVertex::particles_out_const_iterator> m_it;
+
+#ifdef HEPMC3 
+    RootUtils::PyROOTIteratorFuncs<std::vector<HepMC::GenVertex>::const_iterator> m_it;
+#else    
+    RootUtils::PyROOTIteratorFuncs<HepMC::GenVertex::particles_out_const_iterator> m_it;
+#endif
   };
 
 }
diff --git a/Generators/GeneratorObjects/GeneratorObjects/selection.xml b/Generators/GeneratorObjects/GeneratorObjects/selection.xml
index ad9db4103ad4..d8f1e990babb 100755
--- a/Generators/GeneratorObjects/GeneratorObjects/selection.xml
+++ b/Generators/GeneratorObjects/GeneratorObjects/selection.xml
@@ -16,9 +16,11 @@
   <class name="std::map<int,HepMC::GenVertex*,std::greater<int> >" />
   <class name="HepMC::WeightContainer" />
   <class name="std::set<HepMC::GenParticle*>" />
+<!--  
   <class name="HepMC::Flow" >
     <field name="m_particle_owner" transient="true" />
   </class>
+-->
   <class name="HepMC::Polarization" />
   <class name="HepMcParticleLink" >
    <field name="m_ptrs" transient="true" />
diff --git a/Generators/GeneratorObjectsTPCnv/GeneratorObjectsTPCnv/McEventCollectionCnv_p4.h b/Generators/GeneratorObjectsTPCnv/GeneratorObjectsTPCnv/McEventCollectionCnv_p4.h
index 19ba716047d0..520c5021c22d 100755
--- a/Generators/GeneratorObjectsTPCnv/GeneratorObjectsTPCnv/McEventCollectionCnv_p4.h
+++ b/Generators/GeneratorObjectsTPCnv/GeneratorObjectsTPCnv/McEventCollectionCnv_p4.h
@@ -129,17 +129,27 @@ class McEventCollectionCnv_p4 : public T_AthenaPoolTPCnvBase<
    *  vertex is added to the persistent is added to the persistent
    *  @c GenEvent.
    */
+#ifdef HEPMC3
+  void writeGenVertex( const HepMC::GenVertexPtr vtx,
+                       McEventCollection_p4& persEvt ) const;
+#else
   void writeGenVertex( const HepMC::GenVertex& vtx,
                        McEventCollection_p4& persEvt ) const;
+#endif
 
   /** @brief Method to write a persistent @c GenParticle object
    *  It returns the index of the persistent @c GenParticle into the
    *  collection of persistent of @c GenParticles from the
    *  persistent @c GenEvent
    */
+#ifdef HEPMC3   
+  int writeGenParticle( const HepMC::GenParticlePtr p,
+                        McEventCollection_p4& persEvt ) const;
+#else
   int writeGenParticle( const HepMC::GenParticle& p,
                         McEventCollection_p4& persEvt ) const;
 
+#endif
   ///////////////////////////////////////////////////////////////////
   // Protected data:
   ///////////////////////////////////////////////////////////////////
diff --git a/Generators/GeneratorObjectsTPCnv/GeneratorObjectsTPCnv/McEventCollectionCnv_p5.h b/Generators/GeneratorObjectsTPCnv/GeneratorObjectsTPCnv/McEventCollectionCnv_p5.h
index c5649ca6fd44..f44925134f1a 100755
--- a/Generators/GeneratorObjectsTPCnv/GeneratorObjectsTPCnv/McEventCollectionCnv_p5.h
+++ b/Generators/GeneratorObjectsTPCnv/GeneratorObjectsTPCnv/McEventCollectionCnv_p5.h
@@ -130,16 +130,26 @@ class McEventCollectionCnv_p5 : public T_AthenaPoolTPCnvBase<
    *  vertex is added to the persistent is added to the persistent
    *  @c GenEvent.
    */
+#ifdef HEPMC3
+  void writeGenVertex( const HepMC::GenVertexPtr vtx,
+                       McEventCollection_p5& persEvt ) const;
+#else
   void writeGenVertex( const HepMC::GenVertex& vtx,
                        McEventCollection_p5& persEvt ) const;
 
+#endif
   /** @brief Method to write a persistent @c GenParticle object
    *  It returns the index of the persistent @c GenParticle into the
    *  collection of persistent of @c GenParticles from the
    *  persistent @c GenEvent
    */
+#ifdef HEPMC3
+  int writeGenParticle( const HepMC::GenParticlePtr p,
+                        McEventCollection_p5& persEvt ) const;
+#else
   int writeGenParticle( const HepMC::GenParticle& p,
                         McEventCollection_p5& persEvt ) const;
+#endif
 
   ///////////////////////////////////////////////////////////////////
   // Protected data:
diff --git a/Generators/GeneratorObjectsTPCnv/src/GenEventCnv_p1.cxx b/Generators/GeneratorObjectsTPCnv/src/GenEventCnv_p1.cxx
index fd88e5a0df01..03153a81c00a 100755
--- a/Generators/GeneratorObjectsTPCnv/src/GenEventCnv_p1.cxx
+++ b/Generators/GeneratorObjectsTPCnv/src/GenEventCnv_p1.cxx
@@ -62,6 +62,8 @@ void GenEventCnv_p1::persToTrans( const GenEvent_p1* persObj,
     m_pool->part.reserve( m_pool->part.allocated() + nParts );
   }
 
+#ifdef HEPMC3
+#else  
   transObj->set_signal_process_id( persObj->m_signalProcessId );
   transObj->set_event_number( persObj->m_eventNbr );
   transObj->set_event_scale ( persObj->m_eventScale );
@@ -78,6 +80,7 @@ void GenEventCnv_p1::persToTrans( const GenEvent_p1* persObj,
 
   transObj->m_pdf_info = 0;         //> not available at that time...
 
+#endif
   // 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
@@ -142,6 +145,9 @@ GenEventCnv_p1::createGenVertex( const GenEvent_p1& persEvt,
 				 const GenVertex_p1& persVtx,
 				 ParticlesMap_t& partToEndVtx ) const
 {
+#ifdef HEPMC3
+HepMC::GenVertexPtr vtx;
+#else
   HepMC::GenVertexPtr vtx = m_pool->vtx.nextElementPtr();
   vtx->m_position.setX( persVtx.m_x );
   vtx->m_position.setY( persVtx.m_y );
@@ -167,6 +173,7 @@ GenEventCnv_p1::createGenVertex( const GenEvent_p1& persEvt,
      vtx->add_particle_out( createGenParticle( persEvt.m_particles[persVtx.m_particlesOut[i]],
 					       partToEndVtx ) );
   }
+#endif
 
   return vtx;
 }
@@ -175,8 +182,9 @@ HepMC::GenParticlePtr
 GenEventCnv_p1::createGenParticle( const GenParticle_p1& persPart,
 				   ParticlesMap_t& partToEndVtx ) const
 {
-
-
+#ifdef HEPMC3
+HepMC::GenParticlePtr p;
+#else
   HepMC::GenParticlePtr p = m_pool->part.nextElementPtr();
   p->m_momentum.setPx( persPart.m_px  );
   p->m_momentum.setPy( persPart.m_py  );
@@ -201,6 +209,7 @@ GenEventCnv_p1::createGenParticle( const GenParticle_p1& persPart,
     partToEndVtx[p] = persPart.m_endVtx;
   }
 
+#endif
   return p;
 }
 
diff --git a/Generators/GeneratorObjectsTPCnv/src/HepMcDataPool.h b/Generators/GeneratorObjectsTPCnv/src/HepMcDataPool.h
index be051d1fbb40..1faeee2f5d7d 100755
--- a/Generators/GeneratorObjectsTPCnv/src/HepMcDataPool.h
+++ b/Generators/GeneratorObjectsTPCnv/src/HepMcDataPool.h
@@ -35,6 +35,43 @@
 // various DataPool<Xyz>.
 namespace SG {
 
+#ifdef HEPMC3
+
+
+  template<>
+  inline void
+  ArenaAllocatorBase::destroy_fcn<HepMC::GenParticlePtr>(ArenaAllocatorBase::pointer p)
+  {
+   // HepMC::GenParticle* part = reinterpret_cast<HepMC::GenParticle*>(p);
+   // part->m_production_vertex = 0;
+   // part->m_end_vertex = 0;
+   // part->~GenParticle();
+  }
+
+  template<>
+  inline void
+  ArenaAllocatorBase::destroy_fcn<HepMC::GenVertexPtr>(ArenaAllocatorBase::pointer p)
+  {
+   // HepMC::GenVertex* vtx = reinterpret_cast<HepMC::GenVertex*>(p);
+   // vtx->m_event = 0;
+   // vtx->m_particles_in.clear();
+   // vtx->m_particles_out.clear();
+   // vtx->~GenVertex();
+  }
+
+  template<>
+  inline void
+  ArenaAllocatorBase::destroy_fcn<HepMC::GenEvent>(ArenaAllocatorBase::pointer p)
+  {
+    HepMC::GenEvent* evt = reinterpret_cast<HepMC::GenEvent*>(p);
+   // evt->m_particle_barcodes.clear();
+   // evt->m_vertex_barcodes.clear();
+   // delete evt->m_pdf_info; evt->m_pdf_info = 0;
+    evt->~GenEvent();
+  }
+
+#else
+
   template<>
   inline void
   ArenaAllocatorBase::destroy_fcn<HepMC::GenParticle>(ArenaAllocatorBase::pointer p)
@@ -66,9 +103,26 @@ namespace SG {
     delete evt->m_pdf_info; evt->m_pdf_info = 0;
     evt->~GenEvent();
   }
+#endif  
 } // end namespace SG
 
 namespace HepMC {
+ #ifdef HEPMC3
+  struct DataPool {
+
+    typedef ::DataPool<HepMC::GenEvent> GenEvtPool_t;
+    /// an arena of @c HepMC::GenEvent for efficient object instantiation
+    GenEvtPool_t evt;
+
+    typedef ::DataPool<HepMC::GenVertexPtr> GenVtxPool_t;
+    /// an arena of @c HepMC::GenVertex for efficient object instantiation
+    GenVtxPool_t vtx;
+
+    typedef ::DataPool<HepMC::GenParticlePtr> GenPartPool_t;
+    /// an arena of @c HepMC::GenParticle for efficient object instantiation
+    GenPartPool_t part;
+  };
+#else
   struct DataPool {
 
     typedef ::DataPool<HepMC::GenEvent> GenEvtPool_t;
@@ -84,6 +138,7 @@ namespace HepMC {
     GenPartPool_t part;
   };
 
+#endif
 } // end namespace HepMC
 
 #endif // GENERATOROBJECTSATHENAPOOL_HEPMCDATAPOOL_H
diff --git a/Generators/GeneratorObjectsTPCnv/src/McEventCollectionCnv_p2.cxx b/Generators/GeneratorObjectsTPCnv/src/McEventCollectionCnv_p2.cxx
index aa4cb45c00db..7c564ece43b7 100755
--- a/Generators/GeneratorObjectsTPCnv/src/McEventCollectionCnv_p2.cxx
+++ b/Generators/GeneratorObjectsTPCnv/src/McEventCollectionCnv_p2.cxx
@@ -79,6 +79,50 @@ void McEventCollectionCnv_p2::persToTrans( const McEventCollection_p2* persObj,
         ++itr ) {
     const GenEvent_p2& persEvt = *itr;
     HepMC::GenEvent * genEvt        = poolOfEvents.nextElementPtr();
+#ifdef HEPMC3
+    genEvt->add_attribute("signal_process_id",std::make_shared<HepMC3::IntAttribute>(persEvt.m_signalProcessId));
+    genEvt->set_event_number(persEvt.m_eventNbr);
+    genEvt->add_attribute("event_scale",std::make_shared<HepMC3::DoubleAttribute>(persEvt.m_eventScale));
+    genEvt->add_attribute("alphaQCD",std::make_shared<HepMC3::DoubleAttribute>(persEvt.m_alphaQCD));
+    genEvt->add_attribute("alphaQED",std::make_shared<HepMC3::DoubleAttribute>(persEvt.m_alphaQED));
+    //AV genEvt->m_signal_process_vertex = 0;
+    //AV genEvt->m_weights               = persEvt.m_weights;
+    //AV genEvt->m_random_states         = persEvt.m_randomStates;
+    //AV genEvt->m_vertex_barcodes.clear();
+    //AV genEvt->m_particle_barcodes.clear();
+    //AV genEvt->m_pdf_info = 0;         //> not available at that time...
+
+    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
+    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 ) );
+    } //> end loop over vertices
+
+    // set the signal process vertex
+    const int sigProcVtx = persEvt.m_signalProcessVtx;
+    if ( sigProcVtx ) HepMC::set_signal_process_vertex(genEvt, HepMC::barcode_to_vertex(genEvt, sigProcVtx ) );
+
+    // connect particles to their end vertices
+    for ( auto p:  partToEndVtx) {
+      auto decayVtx = HepMC::barcode_to_vertex(genEvt, p.second );
+      if ( decayVtx ) {
+        decayVtx->add_particle_in( p.first );
+      } else {
+        msg << MSG::ERROR<< "GenParticle points to null end vertex !!"<< endmsg;
+      }
+    }
+#else
     genEvt->m_signal_process_id     = persEvt.m_signalProcessId;
     genEvt->m_event_number          = persEvt.m_eventNbr;
     genEvt->m_event_scale           = persEvt.m_eventScale;
@@ -129,6 +173,7 @@ void McEventCollectionCnv_p2::persToTrans( const McEventCollection_p2* persObj,
             << endmsg;
       }
     }
+#endif    
   } //> end loop over m_genEvents
 
   msg << MSG::DEBUG << "Loaded McEventCollection from persistent state [OK]"
@@ -160,8 +205,37 @@ McEventCollectionCnv_p2::createGenVertex( const McEventCollection_p2& persEvt,
                                           const GenVertex_p2& persVtx,
                                           ParticlesMap_t& partToEndVtx, HepMC::DataPool* datapools ) const
 {
+#ifdef HEPMC3
+  DataPool<HepMC::GenVertexPtr>& poolOfVertices = datapools->vtx;
+  //auto vtx = poolOfVertices.nextElementPtr();
+  HepMC::GenVertexPtr vtx;
+  vtx->set_position( HepMC::FourVector(persVtx.m_x,persVtx.m_y, persVtx.m_z, persVtx.m_t) );
+  //AV vtx->m_particles_in.clear();
+  //AV vtx->m_particles_out.clear();
+  //AV vtx->m_id      = persVtx.m_id;
+  //AV vtx->m_weights.m_weights.reserve( persVtx.m_weights.size() );
+  //AV vtx->m_weights.m_weights.assign ( persVtx.m_weights.begin(),persVtx.m_weights.end() );
+  //AV vtx->m_event   = 0;
+  //AV vtx->m_barcode = 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 );
+  }
+
+  // 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 ) );
+  }
+#else
   DataPool<HepMC::GenVertex>& poolOfVertices = datapools->vtx;
-  HepMC::GenVertexPtr vtx = poolOfVertices.nextElementPtr();
+  HepMC::GenVertex* vtx = poolOfVertices.nextElementPtr();
   vtx->m_position.setX( persVtx.m_x );
   vtx->m_position.setY( persVtx.m_y );
   vtx->m_position.setZ( persVtx.m_z );
@@ -190,6 +264,7 @@ McEventCollectionCnv_p2::createGenVertex( const McEventCollection_p2& persEvt,
                                               partToEndVtx,
                                               datapools ) );
   }
+#endif
 
   return vtx;
 }
@@ -198,6 +273,24 @@ HepMC::GenParticlePtr
 McEventCollectionCnv_p2::createGenParticle( const GenParticle_p2& persPart,
                                             ParticlesMap_t& partToEndVtx, HepMC::DataPool* datapools ) const
 {
+#ifdef HEPMC3
+  DataPool<HepMC::GenParticlePtr>& poolOfParticles = datapools->part;
+  HepMC::GenParticlePtr p;
+  p->set_momentum( HepMC::FourVector(persPart.m_px,persPart.m_py,persPart.m_pz, persPart.m_ene ));
+  p->set_pdg_id(               persPart.m_pdgId);
+  p->set_status(               persPart.m_status);
+  //p->m_polarization.m_theta= static_cast<double>(persPart.m_thetaPolarization);
+  //p->m_polarization.m_phi  = static_cast<double>(persPart.m_phiPolarization  );
+  //p->m_production_vertex   = 0;
+  //p->m_end_vertex          = 0;
+  //p->m_barcode             = persPart.m_barcode;
+
+  // fillin' the flow
+  const unsigned int nFlow = persPart.m_flow.size();
+  for ( unsigned int iFlow= 0; iFlow != nFlow; ++iFlow ) {
+    //p->m_flow.set_icode( persPart.m_flow[iFlow].first,persPart.m_flow[iFlow].second );
+  }
+#else
   DataPool<HepMC::GenParticle>& poolOfParticles = datapools->part;
   HepMC::GenParticlePtr p    = poolOfParticles.nextElementPtr();
   p->m_momentum.setPx( persPart.m_px  );
@@ -218,6 +311,7 @@ McEventCollectionCnv_p2::createGenParticle( const GenParticle_p2& persPart,
     p->m_flow.set_icode( persPart.m_flow[iFlow].first,
                          persPart.m_flow[iFlow].second );
   }
+#endif
 
   if ( persPart.m_endVtx != 0 ) {
     partToEndVtx[p] = persPart.m_endVtx;
diff --git a/Generators/GeneratorObjectsTPCnv/src/McEventCollectionCnv_p3.cxx b/Generators/GeneratorObjectsTPCnv/src/McEventCollectionCnv_p3.cxx
index 6a6383de3e96..ff07475dcbf5 100755
--- a/Generators/GeneratorObjectsTPCnv/src/McEventCollectionCnv_p3.cxx
+++ b/Generators/GeneratorObjectsTPCnv/src/McEventCollectionCnv_p3.cxx
@@ -83,6 +83,9 @@ void McEventCollectionCnv_p3::persToTrans( const McEventCollection_p3* persObj,
     const GenEvent_p3& persEvt = *itr;
 
     HepMC::GenEvent * genEvt        = poolOfEvents.nextElementPtr();
+#ifdef HEPMC3
+
+#else
     genEvt->m_signal_process_id     = persEvt.m_signalProcessId;
     genEvt->m_event_number          = persEvt.m_eventNbr;
     genEvt->m_event_scale           = persEvt.m_eventScale;
@@ -96,6 +99,7 @@ void McEventCollectionCnv_p3::persToTrans( const McEventCollection_p3* persObj,
     genEvt->m_pdf_info = 0;         //> not available at that time...
 
     transObj->push_back( genEvt );
+#endif
 
     // create a temporary map associating the barcode of an end-vtx to its
     // particle.
@@ -163,6 +167,11 @@ McEventCollectionCnv_p3::createGenVertex( const McEventCollection_p3& persEvt,
                                           ParticlesMap_t& partToEndVtx,
                                           HepMC::DataPool* datapools ) const
 {
+
+#ifdef HEPMC3
+  DataPool<HepMC::GenVertexPtr>& poolOfVertices = datapools->vtx;
+  HepMC::GenVertexPtr vtx=*(poolOfVertices.nextElementPtr());
+#else
   DataPool<HepMC::GenVertex>& poolOfVertices = datapools->vtx;
   HepMC::GenVertexPtr vtx = poolOfVertices.nextElementPtr();
   vtx->m_position.setX( persVtx.m_x );
@@ -177,6 +186,7 @@ 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();
@@ -202,6 +212,14 @@ McEventCollectionCnv_p3::createGenParticle( const GenParticle_p3& persPart,
                                             ParticlesMap_t& partToEndVtx,
                                             HepMC::DataPool* datapools ) const
 {
+
+#ifdef HEPMC3
+  DataPool<HepMC::GenParticlePtr>& poolOfParticles = datapools->part;
+  HepMC::GenParticlePtr p    = *(poolOfParticles.nextElementPtr());
+  p->set_pdg_id(              persPart.m_pdgId);
+  p->set_status(              persPart.m_status);
+
+#else
   DataPool<HepMC::GenParticle>& poolOfParticles = datapools->part;
   HepMC::GenParticlePtr p    = poolOfParticles.nextElementPtr();
   p->m_pdg_id              = persPart.m_pdgId;
@@ -250,6 +268,7 @@ McEventCollectionCnv_p3::createGenParticle( const GenParticle_p3& persPart,
   if ( persPart.m_endVtx != 0 ) {
     partToEndVtx[p] = persPart.m_endVtx;
   }
+#endif
 
   return p;
 }
diff --git a/Generators/GeneratorObjectsTPCnv/src/McEventCollectionCnv_p4.cxx b/Generators/GeneratorObjectsTPCnv/src/McEventCollectionCnv_p4.cxx
index db580216dada..e6b4bd4d7486 100755
--- a/Generators/GeneratorObjectsTPCnv/src/McEventCollectionCnv_p4.cxx
+++ b/Generators/GeneratorObjectsTPCnv/src/McEventCollectionCnv_p4.cxx
@@ -1,4 +1,4 @@
-///////////////////////// -*- C++ -*- /////////////////////////////
+ ///////////////////////// -*- C++ -*- /////////////////////////////
 
 /*
   Copyright (C) 2002-2020 CERN for the benefit of the ATLAS collaboration
@@ -107,6 +107,36 @@ void McEventCollectionCnv_p4::persToTrans( const McEventCollection_p4* persObj,
         {
           genEvt        =  poolOfEvents.nextElementPtr();
         }
+#ifdef HEPMC3
+      printf("OK1");
+      genEvt->add_attribute("signal_process_id",std::make_shared<HepMC3::IntAttribute>(persEvt.m_signalProcessId));
+      genEvt->set_event_number(persEvt.m_eventNbr);
+      genEvt->add_attribute("event_scale",std::make_shared<HepMC3::DoubleAttribute>(persEvt.m_eventScale));
+      genEvt->add_attribute("alphaQCD",std::make_shared<HepMC3::DoubleAttribute>(persEvt.m_alphaQCD));
+      genEvt->add_attribute("alphaQED",std::make_shared<HepMC3::DoubleAttribute>(persEvt.m_alphaQED));
+
+      //      genEvt->m_signal_process_vertex = 0;
+      genEvt->add_attribute("signal_process_vertex",std::make_shared<HepMC3::IntAttribute>(0));
+ //     genEvt->m_weights               = persEvt.m_weights;
+ //     genEvt->m_random_states         = persEvt.m_randomStates;
+      //restore weight names from the dedicated svc (which was keeping them in metadata for efficiency)
+    //  genEvt->m_weights.m_names = m_hepMCWeightSvc->weightNames();
+      // pdfinfo restore
+    //  delete genEvt->m_pdf_info; genEvt->m_pdf_info = 0;
+      /*
+      if (!persEvt.m_pdfinfo.empty())
+        {
+          const std::vector<double>& pdf = persEvt.m_pdfinfo;
+          genEvt->m_pdf_info = new HepMC::PdfInfo
+            ( static_cast<int>(pdf[6]), // id1
+              static_cast<int>(pdf[5]), // id2
+              pdf[4],                   // x1
+              pdf[3],                   // x2
+              pdf[2],                   // scalePDF
+              pdf[1],                   // pdf1
+              pdf[0] );                 // pdf2
+        }*/
+#else
       genEvt->m_signal_process_id     = persEvt.m_signalProcessId;
       genEvt->m_event_number          = persEvt.m_eventNbr;
       genEvt->m_event_scale           = persEvt.m_eventScale;
@@ -134,9 +164,10 @@ void McEventCollectionCnv_p4::persToTrans( const McEventCollection_p4* persObj,
               pdf[1],                   // pdf1
               pdf[0] );                 // pdf2
         }
-
+#endif
+printf("OK2");
       transObj->push_back( genEvt );
-
+printf("OK3");
       // 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
@@ -205,6 +236,71 @@ void McEventCollectionCnv_p4::transToPers( const McEventCollection* transObj,
         itr != itrEnd;
         ++itr )
     {
+#ifdef HEPMC3 
+      const unsigned int nPersVtx   = persObj->m_genVertices.size();
+      const unsigned int nPersParts = persObj->m_genParticles.size();
+      const HepMC::GenEvent* genEvt = *itr;
+      //const int signalProcessVtx = genEvt->m_signal_process_vertex? genEvt->m_signal_process_vertex->barcode(): 0;
+      //save the weight names to metadata via the HepMCWeightSvc
+      // m_hepMCWeightSvc->setWeightNames( genEvt->m_weights.m_names ).ignore(); 
+      auto A_signal_process_id=genEvt->attribute<HepMC3::IntAttribute>("signal_process_id");    
+      persObj->m_genEvents.
+      push_back( GenEvent_p4( A_signal_process_id?(A_signal_process_id->value()):0,
+                                genEvt->event_number(),
+                                1,
+                                1,
+                                1,
+                                0,
+                                std::vector<double>(),
+                                std::vector<double>(),
+                                std::vector<long>(),
+                                nPersVtx,
+                                nPersVtx + genEvt->vertices().size(),
+                                nPersParts,
+                                nPersParts + genEvt->particles().size() ) );
+
+
+
+
+  /*       persObj->m_genEvents.
+        push_back( GenEvent_p4( genEvt->m_signal_process_id,
+                                genEvt->m_event_number,
+                                genEvt->m_event_scale,
+                                genEvt->m_alphaQCD,
+                                genEvt->m_alphaQED,
+                                signalProcessVtx,
+                                genEvt->m_weights.m_weights,
+                                std::vector<double>(),
+                                genEvt->m_random_states,
+                                nPersVtx,
+                                nPersVtx + genEvt->vertices_size(),
+                                nPersParts,
+                                nPersParts + genEvt->particles_size() ) );
+      //PdfInfo encoding
+   if (genEvt->m_pdf_info)
+        {
+          GenEvent_p4& persEvt = persObj->m_genEvents.back();
+          std::vector<double>& pdfinfo = persEvt.m_pdfinfo;
+          pdfinfo.resize(7);
+          pdfinfo[6] = static_cast<double>(genEvt->m_pdf_info->m_id1);
+          pdfinfo[5] = static_cast<double>(genEvt->m_pdf_info->m_id2);
+          pdfinfo[4] = genEvt->m_pdf_info->m_x1;
+          pdfinfo[3] = genEvt->m_pdf_info->m_x2;
+          pdfinfo[2] = genEvt->m_pdf_info->m_scalePDF;
+          pdfinfo[1] = genEvt->m_pdf_info->m_pdf1;
+          pdfinfo[0] = genEvt->m_pdf_info->m_pdf2;
+        }
+
+      // create vertices
+      const HepMC::GenEvent::vertex_const_iterator endVtx=genEvt->vertices_end();
+      for ( HepMC::GenEvent::vertex_const_iterator i = genEvt->vertices_begin();
+            i != endVtx;
+            ++i )
+        {
+          writeGenVertex( **i, *persObj );
+        }
+*/
+#else
       const unsigned int nPersVtx   = persObj->m_genVertices.size();
       const unsigned int nPersParts = persObj->m_genParticles.size();
       const HepMC::GenEvent* genEvt = *itr;
@@ -250,6 +346,7 @@ void McEventCollectionCnv_p4::transToPers( const McEventCollection* transObj,
         {
           writeGenVertex( **i, *persObj );
         }
+#endif
 
     } //> end loop over GenEvents
 
@@ -265,8 +362,45 @@ McEventCollectionCnv_p4::createGenVertex( const McEventCollection_p4& persEvt,
                                           ParticlesMap_t& partToEndVtx,
                                           HepMC::DataPool* datapools ) const
 {
-  DataPool<HepMC::GenVertex>& poolOfVertices = datapools->vtx;
+  
+#ifdef HEPMC3
+  DataPool<HepMC::GenVertexPtr>& poolOfVertices = datapools->vtx;
   HepMC::GenVertexPtr vtx(0);
+  if(m_isPileup)
+    {
+      vtx=HepMC::newGenVertexPtr();
+    }
+  else
+    {
+      vtx = *(poolOfVertices.nextElementPtr());
+    }
+  vtx->set_position(HepMC::FourVector( persVtx.m_x , persVtx.m_y , persVtx.m_z ,persVtx.m_t ));
+//  vtx->m_id      = persVtx.m_id;
+//  vtx->m_weights.m_weights.reserve( persVtx.m_weights.size() );
+//  vtx->m_weights.m_weights.assign ( persVtx.m_weights.begin(),persVtx.m_weights.end() );
+//  vtx->m_event   = 0;
+//  vtx->m_barcode = 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 );
+    }
+
+  // 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 ) );
+    }
+#else
+  DataPool<HepMC::GenVertex>& poolOfVertices = datapools->vtx;
+    HepMC::GenVertexPtr vtx(0);
   if(m_isPileup)
     {
       vtx=HepMC::newGenVertexPtr();
@@ -305,6 +439,7 @@ McEventCollectionCnv_p4::createGenVertex( const McEventCollection_p4& persEvt,
                                                 partToEndVtx,
                                                 datapools ) );
     }
+#endif
 
   return vtx;
 }
@@ -314,7 +449,67 @@ McEventCollectionCnv_p4::createGenParticle( const GenParticle_p4& persPart,
                                             ParticlesMap_t& partToEndVtx,
                                             HepMC::DataPool* datapools ) const
 {
-  DataPool<HepMC::GenParticle>& poolOfParticles = datapools->part;
+#ifdef HEPMC3
+  DataPool<HepMC::GenParticlePtr>& poolOfParticles = datapools->part;
+  HepMC::GenParticlePtr p(0);
+  if (m_isPileup)
+    {
+      p = HepMC::newGenParticlePtr();
+    }
+  else
+    {
+      p    = *(poolOfParticles.nextElementPtr());
+    }
+  p->set_pdg_id(              persPart.m_pdgId);
+  p->set_status(              persPart.m_status);
+  //p->m_polarization.m_theta= static_cast<double>(persPart.m_thetaPolarization);
+  //p->m_polarization.m_phi  = static_cast<double>(persPart.m_phiPolarization  );
+  //p->m_production_vertex   = 0;
+  //p->m_end_vertex          = 0;
+  //p->m_barcode             = persPart.m_barcode;
+
+  // Note: do the E calculation in extended (long double) precision.
+  // That happens implicitly on x86 with optimization on; saying it
+  // explicitly ensures that we get the same results with and without
+  // 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 )
+    {
+      double temp_e = std::sqrt( (long double)(persPart.m_px)*persPart.m_px +
+                            (long double)(persPart.m_py)*persPart.m_py +
+                            (long double)(persPart.m_pz)*persPart.m_pz +
+                            (long double)(persPart.m_m) *persPart.m_m );
+      p->set_momentum( HepMC::FourVector(persPart.m_px,persPart.m_px,persPart.m_px,temp_e));
+    }
+  else
+    {
+      const int signM2 = ( persPart.m_m >= 0. ? 1 : -1 );
+      const double persPart_ene =
+        std::sqrt( std::abs((long double)(persPart.m_px)*persPart.m_px +
+                  (long double)(persPart.m_py)*persPart.m_py +
+                  (long double)(persPart.m_pz)*persPart.m_pz +
+                  signM2* (long double)(persPart.m_m)* persPart.m_m));
+      const int signEne = ( persPart.m_recoMethod == 1 ? 1 : -1 );
+     p->set_momentum( HepMC::FourVector( persPart.m_px,
+                         persPart.m_py,
+                         persPart.m_pz,
+                         signEne * persPart_ene ));
+    }
+
+  // setup flow
+  const unsigned int nFlow = persPart.m_flow.size();
+  for ( unsigned int iFlow= 0; iFlow != nFlow; ++iFlow )
+    {
+      //p->m_flow.set_icode( persPart.m_flow[iFlow].first, persPart.m_flow[iFlow].second );
+    }
+
+  if ( persPart.m_endVtx != 0 )
+    {
+      partToEndVtx[p] = persPart.m_endVtx;
+    }
+
+#else
+DataPool<HepMC::GenParticle>& poolOfParticles = datapools->part;
   HepMC::GenParticlePtr p(0);
   if (m_isPileup)
     {
@@ -381,9 +576,44 @@ McEventCollectionCnv_p4::createGenParticle( const GenParticle_p4& persPart,
       partToEndVtx[p] = persPart.m_endVtx;
     }
 
+#endif
   return p;
 }
 
+#ifdef HEPMC3
+void McEventCollectionCnv_p4::writeGenVertex( const HepMC::GenVertexPtr vtx,
+                                              McEventCollection_p4& persEvt ) const
+{                                              
+  const HepMC::FourVector& position = vtx->position();
+  std::vector<double> foo;
+  persEvt.m_genVertices.push_back(
+                                  GenVertex_p4( position.x(),
+                                                position.y(),
+                                                position.z(),
+                                                position.t(),
+                                                vtx->id(),
+                                                foo.begin(),//vtx.m_weights.m_weights.begin(),
+                                                foo.end(),//vtx.m_weights.m_weights.end(),
+                                                0//HepMC::barcode(vtx)
+                                                ) );
+  GenVertex_p4& persVtx = persEvt.m_genVertices.back();
+  // we write only the orphans in-coming particles
+  persVtx.m_particlesIn.reserve(vtx->particles_in().size());
+  for ( auto p: vtx->particles_in())
+    {
+      if ( !p->production_vertex() )
+        {
+          persVtx.m_particlesIn.push_back( writeGenParticle(p, persEvt ));
+        }
+    }
+  persVtx.m_particlesOut.reserve(vtx->particles_out().size());
+  for ( auto p: vtx->particles_out())
+    {
+      persVtx.m_particlesOut.push_back( writeGenParticle(p, persEvt ) );
+    }
+  return;
+}                                              
+#else
 void McEventCollectionCnv_p4::writeGenVertex( const HepMC::GenVertex& vtx,
                                               McEventCollection_p4& persEvt ) const
 {
@@ -423,7 +653,51 @@ void McEventCollectionCnv_p4::writeGenVertex( const HepMC::GenVertex& vtx,
 
   return;
 }
+#endif
 
+#ifdef HEPMC3
+int McEventCollectionCnv_p4::writeGenParticle( const HepMC::GenParticlePtr p,
+                                               McEventCollection_p4& persEvt ) const
+{                                               
+  const HepMC::FourVector& mom = p->momentum();
+  const double ene = mom.e();
+  const double m2  = mom.m2();
+
+  // Definitions of Bool isTimeLilike, isSpacelike and isLightlike according to HepLorentzVector definition
+  const bool useP2M2 = !(m2 > 0) &&   // !isTimelike
+    (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
+                                 ? 1
+                                 : 2 ) );
+
+    persEvt.m_genParticles.
+    push_back( GenParticle_p4( mom.px(),
+                               mom.py(),
+                               mom.pz(),
+                               mom.m(),
+                               p->pdg_id(),
+                               p->status(),
+                               0,//p.m_flow.size(),
+                               0,//p.m_polarization.theta(),
+                               0,//p.m_polarization.phi(),
+                               0,//p.m_production_vertex? p.m_production_vertex->barcode(): 0,
+                               0,//p.m_end_vertex? p.m_end_vertex->barcode(): 0,
+                               HepMC::barcode(p),
+                               recoMethod ) );
+  //persEvt.m_genParticles.back().m_flow.assign( p.m_flow.begin(),p.m_flow.end() );
+
+  // we return the index of the particle in the big vector of particles
+  // (contained by the persistent GenEvent)
+  return (persEvt.m_genParticles.size() - 1);
+}                                               
+#else
 int McEventCollectionCnv_p4::writeGenParticle( const HepMC::GenParticle& p,
                                                McEventCollection_p4& persEvt ) const
 {
@@ -467,6 +741,7 @@ int McEventCollectionCnv_p4::writeGenParticle( const HepMC::GenParticle& p,
   // (contained by the persistent GenEvent)
   return (persEvt.m_genParticles.size() - 1);
 }
+#endif
 
 void McEventCollectionCnv_p4::setPileup()
 {
diff --git a/Generators/GeneratorObjectsTPCnv/src/McEventCollectionCnv_p5.cxx b/Generators/GeneratorObjectsTPCnv/src/McEventCollectionCnv_p5.cxx
index a769cb98d3f4..717af7f03c4a 100755
--- a/Generators/GeneratorObjectsTPCnv/src/McEventCollectionCnv_p5.cxx
+++ b/Generators/GeneratorObjectsTPCnv/src/McEventCollectionCnv_p5.cxx
@@ -93,6 +93,139 @@ void McEventCollectionCnv_p5::persToTrans( const McEventCollection_p5* persObj,
     } else {
       genEvt        =  poolOfEvents.nextElementPtr();
     }
+#ifdef HEPMC3
+  
+  
+
+//   genEvt->m_signal_process_id     = persEvt.m_signalProcessId;
+//    genEvt->m_event_number          = persEvt.m_eventNbr;
+   genEvt->add_attribute("signal_process_id",std::make_shared<HepMC3::IntAttribute>(persEvt.m_signalProcessId));
+
+   genEvt->set_event_number(persEvt.m_eventNbr);
+/*
+    genEvt->m_mpi                   = persEvt.m_mpi;
+    genEvt->m_event_scale           = persEvt.m_eventScale;
+    genEvt->m_alphaQCD              = persEvt.m_alphaQCD;
+    genEvt->m_alphaQED              = persEvt.m_alphaQED;
+    genEvt->m_signal_process_vertex = 0;
+    genEvt->m_beam_particle_1       = 0;
+    genEvt->m_beam_particle_2       = 0;
+    genEvt->m_weights               = persEvt.m_weights;
+    genEvt->m_random_states         = persEvt.m_randomStates;
+    genEvt->m_vertex_barcodes.clear();
+    genEvt->m_particle_barcodes.clear();
+    genEvt->m_momentum_unit         = static_cast<HepMC::Units::MomentumUnit>(persEvt.m_momentumUnit);
+    genEvt->m_position_unit         = static_cast<HepMC::Units::LengthUnit>(persEvt.m_lengthUnit);
+
+    //restore weight names from the dedicated svc (which was keeping them in metadata for efficiency)
+    genEvt->m_weights.m_names = m_hepMCWeightSvc->weightNames();
+
+    // cross-section restore
+    if( genEvt->m_cross_section )
+      delete genEvt->m_cross_section;
+    genEvt->m_cross_section = 0;
+
+    genEvt->m_cross_section = new HepMC::GenCrossSection();
+    if (!persEvt.m_crossSection.empty()) {
+      const std::vector<double>& xsection = persEvt.m_crossSection;
+      if( static_cast<bool>(xsection[0]) )
+        genEvt->m_cross_section->set_cross_section(xsection[2],xsection[1]);
+    }
+
+    // heavyIon restore
+    if(genEvt->m_heavy_ion )
+      delete genEvt->m_heavy_ion;
+    genEvt->m_heavy_ion = 0;
+    if (!persEvt.m_heavyIon.empty()) {
+      const std::vector<float>& hIon = persEvt.m_heavyIon;
+      genEvt->m_heavy_ion = new HepMC::HeavyIon
+        (
+         static_cast<int>(hIon[12]), // Ncoll_hard
+         static_cast<int>(hIon[11]), // Npart_proj
+         static_cast<int>(hIon[10]), // Npart_targ
+         static_cast<int>(hIon[9]), // Ncoll
+         static_cast<int>(hIon[8]), // spectator_neutrons
+         static_cast<int>(hIon[7]), // spectator_protons
+         static_cast<int>(hIon[6]), // N_Nwounded_collisions
+         static_cast<int>(hIon[5]), // Nwounded_N_collisions
+         static_cast<int>(hIon[4]), // Nwounded_Nwounded_collisions
+         hIon[3],                   // impact_parameter
+         hIon[2],                  // event_plane_angle
+         hIon[1],                  // eccentricity
+         hIon[0]         );         // sigma_inel_NN
+    }
+
+
+
+    // pdfinfo restore
+    if(genEvt->m_pdf_info)
+      delete genEvt->m_pdf_info;
+    genEvt->m_pdf_info = 0;
+    if (!persEvt.m_pdfinfo.empty()) {
+      const std::vector<double>& pdf = persEvt.m_pdfinfo;
+      genEvt->m_pdf_info = new HepMC::PdfInfo
+        (
+         static_cast<int>(pdf[8]), // id1
+         static_cast<int>(pdf[7]), // id2
+         pdf[4],                   // x1
+         pdf[3],                   // x2
+         pdf[2],                   // scalePDF
+         pdf[1],                   // pdf1
+         pdf[0],                   // pdf2
+         static_cast<int>(pdf[6]), // pdf_id1
+         static_cast<int>(pdf[5])  // pdf_id2
+         );
+    }
+*/
+    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
+    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 ) );
+    } //> end loop over vertices
+
+    // set the signal process vertex
+    const int sigProcVtx = persEvt.m_signalProcessVtx;
+    if ( sigProcVtx != 0 ) {
+      genEvt->set_signal_process_vertex( genEvt->barcode_to_vertex( sigProcVtx ) );
+    }
+
+    // connect particles to their end vertices
+    for ( ParticlesMap_t::iterator
+            p = partToEndVtx.begin(),
+            endItr = partToEndVtx.end();
+          p != endItr;
+          ++p ) {
+      auto decayVtx = HepMC::barcode_to_vertex(genEvt, p->second );
+      if ( decayVtx ) {
+        decayVtx->add_particle_in( p->first );
+      } else {
+        msg << MSG::ERROR
+            << "GenParticle points to null end vertex !!"
+            << endmsg;
+      }
+    }
+
+    // set the beam particles
+    const int beamPart1 = persEvt.m_beamParticle1;
+    const int beamPart2 = persEvt.m_beamParticle2;
+    if (  beamPart1 != 0  &&  beamPart2 !=0 ) {
+      genEvt->set_beam_particles(genEvt->barcode_to_particle(beamPart1),
+                                 genEvt->barcode_to_particle(beamPart2));
+    }
+*/
+#else  
     genEvt->m_signal_process_id     = persEvt.m_signalProcessId;
     genEvt->m_event_number          = persEvt.m_eventNbr;
     genEvt->m_mpi                   = persEvt.m_mpi;
@@ -217,6 +350,7 @@ void McEventCollectionCnv_p5::persToTrans( const McEventCollection_p5* persObj,
                                  genEvt->barcode_to_particle(beamPart2));
     }
 
+#endif
 
 
   } //> end loop over m_genEvents
@@ -246,6 +380,99 @@ void McEventCollectionCnv_p5::transToPers( const McEventCollection* transObj,
     const unsigned int nPersVtx   = persObj->m_genVertices.size();
     const unsigned int nPersParts = persObj->m_genParticles.size();
     const HepMC::GenEvent* genEvt = *itr;
+#ifdef HEPMC3
+/*    const int signalProcessVtx = genEvt->m_signal_process_vertex
+      ? genEvt->m_signal_process_vertex->barcode()
+      : 0;
+    const int beamParticle1Barcode = genEvt->m_beam_particle_1
+      ? genEvt->m_beam_particle_1->barcode()
+      : 0;
+    const int beamParticle2Barcode = genEvt->m_beam_particle_2
+      ? genEvt->m_beam_particle_2->barcode()
+      : 0;
+
+   //save the weight names to metadata via the HepMCWeightSvc 
+   m_hepMCWeightSvc->setWeightNames( genEvt->m_weights.m_names ).ignore();
+   */
+ auto A_signal_process_id=genEvt->attribute<HepMC3::IntAttribute>("signal_process_id");
+    persObj->m_genEvents.
+      push_back( GenEvent_p5(A_signal_process_id?(A_signal_process_id->value()):0,
+                              genEvt->event_number(),
+                              0,//genEvt->mpi(),              // number of multi particle interactions
+                              0,//genEvt->m_event_scale,
+                              0,//genEvt->m_alphaQCD,
+                              0,//genEvt->m_alphaQED,
+                              0,//signalProcessVtx,
+                              0,//beamParticle1Barcode,       // barcodes of beam particles
+                              0,//beamParticle2Barcode,
+                              std::vector<double>(),//genEvt->m_weights.m_weights,
+                              std::vector<long>(),//genEvt->m_random_states,
+                              std::vector<double>(),      // cross section
+                              std::vector<float>(),       // heavyion
+                              std::vector<double>(),      // pdf info
+                              0,//genEvt->m_momentum_unit,
+                              0,//genEvt->m_position_unit,
+                              nPersVtx,
+                              nPersVtx + genEvt->vertices().size(),
+                              nPersParts,
+                              nPersParts + genEvt->particles().size() ) );
+    
+    
+    /*
+    //HepMC::GenCrossSection encoding
+    if (genEvt->m_cross_section) {
+      GenEvent_p5& persEvt = persObj->m_genEvents.back();
+      std::vector<double>& crossSection = persEvt.m_crossSection;
+      crossSection.resize(3);
+      crossSection[2] = genEvt->m_cross_section->m_cross_section;
+      crossSection[1] = genEvt->m_cross_section->m_cross_section_error;
+      crossSection[0] = static_cast<double>(genEvt->m_cross_section->m_is_set);
+    }
+
+    //HepMC::HeavyIon encoding
+    if (genEvt->m_heavy_ion) {
+      GenEvent_p5& persEvt = persObj->m_genEvents.back();
+      std::vector<float>& heavyIon = persEvt.m_heavyIon;
+      heavyIon.resize(13);
+      heavyIon[12]  = static_cast<float>(genEvt->m_heavy_ion->m_Ncoll_hard);
+      heavyIon[11]  = static_cast<float>(genEvt->m_heavy_ion->m_Npart_proj);
+      heavyIon[10]  = static_cast<float>(genEvt->m_heavy_ion->m_Npart_targ);
+      heavyIon[9]   = static_cast<float>(genEvt->m_heavy_ion->m_Ncoll);
+      heavyIon[8]   = static_cast<float>(genEvt->m_heavy_ion->m_spectator_neutrons);
+      heavyIon[7]   = static_cast<float>(genEvt->m_heavy_ion->m_spectator_protons);
+      heavyIon[6]   = static_cast<float>(genEvt->m_heavy_ion->m_N_Nwounded_collisions);
+      heavyIon[5]   = static_cast<float>(genEvt->m_heavy_ion->m_Nwounded_N_collisions);
+      heavyIon[4]   = static_cast<float>(genEvt->m_heavy_ion->m_Nwounded_Nwounded_collisions);
+      heavyIon[3]   = genEvt->m_heavy_ion->m_impact_parameter;
+      heavyIon[2]   = genEvt->m_heavy_ion->m_event_plane_angle;
+      heavyIon[1]   = genEvt->m_heavy_ion->m_eccentricity;
+      heavyIon[0]   = genEvt->m_heavy_ion->m_sigma_inel_NN;
+    }
+
+    //PdfInfo encoding
+    if (genEvt->m_pdf_info) {
+      GenEvent_p5& persEvt = persObj->m_genEvents.back();
+      std::vector<double>& pdfinfo = persEvt.m_pdfinfo;
+      pdfinfo.resize(9);
+      pdfinfo[8] = static_cast<double>(genEvt->m_pdf_info->m_id1);
+      pdfinfo[7] = static_cast<double>(genEvt->m_pdf_info->m_id2);
+      pdfinfo[6] = static_cast<double>(genEvt->m_pdf_info->m_pdf_id1);
+      pdfinfo[5] = static_cast<double>(genEvt->m_pdf_info->m_pdf_id2);
+      pdfinfo[4] = genEvt->m_pdf_info->m_x1;
+      pdfinfo[3] = genEvt->m_pdf_info->m_x2;
+      pdfinfo[2] = genEvt->m_pdf_info->m_scalePDF;
+      pdfinfo[1] = genEvt->m_pdf_info->m_pdf1;
+      pdfinfo[0] = genEvt->m_pdf_info->m_pdf2;
+    }
+
+    // create vertices
+    const HepMC::GenEvent::vertex_const_iterator endVtx=genEvt->vertices_end();
+    for ( HepMC::GenEvent::vertex_const_iterator i = genEvt->vertices_begin();
+          i != endVtx;
+          ++i ) {
+      writeGenVertex( **i, *persObj );
+    }*/
+#else
     const int signalProcessVtx = genEvt->m_signal_process_vertex
       ? genEvt->m_signal_process_vertex->barcode()
       : 0;
@@ -334,6 +561,7 @@ void McEventCollectionCnv_p5::transToPers( const McEventCollection* transObj,
           ++i ) {
       writeGenVertex( **i, *persObj );
     }
+#endif
 
   } //> end loop over GenEvents
 
@@ -349,8 +577,15 @@ McEventCollectionCnv_p5::createGenVertex( const McEventCollection_p5& persEvt,
                                           ParticlesMap_t& partToEndVtx, HepMC::DataPool* datapools
                                           ) const
 {
+#ifdef HEPMC3
+  DataPool<HepMC::GenVertexPtr>& poolOfVertices = datapools->vtx;
+#else
   DataPool<HepMC::GenVertex>& poolOfVertices = datapools->vtx;
+#endif
   HepMC::GenVertexPtr vtx(0);
+#ifdef HEPMC3
+
+#else
   if(m_isPileup) {
     vtx=HepMC::newGenVertexPtr();
   } else {
@@ -385,6 +620,7 @@ McEventCollectionCnv_p5::createGenVertex( const McEventCollection_p5& persEvt,
                                               datapools ) );
   }
 
+#endif
   return vtx;
 }
 
@@ -392,8 +628,16 @@ HepMC::GenParticlePtr
 McEventCollectionCnv_p5::createGenParticle( const GenParticle_p5& persPart,
                                             ParticlesMap_t& partToEndVtx, HepMC::DataPool* datapools ) const
 {
+
+#ifdef HEPMC3
+  DataPool<HepMC::GenParticlePtr>& poolOfParticles = datapools->part;
+#else
   DataPool<HepMC::GenParticle>& poolOfParticles = datapools->part;
+#endif
   HepMC::GenParticlePtr p(0);
+#ifdef HEPMC3
+
+#else
   if (m_isPileup) {
     p = HepMC::newGenParticlePtr();
   } else {
@@ -449,12 +693,21 @@ McEventCollectionCnv_p5::createGenParticle( const GenParticle_p5& persPart,
     partToEndVtx[p] = persPart.m_endVtx;
   }
 
+#endif
   return p;
 }
+#ifdef HEPMC3
 
+void McEventCollectionCnv_p5::writeGenVertex( const HepMC::GenVertexPtr vtx,
+                                              McEventCollection_p5& persEvt ) const
+#else
 void McEventCollectionCnv_p5::writeGenVertex( const HepMC::GenVertex& vtx,
                                               McEventCollection_p5& persEvt ) const
+#endif
 {
+#ifdef HEPMC3
+  const HepMC::FourVector& position = vtx->position();
+#else
   const HepMC::FourVector& position = vtx.m_position;
   persEvt.m_genVertices.push_back(
                                   GenVertex_p5( position.x(),
@@ -465,6 +718,10 @@ void McEventCollectionCnv_p5::writeGenVertex( const HepMC::GenVertex& vtx,
                                                 vtx.m_weights.m_weights.begin(),
                                                 vtx.m_weights.m_weights.end(),
                                                 vtx.m_barcode ) );
+#endif
+#ifdef HEPMC3
+
+#else
   GenVertex_p5& persVtx = persEvt.m_genVertices.back();
 
   // we write only the orphans in-coming particles
@@ -486,13 +743,23 @@ void McEventCollectionCnv_p5::writeGenVertex( const HepMC::GenVertex& vtx,
     persVtx.m_particlesOut.push_back( writeGenParticle( **p, persEvt ) );
   }
 
+#endif
   return;
 }
 
+#ifdef HEPMC3
+int McEventCollectionCnv_p5::writeGenParticle( const HepMC::GenParticlePtr p,
+                                               McEventCollection_p5& persEvt ) const
+#else
 int McEventCollectionCnv_p5::writeGenParticle( const HepMC::GenParticle& p,
                                                McEventCollection_p5& persEvt ) const
+#endif
 {
+#ifdef HEPMC3
+  const HepMC::FourVector mom = p->momentum();
+#else
   const HepMC::FourVector& mom = p.m_momentum;
+#endif
   const double ene = mom.e();
   const double m2  = mom.m2();
 
@@ -507,6 +774,8 @@ int McEventCollectionCnv_p5::writeGenParticle( const HepMC::GenParticle& p,
                                  ? 1
                                  : 2 ) );
 
+#ifdef HEPMC3
+#else
 
   persEvt.m_genParticles.
     push_back( GenParticle_p5( mom.px(),
@@ -530,6 +799,7 @@ int McEventCollectionCnv_p5::writeGenParticle( const HepMC::GenParticle& p,
   persEvt.m_genParticles.back().m_flow.assign( p.m_flow.begin(),
                                                p.m_flow.end() );
 
+#endif
   // we return the index of the particle in the big vector of particles
   // (contained by the persistent GenEvent)
   return (persEvt.m_genParticles.size() - 1);
diff --git a/PhysicsAnalysis/AnalysisCommon/AnalysisTest/CMakeLists.txt b/PhysicsAnalysis/AnalysisCommon/AnalysisTest/CMakeLists.txt
index 5e99eea7a1fe..a1544af7aadd 100644
--- a/PhysicsAnalysis/AnalysisCommon/AnalysisTest/CMakeLists.txt
+++ b/PhysicsAnalysis/AnalysisCommon/AnalysisTest/CMakeLists.txt
@@ -23,6 +23,7 @@ atlas_depends_on_subdirs( PUBLIC
                           Control/AthenaKernel
                           Event/EventKernel
                           Event/FourMom
+                          Generators/AtlasHepMC
                           Generators/GeneratorObjects
                           PhysicsAnalysis/AnalysisCommon/AnalysisAssociation
                           PhysicsAnalysis/AnalysisCommon/AnalysisUtils
diff --git a/PhysicsAnalysis/TruthParticleID/McParticleTools/src/McVtxFilterTool.cxx b/PhysicsAnalysis/TruthParticleID/McParticleTools/src/McVtxFilterTool.cxx
index 95aaa5558937..b3a7447b747b 100755
--- a/PhysicsAnalysis/TruthParticleID/McParticleTools/src/McVtxFilterTool.cxx
+++ b/PhysicsAnalysis/TruthParticleID/McParticleTools/src/McVtxFilterTool.cxx
@@ -327,7 +327,7 @@ void McVtxFilterTool::addVertex( const HepMC::GenVertex* srcVtx,
   ATH_MSG_VERBOSE("In McVtxFilterTool::addVertex( vtxType= "<<vtxType<< " )");
   HepMC::GenVertex * vtx = evt->barcode_to_vertex(srcVtx->barcode());
   if ( 0 == vtx ) {
-    vtx = new HepMC::GenVertex();
+    vtx = HepMC::newGenVertexPtr();
     vtx->set_position( srcVtx->position() );
     vtx->set_id( srcVtx->id() );
     vtx->suggest_barcode( srcVtx->barcode() );
@@ -341,7 +341,7 @@ void McVtxFilterTool::addVertex( const HepMC::GenVertex* srcVtx,
 	++parent ) {
     HepMC::GenParticle * mother = evt->barcode_to_particle( (*parent)->barcode() );
     if ( 0 == mother ) {
-      mother = new HepMC::GenParticle;
+      mother = HepMC::newGenParticlePtr();
       mother->set_momentum( (*parent)->momentum() );
       mother->set_generated_mass( (*parent)->generated_mass() );
       mother->set_pdg_id( (*parent)->pdg_id() );
@@ -368,7 +368,7 @@ void McVtxFilterTool::addVertex( const HepMC::GenVertex* srcVtx,
 			<< (*child)->pdg_id() << "|" 
 			<< (*child)->barcode() << "]");
       } else {
-	daughter = new HepMC::GenParticle;
+	daughter = HepMC::newGenParticlePtr();
 	daughter->set_momentum( (*child)->momentum() );
    daughter->set_generated_mass( (*child)->generated_mass() );
 	daughter->set_pdg_id( (*child)->pdg_id() );
diff --git a/PhysicsAnalysis/TruthParticleID/McParticleTools/src/OldSpclMcFilterTool.cxx b/PhysicsAnalysis/TruthParticleID/McParticleTools/src/OldSpclMcFilterTool.cxx
index 17655a7d1207..888edd4999a8 100755
--- a/PhysicsAnalysis/TruthParticleID/McParticleTools/src/OldSpclMcFilterTool.cxx
+++ b/PhysicsAnalysis/TruthParticleID/McParticleTools/src/OldSpclMcFilterTool.cxx
@@ -608,7 +608,7 @@ StatusCode OldSpclMcFilterTool::rebuildLinks( const HepMC::GenEvent * mcEvt,
 		// create a GenVertex which will be the decay vertex of our
 		// GenParticle and the production vertex of the GenParticle
 		// we just found
-		HepMC::GenVertex * linkVtx = new HepMC::GenVertex();
+		HepMC::GenVertexPtr linkVtx = HepMC::newGenVertexPtr();
 		outEvt->add_vertex( linkVtx );
 		linkVtx->add_particle_in( mcPart );
 		linkVtx->add_particle_out( *itrPart );
diff --git a/PhysicsAnalysis/TruthParticleID/McParticleTools/src/PileupFilterTool.cxx b/PhysicsAnalysis/TruthParticleID/McParticleTools/src/PileupFilterTool.cxx
index 57ce5b8731ef..1ae2edd6ddd2 100755
--- a/PhysicsAnalysis/TruthParticleID/McParticleTools/src/PileupFilterTool.cxx
+++ b/PhysicsAnalysis/TruthParticleID/McParticleTools/src/PileupFilterTool.cxx
@@ -573,7 +573,7 @@ StatusCode PileupFilterTool::rebuildLinks( const HepMC::GenEvent * mcEvt,
 		// create a GenVertex which will be the decay vertex of our
 		// GenParticle and the production vertex of the GenParticle
 		// we just found
-		HepMC::GenVertex * linkVtx = new HepMC::GenVertex();
+		HepMC::GenVertexPtr linkVtx = HepMC::newGenVertexPtr();
 		outEvt->add_vertex( linkVtx );
 		linkVtx->add_particle_in( mcPart );
 		linkVtx->add_particle_out( *itrPart );
diff --git a/PhysicsAnalysis/TruthParticleID/McParticleUtils/test/McVtxFilterTest_CppUnit.cxx b/PhysicsAnalysis/TruthParticleID/McParticleUtils/test/McVtxFilterTest_CppUnit.cxx
index f205bc92ffae..29dfd2d6e5a9 100755
--- a/PhysicsAnalysis/TruthParticleID/McParticleUtils/test/McVtxFilterTest_CppUnit.cxx
+++ b/PhysicsAnalysis/TruthParticleID/McParticleUtils/test/McVtxFilterTest_CppUnit.cxx
@@ -81,15 +81,15 @@ public:
     m_evt->set_random_states( rdmStates );
     
     // Add 2 vertices
-    HepMC::GenVertex * v1 = new HepMC::GenVertex();
+    HepMC::GenVertex * v1 = HepMC::newGenVertexPtr();
     m_evt->add_vertex( v1 );
-    v1->add_particle_in( new HepMC::GenParticle( HLV_t(0,0,
+    v1->add_particle_in( HepMC::newGenParticlePtr( HepMC::FourVector(0,0,
 						       7000*GeV,
 						       7000*GeV),
 						 2212, 3 ) );
     HepMC::GenVertex* v2 = new HepMC::GenVertex;
     m_evt->add_vertex( v2 );
-    v2->add_particle_in( new HepMC::GenParticle( HLV_t(0,0,
+    v2->add_particle_in( HepMC::newGenParticlePtr( HepMC::FourVector(0,0,
 						       -7000*GeV,
 						       +7000*GeV),
 						 2212, 3 ) );
@@ -97,13 +97,13 @@ public:
     //
     // create the outgoing particles of v1 and v2
     HepMC::GenParticle* p3 = 
-      new HepMC::GenParticle( HLV_t(.750*GeV,
+      HepMC::newGenParticlePtr( HepMC::FourVector(.750*GeV,
 				    -1.569*GeV,
 				    32.191*GeV,
 				    32.238*GeV), 1, 3 );
     v1->add_particle_out( p3 );
     HepMC::GenParticle* p4 = 
-      new HepMC::GenParticle( HLV_t( -3.047*GeV,
+      HepMC::newGenParticlePtr( HepMC::FourVector( -3.047*GeV,
 				     -19.*GeV,
 				     -54.629*GeV,
 				     57.920*GeV), -2, 3 );
@@ -111,16 +111,16 @@ public:
     
     //
     // create v3
-    HepMC::GenVertex* v3 = new HepMC::GenVertex();
+    HepMC::GenVertex* v3 = HepMC::newGenVertexPtr();
     m_evt->add_vertex( v3 );
     v3->add_particle_in( p3 );
     v3->add_particle_in( p4 );
     v3->add_particle_out( 
-	new HepMC::GenParticle( HLV_t(-3.813,0.113,-1.833,4.233 ), 
+	HepMC::newGenParticlePtr( HepMC::FourVector(-3.813,0.113,-1.833,4.233 ), 
 				22, 1 )
 	);
     HepMC::GenParticle* p5 = 
-	new HepMC::GenParticle( HLV_t(1.517,-20.68,-20.605,85.925), 
+	HepMC::newGenParticlePtr( HepMC::FourVector(1.517,-20.68,-20.605,85.925), 
 				-24,3);
     v3->add_particle_out( p5 );
 
@@ -134,39 +134,39 @@ public:
     HepMC::GenVertex * vZgee = new HepMC::GenVertex;
     m_evt->add_vertex( vZgee );
     // Z0
-    vZgee->add_particle_in( new HepMC::GenParticle( HLV_t( -4.49e+04,
+    vZgee->add_particle_in( HepMC::newGenParticlePtr( HepMC::FourVector( -4.49e+04,
 							   +8.36e+03,
 							   -2.70e+05,
 							   +2.89e+05 ),
 						    23, 2 ) );
     // Gammas
-    vZgee->add_particle_out( new HepMC::GenParticle( HLV_t( -1.28e+03,
+    vZgee->add_particle_out( HepMC::newGenParticlePtr( HepMC::FourVector( -1.28e+03,
 							    +1.03e+03,
 							    -5.47e+03,
 							    +5.71e+03 ),
 						     22, 1 ) );
-    vZgee->add_particle_out( new HepMC::GenParticle( HLV_t( +3.89e+02,
+    vZgee->add_particle_out( HepMC::newGenParticlePtr( HepMC::FourVector( +3.89e+02,
 							    -3.16e+02,
 							    -6.69e+03,
 							    +6.70e+03 ),
 						     22, 1 ) );
-    vZgee->add_particle_out( new HepMC::GenParticle( HLV_t( +7.34e+00,
+    vZgee->add_particle_out( HepMC::newGenParticlePtr( HepMC::FourVector( +7.34e+00,
 							    -2.71e+01,
 							    -4.12e+01,
 							    +4.98e+01 ),
 						     22, 1 ) );
-    vZgee->add_particle_out( new HepMC::GenParticle( HLV_t( -1.36e+02,
+    vZgee->add_particle_out( HepMC::newGenParticlePtr( HepMC::FourVector( -1.36e+02,
 							    +9.38e+01,
 							    -5.62e+02,
 							    +5.86e+02 ),
 						     22, 1 ) );
     // Electrons
-    vZgee->add_particle_out( new HepMC::GenParticle( HLV_t( +8.01e+03,
+    vZgee->add_particle_out( HepMC::newGenParticlePtr( HepMC::FourVector( +8.01e+03,
 							    -2.96e+04,
 							    -4.50e+04,
 							    +5.44e+04 ),
 						     -11, 1 ) );
-    vZgee->add_particle_out( new HepMC::GenParticle( HLV_t( -5.19e+04,
+    vZgee->add_particle_out( HepMC::newGenParticlePtr( HepMC::FourVector( -5.19e+04,
 							    +3.72e+04,
 							    -2.13e+05,
 							    +2.22e+05 ),
@@ -178,18 +178,18 @@ public:
     // Add a Z->e+e-
     HepMC::GenVertex * vZee = new HepMC::GenVertex;
     m_evt->add_vertex( vZee );
-    vZee->add_particle_in( new HepMC::GenParticle( HLV_t( +7.29e+03,
+    vZee->add_particle_in( HepMC::newGenParticlePtr( HepMC::FourVector( +7.29e+03,
 							  +2.34e+04,
 							  +2.81e+05,
 							  +2.96e+05 ),
 						   23, 2 ) );
     
-    vZee->add_particle_out( new HepMC::GenParticle( HLV_t( +2.74e+04,
+    vZee->add_particle_out( HepMC::newGenParticlePtr( HepMC::FourVector( +2.74e+04,
 							   -1.83e+04,
 							   +4.70e+04,
 							   +5.74e+04 ),
 						    11, 1 ) );
-    vZee->add_particle_out( new HepMC::GenParticle( HLV_t( -2.01e+04,
+    vZee->add_particle_out( HepMC::newGenParticlePtr( HepMC::FourVector( -2.01e+04,
 							   +4.17e+04,
 							   +2.34e+05,
 							   +2.38e+05 ),
@@ -201,29 +201,29 @@ public:
     HepMC::GenVertex * vtWbgg = new HepMC::GenVertex;
     m_evt->add_vertex( vtWbgg );
     // top
-    vtWbgg->add_particle_in(new HepMC::GenParticle(HLV_t(-2.35e+05,
+    vtWbgg->add_particle_in(HepMC::newGenParticlePtr(HLV_t(-2.35e+05,
 							 +7.34e+04,
 							 +3.60e+04,
 							 +3.04e+05),
 						   6, 3 ) );
 
     // Wbgg
-    vtWbgg->add_particle_out(new HepMC::GenParticle(HLV_t(-1.09e+05,
+    vtWbgg->add_particle_out(HepMC::newGenParticlePtr(HLV_t(-1.09e+05,
 							  +6.99e+04,
 							  -3.86e+04,
 							  +1.57e+05),
 						    24, 2 ) );
-    vtWbgg->add_particle_out(new HepMC::GenParticle(HLV_t(-9.23e+04,
+    vtWbgg->add_particle_out(HepMC::newGenParticlePtr(HLV_t(-9.23e+04,
 							  +2.54e+03,
 							  +5.32e+04,
 							  +1.07e+05),
 						    5, 2 ) );
-    vtWbgg->add_particle_out(new HepMC::GenParticle(HLV_t(-4.76e+03,
+    vtWbgg->add_particle_out(HepMC::newGenParticlePtr(HLV_t(-4.76e+03,
 							  +6.72e+02,
 							  +2.90e+03,
 							  +5.62e+03),
 						    21, 2 ) );
-    vtWbgg->add_particle_out(new HepMC::GenParticle(HLV_t(-2.93e+04,
+    vtWbgg->add_particle_out(HepMC::newGenParticlePtr(HLV_t(-2.93e+04,
 							  +2.13e+02,
 							  +1.85e+04,
 							  +3.46e+04),
@@ -459,12 +459,12 @@ public:
   {
     HepMC::GenVertex * vtx = new HepMC::GenVertex;
     m_evt->add_vertex( vtx );
-    vtx->add_particle_in( new HepMC::GenParticle( HLV_t( -2.45e+04,
+    vtx->add_particle_in( HepMC::newGenParticlePtr( HepMC::FourVector( -2.45e+04,
 							 +1.88e+04,
 							 -8.65e+05,
 							 +8.65e+05 ),
 						  22, 3 ) );
-    vtx->add_particle_out( new HepMC::GenParticle( HLV_t( -2.45e+04,
+    vtx->add_particle_out( HepMC::newGenParticlePtr( HepMC::FourVector( -2.45e+04,
 							  +1.88e+04,
 							  -8.65e+05,
 							  +8.65e+05 ),
@@ -575,18 +575,18 @@ public:
     
     HepMC::GenVertex * vtx = new HepMC::GenVertex;
     m_evt->add_vertex( vtx );
-    vtx->add_particle_in( new HepMC::GenParticle( HLV_t( -6.76e+04,
+    vtx->add_particle_in( HepMC::newGenParticlePtr( HepMC::FourVector( -6.76e+04,
 							 +4.85e+03,
 							 -1.46e+03,
 							 +9.51e+04 ),
 						  -24, 2 ) );
-    vtx->add_particle_out( new HepMC::GenParticle( HLV_t( -7.14e+04,
+    vtx->add_particle_out( HepMC::newGenParticlePtr( HepMC::FourVector( -7.14e+04,
 							  -6.17e+03,
 							  +1.67e+04,
 							  +7.36e+04 ),
 						   13, 1 ) );
     
-    vtx->add_particle_out( new HepMC::GenParticle( HLV_t( +3.75e+03,
+    vtx->add_particle_out( HepMC::newGenParticlePtr( HepMC::FourVector( +3.75e+03,
 							  +1.10e+04,
 							  -1.81e+04,
 							  +2.15e+04 ),
@@ -627,18 +627,18 @@ GenVertex:      -39 ID:    0 (X,cT):0
     // create a b->g+b vertex
     HepMC::GenVertex * vtxgb = new HepMC::GenVertex;
     m_evt->add_vertex( vtxgb );
-    vtxgb->add_particle_in( new HepMC::GenParticle( HLV_t( -3.21e+04,
+    vtxgb->add_particle_in( HepMC::newGenParticlePtr( HepMC::FourVector( -3.21e+04,
 							   -6.19e+03,
 							   +5.05e+04,
 							   +6.38e+04 ),
 						    -5, 2 ) );
-    vtxgb->add_particle_out( new HepMC::GenParticle( HLV_t( -1.29e+04,
+    vtxgb->add_particle_out( HepMC::newGenParticlePtr( HepMC::FourVector( -1.29e+04,
 							    +1.12e+03,
 							    +3.50e+04,
 							    +3.77e+04 ),
 						     -5, 2 ) );
     
-    vtxgb->add_particle_out( new HepMC::GenParticle( HLV_t( -1.92e+04,
+    vtxgb->add_particle_out( HepMC::newGenParticlePtr( HepMC::FourVector( -1.92e+04,
 							    -7.30e+03,
 							    +1.55e+04,
 							    +2.61e+04 ),
@@ -647,23 +647,23 @@ GenVertex:      -39 ID:    0 (X,cT):0
     // create a gg->b+bbar vertex
     HepMC::GenVertex * vtxbb = new HepMC::GenVertex;
     m_evt->add_vertex( vtxbb );
-    vtxbb->add_particle_in( new HepMC::GenParticle( HLV_t( +1.23e+04,
+    vtxbb->add_particle_in( HepMC::newGenParticlePtr( HepMC::FourVector( +1.23e+04,
 							   -4.79e+03,
 							   +6.52e+04,
 							   +6.65e+04 ),
 						    21, 3 ) );
-    vtxbb->add_particle_in( new HepMC::GenParticle( HLV_t( +1.14e+02,
+    vtxbb->add_particle_in( HepMC::newGenParticlePtr( HepMC::FourVector( +1.14e+02,
 							   +1.35e+04,
 							   -6.42e+04,
 							   +6.56e+04 ),
 						    21, 3 ) );
-    vtxbb->add_particle_out( new HepMC::GenParticle( HLV_t( +4.56e+04,
+    vtxbb->add_particle_out( HepMC::newGenParticlePtr( HepMC::FourVector( +4.56e+04,
 							    +1.53e+04,
 							    -5.08e+04,
 							    +7.01e+04 ),
 						     5, 3 ) );
     
-    vtxbb->add_particle_out( new HepMC::GenParticle( HLV_t( -3.32e+04,
+    vtxbb->add_particle_out( HepMC::newGenParticlePtr( HepMC::FourVector( -3.32e+04,
 							    -6.56e+03,
 							    +5.18e+04,
 							    +6.20e+04 ),
@@ -705,13 +705,13 @@ GenVertex:      -39 ID:    0 (X,cT):0
   {
     HepMC::GenVertex * vtx = new HepMC::GenVertex;
     m_evt->add_vertex( vtx );
-    vtx->add_particle_in( new HepMC::GenParticle( HLV_t( -2.45e+04,
+    vtx->add_particle_in( HepMC::newGenParticlePtr( HepMC::FourVector( -2.45e+04,
 							 +1.88e+04,
 							 -8.65e+05,
 							 +8.65e+05 ),
 						  23, 3 ) );
     HepMC::GenParticle * photon = 0;
-    photon = new HepMC::GenParticle( HLV_t( -2.45e+04,
+    photon = HepMC::newGenParticlePtr( HepMC::FourVector( -2.45e+04,
 					    +1.88e+04,
 					    -8.65e+05,
 					    +8.65e+05 ),
diff --git a/Projects/AnalysisBase/CMakeLists.txt b/Projects/AnalysisBase/CMakeLists.txt
index 90ed7b819398..47e147b4e7b3 100644
--- a/Projects/AnalysisBase/CMakeLists.txt
+++ b/Projects/AnalysisBase/CMakeLists.txt
@@ -14,6 +14,12 @@ unset( _version )
 # This project is built on top of AnalysisBaseExternals:
 find_package( AnalysisBaseExternals REQUIRED )
 
+
+add_definitions(-DHEPMC3)
+find_package( hepmc3 COMPONENTS HepMC HepMCsearch  HINTS /cvmfs/sft.cern.ch/lcg/releases/LCG_96b/hepmc3/3.1.2/x86_64-centos7-gcc8-opt/)
+SET(HEPMC3_USE TRUE)
+
+
 # Set up the build/runtime environment:
 set( AnalysisBaseReleaseEnvironment_DIR ${CMAKE_SOURCE_DIR}/cmake CACHE PATH
    "Path to AnalysisBaseReleaseEnvironmentConfig.cmake" )
diff --git a/Projects/AthGeneration/CMakeLists.txt b/Projects/AthGeneration/CMakeLists.txt
index 8a4a04ddf1ee..1f54267fd3c9 100644
--- a/Projects/AthGeneration/CMakeLists.txt
+++ b/Projects/AthGeneration/CMakeLists.txt
@@ -31,6 +31,11 @@ find_package( BLAS )
 find_package( AIDA )
 find_package( VDT )
 
+add_definitions(-DHEPMC3)
+find_package( hepmc3 COMPONENTS HepMC3 HepMC3search)
+MESSAGE(STATUS "${hepmc3_FOUND}   ${HEPMC3_HepMC3_LIBRARY}   ${HEPMC3_HepMC3search_LIBRARY}")
+SET(HEPMC3_USE TRUE)
+
 # Set the project into "GENERATIONBASE mode".
 set( GENERATIONBASE TRUE CACHE BOOL
    "Flag specifying that this is a generation release build" )
diff --git a/Projects/AthSimulation/CMakeLists.txt b/Projects/AthSimulation/CMakeLists.txt
index d44b378aeeb5..a9dc57d6acb7 100644
--- a/Projects/AthSimulation/CMakeLists.txt
+++ b/Projects/AthSimulation/CMakeLists.txt
@@ -28,6 +28,17 @@ find_package( PNG )
 find_package( VDT )
 find_package( TIFF )
 
+add_definitions(-DHEPMC3)
+set (hepmc3_DIR /cvmfs/sft.cern.ch/lcg/releases/LCG_97apython3_ATLAS_1/hepmc3/3.2.2/x86_64-centos7-gcc8-opt/)
+find_package( hepmc3 COMPONENTS HepMC3 HepMC3search HINTS /cvmfs/sft.cern.ch/lcg/releases/LCG_97apython3_ATLAS_1/hepmc3/3.2.2/x86_64-centos7-gcc8-opt/)
+#MESSAGE(STATUS "${hepmc3_FOUND}   ${HEPMC3_HepMC3_LIBRARY}   ${HEPMC3_HepMC3search_LIBRARY}")
+#SET(HEPMC3_USE TRUE)
+
+#add_definitions(-DHEPMC3)
+#find_package( hepmc3 COMPONENTS HepMC3 HepMC3search)
+MESSAGE(STATUS "${hepmc3_FOUND}   ${HEPMC3_HepMC3_LIBRARY}   ${HEPMC3_HepMC3search_LIBRARY}")
+SET(HEPMC3_USE TRUE)
+
 # Set the project into "SIMULATIONBASE mode".
 set( SIMULATIONBASE TRUE CACHE BOOL
    "Flag specifying that this is a simulation release build" )
diff --git a/Simulation/FastShower/FastCaloSim/src/FastShowerCellBuilderTool.cxx b/Simulation/FastShower/FastCaloSim/src/FastShowerCellBuilderTool.cxx
index 488fdbeffb2a..9dbb787129ce 100644
--- a/Simulation/FastShower/FastCaloSim/src/FastShowerCellBuilderTool.cxx
+++ b/Simulation/FastShower/FastCaloSim/src/FastShowerCellBuilderTool.cxx
@@ -2516,7 +2516,7 @@ std::vector<Trk::HitInfo>* FastShowerCellBuilderTool::caloHits(const HepMC::GenP
   // geantinos not handled by PdgToParticleHypothesis - fix there
   if ( pdgId == 999 ) pHypothesis = Trk::geantino;
 
-  HepMC::GenVertex *vtx = part.production_vertex();
+  HepMC::GenVertexPtr  vtx = part.production_vertex();
   Amg::Vector3D pos(0.,0.,0.);    // default
 
   if (vtx) {
diff --git a/Simulation/FastSimulation/FastChainPileup/src/MultiParticleGunPileup.cxx b/Simulation/FastSimulation/FastChainPileup/src/MultiParticleGunPileup.cxx
index 89dfb261ec48..833e49bb3281 100644
--- a/Simulation/FastSimulation/FastChainPileup/src/MultiParticleGunPileup.cxx
+++ b/Simulation/FastSimulation/FastChainPileup/src/MultiParticleGunPileup.cxx
@@ -122,11 +122,11 @@ StatusCode MultiParticleGunPileup::callGenerator() {
 	// Make particle-creation vertex
 	// TODO: do something cleverer than one vertex per particle?
 	HepMC::FourVector pos(p.m_pos.X(), p.m_pos.Y(), p.m_pos.Z(), p.m_pos.T());
-	HepMC::GenVertexPtr   gv = new HepMC::GenVertex(pos);
+	HepMC::GenVertexPtr   gv = HepMC::newGenVertexPtr(pos);
 	evt->add_vertex(gv);
 	// Make particle with status == 1
 	HepMC::FourVector mom(p.m_mom.Px(), p.m_mom.Py(), p.m_mom.Pz(), p.m_mom.E());
-	HepMC::GenParticlePtr   gp = new HepMC::GenParticle;
+	HepMC::GenParticlePtr   gp = HepMC::newGenParticlePtr();
 	gp->set_status(1);
 	gp->set_pdg_id(p.m_pid);
 	gp->set_momentum(mom);
diff --git a/Simulation/G4Sim/MCTruth/MCTruth/PrimaryParticleInformation.h b/Simulation/G4Sim/MCTruth/MCTruth/PrimaryParticleInformation.h
index 009e9e79883c..8ed5e26021ba 100644
--- a/Simulation/G4Sim/MCTruth/MCTruth/PrimaryParticleInformation.h
+++ b/Simulation/G4Sim/MCTruth/MCTruth/PrimaryParticleInformation.h
@@ -12,9 +12,33 @@
 namespace ISF {
   class ISFParticle;
 }
+#ifdef HEPMC3
+class PrimaryParticleInformation: public G4VUserPrimaryParticleInformation {
+public:
+	PrimaryParticleInformation();
+	PrimaryParticleInformation(const HepMC::GenParticlePtr , const ISF::ISFParticle* isp=0);
+	const HepMC::GenParticlePtr  GetHepMCParticle() const;
+	int GetParticleBarcode() const;
+	void SuggestBarcode(int bc);
+	void SetParticle(const HepMC::GenParticlePtr );
+	void Print() const {}
+	int GetRegenerationNr() {return  m_regenerationNr;}
+	void SetRegenerationNr(int i) {m_regenerationNr=i;}
+
+	void SetISFParticle(const ISF::ISFParticle* isp);
+	const ISF::ISFParticle* GetISFParticle() const;
+
+private:
+	HepMC::GenParticlePtr  m_theParticle;
+	const ISF::ISFParticle* m_theISFParticle;
 
+	int m_regenerationNr;
+	int m_barcode;
+};
+#else
 class PrimaryParticleInformation: public G4VUserPrimaryParticleInformation {
 public:
+
   PrimaryParticleInformation();
   PrimaryParticleInformation(HepMC::ConstGenParticlePtr, const ISF::ISFParticle* isp=0);
   HepMC::ConstGenParticlePtr GetHepMCParticle() const;
@@ -37,3 +61,4 @@ private:
 };
 
 #endif
+#endif
diff --git a/Simulation/G4Sim/MCTruth/MCTruth/TrackInformation.h b/Simulation/G4Sim/MCTruth/MCTruth/TrackInformation.h
index 6726589ae766..605ba72426cb 100644
--- a/Simulation/G4Sim/MCTruth/MCTruth/TrackInformation.h
+++ b/Simulation/G4Sim/MCTruth/MCTruth/TrackInformation.h
@@ -10,10 +10,32 @@
 namespace ISF {
   class ISFParticle;
 }
+#ifdef HEPMC3
+class TrackInformation: public VTrackInformation {
+public:
+	TrackInformation();
+	TrackInformation(const HepMC::GenParticlePtr ,const ISF::ISFParticle* baseIsp=0);
 
+	const HepMC::GenParticlePtr  GetHepMCParticle() const;
+	const ISF::ISFParticle *GetBaseISFParticle() const;
+	int GetParticleBarcode() const;
+	void SetParticle(const HepMC::GenParticlePtr );
+	void SetBaseISFParticle(const ISF::ISFParticle*);
+	void SetReturnedToISF(bool returned) {m_returnedToISF=returned;};
+	bool GetReturnedToISF() const {return m_returnedToISF;};
+	void SetRegenerationNr(int i) {m_regenerationNr=i;};
+	int GetRegenerationNr() const {return m_regenerationNr;};
+private:
+	int m_regenerationNr;
+	HepMC::GenParticlePtr  m_theParticle;
+	const ISF::ISFParticle *m_theBaseISFParticle;
+	bool m_returnedToISF;
+};
+#else
 class TrackInformation: public VTrackInformation {
 public:
 	TrackInformation();
+
 	TrackInformation(HepMC::ConstGenParticlePtr,const ISF::ISFParticle* baseIsp=0);
 	HepMC::ConstGenParticlePtr GetHepMCParticle() const;
 	const ISF::ISFParticle *GetBaseISFParticle() const;
@@ -30,5 +52,6 @@ private:
 	const ISF::ISFParticle *m_theBaseISFParticle;
 	bool m_returnedToISF;
 };
+#endif
 
 #endif
diff --git a/Simulation/G4Sim/MCTruth/MCTruth/VTrackInformation.h b/Simulation/G4Sim/MCTruth/MCTruth/VTrackInformation.h
index 57d2a9f0d088..cf81ac2be777 100644
--- a/Simulation/G4Sim/MCTruth/MCTruth/VTrackInformation.h
+++ b/Simulation/G4Sim/MCTruth/MCTruth/VTrackInformation.h
@@ -15,24 +15,55 @@ namespace ISF {
   class ISFParticle;
 }
 
+#ifdef HEPMC3
 class VTrackInformation: public G4VUserTrackInformation {
 public:
-  VTrackInformation(TrackClassification tc=Primary);
-  HepMC::ConstGenParticlePtr GetPrimaryHepMCParticle() const;
-  void  SetPrimaryHepMCParticle(HepMC::ConstGenParticlePtr);
-  virtual HepMC::ConstGenParticlePtr GetHepMCParticle() const;
-  virtual const ISF::ISFParticle *GetBaseISFParticle() const;
-  virtual bool GetReturnedToISF() const;
-  virtual int  GetParticleBarcode() const =0;
-  virtual void SetParticle(HepMC::ConstGenParticlePtr);
-  virtual void SetBaseISFParticle(const ISF::ISFParticle*);
-  virtual void SetReturnedToISF(bool) ;
-  virtual void Print() const {}
-  void SetClassification(TrackClassification tc) {m_classify=tc;}
-  TrackClassification GetClassification() {return m_classify;}
+	VTrackInformation(TrackClassification tc=Primary);
+
+	const HepMC::GenParticlePtr  GetPrimaryHepMCParticle() const;
+	virtual const HepMC::GenParticlePtr  GetHepMCParticle() const;
+
+	void  SetPrimaryHepMCParticle(const HepMC::GenParticlePtr );
+	virtual const ISF::ISFParticle *GetBaseISFParticle() const;
+	virtual bool GetReturnedToISF() const;
+	virtual int  GetParticleBarcode() const =0;
+	virtual void SetParticle(const HepMC::GenParticlePtr );
+	virtual void SetBaseISFParticle(const ISF::ISFParticle*);
+	virtual void SetReturnedToISF(bool) ;
+	virtual void Print() const {}
+	void SetClassification(TrackClassification tc) {m_classify=tc;}
+	TrackClassification GetClassification() {return m_classify;}
+private:
+	TrackClassification m_classify;
+	HepMC::GenParticlePtr  m_thePrimaryParticle;
+};
+
+#else
+
+class VTrackInformation: public G4VUserTrackInformation {
+public:
+	VTrackInformation(TrackClassification tc=Primary);
+
+	const HepMC::GenParticle*  GetPrimaryHepMCParticle() const;
+	virtual const HepMC::GenParticle*  GetHepMCParticle() const;
+
+	void  SetPrimaryHepMCParticle(const HepMC::GenParticle* );
+	virtual const ISF::ISFParticle *GetBaseISFParticle() const;
+	virtual bool GetReturnedToISF() const;
+	virtual int  GetParticleBarcode() const =0;
+	virtual void SetParticle(const HepMC::GenParticle* );
+	virtual void SetBaseISFParticle(const ISF::ISFParticle*);
+	virtual void SetReturnedToISF(bool) ;
+	virtual void Print() const {}
+	void SetClassification(TrackClassification tc) {m_classify=tc;}
+	TrackClassification GetClassification() {return m_classify;}
 private:
-  TrackClassification m_classify;
-  HepMC::ConstGenParticlePtr m_thePrimaryParticle{};
+	TrackClassification m_classify;
+	const HepMC::GenParticle*  m_thePrimaryParticle;
 };
 
+
+#endif
+
+
 #endif
diff --git a/Simulation/G4Sim/MCTruth/src/PrimaryParticleInformation.cxx b/Simulation/G4Sim/MCTruth/src/PrimaryParticleInformation.cxx
index c4a1e311f2a6..bbd4219c25a5 100644
--- a/Simulation/G4Sim/MCTruth/src/PrimaryParticleInformation.cxx
+++ b/Simulation/G4Sim/MCTruth/src/PrimaryParticleInformation.cxx
@@ -4,6 +4,63 @@
 
 #include "MCTruth/PrimaryParticleInformation.h"
 
+
+#ifdef HEPMC3
+PrimaryParticleInformation::PrimaryParticleInformation() 
+  : m_theParticle(0),m_theISFParticle(0),m_regenerationNr(0),m_barcode(-1)
+{
+}
+
+PrimaryParticleInformation::PrimaryParticleInformation(const HepMC::GenParticlePtr  p, const ISF::ISFParticle* isp):m_theParticle(p),m_theISFParticle(isp),m_regenerationNr(0),m_barcode(-1)
+{
+}
+
+const HepMC::GenParticlePtr  PrimaryParticleInformation::GetHepMCParticle() const
+{
+	return m_theParticle;
+}
+
+const ISF::ISFParticle* PrimaryParticleInformation::GetISFParticle() const
+{
+	return m_theISFParticle;
+}
+
+void PrimaryParticleInformation::SuggestBarcode(int bc)
+{
+  m_barcode=bc;
+  if (m_theParticle) {
+    std::cout<<"ERROR: PrimaryParticleInformation::SuggestBarcode() should be only called if no HepMC::Particle is available"<<std::endl;
+    //theParticle->suggest_barcode(bc);
+  }
+}
+
+int PrimaryParticleInformation::GetParticleBarcode() const
+{
+	return m_theParticle?HepMC::barcode(m_theParticle):m_barcode;
+}
+
+void PrimaryParticleInformation::SetParticle(const HepMC::GenParticlePtr  p)
+{
+	m_theParticle=p;
+}
+
+void PrimaryParticleInformation::SetISFParticle(const ISF::ISFParticle* p)
+{
+	m_theISFParticle=p;
+}
+
+#else
+
+PrimaryParticleInformation::PrimaryParticleInformation() 
+  : m_theParticle(0),m_theISFParticle(0),m_regenerationNr(0),m_barcode(-1)
+{
+}
+
+PrimaryParticleInformation::PrimaryParticleInformation(const HepMC::GenParticle*  p, const ISF::ISFParticle* isp):m_theParticle(p),m_theISFParticle(isp),m_regenerationNr(0),m_barcode(-1)
+{
+}
+
+const HepMC::GenParticle*  PrimaryParticleInformation::GetHepMCParticle() const
 PrimaryParticleInformation::PrimaryParticleInformation()
 {
 }
@@ -44,3 +101,4 @@ void PrimaryParticleInformation::SetISFParticle(const ISF::ISFParticle* p)
 {
   m_theISFParticle=p;
 }
+#endif
diff --git a/Simulation/G4Sim/MCTruth/src/TrackInformation.cxx b/Simulation/G4Sim/MCTruth/src/TrackInformation.cxx
index fcaa59ba6541..d3b55a4667e7 100644
--- a/Simulation/G4Sim/MCTruth/src/TrackInformation.cxx
+++ b/Simulation/G4Sim/MCTruth/src/TrackInformation.cxx
@@ -5,6 +5,48 @@
 #include "MCTruth/TrackInformation.h"
 #include "AtlasHepMC/GenEvent.h"
 
+#ifdef HEPMC3
+
+TrackInformation::TrackInformation():m_regenerationNr(0),m_theParticle(0),m_theBaseISFParticle(0),m_returnedToISF(false)
+{
+}
+
+TrackInformation::TrackInformation(const HepMC::GenParticlePtr  p,const ISF::ISFParticle* baseIsp):
+    m_regenerationNr(0),
+    m_theParticle(p),
+    m_theBaseISFParticle(baseIsp),
+    m_returnedToISF(false)
+{
+}
+
+const HepMC::GenParticlePtr  TrackInformation::GetHepMCParticle() const
+{
+  return m_theParticle;
+}
+const ISF::ISFParticle* TrackInformation::GetBaseISFParticle() const
+{
+  return m_theBaseISFParticle;
+}
+
+int TrackInformation::GetParticleBarcode() const
+{
+  return ( m_theParticle ?HepMC::barcode( m_theParticle) : 0 );
+}
+
+void TrackInformation::SetParticle(const HepMC::GenParticlePtr  p)
+{
+  m_theParticle=p;
+}
+
+void TrackInformation::SetBaseISFParticle(const ISF::ISFParticle* p)
+{
+  m_theBaseISFParticle=p;
+}
+
+
+
+#else
+
 TrackInformation::TrackInformation():m_regenerationNr(0),m_theParticle(0),m_theBaseISFParticle(0),m_returnedToISF(false)
 {
 }
@@ -28,7 +70,7 @@ const ISF::ISFParticle* TrackInformation::GetBaseISFParticle() const
 
 int TrackInformation::GetParticleBarcode() const
 {
-  return ( m_theParticle ? m_theParticle->barcode() : 0 );
+  return ( m_theParticle ?m_theParticle->barcode() : 0 );
 }
 
 void TrackInformation::SetParticle(HepMC::ConstGenParticlePtr p)
@@ -40,3 +82,4 @@ void TrackInformation::SetBaseISFParticle(const ISF::ISFParticle* p)
 {
   m_theBaseISFParticle=p;
 }
+#endif
diff --git a/Simulation/G4Sim/MCTruth/src/VTrackInformation.cxx b/Simulation/G4Sim/MCTruth/src/VTrackInformation.cxx
index 022afaf4f887..ed653142432a 100644
--- a/Simulation/G4Sim/MCTruth/src/VTrackInformation.cxx
+++ b/Simulation/G4Sim/MCTruth/src/VTrackInformation.cxx
@@ -8,21 +8,50 @@ VTrackInformation::VTrackInformation(TrackClassification tc):m_classify(tc)
 {
 }
 
-HepMC::ConstGenParticlePtr VTrackInformation::GetPrimaryHepMCParticle() const
+#ifdef HEPMC3
+
+void VTrackInformation::SetPrimaryHepMCParticle(const HepMC::GenParticlePtr  p)
+{
+  m_thePrimaryParticle=p;
+}
+const HepMC::GenParticlePtr  VTrackInformation::GetPrimaryHepMCParticle() const
 {
   return m_thePrimaryParticle;
 }
-
-void VTrackInformation::SetPrimaryHepMCParticle(HepMC::ConstGenParticlePtr p)
 {
-  m_thePrimaryParticle=p;
+  return 0;
 }
+void VTrackInformation::SetParticle(const HepMC::GenParticlePtr  /*p*/)
+{
+  // you should not call this, perhaps throw an exception?
+  std::cerr<<"ERROR  VTrackInformation::SetParticle() not supported  "<<std::endl;
+ 
+}
+
 
 
-HepMC::ConstGenParticlePtr VTrackInformation::GetHepMCParticle() const
+#else
+
+void VTrackInformation::SetPrimaryHepMCParticle(const HepMC::GenParticle*  p)
+{
+  m_thePrimaryParticle=p;
+}
+const HepMC::GenParticle*  VTrackInformation::GetPrimaryHepMCParticle() const
+{
+  return m_thePrimaryParticle;
+}
+const HepMC::GenParticle*  VTrackInformation::GetHepMCParticle() const
 {
   return 0;
 }
+void VTrackInformation::SetParticle(const HepMC::GenParticle*  /*p*/)
+{
+  // you should not call this, perhaps throw an exception?
+  std::cerr<<"ERROR  VTrackInformation::SetParticle() not supported  "<<std::endl;
+ 
+}
+#endif
+
 
 const ISF::ISFParticle* VTrackInformation::GetBaseISFParticle() const
 {
diff --git a/Simulation/G4Utilities/G4UserActions/src/AthenaTrackingAction.cxx b/Simulation/G4Utilities/G4UserActions/src/AthenaTrackingAction.cxx
index acc9cd35f9db..2234189190bb 100644
--- a/Simulation/G4Utilities/G4UserActions/src/AthenaTrackingAction.cxx
+++ b/Simulation/G4Utilities/G4UserActions/src/AthenaTrackingAction.cxx
@@ -44,11 +44,18 @@ namespace G4UA
     // Condition for storing the GenParticle in the AtlasG4EventUserInfo for later.
     if (trackHelper.IsPrimary() || trackHelper.IsRegisteredSecondary())
     {
+
+#ifdef HEPMC3
+      HepMC::GenParticlePtr  part;
+
+#else
+
       // Why a const_cast???
       // This is an ugly way to communicate the GenParticle...
       HepMC::GenParticlePtr part =
         const_cast<HepMC::GenParticlePtr>( trackHelper.GetTrackInformation()->
                                          GetHepMCParticle() );
+#endif
 
       // Assign the GenParticle to the AtlasG4EventUserInfo.
       AtlasG4EventUserInfo* atlasG4EvtUserInfo = static_cast<AtlasG4EventUserInfo*>
diff --git a/Simulation/G4Utilities/MCTruthSimAlgs/src/MergeMcEventCollTool.cxx b/Simulation/G4Utilities/MCTruthSimAlgs/src/MergeMcEventCollTool.cxx
index 262a6f240acf..e91a39b74fe6 100644
--- a/Simulation/G4Utilities/MCTruthSimAlgs/src/MergeMcEventCollTool.cxx
+++ b/Simulation/G4Utilities/MCTruthSimAlgs/src/MergeMcEventCollTool.cxx
@@ -449,7 +449,7 @@ StatusCode MergeMcEventCollTool::processUnfilteredEvent(const McEventCollection
   const HepMC::GenEvent& currentBackgroundEvent(**(pMcEvtColl->begin()));         //background event
   //handle the slimming case
   //ATH_MSG_VERBOSE( "The MB Event Number is " << currentBkgEventIndex << ". m_nBkgEventsReadSoFar = " << m_nBkgEventsReadSoFar );
-  HepMC::GenVertex *pCopyOfGenVertex(NULL);
+  HepMC::GenVertexPtr  pCopyOfGenVertex(NULL);
   if ( currentBackgroundEvent.signal_process_vertex() ) pCopyOfGenVertex = new HepMC::GenVertex ( *currentBackgroundEvent.signal_process_vertex() );
   //insert the GenEvent into the overlay McEventCollection.
   m_pOvrlMcEvColl->at(m_startingIndexForBackground+m_nBkgEventsReadSoFar) = new HepMC::GenEvent(currentBackgroundEvent.signal_process_id(), currentBkgEventIndex, pCopyOfGenVertex );
@@ -462,9 +462,9 @@ StatusCode MergeMcEventCollTool::processUnfilteredEvent(const McEventCollection
   ATH_MSG_VERBOSE( "Starting a vertex loop ... " );
   //cout << "Starting a vertex loop ... " <<endl;
   for (; currentVertexIter != endOfCurrentListOfVertices; ++currentVertexIter) {
-    const HepMC::GenVertex *pCurrentVertex(*currentVertexIter);
-    HepMC::GenVertex *pCopyOfVertexForClassification[NOPUTYPE];
-    for (int type(INTIME); type<NOPUTYPE; ++type) pCopyOfVertexForClassification[type]=(HepMC::GenVertex*)0;
+    const HepMC::GenVertexPtr  pCurrentVertex(*currentVertexIter);
+    HepMC::GenVertexPtr  pCopyOfVertexForClassification[NOPUTYPE];
+    for (int type(INTIME); type<NOPUTYPE; ++type) pCopyOfVertexForClassification[type]=(HepMC::GenVertexPtr )0;
 
     //check for collision vertices for in-time events
     bool isCollisionVertex(false);
@@ -480,8 +480,8 @@ StatusCode MergeMcEventCollTool::processUnfilteredEvent(const McEventCollection
     const HepMC::GenVertex::particles_out_const_iterator endOfListOfParticlesFromCurrentVertex(pCurrentVertex->particles_out_const_end());
     for (; currentVertexParticleIter != endOfListOfParticlesFromCurrentVertex; ++currentVertexParticleIter) {
       ATH_MSG_VERBOSE( "Found a particle at location " << std::hex << *currentVertexParticleIter << std::dec  << " with PDG ID = " << (*currentVertexParticleIter)->pdg_id() );
-      const HepMC::GenParticle *pCurrentVertexParticle(*currentVertexParticleIter);
-      const HepMC::GenVertex *pCurrentParticleProductionVertex(pCurrentVertexParticle->production_vertex());
+      const HepMC::GenParticlePtr  pCurrentVertexParticle(*currentVertexParticleIter);
+      const HepMC::GenVertexPtr  pCurrentParticleProductionVertex(pCurrentVertexParticle->production_vertex());
       puType particleClassification(classifyVertex(pCurrentVertexParticle, pCurrentParticleProductionVertex,currentEventTime));
       //hack to keep the complete vertex information for the interaction vertices of in-time background events
       if(isCollisionVertex && NOPUTYPE==particleClassification) {
@@ -525,11 +525,11 @@ StatusCode MergeMcEventCollTool::processUnfilteredEvent(const McEventCollection
   return StatusCode::SUCCESS;
 }
 
-bool MergeMcEventCollTool::isInitialCollisionVertex(const HepMC::GenVertex *pCurrentVertex) const {
+bool MergeMcEventCollTool::isInitialCollisionVertex(const HepMC::GenVertexPtr  pCurrentVertex) const {
   HepMC::GenVertex::particles_in_const_iterator currentVertexParticleIter(pCurrentVertex->particles_in_const_begin());
   const HepMC::GenVertex::particles_in_const_iterator endOfListOfParticlesFromCurrentVertex(pCurrentVertex->particles_in_const_end());
   while(currentVertexParticleIter != endOfListOfParticlesFromCurrentVertex) {
-    const HepMC::GenParticle *pCurrentVertexParticle(*currentVertexParticleIter);
+    const HepMC::GenParticlePtr  pCurrentVertexParticle(*currentVertexParticleIter);
     // FIXME: Nasty kludge will only work for Pythia minbias currently
     // Eventually just look for beam particles with status 4, but this
     // requires an update to the HepMC version used by ATLAS.
@@ -543,7 +543,7 @@ bool MergeMcEventCollTool::isInitialCollisionVertex(const HepMC::GenVertex *pCur
   return false;
 }
 
-MergeMcEventCollTool::puType MergeMcEventCollTool::classifyVertex(const HepMC::GenParticle *pCurrentVertexParticle, const HepMC::GenVertex *pCurrentParticleProductionVertex, double currentEventTime) {
+MergeMcEventCollTool::puType MergeMcEventCollTool::classifyVertex(const HepMC::GenParticlePtr  pCurrentVertexParticle, const HepMC::GenVertexPtr  pCurrentParticleProductionVertex, double currentEventTime) {
   //=======================================================================
   //handle the slimming case
   //=======================================================================
diff --git a/Simulation/G4Utilities/MCTruthSimAlgs/src/MergeMcEventCollTool.h b/Simulation/G4Utilities/MCTruthSimAlgs/src/MergeMcEventCollTool.h
index 038b9aefa928..0fff5864e455 100755
--- a/Simulation/G4Utilities/MCTruthSimAlgs/src/MergeMcEventCollTool.h
+++ b/Simulation/G4Utilities/MCTruthSimAlgs/src/MergeMcEventCollTool.h
@@ -67,9 +67,9 @@ private:
   //** Ensure that any GenEvent::HeavyIon info is stored in the signal GenEvent.
   StatusCode saveHeavyIonInfo(const McEventCollection *pMcEvtColl);
   //** Classify the current GenParticle according to the MC Truth Taskforce requirements
-  MergeMcEventCollTool::puType classifyVertex(const HepMC::GenParticle *pCurrentVertexParticle, const HepMC::GenVertex *pCurrentParticleProductionVertex, double currentEventTime);
+  MergeMcEventCollTool::puType classifyVertex(const HepMC::GenParticlePtr  pCurrentVertexParticle, const HepMC::GenVertexPtr  pCurrentParticleProductionVertex, double currentEventTime);
   //** Check if the current GenVertex contains beam particles
-  bool isInitialCollisionVertex(const HepMC::GenVertex *pCurrentVertex) const;
+  bool isInitialCollisionVertex(const HepMC::GenVertexPtr  pCurrentVertex) const;
   //** Check whether the current McEventCollection has already been truth-filtered
   bool isTruthFiltertedMcEventCollection(const McEventCollection *pMcEvtColl) const;
   //** Map from GenEvent to puType FIXME: Simpler to key the map on GenEvent* ?
diff --git a/Simulation/ISF/ISF_Core/ISF_Event/ISF_Event/HepMCHelper.h b/Simulation/ISF/ISF_Core/ISF_Event/ISF_Event/HepMCHelper.h
index 69ed5994ff62..8abebde1b18d 100644
--- a/Simulation/ISF/ISF_Core/ISF_Event/ISF_Event/HepMCHelper.h
+++ b/Simulation/ISF/ISF_Core/ISF_Event/ISF_Event/HepMCHelper.h
@@ -51,9 +51,16 @@ namespace ISF {
           at least one particle with one of the given PDG codes appears.
           returns pointer to first found particle that matches any of the
           given PDG codes in relativesPDG */
+#ifdef HEPMC3
       static inline HepMC::ConstGenParticlePtr findRealtiveWithPDG( const HepMC::GenParticle &genParticle,
                                                                     const HepMC::IteratorRange &relation,
                                                                     const std::set<int> &relativesPDG     );
+
+#else
+      static inline const HepMC::GenParticlePtr   findRealtiveWithPDG( const HepMC::GenParticle &genParticle,
+                                                                    const HepMC::IteratorRange &relation,
+                                                                    const std::set<int> &relativesPDG     );
+#endif
   };
 
 }
diff --git a/Simulation/ISF/ISF_Core/ISF_Event/ISF_Event/HepMCHelper.icc b/Simulation/ISF/ISF_Core/ISF_Event/ISF_Event/HepMCHelper.icc
index ba477d1d70ce..2c58f45ee715 100644
--- a/Simulation/ISF/ISF_Core/ISF_Event/ISF_Event/HepMCHelper.icc
+++ b/Simulation/ISF/ISF_Core/ISF_Event/ISF_Event/HepMCHelper.icc
@@ -12,6 +12,9 @@
 // @TODO: probably replace this by an enum some day
 #define ISF_UNDEF_CHARGE -99999.
 
+#include "AtlasHepMC/GenEvent.h"
+#include "AtlasHepMC/IteratorRange.h"
+
 /** constructor */
 ISF::HepMCHelper::HepMCHelper() {
 }
@@ -22,12 +25,25 @@ ISF::HepMCHelper::~HepMCHelper() {
 
 
 HepMC::IteratorRange ISF::HepMCHelper::convertIteratorRange( int intItRange ) {
+#ifdef HEPMC3
+return HepMC::IteratorRange();
+#else
   if      (intItRange==0) return ( HepMC::parents   );
   else if (intItRange==1) return ( HepMC::family    );
   else if (intItRange==2) return ( HepMC::ancestors );
   else if (intItRange==3) return ( HepMC::relatives );
   else                    return ( HepMC::parents   );
+#endif
+}
+
+#ifdef HEPMC3
+const HepMC::GenParticlePtr   ISF::HepMCHelper::findRealtiveWithPDG( const HepMC::GenParticlePtr &genParticle,
+                                                                  const HepMC::IteratorRange &relation,
+                                                                  const std::set<int> &relativesPDG     ) {
+
+return HepMC::GenParticlePtr();
 }
+#else
 
 HepMC::ConstGenParticlePtr ISF::HepMCHelper::findRealtiveWithPDG( const HepMC::GenParticle &genParticle,
                                                                   const HepMC::IteratorRange &relation,
@@ -50,3 +66,4 @@ HepMC::ConstGenParticlePtr ISF::HepMCHelper::findRealtiveWithPDG( const HepMC::G
   return (found ? curRelative : 0);
 }
 
+#endif
diff --git a/Simulation/ISF/ISF_Core/ISF_Event/ISF_Event/TruthBinding.icc b/Simulation/ISF/ISF_Core/ISF_Event/ISF_Event/TruthBinding.icc
index 91c73a6f98b9..04b87be7e795 100644
--- a/Simulation/ISF/ISF_Core/ISF_Event/ISF_Event/TruthBinding.icc
+++ b/Simulation/ISF/ISF_Core/ISF_Event/ISF_Event/TruthBinding.icc
@@ -56,7 +56,9 @@ namespace ISF {
   /** check equality */
   bool TruthBinding::isEqual(const TruthBinding& rhs) const {
     bool pass = true;
+#ifdef HEPMC3
 
+#else
     const auto rhsTruth = rhs.getTruthParticle();
     if (m_truthParticle && rhsTruth) {
       pass &= *m_truthParticle == *rhsTruth;
@@ -77,6 +79,7 @@ namespace ISF {
     } else {
       return false;
     }
+#endif
 
     return pass;
   }
diff --git a/Simulation/ISF/ISF_Core/ISF_Event/src/ISFTruthIncident.cxx b/Simulation/ISF/ISF_Core/ISF_Event/src/ISFTruthIncident.cxx
index 4c8aa3f2b174..8c53a6c45c0a 100644
--- a/Simulation/ISF/ISF_Core/ISF_Event/src/ISFTruthIncident.cxx
+++ b/Simulation/ISF/ISF_Core/ISF_Event/src/ISFTruthIncident.cxx
@@ -162,7 +162,13 @@ void ISF::ISFTruthIncident::setAllChildrenBarcodes(Barcode::ParticleBarcode bc)
 
 
 /** return attached truth particle */
-HepMC::GenParticlePtr ISF::ISFTruthIncident::getHepMCTruthParticle( const ISF::ISFParticle& particle ) const {
+HepMC::GenParticlePtr  ISF::ISFTruthIncident::getHepMCTruthParticle( const ISF::ISFParticle& particle ) const {
+#ifdef HEPMC3
+
+return HepMC::GenParticlePtr();
+#else
+
+
   auto* truthBinding     = particle.getTruthBinding();
   auto* hepTruthParticle = truthBinding ? truthBinding->getTruthParticle() : nullptr;
 
@@ -174,12 +180,18 @@ HepMC::GenParticlePtr ISF::ISFTruthIncident::getHepMCTruthParticle( const ISF::I
   }
 
   return hepTruthParticle;
+#endif
 }
 
 
 /** convert ISFParticle to GenParticle and attach to ISFParticle's TruthBinding */
-HepMC::GenParticlePtr ISF::ISFTruthIncident::updateHepMCTruthParticle( ISF::ISFParticle& particle,
-                                                                       const ISF::ISFParticle* parent ) const {
+HepMC::GenParticlePtr  ISF::ISFTruthIncident::updateHepMCTruthParticle( ISF::ISFParticle& particle,
+
+                                                                     const ISF::ISFParticle* parent ) const {
+#ifdef HEPMC3
+
+return HepMC::GenParticlePtr();
+#else
   auto* truthBinding     = particle.getTruthBinding();
   auto* hepTruthParticle = ParticleHelper::convert( particle );
 
@@ -205,4 +217,5 @@ HepMC::GenParticlePtr ISF::ISFTruthIncident::updateHepMCTruthParticle( ISF::ISFP
   particle.setParticleLink(newHMPL);
 
   return hepTruthParticle;
+#endif
 }
diff --git a/Simulation/ISF/ISF_Core/ISF_Services/src/InputConverter.cxx b/Simulation/ISF/ISF_Core/ISF_Services/src/InputConverter.cxx
index d1a74c303ed2..8bed8807fcba 100644
--- a/Simulation/ISF/ISF_Core/ISF_Services/src/InputConverter.cxx
+++ b/Simulation/ISF/ISF_Core/ISF_Services/src/InputConverter.cxx
@@ -142,7 +142,7 @@ ISF::InputConverter::convert(const McEventCollection& inputGenEvents,
     if (eventPtr == nullptr) { continue; }
 
     ATH_MSG_DEBUG("Starting conversion of GenEvent with"
-                  " signal_process_id=" << eventPtr->signal_process_id() <<
+                  " signal_process_id=" << HepMC::signal_process_id(eventPtr) <<
                   " and event_number=" << eventPtr->event_number() );
 
     // new collection containing all gen particles that passed filters
@@ -154,7 +154,10 @@ ISF::InputConverter::convert(const McEventCollection& inputGenEvents,
     const auto passedGenParticles = getSelectedParticles(*eventPtr, legacyOrdering);
 
     for ( auto& genPartPtr : passedGenParticles ) {
+#ifdef HEPMC3
+#else
       ATH_MSG_VERBOSE("Picking up following GenParticle for conversion to ISFParticle: " <<  *genPartPtr);
+#endif
       auto simParticlePtr = convertParticle(genPartPtr, kindOfCollection);
       if (!simParticlePtr) {
         ATH_MSG_ERROR("Error while trying to convert input generator particles. Aborting.");
@@ -189,8 +192,13 @@ StatusCode ISF::InputConverter::convertHepMCToG4Event(McEventCollection& inputGe
 /** get all generator particles which pass filters */
 std::vector<HepMC::GenParticlePtr>
 ISF::InputConverter::getSelectedParticles(const HepMC::GenEvent& evnt, bool legacyOrdering) const {
+#ifdef HEPMC3
+  auto allGenPartBegin = evnt.particles().begin();
+  auto allGenPartEnd = evnt.particles().end();
+#else
   auto allGenPartBegin = evnt.particles_begin();
   auto allGenPartEnd = evnt.particles_end();
+#endif
 
   // reserve destination container with maximum size, i.e. number of particles in input event
   std::vector<HepMC::GenParticlePtr> passedGenParticles{};
@@ -200,6 +208,8 @@ ISF::InputConverter::getSelectedParticles(const HepMC::GenEvent& evnt, bool lega
   if (legacyOrdering) {
     // FIXME: remove this block and the 'legacyOrdering' flag
     //        once we don't need the legacy order any longer
+#ifdef HEPMC3
+#else
     auto vtxIt = evnt.vertices_begin();
     auto vtxItEnd = evnt.vertices_end();
     for ( ; vtxIt != vtxItEnd; ++vtxIt ) {
@@ -209,12 +219,16 @@ ISF::InputConverter::getSelectedParticles(const HepMC::GenEvent& evnt, bool lega
                    std::back_inserter(passedGenParticles),
                    [this](HepMC::GenParticlePtr p){return this->passesFilters(*p);});
     }
+#endif
   }
   else {
+#ifdef HEPMC3
+#else
     std::copy_if(allGenPartBegin,
                  allGenPartEnd,
                  std::back_inserter(passedGenParticles),
-                 [this](HepMC::GenParticlePtr p){return this->passesFilters(*p);});
+                 [this](HepMC::GenParticlePtr  p){return this->passesFilters(*p);});
+#endif
   }
 
   passedGenParticles.shrink_to_fit();
@@ -235,8 +249,11 @@ ISF::InputConverter::convertParticle(HepMC::GenParticlePtr genPartPtr, EBC_EVCOL
 
   HepMC::GenVertexPtr  pVertex = genPart.production_vertex();
   if (!pVertex) {
+#ifdef HEPMC3
+#else
     ATH_MSG_ERROR("Unable to convert following generator particle due to missing "
                   << "production vertex: " << genPart);
+#endif
     return nullptr;
   }
 
@@ -244,7 +261,11 @@ ISF::InputConverter::convertParticle(HepMC::GenParticlePtr genPartPtr, EBC_EVCOL
   const Amg::Vector3D pos(pVertex->position().x(), pVertex->position().y(), pVertex->position().z());
   const auto& pMomentum(genPart.momentum());
   const Amg::Vector3D mom(pMomentum.px(), pMomentum.py(), pMomentum.pz());
+#ifdef HEPMC3
+const double pMass =0;
+#else
   const double pMass = this->getParticleMass(genPart);
+#endif
 
   double e=pMomentum.e();
   if(e>1) { //only test for >1 MeV in momentum
@@ -262,7 +283,7 @@ ISF::InputConverter::convertParticle(HepMC::GenParticlePtr genPartPtr, EBC_EVCOL
   const double pTime = pVertex->position().t() / Gaudi::Units::c_light;
   /// particle origin (TODO: add proper GeoID, collision/cosmics)
   DetRegionSvcIDPair origin(AtlasDetDescr::fUndefinedAtlasRegion, ISF::fEventGeneratorSimID);
-  const auto pBarcode = genPart.barcode();
+  const auto pBarcode = HepMC::barcode(genPart);
   auto tBinding = std::make_unique<ISF::TruthBinding>(genPartPtr);
 
   auto *parentEvent = genPart.parent_event();
@@ -270,6 +291,9 @@ ISF::InputConverter::convertParticle(HepMC::GenParticlePtr genPartPtr, EBC_EVCOL
     ATH_MSG_ERROR("Cannot convert a GenParticle without a parent GenEvent into an ISFParticle!!!");
     return nullptr;
   }
+#ifdef HEPMC3
+  return nullptr;
+#else
   auto hmpl = std::make_unique<HepMcParticleLink>(&genPart, parentEvent->event_number(), kindOfCollection);
   auto sParticle = std::make_unique<ISF::ISFParticle>( std::move(pos),
                                                        std::move(mom),
@@ -283,13 +307,21 @@ ISF::InputConverter::convertParticle(HepMC::GenParticlePtr genPartPtr, EBC_EVCOL
                                                        tBinding.release(),
                                                        hmpl.release() );
   return sParticle.release();
+#endif
 }
 
 
 /** get right GenParticle mass */
+#ifdef HEPMC3
 double
-ISF::InputConverter::getParticleMass(const HepMC::GenParticle &part) const
-{
+ISF::InputConverter::getParticleMass(const HepMC::GenParticlePtr part) const{
+
+
+return 0;
+}
+#else
+double
+ISF::InputConverter::getParticleMass(const HepMC::GenParticle &part) const{
   // default value: generated particle mass
   double mass = part.generated_mass();
   ATH_MSG_VERBOSE("part.generated_mass, mass="<<mass);
@@ -310,9 +342,18 @@ ISF::InputConverter::getParticleMass(const HepMC::GenParticle &part) const
   }
   return mass;
 }
+#endif
 
 
 /** check if the given particle passes all filters */
+#ifdef HEPMC3
+bool
+ISF::InputConverter::passesFilters(const HepMC::GenParticlePtr part) const
+{
+	
+return true;	
+}	
+#else
 bool
 ISF::InputConverter::passesFilters(const HepMC::GenParticle& part) const
 {
@@ -337,6 +378,7 @@ ISF::InputConverter::passesFilters(const HepMC::GenParticle& part) const
 
   return true;
 }
+#endif
 
 
 //________________________________________________________________________
@@ -397,8 +439,13 @@ const G4ParticleDefinition* ISF::InputConverter::getG4ParticleDefinition(int pdg
 }
 
 //________________________________________________________________________
-G4PrimaryParticle* ISF::InputConverter::getG4PrimaryParticle(const HepMC::GenParticle& genpart) const
-{
+#ifdef HEPMC3
+G4PrimaryParticle* ISF::InputConverter::getG4PrimaryParticle(const HepMC::GenParticlePtr genpart) const{
+
+return nullptr;
+}
+#else
+G4PrimaryParticle* ISF::InputConverter::getG4PrimaryParticle(const HepMC::GenParticle& genpart) const{
   ATH_MSG_VERBOSE("Creating G4PrimaryParticle from GenParticle.");
 
   const G4ParticleDefinition *particleDefinition = this->getG4ParticleDefinition(genpart.pdg_id());
@@ -433,26 +480,35 @@ G4PrimaryParticle* ISF::InputConverter::getG4PrimaryParticle(const HepMC::GenPar
       ATH_MSG_VERBOSE( "Detected primary particle with end vertex." );
       ATH_MSG_VERBOSE( "Will add the primary particle set on." );
       ATH_MSG_VERBOSE( "Primary Particle: " << genpart );
+#ifdef HEPMC3
+
+#else
       ATH_MSG_VERBOSE( "Number of daughters of "<<genpart.barcode()<<": " << genpart.end_vertex()->particles_out_size() );
+#endif
     }
     else {
       ATH_MSG_WARNING( "Detected primary particle with end vertex." );
       ATH_MSG_WARNING( "Will add the primary particle set on." );
       ATH_MSG_WARNING( "Primary Particle: " << genpart );
+#ifdef HEPMC3
+
+#else
+
       ATH_MSG_WARNING( "Number of daughters of "<<genpart.barcode()<<": " << genpart.end_vertex()->particles_out_size() );
+#endif
     }
     // Add all necessary daughter particles
     for ( auto daughterIter=genpart.end_vertex()->particles_out_const_begin();
           daughterIter!=genpart.end_vertex()->particles_out_const_end(); ++daughterIter ) {
       if(m_quasiStableParticlesIncluded) {
-        ATH_MSG_VERBOSE ( "Attempting to add daughter particle of "<<genpart.barcode()<<": " << **daughterIter );
+        ATH_MSG_VERBOSE ( "Attempting to add daughter particle of "<<HepMC::barcode(genpart)<<": " << **daughterIter );
       }
       else {
-        ATH_MSG_WARNING ( "Attempting to add daughter particle of "<<genpart.barcode()<<": " << **daughterIter );
+        ATH_MSG_WARNING ( "Attempting to add daughter particle of "<<HepMC::barcode(genpart)<<": " << **daughterIter );
       }
       G4PrimaryParticle *daughterG4Particle = this->getG4PrimaryParticle( **daughterIter );
       if(!daughterG4Particle) {
-        ATH_MSG_ERROR("Bailing out of loop over daughters of particle with barcode: "<<genpart.barcode() <<
+        ATH_MSG_ERROR("Bailing out of loop over daughters of particle with barcode: "<<HepMC::barcode(genpart) <<
                       " due to errors - will not return G4Particle.");
         return nullptr;
       }
@@ -469,6 +525,7 @@ G4PrimaryParticle* ISF::InputConverter::getG4PrimaryParticle(const HepMC::GenPar
 
   return g4particle.release();
 }
+#endif
 
 
 //________________________________________________________________________
@@ -540,8 +597,11 @@ G4PrimaryParticle* ISF::InputConverter::getG4PrimaryParticle(const ISF::ISFParti
         ATH_MSG_VERBOSE( "Detected primary particle with end vertex." );
         ATH_MSG_VERBOSE( "Will add the primary particle set on." );
         ATH_MSG_VERBOSE( "ISF Particle: " << isp );
+#ifdef HEPMC3
+#else
         ATH_MSG_VERBOSE( "Primary Particle: " << *genpart );
         ATH_MSG_VERBOSE( "Number of daughters of "<<genpart->barcode()<<": " << genpart->end_vertex()->particles_out_size() );
+#endif
       }
       else {
         ATH_MSG_WARNING( "Detected primary particle with end vertex. This should only be the case if" );
@@ -549,26 +609,32 @@ G4PrimaryParticle* ISF::InputConverter::getG4PrimaryParticle(const ISF::ISFParti
         ATH_MSG_WARNING( "yet validated - you'd better know what you're doing.  Will add the primary" );
         ATH_MSG_WARNING( "particle set on." );
         ATH_MSG_WARNING( "ISF Particle: " << isp );
+#ifdef HEPMC3
+#else
         ATH_MSG_WARNING( "Primary Particle: " << *genpart );
-        ATH_MSG_WARNING( "Number of daughters of "<<genpart->barcode()<<": " << genpart->end_vertex()->particles_out_size() );
+        ATH_MSG_WARNING( "Number of daughters of "<<HepMC::barcode(genpart)<<": " << genpart->end_vertex()->particles_out_size() );
+#endif
       }
       // Add all necessary daughter particles
+#ifdef HEPMC3
+#else
       for ( auto daughterIter=genpart->end_vertex()->particles_out_const_begin();
             daughterIter!=genpart->end_vertex()->particles_out_const_end(); ++daughterIter ) {
         if(m_quasiStableParticlesIncluded) {
-          ATH_MSG_VERBOSE ( "Attempting to add daughter particle of "<<genpart->barcode()<<": " << **daughterIter );
+          ATH_MSG_VERBOSE ( "Attempting to add daughter particle of "<<HepMC::barcode(genpart)<<": " << **daughterIter );
         }
         else {
-          ATH_MSG_WARNING ( "Attempting to add daughter particle of "<<genpart->barcode()<<": " << **daughterIter );
+          ATH_MSG_WARNING ( "Attempting to add daughter particle of "<<HepMC::barcode(genpart)<<": " << **daughterIter );
         }
         G4PrimaryParticle *daughterG4Particle = this->getG4PrimaryParticle( **daughterIter );
         if(!daughterG4Particle) {
-          ATH_MSG_ERROR("Bailing out of loop over daughters of particle with barcode: "<<genpart->barcode() <<
+          ATH_MSG_ERROR("Bailing out of loop over daughters of particle with barcode: "<<HepMC::barcode(genpart) <<
                         " due to errors - will not return G4Particle.");
           return nullptr;
         }
         g4particle->SetDaughter( daughterG4Particle );
       }
+#endif     
     } // particle had an end vertex
     
     double px,py,pz;
diff --git a/Simulation/ISF/ISF_Core/ISF_Services/src/InputConverter.h b/Simulation/ISF/ISF_Core/ISF_Services/src/InputConverter.h
index 562aa431070c..4a440c1eccf2 100644
--- a/Simulation/ISF/ISF_Core/ISF_Services/src/InputConverter.h
+++ b/Simulation/ISF/ISF_Core/ISF_Services/src/InputConverter.h
@@ -83,7 +83,11 @@ namespace ISF {
 
     const G4ParticleDefinition* getG4ParticleDefinition(int pdgcode) const;
 
+#ifdef HEPMC3
+    G4PrimaryParticle* getG4PrimaryParticle(const HepMC::GenParticlePtr gp) const;
+#else
     G4PrimaryParticle* getG4PrimaryParticle(const HepMC::GenParticle& gp) const;
+#endif
 
     G4PrimaryParticle* getG4PrimaryParticle(const ISF::ISFParticle& isp, bool useHepMC) const;
 
@@ -93,13 +97,21 @@ namespace ISF {
     bool isInsideG4WorldVolume(const ISF::ISFParticle& isp, const G4VSolid* worldSolid) const;
 
     /** get right GenParticle mass */
+#ifdef HEPMC3
+    double getParticleMass(const HepMC::GenParticlePtr p) const;
+#else
     double getParticleMass(const HepMC::GenParticle& p) const;
+#endif
 
     /** get all generator particles which pass filters */
     std::vector<HepMC::GenParticlePtr > getSelectedParticles(const HepMC::GenEvent& evnt, bool legacyOrdering=false) const;
 
     /** check if the given particle passes all filters */
+#ifdef HEPMC3
+    bool passesFilters(const HepMC::GenParticlePtr p) const;
+#else
     bool passesFilters(const HepMC::GenParticle& p) const;
+#endif
 
     /** convert GenParticle to ISFParticle */
     ISF::ISFParticle* convertParticle(HepMC::GenParticlePtr genPartPtr, EBC_EVCOLL kindOfCollection=EBC_MAINEVCOLL) const;
diff --git a/Simulation/ISF/ISF_Core/ISF_Services/src/TruthSvc.cxx b/Simulation/ISF/ISF_Core/ISF_Services/src/TruthSvc.cxx
index 5ae0ceca71c4..40d043be59f2 100644
--- a/Simulation/ISF/ISF_Core/ISF_Services/src/TruthSvc.cxx
+++ b/Simulation/ISF/ISF_Core/ISF_Services/src/TruthSvc.cxx
@@ -132,18 +132,21 @@ StatusCode ISF::TruthSvc::initializeTruthCollection()
 }
 
 /** Delete child vertex */
-void ISF::TruthSvc::deleteChildVertex(HepMC::GenVertexPtr vertex) const {
-  std::vector<HepMC::GenVertexPtr> verticesToDelete;
+void ISF::TruthSvc::deleteChildVertex(HepMC::GenVertexPtr  vertex) const {
+  std::vector<HepMC::GenVertexPtr > verticesToDelete;
   verticesToDelete.resize(0);
   verticesToDelete.push_back(vertex);
   for ( unsigned short i = 0; i<verticesToDelete.size(); ++i ) {
-    HepMC::GenVertexPtr vtx = verticesToDelete.at(i);
+    HepMC::GenVertexPtr  vtx = verticesToDelete.at(i);
+#ifdef HEPMC3
+#else
     for (HepMC::GenVertex::particles_out_const_iterator iter = vtx->particles_out_const_begin();
          iter != vtx->particles_out_const_end(); ++iter) {
       if( (*iter) && (*iter)->end_vertex() ) {
         verticesToDelete.push_back( (*iter)->end_vertex() );
       }
     }
+#endif
     vtx->parent_event()->remove_vertex(vtx);
   }
   return;
@@ -277,6 +280,8 @@ void ISF::TruthSvc::recordIncidentToMCTruth( ISF::ITruthIncident& ti) const {
   HepMC::GenParticlePtr  parentBeforeIncident = ti.parentParticle();
   HepMC::GenParticlePtr  parentAfterIncident = ti.parentParticleAfterIncident( newPrimBC ); // This call changes ti.parentParticle() output
   if(parentAfterIncident) {
+#ifdef HEPMC3
+#else
     ATH_MSG_VERBOSE ( "Parent After Incident: " << *parentAfterIncident);
     if (classification==ISF::QS_SURV_VTX) {
       // Special case when a particle with a pre-defined decay
@@ -312,6 +317,7 @@ void ISF::TruthSvc::recordIncidentToMCTruth( ISF::ITruthIncident& ti) const {
     else {
       vtx->add_particle_out( parentAfterIncident );
     }
+#endif
   }
 
   const bool isQuasiStableVertex = (classification == ISF::QS_PREDEF_VTX); // QS_DEST_VTX and QS_SURV_VTX should be treated as normal from now on.
@@ -323,6 +329,8 @@ void ISF::TruthSvc::recordIncidentToMCTruth( ISF::ITruthIncident& ti) const {
     // FIXME should probably make this part a separate function and
     // also check if the pdgids of the child particles are the same
     // too.
+#ifdef HEPMC3
+#else
     unsigned short nVertexChildren=vtx->particles_out_size();
     if(parentAfterIncident) { nVertexChildren-=1; }
     if(nVertexChildren!=numSec) {
@@ -331,7 +339,12 @@ void ISF::TruthSvc::recordIncidentToMCTruth( ISF::ITruthIncident& ti) const {
     }
     ATH_MSG_VERBOSE("Existing vertex has " << nVertexChildren << " children. " <<
                  "Number of secondaries in current truth incident = " << numSec);
+#endif
   }
+
+#ifdef HEPMC3
+
+#else
   const std::vector<HepMC::GenParticlePtr> childParticleVector = (isQuasiStableVertex) ? MC::findChildren(ti.parentParticle()) : std::vector<HepMC::GenParticlePtr>();
   std::vector<HepMC::GenParticlePtr> matchedChildParticles;
   for ( unsigned short i=0; i<numSec; ++i) {
@@ -389,6 +402,7 @@ void ISF::TruthSvc::recordIncidentToMCTruth( ISF::ITruthIncident& ti) const {
     }
 
   } // <-- loop over all child particles
+#endif
   ATH_MSG_VERBOSE("--------------------------------------------------------");
 }
 
@@ -429,8 +443,14 @@ HepMC::GenVertexPtr  ISF::TruthSvc::createGenVertexFromTruthIncident( ISF::ITrut
     }
   }
   int vtxID = 1000 + static_cast<int>(processCode);
+#ifdef HEPMC3
+  HepMC::GenVertexPtr vtx;
+#else
   std::unique_ptr<HepMC::GenVertex> vtx = std::make_unique<HepMC::GenVertex>( ti.position(), vtxID, weights );
+#endif
   HepMC::suggest_barcode( vtx.get(), vtxbcode );
+#ifdef HEPMC3
+#else
 
   if (parent->end_vertex()){
     if(!m_quasiStableParticlesIncluded) {
@@ -476,6 +496,7 @@ HepMC::GenVertexPtr  ISF::TruthSvc::createGenVertexFromTruthIncident( ISF::ITrut
 #endif
     mcEvent->add_vertex( vtx.release() );
   }
+#endif
 
   return parent->end_vertex();
 }
@@ -500,6 +521,9 @@ void ISF::TruthSvc::setSharedChildParticleBarcode( ISF::ITruthIncident& ti) cons
 int ISF::TruthSvc::maxGeneratedParticleBarcode(HepMC::GenEvent *genEvent) const {
   int maxBarcode=0;
   const int firstSecondaryParticleBarcode(m_barcodeSvc->secondaryParticleBcOffset());
+#ifdef HEPMC3
+
+#else
   HepMC::GenEvent::particle_const_iterator currentGenParticleIter;
   for (currentGenParticleIter= genEvent->particles_begin();
        currentGenParticleIter!= genEvent->particles_end();
@@ -507,11 +531,15 @@ int ISF::TruthSvc::maxGeneratedParticleBarcode(HepMC::GenEvent *genEvent) const
     const int barcode((*currentGenParticleIter)->barcode());
     if(barcode > maxBarcode && barcode < firstSecondaryParticleBarcode) { maxBarcode=barcode; }
   }
+#endif
   return maxBarcode;
 }
 
 int ISF::TruthSvc::maxGeneratedVertexBarcode(HepMC::GenEvent *genEvent) const {
   int maxBarcode=0;
+#ifdef HEPMC3
+
+#else
   const int firstSecondaryVertexBarcode(m_barcodeSvc->secondaryVertexBcOffset());
   HepMC::GenEvent::vertex_const_iterator currentGenVertexIter;
   for (currentGenVertexIter= genEvent->vertices_begin();
@@ -520,5 +548,6 @@ int ISF::TruthSvc::maxGeneratedVertexBarcode(HepMC::GenEvent *genEvent) const {
     const int barcode((*currentGenVertexIter)->barcode());
     if(barcode < maxBarcode && barcode > firstSecondaryVertexBarcode) { maxBarcode=barcode; }
   }
+#endif
   return maxBarcode;
 }
diff --git a/Simulation/ISF/ISF_Core/ISF_Services/test/InputConverter_test.cxx b/Simulation/ISF/ISF_Core/ISF_Services/test/InputConverter_test.cxx
index ea5c25131f40..17813c67825b 100644
--- a/Simulation/ISF/ISF_Core/ISF_Services/test/InputConverter_test.cxx
+++ b/Simulation/ISF/ISF_Core/ISF_Services/test/InputConverter_test.cxx
@@ -159,7 +159,7 @@ TEST_F(InputConverter_test, convertParticle_nullptr) {
 
 TEST_F(InputConverter_test, convertParticle_without_production_vertex) {
   HepMC::FourVector mom(12.3, 45.6, 78.9, 0.12);
-  HepMC::GenParticlePtr  genPart = new HepMC::GenParticle(mom,
+  HepMC::GenParticlePtr  genPart = HepMC::newGenParticlePtr(mom,
                                                        123, // pdg
                                                        1 // status
                                                       );
@@ -232,7 +232,7 @@ TEST_F(InputConverter_test, convertParticle_using_particleDataTable_photon) {
   HepMC::FourVector mom(12.3, 45.6, 78.9, 0.12);
   // dynamic allocation necessary as particle ownership is
   // handed over to a HepMC::GenVertex later
-  HepMC::GenParticlePtr  genPart = new HepMC::GenParticle(mom,
+  HepMC::GenParticlePtr  genPart = HepMC::newGenParticlePtr(mom,
                                                        22, // pdg id (gamma)
                                                        1 // status
                                                       );
@@ -241,7 +241,7 @@ TEST_F(InputConverter_test, convertParticle_using_particleDataTable_photon) {
 
   HepMC::FourVector pos(9.8, 7.65, 4.3, 0.321); // NB: 4th component is time*c
   int vtx_id = -123;
-  HepMC::GenVertexPtr  prodVtx = new HepMC::GenVertex(pos, vtx_id);
+  HepMC::GenVertexPtr  prodVtx = HepMC::newGenVertexPtr(pos, vtx_id);
   prodVtx->add_particle_out(genPart);
 
   // create dummy input McEventCollection containing a dummy GenEvent
@@ -286,7 +286,7 @@ TEST_F(InputConverter_test, convertParticle_using_particleDataTable_electron) {
   HepMC::FourVector mom(12.3, 45.6, 78.9, 0.12);
   // dynamic allocation necessary as particle ownership is
   // handed over to a HepMC::GenVertex later
-  HepMC::GenParticlePtr  genPart = new HepMC::GenParticle(mom,
+  HepMC::GenParticlePtr  genPart = HepMC::newGenParticlePtr(mom,
                                                        11, // pdg id (e-)
                                                        1 // status
                                                       );
@@ -295,7 +295,7 @@ TEST_F(InputConverter_test, convertParticle_using_particleDataTable_electron) {
 
   HepMC::FourVector pos(9.8, 7.65, 4.3, 0.321); // NB: 4th component is time*c
   int vtx_id = -123;
-  HepMC::GenVertexPtr  prodVtx = new HepMC::GenVertex(pos, vtx_id);
+  HepMC::GenVertexPtr  prodVtx = HepMC::newGenVertexPtr(pos, vtx_id);
   prodVtx->add_particle_out(genPart);
 
   // create dummy input McEventCollection containing a dummy GenEvent
diff --git a/Simulation/ISF/ISF_Core/ISF_Services/test/TruthSvc_test.cxx b/Simulation/ISF/ISF_Core/ISF_Services/test/TruthSvc_test.cxx
index 7f998b5bfbf9..67ad9d4a331e 100644
--- a/Simulation/ISF/ISF_Core/ISF_Services/test/TruthSvc_test.cxx
+++ b/Simulation/ISF/ISF_Core/ISF_Services/test/TruthSvc_test.cxx
@@ -274,18 +274,18 @@ namespace ISFTesting {
     const int pdgid2(13);
     std::unique_ptr<HepMC::GenEvent> anEvent = std::make_unique<HepMC::GenEvent>(process_id1, event_number1);
     const CLHEP::HepLorentzVector myPos( 0.0, 0.0, 0.0, 0.0);
-    HepMC::GenVertexPtr  myVertex = new HepMC::GenVertex( myPos, -1 );
+    HepMC::GenVertexPtr  myVertex = HepMC::newGenVertexPtr( myPos, -1 );
     const HepMC::FourVector fourMomentum1( 0.0, 0.0, 1.0, 1.0*CLHEP::TeV);
-    HepMC::GenParticlePtr  inParticle1 = new HepMC::GenParticle(fourMomentum1, pdgid1, 2);
+    HepMC::GenParticlePtr  inParticle1 = HepMC::newGenParticlePtr(fourMomentum1, pdgid1, 2);
     myVertex->add_particle_in(inParticle1);
     const HepMC::FourVector fourMomentum2( 0.0, 0.0, -1.0, 1.0*CLHEP::TeV);
-    HepMC::GenParticlePtr  inParticle2 = new HepMC::GenParticle(fourMomentum2, pdgid2, 2);
+    HepMC::GenParticlePtr  inParticle2 = HepMC::newGenParticlePtr(fourMomentum2, pdgid2, 2);
     myVertex->add_particle_in(inParticle2);
     const HepMC::FourVector fourMomentum3( 0.0, 1.0, 0.0, 1.0*CLHEP::TeV);
-    HepMC::GenParticlePtr  inParticle3 = new HepMC::GenParticle(fourMomentum3, pdgid1, 1);
+    HepMC::GenParticlePtr  inParticle3 = HepMC::newGenParticlePtr(fourMomentum3, pdgid1, 1);
     myVertex->add_particle_out(inParticle3);
     const HepMC::FourVector fourMomentum4( 0.0, -1.0, 0.0, 1.0*CLHEP::TeV);
-    HepMC::GenParticlePtr  inParticle4 = new HepMC::GenParticle(fourMomentum4, pdgid2, 1);
+    HepMC::GenParticlePtr  inParticle4 = HepMC::newGenParticlePtr(fourMomentum4, pdgid2, 1);
     myVertex->add_particle_out(inParticle4);
     anEvent->add_vertex( myVertex );
     anEvent->set_signal_process_vertex( myVertex );
@@ -322,18 +322,18 @@ namespace ISFTesting {
     const int pdgid2(13);
     std::unique_ptr<HepMC::GenEvent> anEvent = std::make_unique<HepMC::GenEvent>(process_id1, event_number1);
     const CLHEP::HepLorentzVector myPos( 0.0, 0.0, 0.0, 0.0);
-    HepMC::GenVertexPtr  myVertex = new HepMC::GenVertex( myPos, -1 );
+    HepMC::GenVertexPtr  myVertex = HepMC::newGenVertexPtr( myPos, -1 );
     const HepMC::FourVector fourMomentum1( 0.0, 0.0, 1.0, 1.0*CLHEP::TeV);
-    HepMC::GenParticlePtr  inParticle1 = new HepMC::GenParticle(fourMomentum1, pdgid1, 2);
+    HepMC::GenParticlePtr  inParticle1 = HepMC::newGenParticlePtr(fourMomentum1, pdgid1, 2);
     myVertex->add_particle_in(inParticle1);
     const HepMC::FourVector fourMomentum2( 0.0, 0.0, -1.0, 1.0*CLHEP::TeV);
-    HepMC::GenParticlePtr  inParticle2 = new HepMC::GenParticle(fourMomentum2, pdgid2, 2);
+    HepMC::GenParticlePtr  inParticle2 = HepMC::newGenParticlePtr(fourMomentum2, pdgid2, 2);
     myVertex->add_particle_in(inParticle2);
     const HepMC::FourVector fourMomentum3( 0.0, 1.0, 0.0, 1.0*CLHEP::TeV);
-    HepMC::GenParticlePtr  inParticle3 = new HepMC::GenParticle(fourMomentum3, pdgid1, 1);
+    HepMC::GenParticlePtr  inParticle3 = HepMC::newGenParticlePtr(fourMomentum3, pdgid1, 1);
     myVertex->add_particle_out(inParticle3);
     const HepMC::FourVector fourMomentum4( 0.0, -1.0, 0.0, 1.0*CLHEP::TeV);
-    HepMC::GenParticlePtr  inParticle4 = new HepMC::GenParticle(fourMomentum4, pdgid2, 1);
+    HepMC::GenParticlePtr  inParticle4 = HepMC::newGenParticlePtr(fourMomentum4, pdgid2, 1);
     myVertex->add_particle_out(inParticle4);
     anEvent->add_vertex( myVertex );
     anEvent->set_signal_process_vertex( myVertex );
@@ -358,7 +358,7 @@ namespace ISFTesting {
       .WillOnce(::testing::Return(nullptr));
 
     recordIncidentToMCTruth(ti);
-    HepMC::GenVertexPtr  generated = anEvent->barcode_to_vertex(-200001); //Find a nicer way to get this.
+    HepMC::GenVertexPtr  generated = HepMC::barcode_to_vertex(anEvent,-200001); //Find a nicer way to get this.
     ASSERT_EQ( vtxPosition, generated->position() );
     ASSERT_EQ( 1021, generated->id() );
     ASSERT_EQ( -200001, generated->barcode() ); // by construction at the moment
@@ -377,18 +377,18 @@ namespace ISFTesting {
     const int pdgid2(13);
     std::unique_ptr<HepMC::GenEvent> anEvent = std::make_unique<HepMC::GenEvent>(process_id1, event_number1);
     const CLHEP::HepLorentzVector myPos( 0.0, 0.0, 0.0, 0.0);
-    HepMC::GenVertexPtr  myVertex = new HepMC::GenVertex( myPos, -1 );
+    HepMC::GenVertexPtr  myVertex = HepMC::newGenVertexPtr( myPos, -1 );
     const HepMC::FourVector fourMomentum1( 0.0, 0.0, 1.0, 1.0*CLHEP::TeV);
-    HepMC::GenParticlePtr  inParticle1 = new HepMC::GenParticle(fourMomentum1, pdgid1, 2);
+    HepMC::GenParticlePtr  inParticle1 = HepMC::newGenParticlePtr(fourMomentum1, pdgid1, 2);
     myVertex->add_particle_in(inParticle1);
     const HepMC::FourVector fourMomentum2( 0.0, 0.0, -1.0, 1.0*CLHEP::TeV);
-    HepMC::GenParticlePtr  inParticle2 = new HepMC::GenParticle(fourMomentum2, pdgid2, 2);
+    HepMC::GenParticlePtr  inParticle2 = HepMC::newGenParticlePtr(fourMomentum2, pdgid2, 2);
     myVertex->add_particle_in(inParticle2);
     const HepMC::FourVector fourMomentum3( 0.0, 1.0, 0.0, 1.0*CLHEP::TeV);
-    HepMC::GenParticlePtr  inParticle3 = new HepMC::GenParticle(fourMomentum3, pdgid1, 1);
+    HepMC::GenParticlePtr  inParticle3 = HepMC::newGenParticlePtr(fourMomentum3, pdgid1, 1);
     myVertex->add_particle_out(inParticle3);
     const HepMC::FourVector fourMomentum4( 0.0, -1.0, 0.0, 1.0*CLHEP::TeV);
-    HepMC::GenParticlePtr  inParticle4 = new HepMC::GenParticle(fourMomentum4, pdgid2, 1);
+    HepMC::GenParticlePtr  inParticle4 = HepMC::newGenParticlePtr(fourMomentum4, pdgid2, 1);
     myVertex->add_particle_out(inParticle4);
     anEvent->add_vertex( myVertex );
     anEvent->set_signal_process_vertex( myVertex );
@@ -404,7 +404,7 @@ namespace ISFTesting {
       .WillOnce(::testing::Return(inParticle3->barcode()));
 
     registerTruthIncident(ti);
-    HepMC::GenVertexPtr  generated = anEvent->barcode_to_vertex(-200001); //Find a nicer way to get this.
+    HepMC::GenVertexPtr  generated = HepMC::barcode_to_vertex(anEvent,-200001); //Find a nicer way to get this.
     HepMC::GenVertexPtr  expectedVtx(nullptr);
     ASSERT_EQ( expectedVtx, generated);
   }
@@ -421,18 +421,18 @@ namespace ISFTesting {
     const int pdgid2(13);
     std::unique_ptr<HepMC::GenEvent> anEvent = std::make_unique<HepMC::GenEvent>(process_id1, event_number1);
     const CLHEP::HepLorentzVector myPos( 0.0, 0.0, 0.0, 0.0);
-    HepMC::GenVertexPtr  myVertex = new HepMC::GenVertex( myPos, -1 );
+    HepMC::GenVertexPtr  myVertex = HepMC::newGenVertexPtr( myPos, -1 );
     const HepMC::FourVector fourMomentum1( 0.0, 0.0, 1.0, 1.0*CLHEP::TeV);
-    HepMC::GenParticlePtr  inParticle1 = new HepMC::GenParticle(fourMomentum1, pdgid1, 2);
+    HepMC::GenParticlePtr  inParticle1 = HepMC::newGenParticlePtr(fourMomentum1, pdgid1, 2);
     myVertex->add_particle_in(inParticle1);
     const HepMC::FourVector fourMomentum2( 0.0, 0.0, -1.0, 1.0*CLHEP::TeV);
-    HepMC::GenParticlePtr  inParticle2 = new HepMC::GenParticle(fourMomentum2, pdgid2, 2);
+    HepMC::GenParticlePtr  inParticle2 = HepMC::newGenParticlePtr(fourMomentum2, pdgid2, 2);
     myVertex->add_particle_in(inParticle2);
     const HepMC::FourVector fourMomentum3( 0.0, 1.0, 0.0, 1.0*CLHEP::TeV);
-    HepMC::GenParticlePtr  inParticle3 = new HepMC::GenParticle(fourMomentum3, pdgid1, 1);
+    HepMC::GenParticlePtr  inParticle3 = HepMC::newGenParticlePtr(fourMomentum3, pdgid1, 1);
     myVertex->add_particle_out(inParticle3);
     const HepMC::FourVector fourMomentum4( 0.0, -1.0, 0.0, 1.0*CLHEP::TeV);
-    HepMC::GenParticlePtr  inParticle4 = new HepMC::GenParticle(fourMomentum4, pdgid2, 1);
+    HepMC::GenParticlePtr  inParticle4 = HepMC::newGenParticlePtr(fourMomentum4, pdgid2, 1);
     myVertex->add_particle_out(inParticle4);
     anEvent->add_vertex( myVertex );
     anEvent->set_signal_process_vertex( myVertex );
@@ -454,7 +454,7 @@ namespace ISFTesting {
       .WillOnce(::testing::Return(inParticle3));
 
     registerTruthIncident(ti);
-    HepMC::GenVertexPtr  generated = anEvent->barcode_to_vertex(-200001); //Find a nicer way to get this.
+    HepMC::GenVertexPtr  generated = HepMC::barcode_to_vertex(anEvent,-200001); //Find a nicer way to get this.
     ASSERT_EQ( vtxPosition, generated->position() );
     ASSERT_EQ( 1021, generated->id() );
     ASSERT_EQ( -200001, generated->barcode() ); // by construction at the moment
@@ -484,18 +484,18 @@ namespace ISFTesting {
     const int pdgid2(13);
     std::unique_ptr<HepMC::GenEvent> anEvent = std::make_unique<HepMC::GenEvent>(process_id1, event_number1);
     const CLHEP::HepLorentzVector myPos( 0.0, 0.0, 0.0, 0.0);
-    HepMC::GenVertexPtr  myVertex = new HepMC::GenVertex( myPos, -1 );
+    HepMC::GenVertexPtr  myVertex = HepMC::newGenVertexPtr( myPos, -1 );
     const HepMC::FourVector fourMomentum1( 0.0, 0.0, 1.0, 1.0*CLHEP::TeV);
-    HepMC::GenParticlePtr  inParticle1 = new HepMC::GenParticle(fourMomentum1, pdgid1, 2);
+    HepMC::GenParticlePtr  inParticle1 = HepMC::newGenParticlePtr(fourMomentum1, pdgid1, 2);
     myVertex->add_particle_in(inParticle1);
     const HepMC::FourVector fourMomentum2( 0.0, 0.0, -1.0, 1.0*CLHEP::TeV);
-    HepMC::GenParticlePtr  inParticle2 = new HepMC::GenParticle(fourMomentum2, pdgid2, 2);
+    HepMC::GenParticlePtr  inParticle2 = HepMC::newGenParticlePtr(fourMomentum2, pdgid2, 2);
     myVertex->add_particle_in(inParticle2);
     const HepMC::FourVector fourMomentum3( 0.0, 1.0, 0.0, 1.0*CLHEP::TeV);
-    HepMC::GenParticlePtr  inParticle3 = new HepMC::GenParticle(fourMomentum3, pdgid1, 1);
+    HepMC::GenParticlePtr  inParticle3 = HepMC::newGenParticlePtr(fourMomentum3, pdgid1, 1);
     myVertex->add_particle_out(inParticle3);
     const HepMC::FourVector fourMomentum4( 0.0, -1.0, 0.0, 1.0*CLHEP::TeV);
-    HepMC::GenParticlePtr  inParticle4 = new HepMC::GenParticle(fourMomentum4, pdgid2, 1);
+    HepMC::GenParticlePtr  inParticle4 = HepMC::newGenParticlePtr(fourMomentum4, pdgid2, 1);
     myVertex->add_particle_out(inParticle4);
     anEvent->add_vertex( myVertex );
     anEvent->set_signal_process_vertex( myVertex );
@@ -524,7 +524,7 @@ namespace ISFTesting {
       .WillOnce(::testing::Return(false));
 
     registerTruthIncident(ti);
-    HepMC::GenVertexPtr  generated = anEvent->barcode_to_vertex(-200001); //Find a nicer way to get this.
+    HepMC::GenVertexPtr  generated = HepMC::barcode_to_vertex(anEvent,-200001); //Find a nicer way to get this.
     ASSERT_EQ( vtxPosition, generated->position() );
     ASSERT_EQ( 1021, generated->id() );
     ASSERT_EQ( -200001, generated->barcode() ); // by construction at the moment
@@ -551,23 +551,23 @@ namespace ISFTesting {
     const int pdgid2(13);
     std::unique_ptr<HepMC::GenEvent> anEvent = std::make_unique<HepMC::GenEvent>(process_id1, event_number1);
     const CLHEP::HepLorentzVector myPos( 0.0, 0.0, 0.0, 0.0);
-    HepMC::GenVertexPtr  myVertex = new HepMC::GenVertex( myPos, -1 );
+    HepMC::GenVertexPtr  myVertex = HepMC::newGenVertexPtr( myPos, -1 );
     const HepMC::FourVector fourMomentum1( 0.0, 0.0, 1.0, 1.0*CLHEP::TeV);
-    HepMC::GenParticlePtr  inParticle1 = new HepMC::GenParticle(fourMomentum1, pdgid1, 2);
+    HepMC::GenParticlePtr  inParticle1 = HepMC::newGenParticlePtr(fourMomentum1, pdgid1, 2);
     myVertex->add_particle_in(inParticle1);
     const HepMC::FourVector fourMomentum2( 0.0, 0.0, -1.0, 1.0*CLHEP::TeV);
-    HepMC::GenParticlePtr  inParticle2 = new HepMC::GenParticle(fourMomentum2, pdgid2, 2);
+    HepMC::GenParticlePtr  inParticle2 = HepMC::newGenParticlePtr(fourMomentum2, pdgid2, 2);
     myVertex->add_particle_in(inParticle2);
     const HepMC::FourVector fourMomentum3( 0.0, 1.0, 0.0, 1.0*CLHEP::TeV);
-    HepMC::GenParticlePtr  inParticle3 = new HepMC::GenParticle(fourMomentum3, pdgid1, 1);
+    HepMC::GenParticlePtr  inParticle3 = HepMC::newGenParticlePtr(fourMomentum3, pdgid1, 1);
     myVertex->add_particle_out(inParticle3);
     const HepMC::FourVector fourMomentum4( 0.0, -1.0, 0.0, 1.0*CLHEP::TeV);
-    HepMC::GenParticlePtr  inParticle4 = new HepMC::GenParticle(fourMomentum4, pdgid2, 1);
+    HepMC::GenParticlePtr  inParticle4 = HepMC::newGenParticlePtr(fourMomentum4, pdgid2, 1);
     myVertex->add_particle_out(inParticle4);
     anEvent->add_vertex( myVertex );
     anEvent->set_signal_process_vertex( myVertex );
     anEvent->set_beam_particles(inParticle1,inParticle2);
-    HepMC::GenParticlePtr  inParticle5 = new HepMC::GenParticle(fourMomentum3, pdgid1, 1);
+    HepMC::GenParticlePtr  inParticle5 = HepMC::newGenParticlePtr(fourMomentum3, pdgid1, 1);
     inParticle5->suggest_barcode(1010003);
     inParticle5->set_status(1);
 
@@ -597,7 +597,7 @@ namespace ISFTesting {
       .WillOnce(::testing::Return(true));
 
     registerTruthIncident(ti);
-    HepMC::GenVertexPtr  generated = anEvent->barcode_to_vertex(-200001); //Find a nicer way to get this.
+    HepMC::GenVertexPtr  generated = HepMC::barcode_to_vertex(anEvent,-200001); //Find a nicer way to get this.
     ASSERT_EQ( vtxPosition, generated->position() );
     ASSERT_EQ( 1021, generated->id() );
     ASSERT_EQ( -200001, generated->barcode() ); // by construction at the moment
diff --git a/Simulation/ISF/ISF_Fatras/ISF_FatrasRecoTools/ISF_FatrasRecoTools/PRD_PlanarTruthTrajectoryBuilder.h b/Simulation/ISF/ISF_Fatras/ISF_FatrasRecoTools/ISF_FatrasRecoTools/PRD_PlanarTruthTrajectoryBuilder.h
index 274be6f77222..7b0a65c0d682 100644
--- a/Simulation/ISF/ISF_Fatras/ISF_FatrasRecoTools/ISF_FatrasRecoTools/PRD_PlanarTruthTrajectoryBuilder.h
+++ b/Simulation/ISF/ISF_Fatras/ISF_FatrasRecoTools/ISF_FatrasRecoTools/PRD_PlanarTruthTrajectoryBuilder.h
@@ -57,7 +57,7 @@ namespace iFatras {
        StatusCode  finalize();
 
        /** return a vector of PrepRawData trajectories - uses internal cache**/
-       const std::map< const HepMC::GenParticle*, Trk::PRD_TruthTrajectory >& truthTrajectories() const;
+       const std::map< const HepMC::GenParticlePtr , Trk::PRD_TruthTrajectory >& truthTrajectories() const;
 
        /** Event refresh - can't be an IIncident, because it has to run after PRD creation and PRD truth creation */
        StatusCode refreshEvent();
@@ -83,7 +83,7 @@ namespace iFatras {
        //!< Track geantinos or not        
        bool                                                   m_geantinos;
        //!< the cache for the return (cleared by Incident)
-       mutable std::map< const HepMC::GenParticle*, Trk::PRD_TruthTrajectory > m_gpPrdTruthTrajectories; 
+       mutable std::map< const HepMC::GenParticlePtr , Trk::PRD_TruthTrajectory > m_gpPrdTruthTrajectories; 
   };
 
 } // end of namespace
diff --git a/Simulation/ISF/ISF_Fatras/ISF_FatrasRecoTools/src/PRD_PlanarTruthTrajectoryBuilder.cxx b/Simulation/ISF/ISF_Fatras/ISF_FatrasRecoTools/src/PRD_PlanarTruthTrajectoryBuilder.cxx
index 0e31e6c0261f..9b3c3adfe34e 100644
--- a/Simulation/ISF/ISF_Fatras/ISF_FatrasRecoTools/src/PRD_PlanarTruthTrajectoryBuilder.cxx
+++ b/Simulation/ISF/ISF_Fatras/ISF_FatrasRecoTools/src/PRD_PlanarTruthTrajectoryBuilder.cxx
@@ -105,7 +105,7 @@ StatusCode iFatras::PRD_PlanarTruthTrajectoryBuilder::refreshEvent()  {
    
 }
 
-const std::map< const HepMC::GenParticle*, Trk::PRD_TruthTrajectory >& iFatras::PRD_PlanarTruthTrajectoryBuilder::truthTrajectories() const {
+const std::map< const HepMC::GenParticlePtr , Trk::PRD_TruthTrajectory >& iFatras::PRD_PlanarTruthTrajectoryBuilder::truthTrajectories() const {
     // ndof
     size_t ndofTotal = 0;
     size_t ndof      = 0;
@@ -125,7 +125,7 @@ const std::map< const HepMC::GenParticle*, Trk::PRD_TruthTrajectory >& iFatras::
         for ( ; prdMtCIter != prdMtCIterE; ++ prdMtCIter ){
 	  ATH_MSG_VERBOSE("  2-Count " << second_count++ );
             // check if entry exists and if   
-            const HepMC::GenParticle* curGenP       = (*prdMtCIter).second;
+            const HepMC::GenParticlePtr  curGenP       = (*prdMtCIter).second;
             Identifier                curIdentifier = (*prdMtCIter).first;
             // apply the min pT cut 
             if ( curGenP->momentum().perp() < m_minPt ) continue;
@@ -139,7 +139,7 @@ const std::map< const HepMC::GenParticle*, Trk::PRD_TruthTrajectory >& iFatras::
             if (prd){
 	      ATH_MSG_VERBOSE("  I got the PRD for Id = " << curIdentifier );
                 // try to find the entry for this GenParticle 
-                std::map< const HepMC::GenParticle*, Trk::PRD_TruthTrajectory >::iterator prdTrajIter = m_gpPrdTruthTrajectories.find(curGenP);
+                std::map< const HepMC::GenParticlePtr , Trk::PRD_TruthTrajectory >::iterator prdTrajIter = m_gpPrdTruthTrajectories.find(curGenP);
                 if ( prdTrajIter ==  m_gpPrdTruthTrajectories.end() ){
                     // first PRD associated to this: create PRD_TruthTrajectory object
                     Trk::PRD_TruthTrajectory newPrdTruthTrajectory;
@@ -164,8 +164,8 @@ const std::map< const HepMC::GenParticle*, Trk::PRD_TruthTrajectory >& iFatras::
 
     // PART 2 --------------------------------------------------------------------------------------------------------
     // loop through the provided list of manipulators ( sorter is included )
-    std::map< const HepMC::GenParticle*, Trk::PRD_TruthTrajectory >::iterator prdTruthTrajIter  = m_gpPrdTruthTrajectories.begin();
-    std::map< const HepMC::GenParticle*, Trk::PRD_TruthTrajectory >::iterator prdTruthTrajIterE = m_gpPrdTruthTrajectories.end();
+    std::map< const HepMC::GenParticlePtr , Trk::PRD_TruthTrajectory >::iterator prdTruthTrajIter  = m_gpPrdTruthTrajectories.begin();
+    std::map< const HepMC::GenParticlePtr , Trk::PRD_TruthTrajectory >::iterator prdTruthTrajIterE = m_gpPrdTruthTrajectories.end();
     for ( ; prdTruthTrajIter != prdTruthTrajIterE; ++prdTruthTrajIter ){
         if ( m_prdTruthTrajectoryManipulators.size() ){
             ToolHandleArray<Trk::IPRD_TruthTrajectoryManipulator>::const_iterator prdTTMIter  = m_prdTruthTrajectoryManipulators.begin();
diff --git a/Simulation/ISF/ISF_Geant4/ISF_Geant4Event/src/ISFG4Helper.cxx b/Simulation/ISF/ISF_Geant4/ISF_Geant4Event/src/ISFG4Helper.cxx
index f84bbcf0bade..da7da14cc620 100644
--- a/Simulation/ISF/ISF_Geant4/ISF_Geant4Event/src/ISFG4Helper.cxx
+++ b/Simulation/ISF/ISF_Geant4/ISF_Geant4Event/src/ISFG4Helper.cxx
@@ -43,7 +43,11 @@ iGeant4::ISFG4Helper::convertG4TrackToISFParticle(const G4Track& aTrack,
   double charge  = particleDefinition.GetPDGCharge();
   int    pdgID   = particleDefinition.GetPDGEncoding();
 
+#ifdef HEPMC3
+  HepMC::GenParticlePtr genParticle;
+#else  
   auto* genParticle = (truth) ? truth->getTruthParticle(): nullptr;
+#endif
   Barcode::ParticleBarcode barcode = (genParticle) ? HepMC::barcode(genParticle) : Barcode::fUndefinedBarcode;
 
   ISF::ISFParticle *isp = new ISF::ISFParticle( position,
diff --git a/Simulation/ISF/ISF_Geant4/ISF_Geant4Tools/src/ISFTrajectory.cxx b/Simulation/ISF/ISF_Geant4/ISF_Geant4Tools/src/ISFTrajectory.cxx
index ae443c2c671f..cf77e2f97fb3 100644
--- a/Simulation/ISF/ISF_Geant4/ISF_Geant4Tools/src/ISFTrajectory.cxx
+++ b/Simulation/ISF/ISF_Geant4/ISF_Geant4Tools/src/ISFTrajectory.cxx
@@ -113,7 +113,11 @@ void iGeant4::ISFTrajectory::AppendStep(const G4Step* aStep)
         // make sure that the TruthBinding of the ISFParticle points to the newest
         // HepMC::GenParticle instance in case it got updated by the
         // ITruthSvc::registerTruthIncident call above
-        auto* currentGenPart = atlasG4EvtUserInfo->GetCurrentlyTraced();
+#ifdef HEPMC3
+        auto currentGenPart = eventInfo->GetCurrentlyTraced();
+#else
+        auto* currentGenPart = eventInfo->GetCurrentlyTraced();
+#endif
         baseIsp->getTruthBinding()->setTruthParticle( currentGenPart );
         Barcode::ParticleBarcode newBarcode = HepMC::barcode(currentGenPart);
         baseIsp->setBarcode( newBarcode );
diff --git a/Simulation/ISF/ISF_Geant4/ISF_Geant4Tools/src/PhysicsValidationUserAction.cxx b/Simulation/ISF/ISF_Geant4/ISF_Geant4Tools/src/PhysicsValidationUserAction.cxx
index 17e8a0fb8ef2..0536415ac975 100644
--- a/Simulation/ISF/ISF_Geant4/ISF_Geant4Tools/src/PhysicsValidationUserAction.cxx
+++ b/Simulation/ISF/ISF_Geant4/ISF_Geant4Tools/src/PhysicsValidationUserAction.cxx
@@ -240,16 +240,29 @@ namespace G4UA{
 	m_scIn = creation? creation->GetProcessSubType() : -1;
 	
 	VTrackInformation * trackInfo= static_cast<VTrackInformation*>(track->GetUserInformation());
+#ifdef HEPMC3
+	HepMC::GenParticlePtr  genpart;
+	HepMC::GenVertexPtr  vtx; 
+
+#else 
 	HepMC::GenParticlePtr genpart= trackInfo ? const_cast<HepMC::GenParticlePtr>(trackInfo->GetHepMCParticle()):0;
 	HepMC::GenVertex* vtx = genpart ? genpart->production_vertex() : 0;
+#endif
 	m_gen = genpart? 0 : -1;
 	
 	if (genpart)  { // mc truth known
 	  while (genpart && vtx ) {
 	    int pdgID=genpart->pdg_id();
+#ifdef HEPMC3
+	    HepMC::GenParticlePtr  genmom = vtx->particles_in().size()>0 ? vtx->particles_in().front() : nullptr;
+	    if ( genmom && pdgID!=genmom->pdg_id() ) m_gen++;
+	    else if (vtx->particles_out().size()>0 && genpart!=vtx->particles_out().front())) m_gen++;
+
+#else
 	    HepMC::GenParticlePtr genmom = vtx->particles_in_size()>0 ? *(vtx->particles_in_const_begin()) : 0;
 	    if ( genmom && pdgID!=genmom->pdg_id() ) m_gen++;
 	    else if (vtx->particles_out_size()>0 && genpart!=*(vtx->particles_out_const_begin())) m_gen++;
+#endif
 	    vtx = genmom ? genmom->production_vertex() : 0;
 	    genpart = genmom;
 	  }
diff --git a/Simulation/ISF/ISF_Geant4/ISF_Geant4Tools/src/TrackProcessorUserActionBase.cxx b/Simulation/ISF/ISF_Geant4/ISF_Geant4Tools/src/TrackProcessorUserActionBase.cxx
index dab4b903e432..7ee8f78bf789 100644
--- a/Simulation/ISF/ISF_Geant4/ISF_Geant4Tools/src/TrackProcessorUserActionBase.cxx
+++ b/Simulation/ISF/ISF_Geant4/ISF_Geant4Tools/src/TrackProcessorUserActionBase.cxx
@@ -93,7 +93,7 @@ void TrackProcessorUserActionBase::UserSteppingAction(const G4Step* aStep)
     // G4Tracks aready returned to ISF will have a TrackInformation attached to them
     bool particleReturnedToISF = trackInfo && trackInfo->GetReturnedToISF();
     if (!particleReturnedToISF) {
-      HepMC::GenParticlePtr generationZeroTruthParticle{};
+      HepMC::GenParticlePtr  generationZeroTruthParticle = nullptr;
       ::iGeant4::ISFG4Helper::attachTrackInfoToNewG4Track( *aSecondaryTrack,
                                                 *m_curBaseISP,
                                                 Secondary,
@@ -166,9 +166,15 @@ void TrackProcessorUserActionBase::setupPrimary(G4Track& aTrack)
   }
 
   int regenerationNr = ppInfo->GetRegenerationNr();
+#ifdef HEPMC3
+  auto primaryTruthParticle = truthBinding->getGenerationZeroTruthParticle();
+  auto generationZeroTruthParticle = truthBinding->getGenerationZeroTruthParticle();
+  auto currentlyTracedHepPart = truthBinding->getTruthParticle();
+#else
   auto* primaryTruthParticle = truthBinding->getGenerationZeroTruthParticle();
   auto* generationZeroTruthParticle = truthBinding->getGenerationZeroTruthParticle();
   auto* currentlyTracedHepPart = truthBinding->getTruthParticle();
+#endif
   auto classification = classify(primaryTruthParticle,
                                  generationZeroTruthParticle,
                                  currentlyTracedHepPart,
@@ -191,11 +197,15 @@ void TrackProcessorUserActionBase::setupSecondary(const G4Track& aTrack)
   auto* trackInfo = ::iGeant4::ISFG4Helper::getISFTrackInfo(aTrack);
 
   // why does TrackInformation return *const* GenParticle and ISFParticle objects!?
+#ifdef HEPMC3
+
+#else
   HepMC::GenParticlePtr currentlyTracedTruthParticle = const_cast<HepMC::GenParticlePtr>( trackInfo->GetHepMCParticle() );
   HepMC::GenParticlePtr primaryTruthParticle = const_cast<HepMC::GenParticlePtr>( trackInfo->GetPrimaryHepMCParticle() );
   auto* baseISFParticle = const_cast<ISF::ISFParticle*>( trackInfo->GetBaseISFParticle() );
 
   setCurrentParticle(baseISFParticle, primaryTruthParticle, currentlyTracedTruthParticle);
+#endif
   return;
 }
 
diff --git a/Simulation/ISF/ISF_Geant4/ISF_Geant4Tools/src/TrackProcessorUserActionPassBack.cxx b/Simulation/ISF/ISF_Geant4/ISF_Geant4Tools/src/TrackProcessorUserActionPassBack.cxx
index 1fdfb5dbe154..5c463ffdc91a 100644
--- a/Simulation/ISF/ISF_Geant4/ISF_Geant4Tools/src/TrackProcessorUserActionPassBack.cxx
+++ b/Simulation/ISF/ISF_Geant4/ISF_Geant4Tools/src/TrackProcessorUserActionPassBack.cxx
@@ -220,7 +220,7 @@ namespace G4UA {
                                                        Secondary,
                                                        generationZeroTruthParticle );
 
-            HepMC::GenParticlePtr truthParticle{};
+            HepMC::GenParticlePtr  truthParticle = nullptr;
             returnParticleToISF(aTrack_2nd, parent, truthParticle, nextGeoID_2nd);
           }
         }
@@ -241,9 +241,14 @@ namespace G4UA {
         G4Exception("iGeant4::TrackProcessorUserActionPassBack", "NoTrackInformation", FatalException, description);
         return nullptr; //The G4Exception call above should abort the job, but Coverity does not seem to pick this up.
       }
+#ifdef HEPMC3
+      HepMC::GenParticlePtr          primaryHepParticle;// = const_cast<HepMC::GenParticlePtr >(trackInfo->GetPrimaryHepMCParticle());
+      HepMC::GenParticlePtr   generationZeroHepParticle;// = const_cast<HepMC::GenParticlePtr >(trackInfo->GetHepMCParticle());
 
+#else
       HepMC::GenParticlePtr         primaryHepParticle = const_cast<HepMC::GenParticlePtr>(trackInfo->GetPrimaryHepMCParticle());
       HepMC::GenParticlePtr  generationZeroHepParticle = const_cast<HepMC::GenParticlePtr>(trackInfo->GetHepMCParticle());
+#endif
 
       ISF::TruthBinding* tBinding = new ISF::TruthBinding(truthParticle, primaryHepParticle, generationZeroHepParticle);
 
diff --git a/Simulation/ISF/ISF_HepMC/ISF_HepMC_Interfaces/ISF_HepMC_Interfaces/IGenParticleFilter.h b/Simulation/ISF/ISF_HepMC/ISF_HepMC_Interfaces/ISF_HepMC_Interfaces/IGenParticleFilter.h
index a98278528158..e3610f8c9b38 100644
--- a/Simulation/ISF/ISF_HepMC/ISF_HepMC_Interfaces/ISF_HepMC_Interfaces/IGenParticleFilter.h
+++ b/Simulation/ISF/ISF_HepMC/ISF_HepMC_Interfaces/ISF_HepMC_Interfaces/IGenParticleFilter.h
@@ -37,8 +37,13 @@ namespace ISF {
        /// Creates the InterfaceID and interfaceID() method
        DeclareInterfaceID(IGenParticleFilter, 1, 0);
        
+#ifdef HEPMC3
+       /** Returns a boolean if the particle has passed or not */
+       virtual bool pass(const HepMC::GenParticlePtr& particle) const = 0;
+#else
        /** Returns a boolean if the particle has passed or not */
        virtual bool pass(const HepMC::GenParticle& particle) const = 0;
+#endif
        
   };
 
diff --git a/Simulation/ISF/ISF_HepMC/ISF_HepMC_Tools/src/GenParticleFinalStateFilter.cxx b/Simulation/ISF/ISF_HepMC/ISF_HepMC_Tools/src/GenParticleFinalStateFilter.cxx
index 7ce0aa81d86c..8635e159b2ff 100644
--- a/Simulation/ISF/ISF_HepMC/ISF_HepMC_Tools/src/GenParticleFinalStateFilter.cxx
+++ b/Simulation/ISF/ISF_HepMC/ISF_HepMC_Tools/src/GenParticleFinalStateFilter.cxx
@@ -39,6 +39,12 @@ StatusCode  ISF::GenParticleFinalStateFilter::initialize()
 
 
 /** returns true if the the particle is considered stable */
+#ifdef HEPMC3
+bool ISF::GenParticleFinalStateFilter::pass(const HepMC::GenParticlePtr& particle) const
+{
+return true;
+}	
+#else
 bool ISF::GenParticleFinalStateFilter::pass(const HepMC::GenParticle& particle) const
 {
   bool passFilter = true;
@@ -49,6 +55,7 @@ bool ISF::GenParticleFinalStateFilter::pass(const HepMC::GenParticle& particle)
   return passFilter;
 }
 
+#endif
 
 StatusCode  ISF::GenParticleFinalStateFilter::finalize()
 {
@@ -57,9 +64,14 @@ StatusCode  ISF::GenParticleFinalStateFilter::finalize()
 }
 
 /** checks if the particle is in its final state (no end vertex) */
+#ifdef HEPMC3
+bool ISF::GenParticleFinalStateFilter::isFinalState(const HepMC::GenParticlePtr &p) const {
+return true;
+#else
 bool ISF::GenParticleFinalStateFilter::isFinalState(const HepMC::GenParticle &p) const {
   // particle is in its final state if both:
   //  * no end_vertex
   //  * status==1
   return ( !p.end_vertex() && p.status()==1 );
+#endif
 }
diff --git a/Simulation/ISF/ISF_HepMC/ISF_HepMC_Tools/src/GenParticleFinalStateFilter.h b/Simulation/ISF/ISF_HepMC/ISF_HepMC_Tools/src/GenParticleFinalStateFilter.h
index 1e6e3dceb61d..6846ab3d1cb7 100644
--- a/Simulation/ISF/ISF_HepMC/ISF_HepMC_Tools/src/GenParticleFinalStateFilter.h
+++ b/Simulation/ISF/ISF_HepMC/ISF_HepMC_Tools/src/GenParticleFinalStateFilter.h
@@ -42,12 +42,21 @@ namespace ISF {
       StatusCode  initialize();
       StatusCode  finalize();
 
+#ifdef HEPMC3
+      /** Returns the Particle Stack, should register truth */
+      bool pass(const HepMC::GenParticlePtr& particle) const;
+        private:
+      /** checks if the particle is in its final state (no end vertex) */
+      bool isFinalState( const HepMC::GenParticlePtr& p) const;
+#else
+
       /** Returns the Particle Stack, should register truth */
       bool pass(const HepMC::GenParticle& particle) const;
 
         private:
       /** checks if the particle is in its final state (no end vertex) */
       bool isFinalState( const HepMC::GenParticle& p) const;
+#endif
 
       bool                              m_checkGenSimStable;    //!< boolean switch to check on sim stable
       bool                              m_checkGenInteracting;  //!< boolean switch to check on gen interacting
diff --git a/Simulation/ISF/ISF_HepMC/ISF_HepMC_Tools/src/GenParticleGenericFilter.cxx b/Simulation/ISF/ISF_HepMC/ISF_HepMC_Tools/src/GenParticleGenericFilter.cxx
index f4a54d5845c4..744e8b0b2089 100644
--- a/Simulation/ISF/ISF_HepMC/ISF_HepMC_Tools/src/GenParticleGenericFilter.cxx
+++ b/Simulation/ISF/ISF_HepMC/ISF_HepMC_Tools/src/GenParticleGenericFilter.cxx
@@ -81,17 +81,29 @@ StatusCode  ISF::GenParticleGenericFilter::finalize()
 
 
 /** Returns whether the given particle passes all cuts or not */
+#ifdef HEPMC3
+bool ISF::GenParticleGenericFilter::pass(const HepMC::GenParticlePtr& particle) const
+#else
 bool ISF::GenParticleGenericFilter::pass(const HepMC::GenParticle& particle) const
+#endif
 {
   bool pass = true;
 
-  HepMC::ConstGenVertexPtr productionVertex = particle.production_vertex();
+#ifdef HEPMC3
+  const auto productionVertex = particle->production_vertex();
+#else
+  const auto* productionVertex = particle.production_vertex();
+#endif
   const auto* position = productionVertex ? &productionVertex->position() : nullptr;
   if (!position || position->perp()<=m_maxApplicableRadius) {
     pass = check_cuts_passed(particle);
   }
 
+#ifdef HEPMC3
+  const auto& momentum = particle->momentum();
+#else
   const auto& momentum = particle.momentum();
+#endif
   ATH_MSG_VERBOSE( "GenParticle '" << particle << "' with "
                    << (position ? "pos: r=" + std::to_string(position->perp()) : "")
                    << ", mom: eta=" << momentum.eta() << " phi=" << momentum.phi()
@@ -102,6 +114,12 @@ bool ISF::GenParticleGenericFilter::pass(const HepMC::GenParticle& particle) con
 
 
 /** Check whether the given particle passes all configure cuts or not */
+#ifdef HEPMC3
+bool ISF::GenParticleGenericFilter::check_cuts_passed(const HepMC::GenParticlePtr & particle) const {
+  int pdg = particle->pdg_id();
+  const auto& momentum = particle->momentum();
+  double mom =-1;;
+#else
 bool ISF::GenParticleGenericFilter::check_cuts_passed(const HepMC::GenParticle &particle) const {
   const auto& momentum = particle.momentum();
   double mom = std::sqrt(momentum.x()*momentum.x()+momentum.y()*momentum.y()+momentum.z()*momentum.z());
diff --git a/Simulation/ISF/ISF_HepMC/ISF_HepMC_Tools/src/GenParticleGenericFilter.h b/Simulation/ISF/ISF_HepMC/ISF_HepMC_Tools/src/GenParticleGenericFilter.h
index b4c7129bcac6..4b148ba466d2 100644
--- a/Simulation/ISF/ISF_HepMC/ISF_HepMC_Tools/src/GenParticleGenericFilter.h
+++ b/Simulation/ISF/ISF_HepMC/ISF_HepMC_Tools/src/GenParticleGenericFilter.h
@@ -52,11 +52,19 @@ typedef std::vector<int>      PDGCodes;
     StatusCode  finalize();
 
     /// Interface method that returns whether the given particle passes all cuts or not
+#ifdef HEPMC3
+    bool pass(const HepMC::GenParticlePtr& particle) const;
+#else
     bool pass(const HepMC::GenParticle& particle) const;
+#endif
 
   private:
     /// Check whether the given particle passes all configure cuts or not
+#ifdef HEPMC3
+    bool check_cuts_passed(const HepMC::GenParticlePtr& particle) const;
+#else
     bool check_cuts_passed(const HepMC::GenParticle& particle) const;
+#endif
 
     /// the cuts defined by the use
     double        m_minEta;     //!< min pseudorapidity cut
diff --git a/Simulation/ISF/ISF_HepMC/ISF_HepMC_Tools/src/GenParticleInteractingFilter.cxx b/Simulation/ISF/ISF_HepMC/ISF_HepMC_Tools/src/GenParticleInteractingFilter.cxx
index dbf3eff74505..9d5c9b7a9cc0 100644
--- a/Simulation/ISF/ISF_HepMC/ISF_HepMC_Tools/src/GenParticleInteractingFilter.cxx
+++ b/Simulation/ISF/ISF_HepMC/ISF_HepMC_Tools/src/GenParticleInteractingFilter.cxx
@@ -11,6 +11,7 @@
 
 // HepMC includes
 #include "AtlasHepMC/GenParticle.h"
+#include "AtlasHepMC/Flow.h"
 
 // Helper function
 #include "TruthUtils/HepMCHelpers.h"
@@ -67,6 +68,13 @@ StatusCode ISF::GenParticleInteractingFilter::initialize()
 }
 
 /** passes through to the private version of the filter */
+#ifdef HEPMC3
+bool ISF::GenParticleInteractingFilter::pass(const HepMC::GenParticlePtr& particle) const
+{
+  const int& pdg_id = particle->pdg_id();
+return true;
+}
+#else
 bool ISF::GenParticleInteractingFilter::pass(const HepMC::GenParticle& particle) const
 {
   const int& pdg_id = particle.pdg_id();
@@ -78,4 +86,5 @@ bool ISF::GenParticleInteractingFilter::pass(const HepMC::GenParticle& particle)
                                 pdg_id) != m_additionalNonInteractingParticleTypes.end();
   return !(MC::isNonInteracting( &particle ) || isNonInteracting) || isInteracting;
 }
+#endif
 
diff --git a/Simulation/ISF/ISF_HepMC/ISF_HepMC_Tools/src/GenParticleInteractingFilter.h b/Simulation/ISF/ISF_HepMC/ISF_HepMC_Tools/src/GenParticleInteractingFilter.h
index 97f0011043c8..22a3e829dbb1 100644
--- a/Simulation/ISF/ISF_HepMC/ISF_HepMC_Tools/src/GenParticleInteractingFilter.h
+++ b/Simulation/ISF/ISF_HepMC/ISF_HepMC_Tools/src/GenParticleInteractingFilter.h
@@ -18,6 +18,7 @@
 // STL includes
 #include <string>
 
+#include "AtlasHepMC/GenParticle.h"
 namespace ISF {
 
     class ISFParticle;
@@ -40,9 +41,14 @@ namespace ISF {
 
       /** Framework methods */
       virtual StatusCode initialize() override;
+#ifdef HEPMC3
+      /** passes through to the private version */
+      virtual bool pass(const HepMC::GenParticlePtr& particle ) const override;
+#else
 
       /** passes through to the private version */
       virtual bool pass(const HepMC::GenParticle& particle ) const override;
+#endif
 
       /** Additional PDG codes to classify as interacting */
       std::vector<int> m_additionalInteractingParticleTypes;
diff --git a/Simulation/ISF/ISF_HepMC/ISF_HepMC_Tools/src/GenParticleLifetimeFilter.cxx b/Simulation/ISF/ISF_HepMC/ISF_HepMC_Tools/src/GenParticleLifetimeFilter.cxx
index dd4edc16bdb1..8f3a6cda72b8 100644
--- a/Simulation/ISF/ISF_HepMC/ISF_HepMC_Tools/src/GenParticleLifetimeFilter.cxx
+++ b/Simulation/ISF/ISF_HepMC/ISF_HepMC_Tools/src/GenParticleLifetimeFilter.cxx
@@ -27,10 +27,18 @@ ISF::GenParticleLifetimeFilter::GenParticleLifetimeFilter( const std::string& t,
 
 
 /** does the given particle pass the filter? */
+#ifdef HEPMC3
+bool ISF::GenParticleLifetimeFilter::pass(const HepMC::GenParticlePtr& particle) const
+#else
 bool ISF::GenParticleLifetimeFilter::pass(const HepMC::GenParticle& particle) const
+#endif
 {
   // the GenParticle end vertex
-  auto endVtx = particle.end_vertex();
+#ifdef HEPMC3
+  auto  endVtx = particle->end_vertex();
+#else
+  HepMC::GenVertexPtr  endVtx = particle.end_vertex();
+#endif
   // no production vertex?
   if (!endVtx) {
     ATH_MSG_DEBUG("GenParticle does not have an end vertex, this is fine");
@@ -40,7 +48,11 @@ bool ISF::GenParticleLifetimeFilter::pass(const HepMC::GenParticle& particle) co
   const auto& end4Vec = endVtx->position();
 
   // the GenParticle production vertex
-  auto  prodVtx = particle.production_vertex();
+#ifdef HEPMC3
+  HepMC::GenVertexPtr  prodVtx = particle->production_vertex();
+#else
+  HepMC::GenVertexPtr  prodVtx = particle.production_vertex();
+#endif
   // no production vertex?
   if (!prodVtx) {
     ATH_MSG_DEBUG("GenParticle does not have a production vertex, filtering it out");
diff --git a/Simulation/ISF/ISF_HepMC/ISF_HepMC_Tools/src/GenParticleLifetimeFilter.h b/Simulation/ISF/ISF_HepMC/ISF_HepMC_Tools/src/GenParticleLifetimeFilter.h
index f5629f8adde5..feca30f6caa0 100644
--- a/Simulation/ISF/ISF_HepMC/ISF_HepMC_Tools/src/GenParticleLifetimeFilter.h
+++ b/Simulation/ISF/ISF_HepMC/ISF_HepMC_Tools/src/GenParticleLifetimeFilter.h
@@ -34,7 +34,11 @@ namespace ISF {
     ~GenParticleLifetimeFilter(){}
 
     /** does the given particle pass the filter? */
+#ifdef HEPMC3
+    bool pass(const HepMC::GenParticlePtr& particle) const;
+#else
     bool pass(const HepMC::GenParticle& particle) const;
+#endif
 
   private:
     double m_minLifetime{0.000001}; //units of c*ns
diff --git a/Simulation/ISF/ISF_HepMC/ISF_HepMC_Tools/src/GenParticlePositionFilter.cxx b/Simulation/ISF/ISF_HepMC/ISF_HepMC_Tools/src/GenParticlePositionFilter.cxx
index 597933ec224e..2e03bcba0d2e 100644
--- a/Simulation/ISF/ISF_HepMC/ISF_HepMC_Tools/src/GenParticlePositionFilter.cxx
+++ b/Simulation/ISF/ISF_HepMC/ISF_HepMC_Tools/src/GenParticlePositionFilter.cxx
@@ -12,6 +12,7 @@
 // HepMC includes
 #include "AtlasHepMC/GenParticle.h"
 #include "AtlasHepMC/GenVertex.h"
+#include "AtlasHepMC/SimpleVector.h"
 
 /** Constructor **/
 ISF::GenParticlePositionFilter::GenParticlePositionFilter( const std::string& t,
@@ -48,6 +49,12 @@ StatusCode  ISF::GenParticlePositionFilter::initialize()
 
 
 /** does the given particle pass the filter? */
+#ifdef HEPMC3
+bool ISF::GenParticlePositionFilter::pass(const HepMC::GenParticlePtr& particle) const
+{
+  // the GenParticle production vertex
+  HepMC::GenVertexPtr  vtx = particle->production_vertex();
+#else
 bool ISF::GenParticlePositionFilter::pass(const HepMC::GenParticle& particle) const
 {
   // the GenParticle production vertex
diff --git a/Simulation/ISF/ISF_HepMC/ISF_HepMC_Tools/src/GenParticlePositionFilter.h b/Simulation/ISF/ISF_HepMC/ISF_HepMC_Tools/src/GenParticlePositionFilter.h
index 18b0c3201542..ff9d5802eb14 100644
--- a/Simulation/ISF/ISF_HepMC/ISF_HepMC_Tools/src/GenParticlePositionFilter.h
+++ b/Simulation/ISF/ISF_HepMC/ISF_HepMC_Tools/src/GenParticlePositionFilter.h
@@ -45,7 +45,11 @@ namespace ISF {
       StatusCode  finalize();
 
       /** does the given particle pass the filter? */
+#ifdef HEPMC3
+      bool pass(const HepMC::GenParticlePtr& particle) const;
+#else
       bool pass(const HepMC::GenParticle& particle) const;
+#endif 
 	  
 	private:
       ServiceHandle<IGeoIDSvc>          m_geoIDSvc;
diff --git a/Simulation/ISF/ISF_HepMC/ISF_HepMC_Tools/src/GenParticleSimWhiteList.cxx b/Simulation/ISF/ISF_HepMC/ISF_HepMC_Tools/src/GenParticleSimWhiteList.cxx
index c4fefcb3daf6..030b7b846cc9 100644
--- a/Simulation/ISF/ISF_HepMC/ISF_HepMC_Tools/src/GenParticleSimWhiteList.cxx
+++ b/Simulation/ISF/ISF_HepMC/ISF_HepMC_Tools/src/GenParticleSimWhiteList.cxx
@@ -72,7 +72,11 @@ StatusCode  ISF::GenParticleSimWhiteList::initialize()
 }
 
 /** passes through to the private version of the filter */
+#ifdef HEPMC3
+bool ISF::GenParticleSimWhiteList::pass(const HepMC::GenParticlePtr& particle) const
+#else
 bool ISF::GenParticleSimWhiteList::pass(const HepMC::GenParticle& particle) const
+#endif
 {
 
   ATH_MSG_VERBOSE( "Checking whether " << particle << " passes the filter." );
@@ -82,6 +86,8 @@ bool ISF::GenParticleSimWhiteList::pass(const HepMC::GenParticle& particle) cons
   bool so_far_so_good = pass( particle , vertices );
 
   // Test all parent particles
+#ifdef HEPMC3
+#else
   if (so_far_so_good && particle.production_vertex() && m_qs){
     for (HepMC::GenVertex::particle_iterator it = particle.production_vertex()->particles_begin(HepMC::parents);
                                              it != particle.production_vertex()->particles_end(HepMC::parents); ++it){
@@ -95,11 +101,18 @@ bool ISF::GenParticleSimWhiteList::pass(const HepMC::GenParticle& particle) cons
       so_far_so_good = so_far_so_good && !parent_all_clear;
     } // Loop over parents
   } // particle had parents
+#endif
 
   return so_far_so_good;
 }
 
 /** returns true if the the particle and all daughters are on the white list */
+#ifdef HEPMC3
+bool ISF::GenParticleSimWhiteList::pass(const HepMC::GenParticlePtr& particle , std::vector<int> & used_vertices ) const
+{
+return true;
+}
+#else
 bool ISF::GenParticleSimWhiteList::pass(const HepMC::GenParticle& particle , std::vector<int> & used_vertices ) const
 {
   // See if the particle is in the white list
@@ -132,6 +145,7 @@ bool ISF::GenParticleSimWhiteList::pass(const HepMC::GenParticle& particle , std
 
   return passFilter;
 }
+#endif
 
 StatusCode  ISF::GenParticleSimWhiteList::finalize()
 {
diff --git a/Simulation/ISF/ISF_HepMC/ISF_HepMC_Tools/src/GenParticleSimWhiteList.h b/Simulation/ISF/ISF_HepMC/ISF_HepMC_Tools/src/GenParticleSimWhiteList.h
index bcd25eebef1d..d8c3add48c69 100644
--- a/Simulation/ISF/ISF_HepMC/ISF_HepMC_Tools/src/GenParticleSimWhiteList.h
+++ b/Simulation/ISF/ISF_HepMC/ISF_HepMC_Tools/src/GenParticleSimWhiteList.h
@@ -19,6 +19,7 @@
 #include <string>
 #include <vector>
 
+#include "AtlasHepMC/GenParticle.h"
 namespace ISF {
 
     class ISFParticle;
@@ -44,11 +45,19 @@ namespace ISF {
       StatusCode  finalize();
 
       /** passes through to the private version */
+#ifdef HEPMC3
+      bool pass(const HepMC::GenParticlePtr& particle ) const;
+#else
       bool pass(const HepMC::GenParticle& particle ) const;
+#endif
 
      private:
       /** returns true if the the particle and all daughters are on the white list */
+#ifdef HEPMC3
+      bool pass(const HepMC::GenParticlePtr& particle , std::vector<int> & used_vertices ) const;
+#else
       bool pass(const HepMC::GenParticle& particle , std::vector<int> & used_vertices ) const;
+#endif
       std::vector<std::string>          m_whiteLists;            //!< The location of the white lists
       std::vector<long int>             m_pdgId;                //!< Allowed PDG IDs
       bool                              m_qs;                   //!< Switch for quasi-stable particle simulation
diff --git a/Simulation/ISF/ISF_HepMC/ISF_HepMC_Tools/test/GenParticleGenericFilter_test.cxx b/Simulation/ISF/ISF_HepMC/ISF_HepMC_Tools/test/GenParticleGenericFilter_test.cxx
index 052a95f5baec..2988dfbf8067 100644
--- a/Simulation/ISF/ISF_HepMC/ISF_HepMC_Tools/test/GenParticleGenericFilter_test.cxx
+++ b/Simulation/ISF/ISF_HepMC/ISF_HepMC_Tools/test/GenParticleGenericFilter_test.cxx
@@ -342,7 +342,7 @@ TEST_F(GenParticleGenericFilter_test, productionVertexInsideApplicableRadius_exp
 
   const HepMC::FourVector pos(0., 0., 0., 0.);
   HepMC::GenVertex vtx(pos);
-  auto* part = new HepMC::GenParticle(); // need dynamic allocation as GenVertex takes ownership
+  auto part = HepMC::newGenParticlePtr(); // need dynamic allocation as GenVertex takes ownership
   vtx.add_particle_out(part);
 
   ASSERT_TRUE( m_filterTool->pass(*part) );
@@ -355,7 +355,7 @@ TEST_F(GenParticleGenericFilter_test, productionVertexOutsideApplicableRadiusAnd
   EXPECT_TRUE( m_filterTool->initialize().isSuccess() );
 
   const HepMC::FourVector mom4(1.0*sin(150.*M_PI/180.), 0.0, 1.0*cos(150.*M_PI/180.), 1.0); // rho=1, eta=-1.32
-  auto* part = new HepMC::GenParticle(mom4, /*pdg id=*/11); // need dynamic allocation as GenVertex takes ownership
+  auto part = HepMC::newGenParticlePtr(mom4, /*pdg id=*/11); // need dynamic allocation as GenVertex takes ownership
 
   const HepMC::FourVector pos(0., 100., 0., 0.);
   HepMC::GenVertex vtx(pos);
@@ -371,7 +371,7 @@ TEST_F(GenParticleGenericFilter_test, productionVertexWithinApplicableRadiusAndU
   EXPECT_TRUE( m_filterTool->initialize().isSuccess() );
 
   const HepMC::FourVector mom4(1.0*sin(150.*M_PI/180.), 0.0, 1.0*cos(150.*M_PI/180.), 1.0); // rho=1, eta=-1.32
-  auto* part = new HepMC::GenParticle(mom4, /*pdg id=*/11); // need dynamic allocation as GenVertex takes ownership
+  auto part = HepMC::newGenParticlePtr(mom4, /*pdg id=*/11); // need dynamic allocation as GenVertex takes ownership
 
   const HepMC::FourVector pos(0., 9.9, 0., 0.);
   HepMC::GenVertex vtx(pos);
@@ -388,7 +388,7 @@ TEST_F(GenParticleGenericFilter_test, productionVertexFarForwardInsideApplicable
   EXPECT_TRUE( m_filterTool->initialize().isSuccess() );
 
   const HepMC::FourVector mom4(0., 0., 1.0, 1.0); // rho=1, eta=inf
-  auto* part = new HepMC::GenParticle(mom4, /*pdg id=*/11); // need dynamic allocation as GenVertex takes ownership
+  auto part = HepMC::newGenParticlePtr(mom4, /*pdg id=*/11); // need dynamic allocation as GenVertex takes ownership
 
   const HepMC::FourVector pos(0., 0., 9999., 0.);
   HepMC::GenVertex vtx(pos);
@@ -406,7 +406,7 @@ TEST_F(GenParticleGenericFilter_test, productionVertexFarForwardOutsideApplicabl
   EXPECT_TRUE( m_filterTool->initialize().isSuccess() );
 
   const HepMC::FourVector mom4(0., 0., 1.0, 1.0); // rho=1, eta=inf
-  auto* part = new HepMC::GenParticle(mom4, /*pdg id=*/11); // need dynamic allocation as GenVertex takes ownership
+  auto part = HepMC::newGenParticlePtr(mom4, /*pdg id=*/11); // need dynamic allocation as GenVertex takes ownership
 
   const HepMC::FourVector pos(1.1, 0., 9999., 0.);
   HepMC::GenVertex vtx(pos);
diff --git a/Simulation/ISF/ISF_SimulationSelectors/src/ConeSimSelector.cxx b/Simulation/ISF/ISF_SimulationSelectors/src/ConeSimSelector.cxx
index d298c9de756c..c1b9d6961b14 100644
--- a/Simulation/ISF/ISF_SimulationSelectors/src/ConeSimSelector.cxx
+++ b/Simulation/ISF/ISF_SimulationSelectors/src/ConeSimSelector.cxx
@@ -25,7 +25,10 @@ ISF::ConeSimSelector::ConeSimSelector(const std::string& t, const std::string& n
   , m_relativesVec()
   , m_relatives()
   , m_relationProp()
+#ifdef HEPMC3
+#else
   , m_relation(HepMC::parents)
+#endif
   , m_extrapolateToCalo(false)
   , m_extrapolator()
 {
@@ -142,7 +145,7 @@ void ISF::ConeSimSelector::update(const ISFParticle& particle)
             }
 
           // test whether any of the pdg codes is found in the genParticle history
-          HepMC::ConstGenParticlePtr relative = HepMCHelper::findRealtiveWithPDG( *genParticle, m_relation, m_relatives);
+          auto  relative = HepMCHelper::findRealtiveWithPDG( genParticle, m_relation, m_relatives);
 
           if (relative)
             {
diff --git a/Simulation/ISF/ISF_SimulationSelectors/src/TruthAssocSimSelector.cxx b/Simulation/ISF/ISF_SimulationSelectors/src/TruthAssocSimSelector.cxx
index 4bf6af110ea8..e89458b3329a 100644
--- a/Simulation/ISF/ISF_SimulationSelectors/src/TruthAssocSimSelector.cxx
+++ b/Simulation/ISF/ISF_SimulationSelectors/src/TruthAssocSimSelector.cxx
@@ -19,7 +19,10 @@ ISF::TruthAssocSimSelector::TruthAssocSimSelector(const std::string& t, const st
   , m_relativesVec()
   , m_relatives()
   , m_relationProp(0)
+#ifdef HEPMC3
+#else  
   , m_relation(HepMC::parents)
+#endif
 {
   declareProperty( "RelativesPDGCode",
                    m_relativesVec,
@@ -69,11 +72,11 @@ bool  ISF::TruthAssocSimSelector::passSelectorCuts(const ISFParticle& particle)
   if (truth)
     {
       // get GenParticle from truth binding
-      HepMC::ConstGenParticlePtr genParticle = truth->getTruthParticle();
+      auto genParticle = truth->getTruthParticle();
       if (genParticle)
         {
           // test whether any of the pdg codes is found in the genParticle history
-          HepMC::ConstGenParticlePtr relative = HepMCHelper::findRealtiveWithPDG( *genParticle, m_relation, m_relatives);
+          auto  relative = HepMCHelper::findRealtiveWithPDG( genParticle, m_relation, m_relatives);
           // in case a relative was found
           if (relative)
             {
@@ -84,7 +87,7 @@ bool  ISF::TruthAssocSimSelector::passSelectorCuts(const ISFParticle& particle)
                               << " barcode=" << particle.barcode() << ")"
                               << " passes due relative particle"
                               << " (pdg=" << relative->pdg_id() << ","
-                              << " barcode=" << HepMC::barcode(*relative) << ")" );
+                              << " barcode=" << HepMC::barcode(relative) << ")" );
               // selector cuts passed
               return true;
             } // found relative
diff --git a/Simulation/Tools/McEventCollectionFilter/src/McEventCollectionFilter.cxx b/Simulation/Tools/McEventCollectionFilter/src/McEventCollectionFilter.cxx
index ca0d931e1a82..77c70f81124e 100644
--- a/Simulation/Tools/McEventCollectionFilter/src/McEventCollectionFilter.cxx
+++ b/Simulation/Tools/McEventCollectionFilter/src/McEventCollectionFilter.cxx
@@ -9,6 +9,9 @@
 //
 #include "AtlasHepMC/GenEvent.h"
 #include "AtlasHepMC/GenVertex.h"
+#include "AtlasHepMC/GenParticle.h"
+#include "AtlasHepMC/Flow.h"
+#include "AtlasHepMC/Polarization.h"
 //
 #include "InDetSimEvent/SiHit.h"
 #include "MuonSimEvent/TGCSimHit.h"
@@ -198,7 +201,7 @@ StatusCode McEventCollectionFilter::ReduceMCEventCollection(){
 
 
   //to set geantino vertex as a truth primary vertex
-  HepMC::GenVertexPtr hScatVx = genEvt->barcode_to_vertex(-3);
+  HepMC::GenVertexPtr hScatVx = HepMC::barcode_to_vertex(genEvt,-3);
   if(hScatVx!=nullptr) {
     const HepMC::FourVector& pmvxpos=hScatVx->position();
     genVertex->set_position(pmvxpos);
@@ -217,6 +220,8 @@ StatusCode McEventCollectionFilter::ReduceMCEventCollection(){
     }
   }
 
+#ifdef HEPMC3 
+#else
   if(!evt->vertices_empty()){
     HepMC::GenEvent::vertex_iterator itvtx = evt->vertices_begin();
     for (;itvtx != evt ->vertices_end(); ++itvtx ) {
@@ -225,19 +230,21 @@ StatusCode McEventCollectionFilter::ReduceMCEventCollection(){
       delete vtx;
     }
   }
+#endif
 
   //--------------------------------------
   if(m_IsKeepTRTElect){
     for(int i=0;i<(int) m_elecBarcode.size();i++){
-      HepMC::GenParticlePtr thePart=genEvt->barcode_to_particle(m_elecBarcode[i]);
+      HepMC::GenParticlePtr thePart=HepMC::barcode_to_particle(genEvt,m_elecBarcode[i]);
       if (!thePart){
         ATH_MSG_DEBUG( "Could not find particle for barcode " << m_elecBarcode[i] );
         continue;
       }
       HepMC::ConstGenVertexPtr vx = thePart->production_vertex();
       HepMC::GenParticlePtr thePart_new = HepMC::newGenParticlePtr( thePart->momentum(),thePart->pdg_id(),
-                                                                    thePart->status());
-      HepMC::suggest_barcode(thePart_new, m_elecBarcode[i]);
+                                                              thePart->status(),HepMC::flow(thePart),
+                                                              HepMC::polarization(thePart) );
+      HepMC::suggest_barcode(thePart_new,m_elecBarcode[i]);
 
       const HepMC::FourVector& pos= vx->position();
       HepMC::GenVertexPtr vx_new = HepMC::newGenVertexPtr(pos);
@@ -248,7 +255,7 @@ StatusCode McEventCollectionFilter::ReduceMCEventCollection(){
 
   //.....add new vertex with geantino
   evt->add_vertex(genVertex);
-  m_RefBarcode=HepMC::barcode(*genPart);
+  m_RefBarcode=HepMC::barcode(genPart);
 
   m_outputTruthCollection->push_back(evt);
 
-- 
GitLab


From 6d1f497b22fe30815235048a6eed6aeea24eaf88 Mon Sep 17 00:00:00 2001
From: Andrii Verbytskyi <averbyts@cern.ch>
Date: Sun, 6 Sep 2020 22:30:32 +0200
Subject: [PATCH 2/3] Revert the last one

---
 Control/AthContainers/CMakeLists.txt          |   4 -
 Event/xAOD/xAODTruthCnv/CMakeLists.txt        |   3 +-
 .../GeneratorObjects/McEventDict.h            |  10 +-
 .../GeneratorObjects/selection.xml            |   2 -
 .../McEventCollectionCnv_p4.h                 |  10 -
 .../McEventCollectionCnv_p5.h                 |  10 -
 .../src/GenEventCnv_p1.cxx                    |  13 +-
 .../GeneratorObjectsTPCnv/src/HepMcDataPool.h |  55 ----
 .../src/McEventCollectionCnv_p2.cxx           |  96 +-----
 .../src/McEventCollectionCnv_p3.cxx           |  19 --
 .../src/McEventCollectionCnv_p4.cxx           | 285 +-----------------
 .../src/McEventCollectionCnv_p5.cxx           | 270 -----------------
 .../AnalysisTest/CMakeLists.txt               |   1 -
 .../McParticleTools/src/McVtxFilterTool.cxx   |   6 +-
 .../src/OldSpclMcFilterTool.cxx               |   2 +-
 .../McParticleTools/src/PileupFilterTool.cxx  |   2 +-
 .../test/McVtxFilterTest_CppUnit.cxx          |  74 ++---
 Projects/AnalysisBase/CMakeLists.txt          |   6 -
 Projects/AthGeneration/CMakeLists.txt         |   5 -
 Projects/AthSimulation/CMakeLists.txt         |  11 -
 .../src/FastShowerCellBuilderTool.cxx         |   2 +-
 .../src/MultiParticleGunPileup.cxx            |   4 +-
 .../MCTruth/PrimaryParticleInformation.h      |  25 --
 .../G4Sim/MCTruth/MCTruth/TrackInformation.h  |  23 --
 .../G4Sim/MCTruth/MCTruth/VTrackInformation.h |  61 +---
 .../src/PrimaryParticleInformation.cxx        |  58 ----
 .../G4Sim/MCTruth/src/TrackInformation.cxx    |  45 +--
 .../G4Sim/MCTruth/src/VTrackInformation.cxx   |  39 +--
 .../src/AthenaTrackingAction.cxx              |   7 -
 .../src/MergeMcEventCollTool.cxx              |  18 +-
 .../MCTruthSimAlgs/src/MergeMcEventCollTool.h |   4 +-
 .../ISF_Event/ISF_Event/HepMCHelper.h         |   7 -
 .../ISF_Event/ISF_Event/HepMCHelper.icc       |  17 --
 .../ISF_Event/ISF_Event/TruthBinding.icc      |   3 -
 .../ISF_Event/src/ISFTruthIncident.cxx        |  19 +-
 .../ISF_Services/src/InputConverter.cxx       |  94 +-----
 .../ISF_Services/src/InputConverter.h         |  12 -
 .../ISF_Core/ISF_Services/src/TruthSvc.cxx    |  35 +--
 .../ISF_Services/test/InputConverter_test.cxx |  10 +-
 .../ISF_Services/test/TruthSvc_test.cxx       |  72 ++---
 .../PRD_PlanarTruthTrajectoryBuilder.h        |   4 +-
 .../src/PRD_PlanarTruthTrajectoryBuilder.cxx  |  10 +-
 .../ISF_Geant4Event/src/ISFG4Helper.cxx       |   4 -
 .../ISF_Geant4Tools/src/ISFTrajectory.cxx     |   6 +-
 .../src/PhysicsValidationUserAction.cxx       |  13 -
 .../src/TrackProcessorUserActionBase.cxx      |  12 +-
 .../src/TrackProcessorUserActionPassBack.cxx  |   7 +-
 .../ISF_HepMC_Interfaces/IGenParticleFilter.h |   5 -
 .../src/GenParticleFinalStateFilter.cxx       |  12 -
 .../src/GenParticleFinalStateFilter.h         |   9 -
 .../src/GenParticleGenericFilter.cxx          |  20 +-
 .../src/GenParticleGenericFilter.h            |   8 -
 .../src/GenParticleInteractingFilter.cxx      |   9 -
 .../src/GenParticleInteractingFilter.h        |   6 -
 .../src/GenParticleLifetimeFilter.cxx         |  16 +-
 .../src/GenParticleLifetimeFilter.h           |   4 -
 .../src/GenParticlePositionFilter.cxx         |   7 -
 .../src/GenParticlePositionFilter.h           |   4 -
 .../src/GenParticleSimWhiteList.cxx           |  14 -
 .../src/GenParticleSimWhiteList.h             |   9 -
 .../test/GenParticleGenericFilter_test.cxx    |  10 +-
 .../src/ConeSimSelector.cxx                   |   5 +-
 .../src/TruthAssocSimSelector.cxx             |   9 +-
 .../src/McEventCollectionFilter.cxx           |  17 +-
 64 files changed, 177 insertions(+), 1482 deletions(-)

diff --git a/Control/AthContainers/CMakeLists.txt b/Control/AthContainers/CMakeLists.txt
index 2d7c2bee6c65..1ee81e1b1790 100644
--- a/Control/AthContainers/CMakeLists.txt
+++ b/Control/AthContainers/CMakeLists.txt
@@ -11,10 +11,6 @@ if( NOT XAOD_STANDALONE )
    set( extra_sources src/*.cxx )
 endif()
 
-atlas_depends_on_subdirs(
-   PUBLIC
-      Generators/AtlasHepMC )
-
 # External dependencies:
 find_package( Boost COMPONENTS thread )
 find_package( ROOT COMPONENTS Core )
diff --git a/Event/xAOD/xAODTruthCnv/CMakeLists.txt b/Event/xAOD/xAODTruthCnv/CMakeLists.txt
index 392f416834bc..e226116ad1ce 100644
--- a/Event/xAOD/xAODTruthCnv/CMakeLists.txt
+++ b/Event/xAOD/xAODTruthCnv/CMakeLists.txt
@@ -26,14 +26,13 @@ atlas_depends_on_subdirs(
    Control/CxxUtils
    Control/AthToolSupport/AsgTools
    Event/xAOD/xAODTruth
-   Generators/AtlasHepMC
    ${extra_dep} )
 
 # Component(s) in the package:
 atlas_add_library( xAODTruthCnvLib
    xAODTruthCnv/*.h Root/*.cxx
    PUBLIC_HEADERS xAODTruthCnv
-   LINK_LIBRARIES AsgTools xAODTruth  AtlasHepMCLib)
+   LINK_LIBRARIES AsgTools xAODTruth )
 
 if( NOT XAOD_STANDALONE )
    atlas_add_component( xAODTruthCnv
diff --git a/Generators/GeneratorObjects/GeneratorObjects/McEventDict.h b/Generators/GeneratorObjects/GeneratorObjects/McEventDict.h
index 2dc20551fff4..58b8b0605e44 100644
--- a/Generators/GeneratorObjects/GeneratorObjects/McEventDict.h
+++ b/Generators/GeneratorObjects/GeneratorObjects/McEventDict.h
@@ -13,7 +13,6 @@
 #include "GeneratorObjects/HijingEventParams.h"
 #include "RootUtils/PyROOTIteratorFuncs.h"
 
-#include "AtlasHepMC/GenEvent.h"
 namespace GeneratorObjectsMcEventDict {
   
   struct tmp {
@@ -25,12 +24,9 @@ namespace GeneratorObjectsMcEventDict {
 
     std::iterator<std::forward_iterator_tag,HepMC::GenVertex*,int,HepMC::GenVertex**,HepMC::GenVertex*&> m_1;
     std::iterator<std::forward_iterator_tag,HepMC::GenParticle*,int,HepMC::GenParticle**,HepMC::GenParticle*&> m_2;
-
-#ifdef HEPMC3 
-    RootUtils::PyROOTIteratorFuncs<std::vector<HepMC::GenVertex>::const_iterator> m_it;
-#else    
-    RootUtils::PyROOTIteratorFuncs<HepMC::GenVertex::particles_out_const_iterator> m_it;
-#endif
+    
+    RootUtils::PyROOTIteratorFuncs<
+      HepMC::GenVertex::particles_out_const_iterator> m_it;
   };
 
 }
diff --git a/Generators/GeneratorObjects/GeneratorObjects/selection.xml b/Generators/GeneratorObjects/GeneratorObjects/selection.xml
index d8f1e990babb..ad9db4103ad4 100755
--- a/Generators/GeneratorObjects/GeneratorObjects/selection.xml
+++ b/Generators/GeneratorObjects/GeneratorObjects/selection.xml
@@ -16,11 +16,9 @@
   <class name="std::map<int,HepMC::GenVertex*,std::greater<int> >" />
   <class name="HepMC::WeightContainer" />
   <class name="std::set<HepMC::GenParticle*>" />
-<!--  
   <class name="HepMC::Flow" >
     <field name="m_particle_owner" transient="true" />
   </class>
--->
   <class name="HepMC::Polarization" />
   <class name="HepMcParticleLink" >
    <field name="m_ptrs" transient="true" />
diff --git a/Generators/GeneratorObjectsTPCnv/GeneratorObjectsTPCnv/McEventCollectionCnv_p4.h b/Generators/GeneratorObjectsTPCnv/GeneratorObjectsTPCnv/McEventCollectionCnv_p4.h
index 520c5021c22d..19ba716047d0 100755
--- a/Generators/GeneratorObjectsTPCnv/GeneratorObjectsTPCnv/McEventCollectionCnv_p4.h
+++ b/Generators/GeneratorObjectsTPCnv/GeneratorObjectsTPCnv/McEventCollectionCnv_p4.h
@@ -129,27 +129,17 @@ class McEventCollectionCnv_p4 : public T_AthenaPoolTPCnvBase<
    *  vertex is added to the persistent is added to the persistent
    *  @c GenEvent.
    */
-#ifdef HEPMC3
-  void writeGenVertex( const HepMC::GenVertexPtr vtx,
-                       McEventCollection_p4& persEvt ) const;
-#else
   void writeGenVertex( const HepMC::GenVertex& vtx,
                        McEventCollection_p4& persEvt ) const;
-#endif
 
   /** @brief Method to write a persistent @c GenParticle object
    *  It returns the index of the persistent @c GenParticle into the
    *  collection of persistent of @c GenParticles from the
    *  persistent @c GenEvent
    */
-#ifdef HEPMC3   
-  int writeGenParticle( const HepMC::GenParticlePtr p,
-                        McEventCollection_p4& persEvt ) const;
-#else
   int writeGenParticle( const HepMC::GenParticle& p,
                         McEventCollection_p4& persEvt ) const;
 
-#endif
   ///////////////////////////////////////////////////////////////////
   // Protected data:
   ///////////////////////////////////////////////////////////////////
diff --git a/Generators/GeneratorObjectsTPCnv/GeneratorObjectsTPCnv/McEventCollectionCnv_p5.h b/Generators/GeneratorObjectsTPCnv/GeneratorObjectsTPCnv/McEventCollectionCnv_p5.h
index f44925134f1a..c5649ca6fd44 100755
--- a/Generators/GeneratorObjectsTPCnv/GeneratorObjectsTPCnv/McEventCollectionCnv_p5.h
+++ b/Generators/GeneratorObjectsTPCnv/GeneratorObjectsTPCnv/McEventCollectionCnv_p5.h
@@ -130,26 +130,16 @@ class McEventCollectionCnv_p5 : public T_AthenaPoolTPCnvBase<
    *  vertex is added to the persistent is added to the persistent
    *  @c GenEvent.
    */
-#ifdef HEPMC3
-  void writeGenVertex( const HepMC::GenVertexPtr vtx,
-                       McEventCollection_p5& persEvt ) const;
-#else
   void writeGenVertex( const HepMC::GenVertex& vtx,
                        McEventCollection_p5& persEvt ) const;
 
-#endif
   /** @brief Method to write a persistent @c GenParticle object
    *  It returns the index of the persistent @c GenParticle into the
    *  collection of persistent of @c GenParticles from the
    *  persistent @c GenEvent
    */
-#ifdef HEPMC3
-  int writeGenParticle( const HepMC::GenParticlePtr p,
-                        McEventCollection_p5& persEvt ) const;
-#else
   int writeGenParticle( const HepMC::GenParticle& p,
                         McEventCollection_p5& persEvt ) const;
-#endif
 
   ///////////////////////////////////////////////////////////////////
   // Protected data:
diff --git a/Generators/GeneratorObjectsTPCnv/src/GenEventCnv_p1.cxx b/Generators/GeneratorObjectsTPCnv/src/GenEventCnv_p1.cxx
index 03153a81c00a..fd88e5a0df01 100755
--- a/Generators/GeneratorObjectsTPCnv/src/GenEventCnv_p1.cxx
+++ b/Generators/GeneratorObjectsTPCnv/src/GenEventCnv_p1.cxx
@@ -62,8 +62,6 @@ void GenEventCnv_p1::persToTrans( const GenEvent_p1* persObj,
     m_pool->part.reserve( m_pool->part.allocated() + nParts );
   }
 
-#ifdef HEPMC3
-#else  
   transObj->set_signal_process_id( persObj->m_signalProcessId );
   transObj->set_event_number( persObj->m_eventNbr );
   transObj->set_event_scale ( persObj->m_eventScale );
@@ -80,7 +78,6 @@ void GenEventCnv_p1::persToTrans( const GenEvent_p1* persObj,
 
   transObj->m_pdf_info = 0;         //> not available at that time...
 
-#endif
   // 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
@@ -145,9 +142,6 @@ GenEventCnv_p1::createGenVertex( const GenEvent_p1& persEvt,
 				 const GenVertex_p1& persVtx,
 				 ParticlesMap_t& partToEndVtx ) const
 {
-#ifdef HEPMC3
-HepMC::GenVertexPtr vtx;
-#else
   HepMC::GenVertexPtr vtx = m_pool->vtx.nextElementPtr();
   vtx->m_position.setX( persVtx.m_x );
   vtx->m_position.setY( persVtx.m_y );
@@ -173,7 +167,6 @@ HepMC::GenVertexPtr vtx;
      vtx->add_particle_out( createGenParticle( persEvt.m_particles[persVtx.m_particlesOut[i]],
 					       partToEndVtx ) );
   }
-#endif
 
   return vtx;
 }
@@ -182,9 +175,8 @@ HepMC::GenParticlePtr
 GenEventCnv_p1::createGenParticle( const GenParticle_p1& persPart,
 				   ParticlesMap_t& partToEndVtx ) const
 {
-#ifdef HEPMC3
-HepMC::GenParticlePtr p;
-#else
+
+
   HepMC::GenParticlePtr p = m_pool->part.nextElementPtr();
   p->m_momentum.setPx( persPart.m_px  );
   p->m_momentum.setPy( persPart.m_py  );
@@ -209,7 +201,6 @@ HepMC::GenParticlePtr p;
     partToEndVtx[p] = persPart.m_endVtx;
   }
 
-#endif
   return p;
 }
 
diff --git a/Generators/GeneratorObjectsTPCnv/src/HepMcDataPool.h b/Generators/GeneratorObjectsTPCnv/src/HepMcDataPool.h
index 1faeee2f5d7d..be051d1fbb40 100755
--- a/Generators/GeneratorObjectsTPCnv/src/HepMcDataPool.h
+++ b/Generators/GeneratorObjectsTPCnv/src/HepMcDataPool.h
@@ -35,43 +35,6 @@
 // various DataPool<Xyz>.
 namespace SG {
 
-#ifdef HEPMC3
-
-
-  template<>
-  inline void
-  ArenaAllocatorBase::destroy_fcn<HepMC::GenParticlePtr>(ArenaAllocatorBase::pointer p)
-  {
-   // HepMC::GenParticle* part = reinterpret_cast<HepMC::GenParticle*>(p);
-   // part->m_production_vertex = 0;
-   // part->m_end_vertex = 0;
-   // part->~GenParticle();
-  }
-
-  template<>
-  inline void
-  ArenaAllocatorBase::destroy_fcn<HepMC::GenVertexPtr>(ArenaAllocatorBase::pointer p)
-  {
-   // HepMC::GenVertex* vtx = reinterpret_cast<HepMC::GenVertex*>(p);
-   // vtx->m_event = 0;
-   // vtx->m_particles_in.clear();
-   // vtx->m_particles_out.clear();
-   // vtx->~GenVertex();
-  }
-
-  template<>
-  inline void
-  ArenaAllocatorBase::destroy_fcn<HepMC::GenEvent>(ArenaAllocatorBase::pointer p)
-  {
-    HepMC::GenEvent* evt = reinterpret_cast<HepMC::GenEvent*>(p);
-   // evt->m_particle_barcodes.clear();
-   // evt->m_vertex_barcodes.clear();
-   // delete evt->m_pdf_info; evt->m_pdf_info = 0;
-    evt->~GenEvent();
-  }
-
-#else
-
   template<>
   inline void
   ArenaAllocatorBase::destroy_fcn<HepMC::GenParticle>(ArenaAllocatorBase::pointer p)
@@ -103,26 +66,9 @@ namespace SG {
     delete evt->m_pdf_info; evt->m_pdf_info = 0;
     evt->~GenEvent();
   }
-#endif  
 } // end namespace SG
 
 namespace HepMC {
- #ifdef HEPMC3
-  struct DataPool {
-
-    typedef ::DataPool<HepMC::GenEvent> GenEvtPool_t;
-    /// an arena of @c HepMC::GenEvent for efficient object instantiation
-    GenEvtPool_t evt;
-
-    typedef ::DataPool<HepMC::GenVertexPtr> GenVtxPool_t;
-    /// an arena of @c HepMC::GenVertex for efficient object instantiation
-    GenVtxPool_t vtx;
-
-    typedef ::DataPool<HepMC::GenParticlePtr> GenPartPool_t;
-    /// an arena of @c HepMC::GenParticle for efficient object instantiation
-    GenPartPool_t part;
-  };
-#else
   struct DataPool {
 
     typedef ::DataPool<HepMC::GenEvent> GenEvtPool_t;
@@ -138,7 +84,6 @@ namespace HepMC {
     GenPartPool_t part;
   };
 
-#endif
 } // end namespace HepMC
 
 #endif // GENERATOROBJECTSATHENAPOOL_HEPMCDATAPOOL_H
diff --git a/Generators/GeneratorObjectsTPCnv/src/McEventCollectionCnv_p2.cxx b/Generators/GeneratorObjectsTPCnv/src/McEventCollectionCnv_p2.cxx
index 7c564ece43b7..aa4cb45c00db 100755
--- a/Generators/GeneratorObjectsTPCnv/src/McEventCollectionCnv_p2.cxx
+++ b/Generators/GeneratorObjectsTPCnv/src/McEventCollectionCnv_p2.cxx
@@ -79,50 +79,6 @@ void McEventCollectionCnv_p2::persToTrans( const McEventCollection_p2* persObj,
         ++itr ) {
     const GenEvent_p2& persEvt = *itr;
     HepMC::GenEvent * genEvt        = poolOfEvents.nextElementPtr();
-#ifdef HEPMC3
-    genEvt->add_attribute("signal_process_id",std::make_shared<HepMC3::IntAttribute>(persEvt.m_signalProcessId));
-    genEvt->set_event_number(persEvt.m_eventNbr);
-    genEvt->add_attribute("event_scale",std::make_shared<HepMC3::DoubleAttribute>(persEvt.m_eventScale));
-    genEvt->add_attribute("alphaQCD",std::make_shared<HepMC3::DoubleAttribute>(persEvt.m_alphaQCD));
-    genEvt->add_attribute("alphaQED",std::make_shared<HepMC3::DoubleAttribute>(persEvt.m_alphaQED));
-    //AV genEvt->m_signal_process_vertex = 0;
-    //AV genEvt->m_weights               = persEvt.m_weights;
-    //AV genEvt->m_random_states         = persEvt.m_randomStates;
-    //AV genEvt->m_vertex_barcodes.clear();
-    //AV genEvt->m_particle_barcodes.clear();
-    //AV genEvt->m_pdf_info = 0;         //> not available at that time...
-
-    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
-    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 ) );
-    } //> end loop over vertices
-
-    // set the signal process vertex
-    const int sigProcVtx = persEvt.m_signalProcessVtx;
-    if ( sigProcVtx ) HepMC::set_signal_process_vertex(genEvt, HepMC::barcode_to_vertex(genEvt, sigProcVtx ) );
-
-    // connect particles to their end vertices
-    for ( auto p:  partToEndVtx) {
-      auto decayVtx = HepMC::barcode_to_vertex(genEvt, p.second );
-      if ( decayVtx ) {
-        decayVtx->add_particle_in( p.first );
-      } else {
-        msg << MSG::ERROR<< "GenParticle points to null end vertex !!"<< endmsg;
-      }
-    }
-#else
     genEvt->m_signal_process_id     = persEvt.m_signalProcessId;
     genEvt->m_event_number          = persEvt.m_eventNbr;
     genEvt->m_event_scale           = persEvt.m_eventScale;
@@ -173,7 +129,6 @@ void McEventCollectionCnv_p2::persToTrans( const McEventCollection_p2* persObj,
             << endmsg;
       }
     }
-#endif    
   } //> end loop over m_genEvents
 
   msg << MSG::DEBUG << "Loaded McEventCollection from persistent state [OK]"
@@ -205,37 +160,8 @@ McEventCollectionCnv_p2::createGenVertex( const McEventCollection_p2& persEvt,
                                           const GenVertex_p2& persVtx,
                                           ParticlesMap_t& partToEndVtx, HepMC::DataPool* datapools ) const
 {
-#ifdef HEPMC3
-  DataPool<HepMC::GenVertexPtr>& poolOfVertices = datapools->vtx;
-  //auto vtx = poolOfVertices.nextElementPtr();
-  HepMC::GenVertexPtr vtx;
-  vtx->set_position( HepMC::FourVector(persVtx.m_x,persVtx.m_y, persVtx.m_z, persVtx.m_t) );
-  //AV vtx->m_particles_in.clear();
-  //AV vtx->m_particles_out.clear();
-  //AV vtx->m_id      = persVtx.m_id;
-  //AV vtx->m_weights.m_weights.reserve( persVtx.m_weights.size() );
-  //AV vtx->m_weights.m_weights.assign ( persVtx.m_weights.begin(),persVtx.m_weights.end() );
-  //AV vtx->m_event   = 0;
-  //AV vtx->m_barcode = 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 );
-  }
-
-  // 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 ) );
-  }
-#else
   DataPool<HepMC::GenVertex>& poolOfVertices = datapools->vtx;
-  HepMC::GenVertex* vtx = poolOfVertices.nextElementPtr();
+  HepMC::GenVertexPtr vtx = poolOfVertices.nextElementPtr();
   vtx->m_position.setX( persVtx.m_x );
   vtx->m_position.setY( persVtx.m_y );
   vtx->m_position.setZ( persVtx.m_z );
@@ -264,7 +190,6 @@ McEventCollectionCnv_p2::createGenVertex( const McEventCollection_p2& persEvt,
                                               partToEndVtx,
                                               datapools ) );
   }
-#endif
 
   return vtx;
 }
@@ -273,24 +198,6 @@ HepMC::GenParticlePtr
 McEventCollectionCnv_p2::createGenParticle( const GenParticle_p2& persPart,
                                             ParticlesMap_t& partToEndVtx, HepMC::DataPool* datapools ) const
 {
-#ifdef HEPMC3
-  DataPool<HepMC::GenParticlePtr>& poolOfParticles = datapools->part;
-  HepMC::GenParticlePtr p;
-  p->set_momentum( HepMC::FourVector(persPart.m_px,persPart.m_py,persPart.m_pz, persPart.m_ene ));
-  p->set_pdg_id(               persPart.m_pdgId);
-  p->set_status(               persPart.m_status);
-  //p->m_polarization.m_theta= static_cast<double>(persPart.m_thetaPolarization);
-  //p->m_polarization.m_phi  = static_cast<double>(persPart.m_phiPolarization  );
-  //p->m_production_vertex   = 0;
-  //p->m_end_vertex          = 0;
-  //p->m_barcode             = persPart.m_barcode;
-
-  // fillin' the flow
-  const unsigned int nFlow = persPart.m_flow.size();
-  for ( unsigned int iFlow= 0; iFlow != nFlow; ++iFlow ) {
-    //p->m_flow.set_icode( persPart.m_flow[iFlow].first,persPart.m_flow[iFlow].second );
-  }
-#else
   DataPool<HepMC::GenParticle>& poolOfParticles = datapools->part;
   HepMC::GenParticlePtr p    = poolOfParticles.nextElementPtr();
   p->m_momentum.setPx( persPart.m_px  );
@@ -311,7 +218,6 @@ McEventCollectionCnv_p2::createGenParticle( const GenParticle_p2& persPart,
     p->m_flow.set_icode( persPart.m_flow[iFlow].first,
                          persPart.m_flow[iFlow].second );
   }
-#endif
 
   if ( persPart.m_endVtx != 0 ) {
     partToEndVtx[p] = persPart.m_endVtx;
diff --git a/Generators/GeneratorObjectsTPCnv/src/McEventCollectionCnv_p3.cxx b/Generators/GeneratorObjectsTPCnv/src/McEventCollectionCnv_p3.cxx
index ff07475dcbf5..6a6383de3e96 100755
--- a/Generators/GeneratorObjectsTPCnv/src/McEventCollectionCnv_p3.cxx
+++ b/Generators/GeneratorObjectsTPCnv/src/McEventCollectionCnv_p3.cxx
@@ -83,9 +83,6 @@ void McEventCollectionCnv_p3::persToTrans( const McEventCollection_p3* persObj,
     const GenEvent_p3& persEvt = *itr;
 
     HepMC::GenEvent * genEvt        = poolOfEvents.nextElementPtr();
-#ifdef HEPMC3
-
-#else
     genEvt->m_signal_process_id     = persEvt.m_signalProcessId;
     genEvt->m_event_number          = persEvt.m_eventNbr;
     genEvt->m_event_scale           = persEvt.m_eventScale;
@@ -99,7 +96,6 @@ void McEventCollectionCnv_p3::persToTrans( const McEventCollection_p3* persObj,
     genEvt->m_pdf_info = 0;         //> not available at that time...
 
     transObj->push_back( genEvt );
-#endif
 
     // create a temporary map associating the barcode of an end-vtx to its
     // particle.
@@ -167,11 +163,6 @@ McEventCollectionCnv_p3::createGenVertex( const McEventCollection_p3& persEvt,
                                           ParticlesMap_t& partToEndVtx,
                                           HepMC::DataPool* datapools ) const
 {
-
-#ifdef HEPMC3
-  DataPool<HepMC::GenVertexPtr>& poolOfVertices = datapools->vtx;
-  HepMC::GenVertexPtr vtx=*(poolOfVertices.nextElementPtr());
-#else
   DataPool<HepMC::GenVertex>& poolOfVertices = datapools->vtx;
   HepMC::GenVertexPtr vtx = poolOfVertices.nextElementPtr();
   vtx->m_position.setX( persVtx.m_x );
@@ -186,7 +177,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();
@@ -212,14 +202,6 @@ McEventCollectionCnv_p3::createGenParticle( const GenParticle_p3& persPart,
                                             ParticlesMap_t& partToEndVtx,
                                             HepMC::DataPool* datapools ) const
 {
-
-#ifdef HEPMC3
-  DataPool<HepMC::GenParticlePtr>& poolOfParticles = datapools->part;
-  HepMC::GenParticlePtr p    = *(poolOfParticles.nextElementPtr());
-  p->set_pdg_id(              persPart.m_pdgId);
-  p->set_status(              persPart.m_status);
-
-#else
   DataPool<HepMC::GenParticle>& poolOfParticles = datapools->part;
   HepMC::GenParticlePtr p    = poolOfParticles.nextElementPtr();
   p->m_pdg_id              = persPart.m_pdgId;
@@ -268,7 +250,6 @@ McEventCollectionCnv_p3::createGenParticle( const GenParticle_p3& persPart,
   if ( persPart.m_endVtx != 0 ) {
     partToEndVtx[p] = persPart.m_endVtx;
   }
-#endif
 
   return p;
 }
diff --git a/Generators/GeneratorObjectsTPCnv/src/McEventCollectionCnv_p4.cxx b/Generators/GeneratorObjectsTPCnv/src/McEventCollectionCnv_p4.cxx
index e6b4bd4d7486..db580216dada 100755
--- a/Generators/GeneratorObjectsTPCnv/src/McEventCollectionCnv_p4.cxx
+++ b/Generators/GeneratorObjectsTPCnv/src/McEventCollectionCnv_p4.cxx
@@ -1,4 +1,4 @@
- ///////////////////////// -*- C++ -*- /////////////////////////////
+///////////////////////// -*- C++ -*- /////////////////////////////
 
 /*
   Copyright (C) 2002-2020 CERN for the benefit of the ATLAS collaboration
@@ -107,36 +107,6 @@ void McEventCollectionCnv_p4::persToTrans( const McEventCollection_p4* persObj,
         {
           genEvt        =  poolOfEvents.nextElementPtr();
         }
-#ifdef HEPMC3
-      printf("OK1");
-      genEvt->add_attribute("signal_process_id",std::make_shared<HepMC3::IntAttribute>(persEvt.m_signalProcessId));
-      genEvt->set_event_number(persEvt.m_eventNbr);
-      genEvt->add_attribute("event_scale",std::make_shared<HepMC3::DoubleAttribute>(persEvt.m_eventScale));
-      genEvt->add_attribute("alphaQCD",std::make_shared<HepMC3::DoubleAttribute>(persEvt.m_alphaQCD));
-      genEvt->add_attribute("alphaQED",std::make_shared<HepMC3::DoubleAttribute>(persEvt.m_alphaQED));
-
-      //      genEvt->m_signal_process_vertex = 0;
-      genEvt->add_attribute("signal_process_vertex",std::make_shared<HepMC3::IntAttribute>(0));
- //     genEvt->m_weights               = persEvt.m_weights;
- //     genEvt->m_random_states         = persEvt.m_randomStates;
-      //restore weight names from the dedicated svc (which was keeping them in metadata for efficiency)
-    //  genEvt->m_weights.m_names = m_hepMCWeightSvc->weightNames();
-      // pdfinfo restore
-    //  delete genEvt->m_pdf_info; genEvt->m_pdf_info = 0;
-      /*
-      if (!persEvt.m_pdfinfo.empty())
-        {
-          const std::vector<double>& pdf = persEvt.m_pdfinfo;
-          genEvt->m_pdf_info = new HepMC::PdfInfo
-            ( static_cast<int>(pdf[6]), // id1
-              static_cast<int>(pdf[5]), // id2
-              pdf[4],                   // x1
-              pdf[3],                   // x2
-              pdf[2],                   // scalePDF
-              pdf[1],                   // pdf1
-              pdf[0] );                 // pdf2
-        }*/
-#else
       genEvt->m_signal_process_id     = persEvt.m_signalProcessId;
       genEvt->m_event_number          = persEvt.m_eventNbr;
       genEvt->m_event_scale           = persEvt.m_eventScale;
@@ -164,10 +134,9 @@ void McEventCollectionCnv_p4::persToTrans( const McEventCollection_p4* persObj,
               pdf[1],                   // pdf1
               pdf[0] );                 // pdf2
         }
-#endif
-printf("OK2");
+
       transObj->push_back( genEvt );
-printf("OK3");
+
       // 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
@@ -236,71 +205,6 @@ void McEventCollectionCnv_p4::transToPers( const McEventCollection* transObj,
         itr != itrEnd;
         ++itr )
     {
-#ifdef HEPMC3 
-      const unsigned int nPersVtx   = persObj->m_genVertices.size();
-      const unsigned int nPersParts = persObj->m_genParticles.size();
-      const HepMC::GenEvent* genEvt = *itr;
-      //const int signalProcessVtx = genEvt->m_signal_process_vertex? genEvt->m_signal_process_vertex->barcode(): 0;
-      //save the weight names to metadata via the HepMCWeightSvc
-      // m_hepMCWeightSvc->setWeightNames( genEvt->m_weights.m_names ).ignore(); 
-      auto A_signal_process_id=genEvt->attribute<HepMC3::IntAttribute>("signal_process_id");    
-      persObj->m_genEvents.
-      push_back( GenEvent_p4( A_signal_process_id?(A_signal_process_id->value()):0,
-                                genEvt->event_number(),
-                                1,
-                                1,
-                                1,
-                                0,
-                                std::vector<double>(),
-                                std::vector<double>(),
-                                std::vector<long>(),
-                                nPersVtx,
-                                nPersVtx + genEvt->vertices().size(),
-                                nPersParts,
-                                nPersParts + genEvt->particles().size() ) );
-
-
-
-
-  /*       persObj->m_genEvents.
-        push_back( GenEvent_p4( genEvt->m_signal_process_id,
-                                genEvt->m_event_number,
-                                genEvt->m_event_scale,
-                                genEvt->m_alphaQCD,
-                                genEvt->m_alphaQED,
-                                signalProcessVtx,
-                                genEvt->m_weights.m_weights,
-                                std::vector<double>(),
-                                genEvt->m_random_states,
-                                nPersVtx,
-                                nPersVtx + genEvt->vertices_size(),
-                                nPersParts,
-                                nPersParts + genEvt->particles_size() ) );
-      //PdfInfo encoding
-   if (genEvt->m_pdf_info)
-        {
-          GenEvent_p4& persEvt = persObj->m_genEvents.back();
-          std::vector<double>& pdfinfo = persEvt.m_pdfinfo;
-          pdfinfo.resize(7);
-          pdfinfo[6] = static_cast<double>(genEvt->m_pdf_info->m_id1);
-          pdfinfo[5] = static_cast<double>(genEvt->m_pdf_info->m_id2);
-          pdfinfo[4] = genEvt->m_pdf_info->m_x1;
-          pdfinfo[3] = genEvt->m_pdf_info->m_x2;
-          pdfinfo[2] = genEvt->m_pdf_info->m_scalePDF;
-          pdfinfo[1] = genEvt->m_pdf_info->m_pdf1;
-          pdfinfo[0] = genEvt->m_pdf_info->m_pdf2;
-        }
-
-      // create vertices
-      const HepMC::GenEvent::vertex_const_iterator endVtx=genEvt->vertices_end();
-      for ( HepMC::GenEvent::vertex_const_iterator i = genEvt->vertices_begin();
-            i != endVtx;
-            ++i )
-        {
-          writeGenVertex( **i, *persObj );
-        }
-*/
-#else
       const unsigned int nPersVtx   = persObj->m_genVertices.size();
       const unsigned int nPersParts = persObj->m_genParticles.size();
       const HepMC::GenEvent* genEvt = *itr;
@@ -346,7 +250,6 @@ void McEventCollectionCnv_p4::transToPers( const McEventCollection* transObj,
         {
           writeGenVertex( **i, *persObj );
         }
-#endif
 
     } //> end loop over GenEvents
 
@@ -362,45 +265,8 @@ McEventCollectionCnv_p4::createGenVertex( const McEventCollection_p4& persEvt,
                                           ParticlesMap_t& partToEndVtx,
                                           HepMC::DataPool* datapools ) const
 {
-  
-#ifdef HEPMC3
-  DataPool<HepMC::GenVertexPtr>& poolOfVertices = datapools->vtx;
-  HepMC::GenVertexPtr vtx(0);
-  if(m_isPileup)
-    {
-      vtx=HepMC::newGenVertexPtr();
-    }
-  else
-    {
-      vtx = *(poolOfVertices.nextElementPtr());
-    }
-  vtx->set_position(HepMC::FourVector( persVtx.m_x , persVtx.m_y , persVtx.m_z ,persVtx.m_t ));
-//  vtx->m_id      = persVtx.m_id;
-//  vtx->m_weights.m_weights.reserve( persVtx.m_weights.size() );
-//  vtx->m_weights.m_weights.assign ( persVtx.m_weights.begin(),persVtx.m_weights.end() );
-//  vtx->m_event   = 0;
-//  vtx->m_barcode = 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 );
-    }
-
-  // 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 ) );
-    }
-#else
   DataPool<HepMC::GenVertex>& poolOfVertices = datapools->vtx;
-    HepMC::GenVertexPtr vtx(0);
+  HepMC::GenVertexPtr vtx(0);
   if(m_isPileup)
     {
       vtx=HepMC::newGenVertexPtr();
@@ -439,7 +305,6 @@ McEventCollectionCnv_p4::createGenVertex( const McEventCollection_p4& persEvt,
                                                 partToEndVtx,
                                                 datapools ) );
     }
-#endif
 
   return vtx;
 }
@@ -449,67 +314,7 @@ McEventCollectionCnv_p4::createGenParticle( const GenParticle_p4& persPart,
                                             ParticlesMap_t& partToEndVtx,
                                             HepMC::DataPool* datapools ) const
 {
-#ifdef HEPMC3
-  DataPool<HepMC::GenParticlePtr>& poolOfParticles = datapools->part;
-  HepMC::GenParticlePtr p(0);
-  if (m_isPileup)
-    {
-      p = HepMC::newGenParticlePtr();
-    }
-  else
-    {
-      p    = *(poolOfParticles.nextElementPtr());
-    }
-  p->set_pdg_id(              persPart.m_pdgId);
-  p->set_status(              persPart.m_status);
-  //p->m_polarization.m_theta= static_cast<double>(persPart.m_thetaPolarization);
-  //p->m_polarization.m_phi  = static_cast<double>(persPart.m_phiPolarization  );
-  //p->m_production_vertex   = 0;
-  //p->m_end_vertex          = 0;
-  //p->m_barcode             = persPart.m_barcode;
-
-  // Note: do the E calculation in extended (long double) precision.
-  // That happens implicitly on x86 with optimization on; saying it
-  // explicitly ensures that we get the same results with and without
-  // 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 )
-    {
-      double temp_e = std::sqrt( (long double)(persPart.m_px)*persPart.m_px +
-                            (long double)(persPart.m_py)*persPart.m_py +
-                            (long double)(persPart.m_pz)*persPart.m_pz +
-                            (long double)(persPart.m_m) *persPart.m_m );
-      p->set_momentum( HepMC::FourVector(persPart.m_px,persPart.m_px,persPart.m_px,temp_e));
-    }
-  else
-    {
-      const int signM2 = ( persPart.m_m >= 0. ? 1 : -1 );
-      const double persPart_ene =
-        std::sqrt( std::abs((long double)(persPart.m_px)*persPart.m_px +
-                  (long double)(persPart.m_py)*persPart.m_py +
-                  (long double)(persPart.m_pz)*persPart.m_pz +
-                  signM2* (long double)(persPart.m_m)* persPart.m_m));
-      const int signEne = ( persPart.m_recoMethod == 1 ? 1 : -1 );
-     p->set_momentum( HepMC::FourVector( persPart.m_px,
-                         persPart.m_py,
-                         persPart.m_pz,
-                         signEne * persPart_ene ));
-    }
-
-  // setup flow
-  const unsigned int nFlow = persPart.m_flow.size();
-  for ( unsigned int iFlow= 0; iFlow != nFlow; ++iFlow )
-    {
-      //p->m_flow.set_icode( persPart.m_flow[iFlow].first, persPart.m_flow[iFlow].second );
-    }
-
-  if ( persPart.m_endVtx != 0 )
-    {
-      partToEndVtx[p] = persPart.m_endVtx;
-    }
-
-#else
-DataPool<HepMC::GenParticle>& poolOfParticles = datapools->part;
+  DataPool<HepMC::GenParticle>& poolOfParticles = datapools->part;
   HepMC::GenParticlePtr p(0);
   if (m_isPileup)
     {
@@ -576,44 +381,9 @@ DataPool<HepMC::GenParticle>& poolOfParticles = datapools->part;
       partToEndVtx[p] = persPart.m_endVtx;
     }
 
-#endif
   return p;
 }
 
-#ifdef HEPMC3
-void McEventCollectionCnv_p4::writeGenVertex( const HepMC::GenVertexPtr vtx,
-                                              McEventCollection_p4& persEvt ) const
-{                                              
-  const HepMC::FourVector& position = vtx->position();
-  std::vector<double> foo;
-  persEvt.m_genVertices.push_back(
-                                  GenVertex_p4( position.x(),
-                                                position.y(),
-                                                position.z(),
-                                                position.t(),
-                                                vtx->id(),
-                                                foo.begin(),//vtx.m_weights.m_weights.begin(),
-                                                foo.end(),//vtx.m_weights.m_weights.end(),
-                                                0//HepMC::barcode(vtx)
-                                                ) );
-  GenVertex_p4& persVtx = persEvt.m_genVertices.back();
-  // we write only the orphans in-coming particles
-  persVtx.m_particlesIn.reserve(vtx->particles_in().size());
-  for ( auto p: vtx->particles_in())
-    {
-      if ( !p->production_vertex() )
-        {
-          persVtx.m_particlesIn.push_back( writeGenParticle(p, persEvt ));
-        }
-    }
-  persVtx.m_particlesOut.reserve(vtx->particles_out().size());
-  for ( auto p: vtx->particles_out())
-    {
-      persVtx.m_particlesOut.push_back( writeGenParticle(p, persEvt ) );
-    }
-  return;
-}                                              
-#else
 void McEventCollectionCnv_p4::writeGenVertex( const HepMC::GenVertex& vtx,
                                               McEventCollection_p4& persEvt ) const
 {
@@ -653,51 +423,7 @@ void McEventCollectionCnv_p4::writeGenVertex( const HepMC::GenVertex& vtx,
 
   return;
 }
-#endif
 
-#ifdef HEPMC3
-int McEventCollectionCnv_p4::writeGenParticle( const HepMC::GenParticlePtr p,
-                                               McEventCollection_p4& persEvt ) const
-{                                               
-  const HepMC::FourVector& mom = p->momentum();
-  const double ene = mom.e();
-  const double m2  = mom.m2();
-
-  // Definitions of Bool isTimeLilike, isSpacelike and isLightlike according to HepLorentzVector definition
-  const bool useP2M2 = !(m2 > 0) &&   // !isTimelike
-    (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
-                                 ? 1
-                                 : 2 ) );
-
-    persEvt.m_genParticles.
-    push_back( GenParticle_p4( mom.px(),
-                               mom.py(),
-                               mom.pz(),
-                               mom.m(),
-                               p->pdg_id(),
-                               p->status(),
-                               0,//p.m_flow.size(),
-                               0,//p.m_polarization.theta(),
-                               0,//p.m_polarization.phi(),
-                               0,//p.m_production_vertex? p.m_production_vertex->barcode(): 0,
-                               0,//p.m_end_vertex? p.m_end_vertex->barcode(): 0,
-                               HepMC::barcode(p),
-                               recoMethod ) );
-  //persEvt.m_genParticles.back().m_flow.assign( p.m_flow.begin(),p.m_flow.end() );
-
-  // we return the index of the particle in the big vector of particles
-  // (contained by the persistent GenEvent)
-  return (persEvt.m_genParticles.size() - 1);
-}                                               
-#else
 int McEventCollectionCnv_p4::writeGenParticle( const HepMC::GenParticle& p,
                                                McEventCollection_p4& persEvt ) const
 {
@@ -741,7 +467,6 @@ int McEventCollectionCnv_p4::writeGenParticle( const HepMC::GenParticle& p,
   // (contained by the persistent GenEvent)
   return (persEvt.m_genParticles.size() - 1);
 }
-#endif
 
 void McEventCollectionCnv_p4::setPileup()
 {
diff --git a/Generators/GeneratorObjectsTPCnv/src/McEventCollectionCnv_p5.cxx b/Generators/GeneratorObjectsTPCnv/src/McEventCollectionCnv_p5.cxx
index 717af7f03c4a..a769cb98d3f4 100755
--- a/Generators/GeneratorObjectsTPCnv/src/McEventCollectionCnv_p5.cxx
+++ b/Generators/GeneratorObjectsTPCnv/src/McEventCollectionCnv_p5.cxx
@@ -93,139 +93,6 @@ void McEventCollectionCnv_p5::persToTrans( const McEventCollection_p5* persObj,
     } else {
       genEvt        =  poolOfEvents.nextElementPtr();
     }
-#ifdef HEPMC3
-  
-  
-
-//   genEvt->m_signal_process_id     = persEvt.m_signalProcessId;
-//    genEvt->m_event_number          = persEvt.m_eventNbr;
-   genEvt->add_attribute("signal_process_id",std::make_shared<HepMC3::IntAttribute>(persEvt.m_signalProcessId));
-
-   genEvt->set_event_number(persEvt.m_eventNbr);
-/*
-    genEvt->m_mpi                   = persEvt.m_mpi;
-    genEvt->m_event_scale           = persEvt.m_eventScale;
-    genEvt->m_alphaQCD              = persEvt.m_alphaQCD;
-    genEvt->m_alphaQED              = persEvt.m_alphaQED;
-    genEvt->m_signal_process_vertex = 0;
-    genEvt->m_beam_particle_1       = 0;
-    genEvt->m_beam_particle_2       = 0;
-    genEvt->m_weights               = persEvt.m_weights;
-    genEvt->m_random_states         = persEvt.m_randomStates;
-    genEvt->m_vertex_barcodes.clear();
-    genEvt->m_particle_barcodes.clear();
-    genEvt->m_momentum_unit         = static_cast<HepMC::Units::MomentumUnit>(persEvt.m_momentumUnit);
-    genEvt->m_position_unit         = static_cast<HepMC::Units::LengthUnit>(persEvt.m_lengthUnit);
-
-    //restore weight names from the dedicated svc (which was keeping them in metadata for efficiency)
-    genEvt->m_weights.m_names = m_hepMCWeightSvc->weightNames();
-
-    // cross-section restore
-    if( genEvt->m_cross_section )
-      delete genEvt->m_cross_section;
-    genEvt->m_cross_section = 0;
-
-    genEvt->m_cross_section = new HepMC::GenCrossSection();
-    if (!persEvt.m_crossSection.empty()) {
-      const std::vector<double>& xsection = persEvt.m_crossSection;
-      if( static_cast<bool>(xsection[0]) )
-        genEvt->m_cross_section->set_cross_section(xsection[2],xsection[1]);
-    }
-
-    // heavyIon restore
-    if(genEvt->m_heavy_ion )
-      delete genEvt->m_heavy_ion;
-    genEvt->m_heavy_ion = 0;
-    if (!persEvt.m_heavyIon.empty()) {
-      const std::vector<float>& hIon = persEvt.m_heavyIon;
-      genEvt->m_heavy_ion = new HepMC::HeavyIon
-        (
-         static_cast<int>(hIon[12]), // Ncoll_hard
-         static_cast<int>(hIon[11]), // Npart_proj
-         static_cast<int>(hIon[10]), // Npart_targ
-         static_cast<int>(hIon[9]), // Ncoll
-         static_cast<int>(hIon[8]), // spectator_neutrons
-         static_cast<int>(hIon[7]), // spectator_protons
-         static_cast<int>(hIon[6]), // N_Nwounded_collisions
-         static_cast<int>(hIon[5]), // Nwounded_N_collisions
-         static_cast<int>(hIon[4]), // Nwounded_Nwounded_collisions
-         hIon[3],                   // impact_parameter
-         hIon[2],                  // event_plane_angle
-         hIon[1],                  // eccentricity
-         hIon[0]         );         // sigma_inel_NN
-    }
-
-
-
-    // pdfinfo restore
-    if(genEvt->m_pdf_info)
-      delete genEvt->m_pdf_info;
-    genEvt->m_pdf_info = 0;
-    if (!persEvt.m_pdfinfo.empty()) {
-      const std::vector<double>& pdf = persEvt.m_pdfinfo;
-      genEvt->m_pdf_info = new HepMC::PdfInfo
-        (
-         static_cast<int>(pdf[8]), // id1
-         static_cast<int>(pdf[7]), // id2
-         pdf[4],                   // x1
-         pdf[3],                   // x2
-         pdf[2],                   // scalePDF
-         pdf[1],                   // pdf1
-         pdf[0],                   // pdf2
-         static_cast<int>(pdf[6]), // pdf_id1
-         static_cast<int>(pdf[5])  // pdf_id2
-         );
-    }
-*/
-    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
-    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 ) );
-    } //> end loop over vertices
-
-    // set the signal process vertex
-    const int sigProcVtx = persEvt.m_signalProcessVtx;
-    if ( sigProcVtx != 0 ) {
-      genEvt->set_signal_process_vertex( genEvt->barcode_to_vertex( sigProcVtx ) );
-    }
-
-    // connect particles to their end vertices
-    for ( ParticlesMap_t::iterator
-            p = partToEndVtx.begin(),
-            endItr = partToEndVtx.end();
-          p != endItr;
-          ++p ) {
-      auto decayVtx = HepMC::barcode_to_vertex(genEvt, p->second );
-      if ( decayVtx ) {
-        decayVtx->add_particle_in( p->first );
-      } else {
-        msg << MSG::ERROR
-            << "GenParticle points to null end vertex !!"
-            << endmsg;
-      }
-    }
-
-    // set the beam particles
-    const int beamPart1 = persEvt.m_beamParticle1;
-    const int beamPart2 = persEvt.m_beamParticle2;
-    if (  beamPart1 != 0  &&  beamPart2 !=0 ) {
-      genEvt->set_beam_particles(genEvt->barcode_to_particle(beamPart1),
-                                 genEvt->barcode_to_particle(beamPart2));
-    }
-*/
-#else  
     genEvt->m_signal_process_id     = persEvt.m_signalProcessId;
     genEvt->m_event_number          = persEvt.m_eventNbr;
     genEvt->m_mpi                   = persEvt.m_mpi;
@@ -350,7 +217,6 @@ void McEventCollectionCnv_p5::persToTrans( const McEventCollection_p5* persObj,
                                  genEvt->barcode_to_particle(beamPart2));
     }
 
-#endif
 
 
   } //> end loop over m_genEvents
@@ -380,99 +246,6 @@ void McEventCollectionCnv_p5::transToPers( const McEventCollection* transObj,
     const unsigned int nPersVtx   = persObj->m_genVertices.size();
     const unsigned int nPersParts = persObj->m_genParticles.size();
     const HepMC::GenEvent* genEvt = *itr;
-#ifdef HEPMC3
-/*    const int signalProcessVtx = genEvt->m_signal_process_vertex
-      ? genEvt->m_signal_process_vertex->barcode()
-      : 0;
-    const int beamParticle1Barcode = genEvt->m_beam_particle_1
-      ? genEvt->m_beam_particle_1->barcode()
-      : 0;
-    const int beamParticle2Barcode = genEvt->m_beam_particle_2
-      ? genEvt->m_beam_particle_2->barcode()
-      : 0;
-
-   //save the weight names to metadata via the HepMCWeightSvc 
-   m_hepMCWeightSvc->setWeightNames( genEvt->m_weights.m_names ).ignore();
-   */
- auto A_signal_process_id=genEvt->attribute<HepMC3::IntAttribute>("signal_process_id");
-    persObj->m_genEvents.
-      push_back( GenEvent_p5(A_signal_process_id?(A_signal_process_id->value()):0,
-                              genEvt->event_number(),
-                              0,//genEvt->mpi(),              // number of multi particle interactions
-                              0,//genEvt->m_event_scale,
-                              0,//genEvt->m_alphaQCD,
-                              0,//genEvt->m_alphaQED,
-                              0,//signalProcessVtx,
-                              0,//beamParticle1Barcode,       // barcodes of beam particles
-                              0,//beamParticle2Barcode,
-                              std::vector<double>(),//genEvt->m_weights.m_weights,
-                              std::vector<long>(),//genEvt->m_random_states,
-                              std::vector<double>(),      // cross section
-                              std::vector<float>(),       // heavyion
-                              std::vector<double>(),      // pdf info
-                              0,//genEvt->m_momentum_unit,
-                              0,//genEvt->m_position_unit,
-                              nPersVtx,
-                              nPersVtx + genEvt->vertices().size(),
-                              nPersParts,
-                              nPersParts + genEvt->particles().size() ) );
-    
-    
-    /*
-    //HepMC::GenCrossSection encoding
-    if (genEvt->m_cross_section) {
-      GenEvent_p5& persEvt = persObj->m_genEvents.back();
-      std::vector<double>& crossSection = persEvt.m_crossSection;
-      crossSection.resize(3);
-      crossSection[2] = genEvt->m_cross_section->m_cross_section;
-      crossSection[1] = genEvt->m_cross_section->m_cross_section_error;
-      crossSection[0] = static_cast<double>(genEvt->m_cross_section->m_is_set);
-    }
-
-    //HepMC::HeavyIon encoding
-    if (genEvt->m_heavy_ion) {
-      GenEvent_p5& persEvt = persObj->m_genEvents.back();
-      std::vector<float>& heavyIon = persEvt.m_heavyIon;
-      heavyIon.resize(13);
-      heavyIon[12]  = static_cast<float>(genEvt->m_heavy_ion->m_Ncoll_hard);
-      heavyIon[11]  = static_cast<float>(genEvt->m_heavy_ion->m_Npart_proj);
-      heavyIon[10]  = static_cast<float>(genEvt->m_heavy_ion->m_Npart_targ);
-      heavyIon[9]   = static_cast<float>(genEvt->m_heavy_ion->m_Ncoll);
-      heavyIon[8]   = static_cast<float>(genEvt->m_heavy_ion->m_spectator_neutrons);
-      heavyIon[7]   = static_cast<float>(genEvt->m_heavy_ion->m_spectator_protons);
-      heavyIon[6]   = static_cast<float>(genEvt->m_heavy_ion->m_N_Nwounded_collisions);
-      heavyIon[5]   = static_cast<float>(genEvt->m_heavy_ion->m_Nwounded_N_collisions);
-      heavyIon[4]   = static_cast<float>(genEvt->m_heavy_ion->m_Nwounded_Nwounded_collisions);
-      heavyIon[3]   = genEvt->m_heavy_ion->m_impact_parameter;
-      heavyIon[2]   = genEvt->m_heavy_ion->m_event_plane_angle;
-      heavyIon[1]   = genEvt->m_heavy_ion->m_eccentricity;
-      heavyIon[0]   = genEvt->m_heavy_ion->m_sigma_inel_NN;
-    }
-
-    //PdfInfo encoding
-    if (genEvt->m_pdf_info) {
-      GenEvent_p5& persEvt = persObj->m_genEvents.back();
-      std::vector<double>& pdfinfo = persEvt.m_pdfinfo;
-      pdfinfo.resize(9);
-      pdfinfo[8] = static_cast<double>(genEvt->m_pdf_info->m_id1);
-      pdfinfo[7] = static_cast<double>(genEvt->m_pdf_info->m_id2);
-      pdfinfo[6] = static_cast<double>(genEvt->m_pdf_info->m_pdf_id1);
-      pdfinfo[5] = static_cast<double>(genEvt->m_pdf_info->m_pdf_id2);
-      pdfinfo[4] = genEvt->m_pdf_info->m_x1;
-      pdfinfo[3] = genEvt->m_pdf_info->m_x2;
-      pdfinfo[2] = genEvt->m_pdf_info->m_scalePDF;
-      pdfinfo[1] = genEvt->m_pdf_info->m_pdf1;
-      pdfinfo[0] = genEvt->m_pdf_info->m_pdf2;
-    }
-
-    // create vertices
-    const HepMC::GenEvent::vertex_const_iterator endVtx=genEvt->vertices_end();
-    for ( HepMC::GenEvent::vertex_const_iterator i = genEvt->vertices_begin();
-          i != endVtx;
-          ++i ) {
-      writeGenVertex( **i, *persObj );
-    }*/
-#else
     const int signalProcessVtx = genEvt->m_signal_process_vertex
       ? genEvt->m_signal_process_vertex->barcode()
       : 0;
@@ -561,7 +334,6 @@ void McEventCollectionCnv_p5::transToPers( const McEventCollection* transObj,
           ++i ) {
       writeGenVertex( **i, *persObj );
     }
-#endif
 
   } //> end loop over GenEvents
 
@@ -577,15 +349,8 @@ McEventCollectionCnv_p5::createGenVertex( const McEventCollection_p5& persEvt,
                                           ParticlesMap_t& partToEndVtx, HepMC::DataPool* datapools
                                           ) const
 {
-#ifdef HEPMC3
-  DataPool<HepMC::GenVertexPtr>& poolOfVertices = datapools->vtx;
-#else
   DataPool<HepMC::GenVertex>& poolOfVertices = datapools->vtx;
-#endif
   HepMC::GenVertexPtr vtx(0);
-#ifdef HEPMC3
-
-#else
   if(m_isPileup) {
     vtx=HepMC::newGenVertexPtr();
   } else {
@@ -620,7 +385,6 @@ McEventCollectionCnv_p5::createGenVertex( const McEventCollection_p5& persEvt,
                                               datapools ) );
   }
 
-#endif
   return vtx;
 }
 
@@ -628,16 +392,8 @@ HepMC::GenParticlePtr
 McEventCollectionCnv_p5::createGenParticle( const GenParticle_p5& persPart,
                                             ParticlesMap_t& partToEndVtx, HepMC::DataPool* datapools ) const
 {
-
-#ifdef HEPMC3
-  DataPool<HepMC::GenParticlePtr>& poolOfParticles = datapools->part;
-#else
   DataPool<HepMC::GenParticle>& poolOfParticles = datapools->part;
-#endif
   HepMC::GenParticlePtr p(0);
-#ifdef HEPMC3
-
-#else
   if (m_isPileup) {
     p = HepMC::newGenParticlePtr();
   } else {
@@ -693,21 +449,12 @@ McEventCollectionCnv_p5::createGenParticle( const GenParticle_p5& persPart,
     partToEndVtx[p] = persPart.m_endVtx;
   }
 
-#endif
   return p;
 }
-#ifdef HEPMC3
 
-void McEventCollectionCnv_p5::writeGenVertex( const HepMC::GenVertexPtr vtx,
-                                              McEventCollection_p5& persEvt ) const
-#else
 void McEventCollectionCnv_p5::writeGenVertex( const HepMC::GenVertex& vtx,
                                               McEventCollection_p5& persEvt ) const
-#endif
 {
-#ifdef HEPMC3
-  const HepMC::FourVector& position = vtx->position();
-#else
   const HepMC::FourVector& position = vtx.m_position;
   persEvt.m_genVertices.push_back(
                                   GenVertex_p5( position.x(),
@@ -718,10 +465,6 @@ void McEventCollectionCnv_p5::writeGenVertex( const HepMC::GenVertex& vtx,
                                                 vtx.m_weights.m_weights.begin(),
                                                 vtx.m_weights.m_weights.end(),
                                                 vtx.m_barcode ) );
-#endif
-#ifdef HEPMC3
-
-#else
   GenVertex_p5& persVtx = persEvt.m_genVertices.back();
 
   // we write only the orphans in-coming particles
@@ -743,23 +486,13 @@ void McEventCollectionCnv_p5::writeGenVertex( const HepMC::GenVertex& vtx,
     persVtx.m_particlesOut.push_back( writeGenParticle( **p, persEvt ) );
   }
 
-#endif
   return;
 }
 
-#ifdef HEPMC3
-int McEventCollectionCnv_p5::writeGenParticle( const HepMC::GenParticlePtr p,
-                                               McEventCollection_p5& persEvt ) const
-#else
 int McEventCollectionCnv_p5::writeGenParticle( const HepMC::GenParticle& p,
                                                McEventCollection_p5& persEvt ) const
-#endif
 {
-#ifdef HEPMC3
-  const HepMC::FourVector mom = p->momentum();
-#else
   const HepMC::FourVector& mom = p.m_momentum;
-#endif
   const double ene = mom.e();
   const double m2  = mom.m2();
 
@@ -774,8 +507,6 @@ int McEventCollectionCnv_p5::writeGenParticle( const HepMC::GenParticle& p,
                                  ? 1
                                  : 2 ) );
 
-#ifdef HEPMC3
-#else
 
   persEvt.m_genParticles.
     push_back( GenParticle_p5( mom.px(),
@@ -799,7 +530,6 @@ int McEventCollectionCnv_p5::writeGenParticle( const HepMC::GenParticle& p,
   persEvt.m_genParticles.back().m_flow.assign( p.m_flow.begin(),
                                                p.m_flow.end() );
 
-#endif
   // we return the index of the particle in the big vector of particles
   // (contained by the persistent GenEvent)
   return (persEvt.m_genParticles.size() - 1);
diff --git a/PhysicsAnalysis/AnalysisCommon/AnalysisTest/CMakeLists.txt b/PhysicsAnalysis/AnalysisCommon/AnalysisTest/CMakeLists.txt
index a1544af7aadd..5e99eea7a1fe 100644
--- a/PhysicsAnalysis/AnalysisCommon/AnalysisTest/CMakeLists.txt
+++ b/PhysicsAnalysis/AnalysisCommon/AnalysisTest/CMakeLists.txt
@@ -23,7 +23,6 @@ atlas_depends_on_subdirs( PUBLIC
                           Control/AthenaKernel
                           Event/EventKernel
                           Event/FourMom
-                          Generators/AtlasHepMC
                           Generators/GeneratorObjects
                           PhysicsAnalysis/AnalysisCommon/AnalysisAssociation
                           PhysicsAnalysis/AnalysisCommon/AnalysisUtils
diff --git a/PhysicsAnalysis/TruthParticleID/McParticleTools/src/McVtxFilterTool.cxx b/PhysicsAnalysis/TruthParticleID/McParticleTools/src/McVtxFilterTool.cxx
index b3a7447b747b..95aaa5558937 100755
--- a/PhysicsAnalysis/TruthParticleID/McParticleTools/src/McVtxFilterTool.cxx
+++ b/PhysicsAnalysis/TruthParticleID/McParticleTools/src/McVtxFilterTool.cxx
@@ -327,7 +327,7 @@ void McVtxFilterTool::addVertex( const HepMC::GenVertex* srcVtx,
   ATH_MSG_VERBOSE("In McVtxFilterTool::addVertex( vtxType= "<<vtxType<< " )");
   HepMC::GenVertex * vtx = evt->barcode_to_vertex(srcVtx->barcode());
   if ( 0 == vtx ) {
-    vtx = HepMC::newGenVertexPtr();
+    vtx = new HepMC::GenVertex();
     vtx->set_position( srcVtx->position() );
     vtx->set_id( srcVtx->id() );
     vtx->suggest_barcode( srcVtx->barcode() );
@@ -341,7 +341,7 @@ void McVtxFilterTool::addVertex( const HepMC::GenVertex* srcVtx,
 	++parent ) {
     HepMC::GenParticle * mother = evt->barcode_to_particle( (*parent)->barcode() );
     if ( 0 == mother ) {
-      mother = HepMC::newGenParticlePtr();
+      mother = new HepMC::GenParticle;
       mother->set_momentum( (*parent)->momentum() );
       mother->set_generated_mass( (*parent)->generated_mass() );
       mother->set_pdg_id( (*parent)->pdg_id() );
@@ -368,7 +368,7 @@ void McVtxFilterTool::addVertex( const HepMC::GenVertex* srcVtx,
 			<< (*child)->pdg_id() << "|" 
 			<< (*child)->barcode() << "]");
       } else {
-	daughter = HepMC::newGenParticlePtr();
+	daughter = new HepMC::GenParticle;
 	daughter->set_momentum( (*child)->momentum() );
    daughter->set_generated_mass( (*child)->generated_mass() );
 	daughter->set_pdg_id( (*child)->pdg_id() );
diff --git a/PhysicsAnalysis/TruthParticleID/McParticleTools/src/OldSpclMcFilterTool.cxx b/PhysicsAnalysis/TruthParticleID/McParticleTools/src/OldSpclMcFilterTool.cxx
index 888edd4999a8..17655a7d1207 100755
--- a/PhysicsAnalysis/TruthParticleID/McParticleTools/src/OldSpclMcFilterTool.cxx
+++ b/PhysicsAnalysis/TruthParticleID/McParticleTools/src/OldSpclMcFilterTool.cxx
@@ -608,7 +608,7 @@ StatusCode OldSpclMcFilterTool::rebuildLinks( const HepMC::GenEvent * mcEvt,
 		// create a GenVertex which will be the decay vertex of our
 		// GenParticle and the production vertex of the GenParticle
 		// we just found
-		HepMC::GenVertexPtr linkVtx = HepMC::newGenVertexPtr();
+		HepMC::GenVertex * linkVtx = new HepMC::GenVertex();
 		outEvt->add_vertex( linkVtx );
 		linkVtx->add_particle_in( mcPart );
 		linkVtx->add_particle_out( *itrPart );
diff --git a/PhysicsAnalysis/TruthParticleID/McParticleTools/src/PileupFilterTool.cxx b/PhysicsAnalysis/TruthParticleID/McParticleTools/src/PileupFilterTool.cxx
index 1ae2edd6ddd2..57ce5b8731ef 100755
--- a/PhysicsAnalysis/TruthParticleID/McParticleTools/src/PileupFilterTool.cxx
+++ b/PhysicsAnalysis/TruthParticleID/McParticleTools/src/PileupFilterTool.cxx
@@ -573,7 +573,7 @@ StatusCode PileupFilterTool::rebuildLinks( const HepMC::GenEvent * mcEvt,
 		// create a GenVertex which will be the decay vertex of our
 		// GenParticle and the production vertex of the GenParticle
 		// we just found
-		HepMC::GenVertexPtr linkVtx = HepMC::newGenVertexPtr();
+		HepMC::GenVertex * linkVtx = new HepMC::GenVertex();
 		outEvt->add_vertex( linkVtx );
 		linkVtx->add_particle_in( mcPart );
 		linkVtx->add_particle_out( *itrPart );
diff --git a/PhysicsAnalysis/TruthParticleID/McParticleUtils/test/McVtxFilterTest_CppUnit.cxx b/PhysicsAnalysis/TruthParticleID/McParticleUtils/test/McVtxFilterTest_CppUnit.cxx
index 29dfd2d6e5a9..f205bc92ffae 100755
--- a/PhysicsAnalysis/TruthParticleID/McParticleUtils/test/McVtxFilterTest_CppUnit.cxx
+++ b/PhysicsAnalysis/TruthParticleID/McParticleUtils/test/McVtxFilterTest_CppUnit.cxx
@@ -81,15 +81,15 @@ public:
     m_evt->set_random_states( rdmStates );
     
     // Add 2 vertices
-    HepMC::GenVertex * v1 = HepMC::newGenVertexPtr();
+    HepMC::GenVertex * v1 = new HepMC::GenVertex();
     m_evt->add_vertex( v1 );
-    v1->add_particle_in( HepMC::newGenParticlePtr( HepMC::FourVector(0,0,
+    v1->add_particle_in( new HepMC::GenParticle( HLV_t(0,0,
 						       7000*GeV,
 						       7000*GeV),
 						 2212, 3 ) );
     HepMC::GenVertex* v2 = new HepMC::GenVertex;
     m_evt->add_vertex( v2 );
-    v2->add_particle_in( HepMC::newGenParticlePtr( HepMC::FourVector(0,0,
+    v2->add_particle_in( new HepMC::GenParticle( HLV_t(0,0,
 						       -7000*GeV,
 						       +7000*GeV),
 						 2212, 3 ) );
@@ -97,13 +97,13 @@ public:
     //
     // create the outgoing particles of v1 and v2
     HepMC::GenParticle* p3 = 
-      HepMC::newGenParticlePtr( HepMC::FourVector(.750*GeV,
+      new HepMC::GenParticle( HLV_t(.750*GeV,
 				    -1.569*GeV,
 				    32.191*GeV,
 				    32.238*GeV), 1, 3 );
     v1->add_particle_out( p3 );
     HepMC::GenParticle* p4 = 
-      HepMC::newGenParticlePtr( HepMC::FourVector( -3.047*GeV,
+      new HepMC::GenParticle( HLV_t( -3.047*GeV,
 				     -19.*GeV,
 				     -54.629*GeV,
 				     57.920*GeV), -2, 3 );
@@ -111,16 +111,16 @@ public:
     
     //
     // create v3
-    HepMC::GenVertex* v3 = HepMC::newGenVertexPtr();
+    HepMC::GenVertex* v3 = new HepMC::GenVertex();
     m_evt->add_vertex( v3 );
     v3->add_particle_in( p3 );
     v3->add_particle_in( p4 );
     v3->add_particle_out( 
-	HepMC::newGenParticlePtr( HepMC::FourVector(-3.813,0.113,-1.833,4.233 ), 
+	new HepMC::GenParticle( HLV_t(-3.813,0.113,-1.833,4.233 ), 
 				22, 1 )
 	);
     HepMC::GenParticle* p5 = 
-	HepMC::newGenParticlePtr( HepMC::FourVector(1.517,-20.68,-20.605,85.925), 
+	new HepMC::GenParticle( HLV_t(1.517,-20.68,-20.605,85.925), 
 				-24,3);
     v3->add_particle_out( p5 );
 
@@ -134,39 +134,39 @@ public:
     HepMC::GenVertex * vZgee = new HepMC::GenVertex;
     m_evt->add_vertex( vZgee );
     // Z0
-    vZgee->add_particle_in( HepMC::newGenParticlePtr( HepMC::FourVector( -4.49e+04,
+    vZgee->add_particle_in( new HepMC::GenParticle( HLV_t( -4.49e+04,
 							   +8.36e+03,
 							   -2.70e+05,
 							   +2.89e+05 ),
 						    23, 2 ) );
     // Gammas
-    vZgee->add_particle_out( HepMC::newGenParticlePtr( HepMC::FourVector( -1.28e+03,
+    vZgee->add_particle_out( new HepMC::GenParticle( HLV_t( -1.28e+03,
 							    +1.03e+03,
 							    -5.47e+03,
 							    +5.71e+03 ),
 						     22, 1 ) );
-    vZgee->add_particle_out( HepMC::newGenParticlePtr( HepMC::FourVector( +3.89e+02,
+    vZgee->add_particle_out( new HepMC::GenParticle( HLV_t( +3.89e+02,
 							    -3.16e+02,
 							    -6.69e+03,
 							    +6.70e+03 ),
 						     22, 1 ) );
-    vZgee->add_particle_out( HepMC::newGenParticlePtr( HepMC::FourVector( +7.34e+00,
+    vZgee->add_particle_out( new HepMC::GenParticle( HLV_t( +7.34e+00,
 							    -2.71e+01,
 							    -4.12e+01,
 							    +4.98e+01 ),
 						     22, 1 ) );
-    vZgee->add_particle_out( HepMC::newGenParticlePtr( HepMC::FourVector( -1.36e+02,
+    vZgee->add_particle_out( new HepMC::GenParticle( HLV_t( -1.36e+02,
 							    +9.38e+01,
 							    -5.62e+02,
 							    +5.86e+02 ),
 						     22, 1 ) );
     // Electrons
-    vZgee->add_particle_out( HepMC::newGenParticlePtr( HepMC::FourVector( +8.01e+03,
+    vZgee->add_particle_out( new HepMC::GenParticle( HLV_t( +8.01e+03,
 							    -2.96e+04,
 							    -4.50e+04,
 							    +5.44e+04 ),
 						     -11, 1 ) );
-    vZgee->add_particle_out( HepMC::newGenParticlePtr( HepMC::FourVector( -5.19e+04,
+    vZgee->add_particle_out( new HepMC::GenParticle( HLV_t( -5.19e+04,
 							    +3.72e+04,
 							    -2.13e+05,
 							    +2.22e+05 ),
@@ -178,18 +178,18 @@ public:
     // Add a Z->e+e-
     HepMC::GenVertex * vZee = new HepMC::GenVertex;
     m_evt->add_vertex( vZee );
-    vZee->add_particle_in( HepMC::newGenParticlePtr( HepMC::FourVector( +7.29e+03,
+    vZee->add_particle_in( new HepMC::GenParticle( HLV_t( +7.29e+03,
 							  +2.34e+04,
 							  +2.81e+05,
 							  +2.96e+05 ),
 						   23, 2 ) );
     
-    vZee->add_particle_out( HepMC::newGenParticlePtr( HepMC::FourVector( +2.74e+04,
+    vZee->add_particle_out( new HepMC::GenParticle( HLV_t( +2.74e+04,
 							   -1.83e+04,
 							   +4.70e+04,
 							   +5.74e+04 ),
 						    11, 1 ) );
-    vZee->add_particle_out( HepMC::newGenParticlePtr( HepMC::FourVector( -2.01e+04,
+    vZee->add_particle_out( new HepMC::GenParticle( HLV_t( -2.01e+04,
 							   +4.17e+04,
 							   +2.34e+05,
 							   +2.38e+05 ),
@@ -201,29 +201,29 @@ public:
     HepMC::GenVertex * vtWbgg = new HepMC::GenVertex;
     m_evt->add_vertex( vtWbgg );
     // top
-    vtWbgg->add_particle_in(HepMC::newGenParticlePtr(HLV_t(-2.35e+05,
+    vtWbgg->add_particle_in(new HepMC::GenParticle(HLV_t(-2.35e+05,
 							 +7.34e+04,
 							 +3.60e+04,
 							 +3.04e+05),
 						   6, 3 ) );
 
     // Wbgg
-    vtWbgg->add_particle_out(HepMC::newGenParticlePtr(HLV_t(-1.09e+05,
+    vtWbgg->add_particle_out(new HepMC::GenParticle(HLV_t(-1.09e+05,
 							  +6.99e+04,
 							  -3.86e+04,
 							  +1.57e+05),
 						    24, 2 ) );
-    vtWbgg->add_particle_out(HepMC::newGenParticlePtr(HLV_t(-9.23e+04,
+    vtWbgg->add_particle_out(new HepMC::GenParticle(HLV_t(-9.23e+04,
 							  +2.54e+03,
 							  +5.32e+04,
 							  +1.07e+05),
 						    5, 2 ) );
-    vtWbgg->add_particle_out(HepMC::newGenParticlePtr(HLV_t(-4.76e+03,
+    vtWbgg->add_particle_out(new HepMC::GenParticle(HLV_t(-4.76e+03,
 							  +6.72e+02,
 							  +2.90e+03,
 							  +5.62e+03),
 						    21, 2 ) );
-    vtWbgg->add_particle_out(HepMC::newGenParticlePtr(HLV_t(-2.93e+04,
+    vtWbgg->add_particle_out(new HepMC::GenParticle(HLV_t(-2.93e+04,
 							  +2.13e+02,
 							  +1.85e+04,
 							  +3.46e+04),
@@ -459,12 +459,12 @@ public:
   {
     HepMC::GenVertex * vtx = new HepMC::GenVertex;
     m_evt->add_vertex( vtx );
-    vtx->add_particle_in( HepMC::newGenParticlePtr( HepMC::FourVector( -2.45e+04,
+    vtx->add_particle_in( new HepMC::GenParticle( HLV_t( -2.45e+04,
 							 +1.88e+04,
 							 -8.65e+05,
 							 +8.65e+05 ),
 						  22, 3 ) );
-    vtx->add_particle_out( HepMC::newGenParticlePtr( HepMC::FourVector( -2.45e+04,
+    vtx->add_particle_out( new HepMC::GenParticle( HLV_t( -2.45e+04,
 							  +1.88e+04,
 							  -8.65e+05,
 							  +8.65e+05 ),
@@ -575,18 +575,18 @@ public:
     
     HepMC::GenVertex * vtx = new HepMC::GenVertex;
     m_evt->add_vertex( vtx );
-    vtx->add_particle_in( HepMC::newGenParticlePtr( HepMC::FourVector( -6.76e+04,
+    vtx->add_particle_in( new HepMC::GenParticle( HLV_t( -6.76e+04,
 							 +4.85e+03,
 							 -1.46e+03,
 							 +9.51e+04 ),
 						  -24, 2 ) );
-    vtx->add_particle_out( HepMC::newGenParticlePtr( HepMC::FourVector( -7.14e+04,
+    vtx->add_particle_out( new HepMC::GenParticle( HLV_t( -7.14e+04,
 							  -6.17e+03,
 							  +1.67e+04,
 							  +7.36e+04 ),
 						   13, 1 ) );
     
-    vtx->add_particle_out( HepMC::newGenParticlePtr( HepMC::FourVector( +3.75e+03,
+    vtx->add_particle_out( new HepMC::GenParticle( HLV_t( +3.75e+03,
 							  +1.10e+04,
 							  -1.81e+04,
 							  +2.15e+04 ),
@@ -627,18 +627,18 @@ GenVertex:      -39 ID:    0 (X,cT):0
     // create a b->g+b vertex
     HepMC::GenVertex * vtxgb = new HepMC::GenVertex;
     m_evt->add_vertex( vtxgb );
-    vtxgb->add_particle_in( HepMC::newGenParticlePtr( HepMC::FourVector( -3.21e+04,
+    vtxgb->add_particle_in( new HepMC::GenParticle( HLV_t( -3.21e+04,
 							   -6.19e+03,
 							   +5.05e+04,
 							   +6.38e+04 ),
 						    -5, 2 ) );
-    vtxgb->add_particle_out( HepMC::newGenParticlePtr( HepMC::FourVector( -1.29e+04,
+    vtxgb->add_particle_out( new HepMC::GenParticle( HLV_t( -1.29e+04,
 							    +1.12e+03,
 							    +3.50e+04,
 							    +3.77e+04 ),
 						     -5, 2 ) );
     
-    vtxgb->add_particle_out( HepMC::newGenParticlePtr( HepMC::FourVector( -1.92e+04,
+    vtxgb->add_particle_out( new HepMC::GenParticle( HLV_t( -1.92e+04,
 							    -7.30e+03,
 							    +1.55e+04,
 							    +2.61e+04 ),
@@ -647,23 +647,23 @@ GenVertex:      -39 ID:    0 (X,cT):0
     // create a gg->b+bbar vertex
     HepMC::GenVertex * vtxbb = new HepMC::GenVertex;
     m_evt->add_vertex( vtxbb );
-    vtxbb->add_particle_in( HepMC::newGenParticlePtr( HepMC::FourVector( +1.23e+04,
+    vtxbb->add_particle_in( new HepMC::GenParticle( HLV_t( +1.23e+04,
 							   -4.79e+03,
 							   +6.52e+04,
 							   +6.65e+04 ),
 						    21, 3 ) );
-    vtxbb->add_particle_in( HepMC::newGenParticlePtr( HepMC::FourVector( +1.14e+02,
+    vtxbb->add_particle_in( new HepMC::GenParticle( HLV_t( +1.14e+02,
 							   +1.35e+04,
 							   -6.42e+04,
 							   +6.56e+04 ),
 						    21, 3 ) );
-    vtxbb->add_particle_out( HepMC::newGenParticlePtr( HepMC::FourVector( +4.56e+04,
+    vtxbb->add_particle_out( new HepMC::GenParticle( HLV_t( +4.56e+04,
 							    +1.53e+04,
 							    -5.08e+04,
 							    +7.01e+04 ),
 						     5, 3 ) );
     
-    vtxbb->add_particle_out( HepMC::newGenParticlePtr( HepMC::FourVector( -3.32e+04,
+    vtxbb->add_particle_out( new HepMC::GenParticle( HLV_t( -3.32e+04,
 							    -6.56e+03,
 							    +5.18e+04,
 							    +6.20e+04 ),
@@ -705,13 +705,13 @@ GenVertex:      -39 ID:    0 (X,cT):0
   {
     HepMC::GenVertex * vtx = new HepMC::GenVertex;
     m_evt->add_vertex( vtx );
-    vtx->add_particle_in( HepMC::newGenParticlePtr( HepMC::FourVector( -2.45e+04,
+    vtx->add_particle_in( new HepMC::GenParticle( HLV_t( -2.45e+04,
 							 +1.88e+04,
 							 -8.65e+05,
 							 +8.65e+05 ),
 						  23, 3 ) );
     HepMC::GenParticle * photon = 0;
-    photon = HepMC::newGenParticlePtr( HepMC::FourVector( -2.45e+04,
+    photon = new HepMC::GenParticle( HLV_t( -2.45e+04,
 					    +1.88e+04,
 					    -8.65e+05,
 					    +8.65e+05 ),
diff --git a/Projects/AnalysisBase/CMakeLists.txt b/Projects/AnalysisBase/CMakeLists.txt
index 47e147b4e7b3..90ed7b819398 100644
--- a/Projects/AnalysisBase/CMakeLists.txt
+++ b/Projects/AnalysisBase/CMakeLists.txt
@@ -14,12 +14,6 @@ unset( _version )
 # This project is built on top of AnalysisBaseExternals:
 find_package( AnalysisBaseExternals REQUIRED )
 
-
-add_definitions(-DHEPMC3)
-find_package( hepmc3 COMPONENTS HepMC HepMCsearch  HINTS /cvmfs/sft.cern.ch/lcg/releases/LCG_96b/hepmc3/3.1.2/x86_64-centos7-gcc8-opt/)
-SET(HEPMC3_USE TRUE)
-
-
 # Set up the build/runtime environment:
 set( AnalysisBaseReleaseEnvironment_DIR ${CMAKE_SOURCE_DIR}/cmake CACHE PATH
    "Path to AnalysisBaseReleaseEnvironmentConfig.cmake" )
diff --git a/Projects/AthGeneration/CMakeLists.txt b/Projects/AthGeneration/CMakeLists.txt
index 1f54267fd3c9..8a4a04ddf1ee 100644
--- a/Projects/AthGeneration/CMakeLists.txt
+++ b/Projects/AthGeneration/CMakeLists.txt
@@ -31,11 +31,6 @@ find_package( BLAS )
 find_package( AIDA )
 find_package( VDT )
 
-add_definitions(-DHEPMC3)
-find_package( hepmc3 COMPONENTS HepMC3 HepMC3search)
-MESSAGE(STATUS "${hepmc3_FOUND}   ${HEPMC3_HepMC3_LIBRARY}   ${HEPMC3_HepMC3search_LIBRARY}")
-SET(HEPMC3_USE TRUE)
-
 # Set the project into "GENERATIONBASE mode".
 set( GENERATIONBASE TRUE CACHE BOOL
    "Flag specifying that this is a generation release build" )
diff --git a/Projects/AthSimulation/CMakeLists.txt b/Projects/AthSimulation/CMakeLists.txt
index a9dc57d6acb7..d44b378aeeb5 100644
--- a/Projects/AthSimulation/CMakeLists.txt
+++ b/Projects/AthSimulation/CMakeLists.txt
@@ -28,17 +28,6 @@ find_package( PNG )
 find_package( VDT )
 find_package( TIFF )
 
-add_definitions(-DHEPMC3)
-set (hepmc3_DIR /cvmfs/sft.cern.ch/lcg/releases/LCG_97apython3_ATLAS_1/hepmc3/3.2.2/x86_64-centos7-gcc8-opt/)
-find_package( hepmc3 COMPONENTS HepMC3 HepMC3search HINTS /cvmfs/sft.cern.ch/lcg/releases/LCG_97apython3_ATLAS_1/hepmc3/3.2.2/x86_64-centos7-gcc8-opt/)
-#MESSAGE(STATUS "${hepmc3_FOUND}   ${HEPMC3_HepMC3_LIBRARY}   ${HEPMC3_HepMC3search_LIBRARY}")
-#SET(HEPMC3_USE TRUE)
-
-#add_definitions(-DHEPMC3)
-#find_package( hepmc3 COMPONENTS HepMC3 HepMC3search)
-MESSAGE(STATUS "${hepmc3_FOUND}   ${HEPMC3_HepMC3_LIBRARY}   ${HEPMC3_HepMC3search_LIBRARY}")
-SET(HEPMC3_USE TRUE)
-
 # Set the project into "SIMULATIONBASE mode".
 set( SIMULATIONBASE TRUE CACHE BOOL
    "Flag specifying that this is a simulation release build" )
diff --git a/Simulation/FastShower/FastCaloSim/src/FastShowerCellBuilderTool.cxx b/Simulation/FastShower/FastCaloSim/src/FastShowerCellBuilderTool.cxx
index 9dbb787129ce..488fdbeffb2a 100644
--- a/Simulation/FastShower/FastCaloSim/src/FastShowerCellBuilderTool.cxx
+++ b/Simulation/FastShower/FastCaloSim/src/FastShowerCellBuilderTool.cxx
@@ -2516,7 +2516,7 @@ std::vector<Trk::HitInfo>* FastShowerCellBuilderTool::caloHits(const HepMC::GenP
   // geantinos not handled by PdgToParticleHypothesis - fix there
   if ( pdgId == 999 ) pHypothesis = Trk::geantino;
 
-  HepMC::GenVertexPtr  vtx = part.production_vertex();
+  HepMC::GenVertex *vtx = part.production_vertex();
   Amg::Vector3D pos(0.,0.,0.);    // default
 
   if (vtx) {
diff --git a/Simulation/FastSimulation/FastChainPileup/src/MultiParticleGunPileup.cxx b/Simulation/FastSimulation/FastChainPileup/src/MultiParticleGunPileup.cxx
index 833e49bb3281..89dfb261ec48 100644
--- a/Simulation/FastSimulation/FastChainPileup/src/MultiParticleGunPileup.cxx
+++ b/Simulation/FastSimulation/FastChainPileup/src/MultiParticleGunPileup.cxx
@@ -122,11 +122,11 @@ StatusCode MultiParticleGunPileup::callGenerator() {
 	// Make particle-creation vertex
 	// TODO: do something cleverer than one vertex per particle?
 	HepMC::FourVector pos(p.m_pos.X(), p.m_pos.Y(), p.m_pos.Z(), p.m_pos.T());
-	HepMC::GenVertexPtr   gv = HepMC::newGenVertexPtr(pos);
+	HepMC::GenVertexPtr   gv = new HepMC::GenVertex(pos);
 	evt->add_vertex(gv);
 	// Make particle with status == 1
 	HepMC::FourVector mom(p.m_mom.Px(), p.m_mom.Py(), p.m_mom.Pz(), p.m_mom.E());
-	HepMC::GenParticlePtr   gp = HepMC::newGenParticlePtr();
+	HepMC::GenParticlePtr   gp = new HepMC::GenParticle;
 	gp->set_status(1);
 	gp->set_pdg_id(p.m_pid);
 	gp->set_momentum(mom);
diff --git a/Simulation/G4Sim/MCTruth/MCTruth/PrimaryParticleInformation.h b/Simulation/G4Sim/MCTruth/MCTruth/PrimaryParticleInformation.h
index 8ed5e26021ba..009e9e79883c 100644
--- a/Simulation/G4Sim/MCTruth/MCTruth/PrimaryParticleInformation.h
+++ b/Simulation/G4Sim/MCTruth/MCTruth/PrimaryParticleInformation.h
@@ -12,33 +12,9 @@
 namespace ISF {
   class ISFParticle;
 }
-#ifdef HEPMC3
-class PrimaryParticleInformation: public G4VUserPrimaryParticleInformation {
-public:
-	PrimaryParticleInformation();
-	PrimaryParticleInformation(const HepMC::GenParticlePtr , const ISF::ISFParticle* isp=0);
-	const HepMC::GenParticlePtr  GetHepMCParticle() const;
-	int GetParticleBarcode() const;
-	void SuggestBarcode(int bc);
-	void SetParticle(const HepMC::GenParticlePtr );
-	void Print() const {}
-	int GetRegenerationNr() {return  m_regenerationNr;}
-	void SetRegenerationNr(int i) {m_regenerationNr=i;}
-
-	void SetISFParticle(const ISF::ISFParticle* isp);
-	const ISF::ISFParticle* GetISFParticle() const;
-
-private:
-	HepMC::GenParticlePtr  m_theParticle;
-	const ISF::ISFParticle* m_theISFParticle;
 
-	int m_regenerationNr;
-	int m_barcode;
-};
-#else
 class PrimaryParticleInformation: public G4VUserPrimaryParticleInformation {
 public:
-
   PrimaryParticleInformation();
   PrimaryParticleInformation(HepMC::ConstGenParticlePtr, const ISF::ISFParticle* isp=0);
   HepMC::ConstGenParticlePtr GetHepMCParticle() const;
@@ -61,4 +37,3 @@ private:
 };
 
 #endif
-#endif
diff --git a/Simulation/G4Sim/MCTruth/MCTruth/TrackInformation.h b/Simulation/G4Sim/MCTruth/MCTruth/TrackInformation.h
index 605ba72426cb..6726589ae766 100644
--- a/Simulation/G4Sim/MCTruth/MCTruth/TrackInformation.h
+++ b/Simulation/G4Sim/MCTruth/MCTruth/TrackInformation.h
@@ -10,32 +10,10 @@
 namespace ISF {
   class ISFParticle;
 }
-#ifdef HEPMC3
-class TrackInformation: public VTrackInformation {
-public:
-	TrackInformation();
-	TrackInformation(const HepMC::GenParticlePtr ,const ISF::ISFParticle* baseIsp=0);
 
-	const HepMC::GenParticlePtr  GetHepMCParticle() const;
-	const ISF::ISFParticle *GetBaseISFParticle() const;
-	int GetParticleBarcode() const;
-	void SetParticle(const HepMC::GenParticlePtr );
-	void SetBaseISFParticle(const ISF::ISFParticle*);
-	void SetReturnedToISF(bool returned) {m_returnedToISF=returned;};
-	bool GetReturnedToISF() const {return m_returnedToISF;};
-	void SetRegenerationNr(int i) {m_regenerationNr=i;};
-	int GetRegenerationNr() const {return m_regenerationNr;};
-private:
-	int m_regenerationNr;
-	HepMC::GenParticlePtr  m_theParticle;
-	const ISF::ISFParticle *m_theBaseISFParticle;
-	bool m_returnedToISF;
-};
-#else
 class TrackInformation: public VTrackInformation {
 public:
 	TrackInformation();
-
 	TrackInformation(HepMC::ConstGenParticlePtr,const ISF::ISFParticle* baseIsp=0);
 	HepMC::ConstGenParticlePtr GetHepMCParticle() const;
 	const ISF::ISFParticle *GetBaseISFParticle() const;
@@ -52,6 +30,5 @@ private:
 	const ISF::ISFParticle *m_theBaseISFParticle;
 	bool m_returnedToISF;
 };
-#endif
 
 #endif
diff --git a/Simulation/G4Sim/MCTruth/MCTruth/VTrackInformation.h b/Simulation/G4Sim/MCTruth/MCTruth/VTrackInformation.h
index cf81ac2be777..57d2a9f0d088 100644
--- a/Simulation/G4Sim/MCTruth/MCTruth/VTrackInformation.h
+++ b/Simulation/G4Sim/MCTruth/MCTruth/VTrackInformation.h
@@ -15,55 +15,24 @@ namespace ISF {
   class ISFParticle;
 }
 
-#ifdef HEPMC3
 class VTrackInformation: public G4VUserTrackInformation {
 public:
-	VTrackInformation(TrackClassification tc=Primary);
-
-	const HepMC::GenParticlePtr  GetPrimaryHepMCParticle() const;
-	virtual const HepMC::GenParticlePtr  GetHepMCParticle() const;
-
-	void  SetPrimaryHepMCParticle(const HepMC::GenParticlePtr );
-	virtual const ISF::ISFParticle *GetBaseISFParticle() const;
-	virtual bool GetReturnedToISF() const;
-	virtual int  GetParticleBarcode() const =0;
-	virtual void SetParticle(const HepMC::GenParticlePtr );
-	virtual void SetBaseISFParticle(const ISF::ISFParticle*);
-	virtual void SetReturnedToISF(bool) ;
-	virtual void Print() const {}
-	void SetClassification(TrackClassification tc) {m_classify=tc;}
-	TrackClassification GetClassification() {return m_classify;}
-private:
-	TrackClassification m_classify;
-	HepMC::GenParticlePtr  m_thePrimaryParticle;
-};
-
-#else
-
-class VTrackInformation: public G4VUserTrackInformation {
-public:
-	VTrackInformation(TrackClassification tc=Primary);
-
-	const HepMC::GenParticle*  GetPrimaryHepMCParticle() const;
-	virtual const HepMC::GenParticle*  GetHepMCParticle() const;
-
-	void  SetPrimaryHepMCParticle(const HepMC::GenParticle* );
-	virtual const ISF::ISFParticle *GetBaseISFParticle() const;
-	virtual bool GetReturnedToISF() const;
-	virtual int  GetParticleBarcode() const =0;
-	virtual void SetParticle(const HepMC::GenParticle* );
-	virtual void SetBaseISFParticle(const ISF::ISFParticle*);
-	virtual void SetReturnedToISF(bool) ;
-	virtual void Print() const {}
-	void SetClassification(TrackClassification tc) {m_classify=tc;}
-	TrackClassification GetClassification() {return m_classify;}
+  VTrackInformation(TrackClassification tc=Primary);
+  HepMC::ConstGenParticlePtr GetPrimaryHepMCParticle() const;
+  void  SetPrimaryHepMCParticle(HepMC::ConstGenParticlePtr);
+  virtual HepMC::ConstGenParticlePtr GetHepMCParticle() const;
+  virtual const ISF::ISFParticle *GetBaseISFParticle() const;
+  virtual bool GetReturnedToISF() const;
+  virtual int  GetParticleBarcode() const =0;
+  virtual void SetParticle(HepMC::ConstGenParticlePtr);
+  virtual void SetBaseISFParticle(const ISF::ISFParticle*);
+  virtual void SetReturnedToISF(bool) ;
+  virtual void Print() const {}
+  void SetClassification(TrackClassification tc) {m_classify=tc;}
+  TrackClassification GetClassification() {return m_classify;}
 private:
-	TrackClassification m_classify;
-	const HepMC::GenParticle*  m_thePrimaryParticle;
+  TrackClassification m_classify;
+  HepMC::ConstGenParticlePtr m_thePrimaryParticle{};
 };
 
-
-#endif
-
-
 #endif
diff --git a/Simulation/G4Sim/MCTruth/src/PrimaryParticleInformation.cxx b/Simulation/G4Sim/MCTruth/src/PrimaryParticleInformation.cxx
index bbd4219c25a5..c4a1e311f2a6 100644
--- a/Simulation/G4Sim/MCTruth/src/PrimaryParticleInformation.cxx
+++ b/Simulation/G4Sim/MCTruth/src/PrimaryParticleInformation.cxx
@@ -4,63 +4,6 @@
 
 #include "MCTruth/PrimaryParticleInformation.h"
 
-
-#ifdef HEPMC3
-PrimaryParticleInformation::PrimaryParticleInformation() 
-  : m_theParticle(0),m_theISFParticle(0),m_regenerationNr(0),m_barcode(-1)
-{
-}
-
-PrimaryParticleInformation::PrimaryParticleInformation(const HepMC::GenParticlePtr  p, const ISF::ISFParticle* isp):m_theParticle(p),m_theISFParticle(isp),m_regenerationNr(0),m_barcode(-1)
-{
-}
-
-const HepMC::GenParticlePtr  PrimaryParticleInformation::GetHepMCParticle() const
-{
-	return m_theParticle;
-}
-
-const ISF::ISFParticle* PrimaryParticleInformation::GetISFParticle() const
-{
-	return m_theISFParticle;
-}
-
-void PrimaryParticleInformation::SuggestBarcode(int bc)
-{
-  m_barcode=bc;
-  if (m_theParticle) {
-    std::cout<<"ERROR: PrimaryParticleInformation::SuggestBarcode() should be only called if no HepMC::Particle is available"<<std::endl;
-    //theParticle->suggest_barcode(bc);
-  }
-}
-
-int PrimaryParticleInformation::GetParticleBarcode() const
-{
-	return m_theParticle?HepMC::barcode(m_theParticle):m_barcode;
-}
-
-void PrimaryParticleInformation::SetParticle(const HepMC::GenParticlePtr  p)
-{
-	m_theParticle=p;
-}
-
-void PrimaryParticleInformation::SetISFParticle(const ISF::ISFParticle* p)
-{
-	m_theISFParticle=p;
-}
-
-#else
-
-PrimaryParticleInformation::PrimaryParticleInformation() 
-  : m_theParticle(0),m_theISFParticle(0),m_regenerationNr(0),m_barcode(-1)
-{
-}
-
-PrimaryParticleInformation::PrimaryParticleInformation(const HepMC::GenParticle*  p, const ISF::ISFParticle* isp):m_theParticle(p),m_theISFParticle(isp),m_regenerationNr(0),m_barcode(-1)
-{
-}
-
-const HepMC::GenParticle*  PrimaryParticleInformation::GetHepMCParticle() const
 PrimaryParticleInformation::PrimaryParticleInformation()
 {
 }
@@ -101,4 +44,3 @@ void PrimaryParticleInformation::SetISFParticle(const ISF::ISFParticle* p)
 {
   m_theISFParticle=p;
 }
-#endif
diff --git a/Simulation/G4Sim/MCTruth/src/TrackInformation.cxx b/Simulation/G4Sim/MCTruth/src/TrackInformation.cxx
index d3b55a4667e7..fcaa59ba6541 100644
--- a/Simulation/G4Sim/MCTruth/src/TrackInformation.cxx
+++ b/Simulation/G4Sim/MCTruth/src/TrackInformation.cxx
@@ -5,48 +5,6 @@
 #include "MCTruth/TrackInformation.h"
 #include "AtlasHepMC/GenEvent.h"
 
-#ifdef HEPMC3
-
-TrackInformation::TrackInformation():m_regenerationNr(0),m_theParticle(0),m_theBaseISFParticle(0),m_returnedToISF(false)
-{
-}
-
-TrackInformation::TrackInformation(const HepMC::GenParticlePtr  p,const ISF::ISFParticle* baseIsp):
-    m_regenerationNr(0),
-    m_theParticle(p),
-    m_theBaseISFParticle(baseIsp),
-    m_returnedToISF(false)
-{
-}
-
-const HepMC::GenParticlePtr  TrackInformation::GetHepMCParticle() const
-{
-  return m_theParticle;
-}
-const ISF::ISFParticle* TrackInformation::GetBaseISFParticle() const
-{
-  return m_theBaseISFParticle;
-}
-
-int TrackInformation::GetParticleBarcode() const
-{
-  return ( m_theParticle ?HepMC::barcode( m_theParticle) : 0 );
-}
-
-void TrackInformation::SetParticle(const HepMC::GenParticlePtr  p)
-{
-  m_theParticle=p;
-}
-
-void TrackInformation::SetBaseISFParticle(const ISF::ISFParticle* p)
-{
-  m_theBaseISFParticle=p;
-}
-
-
-
-#else
-
 TrackInformation::TrackInformation():m_regenerationNr(0),m_theParticle(0),m_theBaseISFParticle(0),m_returnedToISF(false)
 {
 }
@@ -70,7 +28,7 @@ const ISF::ISFParticle* TrackInformation::GetBaseISFParticle() const
 
 int TrackInformation::GetParticleBarcode() const
 {
-  return ( m_theParticle ?m_theParticle->barcode() : 0 );
+  return ( m_theParticle ? m_theParticle->barcode() : 0 );
 }
 
 void TrackInformation::SetParticle(HepMC::ConstGenParticlePtr p)
@@ -82,4 +40,3 @@ void TrackInformation::SetBaseISFParticle(const ISF::ISFParticle* p)
 {
   m_theBaseISFParticle=p;
 }
-#endif
diff --git a/Simulation/G4Sim/MCTruth/src/VTrackInformation.cxx b/Simulation/G4Sim/MCTruth/src/VTrackInformation.cxx
index ed653142432a..022afaf4f887 100644
--- a/Simulation/G4Sim/MCTruth/src/VTrackInformation.cxx
+++ b/Simulation/G4Sim/MCTruth/src/VTrackInformation.cxx
@@ -8,50 +8,21 @@ VTrackInformation::VTrackInformation(TrackClassification tc):m_classify(tc)
 {
 }
 
-#ifdef HEPMC3
-
-void VTrackInformation::SetPrimaryHepMCParticle(const HepMC::GenParticlePtr  p)
-{
-  m_thePrimaryParticle=p;
-}
-const HepMC::GenParticlePtr  VTrackInformation::GetPrimaryHepMCParticle() const
+HepMC::ConstGenParticlePtr VTrackInformation::GetPrimaryHepMCParticle() const
 {
   return m_thePrimaryParticle;
 }
-{
-  return 0;
-}
-void VTrackInformation::SetParticle(const HepMC::GenParticlePtr  /*p*/)
-{
-  // you should not call this, perhaps throw an exception?
-  std::cerr<<"ERROR  VTrackInformation::SetParticle() not supported  "<<std::endl;
- 
-}
-
 
-
-#else
-
-void VTrackInformation::SetPrimaryHepMCParticle(const HepMC::GenParticle*  p)
+void VTrackInformation::SetPrimaryHepMCParticle(HepMC::ConstGenParticlePtr p)
 {
   m_thePrimaryParticle=p;
 }
-const HepMC::GenParticle*  VTrackInformation::GetPrimaryHepMCParticle() const
-{
-  return m_thePrimaryParticle;
-}
-const HepMC::GenParticle*  VTrackInformation::GetHepMCParticle() const
+
+
+HepMC::ConstGenParticlePtr VTrackInformation::GetHepMCParticle() const
 {
   return 0;
 }
-void VTrackInformation::SetParticle(const HepMC::GenParticle*  /*p*/)
-{
-  // you should not call this, perhaps throw an exception?
-  std::cerr<<"ERROR  VTrackInformation::SetParticle() not supported  "<<std::endl;
- 
-}
-#endif
-
 
 const ISF::ISFParticle* VTrackInformation::GetBaseISFParticle() const
 {
diff --git a/Simulation/G4Utilities/G4UserActions/src/AthenaTrackingAction.cxx b/Simulation/G4Utilities/G4UserActions/src/AthenaTrackingAction.cxx
index 2234189190bb..acc9cd35f9db 100644
--- a/Simulation/G4Utilities/G4UserActions/src/AthenaTrackingAction.cxx
+++ b/Simulation/G4Utilities/G4UserActions/src/AthenaTrackingAction.cxx
@@ -44,18 +44,11 @@ namespace G4UA
     // Condition for storing the GenParticle in the AtlasG4EventUserInfo for later.
     if (trackHelper.IsPrimary() || trackHelper.IsRegisteredSecondary())
     {
-
-#ifdef HEPMC3
-      HepMC::GenParticlePtr  part;
-
-#else
-
       // Why a const_cast???
       // This is an ugly way to communicate the GenParticle...
       HepMC::GenParticlePtr part =
         const_cast<HepMC::GenParticlePtr>( trackHelper.GetTrackInformation()->
                                          GetHepMCParticle() );
-#endif
 
       // Assign the GenParticle to the AtlasG4EventUserInfo.
       AtlasG4EventUserInfo* atlasG4EvtUserInfo = static_cast<AtlasG4EventUserInfo*>
diff --git a/Simulation/G4Utilities/MCTruthSimAlgs/src/MergeMcEventCollTool.cxx b/Simulation/G4Utilities/MCTruthSimAlgs/src/MergeMcEventCollTool.cxx
index e91a39b74fe6..262a6f240acf 100644
--- a/Simulation/G4Utilities/MCTruthSimAlgs/src/MergeMcEventCollTool.cxx
+++ b/Simulation/G4Utilities/MCTruthSimAlgs/src/MergeMcEventCollTool.cxx
@@ -449,7 +449,7 @@ StatusCode MergeMcEventCollTool::processUnfilteredEvent(const McEventCollection
   const HepMC::GenEvent& currentBackgroundEvent(**(pMcEvtColl->begin()));         //background event
   //handle the slimming case
   //ATH_MSG_VERBOSE( "The MB Event Number is " << currentBkgEventIndex << ". m_nBkgEventsReadSoFar = " << m_nBkgEventsReadSoFar );
-  HepMC::GenVertexPtr  pCopyOfGenVertex(NULL);
+  HepMC::GenVertex *pCopyOfGenVertex(NULL);
   if ( currentBackgroundEvent.signal_process_vertex() ) pCopyOfGenVertex = new HepMC::GenVertex ( *currentBackgroundEvent.signal_process_vertex() );
   //insert the GenEvent into the overlay McEventCollection.
   m_pOvrlMcEvColl->at(m_startingIndexForBackground+m_nBkgEventsReadSoFar) = new HepMC::GenEvent(currentBackgroundEvent.signal_process_id(), currentBkgEventIndex, pCopyOfGenVertex );
@@ -462,9 +462,9 @@ StatusCode MergeMcEventCollTool::processUnfilteredEvent(const McEventCollection
   ATH_MSG_VERBOSE( "Starting a vertex loop ... " );
   //cout << "Starting a vertex loop ... " <<endl;
   for (; currentVertexIter != endOfCurrentListOfVertices; ++currentVertexIter) {
-    const HepMC::GenVertexPtr  pCurrentVertex(*currentVertexIter);
-    HepMC::GenVertexPtr  pCopyOfVertexForClassification[NOPUTYPE];
-    for (int type(INTIME); type<NOPUTYPE; ++type) pCopyOfVertexForClassification[type]=(HepMC::GenVertexPtr )0;
+    const HepMC::GenVertex *pCurrentVertex(*currentVertexIter);
+    HepMC::GenVertex *pCopyOfVertexForClassification[NOPUTYPE];
+    for (int type(INTIME); type<NOPUTYPE; ++type) pCopyOfVertexForClassification[type]=(HepMC::GenVertex*)0;
 
     //check for collision vertices for in-time events
     bool isCollisionVertex(false);
@@ -480,8 +480,8 @@ StatusCode MergeMcEventCollTool::processUnfilteredEvent(const McEventCollection
     const HepMC::GenVertex::particles_out_const_iterator endOfListOfParticlesFromCurrentVertex(pCurrentVertex->particles_out_const_end());
     for (; currentVertexParticleIter != endOfListOfParticlesFromCurrentVertex; ++currentVertexParticleIter) {
       ATH_MSG_VERBOSE( "Found a particle at location " << std::hex << *currentVertexParticleIter << std::dec  << " with PDG ID = " << (*currentVertexParticleIter)->pdg_id() );
-      const HepMC::GenParticlePtr  pCurrentVertexParticle(*currentVertexParticleIter);
-      const HepMC::GenVertexPtr  pCurrentParticleProductionVertex(pCurrentVertexParticle->production_vertex());
+      const HepMC::GenParticle *pCurrentVertexParticle(*currentVertexParticleIter);
+      const HepMC::GenVertex *pCurrentParticleProductionVertex(pCurrentVertexParticle->production_vertex());
       puType particleClassification(classifyVertex(pCurrentVertexParticle, pCurrentParticleProductionVertex,currentEventTime));
       //hack to keep the complete vertex information for the interaction vertices of in-time background events
       if(isCollisionVertex && NOPUTYPE==particleClassification) {
@@ -525,11 +525,11 @@ StatusCode MergeMcEventCollTool::processUnfilteredEvent(const McEventCollection
   return StatusCode::SUCCESS;
 }
 
-bool MergeMcEventCollTool::isInitialCollisionVertex(const HepMC::GenVertexPtr  pCurrentVertex) const {
+bool MergeMcEventCollTool::isInitialCollisionVertex(const HepMC::GenVertex *pCurrentVertex) const {
   HepMC::GenVertex::particles_in_const_iterator currentVertexParticleIter(pCurrentVertex->particles_in_const_begin());
   const HepMC::GenVertex::particles_in_const_iterator endOfListOfParticlesFromCurrentVertex(pCurrentVertex->particles_in_const_end());
   while(currentVertexParticleIter != endOfListOfParticlesFromCurrentVertex) {
-    const HepMC::GenParticlePtr  pCurrentVertexParticle(*currentVertexParticleIter);
+    const HepMC::GenParticle *pCurrentVertexParticle(*currentVertexParticleIter);
     // FIXME: Nasty kludge will only work for Pythia minbias currently
     // Eventually just look for beam particles with status 4, but this
     // requires an update to the HepMC version used by ATLAS.
@@ -543,7 +543,7 @@ bool MergeMcEventCollTool::isInitialCollisionVertex(const HepMC::GenVertexPtr  p
   return false;
 }
 
-MergeMcEventCollTool::puType MergeMcEventCollTool::classifyVertex(const HepMC::GenParticlePtr  pCurrentVertexParticle, const HepMC::GenVertexPtr  pCurrentParticleProductionVertex, double currentEventTime) {
+MergeMcEventCollTool::puType MergeMcEventCollTool::classifyVertex(const HepMC::GenParticle *pCurrentVertexParticle, const HepMC::GenVertex *pCurrentParticleProductionVertex, double currentEventTime) {
   //=======================================================================
   //handle the slimming case
   //=======================================================================
diff --git a/Simulation/G4Utilities/MCTruthSimAlgs/src/MergeMcEventCollTool.h b/Simulation/G4Utilities/MCTruthSimAlgs/src/MergeMcEventCollTool.h
index 0fff5864e455..038b9aefa928 100755
--- a/Simulation/G4Utilities/MCTruthSimAlgs/src/MergeMcEventCollTool.h
+++ b/Simulation/G4Utilities/MCTruthSimAlgs/src/MergeMcEventCollTool.h
@@ -67,9 +67,9 @@ private:
   //** Ensure that any GenEvent::HeavyIon info is stored in the signal GenEvent.
   StatusCode saveHeavyIonInfo(const McEventCollection *pMcEvtColl);
   //** Classify the current GenParticle according to the MC Truth Taskforce requirements
-  MergeMcEventCollTool::puType classifyVertex(const HepMC::GenParticlePtr  pCurrentVertexParticle, const HepMC::GenVertexPtr  pCurrentParticleProductionVertex, double currentEventTime);
+  MergeMcEventCollTool::puType classifyVertex(const HepMC::GenParticle *pCurrentVertexParticle, const HepMC::GenVertex *pCurrentParticleProductionVertex, double currentEventTime);
   //** Check if the current GenVertex contains beam particles
-  bool isInitialCollisionVertex(const HepMC::GenVertexPtr  pCurrentVertex) const;
+  bool isInitialCollisionVertex(const HepMC::GenVertex *pCurrentVertex) const;
   //** Check whether the current McEventCollection has already been truth-filtered
   bool isTruthFiltertedMcEventCollection(const McEventCollection *pMcEvtColl) const;
   //** Map from GenEvent to puType FIXME: Simpler to key the map on GenEvent* ?
diff --git a/Simulation/ISF/ISF_Core/ISF_Event/ISF_Event/HepMCHelper.h b/Simulation/ISF/ISF_Core/ISF_Event/ISF_Event/HepMCHelper.h
index 8abebde1b18d..69ed5994ff62 100644
--- a/Simulation/ISF/ISF_Core/ISF_Event/ISF_Event/HepMCHelper.h
+++ b/Simulation/ISF/ISF_Core/ISF_Event/ISF_Event/HepMCHelper.h
@@ -51,16 +51,9 @@ namespace ISF {
           at least one particle with one of the given PDG codes appears.
           returns pointer to first found particle that matches any of the
           given PDG codes in relativesPDG */
-#ifdef HEPMC3
       static inline HepMC::ConstGenParticlePtr findRealtiveWithPDG( const HepMC::GenParticle &genParticle,
                                                                     const HepMC::IteratorRange &relation,
                                                                     const std::set<int> &relativesPDG     );
-
-#else
-      static inline const HepMC::GenParticlePtr   findRealtiveWithPDG( const HepMC::GenParticle &genParticle,
-                                                                    const HepMC::IteratorRange &relation,
-                                                                    const std::set<int> &relativesPDG     );
-#endif
   };
 
 }
diff --git a/Simulation/ISF/ISF_Core/ISF_Event/ISF_Event/HepMCHelper.icc b/Simulation/ISF/ISF_Core/ISF_Event/ISF_Event/HepMCHelper.icc
index 2c58f45ee715..ba477d1d70ce 100644
--- a/Simulation/ISF/ISF_Core/ISF_Event/ISF_Event/HepMCHelper.icc
+++ b/Simulation/ISF/ISF_Core/ISF_Event/ISF_Event/HepMCHelper.icc
@@ -12,9 +12,6 @@
 // @TODO: probably replace this by an enum some day
 #define ISF_UNDEF_CHARGE -99999.
 
-#include "AtlasHepMC/GenEvent.h"
-#include "AtlasHepMC/IteratorRange.h"
-
 /** constructor */
 ISF::HepMCHelper::HepMCHelper() {
 }
@@ -25,25 +22,12 @@ ISF::HepMCHelper::~HepMCHelper() {
 
 
 HepMC::IteratorRange ISF::HepMCHelper::convertIteratorRange( int intItRange ) {
-#ifdef HEPMC3
-return HepMC::IteratorRange();
-#else
   if      (intItRange==0) return ( HepMC::parents   );
   else if (intItRange==1) return ( HepMC::family    );
   else if (intItRange==2) return ( HepMC::ancestors );
   else if (intItRange==3) return ( HepMC::relatives );
   else                    return ( HepMC::parents   );
-#endif
-}
-
-#ifdef HEPMC3
-const HepMC::GenParticlePtr   ISF::HepMCHelper::findRealtiveWithPDG( const HepMC::GenParticlePtr &genParticle,
-                                                                  const HepMC::IteratorRange &relation,
-                                                                  const std::set<int> &relativesPDG     ) {
-
-return HepMC::GenParticlePtr();
 }
-#else
 
 HepMC::ConstGenParticlePtr ISF::HepMCHelper::findRealtiveWithPDG( const HepMC::GenParticle &genParticle,
                                                                   const HepMC::IteratorRange &relation,
@@ -66,4 +50,3 @@ HepMC::ConstGenParticlePtr ISF::HepMCHelper::findRealtiveWithPDG( const HepMC::G
   return (found ? curRelative : 0);
 }
 
-#endif
diff --git a/Simulation/ISF/ISF_Core/ISF_Event/ISF_Event/TruthBinding.icc b/Simulation/ISF/ISF_Core/ISF_Event/ISF_Event/TruthBinding.icc
index 04b87be7e795..91c73a6f98b9 100644
--- a/Simulation/ISF/ISF_Core/ISF_Event/ISF_Event/TruthBinding.icc
+++ b/Simulation/ISF/ISF_Core/ISF_Event/ISF_Event/TruthBinding.icc
@@ -56,9 +56,7 @@ namespace ISF {
   /** check equality */
   bool TruthBinding::isEqual(const TruthBinding& rhs) const {
     bool pass = true;
-#ifdef HEPMC3
 
-#else
     const auto rhsTruth = rhs.getTruthParticle();
     if (m_truthParticle && rhsTruth) {
       pass &= *m_truthParticle == *rhsTruth;
@@ -79,7 +77,6 @@ namespace ISF {
     } else {
       return false;
     }
-#endif
 
     return pass;
   }
diff --git a/Simulation/ISF/ISF_Core/ISF_Event/src/ISFTruthIncident.cxx b/Simulation/ISF/ISF_Core/ISF_Event/src/ISFTruthIncident.cxx
index 8c53a6c45c0a..4c8aa3f2b174 100644
--- a/Simulation/ISF/ISF_Core/ISF_Event/src/ISFTruthIncident.cxx
+++ b/Simulation/ISF/ISF_Core/ISF_Event/src/ISFTruthIncident.cxx
@@ -162,13 +162,7 @@ void ISF::ISFTruthIncident::setAllChildrenBarcodes(Barcode::ParticleBarcode bc)
 
 
 /** return attached truth particle */
-HepMC::GenParticlePtr  ISF::ISFTruthIncident::getHepMCTruthParticle( const ISF::ISFParticle& particle ) const {
-#ifdef HEPMC3
-
-return HepMC::GenParticlePtr();
-#else
-
-
+HepMC::GenParticlePtr ISF::ISFTruthIncident::getHepMCTruthParticle( const ISF::ISFParticle& particle ) const {
   auto* truthBinding     = particle.getTruthBinding();
   auto* hepTruthParticle = truthBinding ? truthBinding->getTruthParticle() : nullptr;
 
@@ -180,18 +174,12 @@ return HepMC::GenParticlePtr();
   }
 
   return hepTruthParticle;
-#endif
 }
 
 
 /** convert ISFParticle to GenParticle and attach to ISFParticle's TruthBinding */
-HepMC::GenParticlePtr  ISF::ISFTruthIncident::updateHepMCTruthParticle( ISF::ISFParticle& particle,
-
-                                                                     const ISF::ISFParticle* parent ) const {
-#ifdef HEPMC3
-
-return HepMC::GenParticlePtr();
-#else
+HepMC::GenParticlePtr ISF::ISFTruthIncident::updateHepMCTruthParticle( ISF::ISFParticle& particle,
+                                                                       const ISF::ISFParticle* parent ) const {
   auto* truthBinding     = particle.getTruthBinding();
   auto* hepTruthParticle = ParticleHelper::convert( particle );
 
@@ -217,5 +205,4 @@ return HepMC::GenParticlePtr();
   particle.setParticleLink(newHMPL);
 
   return hepTruthParticle;
-#endif
 }
diff --git a/Simulation/ISF/ISF_Core/ISF_Services/src/InputConverter.cxx b/Simulation/ISF/ISF_Core/ISF_Services/src/InputConverter.cxx
index 8bed8807fcba..d1a74c303ed2 100644
--- a/Simulation/ISF/ISF_Core/ISF_Services/src/InputConverter.cxx
+++ b/Simulation/ISF/ISF_Core/ISF_Services/src/InputConverter.cxx
@@ -142,7 +142,7 @@ ISF::InputConverter::convert(const McEventCollection& inputGenEvents,
     if (eventPtr == nullptr) { continue; }
 
     ATH_MSG_DEBUG("Starting conversion of GenEvent with"
-                  " signal_process_id=" << HepMC::signal_process_id(eventPtr) <<
+                  " signal_process_id=" << eventPtr->signal_process_id() <<
                   " and event_number=" << eventPtr->event_number() );
 
     // new collection containing all gen particles that passed filters
@@ -154,10 +154,7 @@ ISF::InputConverter::convert(const McEventCollection& inputGenEvents,
     const auto passedGenParticles = getSelectedParticles(*eventPtr, legacyOrdering);
 
     for ( auto& genPartPtr : passedGenParticles ) {
-#ifdef HEPMC3
-#else
       ATH_MSG_VERBOSE("Picking up following GenParticle for conversion to ISFParticle: " <<  *genPartPtr);
-#endif
       auto simParticlePtr = convertParticle(genPartPtr, kindOfCollection);
       if (!simParticlePtr) {
         ATH_MSG_ERROR("Error while trying to convert input generator particles. Aborting.");
@@ -192,13 +189,8 @@ StatusCode ISF::InputConverter::convertHepMCToG4Event(McEventCollection& inputGe
 /** get all generator particles which pass filters */
 std::vector<HepMC::GenParticlePtr>
 ISF::InputConverter::getSelectedParticles(const HepMC::GenEvent& evnt, bool legacyOrdering) const {
-#ifdef HEPMC3
-  auto allGenPartBegin = evnt.particles().begin();
-  auto allGenPartEnd = evnt.particles().end();
-#else
   auto allGenPartBegin = evnt.particles_begin();
   auto allGenPartEnd = evnt.particles_end();
-#endif
 
   // reserve destination container with maximum size, i.e. number of particles in input event
   std::vector<HepMC::GenParticlePtr> passedGenParticles{};
@@ -208,8 +200,6 @@ ISF::InputConverter::getSelectedParticles(const HepMC::GenEvent& evnt, bool lega
   if (legacyOrdering) {
     // FIXME: remove this block and the 'legacyOrdering' flag
     //        once we don't need the legacy order any longer
-#ifdef HEPMC3
-#else
     auto vtxIt = evnt.vertices_begin();
     auto vtxItEnd = evnt.vertices_end();
     for ( ; vtxIt != vtxItEnd; ++vtxIt ) {
@@ -219,16 +209,12 @@ ISF::InputConverter::getSelectedParticles(const HepMC::GenEvent& evnt, bool lega
                    std::back_inserter(passedGenParticles),
                    [this](HepMC::GenParticlePtr p){return this->passesFilters(*p);});
     }
-#endif
   }
   else {
-#ifdef HEPMC3
-#else
     std::copy_if(allGenPartBegin,
                  allGenPartEnd,
                  std::back_inserter(passedGenParticles),
-                 [this](HepMC::GenParticlePtr  p){return this->passesFilters(*p);});
-#endif
+                 [this](HepMC::GenParticlePtr p){return this->passesFilters(*p);});
   }
 
   passedGenParticles.shrink_to_fit();
@@ -249,11 +235,8 @@ ISF::InputConverter::convertParticle(HepMC::GenParticlePtr genPartPtr, EBC_EVCOL
 
   HepMC::GenVertexPtr  pVertex = genPart.production_vertex();
   if (!pVertex) {
-#ifdef HEPMC3
-#else
     ATH_MSG_ERROR("Unable to convert following generator particle due to missing "
                   << "production vertex: " << genPart);
-#endif
     return nullptr;
   }
 
@@ -261,11 +244,7 @@ ISF::InputConverter::convertParticle(HepMC::GenParticlePtr genPartPtr, EBC_EVCOL
   const Amg::Vector3D pos(pVertex->position().x(), pVertex->position().y(), pVertex->position().z());
   const auto& pMomentum(genPart.momentum());
   const Amg::Vector3D mom(pMomentum.px(), pMomentum.py(), pMomentum.pz());
-#ifdef HEPMC3
-const double pMass =0;
-#else
   const double pMass = this->getParticleMass(genPart);
-#endif
 
   double e=pMomentum.e();
   if(e>1) { //only test for >1 MeV in momentum
@@ -283,7 +262,7 @@ const double pMass =0;
   const double pTime = pVertex->position().t() / Gaudi::Units::c_light;
   /// particle origin (TODO: add proper GeoID, collision/cosmics)
   DetRegionSvcIDPair origin(AtlasDetDescr::fUndefinedAtlasRegion, ISF::fEventGeneratorSimID);
-  const auto pBarcode = HepMC::barcode(genPart);
+  const auto pBarcode = genPart.barcode();
   auto tBinding = std::make_unique<ISF::TruthBinding>(genPartPtr);
 
   auto *parentEvent = genPart.parent_event();
@@ -291,9 +270,6 @@ const double pMass =0;
     ATH_MSG_ERROR("Cannot convert a GenParticle without a parent GenEvent into an ISFParticle!!!");
     return nullptr;
   }
-#ifdef HEPMC3
-  return nullptr;
-#else
   auto hmpl = std::make_unique<HepMcParticleLink>(&genPart, parentEvent->event_number(), kindOfCollection);
   auto sParticle = std::make_unique<ISF::ISFParticle>( std::move(pos),
                                                        std::move(mom),
@@ -307,21 +283,13 @@ const double pMass =0;
                                                        tBinding.release(),
                                                        hmpl.release() );
   return sParticle.release();
-#endif
 }
 
 
 /** get right GenParticle mass */
-#ifdef HEPMC3
 double
-ISF::InputConverter::getParticleMass(const HepMC::GenParticlePtr part) const{
-
-
-return 0;
-}
-#else
-double
-ISF::InputConverter::getParticleMass(const HepMC::GenParticle &part) const{
+ISF::InputConverter::getParticleMass(const HepMC::GenParticle &part) const
+{
   // default value: generated particle mass
   double mass = part.generated_mass();
   ATH_MSG_VERBOSE("part.generated_mass, mass="<<mass);
@@ -342,18 +310,9 @@ ISF::InputConverter::getParticleMass(const HepMC::GenParticle &part) const{
   }
   return mass;
 }
-#endif
 
 
 /** check if the given particle passes all filters */
-#ifdef HEPMC3
-bool
-ISF::InputConverter::passesFilters(const HepMC::GenParticlePtr part) const
-{
-	
-return true;	
-}	
-#else
 bool
 ISF::InputConverter::passesFilters(const HepMC::GenParticle& part) const
 {
@@ -378,7 +337,6 @@ ISF::InputConverter::passesFilters(const HepMC::GenParticle& part) const
 
   return true;
 }
-#endif
 
 
 //________________________________________________________________________
@@ -439,13 +397,8 @@ const G4ParticleDefinition* ISF::InputConverter::getG4ParticleDefinition(int pdg
 }
 
 //________________________________________________________________________
-#ifdef HEPMC3
-G4PrimaryParticle* ISF::InputConverter::getG4PrimaryParticle(const HepMC::GenParticlePtr genpart) const{
-
-return nullptr;
-}
-#else
-G4PrimaryParticle* ISF::InputConverter::getG4PrimaryParticle(const HepMC::GenParticle& genpart) const{
+G4PrimaryParticle* ISF::InputConverter::getG4PrimaryParticle(const HepMC::GenParticle& genpart) const
+{
   ATH_MSG_VERBOSE("Creating G4PrimaryParticle from GenParticle.");
 
   const G4ParticleDefinition *particleDefinition = this->getG4ParticleDefinition(genpart.pdg_id());
@@ -480,35 +433,26 @@ G4PrimaryParticle* ISF::InputConverter::getG4PrimaryParticle(const HepMC::GenPar
       ATH_MSG_VERBOSE( "Detected primary particle with end vertex." );
       ATH_MSG_VERBOSE( "Will add the primary particle set on." );
       ATH_MSG_VERBOSE( "Primary Particle: " << genpart );
-#ifdef HEPMC3
-
-#else
       ATH_MSG_VERBOSE( "Number of daughters of "<<genpart.barcode()<<": " << genpart.end_vertex()->particles_out_size() );
-#endif
     }
     else {
       ATH_MSG_WARNING( "Detected primary particle with end vertex." );
       ATH_MSG_WARNING( "Will add the primary particle set on." );
       ATH_MSG_WARNING( "Primary Particle: " << genpart );
-#ifdef HEPMC3
-
-#else
-
       ATH_MSG_WARNING( "Number of daughters of "<<genpart.barcode()<<": " << genpart.end_vertex()->particles_out_size() );
-#endif
     }
     // Add all necessary daughter particles
     for ( auto daughterIter=genpart.end_vertex()->particles_out_const_begin();
           daughterIter!=genpart.end_vertex()->particles_out_const_end(); ++daughterIter ) {
       if(m_quasiStableParticlesIncluded) {
-        ATH_MSG_VERBOSE ( "Attempting to add daughter particle of "<<HepMC::barcode(genpart)<<": " << **daughterIter );
+        ATH_MSG_VERBOSE ( "Attempting to add daughter particle of "<<genpart.barcode()<<": " << **daughterIter );
       }
       else {
-        ATH_MSG_WARNING ( "Attempting to add daughter particle of "<<HepMC::barcode(genpart)<<": " << **daughterIter );
+        ATH_MSG_WARNING ( "Attempting to add daughter particle of "<<genpart.barcode()<<": " << **daughterIter );
       }
       G4PrimaryParticle *daughterG4Particle = this->getG4PrimaryParticle( **daughterIter );
       if(!daughterG4Particle) {
-        ATH_MSG_ERROR("Bailing out of loop over daughters of particle with barcode: "<<HepMC::barcode(genpart) <<
+        ATH_MSG_ERROR("Bailing out of loop over daughters of particle with barcode: "<<genpart.barcode() <<
                       " due to errors - will not return G4Particle.");
         return nullptr;
       }
@@ -525,7 +469,6 @@ G4PrimaryParticle* ISF::InputConverter::getG4PrimaryParticle(const HepMC::GenPar
 
   return g4particle.release();
 }
-#endif
 
 
 //________________________________________________________________________
@@ -597,11 +540,8 @@ G4PrimaryParticle* ISF::InputConverter::getG4PrimaryParticle(const ISF::ISFParti
         ATH_MSG_VERBOSE( "Detected primary particle with end vertex." );
         ATH_MSG_VERBOSE( "Will add the primary particle set on." );
         ATH_MSG_VERBOSE( "ISF Particle: " << isp );
-#ifdef HEPMC3
-#else
         ATH_MSG_VERBOSE( "Primary Particle: " << *genpart );
         ATH_MSG_VERBOSE( "Number of daughters of "<<genpart->barcode()<<": " << genpart->end_vertex()->particles_out_size() );
-#endif
       }
       else {
         ATH_MSG_WARNING( "Detected primary particle with end vertex. This should only be the case if" );
@@ -609,32 +549,26 @@ G4PrimaryParticle* ISF::InputConverter::getG4PrimaryParticle(const ISF::ISFParti
         ATH_MSG_WARNING( "yet validated - you'd better know what you're doing.  Will add the primary" );
         ATH_MSG_WARNING( "particle set on." );
         ATH_MSG_WARNING( "ISF Particle: " << isp );
-#ifdef HEPMC3
-#else
         ATH_MSG_WARNING( "Primary Particle: " << *genpart );
-        ATH_MSG_WARNING( "Number of daughters of "<<HepMC::barcode(genpart)<<": " << genpart->end_vertex()->particles_out_size() );
-#endif
+        ATH_MSG_WARNING( "Number of daughters of "<<genpart->barcode()<<": " << genpart->end_vertex()->particles_out_size() );
       }
       // Add all necessary daughter particles
-#ifdef HEPMC3
-#else
       for ( auto daughterIter=genpart->end_vertex()->particles_out_const_begin();
             daughterIter!=genpart->end_vertex()->particles_out_const_end(); ++daughterIter ) {
         if(m_quasiStableParticlesIncluded) {
-          ATH_MSG_VERBOSE ( "Attempting to add daughter particle of "<<HepMC::barcode(genpart)<<": " << **daughterIter );
+          ATH_MSG_VERBOSE ( "Attempting to add daughter particle of "<<genpart->barcode()<<": " << **daughterIter );
         }
         else {
-          ATH_MSG_WARNING ( "Attempting to add daughter particle of "<<HepMC::barcode(genpart)<<": " << **daughterIter );
+          ATH_MSG_WARNING ( "Attempting to add daughter particle of "<<genpart->barcode()<<": " << **daughterIter );
         }
         G4PrimaryParticle *daughterG4Particle = this->getG4PrimaryParticle( **daughterIter );
         if(!daughterG4Particle) {
-          ATH_MSG_ERROR("Bailing out of loop over daughters of particle with barcode: "<<HepMC::barcode(genpart) <<
+          ATH_MSG_ERROR("Bailing out of loop over daughters of particle with barcode: "<<genpart->barcode() <<
                         " due to errors - will not return G4Particle.");
           return nullptr;
         }
         g4particle->SetDaughter( daughterG4Particle );
       }
-#endif     
     } // particle had an end vertex
     
     double px,py,pz;
diff --git a/Simulation/ISF/ISF_Core/ISF_Services/src/InputConverter.h b/Simulation/ISF/ISF_Core/ISF_Services/src/InputConverter.h
index 4a440c1eccf2..562aa431070c 100644
--- a/Simulation/ISF/ISF_Core/ISF_Services/src/InputConverter.h
+++ b/Simulation/ISF/ISF_Core/ISF_Services/src/InputConverter.h
@@ -83,11 +83,7 @@ namespace ISF {
 
     const G4ParticleDefinition* getG4ParticleDefinition(int pdgcode) const;
 
-#ifdef HEPMC3
-    G4PrimaryParticle* getG4PrimaryParticle(const HepMC::GenParticlePtr gp) const;
-#else
     G4PrimaryParticle* getG4PrimaryParticle(const HepMC::GenParticle& gp) const;
-#endif
 
     G4PrimaryParticle* getG4PrimaryParticle(const ISF::ISFParticle& isp, bool useHepMC) const;
 
@@ -97,21 +93,13 @@ namespace ISF {
     bool isInsideG4WorldVolume(const ISF::ISFParticle& isp, const G4VSolid* worldSolid) const;
 
     /** get right GenParticle mass */
-#ifdef HEPMC3
-    double getParticleMass(const HepMC::GenParticlePtr p) const;
-#else
     double getParticleMass(const HepMC::GenParticle& p) const;
-#endif
 
     /** get all generator particles which pass filters */
     std::vector<HepMC::GenParticlePtr > getSelectedParticles(const HepMC::GenEvent& evnt, bool legacyOrdering=false) const;
 
     /** check if the given particle passes all filters */
-#ifdef HEPMC3
-    bool passesFilters(const HepMC::GenParticlePtr p) const;
-#else
     bool passesFilters(const HepMC::GenParticle& p) const;
-#endif
 
     /** convert GenParticle to ISFParticle */
     ISF::ISFParticle* convertParticle(HepMC::GenParticlePtr genPartPtr, EBC_EVCOLL kindOfCollection=EBC_MAINEVCOLL) const;
diff --git a/Simulation/ISF/ISF_Core/ISF_Services/src/TruthSvc.cxx b/Simulation/ISF/ISF_Core/ISF_Services/src/TruthSvc.cxx
index 40d043be59f2..5ae0ceca71c4 100644
--- a/Simulation/ISF/ISF_Core/ISF_Services/src/TruthSvc.cxx
+++ b/Simulation/ISF/ISF_Core/ISF_Services/src/TruthSvc.cxx
@@ -132,21 +132,18 @@ StatusCode ISF::TruthSvc::initializeTruthCollection()
 }
 
 /** Delete child vertex */
-void ISF::TruthSvc::deleteChildVertex(HepMC::GenVertexPtr  vertex) const {
-  std::vector<HepMC::GenVertexPtr > verticesToDelete;
+void ISF::TruthSvc::deleteChildVertex(HepMC::GenVertexPtr vertex) const {
+  std::vector<HepMC::GenVertexPtr> verticesToDelete;
   verticesToDelete.resize(0);
   verticesToDelete.push_back(vertex);
   for ( unsigned short i = 0; i<verticesToDelete.size(); ++i ) {
-    HepMC::GenVertexPtr  vtx = verticesToDelete.at(i);
-#ifdef HEPMC3
-#else
+    HepMC::GenVertexPtr vtx = verticesToDelete.at(i);
     for (HepMC::GenVertex::particles_out_const_iterator iter = vtx->particles_out_const_begin();
          iter != vtx->particles_out_const_end(); ++iter) {
       if( (*iter) && (*iter)->end_vertex() ) {
         verticesToDelete.push_back( (*iter)->end_vertex() );
       }
     }
-#endif
     vtx->parent_event()->remove_vertex(vtx);
   }
   return;
@@ -280,8 +277,6 @@ void ISF::TruthSvc::recordIncidentToMCTruth( ISF::ITruthIncident& ti) const {
   HepMC::GenParticlePtr  parentBeforeIncident = ti.parentParticle();
   HepMC::GenParticlePtr  parentAfterIncident = ti.parentParticleAfterIncident( newPrimBC ); // This call changes ti.parentParticle() output
   if(parentAfterIncident) {
-#ifdef HEPMC3
-#else
     ATH_MSG_VERBOSE ( "Parent After Incident: " << *parentAfterIncident);
     if (classification==ISF::QS_SURV_VTX) {
       // Special case when a particle with a pre-defined decay
@@ -317,7 +312,6 @@ void ISF::TruthSvc::recordIncidentToMCTruth( ISF::ITruthIncident& ti) const {
     else {
       vtx->add_particle_out( parentAfterIncident );
     }
-#endif
   }
 
   const bool isQuasiStableVertex = (classification == ISF::QS_PREDEF_VTX); // QS_DEST_VTX and QS_SURV_VTX should be treated as normal from now on.
@@ -329,8 +323,6 @@ void ISF::TruthSvc::recordIncidentToMCTruth( ISF::ITruthIncident& ti) const {
     // FIXME should probably make this part a separate function and
     // also check if the pdgids of the child particles are the same
     // too.
-#ifdef HEPMC3
-#else
     unsigned short nVertexChildren=vtx->particles_out_size();
     if(parentAfterIncident) { nVertexChildren-=1; }
     if(nVertexChildren!=numSec) {
@@ -339,12 +331,7 @@ void ISF::TruthSvc::recordIncidentToMCTruth( ISF::ITruthIncident& ti) const {
     }
     ATH_MSG_VERBOSE("Existing vertex has " << nVertexChildren << " children. " <<
                  "Number of secondaries in current truth incident = " << numSec);
-#endif
   }
-
-#ifdef HEPMC3
-
-#else
   const std::vector<HepMC::GenParticlePtr> childParticleVector = (isQuasiStableVertex) ? MC::findChildren(ti.parentParticle()) : std::vector<HepMC::GenParticlePtr>();
   std::vector<HepMC::GenParticlePtr> matchedChildParticles;
   for ( unsigned short i=0; i<numSec; ++i) {
@@ -402,7 +389,6 @@ void ISF::TruthSvc::recordIncidentToMCTruth( ISF::ITruthIncident& ti) const {
     }
 
   } // <-- loop over all child particles
-#endif
   ATH_MSG_VERBOSE("--------------------------------------------------------");
 }
 
@@ -443,14 +429,8 @@ HepMC::GenVertexPtr  ISF::TruthSvc::createGenVertexFromTruthIncident( ISF::ITrut
     }
   }
   int vtxID = 1000 + static_cast<int>(processCode);
-#ifdef HEPMC3
-  HepMC::GenVertexPtr vtx;
-#else
   std::unique_ptr<HepMC::GenVertex> vtx = std::make_unique<HepMC::GenVertex>( ti.position(), vtxID, weights );
-#endif
   HepMC::suggest_barcode( vtx.get(), vtxbcode );
-#ifdef HEPMC3
-#else
 
   if (parent->end_vertex()){
     if(!m_quasiStableParticlesIncluded) {
@@ -496,7 +476,6 @@ HepMC::GenVertexPtr  ISF::TruthSvc::createGenVertexFromTruthIncident( ISF::ITrut
 #endif
     mcEvent->add_vertex( vtx.release() );
   }
-#endif
 
   return parent->end_vertex();
 }
@@ -521,9 +500,6 @@ void ISF::TruthSvc::setSharedChildParticleBarcode( ISF::ITruthIncident& ti) cons
 int ISF::TruthSvc::maxGeneratedParticleBarcode(HepMC::GenEvent *genEvent) const {
   int maxBarcode=0;
   const int firstSecondaryParticleBarcode(m_barcodeSvc->secondaryParticleBcOffset());
-#ifdef HEPMC3
-
-#else
   HepMC::GenEvent::particle_const_iterator currentGenParticleIter;
   for (currentGenParticleIter= genEvent->particles_begin();
        currentGenParticleIter!= genEvent->particles_end();
@@ -531,15 +507,11 @@ int ISF::TruthSvc::maxGeneratedParticleBarcode(HepMC::GenEvent *genEvent) const
     const int barcode((*currentGenParticleIter)->barcode());
     if(barcode > maxBarcode && barcode < firstSecondaryParticleBarcode) { maxBarcode=barcode; }
   }
-#endif
   return maxBarcode;
 }
 
 int ISF::TruthSvc::maxGeneratedVertexBarcode(HepMC::GenEvent *genEvent) const {
   int maxBarcode=0;
-#ifdef HEPMC3
-
-#else
   const int firstSecondaryVertexBarcode(m_barcodeSvc->secondaryVertexBcOffset());
   HepMC::GenEvent::vertex_const_iterator currentGenVertexIter;
   for (currentGenVertexIter= genEvent->vertices_begin();
@@ -548,6 +520,5 @@ int ISF::TruthSvc::maxGeneratedVertexBarcode(HepMC::GenEvent *genEvent) const {
     const int barcode((*currentGenVertexIter)->barcode());
     if(barcode < maxBarcode && barcode > firstSecondaryVertexBarcode) { maxBarcode=barcode; }
   }
-#endif
   return maxBarcode;
 }
diff --git a/Simulation/ISF/ISF_Core/ISF_Services/test/InputConverter_test.cxx b/Simulation/ISF/ISF_Core/ISF_Services/test/InputConverter_test.cxx
index 17813c67825b..ea5c25131f40 100644
--- a/Simulation/ISF/ISF_Core/ISF_Services/test/InputConverter_test.cxx
+++ b/Simulation/ISF/ISF_Core/ISF_Services/test/InputConverter_test.cxx
@@ -159,7 +159,7 @@ TEST_F(InputConverter_test, convertParticle_nullptr) {
 
 TEST_F(InputConverter_test, convertParticle_without_production_vertex) {
   HepMC::FourVector mom(12.3, 45.6, 78.9, 0.12);
-  HepMC::GenParticlePtr  genPart = HepMC::newGenParticlePtr(mom,
+  HepMC::GenParticlePtr  genPart = new HepMC::GenParticle(mom,
                                                        123, // pdg
                                                        1 // status
                                                       );
@@ -232,7 +232,7 @@ TEST_F(InputConverter_test, convertParticle_using_particleDataTable_photon) {
   HepMC::FourVector mom(12.3, 45.6, 78.9, 0.12);
   // dynamic allocation necessary as particle ownership is
   // handed over to a HepMC::GenVertex later
-  HepMC::GenParticlePtr  genPart = HepMC::newGenParticlePtr(mom,
+  HepMC::GenParticlePtr  genPart = new HepMC::GenParticle(mom,
                                                        22, // pdg id (gamma)
                                                        1 // status
                                                       );
@@ -241,7 +241,7 @@ TEST_F(InputConverter_test, convertParticle_using_particleDataTable_photon) {
 
   HepMC::FourVector pos(9.8, 7.65, 4.3, 0.321); // NB: 4th component is time*c
   int vtx_id = -123;
-  HepMC::GenVertexPtr  prodVtx = HepMC::newGenVertexPtr(pos, vtx_id);
+  HepMC::GenVertexPtr  prodVtx = new HepMC::GenVertex(pos, vtx_id);
   prodVtx->add_particle_out(genPart);
 
   // create dummy input McEventCollection containing a dummy GenEvent
@@ -286,7 +286,7 @@ TEST_F(InputConverter_test, convertParticle_using_particleDataTable_electron) {
   HepMC::FourVector mom(12.3, 45.6, 78.9, 0.12);
   // dynamic allocation necessary as particle ownership is
   // handed over to a HepMC::GenVertex later
-  HepMC::GenParticlePtr  genPart = HepMC::newGenParticlePtr(mom,
+  HepMC::GenParticlePtr  genPart = new HepMC::GenParticle(mom,
                                                        11, // pdg id (e-)
                                                        1 // status
                                                       );
@@ -295,7 +295,7 @@ TEST_F(InputConverter_test, convertParticle_using_particleDataTable_electron) {
 
   HepMC::FourVector pos(9.8, 7.65, 4.3, 0.321); // NB: 4th component is time*c
   int vtx_id = -123;
-  HepMC::GenVertexPtr  prodVtx = HepMC::newGenVertexPtr(pos, vtx_id);
+  HepMC::GenVertexPtr  prodVtx = new HepMC::GenVertex(pos, vtx_id);
   prodVtx->add_particle_out(genPart);
 
   // create dummy input McEventCollection containing a dummy GenEvent
diff --git a/Simulation/ISF/ISF_Core/ISF_Services/test/TruthSvc_test.cxx b/Simulation/ISF/ISF_Core/ISF_Services/test/TruthSvc_test.cxx
index 67ad9d4a331e..7f998b5bfbf9 100644
--- a/Simulation/ISF/ISF_Core/ISF_Services/test/TruthSvc_test.cxx
+++ b/Simulation/ISF/ISF_Core/ISF_Services/test/TruthSvc_test.cxx
@@ -274,18 +274,18 @@ namespace ISFTesting {
     const int pdgid2(13);
     std::unique_ptr<HepMC::GenEvent> anEvent = std::make_unique<HepMC::GenEvent>(process_id1, event_number1);
     const CLHEP::HepLorentzVector myPos( 0.0, 0.0, 0.0, 0.0);
-    HepMC::GenVertexPtr  myVertex = HepMC::newGenVertexPtr( myPos, -1 );
+    HepMC::GenVertexPtr  myVertex = new HepMC::GenVertex( myPos, -1 );
     const HepMC::FourVector fourMomentum1( 0.0, 0.0, 1.0, 1.0*CLHEP::TeV);
-    HepMC::GenParticlePtr  inParticle1 = HepMC::newGenParticlePtr(fourMomentum1, pdgid1, 2);
+    HepMC::GenParticlePtr  inParticle1 = new HepMC::GenParticle(fourMomentum1, pdgid1, 2);
     myVertex->add_particle_in(inParticle1);
     const HepMC::FourVector fourMomentum2( 0.0, 0.0, -1.0, 1.0*CLHEP::TeV);
-    HepMC::GenParticlePtr  inParticle2 = HepMC::newGenParticlePtr(fourMomentum2, pdgid2, 2);
+    HepMC::GenParticlePtr  inParticle2 = new HepMC::GenParticle(fourMomentum2, pdgid2, 2);
     myVertex->add_particle_in(inParticle2);
     const HepMC::FourVector fourMomentum3( 0.0, 1.0, 0.0, 1.0*CLHEP::TeV);
-    HepMC::GenParticlePtr  inParticle3 = HepMC::newGenParticlePtr(fourMomentum3, pdgid1, 1);
+    HepMC::GenParticlePtr  inParticle3 = new HepMC::GenParticle(fourMomentum3, pdgid1, 1);
     myVertex->add_particle_out(inParticle3);
     const HepMC::FourVector fourMomentum4( 0.0, -1.0, 0.0, 1.0*CLHEP::TeV);
-    HepMC::GenParticlePtr  inParticle4 = HepMC::newGenParticlePtr(fourMomentum4, pdgid2, 1);
+    HepMC::GenParticlePtr  inParticle4 = new HepMC::GenParticle(fourMomentum4, pdgid2, 1);
     myVertex->add_particle_out(inParticle4);
     anEvent->add_vertex( myVertex );
     anEvent->set_signal_process_vertex( myVertex );
@@ -322,18 +322,18 @@ namespace ISFTesting {
     const int pdgid2(13);
     std::unique_ptr<HepMC::GenEvent> anEvent = std::make_unique<HepMC::GenEvent>(process_id1, event_number1);
     const CLHEP::HepLorentzVector myPos( 0.0, 0.0, 0.0, 0.0);
-    HepMC::GenVertexPtr  myVertex = HepMC::newGenVertexPtr( myPos, -1 );
+    HepMC::GenVertexPtr  myVertex = new HepMC::GenVertex( myPos, -1 );
     const HepMC::FourVector fourMomentum1( 0.0, 0.0, 1.0, 1.0*CLHEP::TeV);
-    HepMC::GenParticlePtr  inParticle1 = HepMC::newGenParticlePtr(fourMomentum1, pdgid1, 2);
+    HepMC::GenParticlePtr  inParticle1 = new HepMC::GenParticle(fourMomentum1, pdgid1, 2);
     myVertex->add_particle_in(inParticle1);
     const HepMC::FourVector fourMomentum2( 0.0, 0.0, -1.0, 1.0*CLHEP::TeV);
-    HepMC::GenParticlePtr  inParticle2 = HepMC::newGenParticlePtr(fourMomentum2, pdgid2, 2);
+    HepMC::GenParticlePtr  inParticle2 = new HepMC::GenParticle(fourMomentum2, pdgid2, 2);
     myVertex->add_particle_in(inParticle2);
     const HepMC::FourVector fourMomentum3( 0.0, 1.0, 0.0, 1.0*CLHEP::TeV);
-    HepMC::GenParticlePtr  inParticle3 = HepMC::newGenParticlePtr(fourMomentum3, pdgid1, 1);
+    HepMC::GenParticlePtr  inParticle3 = new HepMC::GenParticle(fourMomentum3, pdgid1, 1);
     myVertex->add_particle_out(inParticle3);
     const HepMC::FourVector fourMomentum4( 0.0, -1.0, 0.0, 1.0*CLHEP::TeV);
-    HepMC::GenParticlePtr  inParticle4 = HepMC::newGenParticlePtr(fourMomentum4, pdgid2, 1);
+    HepMC::GenParticlePtr  inParticle4 = new HepMC::GenParticle(fourMomentum4, pdgid2, 1);
     myVertex->add_particle_out(inParticle4);
     anEvent->add_vertex( myVertex );
     anEvent->set_signal_process_vertex( myVertex );
@@ -358,7 +358,7 @@ namespace ISFTesting {
       .WillOnce(::testing::Return(nullptr));
 
     recordIncidentToMCTruth(ti);
-    HepMC::GenVertexPtr  generated = HepMC::barcode_to_vertex(anEvent,-200001); //Find a nicer way to get this.
+    HepMC::GenVertexPtr  generated = anEvent->barcode_to_vertex(-200001); //Find a nicer way to get this.
     ASSERT_EQ( vtxPosition, generated->position() );
     ASSERT_EQ( 1021, generated->id() );
     ASSERT_EQ( -200001, generated->barcode() ); // by construction at the moment
@@ -377,18 +377,18 @@ namespace ISFTesting {
     const int pdgid2(13);
     std::unique_ptr<HepMC::GenEvent> anEvent = std::make_unique<HepMC::GenEvent>(process_id1, event_number1);
     const CLHEP::HepLorentzVector myPos( 0.0, 0.0, 0.0, 0.0);
-    HepMC::GenVertexPtr  myVertex = HepMC::newGenVertexPtr( myPos, -1 );
+    HepMC::GenVertexPtr  myVertex = new HepMC::GenVertex( myPos, -1 );
     const HepMC::FourVector fourMomentum1( 0.0, 0.0, 1.0, 1.0*CLHEP::TeV);
-    HepMC::GenParticlePtr  inParticle1 = HepMC::newGenParticlePtr(fourMomentum1, pdgid1, 2);
+    HepMC::GenParticlePtr  inParticle1 = new HepMC::GenParticle(fourMomentum1, pdgid1, 2);
     myVertex->add_particle_in(inParticle1);
     const HepMC::FourVector fourMomentum2( 0.0, 0.0, -1.0, 1.0*CLHEP::TeV);
-    HepMC::GenParticlePtr  inParticle2 = HepMC::newGenParticlePtr(fourMomentum2, pdgid2, 2);
+    HepMC::GenParticlePtr  inParticle2 = new HepMC::GenParticle(fourMomentum2, pdgid2, 2);
     myVertex->add_particle_in(inParticle2);
     const HepMC::FourVector fourMomentum3( 0.0, 1.0, 0.0, 1.0*CLHEP::TeV);
-    HepMC::GenParticlePtr  inParticle3 = HepMC::newGenParticlePtr(fourMomentum3, pdgid1, 1);
+    HepMC::GenParticlePtr  inParticle3 = new HepMC::GenParticle(fourMomentum3, pdgid1, 1);
     myVertex->add_particle_out(inParticle3);
     const HepMC::FourVector fourMomentum4( 0.0, -1.0, 0.0, 1.0*CLHEP::TeV);
-    HepMC::GenParticlePtr  inParticle4 = HepMC::newGenParticlePtr(fourMomentum4, pdgid2, 1);
+    HepMC::GenParticlePtr  inParticle4 = new HepMC::GenParticle(fourMomentum4, pdgid2, 1);
     myVertex->add_particle_out(inParticle4);
     anEvent->add_vertex( myVertex );
     anEvent->set_signal_process_vertex( myVertex );
@@ -404,7 +404,7 @@ namespace ISFTesting {
       .WillOnce(::testing::Return(inParticle3->barcode()));
 
     registerTruthIncident(ti);
-    HepMC::GenVertexPtr  generated = HepMC::barcode_to_vertex(anEvent,-200001); //Find a nicer way to get this.
+    HepMC::GenVertexPtr  generated = anEvent->barcode_to_vertex(-200001); //Find a nicer way to get this.
     HepMC::GenVertexPtr  expectedVtx(nullptr);
     ASSERT_EQ( expectedVtx, generated);
   }
@@ -421,18 +421,18 @@ namespace ISFTesting {
     const int pdgid2(13);
     std::unique_ptr<HepMC::GenEvent> anEvent = std::make_unique<HepMC::GenEvent>(process_id1, event_number1);
     const CLHEP::HepLorentzVector myPos( 0.0, 0.0, 0.0, 0.0);
-    HepMC::GenVertexPtr  myVertex = HepMC::newGenVertexPtr( myPos, -1 );
+    HepMC::GenVertexPtr  myVertex = new HepMC::GenVertex( myPos, -1 );
     const HepMC::FourVector fourMomentum1( 0.0, 0.0, 1.0, 1.0*CLHEP::TeV);
-    HepMC::GenParticlePtr  inParticle1 = HepMC::newGenParticlePtr(fourMomentum1, pdgid1, 2);
+    HepMC::GenParticlePtr  inParticle1 = new HepMC::GenParticle(fourMomentum1, pdgid1, 2);
     myVertex->add_particle_in(inParticle1);
     const HepMC::FourVector fourMomentum2( 0.0, 0.0, -1.0, 1.0*CLHEP::TeV);
-    HepMC::GenParticlePtr  inParticle2 = HepMC::newGenParticlePtr(fourMomentum2, pdgid2, 2);
+    HepMC::GenParticlePtr  inParticle2 = new HepMC::GenParticle(fourMomentum2, pdgid2, 2);
     myVertex->add_particle_in(inParticle2);
     const HepMC::FourVector fourMomentum3( 0.0, 1.0, 0.0, 1.0*CLHEP::TeV);
-    HepMC::GenParticlePtr  inParticle3 = HepMC::newGenParticlePtr(fourMomentum3, pdgid1, 1);
+    HepMC::GenParticlePtr  inParticle3 = new HepMC::GenParticle(fourMomentum3, pdgid1, 1);
     myVertex->add_particle_out(inParticle3);
     const HepMC::FourVector fourMomentum4( 0.0, -1.0, 0.0, 1.0*CLHEP::TeV);
-    HepMC::GenParticlePtr  inParticle4 = HepMC::newGenParticlePtr(fourMomentum4, pdgid2, 1);
+    HepMC::GenParticlePtr  inParticle4 = new HepMC::GenParticle(fourMomentum4, pdgid2, 1);
     myVertex->add_particle_out(inParticle4);
     anEvent->add_vertex( myVertex );
     anEvent->set_signal_process_vertex( myVertex );
@@ -454,7 +454,7 @@ namespace ISFTesting {
       .WillOnce(::testing::Return(inParticle3));
 
     registerTruthIncident(ti);
-    HepMC::GenVertexPtr  generated = HepMC::barcode_to_vertex(anEvent,-200001); //Find a nicer way to get this.
+    HepMC::GenVertexPtr  generated = anEvent->barcode_to_vertex(-200001); //Find a nicer way to get this.
     ASSERT_EQ( vtxPosition, generated->position() );
     ASSERT_EQ( 1021, generated->id() );
     ASSERT_EQ( -200001, generated->barcode() ); // by construction at the moment
@@ -484,18 +484,18 @@ namespace ISFTesting {
     const int pdgid2(13);
     std::unique_ptr<HepMC::GenEvent> anEvent = std::make_unique<HepMC::GenEvent>(process_id1, event_number1);
     const CLHEP::HepLorentzVector myPos( 0.0, 0.0, 0.0, 0.0);
-    HepMC::GenVertexPtr  myVertex = HepMC::newGenVertexPtr( myPos, -1 );
+    HepMC::GenVertexPtr  myVertex = new HepMC::GenVertex( myPos, -1 );
     const HepMC::FourVector fourMomentum1( 0.0, 0.0, 1.0, 1.0*CLHEP::TeV);
-    HepMC::GenParticlePtr  inParticle1 = HepMC::newGenParticlePtr(fourMomentum1, pdgid1, 2);
+    HepMC::GenParticlePtr  inParticle1 = new HepMC::GenParticle(fourMomentum1, pdgid1, 2);
     myVertex->add_particle_in(inParticle1);
     const HepMC::FourVector fourMomentum2( 0.0, 0.0, -1.0, 1.0*CLHEP::TeV);
-    HepMC::GenParticlePtr  inParticle2 = HepMC::newGenParticlePtr(fourMomentum2, pdgid2, 2);
+    HepMC::GenParticlePtr  inParticle2 = new HepMC::GenParticle(fourMomentum2, pdgid2, 2);
     myVertex->add_particle_in(inParticle2);
     const HepMC::FourVector fourMomentum3( 0.0, 1.0, 0.0, 1.0*CLHEP::TeV);
-    HepMC::GenParticlePtr  inParticle3 = HepMC::newGenParticlePtr(fourMomentum3, pdgid1, 1);
+    HepMC::GenParticlePtr  inParticle3 = new HepMC::GenParticle(fourMomentum3, pdgid1, 1);
     myVertex->add_particle_out(inParticle3);
     const HepMC::FourVector fourMomentum4( 0.0, -1.0, 0.0, 1.0*CLHEP::TeV);
-    HepMC::GenParticlePtr  inParticle4 = HepMC::newGenParticlePtr(fourMomentum4, pdgid2, 1);
+    HepMC::GenParticlePtr  inParticle4 = new HepMC::GenParticle(fourMomentum4, pdgid2, 1);
     myVertex->add_particle_out(inParticle4);
     anEvent->add_vertex( myVertex );
     anEvent->set_signal_process_vertex( myVertex );
@@ -524,7 +524,7 @@ namespace ISFTesting {
       .WillOnce(::testing::Return(false));
 
     registerTruthIncident(ti);
-    HepMC::GenVertexPtr  generated = HepMC::barcode_to_vertex(anEvent,-200001); //Find a nicer way to get this.
+    HepMC::GenVertexPtr  generated = anEvent->barcode_to_vertex(-200001); //Find a nicer way to get this.
     ASSERT_EQ( vtxPosition, generated->position() );
     ASSERT_EQ( 1021, generated->id() );
     ASSERT_EQ( -200001, generated->barcode() ); // by construction at the moment
@@ -551,23 +551,23 @@ namespace ISFTesting {
     const int pdgid2(13);
     std::unique_ptr<HepMC::GenEvent> anEvent = std::make_unique<HepMC::GenEvent>(process_id1, event_number1);
     const CLHEP::HepLorentzVector myPos( 0.0, 0.0, 0.0, 0.0);
-    HepMC::GenVertexPtr  myVertex = HepMC::newGenVertexPtr( myPos, -1 );
+    HepMC::GenVertexPtr  myVertex = new HepMC::GenVertex( myPos, -1 );
     const HepMC::FourVector fourMomentum1( 0.0, 0.0, 1.0, 1.0*CLHEP::TeV);
-    HepMC::GenParticlePtr  inParticle1 = HepMC::newGenParticlePtr(fourMomentum1, pdgid1, 2);
+    HepMC::GenParticlePtr  inParticle1 = new HepMC::GenParticle(fourMomentum1, pdgid1, 2);
     myVertex->add_particle_in(inParticle1);
     const HepMC::FourVector fourMomentum2( 0.0, 0.0, -1.0, 1.0*CLHEP::TeV);
-    HepMC::GenParticlePtr  inParticle2 = HepMC::newGenParticlePtr(fourMomentum2, pdgid2, 2);
+    HepMC::GenParticlePtr  inParticle2 = new HepMC::GenParticle(fourMomentum2, pdgid2, 2);
     myVertex->add_particle_in(inParticle2);
     const HepMC::FourVector fourMomentum3( 0.0, 1.0, 0.0, 1.0*CLHEP::TeV);
-    HepMC::GenParticlePtr  inParticle3 = HepMC::newGenParticlePtr(fourMomentum3, pdgid1, 1);
+    HepMC::GenParticlePtr  inParticle3 = new HepMC::GenParticle(fourMomentum3, pdgid1, 1);
     myVertex->add_particle_out(inParticle3);
     const HepMC::FourVector fourMomentum4( 0.0, -1.0, 0.0, 1.0*CLHEP::TeV);
-    HepMC::GenParticlePtr  inParticle4 = HepMC::newGenParticlePtr(fourMomentum4, pdgid2, 1);
+    HepMC::GenParticlePtr  inParticle4 = new HepMC::GenParticle(fourMomentum4, pdgid2, 1);
     myVertex->add_particle_out(inParticle4);
     anEvent->add_vertex( myVertex );
     anEvent->set_signal_process_vertex( myVertex );
     anEvent->set_beam_particles(inParticle1,inParticle2);
-    HepMC::GenParticlePtr  inParticle5 = HepMC::newGenParticlePtr(fourMomentum3, pdgid1, 1);
+    HepMC::GenParticlePtr  inParticle5 = new HepMC::GenParticle(fourMomentum3, pdgid1, 1);
     inParticle5->suggest_barcode(1010003);
     inParticle5->set_status(1);
 
@@ -597,7 +597,7 @@ namespace ISFTesting {
       .WillOnce(::testing::Return(true));
 
     registerTruthIncident(ti);
-    HepMC::GenVertexPtr  generated = HepMC::barcode_to_vertex(anEvent,-200001); //Find a nicer way to get this.
+    HepMC::GenVertexPtr  generated = anEvent->barcode_to_vertex(-200001); //Find a nicer way to get this.
     ASSERT_EQ( vtxPosition, generated->position() );
     ASSERT_EQ( 1021, generated->id() );
     ASSERT_EQ( -200001, generated->barcode() ); // by construction at the moment
diff --git a/Simulation/ISF/ISF_Fatras/ISF_FatrasRecoTools/ISF_FatrasRecoTools/PRD_PlanarTruthTrajectoryBuilder.h b/Simulation/ISF/ISF_Fatras/ISF_FatrasRecoTools/ISF_FatrasRecoTools/PRD_PlanarTruthTrajectoryBuilder.h
index 7b0a65c0d682..274be6f77222 100644
--- a/Simulation/ISF/ISF_Fatras/ISF_FatrasRecoTools/ISF_FatrasRecoTools/PRD_PlanarTruthTrajectoryBuilder.h
+++ b/Simulation/ISF/ISF_Fatras/ISF_FatrasRecoTools/ISF_FatrasRecoTools/PRD_PlanarTruthTrajectoryBuilder.h
@@ -57,7 +57,7 @@ namespace iFatras {
        StatusCode  finalize();
 
        /** return a vector of PrepRawData trajectories - uses internal cache**/
-       const std::map< const HepMC::GenParticlePtr , Trk::PRD_TruthTrajectory >& truthTrajectories() const;
+       const std::map< const HepMC::GenParticle*, Trk::PRD_TruthTrajectory >& truthTrajectories() const;
 
        /** Event refresh - can't be an IIncident, because it has to run after PRD creation and PRD truth creation */
        StatusCode refreshEvent();
@@ -83,7 +83,7 @@ namespace iFatras {
        //!< Track geantinos or not        
        bool                                                   m_geantinos;
        //!< the cache for the return (cleared by Incident)
-       mutable std::map< const HepMC::GenParticlePtr , Trk::PRD_TruthTrajectory > m_gpPrdTruthTrajectories; 
+       mutable std::map< const HepMC::GenParticle*, Trk::PRD_TruthTrajectory > m_gpPrdTruthTrajectories; 
   };
 
 } // end of namespace
diff --git a/Simulation/ISF/ISF_Fatras/ISF_FatrasRecoTools/src/PRD_PlanarTruthTrajectoryBuilder.cxx b/Simulation/ISF/ISF_Fatras/ISF_FatrasRecoTools/src/PRD_PlanarTruthTrajectoryBuilder.cxx
index 9b3c3adfe34e..0e31e6c0261f 100644
--- a/Simulation/ISF/ISF_Fatras/ISF_FatrasRecoTools/src/PRD_PlanarTruthTrajectoryBuilder.cxx
+++ b/Simulation/ISF/ISF_Fatras/ISF_FatrasRecoTools/src/PRD_PlanarTruthTrajectoryBuilder.cxx
@@ -105,7 +105,7 @@ StatusCode iFatras::PRD_PlanarTruthTrajectoryBuilder::refreshEvent()  {
    
 }
 
-const std::map< const HepMC::GenParticlePtr , Trk::PRD_TruthTrajectory >& iFatras::PRD_PlanarTruthTrajectoryBuilder::truthTrajectories() const {
+const std::map< const HepMC::GenParticle*, Trk::PRD_TruthTrajectory >& iFatras::PRD_PlanarTruthTrajectoryBuilder::truthTrajectories() const {
     // ndof
     size_t ndofTotal = 0;
     size_t ndof      = 0;
@@ -125,7 +125,7 @@ const std::map< const HepMC::GenParticlePtr , Trk::PRD_TruthTrajectory >& iFatra
         for ( ; prdMtCIter != prdMtCIterE; ++ prdMtCIter ){
 	  ATH_MSG_VERBOSE("  2-Count " << second_count++ );
             // check if entry exists and if   
-            const HepMC::GenParticlePtr  curGenP       = (*prdMtCIter).second;
+            const HepMC::GenParticle* curGenP       = (*prdMtCIter).second;
             Identifier                curIdentifier = (*prdMtCIter).first;
             // apply the min pT cut 
             if ( curGenP->momentum().perp() < m_minPt ) continue;
@@ -139,7 +139,7 @@ const std::map< const HepMC::GenParticlePtr , Trk::PRD_TruthTrajectory >& iFatra
             if (prd){
 	      ATH_MSG_VERBOSE("  I got the PRD for Id = " << curIdentifier );
                 // try to find the entry for this GenParticle 
-                std::map< const HepMC::GenParticlePtr , Trk::PRD_TruthTrajectory >::iterator prdTrajIter = m_gpPrdTruthTrajectories.find(curGenP);
+                std::map< const HepMC::GenParticle*, Trk::PRD_TruthTrajectory >::iterator prdTrajIter = m_gpPrdTruthTrajectories.find(curGenP);
                 if ( prdTrajIter ==  m_gpPrdTruthTrajectories.end() ){
                     // first PRD associated to this: create PRD_TruthTrajectory object
                     Trk::PRD_TruthTrajectory newPrdTruthTrajectory;
@@ -164,8 +164,8 @@ const std::map< const HepMC::GenParticlePtr , Trk::PRD_TruthTrajectory >& iFatra
 
     // PART 2 --------------------------------------------------------------------------------------------------------
     // loop through the provided list of manipulators ( sorter is included )
-    std::map< const HepMC::GenParticlePtr , Trk::PRD_TruthTrajectory >::iterator prdTruthTrajIter  = m_gpPrdTruthTrajectories.begin();
-    std::map< const HepMC::GenParticlePtr , Trk::PRD_TruthTrajectory >::iterator prdTruthTrajIterE = m_gpPrdTruthTrajectories.end();
+    std::map< const HepMC::GenParticle*, Trk::PRD_TruthTrajectory >::iterator prdTruthTrajIter  = m_gpPrdTruthTrajectories.begin();
+    std::map< const HepMC::GenParticle*, Trk::PRD_TruthTrajectory >::iterator prdTruthTrajIterE = m_gpPrdTruthTrajectories.end();
     for ( ; prdTruthTrajIter != prdTruthTrajIterE; ++prdTruthTrajIter ){
         if ( m_prdTruthTrajectoryManipulators.size() ){
             ToolHandleArray<Trk::IPRD_TruthTrajectoryManipulator>::const_iterator prdTTMIter  = m_prdTruthTrajectoryManipulators.begin();
diff --git a/Simulation/ISF/ISF_Geant4/ISF_Geant4Event/src/ISFG4Helper.cxx b/Simulation/ISF/ISF_Geant4/ISF_Geant4Event/src/ISFG4Helper.cxx
index da7da14cc620..f84bbcf0bade 100644
--- a/Simulation/ISF/ISF_Geant4/ISF_Geant4Event/src/ISFG4Helper.cxx
+++ b/Simulation/ISF/ISF_Geant4/ISF_Geant4Event/src/ISFG4Helper.cxx
@@ -43,11 +43,7 @@ iGeant4::ISFG4Helper::convertG4TrackToISFParticle(const G4Track& aTrack,
   double charge  = particleDefinition.GetPDGCharge();
   int    pdgID   = particleDefinition.GetPDGEncoding();
 
-#ifdef HEPMC3
-  HepMC::GenParticlePtr genParticle;
-#else  
   auto* genParticle = (truth) ? truth->getTruthParticle(): nullptr;
-#endif
   Barcode::ParticleBarcode barcode = (genParticle) ? HepMC::barcode(genParticle) : Barcode::fUndefinedBarcode;
 
   ISF::ISFParticle *isp = new ISF::ISFParticle( position,
diff --git a/Simulation/ISF/ISF_Geant4/ISF_Geant4Tools/src/ISFTrajectory.cxx b/Simulation/ISF/ISF_Geant4/ISF_Geant4Tools/src/ISFTrajectory.cxx
index cf77e2f97fb3..ae443c2c671f 100644
--- a/Simulation/ISF/ISF_Geant4/ISF_Geant4Tools/src/ISFTrajectory.cxx
+++ b/Simulation/ISF/ISF_Geant4/ISF_Geant4Tools/src/ISFTrajectory.cxx
@@ -113,11 +113,7 @@ void iGeant4::ISFTrajectory::AppendStep(const G4Step* aStep)
         // make sure that the TruthBinding of the ISFParticle points to the newest
         // HepMC::GenParticle instance in case it got updated by the
         // ITruthSvc::registerTruthIncident call above
-#ifdef HEPMC3
-        auto currentGenPart = eventInfo->GetCurrentlyTraced();
-#else
-        auto* currentGenPart = eventInfo->GetCurrentlyTraced();
-#endif
+        auto* currentGenPart = atlasG4EvtUserInfo->GetCurrentlyTraced();
         baseIsp->getTruthBinding()->setTruthParticle( currentGenPart );
         Barcode::ParticleBarcode newBarcode = HepMC::barcode(currentGenPart);
         baseIsp->setBarcode( newBarcode );
diff --git a/Simulation/ISF/ISF_Geant4/ISF_Geant4Tools/src/PhysicsValidationUserAction.cxx b/Simulation/ISF/ISF_Geant4/ISF_Geant4Tools/src/PhysicsValidationUserAction.cxx
index 0536415ac975..17e8a0fb8ef2 100644
--- a/Simulation/ISF/ISF_Geant4/ISF_Geant4Tools/src/PhysicsValidationUserAction.cxx
+++ b/Simulation/ISF/ISF_Geant4/ISF_Geant4Tools/src/PhysicsValidationUserAction.cxx
@@ -240,29 +240,16 @@ namespace G4UA{
 	m_scIn = creation? creation->GetProcessSubType() : -1;
 	
 	VTrackInformation * trackInfo= static_cast<VTrackInformation*>(track->GetUserInformation());
-#ifdef HEPMC3
-	HepMC::GenParticlePtr  genpart;
-	HepMC::GenVertexPtr  vtx; 
-
-#else 
 	HepMC::GenParticlePtr genpart= trackInfo ? const_cast<HepMC::GenParticlePtr>(trackInfo->GetHepMCParticle()):0;
 	HepMC::GenVertex* vtx = genpart ? genpart->production_vertex() : 0;
-#endif
 	m_gen = genpart? 0 : -1;
 	
 	if (genpart)  { // mc truth known
 	  while (genpart && vtx ) {
 	    int pdgID=genpart->pdg_id();
-#ifdef HEPMC3
-	    HepMC::GenParticlePtr  genmom = vtx->particles_in().size()>0 ? vtx->particles_in().front() : nullptr;
-	    if ( genmom && pdgID!=genmom->pdg_id() ) m_gen++;
-	    else if (vtx->particles_out().size()>0 && genpart!=vtx->particles_out().front())) m_gen++;
-
-#else
 	    HepMC::GenParticlePtr genmom = vtx->particles_in_size()>0 ? *(vtx->particles_in_const_begin()) : 0;
 	    if ( genmom && pdgID!=genmom->pdg_id() ) m_gen++;
 	    else if (vtx->particles_out_size()>0 && genpart!=*(vtx->particles_out_const_begin())) m_gen++;
-#endif
 	    vtx = genmom ? genmom->production_vertex() : 0;
 	    genpart = genmom;
 	  }
diff --git a/Simulation/ISF/ISF_Geant4/ISF_Geant4Tools/src/TrackProcessorUserActionBase.cxx b/Simulation/ISF/ISF_Geant4/ISF_Geant4Tools/src/TrackProcessorUserActionBase.cxx
index 7ee8f78bf789..dab4b903e432 100644
--- a/Simulation/ISF/ISF_Geant4/ISF_Geant4Tools/src/TrackProcessorUserActionBase.cxx
+++ b/Simulation/ISF/ISF_Geant4/ISF_Geant4Tools/src/TrackProcessorUserActionBase.cxx
@@ -93,7 +93,7 @@ void TrackProcessorUserActionBase::UserSteppingAction(const G4Step* aStep)
     // G4Tracks aready returned to ISF will have a TrackInformation attached to them
     bool particleReturnedToISF = trackInfo && trackInfo->GetReturnedToISF();
     if (!particleReturnedToISF) {
-      HepMC::GenParticlePtr  generationZeroTruthParticle = nullptr;
+      HepMC::GenParticlePtr generationZeroTruthParticle{};
       ::iGeant4::ISFG4Helper::attachTrackInfoToNewG4Track( *aSecondaryTrack,
                                                 *m_curBaseISP,
                                                 Secondary,
@@ -166,15 +166,9 @@ void TrackProcessorUserActionBase::setupPrimary(G4Track& aTrack)
   }
 
   int regenerationNr = ppInfo->GetRegenerationNr();
-#ifdef HEPMC3
-  auto primaryTruthParticle = truthBinding->getGenerationZeroTruthParticle();
-  auto generationZeroTruthParticle = truthBinding->getGenerationZeroTruthParticle();
-  auto currentlyTracedHepPart = truthBinding->getTruthParticle();
-#else
   auto* primaryTruthParticle = truthBinding->getGenerationZeroTruthParticle();
   auto* generationZeroTruthParticle = truthBinding->getGenerationZeroTruthParticle();
   auto* currentlyTracedHepPart = truthBinding->getTruthParticle();
-#endif
   auto classification = classify(primaryTruthParticle,
                                  generationZeroTruthParticle,
                                  currentlyTracedHepPart,
@@ -197,15 +191,11 @@ void TrackProcessorUserActionBase::setupSecondary(const G4Track& aTrack)
   auto* trackInfo = ::iGeant4::ISFG4Helper::getISFTrackInfo(aTrack);
 
   // why does TrackInformation return *const* GenParticle and ISFParticle objects!?
-#ifdef HEPMC3
-
-#else
   HepMC::GenParticlePtr currentlyTracedTruthParticle = const_cast<HepMC::GenParticlePtr>( trackInfo->GetHepMCParticle() );
   HepMC::GenParticlePtr primaryTruthParticle = const_cast<HepMC::GenParticlePtr>( trackInfo->GetPrimaryHepMCParticle() );
   auto* baseISFParticle = const_cast<ISF::ISFParticle*>( trackInfo->GetBaseISFParticle() );
 
   setCurrentParticle(baseISFParticle, primaryTruthParticle, currentlyTracedTruthParticle);
-#endif
   return;
 }
 
diff --git a/Simulation/ISF/ISF_Geant4/ISF_Geant4Tools/src/TrackProcessorUserActionPassBack.cxx b/Simulation/ISF/ISF_Geant4/ISF_Geant4Tools/src/TrackProcessorUserActionPassBack.cxx
index 5c463ffdc91a..1fdfb5dbe154 100644
--- a/Simulation/ISF/ISF_Geant4/ISF_Geant4Tools/src/TrackProcessorUserActionPassBack.cxx
+++ b/Simulation/ISF/ISF_Geant4/ISF_Geant4Tools/src/TrackProcessorUserActionPassBack.cxx
@@ -220,7 +220,7 @@ namespace G4UA {
                                                        Secondary,
                                                        generationZeroTruthParticle );
 
-            HepMC::GenParticlePtr  truthParticle = nullptr;
+            HepMC::GenParticlePtr truthParticle{};
             returnParticleToISF(aTrack_2nd, parent, truthParticle, nextGeoID_2nd);
           }
         }
@@ -241,14 +241,9 @@ namespace G4UA {
         G4Exception("iGeant4::TrackProcessorUserActionPassBack", "NoTrackInformation", FatalException, description);
         return nullptr; //The G4Exception call above should abort the job, but Coverity does not seem to pick this up.
       }
-#ifdef HEPMC3
-      HepMC::GenParticlePtr          primaryHepParticle;// = const_cast<HepMC::GenParticlePtr >(trackInfo->GetPrimaryHepMCParticle());
-      HepMC::GenParticlePtr   generationZeroHepParticle;// = const_cast<HepMC::GenParticlePtr >(trackInfo->GetHepMCParticle());
 
-#else
       HepMC::GenParticlePtr         primaryHepParticle = const_cast<HepMC::GenParticlePtr>(trackInfo->GetPrimaryHepMCParticle());
       HepMC::GenParticlePtr  generationZeroHepParticle = const_cast<HepMC::GenParticlePtr>(trackInfo->GetHepMCParticle());
-#endif
 
       ISF::TruthBinding* tBinding = new ISF::TruthBinding(truthParticle, primaryHepParticle, generationZeroHepParticle);
 
diff --git a/Simulation/ISF/ISF_HepMC/ISF_HepMC_Interfaces/ISF_HepMC_Interfaces/IGenParticleFilter.h b/Simulation/ISF/ISF_HepMC/ISF_HepMC_Interfaces/ISF_HepMC_Interfaces/IGenParticleFilter.h
index e3610f8c9b38..a98278528158 100644
--- a/Simulation/ISF/ISF_HepMC/ISF_HepMC_Interfaces/ISF_HepMC_Interfaces/IGenParticleFilter.h
+++ b/Simulation/ISF/ISF_HepMC/ISF_HepMC_Interfaces/ISF_HepMC_Interfaces/IGenParticleFilter.h
@@ -37,13 +37,8 @@ namespace ISF {
        /// Creates the InterfaceID and interfaceID() method
        DeclareInterfaceID(IGenParticleFilter, 1, 0);
        
-#ifdef HEPMC3
-       /** Returns a boolean if the particle has passed or not */
-       virtual bool pass(const HepMC::GenParticlePtr& particle) const = 0;
-#else
        /** Returns a boolean if the particle has passed or not */
        virtual bool pass(const HepMC::GenParticle& particle) const = 0;
-#endif
        
   };
 
diff --git a/Simulation/ISF/ISF_HepMC/ISF_HepMC_Tools/src/GenParticleFinalStateFilter.cxx b/Simulation/ISF/ISF_HepMC/ISF_HepMC_Tools/src/GenParticleFinalStateFilter.cxx
index 8635e159b2ff..7ce0aa81d86c 100644
--- a/Simulation/ISF/ISF_HepMC/ISF_HepMC_Tools/src/GenParticleFinalStateFilter.cxx
+++ b/Simulation/ISF/ISF_HepMC/ISF_HepMC_Tools/src/GenParticleFinalStateFilter.cxx
@@ -39,12 +39,6 @@ StatusCode  ISF::GenParticleFinalStateFilter::initialize()
 
 
 /** returns true if the the particle is considered stable */
-#ifdef HEPMC3
-bool ISF::GenParticleFinalStateFilter::pass(const HepMC::GenParticlePtr& particle) const
-{
-return true;
-}	
-#else
 bool ISF::GenParticleFinalStateFilter::pass(const HepMC::GenParticle& particle) const
 {
   bool passFilter = true;
@@ -55,7 +49,6 @@ bool ISF::GenParticleFinalStateFilter::pass(const HepMC::GenParticle& particle)
   return passFilter;
 }
 
-#endif
 
 StatusCode  ISF::GenParticleFinalStateFilter::finalize()
 {
@@ -64,14 +57,9 @@ StatusCode  ISF::GenParticleFinalStateFilter::finalize()
 }
 
 /** checks if the particle is in its final state (no end vertex) */
-#ifdef HEPMC3
-bool ISF::GenParticleFinalStateFilter::isFinalState(const HepMC::GenParticlePtr &p) const {
-return true;
-#else
 bool ISF::GenParticleFinalStateFilter::isFinalState(const HepMC::GenParticle &p) const {
   // particle is in its final state if both:
   //  * no end_vertex
   //  * status==1
   return ( !p.end_vertex() && p.status()==1 );
-#endif
 }
diff --git a/Simulation/ISF/ISF_HepMC/ISF_HepMC_Tools/src/GenParticleFinalStateFilter.h b/Simulation/ISF/ISF_HepMC/ISF_HepMC_Tools/src/GenParticleFinalStateFilter.h
index 6846ab3d1cb7..1e6e3dceb61d 100644
--- a/Simulation/ISF/ISF_HepMC/ISF_HepMC_Tools/src/GenParticleFinalStateFilter.h
+++ b/Simulation/ISF/ISF_HepMC/ISF_HepMC_Tools/src/GenParticleFinalStateFilter.h
@@ -42,21 +42,12 @@ namespace ISF {
       StatusCode  initialize();
       StatusCode  finalize();
 
-#ifdef HEPMC3
-      /** Returns the Particle Stack, should register truth */
-      bool pass(const HepMC::GenParticlePtr& particle) const;
-        private:
-      /** checks if the particle is in its final state (no end vertex) */
-      bool isFinalState( const HepMC::GenParticlePtr& p) const;
-#else
-
       /** Returns the Particle Stack, should register truth */
       bool pass(const HepMC::GenParticle& particle) const;
 
         private:
       /** checks if the particle is in its final state (no end vertex) */
       bool isFinalState( const HepMC::GenParticle& p) const;
-#endif
 
       bool                              m_checkGenSimStable;    //!< boolean switch to check on sim stable
       bool                              m_checkGenInteracting;  //!< boolean switch to check on gen interacting
diff --git a/Simulation/ISF/ISF_HepMC/ISF_HepMC_Tools/src/GenParticleGenericFilter.cxx b/Simulation/ISF/ISF_HepMC/ISF_HepMC_Tools/src/GenParticleGenericFilter.cxx
index 744e8b0b2089..f4a54d5845c4 100644
--- a/Simulation/ISF/ISF_HepMC/ISF_HepMC_Tools/src/GenParticleGenericFilter.cxx
+++ b/Simulation/ISF/ISF_HepMC/ISF_HepMC_Tools/src/GenParticleGenericFilter.cxx
@@ -81,29 +81,17 @@ StatusCode  ISF::GenParticleGenericFilter::finalize()
 
 
 /** Returns whether the given particle passes all cuts or not */
-#ifdef HEPMC3
-bool ISF::GenParticleGenericFilter::pass(const HepMC::GenParticlePtr& particle) const
-#else
 bool ISF::GenParticleGenericFilter::pass(const HepMC::GenParticle& particle) const
-#endif
 {
   bool pass = true;
 
-#ifdef HEPMC3
-  const auto productionVertex = particle->production_vertex();
-#else
-  const auto* productionVertex = particle.production_vertex();
-#endif
+  HepMC::ConstGenVertexPtr productionVertex = particle.production_vertex();
   const auto* position = productionVertex ? &productionVertex->position() : nullptr;
   if (!position || position->perp()<=m_maxApplicableRadius) {
     pass = check_cuts_passed(particle);
   }
 
-#ifdef HEPMC3
-  const auto& momentum = particle->momentum();
-#else
   const auto& momentum = particle.momentum();
-#endif
   ATH_MSG_VERBOSE( "GenParticle '" << particle << "' with "
                    << (position ? "pos: r=" + std::to_string(position->perp()) : "")
                    << ", mom: eta=" << momentum.eta() << " phi=" << momentum.phi()
@@ -114,12 +102,6 @@ bool ISF::GenParticleGenericFilter::pass(const HepMC::GenParticle& particle) con
 
 
 /** Check whether the given particle passes all configure cuts or not */
-#ifdef HEPMC3
-bool ISF::GenParticleGenericFilter::check_cuts_passed(const HepMC::GenParticlePtr & particle) const {
-  int pdg = particle->pdg_id();
-  const auto& momentum = particle->momentum();
-  double mom =-1;;
-#else
 bool ISF::GenParticleGenericFilter::check_cuts_passed(const HepMC::GenParticle &particle) const {
   const auto& momentum = particle.momentum();
   double mom = std::sqrt(momentum.x()*momentum.x()+momentum.y()*momentum.y()+momentum.z()*momentum.z());
diff --git a/Simulation/ISF/ISF_HepMC/ISF_HepMC_Tools/src/GenParticleGenericFilter.h b/Simulation/ISF/ISF_HepMC/ISF_HepMC_Tools/src/GenParticleGenericFilter.h
index 4b148ba466d2..b4c7129bcac6 100644
--- a/Simulation/ISF/ISF_HepMC/ISF_HepMC_Tools/src/GenParticleGenericFilter.h
+++ b/Simulation/ISF/ISF_HepMC/ISF_HepMC_Tools/src/GenParticleGenericFilter.h
@@ -52,19 +52,11 @@ typedef std::vector<int>      PDGCodes;
     StatusCode  finalize();
 
     /// Interface method that returns whether the given particle passes all cuts or not
-#ifdef HEPMC3
-    bool pass(const HepMC::GenParticlePtr& particle) const;
-#else
     bool pass(const HepMC::GenParticle& particle) const;
-#endif
 
   private:
     /// Check whether the given particle passes all configure cuts or not
-#ifdef HEPMC3
-    bool check_cuts_passed(const HepMC::GenParticlePtr& particle) const;
-#else
     bool check_cuts_passed(const HepMC::GenParticle& particle) const;
-#endif
 
     /// the cuts defined by the use
     double        m_minEta;     //!< min pseudorapidity cut
diff --git a/Simulation/ISF/ISF_HepMC/ISF_HepMC_Tools/src/GenParticleInteractingFilter.cxx b/Simulation/ISF/ISF_HepMC/ISF_HepMC_Tools/src/GenParticleInteractingFilter.cxx
index 9d5c9b7a9cc0..dbf3eff74505 100644
--- a/Simulation/ISF/ISF_HepMC/ISF_HepMC_Tools/src/GenParticleInteractingFilter.cxx
+++ b/Simulation/ISF/ISF_HepMC/ISF_HepMC_Tools/src/GenParticleInteractingFilter.cxx
@@ -11,7 +11,6 @@
 
 // HepMC includes
 #include "AtlasHepMC/GenParticle.h"
-#include "AtlasHepMC/Flow.h"
 
 // Helper function
 #include "TruthUtils/HepMCHelpers.h"
@@ -68,13 +67,6 @@ StatusCode ISF::GenParticleInteractingFilter::initialize()
 }
 
 /** passes through to the private version of the filter */
-#ifdef HEPMC3
-bool ISF::GenParticleInteractingFilter::pass(const HepMC::GenParticlePtr& particle) const
-{
-  const int& pdg_id = particle->pdg_id();
-return true;
-}
-#else
 bool ISF::GenParticleInteractingFilter::pass(const HepMC::GenParticle& particle) const
 {
   const int& pdg_id = particle.pdg_id();
@@ -86,5 +78,4 @@ bool ISF::GenParticleInteractingFilter::pass(const HepMC::GenParticle& particle)
                                 pdg_id) != m_additionalNonInteractingParticleTypes.end();
   return !(MC::isNonInteracting( &particle ) || isNonInteracting) || isInteracting;
 }
-#endif
 
diff --git a/Simulation/ISF/ISF_HepMC/ISF_HepMC_Tools/src/GenParticleInteractingFilter.h b/Simulation/ISF/ISF_HepMC/ISF_HepMC_Tools/src/GenParticleInteractingFilter.h
index 22a3e829dbb1..97f0011043c8 100644
--- a/Simulation/ISF/ISF_HepMC/ISF_HepMC_Tools/src/GenParticleInteractingFilter.h
+++ b/Simulation/ISF/ISF_HepMC/ISF_HepMC_Tools/src/GenParticleInteractingFilter.h
@@ -18,7 +18,6 @@
 // STL includes
 #include <string>
 
-#include "AtlasHepMC/GenParticle.h"
 namespace ISF {
 
     class ISFParticle;
@@ -41,14 +40,9 @@ namespace ISF {
 
       /** Framework methods */
       virtual StatusCode initialize() override;
-#ifdef HEPMC3
-      /** passes through to the private version */
-      virtual bool pass(const HepMC::GenParticlePtr& particle ) const override;
-#else
 
       /** passes through to the private version */
       virtual bool pass(const HepMC::GenParticle& particle ) const override;
-#endif
 
       /** Additional PDG codes to classify as interacting */
       std::vector<int> m_additionalInteractingParticleTypes;
diff --git a/Simulation/ISF/ISF_HepMC/ISF_HepMC_Tools/src/GenParticleLifetimeFilter.cxx b/Simulation/ISF/ISF_HepMC/ISF_HepMC_Tools/src/GenParticleLifetimeFilter.cxx
index 8f3a6cda72b8..dd4edc16bdb1 100644
--- a/Simulation/ISF/ISF_HepMC/ISF_HepMC_Tools/src/GenParticleLifetimeFilter.cxx
+++ b/Simulation/ISF/ISF_HepMC/ISF_HepMC_Tools/src/GenParticleLifetimeFilter.cxx
@@ -27,18 +27,10 @@ ISF::GenParticleLifetimeFilter::GenParticleLifetimeFilter( const std::string& t,
 
 
 /** does the given particle pass the filter? */
-#ifdef HEPMC3
-bool ISF::GenParticleLifetimeFilter::pass(const HepMC::GenParticlePtr& particle) const
-#else
 bool ISF::GenParticleLifetimeFilter::pass(const HepMC::GenParticle& particle) const
-#endif
 {
   // the GenParticle end vertex
-#ifdef HEPMC3
-  auto  endVtx = particle->end_vertex();
-#else
-  HepMC::GenVertexPtr  endVtx = particle.end_vertex();
-#endif
+  auto endVtx = particle.end_vertex();
   // no production vertex?
   if (!endVtx) {
     ATH_MSG_DEBUG("GenParticle does not have an end vertex, this is fine");
@@ -48,11 +40,7 @@ bool ISF::GenParticleLifetimeFilter::pass(const HepMC::GenParticle& particle) co
   const auto& end4Vec = endVtx->position();
 
   // the GenParticle production vertex
-#ifdef HEPMC3
-  HepMC::GenVertexPtr  prodVtx = particle->production_vertex();
-#else
-  HepMC::GenVertexPtr  prodVtx = particle.production_vertex();
-#endif
+  auto  prodVtx = particle.production_vertex();
   // no production vertex?
   if (!prodVtx) {
     ATH_MSG_DEBUG("GenParticle does not have a production vertex, filtering it out");
diff --git a/Simulation/ISF/ISF_HepMC/ISF_HepMC_Tools/src/GenParticleLifetimeFilter.h b/Simulation/ISF/ISF_HepMC/ISF_HepMC_Tools/src/GenParticleLifetimeFilter.h
index feca30f6caa0..f5629f8adde5 100644
--- a/Simulation/ISF/ISF_HepMC/ISF_HepMC_Tools/src/GenParticleLifetimeFilter.h
+++ b/Simulation/ISF/ISF_HepMC/ISF_HepMC_Tools/src/GenParticleLifetimeFilter.h
@@ -34,11 +34,7 @@ namespace ISF {
     ~GenParticleLifetimeFilter(){}
 
     /** does the given particle pass the filter? */
-#ifdef HEPMC3
-    bool pass(const HepMC::GenParticlePtr& particle) const;
-#else
     bool pass(const HepMC::GenParticle& particle) const;
-#endif
 
   private:
     double m_minLifetime{0.000001}; //units of c*ns
diff --git a/Simulation/ISF/ISF_HepMC/ISF_HepMC_Tools/src/GenParticlePositionFilter.cxx b/Simulation/ISF/ISF_HepMC/ISF_HepMC_Tools/src/GenParticlePositionFilter.cxx
index 2e03bcba0d2e..597933ec224e 100644
--- a/Simulation/ISF/ISF_HepMC/ISF_HepMC_Tools/src/GenParticlePositionFilter.cxx
+++ b/Simulation/ISF/ISF_HepMC/ISF_HepMC_Tools/src/GenParticlePositionFilter.cxx
@@ -12,7 +12,6 @@
 // HepMC includes
 #include "AtlasHepMC/GenParticle.h"
 #include "AtlasHepMC/GenVertex.h"
-#include "AtlasHepMC/SimpleVector.h"
 
 /** Constructor **/
 ISF::GenParticlePositionFilter::GenParticlePositionFilter( const std::string& t,
@@ -49,12 +48,6 @@ StatusCode  ISF::GenParticlePositionFilter::initialize()
 
 
 /** does the given particle pass the filter? */
-#ifdef HEPMC3
-bool ISF::GenParticlePositionFilter::pass(const HepMC::GenParticlePtr& particle) const
-{
-  // the GenParticle production vertex
-  HepMC::GenVertexPtr  vtx = particle->production_vertex();
-#else
 bool ISF::GenParticlePositionFilter::pass(const HepMC::GenParticle& particle) const
 {
   // the GenParticle production vertex
diff --git a/Simulation/ISF/ISF_HepMC/ISF_HepMC_Tools/src/GenParticlePositionFilter.h b/Simulation/ISF/ISF_HepMC/ISF_HepMC_Tools/src/GenParticlePositionFilter.h
index ff9d5802eb14..18b0c3201542 100644
--- a/Simulation/ISF/ISF_HepMC/ISF_HepMC_Tools/src/GenParticlePositionFilter.h
+++ b/Simulation/ISF/ISF_HepMC/ISF_HepMC_Tools/src/GenParticlePositionFilter.h
@@ -45,11 +45,7 @@ namespace ISF {
       StatusCode  finalize();
 
       /** does the given particle pass the filter? */
-#ifdef HEPMC3
-      bool pass(const HepMC::GenParticlePtr& particle) const;
-#else
       bool pass(const HepMC::GenParticle& particle) const;
-#endif 
 	  
 	private:
       ServiceHandle<IGeoIDSvc>          m_geoIDSvc;
diff --git a/Simulation/ISF/ISF_HepMC/ISF_HepMC_Tools/src/GenParticleSimWhiteList.cxx b/Simulation/ISF/ISF_HepMC/ISF_HepMC_Tools/src/GenParticleSimWhiteList.cxx
index 030b7b846cc9..c4fefcb3daf6 100644
--- a/Simulation/ISF/ISF_HepMC/ISF_HepMC_Tools/src/GenParticleSimWhiteList.cxx
+++ b/Simulation/ISF/ISF_HepMC/ISF_HepMC_Tools/src/GenParticleSimWhiteList.cxx
@@ -72,11 +72,7 @@ StatusCode  ISF::GenParticleSimWhiteList::initialize()
 }
 
 /** passes through to the private version of the filter */
-#ifdef HEPMC3
-bool ISF::GenParticleSimWhiteList::pass(const HepMC::GenParticlePtr& particle) const
-#else
 bool ISF::GenParticleSimWhiteList::pass(const HepMC::GenParticle& particle) const
-#endif
 {
 
   ATH_MSG_VERBOSE( "Checking whether " << particle << " passes the filter." );
@@ -86,8 +82,6 @@ bool ISF::GenParticleSimWhiteList::pass(const HepMC::GenParticle& particle) cons
   bool so_far_so_good = pass( particle , vertices );
 
   // Test all parent particles
-#ifdef HEPMC3
-#else
   if (so_far_so_good && particle.production_vertex() && m_qs){
     for (HepMC::GenVertex::particle_iterator it = particle.production_vertex()->particles_begin(HepMC::parents);
                                              it != particle.production_vertex()->particles_end(HepMC::parents); ++it){
@@ -101,18 +95,11 @@ bool ISF::GenParticleSimWhiteList::pass(const HepMC::GenParticle& particle) cons
       so_far_so_good = so_far_so_good && !parent_all_clear;
     } // Loop over parents
   } // particle had parents
-#endif
 
   return so_far_so_good;
 }
 
 /** returns true if the the particle and all daughters are on the white list */
-#ifdef HEPMC3
-bool ISF::GenParticleSimWhiteList::pass(const HepMC::GenParticlePtr& particle , std::vector<int> & used_vertices ) const
-{
-return true;
-}
-#else
 bool ISF::GenParticleSimWhiteList::pass(const HepMC::GenParticle& particle , std::vector<int> & used_vertices ) const
 {
   // See if the particle is in the white list
@@ -145,7 +132,6 @@ bool ISF::GenParticleSimWhiteList::pass(const HepMC::GenParticle& particle , std
 
   return passFilter;
 }
-#endif
 
 StatusCode  ISF::GenParticleSimWhiteList::finalize()
 {
diff --git a/Simulation/ISF/ISF_HepMC/ISF_HepMC_Tools/src/GenParticleSimWhiteList.h b/Simulation/ISF/ISF_HepMC/ISF_HepMC_Tools/src/GenParticleSimWhiteList.h
index d8c3add48c69..bcd25eebef1d 100644
--- a/Simulation/ISF/ISF_HepMC/ISF_HepMC_Tools/src/GenParticleSimWhiteList.h
+++ b/Simulation/ISF/ISF_HepMC/ISF_HepMC_Tools/src/GenParticleSimWhiteList.h
@@ -19,7 +19,6 @@
 #include <string>
 #include <vector>
 
-#include "AtlasHepMC/GenParticle.h"
 namespace ISF {
 
     class ISFParticle;
@@ -45,19 +44,11 @@ namespace ISF {
       StatusCode  finalize();
 
       /** passes through to the private version */
-#ifdef HEPMC3
-      bool pass(const HepMC::GenParticlePtr& particle ) const;
-#else
       bool pass(const HepMC::GenParticle& particle ) const;
-#endif
 
      private:
       /** returns true if the the particle and all daughters are on the white list */
-#ifdef HEPMC3
-      bool pass(const HepMC::GenParticlePtr& particle , std::vector<int> & used_vertices ) const;
-#else
       bool pass(const HepMC::GenParticle& particle , std::vector<int> & used_vertices ) const;
-#endif
       std::vector<std::string>          m_whiteLists;            //!< The location of the white lists
       std::vector<long int>             m_pdgId;                //!< Allowed PDG IDs
       bool                              m_qs;                   //!< Switch for quasi-stable particle simulation
diff --git a/Simulation/ISF/ISF_HepMC/ISF_HepMC_Tools/test/GenParticleGenericFilter_test.cxx b/Simulation/ISF/ISF_HepMC/ISF_HepMC_Tools/test/GenParticleGenericFilter_test.cxx
index 2988dfbf8067..052a95f5baec 100644
--- a/Simulation/ISF/ISF_HepMC/ISF_HepMC_Tools/test/GenParticleGenericFilter_test.cxx
+++ b/Simulation/ISF/ISF_HepMC/ISF_HepMC_Tools/test/GenParticleGenericFilter_test.cxx
@@ -342,7 +342,7 @@ TEST_F(GenParticleGenericFilter_test, productionVertexInsideApplicableRadius_exp
 
   const HepMC::FourVector pos(0., 0., 0., 0.);
   HepMC::GenVertex vtx(pos);
-  auto part = HepMC::newGenParticlePtr(); // need dynamic allocation as GenVertex takes ownership
+  auto* part = new HepMC::GenParticle(); // need dynamic allocation as GenVertex takes ownership
   vtx.add_particle_out(part);
 
   ASSERT_TRUE( m_filterTool->pass(*part) );
@@ -355,7 +355,7 @@ TEST_F(GenParticleGenericFilter_test, productionVertexOutsideApplicableRadiusAnd
   EXPECT_TRUE( m_filterTool->initialize().isSuccess() );
 
   const HepMC::FourVector mom4(1.0*sin(150.*M_PI/180.), 0.0, 1.0*cos(150.*M_PI/180.), 1.0); // rho=1, eta=-1.32
-  auto part = HepMC::newGenParticlePtr(mom4, /*pdg id=*/11); // need dynamic allocation as GenVertex takes ownership
+  auto* part = new HepMC::GenParticle(mom4, /*pdg id=*/11); // need dynamic allocation as GenVertex takes ownership
 
   const HepMC::FourVector pos(0., 100., 0., 0.);
   HepMC::GenVertex vtx(pos);
@@ -371,7 +371,7 @@ TEST_F(GenParticleGenericFilter_test, productionVertexWithinApplicableRadiusAndU
   EXPECT_TRUE( m_filterTool->initialize().isSuccess() );
 
   const HepMC::FourVector mom4(1.0*sin(150.*M_PI/180.), 0.0, 1.0*cos(150.*M_PI/180.), 1.0); // rho=1, eta=-1.32
-  auto part = HepMC::newGenParticlePtr(mom4, /*pdg id=*/11); // need dynamic allocation as GenVertex takes ownership
+  auto* part = new HepMC::GenParticle(mom4, /*pdg id=*/11); // need dynamic allocation as GenVertex takes ownership
 
   const HepMC::FourVector pos(0., 9.9, 0., 0.);
   HepMC::GenVertex vtx(pos);
@@ -388,7 +388,7 @@ TEST_F(GenParticleGenericFilter_test, productionVertexFarForwardInsideApplicable
   EXPECT_TRUE( m_filterTool->initialize().isSuccess() );
 
   const HepMC::FourVector mom4(0., 0., 1.0, 1.0); // rho=1, eta=inf
-  auto part = HepMC::newGenParticlePtr(mom4, /*pdg id=*/11); // need dynamic allocation as GenVertex takes ownership
+  auto* part = new HepMC::GenParticle(mom4, /*pdg id=*/11); // need dynamic allocation as GenVertex takes ownership
 
   const HepMC::FourVector pos(0., 0., 9999., 0.);
   HepMC::GenVertex vtx(pos);
@@ -406,7 +406,7 @@ TEST_F(GenParticleGenericFilter_test, productionVertexFarForwardOutsideApplicabl
   EXPECT_TRUE( m_filterTool->initialize().isSuccess() );
 
   const HepMC::FourVector mom4(0., 0., 1.0, 1.0); // rho=1, eta=inf
-  auto part = HepMC::newGenParticlePtr(mom4, /*pdg id=*/11); // need dynamic allocation as GenVertex takes ownership
+  auto* part = new HepMC::GenParticle(mom4, /*pdg id=*/11); // need dynamic allocation as GenVertex takes ownership
 
   const HepMC::FourVector pos(1.1, 0., 9999., 0.);
   HepMC::GenVertex vtx(pos);
diff --git a/Simulation/ISF/ISF_SimulationSelectors/src/ConeSimSelector.cxx b/Simulation/ISF/ISF_SimulationSelectors/src/ConeSimSelector.cxx
index c1b9d6961b14..d298c9de756c 100644
--- a/Simulation/ISF/ISF_SimulationSelectors/src/ConeSimSelector.cxx
+++ b/Simulation/ISF/ISF_SimulationSelectors/src/ConeSimSelector.cxx
@@ -25,10 +25,7 @@ ISF::ConeSimSelector::ConeSimSelector(const std::string& t, const std::string& n
   , m_relativesVec()
   , m_relatives()
   , m_relationProp()
-#ifdef HEPMC3
-#else
   , m_relation(HepMC::parents)
-#endif
   , m_extrapolateToCalo(false)
   , m_extrapolator()
 {
@@ -145,7 +142,7 @@ void ISF::ConeSimSelector::update(const ISFParticle& particle)
             }
 
           // test whether any of the pdg codes is found in the genParticle history
-          auto  relative = HepMCHelper::findRealtiveWithPDG( genParticle, m_relation, m_relatives);
+          HepMC::ConstGenParticlePtr relative = HepMCHelper::findRealtiveWithPDG( *genParticle, m_relation, m_relatives);
 
           if (relative)
             {
diff --git a/Simulation/ISF/ISF_SimulationSelectors/src/TruthAssocSimSelector.cxx b/Simulation/ISF/ISF_SimulationSelectors/src/TruthAssocSimSelector.cxx
index e89458b3329a..4bf6af110ea8 100644
--- a/Simulation/ISF/ISF_SimulationSelectors/src/TruthAssocSimSelector.cxx
+++ b/Simulation/ISF/ISF_SimulationSelectors/src/TruthAssocSimSelector.cxx
@@ -19,10 +19,7 @@ ISF::TruthAssocSimSelector::TruthAssocSimSelector(const std::string& t, const st
   , m_relativesVec()
   , m_relatives()
   , m_relationProp(0)
-#ifdef HEPMC3
-#else  
   , m_relation(HepMC::parents)
-#endif
 {
   declareProperty( "RelativesPDGCode",
                    m_relativesVec,
@@ -72,11 +69,11 @@ bool  ISF::TruthAssocSimSelector::passSelectorCuts(const ISFParticle& particle)
   if (truth)
     {
       // get GenParticle from truth binding
-      auto genParticle = truth->getTruthParticle();
+      HepMC::ConstGenParticlePtr genParticle = truth->getTruthParticle();
       if (genParticle)
         {
           // test whether any of the pdg codes is found in the genParticle history
-          auto  relative = HepMCHelper::findRealtiveWithPDG( genParticle, m_relation, m_relatives);
+          HepMC::ConstGenParticlePtr relative = HepMCHelper::findRealtiveWithPDG( *genParticle, m_relation, m_relatives);
           // in case a relative was found
           if (relative)
             {
@@ -87,7 +84,7 @@ bool  ISF::TruthAssocSimSelector::passSelectorCuts(const ISFParticle& particle)
                               << " barcode=" << particle.barcode() << ")"
                               << " passes due relative particle"
                               << " (pdg=" << relative->pdg_id() << ","
-                              << " barcode=" << HepMC::barcode(relative) << ")" );
+                              << " barcode=" << HepMC::barcode(*relative) << ")" );
               // selector cuts passed
               return true;
             } // found relative
diff --git a/Simulation/Tools/McEventCollectionFilter/src/McEventCollectionFilter.cxx b/Simulation/Tools/McEventCollectionFilter/src/McEventCollectionFilter.cxx
index 77c70f81124e..ca0d931e1a82 100644
--- a/Simulation/Tools/McEventCollectionFilter/src/McEventCollectionFilter.cxx
+++ b/Simulation/Tools/McEventCollectionFilter/src/McEventCollectionFilter.cxx
@@ -9,9 +9,6 @@
 //
 #include "AtlasHepMC/GenEvent.h"
 #include "AtlasHepMC/GenVertex.h"
-#include "AtlasHepMC/GenParticle.h"
-#include "AtlasHepMC/Flow.h"
-#include "AtlasHepMC/Polarization.h"
 //
 #include "InDetSimEvent/SiHit.h"
 #include "MuonSimEvent/TGCSimHit.h"
@@ -201,7 +198,7 @@ StatusCode McEventCollectionFilter::ReduceMCEventCollection(){
 
 
   //to set geantino vertex as a truth primary vertex
-  HepMC::GenVertexPtr hScatVx = HepMC::barcode_to_vertex(genEvt,-3);
+  HepMC::GenVertexPtr hScatVx = genEvt->barcode_to_vertex(-3);
   if(hScatVx!=nullptr) {
     const HepMC::FourVector& pmvxpos=hScatVx->position();
     genVertex->set_position(pmvxpos);
@@ -220,8 +217,6 @@ StatusCode McEventCollectionFilter::ReduceMCEventCollection(){
     }
   }
 
-#ifdef HEPMC3 
-#else
   if(!evt->vertices_empty()){
     HepMC::GenEvent::vertex_iterator itvtx = evt->vertices_begin();
     for (;itvtx != evt ->vertices_end(); ++itvtx ) {
@@ -230,21 +225,19 @@ StatusCode McEventCollectionFilter::ReduceMCEventCollection(){
       delete vtx;
     }
   }
-#endif
 
   //--------------------------------------
   if(m_IsKeepTRTElect){
     for(int i=0;i<(int) m_elecBarcode.size();i++){
-      HepMC::GenParticlePtr thePart=HepMC::barcode_to_particle(genEvt,m_elecBarcode[i]);
+      HepMC::GenParticlePtr thePart=genEvt->barcode_to_particle(m_elecBarcode[i]);
       if (!thePart){
         ATH_MSG_DEBUG( "Could not find particle for barcode " << m_elecBarcode[i] );
         continue;
       }
       HepMC::ConstGenVertexPtr vx = thePart->production_vertex();
       HepMC::GenParticlePtr thePart_new = HepMC::newGenParticlePtr( thePart->momentum(),thePart->pdg_id(),
-                                                              thePart->status(),HepMC::flow(thePart),
-                                                              HepMC::polarization(thePart) );
-      HepMC::suggest_barcode(thePart_new,m_elecBarcode[i]);
+                                                                    thePart->status());
+      HepMC::suggest_barcode(thePart_new, m_elecBarcode[i]);
 
       const HepMC::FourVector& pos= vx->position();
       HepMC::GenVertexPtr vx_new = HepMC::newGenVertexPtr(pos);
@@ -255,7 +248,7 @@ StatusCode McEventCollectionFilter::ReduceMCEventCollection(){
 
   //.....add new vertex with geantino
   evt->add_vertex(genVertex);
-  m_RefBarcode=HepMC::barcode(genPart);
+  m_RefBarcode=HepMC::barcode(*genPart);
 
   m_outputTruthCollection->push_back(evt);
 
-- 
GitLab


From 9e5131fe1a7b0e1fee19a1bce8434ad332457c0d Mon Sep 17 00:00:00 2001
From: Andrii Verbytskyi <averbyts@cern.ch>
Date: Tue, 22 Dec 2020 14:28:40 +0100
Subject: [PATCH 3/3] More migration

---
 .../src/PixelPrepDataToxAOD.cxx                | 16 +++++++++++++---
 .../src/InDetRecStatisticsAlg.cxx              | 10 +++++++---
 .../InDetRecStatistics/src/TrackStatHelper.cxx |  6 +++---
 .../src/TruthLeptonParentAssociationTool.cxx   | 17 +++++++++++------
 .../src/TruthLeptonParentAssociationTool.h     |  2 +-
 .../src/TruthTauDecayAssociationTool.cxx       | 18 ++++++++----------
 .../src/TruthTauDecayAssociationTool.h         |  2 +-
 7 files changed, 44 insertions(+), 27 deletions(-)

diff --git a/InnerDetector/InDetEventCnv/InDetPrepRawDataToxAOD/src/PixelPrepDataToxAOD.cxx b/InnerDetector/InDetEventCnv/InDetPrepRawDataToxAOD/src/PixelPrepDataToxAOD.cxx
index 93cc1a051d16..f25ae994aea0 100644
--- a/InnerDetector/InDetEventCnv/InDetPrepRawDataToxAOD/src/PixelPrepDataToxAOD.cxx
+++ b/InnerDetector/InDetEventCnv/InDetPrepRawDataToxAOD/src/PixelPrepDataToxAOD.cxx
@@ -1040,14 +1040,24 @@ void  PixelPrepDataToxAOD::addNNTruthInfo(  xAOD::TrackMeasurementValidation* xp
       
       auto particle = siHit.particleLink();
       pdgid[hitNumber]   = particle->pdg_id();
-      truep[hitNumber]  = particle->momentum().rho();
-      if ( particle->production_vertex() ){
-        auto vertex =  particle->production_vertex();
+      HepMC::FourVector mom=particle->momentum();
+      truep[hitNumber]  = std::sqrt(mom.x()*mom.x()+mom.y()*mom.y()+mom.z()*mom.z());
+      auto vertex =  particle->production_vertex();
+//AV Please note that taking the first particle as a mother is ambiguous.
+#ifdef HEPMC3
+      if ( vertex && vertex->particles_in().size()>0){
+        auto mother_of_particle=vertex->particles_in().at(0);             
+        motherBarcode[hitNumber] =  HepMC::barcode(mother_of_particle);
+        motherPdgid[hitNumber]    = mother_of_particle->pdg_id();
+      }
+#else
+      if ( vertex ){
         if( vertex->particles_in_const_begin() !=  vertex->particles_in_const_end() ){
           motherBarcode[hitNumber] =  (*vertex->particles_in_const_begin())->barcode();
           motherPdgid[hitNumber]    =  (*vertex->particles_in_const_begin())->pdg_id();
         }
       }
+#endif
     }
     chargeDep[hitNumber] = siHit.energyLoss() ;
     
diff --git a/InnerDetector/InDetValidation/InDetRecStatistics/src/InDetRecStatisticsAlg.cxx b/InnerDetector/InDetValidation/InDetRecStatistics/src/InDetRecStatisticsAlg.cxx
index 4b3feda32334..10bd093d7e5b 100755
--- a/InnerDetector/InDetValidation/InDetRecStatistics/src/InDetRecStatisticsAlg.cxx
+++ b/InnerDetector/InDetValidation/InDetRecStatistics/src/InDetRecStatisticsAlg.cxx
@@ -298,7 +298,7 @@ StatusCode InDet::InDetRecStatisticsAlg::execute(const EventContext &ctx)  const
     // apply pt, eta etc cuts to generated tracks
     // devide generated tracks into primary, truncated, secondary
 
-    std::vector <std::pair<HepMC::GenParticle *,int> > GenSignal;
+    std::vector <std::pair<HepMC::GenParticlePtr,int> > GenSignal;
     //     GenSignalPrimary, GenSignalTruncated, GenSignalSecondary;   
     unsigned int inTimeStart = 0;
     unsigned int inTimeEnd   = 0;
@@ -583,7 +583,7 @@ void InDet::InDetRecStatisticsAlg::selectRecSignal(const TrackCollection* RecCol
 // select charged, stable particles in allowed pt and eta range
 void InDet :: InDetRecStatisticsAlg ::
 selectGenSignal  (const McEventCollection* SimTracks, 
-		  std::vector <std::pair<HepMC::GenParticle *,int> > & GenSignal,
+		  std::vector <std::pair<HepMC::GenParticlePtr,int> > & GenSignal,
 		  unsigned int /*inTimeStart*/, unsigned int /*inTimeEnd*/,
                   InDet::InDetRecStatisticsAlg::CounterLocal &counter) const //'unused' compiler warning
 {
@@ -604,7 +604,11 @@ selectGenSignal  (const McEventCollection* SimTracks,
   for(unsigned int ievt=0; ievt<nb_mc_event; ++ievt)
     {
       const HepMC::GenEvent* genEvent = SimTracks->at(ievt);
-      counter.m_counter[kN_gen_tracks_processed] += ((SimTracks->at(ievt)))->particles_size();
+#ifdef HEPMC3
+      counter.m_counter[kN_gen_tracks_processed] += genEvent->particles().size();
+#else
+      counter.m_counter[kN_gen_tracks_processed] += genEvent->particles_size();
+#endif
       if (put && inTimeMBbegin != inTimeMBend) // if not, inTimeStart and End are untouched
 	{
 	  //if (genEvent == *inTimeMBbegin) inTimeStart = ievt;
diff --git a/InnerDetector/InDetValidation/InDetRecStatistics/src/TrackStatHelper.cxx b/InnerDetector/InDetValidation/InDetRecStatistics/src/TrackStatHelper.cxx
index 1f9d5946e202..4d283224b34a 100755
--- a/InnerDetector/InDetValidation/InDetRecStatistics/src/TrackStatHelper.cxx
+++ b/InnerDetector/InDetValidation/InDetRecStatistics/src/TrackStatHelper.cxx
@@ -407,7 +407,7 @@ void InDet::TrackStatHelper::addEvent(const TrackCollection              * recTr
   Eta = 0;
   Region = ETA_ALL;
   int classification=-999;
-  for (std::vector <std::pair<HepMC::GenParticle *,int> >::const_iterator truth = gen.begin(); truth != gen.end();  ++truth) {
+  for (auto truth = gen.begin(); truth != gen.end();  ++truth) {
     classification=-999; 
     bool inTimePileup = truth->second == 0
       || (truth->second >= (int)*inTimeStart && truth->second <= (int)*inTimeEnd);
@@ -494,7 +494,7 @@ void InDet::TrackStatHelper::addEvent(const TrackCollection              * recTr
   Region = ETA_ALL;
   classification=-999;
   
-  for (std::vector <std::pair<HepMC::GenParticle *,int> >::const_iterator truth = gen.begin(); truth != gen.end();  ++truth) 
+  for (auto truth = gen.begin(); truth != gen.end();  ++truth) 
     {
       if (truth->second != 0) // only signal event GenParticles
 	continue;
@@ -868,7 +868,7 @@ bool InDet::TrackStatHelper::PassTrackCuts(const Trk::TrackParameters *para) con
 
 }
 
-int InDet::TrackStatHelper::ClassifyParticle( const HepMC::GenParticle *particle, const double prob) const {
+int InDet::TrackStatHelper::ClassifyParticle( HepMC::ConstGenParticlePtr particle, const double prob) const {
 
   int partClass=-999;
 
diff --git a/PhysicsAnalysis/D3PDMaker/TruthD3PDMaker/src/TruthLeptonParentAssociationTool.cxx b/PhysicsAnalysis/D3PDMaker/TruthD3PDMaker/src/TruthLeptonParentAssociationTool.cxx
index 9e452a53e796..dd1514279573 100644
--- a/PhysicsAnalysis/D3PDMaker/TruthD3PDMaker/src/TruthLeptonParentAssociationTool.cxx
+++ b/PhysicsAnalysis/D3PDMaker/TruthD3PDMaker/src/TruthLeptonParentAssociationTool.cxx
@@ -84,9 +84,9 @@ TruthLeptonParentAssociationTool::reset (const TruthParticle& p)
   return StatusCode::SUCCESS;
 }
 
-void TruthLeptonParentAssociationTool::addLeptonParent(const HepMC::GenParticle* part) {
+void TruthLeptonParentAssociationTool::addLeptonParent(HepMC::ConstGenParticlePtr part) {
 
-  HepMC::GenVertex* begvx = part->production_vertex();
+  auto begvx = part->production_vertex();
   if(!begvx){ // no parents
     return;
   }
@@ -95,22 +95,27 @@ void TruthLeptonParentAssociationTool::addLeptonParent(const HepMC::GenParticle*
   if (begvx==part->end_vertex()) return;
 
   // More complex loop catch
-  if ( find(m_barcode_trace.begin(),m_barcode_trace.end(),begvx->barcode()) != m_barcode_trace.end()){
+  if ( find(m_barcode_trace.begin(),m_barcode_trace.end(),HepMC::barcode(begvx)) != m_barcode_trace.end()){
     ATH_MSG_DEBUG( "Found a loop (a la Sherpa sample).  Backing out." );
     return;
   }
-  m_barcode_trace.push_back(begvx->barcode());
+  m_barcode_trace.push_back(HepMC::barcode(begvx));
 
   // Loop over the parents of this particle.
+#ifdef HEPMC3
+  auto itrPar = begvx->particles_in().begin();
+  auto endPar = begvx->particles_in().end();
+#else  
   HepMC::GenVertex::particle_iterator itrPar = begvx->particles_begin(HepMC::parents);
   HepMC::GenVertex::particle_iterator endPar = begvx->particles_end(HepMC::parents);
+#endif
   int n_iter=0;
   for(;itrPar!=endPar; ++itrPar){
     if ( !(*itrPar) ) continue;  // parent didn't exist
     n_iter++;
     if (n_iter>2) break; // No point in trying - this vertex does not have a quantum meaning...
 
-    int pdg = abs((*itrPar)->pdg_id());
+    int pdg = std::abs((*itrPar)->pdg_id());
 
     if ( (31<pdg && pdg<38) || // BSM Higgs / W' / Z' / etc
          pdg==39 ||
@@ -125,7 +130,7 @@ void TruthLeptonParentAssociationTool::addLeptonParent(const HepMC::GenParticle*
          (pdg == 15 && !m_primary_is_tau) || // Tau
          HepPID::isHadron (pdg) // from a hadron!
         ){
-      m_parent_barcodes.push_back( (*itrPar)->barcode() ); 
+      m_parent_barcodes.push_back( HepMC::barcode(*itrPar) ); 
     } else { // Will get to here if we are coming from the same lepton again
       addLeptonParent( *itrPar );
     } // End of catch on PDG ID
diff --git a/PhysicsAnalysis/D3PDMaker/TruthD3PDMaker/src/TruthLeptonParentAssociationTool.h b/PhysicsAnalysis/D3PDMaker/TruthD3PDMaker/src/TruthLeptonParentAssociationTool.h
index 70ffc405c617..53bb0bf6dbb5 100644
--- a/PhysicsAnalysis/D3PDMaker/TruthD3PDMaker/src/TruthLeptonParentAssociationTool.h
+++ b/PhysicsAnalysis/D3PDMaker/TruthD3PDMaker/src/TruthLeptonParentAssociationTool.h
@@ -59,7 +59,7 @@ public:
 private:
 
   /// Function for association to a specific lepton 
-  void addLeptonParent(const HepMC::GenParticle*);
+  void addLeptonParent(HepMC::ConstGenParticlePtr);
 
   /// TruthParticle iterator
   std::vector<const TruthParticle*> m_parents;
diff --git a/PhysicsAnalysis/D3PDMaker/TruthD3PDMaker/src/TruthTauDecayAssociationTool.cxx b/PhysicsAnalysis/D3PDMaker/TruthD3PDMaker/src/TruthTauDecayAssociationTool.cxx
index 953fd2cf260d..ad77365a6b8b 100644
--- a/PhysicsAnalysis/D3PDMaker/TruthD3PDMaker/src/TruthTauDecayAssociationTool.cxx
+++ b/PhysicsAnalysis/D3PDMaker/TruthD3PDMaker/src/TruthTauDecayAssociationTool.cxx
@@ -78,25 +78,23 @@ TruthTauDecayAssociationTool::reset (const TruthParticle& p)
   return StatusCode::SUCCESS;
 }
 
-void TruthTauDecayAssociationTool::addStableDaughters(const HepMC::GenParticle* part) {
+void TruthTauDecayAssociationTool::addStableDaughters(HepMC::ConstGenParticlePtr part) {
   // Sanity check
   if (!part) return;
 
-  HepMC::GenVertex* endvx = part->end_vertex();
+  auto endvx = part->end_vertex();
   if(!endvx){ // no children
-    if ( part && part->status()==1 ) m_tau_prod_barcodes.push_back( part->barcode() );
+    if ( part && part->status()==1 ) m_tau_prod_barcodes.push_back( HepMC::barcode(part) );
     return;
   }
 
   // Loop over the parents of this particle.
-  HepMC::GenVertex::particle_iterator itrChild = endvx->particles_begin(HepMC::children);
-  HepMC::GenVertex::particle_iterator endChild = endvx->particles_end(HepMC::children);
-  for(;itrChild!=endChild; ++itrChild){
-    if ( (*itrChild) && (*itrChild)->status()==1 ){
+  for(auto Child: *endvx){
+    if ( (Child) && (Child)->status()==1 ){
       // Found a stable child!
-      m_tau_prod_barcodes.push_back( (*itrChild)->barcode() );
-    } else if ( (*itrChild) ){
-      addStableDaughters( (*itrChild) );
+      m_tau_prod_barcodes.push_back( HepMC::barcode(Child) );
+    } else if ( (Child) ){
+      addStableDaughters( (Child) );
     }
   } // End loop over children
 
diff --git a/PhysicsAnalysis/D3PDMaker/TruthD3PDMaker/src/TruthTauDecayAssociationTool.h b/PhysicsAnalysis/D3PDMaker/TruthD3PDMaker/src/TruthTauDecayAssociationTool.h
index bfb6b361fe69..a56845e22d96 100644
--- a/PhysicsAnalysis/D3PDMaker/TruthD3PDMaker/src/TruthTauDecayAssociationTool.h
+++ b/PhysicsAnalysis/D3PDMaker/TruthD3PDMaker/src/TruthTauDecayAssociationTool.h
@@ -59,7 +59,7 @@ public:
 private:
 
   /// Function for association to a specific tau 
-  void addStableDaughters(const HepMC::GenParticle*);
+  void addStableDaughters(HepMC::ConstGenParticlePtr);
 
   /// TruthParticle iterator
   std::vector<const TruthParticle*> m_tau_prods;
-- 
GitLab