diff --git a/Generators/AtlasHepMC/AtlasHepMC/Operators.h b/Generators/AtlasHepMC/AtlasHepMC/Operators.h
new file mode 100644
index 0000000000000000000000000000000000000000..911f7fe9bf67088e0ef4b26d181283288877acd3
--- /dev/null
+++ b/Generators/AtlasHepMC/AtlasHepMC/Operators.h
@@ -0,0 +1,34 @@
+/*
+  Copyright (C) 2002-2020 CERN for the benefit of the ATLAS collaboration
+*/
+/* Author: Andrii Verbytskyi andrii.verbytskyi@mpp.mpg.de */
+
+#ifndef ATLASHEPMC_OPERATORS_H
+#define ATLASHEPMC_OPERATORS_H
+#ifdef HEPMC3
+// This suboptimal piece of code is here because of the googletest suite.
+namespace HepMC3 {
+bool operator ==(const HepMC3::GenParticle* a, const std::shared_ptr<HepMC3::GenParticle> b ) {
+    return a==b.get();
+}
+bool operator ==(const std::shared_ptr<HepMC3::GenParticle> a, const HepMC3::GenParticle* const b) {
+    return a.get()==b;
+}
+bool operator ==(const std::shared_ptr<const HepMC3::GenParticle> a, const HepMC3::GenParticle* const b) {
+    return a.get()==b;
+}
+bool operator ==(const HepMC3::GenParticle a, const HepMC3::GenParticle b) {
+    return a.id()==b.id();
+}
+bool operator !=(const std::shared_ptr<HepMC3::GenParticle> a, const HepMC3::GenParticle* const b) {
+    return a.get()!=b;
+}
+bool operator !=(const std::shared_ptr<const HepMC3::GenParticle> a, const HepMC3::GenParticle* const b) {
+    return a.get()!=b;
+}
+bool operator !=(const HepMC3::GenParticle a, const HepMC3::GenParticle b) {
+    return a.id()!=b.id();
+}
+}
+#endif
+#endif
diff --git a/InnerDetector/InDetEventCnv/InDetSimEventTPCnv/test/SiHitCnv_p1_test.cxx b/InnerDetector/InDetEventCnv/InDetSimEventTPCnv/test/SiHitCnv_p1_test.cxx
index ecc75766f7384d1ec0a1d41a38b73282957aad0f..7f37bfa90a12fedcb02952c17d1c32388adca7f5 100644
--- a/InnerDetector/InDetEventCnv/InDetSimEventTPCnv/test/SiHitCnv_p1_test.cxx
+++ b/InnerDetector/InDetEventCnv/InDetSimEventTPCnv/test/SiHitCnv_p1_test.cxx
@@ -20,13 +20,14 @@
 #include "GeneratorObjectsTPCnv/initMcEventCollection.h"
 #include "AtlasHepMC/GenParticle.h"
 #include "AtlasHepMC/GenEvent.h"
+#include "AtlasHepMC/Operators.h"
 
 
 void compare (const HepMcParticleLink& p1,
               const HepMcParticleLink& p2)
 {
   assert ( p1.isValid() == p2.isValid() );
-  assert ( p1.barcode() == p2.barcode() );
+  assert ( HepMC::barcode(p1) == HepMC::barcode(p2) );
   assert ( p1.eventIndex() == p2.eventIndex() );
   assert ( p1.getEventCollectionAsChar() == p2.getEventCollectionAsChar() );
   assert ( p1.cptr() == p2.cptr() );
@@ -59,17 +60,17 @@ void testit (const SiHit& trans1)
 }
 
 
