Skip to content

Commit

Permalink
refactor(geo): Add portals + surfaces to closeGeometry and visitSurfa…
Browse files Browse the repository at this point in the history
…ces (#3678)

Also includes some cleanup.

Related to #3502

Blocked by:
- #3675
  • Loading branch information
paulgessinger authored Oct 4, 2024
1 parent 6cea6b2 commit 238639b
Show file tree
Hide file tree
Showing 2 changed files with 55 additions and 3 deletions.
13 changes: 13 additions & 0 deletions Core/include/Acts/Geometry/TrackingVolume.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
45 changes: 42 additions & 3 deletions Core/src/Geometry/TrackingVolume.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -347,6 +347,31 @@ void TrackingVolume::closeGeometry(
std::unordered_map<GeometryIdentifier, const TrackingVolume*>& 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
Expand Down Expand Up @@ -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<RegularSurface*>(&bSurface));
mutableBSurface.assignGeometryId(boundaryID);
Expand All @@ -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<Layer>(layerPtr);
mutableLayerPtr->closeGeometry(materialDecorator, layerID, hook,
Expand Down Expand Up @@ -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);
}
Expand Down

0 comments on commit 238639b

Please sign in to comment.