From 1af0083c8b550f22dcf003318b3669dc7697cf9f Mon Sep 17 00:00:00 2001
From: Chengdong Fu <fucd@ihep.ac.cn>
Date: Mon, 21 Nov 2022 21:47:30 +0800
Subject: [PATCH] remove hits while passing neutral particle

---
 Simulation/DetSimSD/src/GenericTrackerSensitiveDetector.cpp | 3 ++-
 Simulation/DetSimSD/src/TrackerCombineSensitiveDetector.cpp | 2 ++
 2 files changed, 4 insertions(+), 1 deletion(-)

diff --git a/Simulation/DetSimSD/src/GenericTrackerSensitiveDetector.cpp b/Simulation/DetSimSD/src/GenericTrackerSensitiveDetector.cpp
index d250079e..5e9ba1a6 100644
--- a/Simulation/DetSimSD/src/GenericTrackerSensitiveDetector.cpp
+++ b/Simulation/DetSimSD/src/GenericTrackerSensitiveDetector.cpp
@@ -23,10 +23,11 @@ void GenericTrackerSensitiveDetector::Initialize(G4HCofThisEvent* HCE){
 }
 
 G4bool GenericTrackerSensitiveDetector::ProcessHits(G4Step* step, G4TouchableHistory*){
-  
   G4TouchableHandle touchPost = step->GetPostStepPoint()->GetTouchableHandle(); 
   G4TouchableHandle touchPre  = step->GetPreStepPoint()->GetTouchableHandle(); 
   dd4hep::sim::Geant4StepHandler h(step);
+  if (fabs(h.trackDef()->GetPDGCharge()) < 0.01) return true;
+
   dd4hep::Position prePos    = h.prePos();
   dd4hep::Position postPos   = h.postPos();
   dd4hep::Position direction = postPos - prePos;
diff --git a/Simulation/DetSimSD/src/TrackerCombineSensitiveDetector.cpp b/Simulation/DetSimSD/src/TrackerCombineSensitiveDetector.cpp
index 0d53d3b9..591c3cf3 100644
--- a/Simulation/DetSimSD/src/TrackerCombineSensitiveDetector.cpp
+++ b/Simulation/DetSimSD/src/TrackerCombineSensitiveDetector.cpp
@@ -23,6 +23,8 @@ void TrackerCombineSensitiveDetector::Initialize(G4HCofThisEvent* HCE){
 
 G4bool TrackerCombineSensitiveDetector::ProcessHits(G4Step* step, G4TouchableHistory*){
   dd4hep::sim::Geant4StepHandler h(step);
+  if (fabs(h.trackDef()->GetPDGCharge()) < 0.01) return true;
+
   bool return_code = false;
   if ( userData.current == -1 ) userData.start(getCellID(step), step, h.pre);
   else if ( !userData.track || userData.current != h.track->GetTrackID() ) {
-- 
GitLab