From 7a23e53172315b126eafbe920477c8f245aebb8e Mon Sep 17 00:00:00 2001
From: Andre Sailer <andre.philippe.sailer@cern.ch>
Date: Tue, 2 Feb 2016 15:41:07 +0000
Subject: [PATCH] DDFORHEP-17: add property to steer the
 vertexIsNotEndpointOfParent flag

avoid magic numbers :)
---
 DDG4/include/DDG4/Geant4ParticleHandler.h | 2 ++
 DDG4/src/Geant4ParticleHandler.cpp        | 3 ++-
 2 files changed, 4 insertions(+), 1 deletion(-)

diff --git a/DDG4/include/DDG4/Geant4ParticleHandler.h b/DDG4/include/DDG4/Geant4ParticleHandler.h
index 646c3e17b..35fbf5a70 100644
--- a/DDG4/include/DDG4/Geant4ParticleHandler.h
+++ b/DDG4/include/DDG4/Geant4ParticleHandler.h
@@ -92,6 +92,8 @@ namespace DD4hep {
       bool m_ownsParticles;
       /// Property: Energy cut below which particles are not collected, but assigned to the parent
       double m_kinEnergyCut;
+      /// Property: Minimal distance after which the vertexIsNotEndpointOfParent flag is set
+      double m_minDistToParentVertex;
       /// Property: All the processes of which the decay products will be explicitly stored
       Processes                  m_processNames;
 
diff --git a/DDG4/src/Geant4ParticleHandler.cpp b/DDG4/src/Geant4ParticleHandler.cpp
index 657b66129..29c18dc7a 100644
--- a/DDG4/src/Geant4ParticleHandler.cpp
+++ b/DDG4/src/Geant4ParticleHandler.cpp
@@ -79,6 +79,7 @@ Geant4ParticleHandler::Geant4ParticleHandler(Geant4Context* ctxt, const string&
   declareProperty("KeepAllParticles",    m_keepAll = false);
   declareProperty("SaveProcesses",       m_processNames);
   declareProperty("MinimalKineticEnergy",m_kinEnergyCut = 100e0*CLHEP::MeV);
+  declareProperty("MinDistToParentVertex",m_minDistToParentVertex = 2.2e-14*CLHEP::mm);//default tolerance for g4ThreeVector isNear
   m_needsControl = true;
 }
 
@@ -676,7 +677,7 @@ void Geant4ParticleHandler::setVertexEndpointBit() {
     const double X( parent->vex - p->vex );
     const double Y( parent->vey - p->vey );
     const double Z( parent->vez - p->vez );
-    if( sqrt(X*X + Y*Y + Z*Z) > 2.2e-14 ){ //default tolerance for g4ThreeVector isNear
+    if( sqrt(X*X + Y*Y + Z*Z) > m_minDistToParentVertex ){
       PropertyMask(p->status).set(G4PARTICLE_SIM_PARENT_RADIATED);
     }
   }
-- 
GitLab