From cb29eb83af307fc1cc16fb2aa3e4554bba896c1c Mon Sep 17 00:00:00 2001
From: Andre Sailer <andre.philippe.sailer@cern.ch>
Date: Wed, 29 May 2024 18:21:30 +0200
Subject: [PATCH] GeoHandler: store TGeoVolumes in deterministic order

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

diff --git a/DDCore/include/DD4hep/GeoHandler.h b/DDCore/include/DD4hep/GeoHandler.h
index 6abb8fd91..b138d2547 100644
--- a/DDCore/include/DD4hep/GeoHandler.h
+++ b/DDCore/include/DD4hep/GeoHandler.h
@@ -59,7 +59,8 @@ namespace dd4hep {
        */
       class GeometryInfo {
       public:
-        std::set<TGeoShape*>   solids;
+        std::vector<TGeoShape*>   solids;
+        std::set<TGeoShape*>   solid_set;
         std::set<Volume>       volumeSet;
         std::vector<Volume>    volumes;
         std::set<VisAttr>      vis;
diff --git a/DDCore/src/GeoHandler.cpp b/DDCore/src/GeoHandler.cpp
index 38a10f5f6..8cd4fee14 100644
--- a/DDCore/src/GeoHandler.cpp
+++ b/DDCore/src/GeoHandler.cpp
@@ -44,7 +44,9 @@ namespace {
       collectSolid(geo, name + "_left", name + "_left", boolean->GetLeftShape(), boolean->GetLeftMatrix());
       collectSolid(geo, name + "_right", name + "_right", boolean->GetRightShape(), boolean->GetRightMatrix());
     }
-    geo.solids.emplace(shape);
+    if(geo.solid_set.emplace(shape).second) {
+      geo.solids.push_back(shape);
+    }
     geo.trafos.emplace_back(node, matrix);
   }
 }
-- 
GitLab