From a1269c4a76e07e053047f97bc5ca72f015a4fd7c Mon Sep 17 00:00:00 2001
From: Andre Sailer <andre.philippe.sailer@cern.ch>
Date: Wed, 8 Feb 2017 14:37:54 +0100
Subject: [PATCH] DDG4 Only create volumemanager if not yet done

---
 DDG4/plugins/Geant4DetectorGeometryConstruction.cpp | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/DDG4/plugins/Geant4DetectorGeometryConstruction.cpp b/DDG4/plugins/Geant4DetectorGeometryConstruction.cpp
index 4645b7ae0..2bb868764 100644
--- a/DDG4/plugins/Geant4DetectorGeometryConstruction.cpp
+++ b/DDG4/plugins/Geant4DetectorGeometryConstruction.cpp
@@ -92,7 +92,10 @@ void Geant4DetectorGeometryConstruction::constructGeo(Geant4DetectorConstruction
   ctxt->geometry = conv.create(world).detach();
   g4map.attach(ctxt->geometry);
   G4VPhysicalVolume* w = ctxt->geometry->world();
-  ctxt->lcdd.apply("DD4hepVolumeManager", 0, 0);
+  // Create Geant4 volume manager only if not yet available
+  if ( not g4map.volumeManager().isValid() ) {
+    ctxt->lcdd.apply("DD4hepVolumeManager", 0, 0);
+  }
   // Create Geant4 volume manager
   g4map.volumeManager();
   if ( m_dumpHierarchy )   {
-- 
GitLab