diff --git a/InnerDetector/InDetEventCnv/InDetPrepRawDataToxAOD/src/PixelPrepDataToxAOD.cxx b/InnerDetector/InDetEventCnv/InDetPrepRawDataToxAOD/src/PixelPrepDataToxAOD.cxx
index 93cc1a051d1674e4770654dc5b8a8200e0a975fa..f25ae994aea041185dc8e43a7a5bb598406d1aaa 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 4b3feda323344eea55c8022436aff5a02775f71a..10bd093d7e5bcdf23d572c41da0780ab7b32f1a8 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 1f9d5946e2021f86942667d7808aa21c72f20054..4d283224b34a19825beb9f48ac04c0d5520211c2 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 9e452a53e7966a3a4c298548f1b1698199ae3d53..dd1514279573cd4976369d58032919cc615187bc 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 70ffc405c6179a7dc756f2540b36b9cc5c33cfc3..53bb0bf6dbb528deca8404fd2dbe99027fd2d53b 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 953fd2cf260d64cd42212fbafd6d580df71bc060..ad77365a6b8bb95325ba41658fc6eb3a29d17376 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 bfb6b361fe698bdbf7dbe184f584b2316e4f74e5..a56845e22d96cd19fc041dc478e37da7257a6db6 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;