From 9a530393223b7ef71d59e09bdf0a71cb655c65d2 Mon Sep 17 00:00:00 2001
From: Sylvester Joosten <sjoosten@anl.gov>
Date: Mon, 22 Nov 2021 21:14:17 +0000
Subject: [PATCH] Undo particle handler patch as it was causing issues

---
 .../dd4hep/geant4_particle_handler.patch      | 27 -------------------
 spack/packages/dd4hep/package.py              |  1 -
 2 files changed, 28 deletions(-)
 delete mode 100644 spack/packages/dd4hep/geant4_particle_handler.patch

diff --git a/spack/packages/dd4hep/geant4_particle_handler.patch b/spack/packages/dd4hep/geant4_particle_handler.patch
deleted file mode 100644
index 14ed43af4..000000000
--- a/spack/packages/dd4hep/geant4_particle_handler.patch
+++ /dev/null
@@ -1,27 +0,0 @@
-diff --git a/DDG4/src/Geant4ParticleHandler.cpp b/DDG4/src/Geant4ParticleHandler.cpp
-index 82a4b702..779dd044 100644
---- a/DDG4/src/Geant4ParticleHandler.cpp
-+++ b/DDG4/src/Geant4ParticleHandler.cpp
-@@ -436,11 +436,8 @@ void Geant4ParticleHandler::rebaseSimulatedTracks(int )   {
-   for(count = 0, iend=pm.end(), i=pm.begin(); i!=iend; ++i)  {
-     Particle* p = (*i).second;
-     orgParticles[p->id] = p->id;
--    finalParticles[p->id] = p;
-+    finalParticles[p->id] = p->addRef();
-     if ( p->id > count ) count = p->id;
--    if ( (p->reason&G4PARTICLE_PRIMARY) != G4PARTICLE_PRIMARY )  {
--      p->addRef();
--    }
-   }
-   // (1.1) Define the new particle mapping for the simulated tracks
-   for(++count, iend=m_particleMap.end(), i=m_particleMap.begin(); i!=iend; ++i)  {
-@@ -448,7 +445,8 @@ void Geant4ParticleHandler::rebaseSimulatedTracks(int )   {
-     if ( (p->reason&G4PARTICLE_PRIMARY) != G4PARTICLE_PRIMARY )  {
-       //if ( orgParticles.find(p->id) == orgParticles.end() )  {
-       orgParticles[p->id] = count;
--      finalParticles[count] = p;
-+      finalParticles[count]->release();
-+      finalParticles[count] = p->addRef();
-       p->id = count;
-       ++count;
-     }
diff --git a/spack/packages/dd4hep/package.py b/spack/packages/dd4hep/package.py
index 34336c3f7..27430ecf3 100644
--- a/spack/packages/dd4hep/package.py
+++ b/spack/packages/dd4hep/package.py
@@ -53,7 +53,6 @@ class Dd4hep(CMakePackage):
 
     # hack to fix refcount underflow
     patch('refcount_underflow.patch', when='@1.17:')
-    patch('geant4_particle_handler.patch', when='@1.17:')
     patch('pdg.patch', when='@1.17:')
     
     # custom hash for the 2021-07-27 version, needed to include
-- 
GitLab