From d764dd189bb4b3203a60b8ca653fece40403b5d0 Mon Sep 17 00:00:00 2001
From: Markus Frank <Markus.Frank@cern.ch>
Date: Fri, 3 Mar 2023 14:28:27 +0100
Subject: [PATCH] Have named object maps

---
 DDCore/src/DetectorImp.cpp | 15 ++++++++++++---
 1 file changed, 12 insertions(+), 3 deletions(-)

diff --git a/DDCore/src/DetectorImp.cpp b/DDCore/src/DetectorImp.cpp
index 12262bb72..fe5c88126 100644
--- a/DDCore/src/DetectorImp.cpp
+++ b/DDCore/src/DetectorImp.cpp
@@ -636,12 +636,21 @@ Handle<NamedObject> DetectorImp::getRefChild(const HandleMap& e, const string& n
     return (*i).second;
   }
   if (do_throw) {
+    union ptr {
+      const ObjectHandleMap* omap;
+      const char* c;
+      const void* other;
+      ptr(const void* p) { other = p; }
+    };
     int cnt = 0;
-    cout << "GetRefChild: Failed to find child with name: " << name
-         << " Map contains " << e.size() << " elements." << endl;
+    std::string nam = "";
+    ptr m(&e), ref(this);
+    if ( ref.c > m.c && m.c < ref.c+sizeof(*this) ) nam = m.omap->name;
+    cout << "GetRefChild: Failed to find child with name: '" << name
+	 << "'. Map " << nam << " contains " << e.size() << " elements." << endl;
     for(i=e.begin(); i!=e.end(); ++i)
       cout << "   " << cnt << "  " << (*i).first << endl;
-    throw runtime_error("Cannot find a child with the reference name:" + name);
+    throw runtime_error(nam+": Cannot find a child with the reference name:" + name);
   }
   return 0;
 }
-- 
GitLab