diff --git a/Event/xAOD/xAODTrackingCnv/src/TrackParticleCnvAlg.cxx b/Event/xAOD/xAODTrackingCnv/src/TrackParticleCnvAlg.cxx
index 4a1d5be5fb4f21b120050cfe12cb64c1904588cb..ed6f51ccc6618c1754eb495e56b7576b6d614c1f 100644
--- a/Event/xAOD/xAODTrackingCnv/src/TrackParticleCnvAlg.cxx
+++ b/Event/xAOD/xAODTrackingCnv/src/TrackParticleCnvAlg.cxx
@@ -256,7 +256,11 @@ namespace xAODMaker {
 			    << " eta " << (*link)->eta() << " phi " << (*link)->phi());
 	      // if configured also get truth classification
               if( result->second.particleLink().cptr() && !m_truthClassifier.empty() ){
+#ifdef HEPMC3
+                auto truthClass = m_truthClassifier->particleTruthClassifier(result->second.particleLink().scptr());
+#else
                 auto truthClass = m_truthClassifier->particleTruthClassifier(result->second.particleLink().cptr());
+#endif
                 type = truthClass.first;
                 origin = truthClass.second;
                 ATH_MSG_VERBOSE("Got truth type  " << static_cast<int>(type) << "  origin " << static_cast<int>(origin));
diff --git a/Generators/GeneratorObjects/GeneratorObjects/HepMcParticleLink.h b/Generators/GeneratorObjects/GeneratorObjects/HepMcParticleLink.h
index 5cde62711dc8ffd9f47d04fe14c10316d55368a6..6f59b1fc552247335db42e04bd782d1ca6ae9833 100644
--- a/Generators/GeneratorObjects/GeneratorObjects/HepMcParticleLink.h
+++ b/Generators/GeneratorObjects/GeneratorObjects/HepMcParticleLink.h
@@ -489,6 +489,13 @@ public:
    */
   const HepMC::GenParticle* cptr() const;
 
+#ifdef HEPMC3
+  /**
+   * @brief Dereference/smart pointer.
+   */
+  HepMC3::ConstGenParticlePtr scptr() const;
+#endif
+
 
   /** 
    * @brief Validity check.  Dereference and check for null.
diff --git a/Generators/GeneratorObjects/src/HepMcParticleLink.cxx b/Generators/GeneratorObjects/src/HepMcParticleLink.cxx
index be4e96ac8016353de23aff647852556661c29620..716971ee1a7e7a85aba117ab7bde46e69ac15e06 100644
--- a/Generators/GeneratorObjects/src/HepMcParticleLink.cxx
+++ b/Generators/GeneratorObjects/src/HepMcParticleLink.cxx
@@ -237,6 +237,76 @@ const HepMC::GenParticle* HepMcParticleLink::cptr() const
   }
   return p;
 }
+#ifdef HEPMC3
+/**
+ * @brief Dereference/smart pointer.
+ */
+HepMC3::ConstGenParticlePtr HepMcParticleLink::scptr() const
+{
+  HepMC3::ConstGenParticlePtr pp{nullptr};
+  const IProxyDict* sg = nullptr;
+  auto p = m_ptrs.get (sg);
+  if (!p) {
+    if (0 == barcode()) {
+#if 0
+      MsgStream log (Athena::getMessageSvc(), "HepMcParticleLink");
+      log << MSG::DEBUG
+             << "scptr: no truth particle associated with this hit (barcode==0)."
+             << " Probably this is a noise hit" << endmsg;
+#endif
+      return nullptr;
+    }
+    if (!sg) {
+      sg = SG::CurrentEventStore::store();
+    }
+    if (const McEventCollection* pEvtColl = retrieveMcEventCollection(sg)) {
+      const HepMC::GenEvent *pEvt = nullptr;
+      index_type index, position;
+      m_extBarcode.eventIndex (index, position);
+      if (index == 0) {
+        pEvt = pEvtColl->at(0);
+      }
+      else if (position != ExtendedBarCode::UNDEFINED) {
+        if (position < pEvtColl->size()) {
+          pEvt = pEvtColl->at (position);
+        }
+        else {
+#if 0
+          MsgStream log (Athena::getMessageSvc(), "HepMcParticleLink");
+          log << MSG::WARNING << "scptr: position = " << position << ", McEventCollection size = "<< pEvtColl->size() << endmsg;
+#endif
+          return nullptr;
+        }
+      }
+      else {
+        pEvt = pEvtColl->find (index);
+      }
+      if (0 != pEvt) {
+        pp = HepMC::barcode_to_particle(pEvt,barcode());
+        if (position != ExtendedBarCode::UNDEFINED) {
+          m_extBarcode.makeIndex (pEvt->event_number(), position);
+        }
+      } else {
+        MsgStream log (Athena::getMessageSvc(), "HepMcParticleLink");
+        if (position != ExtendedBarCode::UNDEFINED) {
+          log << MSG::WARNING
+            << "scptr: Mc Truth not stored for event at " << position
+            << endmsg;
+        } else {
+          log << MSG::WARNING
+            << "scptr: Mc Truth not stored for event with event number " << index
+            << endmsg;
+        }
+      }
+    } else {
+      MsgStream log (Athena::getMessageSvc(), "HepMcParticleLink");
+      log << MSG::WARNING << "scptr: McEventCollection not found" << endmsg;
+    }
+  }
+  return pp;
+}
+
+#endif
 
 
 /**
diff --git a/InnerDetector/InDetAlignTools/InDetAlignGenTools/src/InDetAlignFillTrack.cxx b/InnerDetector/InDetAlignTools/InDetAlignGenTools/src/InDetAlignFillTrack.cxx
index af237112034a97477bfc93f19f050af7dee3c930..ff7f5b5351c81c703c56a48e044c3f5813afff3b 100644
--- a/InnerDetector/InDetAlignTools/InDetAlignGenTools/src/InDetAlignFillTrack.cxx
+++ b/InnerDetector/InDetAlignTools/InDetAlignGenTools/src/InDetAlignFillTrack.cxx
@@ -300,7 +300,11 @@ StatusCode InDetAlignFillTrack::FillTrack() {
           HepMcParticleLink HMPL = trkTruth.particleLink();
 
           if (HMPL.isValid()) {
+#ifdef HEPMC3
+            HepMC::ConstGenParticlePtr genParticle = HMPL.scptr();
+#else
             const HepMC::GenParticle* genParticle = HMPL.cptr();
+#endif
 
             double charge = 1.0;
             if (genParticle->pdg_id() < 0) charge = -charge;
diff --git a/InnerDetector/InDetAlignment/InDetAlignNtupleTools/src/DetailedIDNtupleTool.cxx b/InnerDetector/InDetAlignment/InDetAlignNtupleTools/src/DetailedIDNtupleTool.cxx
index 492211acc5cdd3202e6438b58f5f0a3c03264844..3583cf8e947063acf1df220d50fab1d5eed9a76b 100644
--- a/InnerDetector/InDetAlignment/InDetAlignNtupleTools/src/DetailedIDNtupleTool.cxx
+++ b/InnerDetector/InDetAlignment/InDetAlignNtupleTools/src/DetailedIDNtupleTool.cxx
@@ -401,7 +401,11 @@ namespace InDet {
         HepMcParticleLink HMPL = trtruth.particleLink();
 
         if (HMPL.isValid()) {
+#ifdef HEPMC3
+          HepMC::ConstGenParticlePtr genparptr = HMPL.scptr();
+#else
           const HepMC::GenParticle* genparptr = HMPL.cptr();
+#endif
 
           if (genparptr) {
             if (genparptr->production_vertex()) {
diff --git a/InnerDetector/InDetEventCnv/InDetPrepRawDataToxAOD/src/PixelPrepDataToxAOD.cxx b/InnerDetector/InDetEventCnv/InDetPrepRawDataToxAOD/src/PixelPrepDataToxAOD.cxx
index f25ae994aea041185dc8e43a7a5bb598406d1aaa..4a1b60f89962cb514afa9297408fc81385462a58 100644
--- a/InnerDetector/InDetEventCnv/InDetPrepRawDataToxAOD/src/PixelPrepDataToxAOD.cxx
+++ b/InnerDetector/InDetEventCnv/InDetPrepRawDataToxAOD/src/PixelPrepDataToxAOD.cxx
@@ -23,6 +23,7 @@
 #include "TrkTruthData/PRD_MultiTruthCollection.h"
 #include "AtlasHepMC/GenParticle.h"
 #include "AtlasHepMC/GenVertex.h"
+#include "AtlasHepMC/SimpleVector.h"
 #include "InDetSimEvent/SiHit.h"
 #include "InDetSimData/InDetSimDataCollection.h"
 
diff --git a/InnerDetector/InDetMonitoring/InDetAlignmentMonitoring/src/IDAlignMonNtuple.cxx b/InnerDetector/InDetMonitoring/InDetAlignmentMonitoring/src/IDAlignMonNtuple.cxx
index 5f017a380f96ac9b1d07afe60eed585b81531d3d..5f61e61409791d893229867ddc409de7dedaffc8 100644
--- a/InnerDetector/InDetMonitoring/InDetAlignmentMonitoring/src/IDAlignMonNtuple.cxx
+++ b/InnerDetector/InDetMonitoring/InDetAlignmentMonitoring/src/IDAlignMonNtuple.cxx
@@ -590,7 +590,11 @@ StatusCode IDAlignMonNtuple::fillHistograms()
       	HepMcParticleLink HMPL = trkTruth.particleLink();
 
 	if ( HMPL.isValid()) {
+#ifdef HEPMC3
+     HepMC::ConstGenParticlePtr genParticle = HMPL.scptr(); 
+#else
 	  const HepMC::GenParticle *genParticle = HMPL.cptr(); 
+#endif
 	  
 	  if(msgLvl(MSG::DEBUG)) msg(MSG::DEBUG) << " Particle with PDG "<< genParticle->pdg_id() << " Status "<< genParticle->status()<<" mass "<< genParticle->momentum().m() <<" pt "<<genParticle->momentum().perp()<<" eta "<<genParticle->momentum().eta()<<" phi "<<genParticle->momentum().phi()<<endmsg;
 
diff --git a/InnerDetector/InDetMonitoring/InDetAlignmentMonitoring/src/IDAlignMonTruthComparison.cxx b/InnerDetector/InDetMonitoring/InDetAlignmentMonitoring/src/IDAlignMonTruthComparison.cxx
index b49387154288b510bd4750a4256a92eb5d3e76b5..001e267d1dde1afa9720edd6922245be8616725f 100755
--- a/InnerDetector/InDetMonitoring/InDetAlignmentMonitoring/src/IDAlignMonTruthComparison.cxx
+++ b/InnerDetector/InDetMonitoring/InDetAlignmentMonitoring/src/IDAlignMonTruthComparison.cxx
@@ -421,7 +421,11 @@ StatusCode IDAlignMonTruthComparison::fillHistograms()
           
 	  if ( HMPL.isValid()) 
 	    {
+#ifdef HEPMC3
+              HepMC::ConstGenParticlePtr genparptr = HMPL.scptr(); 
+#else
 	      const HepMC::GenParticle *genparptr = HMPL.cptr(); 
+#endif
 
 	      if (genparptr) {
 		if (genparptr->production_vertex()) { 
@@ -579,7 +583,11 @@ StatusCode IDAlignMonTruthComparison::fillHistograms()
           
 	  if ( HMPL.isValid()) 
 	    {
+#ifdef HEPMC3
+              HepMC::ConstGenParticlePtr genparptr = HMPL.scptr(); 
+#else
 	      const HepMC::GenParticle *genparptr = HMPL.cptr(); 
+#endif
 	      
 	      if (genparptr) {
 		if (genparptr->production_vertex()) { 
diff --git a/InnerDetector/InDetValidation/InDetRecStatistics/src/TrackStatHelper.cxx b/InnerDetector/InDetValidation/InDetRecStatistics/src/TrackStatHelper.cxx
index 4d283224b34a19825beb9f48ac04c0d5520211c2..1b6dc9c8237978af7b30588042aed0501a6eacab 100755
--- a/InnerDetector/InDetValidation/InDetRecStatistics/src/TrackStatHelper.cxx
+++ b/InnerDetector/InDetValidation/InDetRecStatistics/src/TrackStatHelper.cxx
@@ -131,7 +131,7 @@ void InDet::TrackStatHelper::SetCuts(struct cuts ct)
 void InDet::TrackStatHelper::addEvent(const TrackCollection              * recTracks, 
 				      std::vector <const Trk::Track *>   & rec, 
                                       Trk::PRDtoTrackMap *prd_to_track_map,
-				      std::vector <std::pair<HepMC::GenParticle *,int> > & gen, 
+				      std::vector <std::pair<HepMC::GenParticlePtr,int> > & gen, 
 				      const TrackTruthCollection         * truthMap, 
 				      const AtlasDetectorID              * const idHelper, 
 				      const PixelID                      * pixelID, 
@@ -274,8 +274,11 @@ void InDet::TrackStatHelper::addEvent(const TrackCollection              * recTr
 	}
 	else {
 	  //classify track as coming from primary, secondary or truncated gen particle
-	  //	    if(HMPL.isValid()){
+#ifdef HEPMC3
+	  HepMC::ConstGenParticlePtr particle = HMPL.scptr();
+#else
 	  const HepMC::GenParticle *particle = HMPL.cptr();
+#endif
 	  recoClassification = ClassifyParticle(particle, trprob);
 	    
 	  if (trprob < m_cuts.fakeTrackCut)
@@ -409,13 +412,12 @@ void InDet::TrackStatHelper::addEvent(const TrackCollection              * recTr
   int classification=-999;
   for (auto truth = gen.begin(); truth != gen.end();  ++truth) {
     classification=-999; 
-    bool inTimePileup = truth->second == 0
-      || (truth->second >= (int)*inTimeStart && truth->second <= (int)*inTimeEnd);
+    bool inTimePileup = truth->second == 0 || (truth->second >= (int)*inTimeStart && truth->second <= (int)*inTimeEnd);
     
-    HepMC::GenParticle * const particle = truth->first;
+    auto particle = truth->first;
     
     //determine eta region
-    Eta = fabs(particle->momentum().pseudoRapidity());
+    Eta = std::abs(particle->momentum().pseudoRapidity());
     if (Eta < m_cuts.maxEtaBarrel) Region = ETA_BARREL;
     else if  (Eta < m_cuts.maxEtaTransition) Region = ETA_TRANSITION;
     else if  (Eta < m_cuts.maxEtaEndcap) Region = ETA_ENDCAP;
@@ -501,10 +503,10 @@ void InDet::TrackStatHelper::addEvent(const TrackCollection              * recTr
       
       classification=-999; 
       
-      HepMC::GenParticle * const particle = truth->first;
+      auto particle = truth->first;
       
       //determine eta region
-      Eta = fabs(particle->momentum().pseudoRapidity());
+      Eta = std::abs(particle->momentum().pseudoRapidity());
       if (Eta < m_cuts.maxEtaBarrel) Region = ETA_BARREL;
       else if  (Eta < m_cuts.maxEtaTransition) Region = ETA_TRANSITION;
       else if  (Eta < m_cuts.maxEtaEndcap) Region = ETA_ENDCAP;
diff --git a/PhysicsAnalysis/D3PDMaker/TruthD3PDMaker/src/TruthLeptonNearbyAssociationTool.cxx b/PhysicsAnalysis/D3PDMaker/TruthD3PDMaker/src/TruthLeptonNearbyAssociationTool.cxx
index 73736615c56aa677721ee043e9f6d9886176b23e..5787c1c4df11383966cf6ce99eec5938fe736f13 100644
--- a/PhysicsAnalysis/D3PDMaker/TruthD3PDMaker/src/TruthLeptonNearbyAssociationTool.cxx
+++ b/PhysicsAnalysis/D3PDMaker/TruthD3PDMaker/src/TruthLeptonNearbyAssociationTool.cxx
@@ -106,7 +106,7 @@ StatusCode TruthLeptonNearbyAssociationTool::fill (const TruthParticle& p)
   return StatusCode::SUCCESS;
 }
 
-int TruthLeptonNearbyAssociationTool::get_real_parent( HepMC::GenParticlePtr p , int depth ) const
+int TruthLeptonNearbyAssociationTool::get_real_parent( HepMC::ConstGenParticlePtr p , int depth ) const
 {
   if (depth>10) return 0;
 
diff --git a/PhysicsAnalysis/D3PDMaker/TruthD3PDMaker/src/TruthLeptonNearbyAssociationTool.h b/PhysicsAnalysis/D3PDMaker/TruthD3PDMaker/src/TruthLeptonNearbyAssociationTool.h
index 1a637ac595b650796fdd636a54cbf567800e9399..6ca115aba192f09cb8e5b9cf3d54c39245ccab77 100644
--- a/PhysicsAnalysis/D3PDMaker/TruthD3PDMaker/src/TruthLeptonNearbyAssociationTool.h
+++ b/PhysicsAnalysis/D3PDMaker/TruthD3PDMaker/src/TruthLeptonNearbyAssociationTool.h
@@ -59,7 +59,7 @@ private:
   float *m_iso02;
   float *m_iso03;
 
-  int get_real_parent( HepMC::GenParticlePtr , int depth=0 ) const;
+  int get_real_parent( HepMC::ConstGenParticlePtr , int depth=0 ) const;
 
 };
 
diff --git a/PhysicsAnalysis/TruthParticleID/McParticleTools/src/TruthParticleCnvTool.cxx b/PhysicsAnalysis/TruthParticleID/McParticleTools/src/TruthParticleCnvTool.cxx
index 3809895e0a676218767df771ae6428ef0e9e34d0..8a61a16fca4ad31674c79814ea087e58a568cdd7 100755
--- a/PhysicsAnalysis/TruthParticleID/McParticleTools/src/TruthParticleCnvTool.cxx
+++ b/PhysicsAnalysis/TruthParticleID/McParticleTools/src/TruthParticleCnvTool.cxx
@@ -260,7 +260,11 @@ TruthParticleCnvTool::convert( const McEventCollection * mcCollection,
   container->setGenEvent( mcCollection, genEventIndex, sg );
 
   // reserve enough space for the container so we don't have to relocate it
+#ifdef HEPMC3
+  container->reserve( container->size() + evt->particles().size() );
+#else
   container->reserve( container->size() + evt->particles_size() );
+#endif
 
   /// Create a map to enhance access between GenParticles and TruthParticles
   TruthParticleContainer::Map_t bcToMcPart = container->m_particles;
diff --git a/Tracking/TrkValidation/TrkValAlgs/src/RecMomentumQualityValidation.cxx b/Tracking/TrkValidation/TrkValAlgs/src/RecMomentumQualityValidation.cxx
index 9e37c70845e06b7bed5f0c87947a3954c6bf2e8f..40ed122bc3d52e4939899cbda4ec4300f9ea7995 100644
--- a/Tracking/TrkValidation/TrkValAlgs/src/RecMomentumQualityValidation.cxx
+++ b/Tracking/TrkValidation/TrkValAlgs/src/RecMomentumQualityValidation.cxx
@@ -10,7 +10,6 @@
 #include "TrkTrack/TrackCollection.h"
 #include "TrkTruthData/TrackTruthCollection.h"
 #include "TrkParameters/TrackParameters.h"
-//#include "TrkParameters/Perigee.h"
 #include "AtlasHepMC/GenParticle.h"
 #include "TrkToolInterfaces/ITruthToTrack.h"
 #include "TrkToolInterfaces/ITrackSelectorTool.h"
@@ -126,9 +125,6 @@ StatusCode Trk::RecMomentumQualityValidation::execute()
   TrackCollection::const_iterator trackIterator = trackCollection->begin();
   for (;trackIterator!=trackCollection->end();++trackIterator) {
 
-    /*    const Trk::TrackInfo& info = (*trackIterator)->info();
-          if ( ! info.patternRecoInfo(Trk::TrackInfo::TRTStandalone) &&
-          ! info.patternRecoInfo(Trk::TrackInfo::TRTSeededSingleSpTrackFinder)) { */
     if (!m_trackSelector.empty() && (*trackIterator)!=NULL && 
         m_trackSelector->decision(**trackIterator) ) {
       const Trk::TrackParameters* generatedTrackPerigee(0);
@@ -146,11 +142,15 @@ StatusCode Trk::RecMomentumQualityValidation::execute()
           if (msgLvl(MSG::DEBUG)) msg(MSG::DEBUG) << "Link to generated particle information is not there - assuming a lost G4 particle ('fake fake')." << endmsg;
           //        genParticle = m_visibleParticleWithoutTruth; // with pdg_id 0
         } else {
+#ifdef HEPMC3
+          genParticle = trackTruth->particleLink().scptr();
+#else
           genParticle = trackTruth->particleLink().cptr();
-          if ( genParticle!=NULL && genParticle->pdg_id() == 0 ) {
+#endif
+          if ( genParticle && genParticle->pdg_id() == 0 ) {
             if (msgLvl(MSG::DEBUG)) msg(MSG::DEBUG) << "Associated Particle ID " << genParticle->pdg_id()
                                                     << " does not conform to PDG requirements... ignore it!" << endmsg;
-            genParticle = 0;
+            genParticle = nullptr;
           } 
         }
       }
@@ -182,7 +182,6 @@ StatusCode Trk::RecMomentumQualityValidation::execute()
         
         if (!reconstructedPerigee) return StatusCode::FAILURE;
 
-        //      double this_eta = generatedTrackPerigee->eta();
         double this_eta = reconstructedPerigee->eta();
         
         double truth_over_recP = generatedTrackPerigee->parameters()[Trk::qOverP]
@@ -240,9 +239,9 @@ StatusCode Trk::RecMomentumQualityValidation::execute()
 void Trk::RecMomentumQualityValidation::monitorTrackFits(std::vector<unsigned int>& Ntracks,
                                          const double& eta) const {
   Ntracks[Trk::RecMomentumQualityValidation::iAll] += 1;
-  if (fabs(eta) < 0.80 ) ++Ntracks[Trk::RecMomentumQualityValidation::iBarrel];
-  else if (fabs(eta) < 1.60) ++Ntracks[Trk::RecMomentumQualityValidation::iTransi];
-  else if (fabs(eta) < 2.40) ++Ntracks[Trk::RecMomentumQualityValidation::iEndcap];
+  if (std::abs(eta) < 0.80 ) ++Ntracks[Trk::RecMomentumQualityValidation::iBarrel];
+  else if (std::abs(eta) < 1.60) ++Ntracks[Trk::RecMomentumQualityValidation::iTransi];
+  else if (std::abs(eta) < 2.40) ++Ntracks[Trk::RecMomentumQualityValidation::iEndcap];
 }
 
 
diff --git a/Tracking/TrkValidation/TrkValAlgs/src/TrackValidationNtupleWriter.cxx b/Tracking/TrkValidation/TrkValAlgs/src/TrackValidationNtupleWriter.cxx
index 7ebe04335e8ef9c62bcd553ed5aee2ffe5f405af..1fc34029656f793e9bbba0145a8836f49b297fd4 100644
--- a/Tracking/TrkValidation/TrkValAlgs/src/TrackValidationNtupleWriter.cxx
+++ b/Tracking/TrkValidation/TrkValAlgs/src/TrackValidationNtupleWriter.cxx
@@ -565,9 +565,6 @@ StatusCode Trk::TrackValidationNtupleWriter::writeTrackData(unsigned int trackCo
 
     const unsigned int nTruthTreeRecordsAtCurrentEvent = 
       (m_doTruth ? m_truthNtupleTool->getNumberOfTreeRecords() : 0 );
-    //truthData.truthToTrackIndices
-    //std::vector< std::vector<unsigned int> >    truthToTrackIndices(selecParticles ? selecParticles->size() : 0);
-    //std::vector< std::vector<float> >           truthToTrackMatchingProbabilities(selecParticles ? selecParticles->size() : 0);
 
     int trackTreeIndexBegin = m_trees[trackColIndex]->GetEntries();
     int nTracksPerEvent = 0;
@@ -604,11 +601,15 @@ StatusCode Trk::TrackValidationNtupleWriter::writeTrackData(unsigned int trackCo
                     if (msgLvl(MSG::DEBUG)) msg(MSG::DEBUG) << "Link to generated particle information is not there - assuming a lost G4 particle ('fake fake')." << endmsg;
                     genParticle = m_visibleParticleWithoutTruth; // with pdg_id 0
                   } else {
+#ifdef HEPMC3
+                    genParticle = trackTruth->particleLink().scptr();
+#else
                     genParticle = trackTruth->particleLink().cptr();
+#endif
                     if ( genParticle!=NULL && genParticle->pdg_id() == 0 ) {
                       if (msgLvl(MSG::DEBUG)) msg(MSG::DEBUG) << "Associated Particle ID " << genParticle->pdg_id()
                             << " does not conform to PDG requirements... ignore it!" << endmsg;
-                      genParticle = 0;
+                      genParticle = nullptr;
                     } 
                   }
                 }
@@ -618,9 +619,7 @@ StatusCode Trk::TrackValidationNtupleWriter::writeTrackData(unsigned int trackCo
                   const Trk::TrackParameters* generatedTrackPerigee(0);
                   const Trk::TrackParameters* newTrackPerigee(0);
                   // fill the truth data in the track tree
-                  //unsigned int truthIndex = particleToIndexMap[genParticle];
                   int truthIndex = -1;
-                  //std::vector<const HepMC::GenParticle*>::const_iterator matchedPartIter = find(selecParticles->begin(), selecParticles->end(), genParticle);
                   // TODO: do the search somehow better:
                   std::vector<Trk::ValidationTrackTruthData>::iterator matchedPartIter = truthData.begin();
                   for (; matchedPartIter != truthData.end(); matchedPartIter++) {
@@ -636,7 +635,6 @@ StatusCode Trk::TrackValidationNtupleWriter::writeTrackData(unsigned int trackCo
                       generatedTrackPerigee = newTrackPerigee;
                     }
                   } else {
-                    //truthIndex = int(matchedPartIter - selecParticles->begin());
                     // store the index in the track tree of the current track (establish link from truth to track)
                     (*matchedPartIter).truthToTrackIndices[trackColIndex].push_back(m_nTrackTreeRecords[trackColIndex]);
                     (*matchedPartIter).truthToTrackMatchingProbabilities[trackColIndex].push_back(trackTruth->probability());
@@ -737,7 +735,11 @@ StatusCode Trk::TrackValidationNtupleWriter::finalize() {
 
     msg(MSG::INFO)  << "TrackValidationNtupleWriter finalize()" << endmsg;
 
+#ifdef HEPMC3
+    //This is smart pointer in HepMC3
+#else
     delete m_visibleParticleWithoutTruth;
+#endif
     for (unsigned int toolIndex = 0 ; toolIndex < m_eventPropertyNtupleTools.size(); ++toolIndex ){
       if (m_eventPropertyNtupleTools[toolIndex]->resetVariables( ).isFailure()){};
     }
diff --git a/Tracking/TrkValidation/TrkVertexFitterValidationUtils/src/TrkPriVxPurityTool.cxx b/Tracking/TrkValidation/TrkVertexFitterValidationUtils/src/TrkPriVxPurityTool.cxx
index 9a9d2eb64510eb8f5ecc197099a56e8900f46d8e..2b437fe4cf788ab7f27ef59d000b27f925d19100 100755
--- a/Tracking/TrkValidation/TrkVertexFitterValidationUtils/src/TrkPriVxPurityTool.cxx
+++ b/Tracking/TrkValidation/TrkVertexFitterValidationUtils/src/TrkPriVxPurityTool.cxx
@@ -175,7 +175,11 @@ namespace Trk {
 
                                 if (ttItr != trackParticleTruthCollection->end() ) {
                                     const HepMcParticleLink& particleLink = ttItr->second.particleLink();
+#ifdef HEPMC3
+                                    HepMC::ConstGenParticlePtr genParticle = particleLink.scptr();
+#else
                                     HepMC::ConstGenParticlePtr genParticle = particleLink.cptr();
+#endif
 
                                     if(genParticle) {
                                         auto tpEvent = genParticle->parent_event();