diff --git a/CMakeLists.txt b/CMakeLists.txt index 781367b21fb60164ef4ee840c4289c9de23790de..3c7f12d2f712f6b3625d7044bb255e0e33406959 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -11,8 +11,7 @@ SET( DD4hep_VERSION "${DD4hep_VERSION_MAJOR}.${DD4hep_VERSION_MINOR}" ) SET( DD4hep_SOVERSION "${DD4hep_VERSION_MAJOR}.${DD4hep_VERSION_MINOR}" ) - -set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} ${CMAKE_SOURCE_DIR}/cmake) +set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} ${CMAKE_SOURCE_DIR}/cmake ) set(LIBRARY_OUTPUT_PATH ${PROJECT_BINARY_DIR}/lib) set(EXECUTABLE_OUTPUT_PATH ${PROJECT_BINARY_DIR}/bin) @@ -25,8 +24,6 @@ IF(CMAKE_INSTALL_PREFIX_INITIALIZED_TO_DEFAULT) MESSAGE(STATUS "CMAKE_INSTALL_PREFIX is ${CMAKE_INSTALL_PREFIX} - overwrite with -D CMAKE_INSTALL_PREFIX" ) ENDIF(CMAKE_INSTALL_PREFIX_INITIALIZED_TO_DEFAULT) - - #---Options------------------------------------------------------------------------- option(DD4HEP_USE_XERCESC "Enable 'Detector Builders' based on XercesC" OFF) option(DD4HEP_USE_PYROOT "Enable 'Detector Builders' based on PyROOT" ON) diff --git a/DDCore/src/plugins/LCDDConverter.cpp b/DDCore/src/plugins/LCDDConverter.cpp index 06c5a59ecf3fb6765094f352dd36a6b565149e12..436e628b4c6e215d9bdde7b280d661e7b16f403f 100644 --- a/DDCore/src/plugins/LCDDConverter.cpp +++ b/DDCore/src/plugins/LCDDConverter.cpp @@ -161,8 +161,22 @@ xml_h LCDDConverter::handleMaterial(const string& name, const TGeoMedium* medium /// Dump solid in GDML format to output stream xml_h LCDDConverter::handleSolid(const string& name, const TGeoShape* shape) const { GeometryInfo& geo = data(); - xml_h solid(geo.xmlSolids[shape]); - if ( !solid && shape ) { + SolidMap::iterator sit = geo.xmlSolids.find(shape); + if ( !shape ) { + // This is an invalid volume. Let's pray returning nothing will work, + // and the non-existing solid is also nowhere referenced in the GDML. + return xml_h(0); + } + else if ( sit != geo.xmlSolids.end() ) { + // The solidis already registered. Return the reference + return (*sit).second; + } + else if ( shape->IsA() == TGeoShapeAssembly::Class() ) { + // Assemblies have no shape in GDML. Hence, return nothing. + return xml_h(0); + } + else { + xml_h solid(0); xml_h zplane(0); geo.checkShape(name,shape); if ( shape->IsA() == TGeoBBox::Class() ) { @@ -403,12 +417,6 @@ xml_h LCDDConverter::handleSolid(const string& name, const TGeoShape* shape) c solid.setAttr(_U(dz), s->GetDz()*CM_2_MM); solid.setAttr(_U(lunit),"mm"); } - else if ( shape->IsA() == TGeoShapeAssembly::Class() ) { - //TGeoShapeAssembly* s = (TGeoShapeAssembly*)shape; - //geo.doc_solids.append(solid = xml_elt_t(geo.doc,_U(assembly))); - //solid.setAttr(_U(name),Unicode(name)); - return solid; - } else if ( shape->IsA() == TGeoCompositeShape::Class() ) { char text[32]; const TGeoCompositeShape* s = (const TGeoCompositeShape*)shape; @@ -477,9 +485,8 @@ xml_h LCDDConverter::handleSolid(const string& name, const TGeoShape* shape) c name + " of type " + string(shape->IsA()->GetName()); throw runtime_error(err); } - data().xmlSolids[shape] = solid; + return data().xmlSolids[shape] = solid; } - return solid; } /// Convert the Position into the corresponding Xml object(s).