From 80f65934efa6fc502986f51d5b2a44e9b5c6ab84 Mon Sep 17 00:00:00 2001
From: Wouter Deconinck <wdconinc@gmail.com>
Date: Wed, 26 Jul 2023 11:58:41 -0500
Subject: [PATCH] feat: make Detector::detectors(type, throw_exc) const

---
 DDCore/include/DD4hep/Detector.h    | 2 +-
 DDCore/include/DD4hep/DetectorImp.h | 2 +-
 DDCore/src/DetectorImp.cpp          | 2 +-
 3 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/DDCore/include/DD4hep/Detector.h b/DDCore/include/DD4hep/Detector.h
index 46a4c0d95..76d8b8021 100644
--- a/DDCore/include/DD4hep/Detector.h
+++ b/DDCore/include/DD4hep/Detector.h
@@ -194,7 +194,7 @@ namespace dd4hep {
        is not present. Otherwise an empty detector container is returned.
     */
     virtual const std::vector<DetElement>& detectors(const std::string& type,
-                                                     bool throw_exc=false) = 0;
+                                                     bool throw_exc=false) const = 0;
 
     /// Access a set of subdetectors according to several sensitive types.
     virtual std::vector<DetElement> detectors(const std::string& type1,
diff --git a/DDCore/include/DD4hep/DetectorImp.h b/DDCore/include/DD4hep/DetectorImp.h
index 175940116..37dae4c5f 100644
--- a/DDCore/include/DD4hep/DetectorImp.h
+++ b/DDCore/include/DD4hep/DetectorImp.h
@@ -320,7 +320,7 @@ namespace dd4hep {
        - If throw_exc is set to true, an exception is thrown if the type
        is not present. Otherwise an empty detector container is returned.
     */
-    virtual const std::vector<DetElement>& detectors(const std::string& type, bool throw_exc)  override;
+    virtual const std::vector<DetElement>& detectors(const std::string& type, bool throw_exc) const override;
 
     /// Access a set of subdetectors according to several sensitive types.
     virtual std::vector<DetElement> detectors(const std::string& type1,
diff --git a/DDCore/src/DetectorImp.cpp b/DDCore/src/DetectorImp.cpp
index 9ab77d86d..7e5eeb4d3 100644
--- a/DDCore/src/DetectorImp.cpp
+++ b/DDCore/src/DetectorImp.cpp
@@ -572,7 +572,7 @@ vector<string> DetectorImp::detectorTypes() const  {
 }
 
 /// Access a set of subdetectors according to the sensitive type.
-const vector<DetElement>& DetectorImp::detectors(const string& type, bool throw_exc)  {
+const vector<DetElement>& DetectorImp::detectors(const string& type, bool throw_exc) const {
   if ( m_manager->IsClosed() ) {
     DetectorTypeMap::const_iterator i=m_detectorTypes.find(type);
     if ( i != m_detectorTypes.end() ) return (*i).second;
-- 
GitLab