-void test1(std::vector<HepMC::GenParticle*>& genPartVector)
+void test1(std::vector<HepMC::GenParticlePtr>& genPartVector)
 {
   std::cout << "test1\n";
-  const HepMC::GenParticle *particle = genPartVector.at(0);
+  auto particle = genPartVector.at(0);
   // Create HepMcParticleLink outside of leak check.
-  HepMcParticleLink dummyHMPL(particle->barcode(),particle->parent_event()->event_number());
+  HepMcParticleLink dummyHMPL(HepMC::barcode(particle),particle->parent_event()->event_number());
   assert(dummyHMPL.cptr()==particle);
   Athena_test::Leakcheck check;
 
-  const HepMC::GenParticle *pGenParticle = genPartVector.at(0);
-  HepMcParticleLink trkLink(pGenParticle->barcode(),pGenParticle->parent_event()->event_number());
+  auto pGenParticle = genPartVector.at(0);
+  HepMcParticleLink trkLink(HepMC::barcode(pGenParticle),pGenParticle->parent_event()->event_number());
   SiHit trans1 (HepGeom::Point3D<double> (10.5, 11.5, 12.5),
                 HepGeom::Point3D<double> (13.5, 14.5, 15.5),
                 16.5,
@@ -84,7 +85,7 @@ void test1(std::vector<HepMC::GenParticle*>& genPartVector)
 int main()
 {
   ISvcLocator* pSvcLoc = nullptr;
-  std::vector<HepMC::GenParticle*> genPartVector;
+  std::vector<HepMC::GenParticlePtr> genPartVector;
   if (!Athena_test::initMcEventCollection(pSvcLoc, genPartVector)) {
     std::cerr << "This test can not be run" << std::endl;
     return 0;
diff --git a/InnerDetector/InDetEventCnv/InDetSimEventTPCnv/test/SiHitCollectionCnv_p2_test.cxx b/InnerDetector/InDetEventCnv/InDetSimEventTPCnv/test/SiHitCollectionCnv_p2_test.cxx
index 4e6fa39f52f104016cd1b9dc880a2cbe8c1f99cb..8a7d58a199be318452911e8c8f3e52231e0f57e8 100644
--- a/InnerDetector/InDetEventCnv/InDetSimEventTPCnv/test/SiHitCollectionCnv_p2_test.cxx
+++ b/InnerDetector/InDetEventCnv/InDetSimEventTPCnv/test/SiHitCollectionCnv_p2_test.cxx
@@ -20,13 +20,14 @@
 #include "GeneratorObjectsTPCnv/initMcEventCollection.h"
 #include "AtlasHepMC/GenParticle.h"
 #include "AtlasHepMC/GenEvent.h"
+#include "AtlasHepMC/Operators.h"
 
 
 void compare (const HepMcParticleLink& p1,
               const HepMcParticleLink& p2)
 {
   assert ( p1.isValid() == p2.isValid() );
-  assert ( p1.barcode() == p2.barcode() );
+  assert ( HepMC::barcode(p1) == HepMC::barcode(p2) );
   assert ( p1.eventIndex() == p2.eventIndex() );
   assert ( p1.getEventCollectionAsChar() == p2.getEventCollectionAsChar() );
   assert ( p1.cptr() == p2.cptr() );
@@ -69,12 +70,12 @@ void testit (const SiHitCollection& trans1)
 }
 
 
-void test1(std::vector<HepMC::GenParticle*>& genPartVector)
+void test1(std::vector<HepMC::GenParticlePtr>& genPartVector)
 {
   std::cout << "test1\n";
-  const HepMC::GenParticle *particle = genPartVector.at(0);
+  auto particle = genPartVector.at(0);
   // Create HepMcParticleLink outside of leak check.
-  HepMcParticleLink dummyHMPL(particle->barcode(),particle->parent_event()->event_number());
+  HepMcParticleLink dummyHMPL(HepMC::barcode(particle),particle->parent_event()->event_number());
   assert(dummyHMPL.cptr()==particle);
   // Create DVL info outside of leak check.
   SiHitCollection dum ("coll");
@@ -82,8 +83,8 @@ void test1(std::vector<HepMC::GenParticle*>& genPartVector)
 
   SiHitCollection trans1 ("coll");
   for (int i=0; i < 10; i++) {
-    const HepMC::GenParticle* pGenParticle = genPartVector.at(i);
-    HepMcParticleLink trkLink(pGenParticle->barcode(),pGenParticle->parent_event()->event_number());
+    auto pGenParticle = genPartVector.at(i);
+    HepMcParticleLink trkLink(HepMC::barcode(pGenParticle),pGenParticle->parent_event()->event_number());
     int o = i*100;
     trans1.Emplace (HepGeom::Point3D<double> (10.5+o, 11.5+o, 12.5+o),
                     HepGeom::Point3D<double> (13.5+o, 14.5+o, 15.5+o),
@@ -101,7 +102,7 @@ void test1(std::vector<HepMC::GenParticle*>& genPartVector)
 int main()
 {
   ISvcLocator* pSvcLoc = nullptr;
-  std::vector<HepMC::GenParticle*> genPartVector;
+  std::vector<HepMC::GenParticlePtr> genPartVector;
   if (!Athena_test::initMcEventCollection(pSvcLoc, genPartVector)) {
     std::cerr << "This test can not be run" << std::endl;
     return 0;
diff --git a/InnerDetector/InDetEventCnv/InDetSimEventTPCnv/test/SiHitCollectionCnv_p3_test.cxx b/InnerDetector/InDetEventCnv/InDetSimEventTPCnv/test/SiHitCollectionCnv_p3_test.cxx
index d66def373f6afb9029afef1cf53a4c78fcbdb050..93ae567d15ea96b87748f97e413bc4ff65318b2a 100644
--- a/InnerDetector/InDetEventCnv/InDetSimEventTPCnv/test/SiHitCollectionCnv_p3_test.cxx
+++ b/InnerDetector/InDetEventCnv/InDetSimEventTPCnv/test/SiHitCollectionCnv_p3_test.cxx
@@ -19,13 +19,14 @@
 #include "GeneratorObjectsTPCnv/initMcEventCollection.h"
 #include "AtlasHepMC/GenParticle.h"
 #include "AtlasHepMC/GenEvent.h"
+#include "AtlasHepMC/Operators.h"
 
 
 void compare (const HepMcParticleLink& p1,
               const HepMcParticleLink& p2)
 {
   assert ( p1.isValid() == p2.isValid() );
-  assert ( p1.barcode() == p2.barcode() );
+  assert ( HepMC::barcode(p1) == HepMC::barcode(p2) );
   assert ( p1.eventIndex() == p2.eventIndex() );
   assert ( p1.getEventCollectionAsChar() == p2.getEventCollectionAsChar() );
   assert ( p1.cptr() == p2.cptr() );
@@ -68,12 +69,12 @@ void testit (const SiHitCollection& trans1)
 }
 
 
-void test1(std::vector<HepMC::GenParticle*>& genPartVector)
+void test1(std::vector<HepMC::GenParticlePtr>& genPartVector)
 {
   std::cout << "test1\n";
-  const HepMC::GenParticle *particle = genPartVector.at(0);
+  auto particle = genPartVector.at(0);
   // Create HepMcParticleLink outside of leak check.
-  HepMcParticleLink dummyHMPL(particle->barcode(),particle->parent_event()->event_number());
+  HepMcParticleLink dummyHMPL(HepMC::barcode(particle),particle->parent_event()->event_number());
   assert(dummyHMPL.cptr()==particle);
   // Create DVL info outside of leak check.
   SiHitCollection dum ("coll");
@@ -81,8 +82,8 @@ void test1(std::vector<HepMC::GenParticle*>& genPartVector)
 
   SiHitCollection trans1 ("coll");
   for (int i=0; i < 10; i++) {
-    const HepMC::GenParticle* pGenParticle = genPartVector.at(i);
-    HepMcParticleLink trkLink(pGenParticle->barcode(),pGenParticle->parent_event()->event_number());
+    auto pGenParticle = genPartVector.at(i);
+    HepMcParticleLink trkLink(HepMC::barcode(pGenParticle),pGenParticle->parent_event()->event_number());
     int o = i*100;
     trans1.Emplace (HepGeom::Point3D<double> (10.5+o, 11.5+o, 12.5+o),
                     HepGeom::Point3D<double> (13.5+o, 14.5+o, 15.5+o),
@@ -100,7 +101,7 @@ void test1(std::vector<HepMC::GenParticle*>& genPartVector)
 int main()
 {
   ISvcLocator* pSvcLoc = nullptr;
-  std::vector<HepMC::GenParticle*> genPartVector;
+  std::vector<HepMC::GenParticlePtr> genPartVector;
   if (!Athena_test::initMcEventCollection(pSvcLoc, genPartVector)) {
     std::cerr << "This test can not be run" << std::endl;
     return 0;
diff --git a/InnerDetector/InDetEventCnv/InDetSimEventTPCnv/test/TRT_HitCnv_p1_test.cxx b/InnerDetector/InDetEventCnv/InDetSimEventTPCnv/test/TRT_HitCnv_p1_test.cxx
index 172512e34d525988e3e71114cbb4edaf0feeff8c..d329d637d3546e3d660de02e4ef67ea9d67764e7 100644
--- a/InnerDetector/InDetEventCnv/InDetSimEventTPCnv/test/TRT_HitCnv_p1_test.cxx
+++ b/InnerDetector/InDetEventCnv/InDetSimEventTPCnv/test/TRT_HitCnv_p1_test.cxx
@@ -20,12 +20,13 @@
 #include "GeneratorObjectsTPCnv/initMcEventCollection.h"
 #include "AtlasHepMC/GenParticle.h"
 #include "AtlasHepMC/GenEvent.h"
+#include "AtlasHepMC/Operators.h"
 
 void compare (const HepMcParticleLink& p1,
               const HepMcParticleLink& p2)
 {
   assert ( p1.isValid() == p2.isValid() );
-  assert ( p1.barcode() == p2.barcode() );
+  assert ( HepMC::barcode(p1) == HepMC::barcode(p2) );
   assert ( p1.eventIndex() == p2.eventIndex() );
   assert ( p1.getEventCollectionAsChar() == p2.getEventCollectionAsChar() );
   assert ( p1.cptr() == p2.cptr() );
@@ -64,17 +65,17 @@ void testit (const TRTUncompressedHit& trans1)
 }
 
 
-void test1(std::vector<HepMC::GenParticle*>& genPartVector)
+void test1(std::vector<HepMC::GenParticlePtr>& genPartVector)
 {
   std::cout << "test1\n";
-  const HepMC::GenParticle *particle = genPartVector.at(0);
+  auto particle = genPartVector.at(0);
   // Create HepMcParticleLink outside of leak check.
-  HepMcParticleLink dummyHMPL(particle->barcode(),particle->parent_event()->event_number());
+  HepMcParticleLink dummyHMPL(HepMC::barcode(particle),particle->parent_event()->event_number());
   assert(dummyHMPL.cptr()==particle);
   Athena_test::Leakcheck check;
 
-  const HepMC::GenParticle *pGenParticle = genPartVector.at(0);
-  HepMcParticleLink trkLink(pGenParticle->barcode(),pGenParticle->parent_event()->event_number());
+  auto pGenParticle = genPartVector.at(0);
+  HepMcParticleLink trkLink(HepMC::barcode(pGenParticle),pGenParticle->parent_event()->event_number());
   TRTUncompressedHit trans1 (101, trkLink, pGenParticle->pdg_id(),
                              104.5, 105.5,
                              106.5, 107.5, 108.5,
@@ -88,7 +89,7 @@ void test1(std::vector<HepMC::GenParticle*>& genPartVector)
 int main()
 {
   ISvcLocator* pSvcLoc = nullptr;
-  std::vector<HepMC::GenParticle*> genPartVector;
+  std::vector<HepMC::GenParticlePtr> genPartVector;
   if (!Athena_test::initMcEventCollection(pSvcLoc, genPartVector)) {
     std::cerr << "This test can not be run" << std::endl;
     return 0;
diff --git a/InnerDetector/InDetEventCnv/InDetSimEventTPCnv/test/TRT_HitCollectionCnv_p2_test.cxx b/InnerDetector/InDetEventCnv/InDetSimEventTPCnv/test/TRT_HitCollectionCnv_p2_test.cxx
index 6eff0faf8819c2ed4f9111baf3d23d07765d108e..c53c6b22e72b1fc56a56712bad230c0be351f31a 100644
--- a/InnerDetector/InDetEventCnv/InDetSimEventTPCnv/test/TRT_HitCollectionCnv_p2_test.cxx
+++ b/InnerDetector/InDetEventCnv/InDetSimEventTPCnv/test/TRT_HitCollectionCnv_p2_test.cxx
@@ -20,12 +20,13 @@
 #include "GeneratorObjectsTPCnv/initMcEventCollection.h"
 #include "AtlasHepMC/GenParticle.h"
 #include "AtlasHepMC/GenEvent.h"
+#include "AtlasHepMC/Operators.h"
 
 void compare (const HepMcParticleLink& p1,
               const HepMcParticleLink& p2)
 {
   assert ( p1.isValid() == p2.isValid() );
-  assert ( p1.barcode() == p2.barcode() );
+  assert ( HepMC::barcode(p1) == HepMC::barcode(p2) );
   assert ( p1.eventIndex() == p2.eventIndex() );
   assert ( p1.getEventCollectionAsChar() == p2.getEventCollectionAsChar() );
   assert ( p1.cptr() == p2.cptr() );
@@ -74,12 +75,12 @@ void testit (const TRTUncompressedHitCollection& trans1)
 }
 
 
-void test1(std::vector<HepMC::GenParticle*>& genPartVector)
+void test1(std::vector<HepMC::GenParticlePtr>& genPartVector)
 {
   std::cout << "test1\n";
-  const HepMC::GenParticle *particle = genPartVector.at(0);
+  auto particle = genPartVector.at(0);
   // Create HepMcParticleLink outside of leak check.
-  HepMcParticleLink dummyHMPL(particle->barcode(),particle->parent_event()->event_number());
+  HepMcParticleLink dummyHMPL(HepMC::barcode(particle),particle->parent_event()->event_number());
   assert(dummyHMPL.cptr()==particle);
   // Create DVL info outside of leak check.
   TRTUncompressedHitCollection dum ("coll");
@@ -88,8 +89,8 @@ void test1(std::vector<HepMC::GenParticle*>& genPartVector)
   TRTUncompressedHitCollection trans1 ("coll");
   for (int i=0; i < 10; i++) {
     int o = i*100;
-    const HepMC::GenParticle* pGenParticle = genPartVector.at(0);
-    HepMcParticleLink trkLink(pGenParticle->barcode(),pGenParticle->parent_event()->event_number());
+    auto pGenParticle = genPartVector.at(0);
+    HepMcParticleLink trkLink(HepMC::barcode(pGenParticle),pGenParticle->parent_event()->event_number());
     trans1.Emplace (101+o, trkLink, pGenParticle->pdg_id(),
                     104.5+o, 105.5+o,
                     (106.5+o)/1000, (107.5+o)/1000, 108.5+o,
@@ -97,8 +98,8 @@ void test1(std::vector<HepMC::GenParticle*>& genPartVector)
                     112.5+o);
   }
   // Special case for photons
-  const HepMC::GenParticle* pGenParticle = genPartVector.at(10);
-  HepMcParticleLink trkLink(pGenParticle->barcode(),pGenParticle->parent_event()->event_number());
+  auto pGenParticle = genPartVector.at(10);
+  HepMcParticleLink trkLink(HepMC::barcode(pGenParticle),pGenParticle->parent_event()->event_number());
   trans1.Emplace (131, trkLink, 22,
                   134.5, 135.5,
                   10, 3, 138.5,
@@ -112,7 +113,7 @@ void test1(std::vector<HepMC::GenParticle*>& genPartVector)
 int main()
 {
   ISvcLocator* pSvcLoc = nullptr;
-  std::vector<HepMC::GenParticle*> genPartVector;
+  std::vector<HepMC::GenParticlePtr> genPartVector;
   if (!Athena_test::initMcEventCollection(pSvcLoc, genPartVector)) {
     std::cerr << "This test can not be run" << std::endl;
     return 0;
diff --git a/InnerDetector/InDetEventCnv/InDetSimEventTPCnv/test/TRT_HitCollectionCnv_p3_test.cxx b/InnerDetector/InDetEventCnv/InDetSimEventTPCnv/test/TRT_HitCollectionCnv_p3_test.cxx
index 4f9b1cdff529201948c0b2f05309c404dbb5de0a..d223bd0a692576c8f63535d6fb051c6bb3fc51ac 100644
--- a/InnerDetector/InDetEventCnv/InDetSimEventTPCnv/test/TRT_HitCollectionCnv_p3_test.cxx
+++ b/InnerDetector/InDetEventCnv/InDetSimEventTPCnv/test/TRT_HitCollectionCnv_p3_test.cxx
@@ -22,6 +22,7 @@
 #include "GeneratorObjectsTPCnv/initMcEventCollection.h"
 #include "AtlasHepMC/GenParticle.h"
 #include "AtlasHepMC/GenEvent.h"
+#include "AtlasHepMC/Operators.h"
 
 using Athena_test::isEqual;
 using std::atan2;
@@ -31,7 +32,7 @@ void compare (const HepMcParticleLink& p1,
               const HepMcParticleLink& p2)
 {
   assert ( p1.isValid() == p2.isValid() );
-  assert ( p1.barcode() == p2.barcode() );
+  assert ( HepMC::barcode(p1) == HepMC::barcode(p2) );
   assert ( p1.eventIndex() == p2.eventIndex() );
   assert ( p1.getEventCollectionAsChar() == p2.getEventCollectionAsChar() );
   assert ( p1.cptr() == p2.cptr() );
@@ -94,12 +95,12 @@ void testit (const TRTUncompressedHitCollection& trans1)
 }
 
 
-void test1(std::vector<HepMC::GenParticle*>& genPartVector)
+void test1(std::vector<HepMC::GenParticlePtr>& genPartVector)
 {
   std::cout << "test1\n";
-  const HepMC::GenParticle *particle = genPartVector.at(0);
+  auto particle = genPartVector.at(0);
   // Create HepMcParticleLink outside of leak check.
-  HepMcParticleLink dummyHMPL(particle->barcode(),particle->parent_event()->event_number());
+  HepMcParticleLink dummyHMPL(HepMC::barcode(particle),particle->parent_event()->event_number());
   assert(dummyHMPL.cptr()==particle);
   // Create DVL info outside of leak check.
   TRTUncompressedHitCollection dum ("coll");
@@ -108,8 +109,8 @@ void test1(std::vector<HepMC::GenParticle*>& genPartVector)
   TRTUncompressedHitCollection trans1 ("coll");
   for (int i=0; i < 10; i++) {
     int o = i*100;
-    const HepMC::GenParticle* pGenParticle = genPartVector.at(0);
-    HepMcParticleLink trkLink(pGenParticle->barcode(),pGenParticle->parent_event()->event_number());
+    auto pGenParticle = genPartVector.at(0);
+    HepMcParticleLink trkLink(HepMC::barcode(pGenParticle),pGenParticle->parent_event()->event_number());
     trans1.Emplace (101+o, trkLink, 20+o,
                     104.5+o, 105.5+o,
                     (106.5+o)/1000, (107.5+o)/1000, 108.5+o,
@@ -117,8 +118,8 @@ void test1(std::vector<HepMC::GenParticle*>& genPartVector)
                     112.5+o);
   }
   // Special case for photons
-  const HepMC::GenParticle* pGenParticle = genPartVector.at(10);
-  HepMcParticleLink trkLink(pGenParticle->barcode(),pGenParticle->parent_event()->event_number());
+  auto pGenParticle = genPartVector.at(10);
+  HepMcParticleLink trkLink(HepMC::barcode(pGenParticle),pGenParticle->parent_event()->event_number());
   trans1.Emplace (131, trkLink, 22,
                   134.5, 135.5,
                   10, 3, 138.5,
@@ -132,7 +133,7 @@ void test1(std::vector<HepMC::GenParticle*>& genPartVector)
 int main()
 {
   ISvcLocator* pSvcLoc = nullptr;
-  std::vector<HepMC::GenParticle*> genPartVector;
+  std::vector<HepMC::GenParticlePtr> genPartVector;
   if (!Athena_test::initMcEventCollection(pSvcLoc, genPartVector)) {
     std::cerr << "This test can not be run" << std::endl;
     return 0;
diff --git a/InnerDetector/InDetEventCnv/InDetSimEventTPCnv/test/TRT_HitCollectionCnv_p4_test.cxx b/InnerDetector/InDetEventCnv/InDetSimEventTPCnv/test/TRT_HitCollectionCnv_p4_test.cxx
index 7cd6335bba46c70f4898702628708e1162261c98..eae9cee6f0f7da9ee01bedcf66ad5759c3ce747d 100644
--- a/InnerDetector/InDetEventCnv/InDetSimEventTPCnv/test/TRT_HitCollectionCnv_p4_test.cxx
+++ b/InnerDetector/InDetEventCnv/InDetSimEventTPCnv/test/TRT_HitCollectionCnv_p4_test.cxx
@@ -22,6 +22,7 @@
 #include "GeneratorObjectsTPCnv/initMcEventCollection.h"
 #include "AtlasHepMC/GenParticle.h"
 #include "AtlasHepMC/GenEvent.h"
+#include "AtlasHepMC/Operators.h"
 
 using Athena_test::isEqual;
 using std::atan2;
@@ -31,7 +32,7 @@ void compare (const HepMcParticleLink& p1,
               const HepMcParticleLink& p2)
 {
   assert ( p1.isValid() == p2.isValid() );
-  assert ( p1.barcode() == p2.barcode() );
+  assert ( HepMC::barcode(p1) == HepMC::barcode(p2) );
   assert ( p1.eventIndex() == p2.eventIndex() );
   assert ( p1.getEventCollectionAsChar() == p2.getEventCollectionAsChar() );
   assert ( p1.cptr() == p2.cptr() );
@@ -94,12 +95,12 @@ void testit (const TRTUncompressedHitCollection& trans1)
 }
 
 
-void test1(std::vector<HepMC::GenParticle*>& genPartVector)
+void test1(std::vector<HepMC::GenParticlePtr>& genPartVector)
 {
   std::cout << "test1\n";
-  const HepMC::GenParticle *particle = genPartVector.at(0);
+  auto particle = genPartVector.at(0);
   // Create HepMcParticleLink outside of leak check.
-  HepMcParticleLink dummyHMPL(particle->barcode(),particle->parent_event()->event_number());
+  HepMcParticleLink dummyHMPL(HepMC::barcode(particle),particle->parent_event()->event_number());
   assert(dummyHMPL.cptr()==particle);
   // Create DVL info outside of leak check.
   TRTUncompressedHitCollection dum ("coll");
@@ -108,8 +109,8 @@ void test1(std::vector<HepMC::GenParticle*>& genPartVector)
   TRTUncompressedHitCollection trans1 ("coll");
   for (int i=0; i < 10; i++) {
     int o = i*100;
-    const HepMC::GenParticle* pGenParticle = genPartVector.at(0);
-    HepMcParticleLink trkLink(pGenParticle->barcode(),pGenParticle->parent_event()->event_number());
+    auto pGenParticle = genPartVector.at(0);
+    HepMcParticleLink trkLink(HepMC::barcode(pGenParticle),pGenParticle->parent_event()->event_number());
     trans1.Emplace (101+o, trkLink, 20+o,
                     104.5+o, 105.5+o,
                     (106.5+o)/1000, (107.5+o)/1000, 108.5+o,
@@ -117,8 +118,8 @@ void test1(std::vector<HepMC::GenParticle*>& genPartVector)
                     112.5+o);
   }
   // Special case for photons
-  const HepMC::GenParticle* pGenParticle = genPartVector.at(10);
-  HepMcParticleLink trkLink(pGenParticle->barcode(),pGenParticle->parent_event()->event_number());
+  auto pGenParticle = genPartVector.at(10);
+  HepMcParticleLink trkLink(HepMC::barcode(pGenParticle),pGenParticle->parent_event()->event_number());
   trans1.Emplace (131, trkLink, 22,
                   134.5, 135.5,
                   10, 3, 138.5,
@@ -132,7 +133,7 @@ void test1(std::vector<HepMC::GenParticle*>& genPartVector)
 int main()
 {
   ISvcLocator* pSvcLoc = nullptr;
-  std::vector<HepMC::GenParticle*> genPartVector;
+  std::vector<HepMC::GenParticlePtr> genPartVector;
   if (!Athena_test::initMcEventCollection(pSvcLoc, genPartVector)) {
     std::cerr << "This test can not be run" << std::endl;
     return 0;
diff --git a/MuonSpectrometer/MuonCnv/MuonEventTPCnv/test/CscSimDataCnv_p1_test.cxx b/MuonSpectrometer/MuonCnv/MuonEventTPCnv/test/CscSimDataCnv_p1_test.cxx
index 870a33a2998fcf5b5ce5a3bdc4e2b07413148586..c999fc30af90c22ad17d56fee076dff123c9b358 100644
--- a/MuonSpectrometer/MuonCnv/MuonEventTPCnv/test/CscSimDataCnv_p1_test.cxx
+++ b/MuonSpectrometer/MuonCnv/MuonEventTPCnv/test/CscSimDataCnv_p1_test.cxx
@@ -20,13 +20,14 @@
 #include "GeneratorObjectsTPCnv/initMcEventCollection.h"
 #include "AtlasHepMC/GenEvent.h"
 #include "AtlasHepMC/GenParticle.h"
+#include "AtlasHepMC/Operators.h"
 
 
 void compare (const HepMcParticleLink& p1,
               const HepMcParticleLink& p2)
 {
   assert ( p1.isValid() == p2.isValid() );
-  assert ( p1.barcode() == p2.barcode() );
+  assert ( HepMC::barcode(p1) == HepMC::barcode(p2) );
   assert ( p1.eventIndex() == p2.eventIndex() );
   assert ( p1.getEventCollectionAsChar() == p2.getEventCollectionAsChar() );
   assert ( p1.cptr() == p2.cptr() );
@@ -72,12 +73,12 @@ void testit (const CscSimData& trans1)
 }
 
 
-void test1(std::vector<HepMC::GenParticle*>& genPartVector)
+void test1(std::vector<HepMC::GenParticlePtr>& genPartVector)
 {
   std::cout << "test1\n";
-  const HepMC::GenParticle *particle = genPartVector.at(0);
+  auto particle = genPartVector.at(0);
   // Create HepMcParticleLink outside of leak check.
-  HepMcParticleLink dummyHMPL(particle->barcode(),particle->parent_event()->event_number());
+  HepMcParticleLink dummyHMPL(HepMC::barcode(particle),particle->parent_event()->event_number());
   assert(dummyHMPL.cptr()==particle);
   Athena_test::Leakcheck check;
 
@@ -99,7 +100,7 @@ void test1(std::vector<HepMC::GenParticle*>& genPartVector)
 int main()
 {
   ISvcLocator* pSvcLoc = nullptr;
-  std::vector<HepMC::GenParticle*> genPartVector;
+  std::vector<HepMC::GenParticlePtr> genPartVector;
   if (!Athena_test::initMcEventCollection(pSvcLoc,genPartVector)) {
     std::cerr << "This test can not be run" << std::endl;
     return 0;
diff --git a/MuonSpectrometer/MuonCnv/MuonEventTPCnv/test/CscSimDataCnv_p2_test.cxx b/MuonSpectrometer/MuonCnv/MuonEventTPCnv/test/CscSimDataCnv_p2_test.cxx
index b5ce72e597d9bbb057262c5bf2f62c1d308e1010..16c750c3e1dc68d6db4fda3cdb705c7a32567a33 100644
--- a/MuonSpectrometer/MuonCnv/MuonEventTPCnv/test/CscSimDataCnv_p2_test.cxx
+++ b/MuonSpectrometer/MuonCnv/MuonEventTPCnv/test/CscSimDataCnv_p2_test.cxx
@@ -21,13 +21,14 @@
 #include "GeneratorObjectsTPCnv/initMcEventCollection.h"
 #include "AtlasHepMC/GenEvent.h"
 #include "AtlasHepMC/GenParticle.h"
+#include "AtlasHepMC/Operators.h"
 
 
 void compare (const HepMcParticleLink& p1,
               const HepMcParticleLink& p2)
 {
   assert ( p1.isValid() == p2.isValid() );
-  assert ( p1.barcode() == p2.barcode() );
+  assert ( HepMC::barcode(p1) == HepMC::barcode(p2) );
   assert ( p1.eventIndex() == p2.eventIndex() );
   assert ( p1.getEventCollectionAsChar() == p2.getEventCollectionAsChar() );
   assert ( p1.cptr() == p2.cptr() );
@@ -73,12 +74,12 @@ void testit (const CscSimData& trans1)
 }
 
 
-void test1(std::vector<HepMC::GenParticle*>& genPartVector)
+void test1(std::vector<HepMC::GenParticlePtr>& genPartVector)
 {
   std::cout << "test1\n";
-  const HepMC::GenParticle *particle = genPartVector.at(0);
+  auto particle = genPartVector.at(0);
   // Create HepMcParticleLink outside of leak check.
-  HepMcParticleLink dummyHMPL(particle->barcode(),particle->parent_event()->event_number());
+  HepMcParticleLink dummyHMPL(HepMC::barcode(particle),particle->parent_event()->event_number());
   assert(dummyHMPL.cptr()==particle);
   Athena_test::Leakcheck check;
 
@@ -100,7 +101,7 @@ void test1(std::vector<HepMC::GenParticle*>& genPartVector)
 int main()
 {
   ISvcLocator* pSvcLoc = nullptr;
-  std::vector<HepMC::GenParticle*> genPartVector;
+  std::vector<HepMC::GenParticlePtr> genPartVector;
   if (!Athena_test::initMcEventCollection(pSvcLoc,genPartVector)) {
     std::cerr << "This test can not be run" << std::endl;
     return 0;
diff --git a/MuonSpectrometer/MuonCnv/MuonEventTPCnv/test/CscSimDataCollectionCnv_p1_test.cxx b/MuonSpectrometer/MuonCnv/MuonEventTPCnv/test/CscSimDataCollectionCnv_p1_test.cxx
index 5198de86e1ad459f58d748510aa3850ea9a6e807..fe92f5d541682cbb91acb50f8db76509b81e40ce 100644
--- a/MuonSpectrometer/MuonCnv/MuonEventTPCnv/test/CscSimDataCollectionCnv_p1_test.cxx
+++ b/MuonSpectrometer/MuonCnv/MuonEventTPCnv/test/CscSimDataCollectionCnv_p1_test.cxx
@@ -21,13 +21,14 @@
 #include "GeneratorObjectsTPCnv/initMcEventCollection.h"
 #include "AtlasHepMC/GenEvent.h"
 #include "AtlasHepMC/GenParticle.h"
+#include "AtlasHepMC/Operators.h"
 
 
 void compare (const HepMcParticleLink& p1,
               const HepMcParticleLink& p2)
 {
   assert ( p1.isValid() == p2.isValid() );
-  assert ( p1.barcode() == p2.barcode() );
+  assert ( HepMC::barcode(p1) == HepMC::barcode(p2) );
   assert ( p1.eventIndex() == p2.eventIndex() );
   assert ( p1.getEventCollectionAsChar() == p2.getEventCollectionAsChar() );
   assert ( p1.cptr() == p2.cptr() );
@@ -86,12 +87,12 @@ void testit (const CscSimDataCollection& trans1)
 }
 
 
-void test1(std::vector<HepMC::GenParticle*>& genPartVector)
+void test1(std::vector<HepMC::GenParticlePtr>& genPartVector)
 {
   std::cout << "test1\n";
-  const HepMC::GenParticle *particle = genPartVector.at(0);
+  auto particle = genPartVector.at(0);
   // Create HepMcParticleLink outside of leak check.
-  HepMcParticleLink dummyHMPL(particle->barcode(),particle->parent_event()->event_number());
+  HepMcParticleLink dummyHMPL(HepMC::barcode(particle),particle->parent_event()->event_number());
   assert(dummyHMPL.cptr()==particle);
   Athena_test::Leakcheck check;
 
@@ -116,7 +117,7 @@ void test1(std::vector<HepMC::GenParticle*>& genPartVector)
 int main()
 {
   ISvcLocator* pSvcLoc = nullptr;
-  std::vector<HepMC::GenParticle*> genPartVector;
+  std::vector<HepMC::GenParticlePtr> genPartVector;
   if (!Athena_test::initMcEventCollection(pSvcLoc,genPartVector)) {
     std::cerr << "This test can not be run" << std::endl;
     return 0;
diff --git a/MuonSpectrometer/MuonCnv/MuonEventTPCnv/test/CscSimDataCollectionCnv_p2_test.cxx b/MuonSpectrometer/MuonCnv/MuonEventTPCnv/test/CscSimDataCollectionCnv_p2_test.cxx
index 67e4810d18a965ef533dab479b29c1ac3a011380..7b4a6f5ff7c5f115a76e3736d55a924732d6cf08 100644
--- a/MuonSpectrometer/MuonCnv/MuonEventTPCnv/test/CscSimDataCollectionCnv_p2_test.cxx
+++ b/MuonSpectrometer/MuonCnv/MuonEventTPCnv/test/CscSimDataCollectionCnv_p2_test.cxx
@@ -21,13 +21,14 @@
 #include "GeneratorObjectsTPCnv/initMcEventCollection.h"
 #include "AtlasHepMC/GenEvent.h"
 #include "AtlasHepMC/GenParticle.h"
+#include "AtlasHepMC/Operators.h"
 
 
 void compare (const HepMcParticleLink& p1,
               const HepMcParticleLink& p2)
 {
   assert ( p1.isValid() == p2.isValid() );
-  assert ( p1.barcode() == p2.barcode() );
+  assert ( HepMC::barcode(p1) == HepMC::barcode(p2) );
   assert ( p1.eventIndex() == p2.eventIndex() );
   assert ( p1.getEventCollectionAsChar() == p2.getEventCollectionAsChar() );
   assert ( p1.cptr() == p2.cptr() );
@@ -86,12 +87,12 @@ void testit (const CscSimDataCollection& trans1)
 }
 
 
-void test1(std::vector<HepMC::GenParticle*>& genPartVector)
+void test1(std::vector<HepMC::GenParticlePtr>& genPartVector)
 {
   std::cout << "test1\n";
-  const HepMC::GenParticle *particle = genPartVector.at(0);
+  auto particle = genPartVector.at(0);
   // Create HepMcParticleLink outside of leak check.
-  HepMcParticleLink dummyHMPL(particle->barcode(),particle->parent_event()->event_number());
+  HepMcParticleLink dummyHMPL(HepMC::barcode(particle),particle->parent_event()->event_number());
   assert(dummyHMPL.cptr()==particle);
   Athena_test::Leakcheck check;
 
@@ -116,7 +117,7 @@ void test1(std::vector<HepMC::GenParticle*>& genPartVector)
 int main()
 {
   ISvcLocator* pSvcLoc = nullptr;
-  std::vector<HepMC::GenParticle*> genPartVector;
+  std::vector<HepMC::GenParticlePtr> genPartVector;
   if (!Athena_test::initMcEventCollection(pSvcLoc,genPartVector)) {
     std::cerr << "This test can not be run" << std::endl;
     return 0;
diff --git a/MuonSpectrometer/MuonCnv/MuonEventTPCnv/test/MuonSimDataCnv_p1_test.cxx b/MuonSpectrometer/MuonCnv/MuonEventTPCnv/test/MuonSimDataCnv_p1_test.cxx
index 2906f2f7cb7d28453e7085c43ce247116fe86f85..d187fa5584b2c17e641c2e63a23bcb969851e801 100644
--- a/MuonSpectrometer/MuonCnv/MuonEventTPCnv/test/MuonSimDataCnv_p1_test.cxx
+++ b/MuonSpectrometer/MuonCnv/MuonEventTPCnv/test/MuonSimDataCnv_p1_test.cxx
@@ -21,13 +21,14 @@
 #include "GeneratorObjectsTPCnv/initMcEventCollection.h"
 #include "AtlasHepMC/GenEvent.h"
 #include "AtlasHepMC/GenParticle.h"
+#include "AtlasHepMC/Operators.h"
 
 
 void compare (const HepMcParticleLink& p1,
               const HepMcParticleLink& p2)
 {
   assert ( p1.isValid() == p2.isValid() );
-  assert ( p1.barcode() == p2.barcode() );
+  assert ( HepMC::barcode(p1) == HepMC::barcode(p2) );
   assert ( p1.eventIndex() == p2.eventIndex() );
   assert ( p1.getEventCollectionAsChar() == p2.getEventCollectionAsChar() );
   assert ( p1.cptr() == p2.cptr() );
@@ -72,12 +73,12 @@ void testit (const MuonSimData& trans1)
 }
 
 
-void test1(std::vector<HepMC::GenParticle*>& genPartVector)
+void test1(std::vector<HepMC::GenParticlePtr>& genPartVector)
 {
   std::cout << "test1\n";
-  const HepMC::GenParticle *particle = genPartVector.at(0);
+  auto particle = genPartVector.at(0);
   // Create HepMcParticleLink outside of leak check.
-  HepMcParticleLink dummyHMPL(particle->barcode(),particle->parent_event()->event_number());
+  HepMcParticleLink dummyHMPL(HepMC::barcode(particle),particle->parent_event()->event_number());
   assert(dummyHMPL.cptr()==particle);
   Athena_test::Leakcheck check;
 
@@ -97,7 +98,7 @@ void test1(std::vector<HepMC::GenParticle*>& genPartVector)
 int main()
 {
   ISvcLocator* pSvcLoc = nullptr;
-  std::vector<HepMC::GenParticle*> genPartVector;
+  std::vector<HepMC::GenParticlePtr> genPartVector;
   if (!Athena_test::initMcEventCollection(pSvcLoc,genPartVector)) {
     std::cerr << "This test can not be run" << std::endl;
     return 0;
diff --git a/MuonSpectrometer/MuonCnv/MuonEventTPCnv/test/MuonSimDataCnv_p2_test.cxx b/MuonSpectrometer/MuonCnv/MuonEventTPCnv/test/MuonSimDataCnv_p2_test.cxx
index f5d5414379f823210e9ef1439124a03556026172..f7aecbe23ed9503009c3dced46b4b7abc72d67b5 100644
--- a/MuonSpectrometer/MuonCnv/MuonEventTPCnv/test/MuonSimDataCnv_p2_test.cxx
+++ b/MuonSpectrometer/MuonCnv/MuonEventTPCnv/test/MuonSimDataCnv_p2_test.cxx
@@ -21,13 +21,14 @@
 #include "GeneratorObjectsTPCnv/initMcEventCollection.h"
 #include "AtlasHepMC/GenEvent.h"
 #include "AtlasHepMC/GenParticle.h"
+#include "AtlasHepMC/Operators.h"
 
 
 void compare (const HepMcParticleLink& p1,
               const HepMcParticleLink& p2)
 {
   assert ( p1.isValid() == p2.isValid() );
-  assert ( p1.barcode() == p2.barcode() );
+  assert ( HepMC::barcode(p1) == HepMC::barcode(p2) );
   assert ( p1.eventIndex() == p2.eventIndex() );
   assert ( p1.getEventCollectionAsChar() == p2.getEventCollectionAsChar() );
   assert ( p1.cptr() == p2.cptr() );
@@ -72,12 +73,12 @@ void testit (const MuonSimData& trans1)
 }
 
 
-void test1(std::vector<HepMC::GenParticle*>& genPartVector)
+void test1(std::vector<HepMC::GenParticlePtr>& genPartVector)
 {
   std::cout << "test1\n";
-  const HepMC::GenParticle *particle = genPartVector.at(0);
+  auto particle = genPartVector.at(0);
   // Create HepMcParticleLink outside of leak check.
-  HepMcParticleLink dummyHMPL(particle->barcode(),particle->parent_event()->event_number());
+  HepMcParticleLink dummyHMPL(HepMC::barcode(particle),particle->parent_event()->event_number());
   assert(dummyHMPL.cptr()==particle);
   Athena_test::Leakcheck check;
 
@@ -97,7 +98,7 @@ void test1(std::vector<HepMC::GenParticle*>& genPartVector)
 int main()
 {
   ISvcLocator* pSvcLoc = nullptr;
-  std::vector<HepMC::GenParticle*> genPartVector;
+  std::vector<HepMC::GenParticlePtr> genPartVector;
   if (!Athena_test::initMcEventCollection(pSvcLoc,genPartVector)) {
     std::cerr << "This test can not be run" << std::endl;
     return 0;
diff --git a/MuonSpectrometer/MuonCnv/MuonEventTPCnv/test/MuonSimDataCollectionCnv_p1_test.cxx b/MuonSpectrometer/MuonCnv/MuonEventTPCnv/test/MuonSimDataCollectionCnv_p1_test.cxx
index 0322e37738cf2129ba5f66ab2ad29bee7bee933d..934c930b845e34082d24a594449723b41d77324e 100644
--- a/MuonSpectrometer/MuonCnv/MuonEventTPCnv/test/MuonSimDataCollectionCnv_p1_test.cxx
+++ b/MuonSpectrometer/MuonCnv/MuonEventTPCnv/test/MuonSimDataCollectionCnv_p1_test.cxx
@@ -21,13 +21,14 @@
 #include "GeneratorObjectsTPCnv/initMcEventCollection.h"
 #include "AtlasHepMC/GenEvent.h"
 #include "AtlasHepMC/GenParticle.h"
+#include "AtlasHepMC/Operators.h"
 
 
 void compare (const HepMcParticleLink& p1,
               const HepMcParticleLink& p2)
 {
   assert ( p1.isValid() == p2.isValid() );
-  assert ( p1.barcode() == p2.barcode() );
+  assert ( HepMC::barcode(p1) == HepMC::barcode(p2) );
   assert ( p1.eventIndex() == p2.eventIndex() );
   assert ( p1.getEventCollectionAsChar() == p2.getEventCollectionAsChar() );
   assert ( p1.cptr() == p2.cptr() );
@@ -85,12 +86,12 @@ void testit (const MuonSimDataCollection& trans1)
 }
 
 
-void test1(std::vector<HepMC::GenParticle*>& genPartVector)
+void test1(std::vector<HepMC::GenParticlePtr>& genPartVector)
 {
   std::cout << "test1\n";
-  const HepMC::GenParticle *particle = genPartVector.at(0);
+  auto particle = genPartVector.at(0);
   // Create HepMcParticleLink outside of leak check.
-  HepMcParticleLink dummyHMPL(particle->barcode(),particle->parent_event()->event_number());
+  HepMcParticleLink dummyHMPL(HepMC::barcode(particle),particle->parent_event()->event_number());
   assert(dummyHMPL.cptr()==particle);
   Athena_test::Leakcheck check;
 
@@ -113,7 +114,7 @@ void test1(std::vector<HepMC::GenParticle*>& genPartVector)
 int main()
 {
   ISvcLocator* pSvcLoc = nullptr;
-  std::vector<HepMC::GenParticle*> genPartVector;
+  std::vector<HepMC::GenParticlePtr> genPartVector;
   if (!Athena_test::initMcEventCollection(pSvcLoc,genPartVector)) {
     std::cerr << "This test can not be run" << std::endl;
     return 0;
diff --git a/MuonSpectrometer/MuonCnv/MuonEventTPCnv/test/MuonSimDataCollectionCnv_p2_test.cxx b/MuonSpectrometer/MuonCnv/MuonEventTPCnv/test/MuonSimDataCollectionCnv_p2_test.cxx
index 254f3d286e67292f5847725815b8d465ec3b4e19..8fe08f09c68551ff0d88e84d6a1c015c5f539dd3 100644
--- a/MuonSpectrometer/MuonCnv/MuonEventTPCnv/test/MuonSimDataCollectionCnv_p2_test.cxx
+++ b/MuonSpectrometer/MuonCnv/MuonEventTPCnv/test/MuonSimDataCollectionCnv_p2_test.cxx
@@ -20,13 +20,14 @@
 #include "GeneratorObjectsTPCnv/initMcEventCollection.h"
 #include "AtlasHepMC/GenEvent.h"
 #include "AtlasHepMC/GenParticle.h"
+#include "AtlasHepMC/Operators.h"
 
 
 void compare (const HepMcParticleLink& p1,
               const HepMcParticleLink& p2)
 {
   assert ( p1.isValid() == p2.isValid() );
-  assert ( p1.barcode() == p2.barcode() );
+  assert ( HepMC::barcode(p1) == HepMC::barcode(p2) );
   assert ( p1.eventIndex() == p2.eventIndex() );
   assert ( p1.getEventCollectionAsChar() == p2.getEventCollectionAsChar() );
   assert ( p1.cptr() == p2.cptr() );
@@ -84,12 +85,12 @@ void testit (const MuonSimDataCollection& trans1)
 }
 
 
-void test1(std::vector<HepMC::GenParticle*>& genPartVector)
+void test1(std::vector<HepMC::GenParticlePtr>& genPartVector)
 {
   std::cout << "test1\n";
-  const HepMC::GenParticle *particle = genPartVector.at(0);
+  auto particle = genPartVector.at(0);
   // Create HepMcParticleLink outside of leak check.
-  HepMcParticleLink dummyHMPL(particle->barcode(),particle->parent_event()->event_number());
+  HepMcParticleLink dummyHMPL(HepMC::barcode(particle),particle->parent_event()->event_number());
   assert(dummyHMPL.cptr()==particle);
   Athena_test::Leakcheck check;
 
@@ -112,7 +113,7 @@ void test1(std::vector<HepMC::GenParticle*>& genPartVector)
 int main()
 {
   ISvcLocator* pSvcLoc = nullptr;
-  std::vector<HepMC::GenParticle*> genPartVector;
+  std::vector<HepMC::GenParticlePtr> genPartVector;
   if (!Athena_test::initMcEventCollection(pSvcLoc,genPartVector)) {
     std::cerr << "This test can not be run" << std::endl;
     return 0;
diff --git a/MuonSpectrometer/MuonCnv/MuonSimEventTPCnv/test/CSCSimHitCollectionCnv_p1_test.cxx b/MuonSpectrometer/MuonCnv/MuonSimEventTPCnv/test/CSCSimHitCollectionCnv_p1_test.cxx
index 74581857e190053df5061eea0e70514030ab43d1..129a44e60f44bbd1e12249b185dfd1ccf5f8da2a 100644
--- a/MuonSpectrometer/MuonCnv/MuonSimEventTPCnv/test/CSCSimHitCollectionCnv_p1_test.cxx
+++ b/MuonSpectrometer/MuonCnv/MuonSimEventTPCnv/test/CSCSimHitCollectionCnv_p1_test.cxx
@@ -20,13 +20,14 @@
 #include "GeneratorObjectsTPCnv/initMcEventCollection.h"
 #include "AtlasHepMC/GenEvent.h"
 #include "AtlasHepMC/GenParticle.h"
+#include "AtlasHepMC/Operators.h"
 
 
 void compare (const HepMcParticleLink& p1,
               const HepMcParticleLink& p2)
 {
   assert ( p1.isValid() == p2.isValid() );
-  assert ( p1.barcode() == p2.barcode() );
+  assert ( HepMC::barcode(p1) == HepMC::barcode(p2) );
   assert ( p1.eventIndex() == p2.eventIndex() );
   assert ( p1.getEventCollectionAsChar() == p2.getEventCollectionAsChar() );
   assert ( p1.cptr() == p2.cptr() );
@@ -79,12 +80,12 @@ int lundCode(int pdgid) {
   return -1;
 }
 
-void test1(std::vector<HepMC::GenParticle*>& genPartVector)
+void test1(std::vector<HepMC::GenParticlePtr>& genPartVector)
 {
   std::cout << "test1\n";
-  const HepMC::GenParticle *particle = genPartVector.at(0);
+  auto particle = genPartVector.at(0);
   // Create HepMcParticleLink outside of leak check.
-  HepMcParticleLink dummyHMPL(particle->barcode(),particle->parent_event()->event_number());
+  HepMcParticleLink dummyHMPL(HepMC::barcode(particle),particle->parent_event()->event_number());
   assert(dummyHMPL.cptr()==particle);
   // Create DVL info outside of leak check.
   CSCSimHitCollection dum ("coll");
@@ -92,8 +93,8 @@ void test1(std::vector<HepMC::GenParticle*>& genPartVector)
 
   CSCSimHitCollection trans1 ("coll");
   for (int i=0; i < 10; i++) {
-    const HepMC::GenParticle* pGenParticle = genPartVector.at(i);
-    HepMcParticleLink trkLink(pGenParticle->barcode(),pGenParticle->parent_event()->event_number());
+    auto pGenParticle = genPartVector.at(i);
+    HepMcParticleLink trkLink(HepMC::barcode(pGenParticle),pGenParticle->parent_event()->event_number());
     trans1.Emplace (123, 10.5, 11.5,
                     Amg::Vector3D (12.5, 13.5, 14.5),
                     Amg::Vector3D (15.5, 16.5, 17.5),
@@ -108,7 +109,7 @@ void test1(std::vector<HepMC::GenParticle*>& genPartVector)
 int main()
 {
   ISvcLocator* pSvcLoc = nullptr;
-  std::vector<HepMC::GenParticle*> genPartVector;
+  std::vector<HepMC::GenParticlePtr> genPartVector;
   if (!Athena_test::initMcEventCollection(pSvcLoc,genPartVector)) {
     std::cerr << "This test can not be run" << std::endl;
     return 0;
diff --git a/MuonSpectrometer/MuonCnv/MuonSimEventTPCnv/test/CSCSimHitCollectionCnv_p2_test.cxx b/MuonSpectrometer/MuonCnv/MuonSimEventTPCnv/test/CSCSimHitCollectionCnv_p2_test.cxx
index d34e3181f178c75b87c5304534462371c7762684..e7a6ac7cf931c9c37f8cd3934aff1394a277d96c 100644
--- a/MuonSpectrometer/MuonCnv/MuonSimEventTPCnv/test/CSCSimHitCollectionCnv_p2_test.cxx
+++ b/MuonSpectrometer/MuonCnv/MuonSimEventTPCnv/test/CSCSimHitCollectionCnv_p2_test.cxx
@@ -20,13 +20,14 @@
 #include "GeneratorObjectsTPCnv/initMcEventCollection.h"
 #include "AtlasHepMC/GenEvent.h"
 #include "AtlasHepMC/GenParticle.h"
+#include "AtlasHepMC/Operators.h"
 
 
 void compare (const HepMcParticleLink& p1,
               const HepMcParticleLink& p2)
 {
   assert ( p1.isValid() == p2.isValid() );
-  assert ( p1.barcode() == p2.barcode() );
+  assert ( HepMC::barcode(p1) == HepMC::barcode(p2) );
   assert ( p1.eventIndex() == p2.eventIndex() );
   assert ( p1.getEventCollectionAsChar() == p2.getEventCollectionAsChar() );
   assert ( p1.cptr() == p2.cptr() );
@@ -79,12 +80,12 @@ int lundCode(int pdgid) {
   return -1;
 }
 
-void test1(std::vector<HepMC::GenParticle*>& genPartVector)
+void test1(std::vector<HepMC::GenParticlePtr>& genPartVector)
 {
   std::cout << "test1\n";
-  const HepMC::GenParticle *particle = genPartVector.at(0);
+  auto particle = genPartVector.at(0);
   // Create HepMcParticleLink outside of leak check.
-  HepMcParticleLink dummyHMPL(particle->barcode(),particle->parent_event()->event_number());
+  HepMcParticleLink dummyHMPL(HepMC::barcode(particle),particle->parent_event()->event_number());
   assert(dummyHMPL.cptr()==particle);
   // Create DVL info outside of leak check.
   CSCSimHitCollection dum ("coll");
@@ -92,8 +93,8 @@ void test1(std::vector<HepMC::GenParticle*>& genPartVector)
 
   CSCSimHitCollection trans1 ("coll");
   for (int i=0; i < 10; i++) {
-    const HepMC::GenParticle* pGenParticle = genPartVector.at(i);
-    HepMcParticleLink trkLink(pGenParticle->barcode(),pGenParticle->parent_event()->event_number());
+    auto pGenParticle = genPartVector.at(i);
+    HepMcParticleLink trkLink(HepMC::barcode(pGenParticle),pGenParticle->parent_event()->event_number());
     trans1.Emplace (123, 10.5, 11.5,
                     Amg::Vector3D (12.5, 13.5, 14.5),
                     Amg::Vector3D (15.5, 16.5, 17.5),
@@ -108,7 +109,7 @@ void test1(std::vector<HepMC::GenParticle*>& genPartVector)
 int main()
 {
   ISvcLocator* pSvcLoc = nullptr;
-  std::vector<HepMC::GenParticle*> genPartVector;
+  std::vector<HepMC::GenParticlePtr> genPartVector;
   if (!Athena_test::initMcEventCollection(pSvcLoc,genPartVector)) {
     std::cerr << "This test can not be run" << std::endl;
     return 0;
diff --git a/MuonSpectrometer/MuonCnv/MuonSimEventTPCnv/test/CSCSimHitCollectionCnv_p3_test.cxx b/MuonSpectrometer/MuonCnv/MuonSimEventTPCnv/test/CSCSimHitCollectionCnv_p3_test.cxx
index d51aceac5cbb8f8c94e0666b252f1b1978d874c6..da252fd2cb808277e9e8f05f99995a2768e00d69 100644
--- a/MuonSpectrometer/MuonCnv/MuonSimEventTPCnv/test/CSCSimHitCollectionCnv_p3_test.cxx
+++ b/MuonSpectrometer/MuonCnv/MuonSimEventTPCnv/test/CSCSimHitCollectionCnv_p3_test.cxx
@@ -20,13 +20,14 @@
 #include "GeneratorObjectsTPCnv/initMcEventCollection.h"
 #include "AtlasHepMC/GenEvent.h"
 #include "AtlasHepMC/GenParticle.h"
+#include "AtlasHepMC/Operators.h"
 
 
 void compare (const HepMcParticleLink& p1,
               const HepMcParticleLink& p2)
 {
   assert ( p1.isValid() == p2.isValid() );
-  assert ( p1.barcode() == p2.barcode() );
+  assert ( HepMC::barcode(p1) == HepMC::barcode(p2) );
   assert ( p1.eventIndex() == p2.eventIndex() );
   assert ( p1.getEventCollectionAsChar() == p2.getEventCollectionAsChar() );
   assert ( p1.cptr() == p2.cptr() );
@@ -79,12 +80,12 @@ int lundCode(int pdgid) {
   return -1;
 }
 
-void test1(std::vector<HepMC::GenParticle*>& genPartVector)
+void test1(std::vector<HepMC::GenParticlePtr>& genPartVector)
 {
   std::cout << "test1\n";
-  const HepMC::GenParticle *particle = genPartVector.at(0);
+  auto particle = genPartVector.at(0);
   // Create HepMcParticleLink outside of leak check.
-  HepMcParticleLink dummyHMPL(particle->barcode(),particle->parent_event()->event_number());
+  HepMcParticleLink dummyHMPL(HepMC::barcode(particle),particle->parent_event()->event_number());
   assert(dummyHMPL.cptr()==particle);
   // Create DVL info outside of leak check.
   CSCSimHitCollection dum ("coll");
@@ -92,8 +93,8 @@ void test1(std::vector<HepMC::GenParticle*>& genPartVector)
 
   CSCSimHitCollection trans1 ("coll");
   for (int i=0; i < 10; i++) {
-    const HepMC::GenParticle* pGenParticle = genPartVector.at(i);
-    HepMcParticleLink trkLink(pGenParticle->barcode(),pGenParticle->parent_event()->event_number());
+    auto pGenParticle = genPartVector.at(i);
+    HepMcParticleLink trkLink(HepMC::barcode(pGenParticle),pGenParticle->parent_event()->event_number());
     trans1.Emplace (123, 10.5, 11.5,
                     Amg::Vector3D (12.5, 13.5, 14.5),
                     Amg::Vector3D (15.5, 16.5, 17.5),
@@ -108,7 +109,7 @@ void test1(std::vector<HepMC::GenParticle*>& genPartVector)
 int main()
 {
   ISvcLocator* pSvcLoc = nullptr;
-  std::vector<HepMC::GenParticle*> genPartVector;
+  std::vector<HepMC::GenParticlePtr> genPartVector;
   if (!Athena_test::initMcEventCollection(pSvcLoc,genPartVector)) {
     std::cerr << "This test can not be run" << std::endl;
     return 0;
diff --git a/MuonSpectrometer/MuonCnv/MuonSimEventTPCnv/test/GenericMuonSimHitCollectionCnv_p1_test.cxx b/MuonSpectrometer/MuonCnv/MuonSimEventTPCnv/test/GenericMuonSimHitCollectionCnv_p1_test.cxx
index b589febcc606cd79c74f1b8438f5c985c5db0690..c2c3f8c620194a9be9de779e6741aaef3299a888 100644
--- a/MuonSpectrometer/MuonCnv/MuonSimEventTPCnv/test/GenericMuonSimHitCollectionCnv_p1_test.cxx
+++ b/MuonSpectrometer/MuonCnv/MuonSimEventTPCnv/test/GenericMuonSimHitCollectionCnv_p1_test.cxx
@@ -20,13 +20,14 @@
 #include "GeneratorObjectsTPCnv/initMcEventCollection.h"
 #include "AtlasHepMC/GenEvent.h"
 #include "AtlasHepMC/GenParticle.h"
+#include "AtlasHepMC/Operators.h"
 
 
 void compare (const HepMcParticleLink& p1,
               const HepMcParticleLink& p2)
 {
   assert ( p1.isValid() == p2.isValid() );
-  assert ( p1.barcode() == p2.barcode() );
+  assert ( HepMC::barcode(p1) == HepMC::barcode(p2) );
   assert ( p1.eventIndex() == p2.eventIndex() );
   assert ( p1.getEventCollectionAsChar() == p2.getEventCollectionAsChar() );
   assert ( p1.cptr() == p2.cptr() );
@@ -76,12 +77,12 @@ void testit (const GenericMuonSimHitCollection& trans1)
 }
 
 
-void test1(std::vector<HepMC::GenParticle*> genPartVector)
+void test1(std::vector<HepMC::GenParticlePtr> genPartVector)
 {
   std::cout << "test1\n";
-  const HepMC::GenParticle *particle = genPartVector.at(0);
+  auto particle = genPartVector.at(0);
   // Create HepMcParticleLink outside of leak check.
-  HepMcParticleLink dummyHMPL(particle->barcode(),particle->parent_event()->event_number());
+  HepMcParticleLink dummyHMPL(HepMC::barcode(particle),particle->parent_event()->event_number());
   assert(dummyHMPL.cptr()==particle);
   // Create DVL info outside of leak check.
   GenericMuonSimHitCollection dum ("coll");
@@ -89,8 +90,8 @@ void test1(std::vector<HepMC::GenParticle*> genPartVector)
 
   GenericMuonSimHitCollection trans1 ("coll");
   for (int i=0; i < 10; i++) {
-    const HepMC::GenParticle* pGenParticle = genPartVector.at(i);
-    HepMcParticleLink trkLink(pGenParticle->barcode(),pGenParticle->parent_event()->event_number());
+    auto pGenParticle = genPartVector.at(i);
+    HepMcParticleLink trkLink(HepMC::barcode(pGenParticle),pGenParticle->parent_event()->event_number());
     trans1.Emplace (123, 10.5, 11.5,
                     Amg::Vector3D (12.5, 13.5, 14.5),
                     Amg::Vector3D (15.5, 16.5, 17.5),
@@ -109,7 +110,7 @@ void test1(std::vector<HepMC::GenParticle*> genPartVector)
 int main()
 {
   ISvcLocator* pSvcLoc = nullptr;
-  std::vector<HepMC::GenParticle*> genPartVector;
+  std::vector<HepMC::GenParticlePtr> genPartVector;
   if (!Athena_test::initMcEventCollection(pSvcLoc,genPartVector)) {
     std::cerr << "This test can not be run" << std::endl;
     return 0;
diff --git a/MuonSpectrometer/MuonCnv/MuonSimEventTPCnv/test/GenericMuonSimHitCollectionCnv_p2_test.cxx b/MuonSpectrometer/MuonCnv/MuonSimEventTPCnv/test/GenericMuonSimHitCollectionCnv_p2_test.cxx
index bdbc5fea4a4178471cfce0d7d422c229265cb1db..88878550f96a397ad1507f298e646964d36aa983 100644
--- a/MuonSpectrometer/MuonCnv/MuonSimEventTPCnv/test/GenericMuonSimHitCollectionCnv_p2_test.cxx
+++ b/MuonSpectrometer/MuonCnv/MuonSimEventTPCnv/test/GenericMuonSimHitCollectionCnv_p2_test.cxx
@@ -20,12 +20,13 @@
 #include "GeneratorObjectsTPCnv/initMcEventCollection.h"
 #include "AtlasHepMC/GenEvent.h"
 #include "AtlasHepMC/GenParticle.h"
+#include "AtlasHepMC/Operators.h"
 
 void compare (const HepMcParticleLink& p1,
               const HepMcParticleLink& p2)
 {
   assert ( p1.isValid() == p2.isValid() );
-  assert ( p1.barcode() == p2.barcode() );
+  assert ( HepMC::barcode(p1) == HepMC::barcode(p2) );
   assert ( p1.eventIndex() == p2.eventIndex() );
   assert ( p1.getEventCollectionAsChar() == p2.getEventCollectionAsChar() );
   assert ( p1.cptr() == p2.cptr() );
@@ -75,20 +76,20 @@ void testit (const GenericMuonSimHitCollection& trans1)
 }
 
 
-void test1(std::vector<HepMC::GenParticle*> genPartVector)
+void test1(std::vector<HepMC::GenParticlePtr> genPartVector)
 {
   std::cout << "test1\n";
-  const HepMC::GenParticle *particle = genPartVector.at(0);
+  auto particle = genPartVector.at(0);
   // Create HepMcParticleLink outside of leak check.
-  HepMcParticleLink dummyHMPL(particle->barcode(),particle->parent_event()->event_number());
+  HepMcParticleLink dummyHMPL(HepMC::barcode(particle),particle->parent_event()->event_number());
   assert(dummyHMPL.cptr()==particle);
   // Create DVL info outside of leak check.
   GenericMuonSimHitCollection dum ("coll");
 
   GenericMuonSimHitCollection trans1 ("coll");
   for (int i=0; i < 10; i++) {
-    const HepMC::GenParticle* pGenParticle = genPartVector.at(i);
-    HepMcParticleLink trkLink(pGenParticle->barcode(),pGenParticle->parent_event()->event_number());
+    auto pGenParticle = genPartVector.at(i);
+    HepMcParticleLink trkLink(HepMC::barcode(pGenParticle),pGenParticle->parent_event()->event_number());
     trans1.Emplace (123, 10.5, 11.5,
                     Amg::Vector3D (12.5, 13.5, 14.5),
                     Amg::Vector3D (15.5, 16.5, 17.5),
@@ -107,7 +108,7 @@ void test1(std::vector<HepMC::GenParticle*> genPartVector)
 int main()
 {
   ISvcLocator* pSvcLoc = nullptr;
-  std::vector<HepMC::GenParticle*> genPartVector;
+  std::vector<HepMC::GenParticlePtr> genPartVector;
   if (!Athena_test::initMcEventCollection(pSvcLoc,genPartVector)) {
     std::cerr << "This test can not be run" << std::endl;
     return 0;
diff --git a/MuonSpectrometer/MuonCnv/MuonSimEventTPCnv/test/MDTSimHitCollectionCnv_p1_test.cxx b/MuonSpectrometer/MuonCnv/MuonSimEventTPCnv/test/MDTSimHitCollectionCnv_p1_test.cxx
index 6974a3d2d7690a5b7d19f41ba3a76e2b69cc97c9..0b1b34bbf3bcf87b73f5e4405787a9da9dd893ae 100644
--- a/MuonSpectrometer/MuonCnv/MuonSimEventTPCnv/test/MDTSimHitCollectionCnv_p1_test.cxx
+++ b/MuonSpectrometer/MuonCnv/MuonSimEventTPCnv/test/MDTSimHitCollectionCnv_p1_test.cxx
@@ -20,13 +20,14 @@
 #include "GeneratorObjectsTPCnv/initMcEventCollection.h"
 #include "AtlasHepMC/GenEvent.h"
 #include "AtlasHepMC/GenParticle.h"
+#include "AtlasHepMC/Operators.h"
 
 
 void compare (const HepMcParticleLink& p1,
               const HepMcParticleLink& p2)
 {
   assert ( p1.isValid() == p2.isValid() );
-  assert ( p1.barcode() == p2.barcode() );
+  assert ( HepMC::barcode(p1) == HepMC::barcode(p2) );
   assert ( p1.eventIndex() == p2.eventIndex() );
   assert ( p1.getEventCollectionAsChar() == p2.getEventCollectionAsChar() );
   assert ( p1.cptr() == p2.cptr() );
@@ -72,12 +73,12 @@ void testit (const MDTSimHitCollection& trans1)
 }
 
 
-void test1(std::vector<HepMC::GenParticle*> genPartVector)
+void test1(std::vector<HepMC::GenParticlePtr> genPartVector)
 {
   std::cout << "test1\n";
-  const HepMC::GenParticle *particle = genPartVector.at(0);
+  auto particle = genPartVector.at(0);
   // Create HepMcParticleLink outside of leak check.
-  HepMcParticleLink dummyHMPL(particle->barcode(),particle->parent_event()->event_number());
+  HepMcParticleLink dummyHMPL(HepMC::barcode(particle),particle->parent_event()->event_number());
   assert(dummyHMPL.cptr()==particle);
   // Create DVL info outside of leak check.
   MDTSimHitCollection dum ("coll");
@@ -85,8 +86,8 @@ void test1(std::vector<HepMC::GenParticle*> genPartVector)
 
   MDTSimHitCollection trans1 ("coll");
   for (int i=0; i < 10; i++) {
-    const HepMC::GenParticle* pGenParticle = genPartVector.at(i);
-    HepMcParticleLink trkLink(pGenParticle->barcode(),pGenParticle->parent_event()->event_number());
+    auto pGenParticle = genPartVector.at(i);
+    HepMcParticleLink trkLink(HepMC::barcode(pGenParticle),pGenParticle->parent_event()->event_number());
     trans1.Emplace (123, 10.5, 11.5,
                     Amg::Vector3D (12.5, 13.5, 14.5),
                     trkLink, 19.5, 20.5, pGenParticle->pdg_id(), 22.5
@@ -100,7 +101,7 @@ void test1(std::vector<HepMC::GenParticle*> genPartVector)
 int main()
 {
   ISvcLocator* pSvcLoc = nullptr;
-  std::vector<HepMC::GenParticle*> genPartVector;
+  std::vector<HepMC::GenParticlePtr> genPartVector;
   if (!Athena_test::initMcEventCollection(pSvcLoc,genPartVector)) {
     std::cerr << "This test can not be run" << std::endl;
     return 0;
diff --git a/MuonSpectrometer/MuonCnv/MuonSimEventTPCnv/test/MDTSimHitCollectionCnv_p2_test.cxx b/MuonSpectrometer/MuonCnv/MuonSimEventTPCnv/test/MDTSimHitCollectionCnv_p2_test.cxx
index 707804a41465c8c30bc50b4e40be22fe20b03181..8de459f98c50bd380dd1b769bde50509f8a9937f 100644
--- a/MuonSpectrometer/MuonCnv/MuonSimEventTPCnv/test/MDTSimHitCollectionCnv_p2_test.cxx
+++ b/MuonSpectrometer/MuonCnv/MuonSimEventTPCnv/test/MDTSimHitCollectionCnv_p2_test.cxx
@@ -20,13 +20,14 @@
 #include "GeneratorObjectsTPCnv/initMcEventCollection.h"
 #include "AtlasHepMC/GenEvent.h"
 #include "AtlasHepMC/GenParticle.h"
+#include "AtlasHepMC/Operators.h"
 
 
 void compare (const HepMcParticleLink& p1,
               const HepMcParticleLink& p2)
 {
   assert ( p1.isValid() == p2.isValid() );
-  assert ( p1.barcode() == p2.barcode() );
+  assert ( HepMC::barcode(p1) == HepMC::barcode(p2) );
   assert ( p1.eventIndex() == p2.eventIndex() );
   assert ( p1.getEventCollectionAsChar() == p2.getEventCollectionAsChar() );
   assert ( p1.cptr() == p2.cptr() );
@@ -72,12 +73,12 @@ void testit (const MDTSimHitCollection& trans1)
 }
 
 
-void test1(std::vector<HepMC::GenParticle*> genPartVector)
+void test1(std::vector<HepMC::GenParticlePtr> genPartVector)
 {
   std::cout << "test1\n";
-  const HepMC::GenParticle *particle = genPartVector.at(0);
+  auto particle = genPartVector.at(0);
   // Create HepMcParticleLink outside of leak check.
-  HepMcParticleLink dummyHMPL(particle->barcode(),particle->parent_event()->event_number());
+  HepMcParticleLink dummyHMPL(HepMC::barcode(particle),particle->parent_event()->event_number());
   assert(dummyHMPL.cptr()==particle);
   // Create DVL info outside of leak check.
   MDTSimHitCollection dum ("coll");
@@ -85,8 +86,8 @@ void test1(std::vector<HepMC::GenParticle*> genPartVector)
 
   MDTSimHitCollection trans1 ("coll");
   for (int i=0; i < 10; i++) {
-    const HepMC::GenParticle* pGenParticle = genPartVector.at(i);
-    HepMcParticleLink trkLink(pGenParticle->barcode(),pGenParticle->parent_event()->event_number());
+    auto pGenParticle = genPartVector.at(i);
+    HepMcParticleLink trkLink(HepMC::barcode(pGenParticle),pGenParticle->parent_event()->event_number());
     trans1.Emplace (123, 10.5, 11.5,
                     Amg::Vector3D (12.5, 13.5, 14.5),
                     trkLink, 19.5, 20.5, pGenParticle->pdg_id(), 22.5
@@ -100,7 +101,7 @@ void test1(std::vector<HepMC::GenParticle*> genPartVector)
 int main()
 {
   ISvcLocator* pSvcLoc = nullptr;
-  std::vector<HepMC::GenParticle*> genPartVector;
+  std::vector<HepMC::GenParticlePtr> genPartVector;
   if (!Athena_test::initMcEventCollection(pSvcLoc,genPartVector)) {
     std::cerr << "This test can not be run" << std::endl;
     return 0;
diff --git a/MuonSpectrometer/MuonCnv/MuonSimEventTPCnv/test/MDTSimHitCollectionCnv_p3_test.cxx b/MuonSpectrometer/MuonCnv/MuonSimEventTPCnv/test/MDTSimHitCollectionCnv_p3_test.cxx
index f950056fef192bdbb3a701178bd1480ddd5dc584..ee49e801a60972a56f5529f88ab1a761cd13d445 100644
--- a/MuonSpectrometer/MuonCnv/MuonSimEventTPCnv/test/MDTSimHitCollectionCnv_p3_test.cxx
+++ b/MuonSpectrometer/MuonCnv/MuonSimEventTPCnv/test/MDTSimHitCollectionCnv_p3_test.cxx
@@ -20,13 +20,14 @@
 #include "GeneratorObjectsTPCnv/initMcEventCollection.h"
 #include "AtlasHepMC/GenEvent.h"
 #include "AtlasHepMC/GenParticle.h"
+#include "AtlasHepMC/Operators.h"
 
 
 void compare (const HepMcParticleLink& p1,
               const HepMcParticleLink& p2)
 {
   assert ( p1.isValid() == p2.isValid() );
-  assert ( p1.barcode() == p2.barcode() );
+  assert ( HepMC::barcode(p1) == HepMC::barcode(p2) );
   assert ( p1.eventIndex() == p2.eventIndex() );
   assert ( p1.getEventCollectionAsChar() == p2.getEventCollectionAsChar() );
   assert ( p1.cptr() == p2.cptr() );
@@ -72,12 +73,12 @@ void testit (const MDTSimHitCollection& trans1)
 }
 
 
-void test1(std::vector<HepMC::GenParticle*> genPartVector)
+void test1(std::vector<HepMC::GenParticlePtr> genPartVector)
 {
   std::cout << "test1\n";
-  const HepMC::GenParticle *particle = genPartVector.at(0);
+  auto particle = genPartVector.at(0);
   // Create HepMcParticleLink outside of leak check.
-  HepMcParticleLink dummyHMPL(particle->barcode(),particle->parent_event()->event_number());
+  HepMcParticleLink dummyHMPL(HepMC::barcode(particle),particle->parent_event()->event_number());
   assert(dummyHMPL.cptr()==particle);
   // Create DVL info outside of leak check.
   MDTSimHitCollection dum ("coll");
@@ -85,8 +86,8 @@ void test1(std::vector<HepMC::GenParticle*> genPartVector)
 
   MDTSimHitCollection trans1 ("coll");
   for (int i=0; i < 10; i++) {
-    const HepMC::GenParticle* pGenParticle = genPartVector.at(i);
-    HepMcParticleLink trkLink(pGenParticle->barcode(),pGenParticle->parent_event()->event_number());
+    auto pGenParticle = genPartVector.at(i);
+    HepMcParticleLink trkLink(HepMC::barcode(pGenParticle),pGenParticle->parent_event()->event_number());
     trans1.Emplace (123, 10.5, 11.5,
                     Amg::Vector3D (12.5, 13.5, 14.5),
                     trkLink, 19.5, 20.5, pGenParticle->pdg_id(), 22.5
@@ -100,7 +101,7 @@ void test1(std::vector<HepMC::GenParticle*> genPartVector)
 int main()
 {
   ISvcLocator* pSvcLoc = nullptr;
-  std::vector<HepMC::GenParticle*> genPartVector;
+  std::vector<HepMC::GenParticlePtr> genPartVector;
   if (!Athena_test::initMcEventCollection(pSvcLoc,genPartVector)) {
     std::cerr << "This test can not be run" << std::endl;
     return 0;
diff --git a/MuonSpectrometer/MuonCnv/MuonSimEventTPCnv/test/MMSimHitCollectionCnv_p1_test.cxx b/MuonSpectrometer/MuonCnv/MuonSimEventTPCnv/test/MMSimHitCollectionCnv_p1_test.cxx
index e603cdd6dac158af75be82fc9328658bde27dd32..ad0bd4da5199ea88a3d14e5397dd930af9cdf202 100644
--- a/MuonSpectrometer/MuonCnv/MuonSimEventTPCnv/test/MMSimHitCollectionCnv_p1_test.cxx
+++ b/MuonSpectrometer/MuonCnv/MuonSimEventTPCnv/test/MMSimHitCollectionCnv_p1_test.cxx
@@ -11,13 +11,14 @@
 #include "GeneratorObjectsTPCnv/initMcEventCollection.h"
 #include "AtlasHepMC/GenEvent.h"
 #include "AtlasHepMC/GenParticle.h"
+#include "AtlasHepMC/Operators.h"
 
 
 void compare (const HepMcParticleLink& p1,
               const HepMcParticleLink& p2)
 {
   assert ( p1.isValid() == p2.isValid() );
-  assert ( p1.barcode() == p2.barcode() );
+  assert ( HepMC::barcode(p1) == HepMC::barcode(p2) );
   assert ( p1.eventIndex() == p2.eventIndex() );
   assert ( p1.cptr() == p2.cptr() );
   assert ( p1 == p2 );
@@ -61,20 +62,20 @@ void testit (const MMSimHitCollection& trans1)
 }
 
 
-void test1(std::vector<HepMC::GenParticle*> genPartVector)
+void test1(std::vector<HepMC::GenParticlePtr> genPartVector)
 {
   std::cout << "test1\n";
-  const HepMC::GenParticle *particle = genPartVector.at(0);
+  auto particle = genPartVector.at(0);
   // Create HepMcParticleLink outside of leak check.
-  HepMcParticleLink dummyHMPL(particle->barcode(),particle->parent_event()->event_number());
+  HepMcParticleLink dummyHMPL(HepMC::barcode(particle),particle->parent_event()->event_number());
   assert(dummyHMPL.cptr()==particle);
   // Create DVL info outside of leak check.
   MMSimHitCollection dum ("coll");
 
   MMSimHitCollection trans1 ("coll");
   for (int i=0; i < 10; i++) {
-    const HepMC::GenParticle* pGenParticle = genPartVector.at(i);
-    HepMcParticleLink trkLink(pGenParticle->barcode(),pGenParticle->parent_event()->event_number());
+    auto pGenParticle = genPartVector.at(i);
+    HepMcParticleLink trkLink(HepMC::barcode(pGenParticle),pGenParticle->parent_event()->event_number());
     trans1.Emplace (123, 10.5,
                     Amg::Vector3D (12.5, 13.5, 14.5),
                     pGenParticle->pdg_id(), 25.5,
@@ -90,7 +91,7 @@ void test1(std::vector<HepMC::GenParticle*> genPartVector)
 int main()
 {
   ISvcLocator* pSvcLoc = nullptr;
-  std::vector<HepMC::GenParticle*> genPartVector;
+  std::vector<HepMC::GenParticlePtr> genPartVector;
   if (!Athena_test::initMcEventCollection(pSvcLoc,genPartVector)) {
     std::cerr << "This test can not be run" << std::endl;
     return 0;
diff --git a/MuonSpectrometer/MuonCnv/MuonSimEventTPCnv/test/MMSimHitCollectionCnv_p2_test.cxx b/MuonSpectrometer/MuonCnv/MuonSimEventTPCnv/test/MMSimHitCollectionCnv_p2_test.cxx
index 61e692d54997052c6f0278dd0ef61768bc61d7d0..f8a1928911ed0966c286b5258f9cd5eda23f97f5 100644
--- a/MuonSpectrometer/MuonCnv/MuonSimEventTPCnv/test/MMSimHitCollectionCnv_p2_test.cxx
+++ b/MuonSpectrometer/MuonCnv/MuonSimEventTPCnv/test/MMSimHitCollectionCnv_p2_test.cxx
@@ -11,12 +11,13 @@
 #include "GeneratorObjectsTPCnv/initMcEventCollection.h"
 #include "AtlasHepMC/GenEvent.h"
 #include "AtlasHepMC/GenParticle.h"
+#include "AtlasHepMC/Operators.h"
 
 void compare (const HepMcParticleLink& p1,
               const HepMcParticleLink& p2)
 {
   assert ( p1.isValid() == p2.isValid() );
-  assert ( p1.barcode() == p2.barcode() );
+  assert ( HepMC::barcode(p1) == HepMC::barcode(p2) );
   assert ( p1.eventIndex() == p2.eventIndex() );
   assert ( p1.cptr() == p2.cptr() );
   assert ( p1 == p2 );
@@ -60,20 +61,20 @@ void testit (const MMSimHitCollection& trans1)
 }
 
 
-void test1(std::vector<HepMC::GenParticle*> genPartVector)
+void test1(std::vector<HepMC::GenParticlePtr> genPartVector)
 {
   std::cout << "test1\n";
-  const HepMC::GenParticle *particle = genPartVector.at(0);
+  auto particle = genPartVector.at(0);
   // Create HepMcParticleLink outside of leak check.
-  HepMcParticleLink dummyHMPL(particle->barcode(),particle->parent_event()->event_number());
+  HepMcParticleLink dummyHMPL(HepMC::barcode(particle),particle->parent_event()->event_number());
   assert(dummyHMPL.cptr()==particle);
   // Create DVL info outside of leak check.
   MMSimHitCollection dum ("coll");
 
   MMSimHitCollection trans1 ("coll");
   for (int i=0; i < 10; i++) {
-    const HepMC::GenParticle* pGenParticle = genPartVector.at(i);
-    HepMcParticleLink trkLink(pGenParticle->barcode(),pGenParticle->parent_event()->event_number());
+    auto pGenParticle = genPartVector.at(i);
+    HepMcParticleLink trkLink(HepMC::barcode(pGenParticle),pGenParticle->parent_event()->event_number());
     trans1.Emplace (123, 10.5,
                     Amg::Vector3D (12.5, 13.5, 14.5),
                     pGenParticle->pdg_id(), 25.5,
@@ -89,7 +90,7 @@ void test1(std::vector<HepMC::GenParticle*> genPartVector)
 int main()
 {
   ISvcLocator* pSvcLoc = nullptr;
-  std::vector<HepMC::GenParticle*> genPartVector;
+  std::vector<HepMC::GenParticlePtr> genPartVector;
   if (!Athena_test::initMcEventCollection(pSvcLoc,genPartVector)) {
     std::cerr << "This test can not be run" << std::endl;
     return 0;
diff --git a/MuonSpectrometer/MuonCnv/MuonSimEventTPCnv/test/RPCSimHitCollectionCnv_p1_test.cxx b/MuonSpectrometer/MuonCnv/MuonSimEventTPCnv/test/RPCSimHitCollectionCnv_p1_test.cxx
index 75bff7a15b74d7ad237c54218e4143eccf5ef86a..bb6dd64cf098010ae789fdaa0490173eaf201822 100644
--- a/MuonSpectrometer/MuonCnv/MuonSimEventTPCnv/test/RPCSimHitCollectionCnv_p1_test.cxx
+++ b/MuonSpectrometer/MuonCnv/MuonSimEventTPCnv/test/RPCSimHitCollectionCnv_p1_test.cxx
@@ -20,13 +20,14 @@
 #include "GeneratorObjectsTPCnv/initMcEventCollection.h"
 #include "AtlasHepMC/GenEvent.h"
 #include "AtlasHepMC/GenParticle.h"
+#include "AtlasHepMC/Operators.h"
 
 
 void compare (const HepMcParticleLink& p1,
               const HepMcParticleLink& p2)
 {
   assert ( p1.isValid() == p2.isValid() );
-  assert ( p1.barcode() == p2.barcode() );
+  assert ( HepMC::barcode(p1) == HepMC::barcode(p2) );
   assert ( p1.eventIndex() == p2.eventIndex() );
   assert ( p1.getEventCollectionAsChar() == p2.getEventCollectionAsChar() );
   assert ( p1.cptr() == p2.cptr() );
@@ -72,12 +73,12 @@ void testit (const RPCSimHitCollection& trans1)
 }
 
 
-void test1(std::vector<HepMC::GenParticle*> genPartVector)
+void test1(std::vector<HepMC::GenParticlePtr> genPartVector)
 {
   std::cout << "test1\n";
-  const HepMC::GenParticle *particle = genPartVector.at(0);
+  auto particle = genPartVector.at(0);
   // Create HepMcParticleLink outside of leak check.
-  HepMcParticleLink dummyHMPL(particle->barcode(),particle->parent_event()->event_number());
+  HepMcParticleLink dummyHMPL(HepMC::barcode(particle),particle->parent_event()->event_number());
   assert(dummyHMPL.cptr()==particle);
   // Create DVL info outside of leak check.
   RPCSimHitCollection dum ("coll");
@@ -85,8 +86,8 @@ void test1(std::vector<HepMC::GenParticle*> genPartVector)
 
   RPCSimHitCollection trans1 ("coll");
   for (int i=0; i < 10; i++) {
-    const HepMC::GenParticle* pGenParticle = genPartVector.at(i);
-    HepMcParticleLink trkLink(pGenParticle->barcode(),pGenParticle->parent_event()->event_number());
+    auto pGenParticle = genPartVector.at(i);
+    HepMcParticleLink trkLink(HepMC::barcode(pGenParticle),pGenParticle->parent_event()->event_number());
     trans1.Emplace (123, 10.5,
                     Amg::Vector3D (12.5, 13.5, 14.5),
                     trkLink,
@@ -101,7 +102,7 @@ void test1(std::vector<HepMC::GenParticle*> genPartVector)
 int main()
 {
   ISvcLocator* pSvcLoc = nullptr;
-  std::vector<HepMC::GenParticle*> genPartVector;
+  std::vector<HepMC::GenParticlePtr> genPartVector;
   if (!Athena_test::initMcEventCollection(pSvcLoc,genPartVector)) {
     std::cerr << "This test can not be run" << std::endl;
     return 0;
diff --git a/MuonSpectrometer/MuonCnv/MuonSimEventTPCnv/test/RPCSimHitCollectionCnv_p2_test.cxx b/MuonSpectrometer/MuonCnv/MuonSimEventTPCnv/test/RPCSimHitCollectionCnv_p2_test.cxx
index c6405032b2ada47e60c034dc1a18870f3695330e..065f1c92f68d4e1ad4ebd746482590ccf0c3d9c7 100644
--- a/MuonSpectrometer/MuonCnv/MuonSimEventTPCnv/test/RPCSimHitCollectionCnv_p2_test.cxx
+++ b/MuonSpectrometer/MuonCnv/MuonSimEventTPCnv/test/RPCSimHitCollectionCnv_p2_test.cxx
@@ -20,13 +20,14 @@
 #include "GeneratorObjectsTPCnv/initMcEventCollection.h"
 #include "AtlasHepMC/GenEvent.h"
 #include "AtlasHepMC/GenParticle.h"
+#include "AtlasHepMC/Operators.h"
 
 
 void compare (const HepMcParticleLink& p1,
               const HepMcParticleLink& p2)
 {
   assert ( p1.isValid() == p2.isValid() );
-  assert ( p1.barcode() == p2.barcode() );
+  assert ( HepMC::barcode(p1) == HepMC::barcode(p2) );
   assert ( p1.eventIndex() == p2.eventIndex() );
   assert ( p1.getEventCollectionAsChar() == p2.getEventCollectionAsChar() );
   assert ( p1.cptr() == p2.cptr() );
@@ -72,12 +73,12 @@ void testit (const RPCSimHitCollection& trans1)
 }
 
 
-void test1(std::vector<HepMC::GenParticle*> genPartVector)
+void test1(std::vector<HepMC::GenParticlePtr> genPartVector)
 {
   std::cout << "test1\n";
-  const HepMC::GenParticle *particle = genPartVector.at(0);
+  auto particle = genPartVector.at(0);
   // Create HepMcParticleLink outside of leak check.
-  HepMcParticleLink dummyHMPL(particle->barcode(),particle->parent_event()->event_number());
+  HepMcParticleLink dummyHMPL(HepMC::barcode(particle),particle->parent_event()->event_number());
   assert(dummyHMPL.cptr()==particle);
   // Create DVL info outside of leak check.
   RPCSimHitCollection dum ("coll");
@@ -85,8 +86,8 @@ void test1(std::vector<HepMC::GenParticle*> genPartVector)
 
   RPCSimHitCollection trans1 ("coll");
   for (int i=0; i < 10; i++) {
-    const HepMC::GenParticle* pGenParticle = genPartVector.at(i);
-    HepMcParticleLink trkLink(pGenParticle->barcode(),pGenParticle->parent_event()->event_number());
+    auto pGenParticle = genPartVector.at(i);
+    HepMcParticleLink trkLink(HepMC::barcode(pGenParticle),pGenParticle->parent_event()->event_number());
     trans1.Emplace (123, 10.5,
                     Amg::Vector3D (12.5, 13.5, 14.5),
                     trkLink,
@@ -101,7 +102,7 @@ void test1(std::vector<HepMC::GenParticle*> genPartVector)
 int main()
 {
   ISvcLocator* pSvcLoc = nullptr;
-  std::vector<HepMC::GenParticle*> genPartVector;
+  std::vector<HepMC::GenParticlePtr> genPartVector;
   if (!Athena_test::initMcEventCollection(pSvcLoc,genPartVector)) {
     std::cerr << "This test can not be run" << std::endl;
     return 0;
diff --git a/MuonSpectrometer/MuonCnv/MuonSimEventTPCnv/test/RPCSimHitCollectionCnv_p3_test.cxx b/MuonSpectrometer/MuonCnv/MuonSimEventTPCnv/test/RPCSimHitCollectionCnv_p3_test.cxx
index d29f0905b5de2a765de6745ded524be328c864a5..144a75018a451269c421d13b26a29924cacbdc7f 100644
--- a/MuonSpectrometer/MuonCnv/MuonSimEventTPCnv/test/RPCSimHitCollectionCnv_p3_test.cxx
+++ b/MuonSpectrometer/MuonCnv/MuonSimEventTPCnv/test/RPCSimHitCollectionCnv_p3_test.cxx
@@ -20,13 +20,14 @@
 #include "GeneratorObjectsTPCnv/initMcEventCollection.h"
 #include "AtlasHepMC/GenEvent.h"
 #include "AtlasHepMC/GenParticle.h"
+#include "AtlasHepMC/Operators.h"
 
 
 void compare (const HepMcParticleLink& p1,
               const HepMcParticleLink& p2)
 {
   assert ( p1.isValid() == p2.isValid() );
-  assert ( p1.barcode() == p2.barcode() );
+  assert ( HepMC::barcode(p1) == HepMC::barcode(p2) );
   assert ( p1.eventIndex() == p2.eventIndex() );
   assert ( p1.getEventCollectionAsChar() == p2.getEventCollectionAsChar() );
   assert ( p1.cptr() == p2.cptr() );
@@ -72,12 +73,12 @@ void testit (const RPCSimHitCollection& trans1)
 }
 
 
-void test1(std::vector<HepMC::GenParticle*> genPartVector)
+void test1(std::vector<HepMC::GenParticlePtr> genPartVector)
 {
   std::cout << "test1\n";
-  const HepMC::GenParticle *particle = genPartVector.at(0);
+  auto particle = genPartVector.at(0);
   // Create HepMcParticleLink outside of leak check.
-  HepMcParticleLink dummyHMPL(particle->barcode(),particle->parent_event()->event_number());
+  HepMcParticleLink dummyHMPL(HepMC::barcode(particle),particle->parent_event()->event_number());
   assert(dummyHMPL.cptr()==particle);
   // Create DVL info outside of leak check.
   RPCSimHitCollection dum ("coll");
@@ -85,8 +86,8 @@ void test1(std::vector<HepMC::GenParticle*> genPartVector)
 
   RPCSimHitCollection trans1 ("coll");
   for (int i=0; i < 10; i++) {
-    const HepMC::GenParticle* pGenParticle = genPartVector.at(i);
-    HepMcParticleLink trkLink(pGenParticle->barcode(),pGenParticle->parent_event()->event_number());
+    auto pGenParticle = genPartVector.at(i);
+    HepMcParticleLink trkLink(HepMC::barcode(pGenParticle),pGenParticle->parent_event()->event_number());
     trans1.Emplace (123, 10.5,
                     Amg::Vector3D (12.5, 13.5, 14.5),
                     trkLink,
@@ -101,7 +102,7 @@ void test1(std::vector<HepMC::GenParticle*> genPartVector)
 int main()
 {
   ISvcLocator* pSvcLoc = nullptr;
-  std::vector<HepMC::GenParticle*> genPartVector;
+  std::vector<HepMC::GenParticlePtr> genPartVector;
   if (!Athena_test::initMcEventCollection(pSvcLoc,genPartVector)) {
     std::cerr << "This test can not be run" << std::endl;
     return 0;
diff --git a/MuonSpectrometer/MuonCnv/MuonSimEventTPCnv/test/TGCSimHitCollectionCnv_p1_test.cxx b/MuonSpectrometer/MuonCnv/MuonSimEventTPCnv/test/TGCSimHitCollectionCnv_p1_test.cxx
index ca1b9ed7cb6b9dc5fc95b0e9de50145c3c9eb41b..8fbce420da76ff2ac3473228e3f2d718198ae172 100644
--- a/MuonSpectrometer/MuonCnv/MuonSimEventTPCnv/test/TGCSimHitCollectionCnv_p1_test.cxx
+++ b/MuonSpectrometer/MuonCnv/MuonSimEventTPCnv/test/TGCSimHitCollectionCnv_p1_test.cxx
@@ -20,13 +20,14 @@
 #include "GeneratorObjectsTPCnv/initMcEventCollection.h"
 #include "AtlasHepMC/GenEvent.h"
 #include "AtlasHepMC/GenParticle.h"
+#include "AtlasHepMC/Operators.h"
 
 
 void compare (const HepMcParticleLink& p1,
               const HepMcParticleLink& p2)
 {
   assert ( p1.isValid() == p2.isValid() );
-  assert ( p1.barcode() == p2.barcode() );
+  assert ( HepMC::barcode(p1) == HepMC::barcode(p2) );
   assert ( p1.eventIndex() == p2.eventIndex() );
   assert ( p1.getEventCollectionAsChar() == p2.getEventCollectionAsChar() );
   assert ( p1.cptr() == p2.cptr() );
@@ -72,12 +73,12 @@ void testit (const TGCSimHitCollection& trans1)
 }
 
 
-void test1(std::vector<HepMC::GenParticle*> genPartVector)
+void test1(std::vector<HepMC::GenParticlePtr> genPartVector)
 {
   std::cout << "test1\n";
-  const HepMC::GenParticle *particle = genPartVector.at(0);
+  auto particle = genPartVector.at(0);
   // Create HepMcParticleLink outside of leak check.
-  HepMcParticleLink dummyHMPL(particle->barcode(),particle->parent_event()->event_number());
+  HepMcParticleLink dummyHMPL(HepMC::barcode(particle),particle->parent_event()->event_number());
   assert(dummyHMPL.cptr()==particle);
   // Create DVL info outside of leak check.
   TGCSimHitCollection dum ("coll");
@@ -85,8 +86,8 @@ void test1(std::vector<HepMC::GenParticle*> genPartVector)
 
   TGCSimHitCollection trans1 ("coll");
   for (int i=0; i < 10; i++) {
-    const HepMC::GenParticle* pGenParticle = genPartVector.at(i);
-    HepMcParticleLink trkLink(pGenParticle->barcode(),pGenParticle->parent_event()->event_number());
+    auto pGenParticle = genPartVector.at(i);
+    HepMcParticleLink trkLink(HepMC::barcode(pGenParticle),pGenParticle->parent_event()->event_number());
     trans1.Emplace (123, 10.5,
                     Amg::Vector3D (12.5, 13.5, 14.5),
                     Amg::Vector3D (16.5, 17.5, 18.5),
@@ -100,7 +101,7 @@ void test1(std::vector<HepMC::GenParticle*> genPartVector)
 int main()
 {
   ISvcLocator* pSvcLoc = nullptr;
-  std::vector<HepMC::GenParticle*> genPartVector;
+  std::vector<HepMC::GenParticlePtr> genPartVector;
   if (!Athena_test::initMcEventCollection(pSvcLoc,genPartVector)) {
     std::cerr << "This test can not be run" << std::endl;
     return 0;
diff --git a/MuonSpectrometer/MuonCnv/MuonSimEventTPCnv/test/TGCSimHitCollectionCnv_p2_test.cxx b/MuonSpectrometer/MuonCnv/MuonSimEventTPCnv/test/TGCSimHitCollectionCnv_p2_test.cxx
index 8e14145a1e51e67da76df430f6a89f372a0b53bd..4140e9e5448d67d7189a736eb9657f413895a115 100644
--- a/MuonSpectrometer/MuonCnv/MuonSimEventTPCnv/test/TGCSimHitCollectionCnv_p2_test.cxx
+++ b/MuonSpectrometer/MuonCnv/MuonSimEventTPCnv/test/TGCSimHitCollectionCnv_p2_test.cxx
@@ -20,13 +20,14 @@
 #include "GeneratorObjectsTPCnv/initMcEventCollection.h"
 #include "AtlasHepMC/GenEvent.h"
 #include "AtlasHepMC/GenParticle.h"
+#include "AtlasHepMC/Operators.h"
 
 
 void compare (const HepMcParticleLink& p1,
               const HepMcParticleLink& p2)
 {
   assert ( p1.isValid() == p2.isValid() );
-  assert ( p1.barcode() == p2.barcode() );
+  assert ( HepMC::barcode(p1) == HepMC::barcode(p2) );
   assert ( p1.eventIndex() == p2.eventIndex() );
   assert ( p1.getEventCollectionAsChar() == p2.getEventCollectionAsChar() );
   assert ( p1.cptr() == p2.cptr() );
@@ -72,12 +73,12 @@ void testit (const TGCSimHitCollection& trans1)
 }
 
 
-void test1(std::vector<HepMC::GenParticle*> genPartVector)
+void test1(std::vector<HepMC::GenParticlePtr> genPartVector)
 {
   std::cout << "test1\n";
-  const HepMC::GenParticle *particle = genPartVector.at(0);
+  auto particle = genPartVector.at(0);
   // Create HepMcParticleLink outside of leak check.
-  HepMcParticleLink dummyHMPL(particle->barcode(),particle->parent_event()->event_number());
+  HepMcParticleLink dummyHMPL(HepMC::barcode(particle),particle->parent_event()->event_number());
   assert(dummyHMPL.cptr()==particle);
   // Create DVL info outside of leak check.
   TGCSimHitCollection dum ("coll");
@@ -85,8 +86,8 @@ void test1(std::vector<HepMC::GenParticle*> genPartVector)
 
   TGCSimHitCollection trans1 ("coll");
   for (int i=0; i < 10; i++) {
-    const HepMC::GenParticle* pGenParticle = genPartVector.at(i);
-    HepMcParticleLink trkLink(pGenParticle->barcode(),pGenParticle->parent_event()->event_number());
+    auto pGenParticle = genPartVector.at(i);
+    HepMcParticleLink trkLink(HepMC::barcode(pGenParticle),pGenParticle->parent_event()->event_number());
     trans1.Emplace (123, 10.5,
                     Amg::Vector3D (12.5, 13.5, 14.5),
                     Amg::Vector3D (16.5, 17.5, 18.5),
@@ -100,7 +101,7 @@ void test1(std::vector<HepMC::GenParticle*> genPartVector)
 int main()
 {
   ISvcLocator* pSvcLoc = nullptr;
-  std::vector<HepMC::GenParticle*> genPartVector;
+  std::vector<HepMC::GenParticlePtr> genPartVector;
   if (!Athena_test::initMcEventCollection(pSvcLoc,genPartVector)) {
     std::cerr << "This test can not be run" << std::endl;
     return 0;
diff --git a/MuonSpectrometer/MuonCnv/MuonSimEventTPCnv/test/TGCSimHitCollectionCnv_p3_test.cxx b/MuonSpectrometer/MuonCnv/MuonSimEventTPCnv/test/TGCSimHitCollectionCnv_p3_test.cxx
index 5193bd46e0472a481d2dd1cb67b2d93f8268608e..96e47b0a1aa8e1a2925a5f30e49a15eba2df51ac 100644
--- a/MuonSpectrometer/MuonCnv/MuonSimEventTPCnv/test/TGCSimHitCollectionCnv_p3_test.cxx
+++ b/MuonSpectrometer/MuonCnv/MuonSimEventTPCnv/test/TGCSimHitCollectionCnv_p3_test.cxx
@@ -20,13 +20,14 @@
 #include "GeneratorObjectsTPCnv/initMcEventCollection.h"
 #include "AtlasHepMC/GenEvent.h"
 #include "AtlasHepMC/GenParticle.h"
+#include "AtlasHepMC/Operators.h"
 
 
 void compare (const HepMcParticleLink& p1,
               const HepMcParticleLink& p2)
 {
   assert ( p1.isValid() == p2.isValid() );
-  assert ( p1.barcode() == p2.barcode() );
+  assert ( HepMC::barcode(p1) == HepMC::barcode(p2) );
   assert ( p1.eventIndex() == p2.eventIndex() );
   assert ( p1.getEventCollectionAsChar() == p2.getEventCollectionAsChar() );
   assert ( p1.cptr() == p2.cptr() );
@@ -72,12 +73,12 @@ void testit (const TGCSimHitCollection& trans1)
 }
 
 
-void test1(std::vector<HepMC::GenParticle*>& genPartVector)
+void test1(std::vector<HepMC::GenParticlePtr>& genPartVector)
 {
   std::cout << "test1\n";
-  const HepMC::GenParticle *particle = genPartVector.at(0);
+  auto particle = genPartVector.at(0);
   // Create HepMcParticleLink outside of leak check.
-  HepMcParticleLink dummyHMPL(particle->barcode(),particle->parent_event()->event_number());
+  HepMcParticleLink dummyHMPL(HepMC::barcode(particle),particle->parent_event()->event_number());
   assert(dummyHMPL.cptr()==particle);
   // Create DVL info outside of leak check.
   TGCSimHitCollection dum ("coll");
@@ -85,8 +86,8 @@ void test1(std::vector<HepMC::GenParticle*>& genPartVector)
 
   TGCSimHitCollection trans1 ("coll");
   for (int i=0; i < 10; i++) {
-    const HepMC::GenParticle* pGenParticle = genPartVector.at(i);
-    HepMcParticleLink trkLink(pGenParticle->barcode(),pGenParticle->parent_event()->event_number());
+    auto pGenParticle = genPartVector.at(i);
+    HepMcParticleLink trkLink(HepMC::barcode(pGenParticle),pGenParticle->parent_event()->event_number());
     trans1.Emplace (123, 10.5,
                     Amg::Vector3D (12.5, 13.5, 14.5),
                     Amg::Vector3D (16.5, 17.5, 18.5),
@@ -100,7 +101,7 @@ void test1(std::vector<HepMC::GenParticle*>& genPartVector)
 int main()
 {
   ISvcLocator* pSvcLoc = nullptr;
-  std::vector<HepMC::GenParticle*> genPartVector;
+  std::vector<HepMC::GenParticlePtr> genPartVector;
   if (!Athena_test::initMcEventCollection(pSvcLoc,genPartVector)) {
     std::cerr << "This test can not be run" << std::endl;
     return 0;
diff --git a/MuonSpectrometer/MuonCnv/MuonSimEventTPCnv/test/TGCSimHitCollectionCnv_p4_test.cxx b/MuonSpectrometer/MuonCnv/MuonSimEventTPCnv/test/TGCSimHitCollectionCnv_p4_test.cxx
index 3e4d844d365aaa02301e7e8644b5e6450e28c78c..94f58958a5a045063a9d331b843fac3bfcc9e8ae 100644
--- a/MuonSpectrometer/MuonCnv/MuonSimEventTPCnv/test/TGCSimHitCollectionCnv_p4_test.cxx
+++ b/MuonSpectrometer/MuonCnv/MuonSimEventTPCnv/test/TGCSimHitCollectionCnv_p4_test.cxx
@@ -20,13 +20,14 @@
 #include "GeneratorObjectsTPCnv/initMcEventCollection.h"
 #include "AtlasHepMC/GenEvent.h"
 #include "AtlasHepMC/GenParticle.h"
+#include "AtlasHepMC/Operators.h"
 
 
 void compare (const HepMcParticleLink& p1,
               const HepMcParticleLink& p2)
 {
   assert ( p1.isValid() == p2.isValid() );
-  assert ( p1.barcode() == p2.barcode() );
+  assert ( HepMC::barcode(p1) == HepMC::barcode(p2) );
   assert ( p1.eventIndex() == p2.eventIndex() );
   assert ( p1.getEventCollectionAsChar() == p2.getEventCollectionAsChar() );
   assert ( p1.cptr() == p2.cptr() );
@@ -72,12 +73,12 @@ void testit (const TGCSimHitCollection& trans1)
 }
 
 
-void test1(std::vector<HepMC::GenParticle*> genPartVector)
+void test1(std::vector<HepMC::GenParticlePtr> genPartVector)
 {
   std::cout << "test1\n";
-  const HepMC::GenParticle *particle = genPartVector.at(0);
+  auto particle = genPartVector.at(0);
   // Create HepMcParticleLink outside of leak check.
-  HepMcParticleLink dummyHMPL(particle->barcode(),particle->parent_event()->event_number());
+  HepMcParticleLink dummyHMPL(HepMC::barcode(particle),particle->parent_event()->event_number());
   assert(dummyHMPL.cptr()==particle);
   // Create DVL info outside of leak check.
   TGCSimHitCollection dum ("coll");
@@ -85,8 +86,8 @@ void test1(std::vector<HepMC::GenParticle*> genPartVector)
 
   TGCSimHitCollection trans1 ("coll");
   for (int i=0; i < 10; i++) {
-    const HepMC::GenParticle* pGenParticle = genPartVector.at(i);
-    HepMcParticleLink trkLink(pGenParticle->barcode(),pGenParticle->parent_event()->event_number());
+    auto pGenParticle = genPartVector.at(i);
+    HepMcParticleLink trkLink(HepMC::barcode(pGenParticle),pGenParticle->parent_event()->event_number());
     trans1.Emplace (123, 10.5,
                     Amg::Vector3D (12.5, 13.5, 14.5),
                     Amg::Vector3D (16.5, 17.5, 18.5),
@@ -100,7 +101,7 @@ void test1(std::vector<HepMC::GenParticle*> genPartVector)
 int main()
 {
   ISvcLocator* pSvcLoc = nullptr;
-  std::vector<HepMC::GenParticle*> genPartVector;
+  std::vector<HepMC::GenParticlePtr> genPartVector;
   if (!Athena_test::initMcEventCollection(pSvcLoc,genPartVector)) {
     std::cerr << "This test can not be run" << std::endl;
     return 0;
diff --git a/MuonSpectrometer/MuonCnv/MuonSimEventTPCnv/test/sTGCSimHitCollectionCnv_p1_test.cxx b/MuonSpectrometer/MuonCnv/MuonSimEventTPCnv/test/sTGCSimHitCollectionCnv_p1_test.cxx
index cf56cf2bdaf04b0b7e2e6caa006aed4b66625ff8..e3d9c38e1ed3d4345a75f0b823d8f336485c1f8e 100644
--- a/MuonSpectrometer/MuonCnv/MuonSimEventTPCnv/test/sTGCSimHitCollectionCnv_p1_test.cxx
+++ b/MuonSpectrometer/MuonCnv/MuonSimEventTPCnv/test/sTGCSimHitCollectionCnv_p1_test.cxx
@@ -20,12 +20,13 @@
 #include "GeneratorObjectsTPCnv/initMcEventCollection.h"
 #include "AtlasHepMC/GenEvent.h"
 #include "AtlasHepMC/GenParticle.h"
+#include "AtlasHepMC/Operators.h"
 
 void compare (const HepMcParticleLink& p1,
               const HepMcParticleLink& p2)
 {
   assert ( p1.isValid() == p2.isValid() );
-  assert ( p1.barcode() == p2.barcode() );
+  assert ( HepMC::barcode(p1) == HepMC::barcode(p2) );
   assert ( p1.eventIndex() == p2.eventIndex() );
   assert ( p1.getEventCollectionAsChar() == p2.getEventCollectionAsChar() );
   assert ( p1.cptr() == p2.cptr() );
@@ -69,12 +70,12 @@ void testit (const sTGCSimHitCollection& trans1)
 }
 
 
-void test1(std::vector<HepMC::GenParticle*> genPartVector)
+void test1(std::vector<HepMC::GenParticlePtr> genPartVector)
 {
   std::cout << "test1\n";
-  const HepMC::GenParticle *particle = genPartVector.at(0);
+  auto particle = genPartVector.at(0);
   // Create HepMcParticleLink outside of leak check.
-  HepMcParticleLink dummyHMPL(particle->barcode(),particle->parent_event()->event_number());
+  HepMcParticleLink dummyHMPL(HepMC::barcode(particle),particle->parent_event()->event_number());
   assert(dummyHMPL.cptr()==particle);
   // Create DVL info outside of leak check.
   sTGCSimHitCollection dum ("coll");
@@ -82,8 +83,8 @@ void test1(std::vector<HepMC::GenParticle*> genPartVector)
 
   sTGCSimHitCollection trans1 ("coll");
   for (int i=0; i < 10; i++) {
-    const HepMC::GenParticle* pGenParticle = genPartVector.at(i);
-    HepMcParticleLink trkLink(pGenParticle->barcode(),pGenParticle->parent_event()->event_number());
+    auto pGenParticle = genPartVector.at(i);
+    HepMcParticleLink trkLink(HepMC::barcode(pGenParticle),pGenParticle->parent_event()->event_number());
     trans1.Emplace (123, 10.5,
                     Amg::Vector3D (12.5, 13.5, 14.5),
                     pGenParticle->pdg_id(),
@@ -99,7 +100,7 @@ void test1(std::vector<HepMC::GenParticle*> genPartVector)
 int main()
 {
   ISvcLocator* pSvcLoc = nullptr;
-  std::vector<HepMC::GenParticle*> genPartVector;
+  std::vector<HepMC::GenParticlePtr> genPartVector;
   if (!Athena_test::initMcEventCollection(pSvcLoc,genPartVector)) {
     std::cerr << "This test can not be run" << std::endl;
     return 0;
diff --git a/MuonSpectrometer/MuonCnv/MuonSimEventTPCnv/test/sTGCSimHitCollectionCnv_p2_test.cxx b/MuonSpectrometer/MuonCnv/MuonSimEventTPCnv/test/sTGCSimHitCollectionCnv_p2_test.cxx
index b72c98bad9e32963ddd72969ab09d3b74fce15b9..c8a390cfc75e6c2834cd198b6bfc260d6dbc3a14 100644
--- a/MuonSpectrometer/MuonCnv/MuonSimEventTPCnv/test/sTGCSimHitCollectionCnv_p2_test.cxx
+++ b/MuonSpectrometer/MuonCnv/MuonSimEventTPCnv/test/sTGCSimHitCollectionCnv_p2_test.cxx
@@ -28,12 +28,13 @@
 #include "GeneratorObjectsTPCnv/initMcEventCollection.h"
 #include "AtlasHepMC/GenEvent.h"
 #include "AtlasHepMC/GenParticle.h"
+#include "AtlasHepMC/Operators.h"
 
 void compare (const HepMcParticleLink& p1,
               const HepMcParticleLink& p2)
 {
   assert ( p1.isValid() == p2.isValid() );
-  assert ( p1.barcode() == p2.barcode() );
+  assert ( HepMC::barcode(p1) == HepMC::barcode(p2) );
   assert ( p1.eventIndex() == p2.eventIndex() );
   assert ( p1.getEventCollectionAsChar() == p2.getEventCollectionAsChar() );
   assert ( p1.cptr() == p2.cptr() );
@@ -78,12 +79,12 @@ void testit (const sTGCSimHitCollection& trans1)
 }
 
 
-void test1(std::vector<HepMC::GenParticle*> genPartVector)
+void test1(std::vector<HepMC::GenParticlePtr> genPartVector)
 {
   std::cout << "test1\n";
-  const HepMC::GenParticle *particle = genPartVector.at(0);
+  auto particle = genPartVector.at(0);
   // Create HepMcParticleLink outside of leak check.
-  HepMcParticleLink dummyHMPL(particle->barcode(),particle->parent_event()->event_number());
+  HepMcParticleLink dummyHMPL(HepMC::barcode(particle),particle->parent_event()->event_number());
   assert(dummyHMPL.cptr()==particle);
   // Create DVL info outside of leak check.
   sTGCSimHitCollection dum ("coll");
@@ -91,8 +92,8 @@ void test1(std::vector<HepMC::GenParticle*> genPartVector)
 
   sTGCSimHitCollection trans1 ("coll");
   for (int i=0; i < 10; i++) {
-    const HepMC::GenParticle* pGenParticle = genPartVector.at(i);
-    HepMcParticleLink trkLink(pGenParticle->barcode(),pGenParticle->parent_event()->event_number());
+    auto pGenParticle = genPartVector.at(i);
+    HepMcParticleLink trkLink(HepMC::barcode(pGenParticle),pGenParticle->parent_event()->event_number());
     trans1.Emplace (123, 10.5,
                     Amg::Vector3D (12.5, 13.5, 14.5),
                     pGenParticle->pdg_id(),
@@ -108,7 +109,7 @@ void test1(std::vector<HepMC::GenParticle*> genPartVector)
 int main()
 {
   ISvcLocator* pSvcLoc = nullptr;
-  std::vector<HepMC::GenParticle*> genPartVector;
+  std::vector<HepMC::GenParticlePtr> genPartVector;
   if (!Athena_test::initMcEventCollection(pSvcLoc,genPartVector)) {
     std::cerr << "This test can not be run" << std::endl;
     return 0;