diff --git a/PhysicsAnalysis/D3PDMaker/TruthD3PDAnalysis/TruthD3PDAnalysis/ATLAS_CHECK_THREAD_SAFETY b/PhysicsAnalysis/D3PDMaker/TruthD3PDAnalysis/TruthD3PDAnalysis/ATLAS_CHECK_THREAD_SAFETY
new file mode 100644
index 0000000000000000000000000000000000000000..2c1d6eeff4dde26d0f146a50df9105bd8163f28b
--- /dev/null
+++ b/PhysicsAnalysis/D3PDMaker/TruthD3PDAnalysis/TruthD3PDAnalysis/ATLAS_CHECK_THREAD_SAFETY
@@ -0,0 +1 @@
+PhysicsAnalysis/D3PDMaker/TruthD3PDAnalysis
diff --git a/PhysicsAnalysis/D3PDMaker/TruthD3PDAnalysis/TruthD3PDAnalysis/TruthParticleFilterBase.h b/PhysicsAnalysis/D3PDMaker/TruthD3PDAnalysis/TruthD3PDAnalysis/TruthParticleFilterBase.h
index 59804669664e9d5944593542eb71c6ad632173b3..6c93b58bf7ca900f8257a7e30e8d0a9127444929 100644
--- a/PhysicsAnalysis/D3PDMaker/TruthD3PDAnalysis/TruthD3PDAnalysis/TruthParticleFilterBase.h
+++ b/PhysicsAnalysis/D3PDMaker/TruthD3PDAnalysis/TruthD3PDAnalysis/TruthParticleFilterBase.h
@@ -1,7 +1,7 @@
 // This file's extension implies that it's C, but it's really -*- C++ -*-.
 
 /*
-  Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration
+  Copyright (C) 2002-2022 CERN for the benefit of the ATLAS collaboration
 */
 
 // $Id$
@@ -65,13 +65,13 @@ public:
 
 
   /// Standard Gaudi initialize method.
-  virtual StatusCode initialize();
+  virtual StatusCode initialize() override;
 
   /// Standard Gaudi finalize  method.
-  virtual StatusCode finalize();
+  virtual StatusCode finalize() override;
 
   /// Run the tool.
-  virtual StatusCode execute();
+  virtual StatusCode execute() override;
 
 
   /** This method will check the validity of the input McEventCollection 
@@ -81,7 +81,7 @@ public:
    *  the filtering process.
    */
   virtual StatusCode buildMcAod( const McEventCollection* in,
-				 McEventCollection* filtered );
+				 McEventCollection* filtered ) override;
 
 
   /// Filter a single @c GenEvent.
@@ -89,11 +89,11 @@ public:
                                   HepMC::GenEvent* ev_out);
 
   /// Add a @c GenParticle (and its production vertex) to a @c GenEvent.
-  virtual StatusCode addParticle (HepMC::GenParticlePtr p,
+  virtual StatusCode addParticle (HepMC::ConstGenParticlePtr p,
                                   HepMC::GenEvent* ev);
 
   /// Add a @c GenVertex to a @c GenEvent.
-  virtual StatusCode addVertex (HepMC::GenVertexPtr p,
+  virtual StatusCode addVertex (HepMC::ConstGenVertexPtr p,
                                 HepMC::GenEvent* ev);
 
   /// Test to see if we want to keep a particle.
diff --git a/PhysicsAnalysis/D3PDMaker/TruthD3PDAnalysis/src/TruthParticleFilterBase.cxx b/PhysicsAnalysis/D3PDMaker/TruthD3PDAnalysis/src/TruthParticleFilterBase.cxx
index b95192cc6560fbd77ba8c63ceee0453a0f9c2fad..83a2d3f07fe1070ec9a70456e2003a9c23837f38 100644
--- a/PhysicsAnalysis/D3PDMaker/TruthD3PDAnalysis/src/TruthParticleFilterBase.cxx
+++ b/PhysicsAnalysis/D3PDMaker/TruthD3PDAnalysis/src/TruthParticleFilterBase.cxx
@@ -1,5 +1,5 @@
 /*
-  Copyright (C) 2002-2019 CERN for the benefit of the ATLAS collaboration
+  Copyright (C) 2002-2022 CERN for the benefit of the ATLAS collaboration
 */
 /**
  * @file TruthD3PDAnalysis/src/TruthParticleFilterBase.cxx
@@ -191,9 +191,7 @@ StatusCode
 TruthParticleFilterBase::filterEvent (const HepMC::GenEvent* ev_in, HepMC::GenEvent* ev_out)
 {
   // Loop over particles.
-  // (range-based for doesn't work here because particle_const_iterator
-  // isn't consistent in the use of const...)
-  for (auto ip: *((HepMC::GenEvent*)ev_in))
+   for (auto ip: *ev_in)
   {
     // Copy the particle if we want to keep it.
     if (isAccepted (ip))
@@ -207,7 +205,7 @@ TruthParticleFilterBase::filterEvent (const HepMC::GenEvent* ev_in, HepMC::GenEv
  * @brief Add a @c GenParticle (and its production vertex) to a @c GenEvent.
  */
 StatusCode
-TruthParticleFilterBase::addParticle (HepMC::GenParticlePtr p, HepMC::GenEvent* ev)
+TruthParticleFilterBase::addParticle (HepMC::ConstGenParticlePtr p, HepMC::GenEvent* ev)
 {
   // Add parent vertex if it exists.  Otherwise, add decay vertex.
   if (p->production_vertex())
@@ -265,7 +263,7 @@ TruthParticleFilterBase::addParticle (HepMC::GenParticlePtr p, HepMC::GenEvent*
  * @brief Add a @c GenVertex to a @c GenEvent.
  */
 StatusCode
-TruthParticleFilterBase::addVertex (HepMC::GenVertexPtr v, HepMC::GenEvent* ev)
+TruthParticleFilterBase::addVertex (HepMC::ConstGenVertexPtr v, HepMC::GenEvent* ev)
 {
 #ifdef HEPMC3
   // See if this vertex has already been copied.