diff --git a/Core/include/Acts/Geometry/TrackingVolume.hpp b/Core/include/Acts/Geometry/TrackingVolume.hpp index b208eefa54b..1d1a5b6dc3c 100644 --- a/Core/include/Acts/Geometry/TrackingVolume.hpp +++ b/Core/include/Acts/Geometry/TrackingVolume.hpp @@ -15,6 +15,7 @@ #include "Acts/Geometry/GeometryIdentifier.hpp" #include "Acts/Geometry/GlueVolumesDescriptor.hpp" #include "Acts/Geometry/Layer.hpp" +#include "Acts/Geometry/Portal.hpp" #include "Acts/Geometry/TrackingVolumeVisitorConcept.hpp" #include "Acts/Geometry/Volume.hpp" #include "Acts/Material/IVolumeMaterial.hpp" @@ -181,6 +182,10 @@ class TrackingVolume : public Volume { for (const auto& bs : m_boundarySurfaces) { visitor(&(bs->surfaceRepresentation())); } + + for (const auto& portal : portals()) { + visitor(&portal.surface()); + } } // Internal structure @@ -214,6 +219,14 @@ class TrackingVolume : public Volume { volume->visitSurfaces(visitor, restrictToSensitives); } } + + for (const auto& surface : surfaces()) { + visitor(&surface); + } + + for (const auto& volume : volumes()) { + volume.visitSurfaces(visitor, restrictToSensitives); + } } /// @brief Visit all sensitive surfaces diff --git a/Core/src/Geometry/TrackingVolume.cpp b/Core/src/Geometry/TrackingVolume.cpp index 79ffdc9d180..9bcf9cc969f 100644 --- a/Core/src/Geometry/TrackingVolume.cpp +++ b/Core/src/Geometry/TrackingVolume.cpp @@ -347,6 +347,31 @@ void TrackingVolume::closeGeometry( std::unordered_map& volumeMap, std::size_t& vol, const GeometryIdentifierHook& hook, const Logger& logger) { + if (!boundarySurfaces().empty() && !portals().empty()) { + ACTS_ERROR( + "TrackingVolume::closeGeometry: Volume " + << volumeName() + << " has both boundary surfaces and portals. This is not supported."); + throw std::invalid_argument( + "Volume has both boundary surfaces and portals"); + } + + if (m_confinedVolumes && !volumes().empty()) { + ACTS_ERROR( + "TrackingVolume::closeGeometry: Volume " + << volumeName() + << " has both confined volumes and volumes. This is not supported."); + throw std::invalid_argument("Volume has both confined volumes and volumes"); + } + + if (m_confinedLayers && !surfaces().empty()) { + ACTS_ERROR( + "TrackingVolume::closeGeometry: Volume " + << volumeName() + << " has both confined layers and surfaces. This is not supported."); + throw std::invalid_argument("Volume has both confined layers and surfaces"); + } + // we can construct the volume ID from this auto volumeID = GeometryIdentifier().setVolume(++vol); // assign the Volume ID to the volume itself @@ -379,7 +404,8 @@ void TrackingVolume::closeGeometry( // get the intersection solution auto& bSurface = bSurfIter->surfaceRepresentation(); // create the boundary surface id - auto boundaryID = GeometryIdentifier(volumeID).setBoundary(++iboundary); + iboundary++; + auto boundaryID = GeometryIdentifier(volumeID).setBoundary(iboundary); // now assign to the boundary surface auto& mutableBSurface = *(const_cast(&bSurface)); mutableBSurface.assignGeometryId(boundaryID); @@ -397,7 +423,8 @@ void TrackingVolume::closeGeometry( // loop over the layers for (auto& layerPtr : m_confinedLayers->arrayObjects()) { // create the layer identification - auto layerID = GeometryIdentifier(volumeID).setLayer(++ilayer); + ilayer++; + auto layerID = GeometryIdentifier(volumeID).setLayer(ilayer); // now close the geometry auto mutableLayerPtr = std::const_pointer_cast(layerPtr); mutableLayerPtr->closeGeometry(materialDecorator, layerID, hook, @@ -428,12 +455,24 @@ void TrackingVolume::closeGeometry( GeometryIdentifier::Value iportal = 0; for (auto& portal : portals()) { - auto portalId = GeometryIdentifier(volumeID).setBoundary(++iportal); + iportal++; + auto portalId = GeometryIdentifier(volumeID).setBoundary(iportal); assert(portal.isValid() && "Invalid portal encountered during closing"); portal.surface().assignGeometryId(portalId); } + GeometryIdentifier::Value isensitive = 0; + + for (auto& surface : surfaces()) { + if (surface.associatedDetectorElement() == nullptr) { + continue; + } + isensitive++; + auto sensitiveId = GeometryIdentifier(volumeID).setSensitive(isensitive); + surface.assignGeometryId(sensitiveId); + } + for (auto& volume : volumes()) { volume.closeGeometry(materialDecorator, volumeMap, vol, hook, logger); }