From c4d5fb4dac0398a2d5ec2f69f05290308a90bb1d Mon Sep 17 00:00:00 2001
From: Andre Sailer <andre.philippe.sailer@cern.ch>
Date: Tue, 6 Mar 2018 15:45:49 +0100
Subject: [PATCH] Geant4InputHandling: fix for initial state electrons present
 in MC Record

---
 DDG4/src/Geant4InputHandling.cpp | 11 ++++++++---
 1 file changed, 8 insertions(+), 3 deletions(-)

diff --git a/DDG4/src/Geant4InputHandling.cpp b/DDG4/src/Geant4InputHandling.cpp
index 3c711c0ef..7e8731c52 100644
--- a/DDG4/src/Geant4InputHandling.cpp
+++ b/DDG4/src/Geant4InputHandling.cpp
@@ -381,9 +381,14 @@ getRelevant(set<int>& visited,
     double me = en > std::numeric_limits<double>::epsilon() ? p->mass / en : 0.0;
     //  fix by S.Morozov for real != 0
     double proper_time = fabs(dp->time-p->time) * me;
-
-    // -- remove original --- if the pdgID is not known (generator "strings") or the particle is quark, gluon, Z, W, etc.
-    if (p.definition() && rejectPDGs.count(abs(p->pdgID)) == 0) {
+    double proper_time_Precision = pow(10.,-DBL_DIG)*me*fmax(fabs(p->time),fabs(dp->time));
+    bool isProperTimeZero = (proper_time <= proper_time_Precision);
+
+    // -- remove original if ---
+    bool rejectParticle = not p.definition() // completely unknown to geant4
+      or (rejectPDGs.count(abs(p->pdgID)) != 0) // quarks, gluon, "strings", W, Z etc.
+      or (isProperTimeZero and p.definition()->GetPDGStable()); // initial state electrons, etc.
+    if (not rejectParticle) {
       map<int,G4PrimaryParticle*>::iterator ip4 = prim.find(p->id);
       G4PrimaryParticle* p4 = (ip4 == prim.end()) ? 0 : (*ip4).second;
       if ( !p4 )  {
-- 
GitLab