From 7a7c0519e29df5e75469d039d09038d5de49ce22 Mon Sep 17 00:00:00 2001
From: lintao <lintao@ihep.ac.cn>
Date: Wed, 26 Feb 2025 15:38:29 +0800
Subject: [PATCH] WIP: save secondary tracks with Ek, rho, z

---
 .../DetSimAna/src/Edm4hepWriterAnaElemTool.cpp       | 12 +++++++++++-
 Simulation/DetSimAna/src/Edm4hepWriterAnaElemTool.h  |  4 ++++
 2 files changed, 15 insertions(+), 1 deletion(-)

diff --git a/Simulation/DetSimAna/src/Edm4hepWriterAnaElemTool.cpp b/Simulation/DetSimAna/src/Edm4hepWriterAnaElemTool.cpp
index 7d6c24cc..ad277de6 100644
--- a/Simulation/DetSimAna/src/Edm4hepWriterAnaElemTool.cpp
+++ b/Simulation/DetSimAna/src/Edm4hepWriterAnaElemTool.cpp
@@ -452,8 +452,19 @@ Edm4hepWriterAnaElemTool::PostUserTrackingAction(const G4Track* track) {
                 G4ParticleDefinition* secparticle = sectrk->GetDefinition();
                 const G4VProcess* creatorProcess = sectrk->GetCreatorProcess();
 
+                double Ek = sectrk->GetKineticEnergy();
+                const auto& pos = sectrk->GetPosition();
+                
                 // select the necessary processes
                 if (creatorProcess==proc_decay || creatorProcess==photon_general || creatorProcess==photon_conv) {
+
+                } else if (Ek >= m_sectrk_Ek.value() && fabs(pos.rho()) < m_sectrk_rho.value() && fabs(pos.z()) < m_sectrk_z.value()) {
+                    // if the Ek > x 
+                } else {
+                    // skip this secondary track
+                    continue;
+                }
+                
                     debug() << "Creator Process is " << creatorProcess->GetProcessName()
                             << " for secondary particle: "
                             << " idx: " << i
@@ -502,7 +513,6 @@ Edm4hepWriterAnaElemTool::PostUserTrackingAction(const G4Track* track) {
                     debug() << " Appending MCParticle: (id: " 
                             << mcp.getObjectID().index << ")"
                             << endmsg;
-                }
             }
         }
 
diff --git a/Simulation/DetSimAna/src/Edm4hepWriterAnaElemTool.h b/Simulation/DetSimAna/src/Edm4hepWriterAnaElemTool.h
index 7fcea799..014ef912 100644
--- a/Simulation/DetSimAna/src/Edm4hepWriterAnaElemTool.h
+++ b/Simulation/DetSimAna/src/Edm4hepWriterAnaElemTool.h
@@ -73,6 +73,10 @@ private:
          "HcalBarrel", "HcalEndcaps", "HcalEndcapRing"}, 
         "Names of the Calorimeter collections (without suffix Collection)"};
 
+    Gaudi::Property<double> m_sectrk_Ek{this, "SecTrackEk", 100., "Ek (MeV) threshold to record a secondary track"};
+    Gaudi::Property<double> m_sectrk_rho{this, "SecTrackRho", 1000., "rho (mm) threshold to record a secondary track"};
+    Gaudi::Property<double> m_sectrk_z{this, "SecTrackZ", 2000., "rho (mm) threshold to record a secondary track"};
+    
 private:
     // in order to associate the hit contribution with the primary track,
     // we have a bookkeeping of every track.
-- 
GitLab