From 7f914918e3df8015157c9e23c31b7cab43a7a361 Mon Sep 17 00:00:00 2001
From: Andrii Verbytskyi <andrii.verbytskyi@cern.ch>
Date: Thu, 2 Jul 2020 07:53:10 +0000
Subject: [PATCH] Migration of GenzModuleEvent  to HepMC3

---
 .../GenzModuleEvent/KineHepMcmap.h            |  5 +----
 .../GenzModuleEvent/src/KineHepMcmap.cxx      | 22 +++++--------------
 2 files changed, 7 insertions(+), 20 deletions(-)

diff --git a/Generators/GenzModuleEvent/GenzModuleEvent/KineHepMcmap.h b/Generators/GenzModuleEvent/GenzModuleEvent/KineHepMcmap.h
index c8d4b5e8104..8610967ce46 100644
--- a/Generators/GenzModuleEvent/GenzModuleEvent/KineHepMcmap.h
+++ b/Generators/GenzModuleEvent/GenzModuleEvent/KineHepMcmap.h
@@ -1,5 +1,5 @@
 /*
-  Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration
+  Copyright (C) 2002-2020 CERN for the benefit of the ATLAS collaboration
 */
 
 #ifndef KINEHEPMCMAP_H
@@ -17,10 +17,7 @@ public:
     HepMC::GenParticlePtr  	givekine_getParticle	( const int ikine ) const;
 private:
     const HepMC::GenEvent*	m_evt;
-    //const int	m_vertex_offset;
     const int 	m_kine_offset;
-    //const int 	m_mbias_int_kine_offset;
-    //const int 	m_mbias_noint_kine_offset;
 };
 
 
diff --git a/Generators/GenzModuleEvent/src/KineHepMcmap.cxx b/Generators/GenzModuleEvent/src/KineHepMcmap.cxx
index e3b07a5ed60..00584e3d82f 100644
--- a/Generators/GenzModuleEvent/src/KineHepMcmap.cxx
+++ b/Generators/GenzModuleEvent/src/KineHepMcmap.cxx
@@ -27,22 +27,12 @@ KineHepMcmap::giveParticle_getkine	(HepMC::GenParticlePtr p ) const
 HepMC::GenParticlePtr
 KineHepMcmap::givekine_getParticle	( const int kine ) const
 {
-    if (kine <= 0) return 0;
-    HepMC::GenParticlePtr	part =	nullptr;
-    bool not_found = true;
-    HepMC::GenEvent::particle_const_iterator p = m_evt->particles_begin();
-    do
+    if (kine <= 0) return nullptr;
+    for (HepMC::GenParticlePtr  part: *m_evt)
     {
-	int pkine = giveParticle_getkine(*p);
-	if (pkine == kine)
-	{
-	    not_found = false;
-	    part = *p;
-	}
-	++p;
-    } while (p != m_evt->particles_end() && not_found);
-
-    return part;
+         if (giveParticle_getkine(part) == kine )  return part;
+    }
+    return  nullptr;
 }
 
 
@@ -57,7 +47,7 @@ KineHepMcmap::givekine_getParticle	( const int kine ) const
 //         int kine = 120;
 	 
 //	 HepMC::KineHepMcmap  kinm(evt )   ;
-//	 HepMC::GenParticle* myparticle = kinm.givekine_getParticle( kine);
+//	 HepMC::GenParticlePtr myparticle = kinm.givekine_getParticle( kine);
 //	 int mykine = kinm.giveParticle_getkine(  myparticle);
 //	 cout << "KineHepMcmap geant particle 120 =  " << mykine << endl; 
 //	 if (myparticle) myparticle->print();
-- 
GitLab