Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(geo): TrackingVolume gets portal storage #3673

Merged
merged 4 commits into from
Oct 1, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions Core/include/Acts/Geometry/Portal.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -212,6 +212,10 @@ class Portal {
/// @return The portal surface
const RegularSurface& surface() const;

/// Access the portal surface that is shared between the two links
/// @return The portal surface
RegularSurface& surface();

private:
/// Helper to check surface equivalence without checking material status. This
/// is needed because we allow fusing portals with surfaces that are
Expand Down
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
5 changes: 5 additions & 0 deletions Core/src/Geometry/Portal.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -172,6 +172,11 @@ const RegularSurface& Portal::surface() const {
return *m_surface;
}

RegularSurface& Portal::surface() {
assert(m_surface != nullptr);
return *m_surface;
}

Portal Portal::merge(const GeometryContext& gctx, Portal& aPortal,
Portal& bPortal, BinningValue direction,
const Logger& logger) {
Expand Down
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
Loading