diff --git a/ForwardDetectors/ZDC/ZdcNtuple/Root/ZdcNtuple.cxx b/ForwardDetectors/ZDC/ZdcNtuple/Root/ZdcNtuple.cxx
index e3abe77ef7e46a258f8da21c895657e4a2a88d24..0c06716a2208aa1bf17177205b2421e058607073 100644
--- a/ForwardDetectors/ZDC/ZdcNtuple/Root/ZdcNtuple.cxx
+++ b/ForwardDetectors/ZDC/ZdcNtuple/Root/ZdcNtuple.cxx
@@ -1,5 +1,5 @@
 /*
-  Copyright (C) 2002-2022 CERN for the benefit of the ATLAS collaboration
+  Copyright (C) 2002-2024 CERN for the benefit of the ATLAS collaboration
 */
 
 #include <TSystem.h>
@@ -929,8 +929,16 @@ void ZdcNtuple::processMCEventCollection(){
   ******************************************/  
   for (unsigned int cntr = 0; cntr < mcEventCollection->size(); ++cntr){
     const HepMC::GenEvent *genEvt = (*mcEventCollection)[cntr];
+#ifdef HEPMC3
     for (const auto &vertex : genEvt->vertices()){
       for (const auto &particle : vertex->particles_in()){
+#else
+    for (const auto &vertex : genEvt->vertex_range()){
+      for (auto ip = vertex->particles_in_const_begin();
+           ip != vertex->particles_in_const_end();
+           ++ip) {
+        auto particle = *ip;
+#endif
         t_ZdcTruthParticlePosx.push_back(vertex->position().x());
         t_ZdcTruthParticlePosy.push_back(vertex->position().y());
         t_ZdcTruthParticlePosz.push_back(vertex->position().z());