From 4807193c302562806aaf4d73498970c3d1ebc96a Mon Sep 17 00:00:00 2001
From: lintao <lintao51@gmail.com>
Date: Wed, 16 Mar 2022 15:42:17 +0800
Subject: [PATCH] WIP: debug the memory leakage

---
 Simulation/DetSimGeom/src/AnExampleDetElemTool.cpp | 8 ++++++++
 Simulation/DetSimGeom/src/AnExampleDetElemTool.h   | 2 ++
 Simulation/DetSimSD/src/CalorimeterSensDetTool.cpp | 2 +-
 3 files changed, 11 insertions(+), 1 deletion(-)

diff --git a/Simulation/DetSimGeom/src/AnExampleDetElemTool.cpp b/Simulation/DetSimGeom/src/AnExampleDetElemTool.cpp
index 001675db..53d9673e 100644
--- a/Simulation/DetSimGeom/src/AnExampleDetElemTool.cpp
+++ b/Simulation/DetSimGeom/src/AnExampleDetElemTool.cpp
@@ -76,6 +76,14 @@ AnExampleDetElemTool::getLV() {
 
 void
 AnExampleDetElemTool::ConstructSDandField() {
+
+    // DEBUG ONLY: turn off all the SD.
+    if (not m_SD_enabled) {
+        warning() << "All the Sensitive Detectors will be disabled by default. " << endmsg;
+        return;
+    }
+
+
     //
     // Construct SD using DD4hep.
     // Refer to FCCSW/Detector/DetComponents/src/
diff --git a/Simulation/DetSimGeom/src/AnExampleDetElemTool.h b/Simulation/DetSimGeom/src/AnExampleDetElemTool.h
index 1ad3702f..9606d5cc 100644
--- a/Simulation/DetSimGeom/src/AnExampleDetElemTool.h
+++ b/Simulation/DetSimGeom/src/AnExampleDetElemTool.h
@@ -31,6 +31,8 @@ private:
     // DD4hep XML compact file path
     Gaudi::Property<std::string> m_dd4hep_xmls{this, "detxml"};
 
+    Gaudi::Property<bool> m_SD_enabled{this, "SDenabled", true};
+
     SmartIF<IGeomSvc> m_geosvc;
     ToolHandle<ISensDetTool> m_calo_sdtool;
     ToolHandle<ISensDetTool> m_driftchamber_sdtool;
diff --git a/Simulation/DetSimSD/src/CalorimeterSensDetTool.cpp b/Simulation/DetSimSD/src/CalorimeterSensDetTool.cpp
index 4219802f..f213a3b4 100644
--- a/Simulation/DetSimSD/src/CalorimeterSensDetTool.cpp
+++ b/Simulation/DetSimSD/src/CalorimeterSensDetTool.cpp
@@ -43,7 +43,7 @@ CalorimeterSensDetTool::createSD(const std::string& name) {
       }
     }
     G4VSensitiveDetector* sd = new CaloSensitiveDetector(name, *dd4hep_geo, is_merge_enabled);
-    debug() << name << " set to merge true/false = " << is_merge_enabled << endmsg;
+    warning() << name << " set to merge true/false = " << is_merge_enabled << endmsg;
 
     return sd;
 }
-- 
GitLab