Skip to content

Commit

Permalink
feat(geo): TrackingVolume gets portal storage
Browse files Browse the repository at this point in the history
  • Loading branch information
paulgessinger committed Oct 1, 2024
1 parent a30c372 commit 074f2a3
Show file tree
Hide file tree
Showing 2 changed files with 47 additions and 0 deletions.
22 changes: 22 additions & 0 deletions Core/include/Acts/Geometry/TrackingVolume.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ class IVolumeMaterial;
class Surface;
class TrackingVolume;
struct GeometryIdentifierHook;
class Portal;

/// Interface types of the Gen1 geometry model
/// @note This interface is being replaced, and is subject to removal
Expand Down Expand Up @@ -301,6 +302,26 @@ class TrackingVolume : public Volume {
/// @return the range of volumes
MutableVolumeRange volumes();

using MutablePortalRange =
detail::TransformRange<detail::Dereference,
std::vector<std::shared_ptr<Portal>>>;

using PortalRange =
detail::TransformRange<detail::ConstDereference,
const std::vector<std::shared_ptr<Portal>>>;

/// Return all portals registered under this tracking volume
/// @return the range of portals
PortalRange portals() const;

/// Return mutable view of the registered portals under this tracking volume
/// @return the range of portals
MutablePortalRange portals();

/// Add a portal to this tracking volume
/// @param portal The portal to add
void addPortal(std::shared_ptr<Portal> portal);

/// Add a child volume to this tracking volume
/// @param volume The volume to add
/// @note The @p volume will have its mother volume assigned to @p this.
Expand Down Expand Up @@ -494,6 +515,7 @@ class TrackingVolume : public Volume {
std::string m_name;

std::vector<std::unique_ptr<TrackingVolume>> m_volumes;
std::vector<std::shared_ptr<Portal>> m_portals;
};

} // namespace Acts
25 changes: 25 additions & 0 deletions Core/src/Geometry/TrackingVolume.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
#include "Acts/Definitions/Direction.hpp"
#include "Acts/Geometry/GeometryIdentifier.hpp"
#include "Acts/Geometry/GlueVolumesDescriptor.hpp"
#include "Acts/Geometry/Portal.hpp"
#include "Acts/Geometry/VolumeBounds.hpp"
#include "Acts/Material/IMaterialDecorator.hpp"
#include "Acts/Material/IVolumeMaterial.hpp"
Expand Down Expand Up @@ -424,6 +425,18 @@ void TrackingVolume::closeGeometry(
logger);
}
}

GeometryIdentifier::Value iportal = 0;
for (auto& portal : portals()) {
auto portalId = GeometryIdentifier(volumeID).setBoundary(++iportal);
assert(portal.isValid() && "Invalid portal encountered during closing");

portal.surface().assignGeometryId(portalId);
}

for (auto& volume : volumes()) {
volume.closeGeometry(materialDecorator, volumeMap, vol, hook, logger);
}
}

// Returns the boundary surfaces ordered in probability to hit them based on
Expand Down Expand Up @@ -641,4 +654,16 @@ TrackingVolume& TrackingVolume::addVolume(
return *m_volumes.back();
}

TrackingVolume::PortalRange TrackingVolume::portals() const {
return PortalRange{m_portals};
}

TrackingVolume::MutablePortalRange TrackingVolume::portals() {
return MutablePortalRange{m_portals};
}

void TrackingVolume::addPortal(std::shared_ptr<Portal> portal) {
m_portals.push_back(std::move(portal));
}

} // namespace Acts

0 comments on commit 074f2a3

Please sign in to comment.