From 2a4fdd53f2fc672b7222f00b85585b7332353c73 Mon Sep 17 00:00:00 2001 From: Andre Sailer <andre.philippe.sailer@cern.ch> Date: Fri, 27 Jan 2017 15:19:13 +0100 Subject: [PATCH] SurfaceHelper/IDDecoder: avoid multiple instantiations of the VolumeManager pick the VolumeManager from lcdd, and create it if necessary instead of creating a static one in SurfaceHelper This is necessary in case someone needs a volumemanger before surfaceHelper is called. --- DDCore/src/plugins/StandardPlugins.cpp | 1 + DDRec/src/IDDecoder.cpp | 3 ++- DDRec/src/SurfaceHelper.cpp | 8 +++++++- 3 files changed, 10 insertions(+), 2 deletions(-) diff --git a/DDCore/src/plugins/StandardPlugins.cpp b/DDCore/src/plugins/StandardPlugins.cpp index 1942cbcdc..ec4128563 100644 --- a/DDCore/src/plugins/StandardPlugins.cpp +++ b/DDCore/src/plugins/StandardPlugins.cpp @@ -461,6 +461,7 @@ DECLARE_APPLY(DD4hepXMLProcessor,process_xml_doc) * \date 01/04/2014 */ static long load_volmgr(LCDD& lcdd, int, char**) { + printout(INFO,"DD4hepVolumeManager","**** running plugin DD4hepVolumeManager ! " ); try { LCDDImp* imp = dynamic_cast<LCDDImp*>(&lcdd); if ( imp ) { diff --git a/DDRec/src/IDDecoder.cpp b/DDRec/src/IDDecoder.cpp index ef872386a..afe888b1e 100644 --- a/DDRec/src/IDDecoder.cpp +++ b/DDRec/src/IDDecoder.cpp @@ -34,7 +34,8 @@ IDDecoder::IDDecoder() { LCDD& lcdd = LCDD::getInstance(); _volumeManager = lcdd.volumeManager(); if (not _volumeManager.isValid()) { - _volumeManager = VolumeManager(lcdd, "volman", lcdd.world(), Readout(), VolumeManager::TREE); + lcdd.apply("DD4hepVolumeManager",0,0); + _volumeManager = lcdd.volumeManager(); } _tgeoMgr = lcdd.world().volume()->GetGeoManager(); } diff --git a/DDRec/src/SurfaceHelper.cpp b/DDRec/src/SurfaceHelper.cpp index 728f0b308..e172813d6 100644 --- a/DDRec/src/SurfaceHelper.cpp +++ b/DDRec/src/SurfaceHelper.cpp @@ -27,7 +27,13 @@ namespace DD4hep { // have to populate the volume manager once in order to have // the volumeIDs attached to the DetElements LCDD& lcdd = LCDD::getInstance(); - static VolumeManager volMgr( lcdd , "volMan" , lcdd.world() ) ; + VolumeManager volMgr = lcdd.volumeManager(); + if(not volMgr.isValid()) { + // VolumeManager initialised by DD4hepVolumeManager plugin + lcdd.apply("DD4hepVolumeManager",0,0); + volMgr = lcdd.volumeManager(); + } + //------------------ breadth first tree traversal --------- -- GitLab