Skip to content

Commit

Permalink
refactor: TrackingVolume and Volume interface + functionality (acts-p…
Browse files Browse the repository at this point in the history
…roject#3064)

This PR:
- Marks all of the Gen1 interface of `TrackingVolume` as such, to indicate what we'll supersede in the future
- Makes a slight adjustment to [`TransformRange`](acts-project#3060), for
- Add internal vector of uniquely owned child `TrackingVolume`s in `TrackingVolume`, accessible in a const-preserving way through `TransformRange`.
- Updates the `TrackingVolume` constructors, eliminating one convenience one we don't need, and start adding ones we'll use for Gen3

Blocked by:
- acts-project#3060
  • Loading branch information
paulgessinger authored and EleniXoch committed May 6, 2024
1 parent 3caa9b4 commit aee8ebb
Show file tree
Hide file tree
Showing 12 changed files with 316 additions and 156 deletions.
240 changes: 145 additions & 95 deletions Core/include/Acts/Geometry/TrackingVolume.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
#include "Acts/Utilities/Intersection.hpp"
#include "Acts/Utilities/Logger.hpp"
#include "Acts/Utilities/Ray.hpp"
#include "Acts/Utilities/TransformRange.hpp"

#include <cstddef>
#include <functional>
Expand All @@ -53,6 +54,10 @@ class Surface;
class TrackingVolume;
struct GeometryIdentifierHook;

/// Interface types of the Gen1 geometry model
/// @note This interface is being replaced, and is subject to removal
/// @{

// master typedefs
using TrackingVolumePtr = std::shared_ptr<const TrackingVolume>;
using MutableTrackingVolumePtr = std::shared_ptr<TrackingVolume>;
Expand Down Expand Up @@ -83,6 +88,8 @@ using BoundaryIntersection =
using BoundaryMultiIntersection =
std::pair<SurfaceMultiIntersection, const BoundarySurface*>;

/// @}

/// @class TrackingVolume
///
/// Full Volume description used in Tracking,
Expand Down Expand Up @@ -122,7 +129,7 @@ class TrackingVolume : public Volume {
/// @param containedVolumeArray are the static volumes that fill this volume
/// @param volumeName is a string identifier
TrackingVolume(const Transform3& transform,
std::shared_ptr<VolumeBounds> volbounds,
std::shared_ptr<const VolumeBounds> volbounds,
const std::shared_ptr<const TrackingVolumeArray>&
containedVolumeArray = nullptr,
const std::string& volumeName = "undefined");
Expand All @@ -139,56 +146,22 @@ class TrackingVolume : public Volume {
/// @param denseVolumeVector The contained dense volumes
/// @param volumeName is a string identifier
TrackingVolume(
const Transform3& transform, std::shared_ptr<VolumeBounds> volumeBounds,
const Transform3& transform,
std::shared_ptr<const VolumeBounds> volumeBounds,
std::shared_ptr<const IVolumeMaterial> volumeMaterial,
std::unique_ptr<const LayerArray> staticLayerArray = nullptr,
std::shared_ptr<const TrackingVolumeArray> containedVolumeArray = nullptr,
MutableTrackingVolumeVector denseVolumeVector = {},
const std::string& volumeName = "undefined");

/// Return the associated Layer to the global position
///
/// @param gctx The current geometry context object, e.g. alignment
/// @param position is the associated global position
///
/// @return plain pointer to layer object
const Layer* associatedLayer(const GeometryContext& gctx,
const Vector3& position) const;

/// @brief Resolves the volume into (compatible) Layers
///
/// This is the method for the propagator/extrapolator
/// @tparam options_t Type of navigation options object for decomposition
///
/// @param gctx The current geometry context object, e.g. alignment
/// @param position Position for the search
/// @param direction Direction for the search
/// @param options The templated navigation options
///
/// @return vector of compatible intersections with layers
boost::container::small_vector<LayerIntersection, 10> compatibleLayers(
const GeometryContext& gctx, const Vector3& position,
const Vector3& direction, const NavigationOptions<Layer>& options) const;

/// @brief Returns all boundary surfaces sorted by the user.
///
/// @tparam options_t Type of navigation options object for decomposition
/// @tparam sorter_t Type of the boundary surface sorter
///
/// @param gctx The current geometry context object, e.g. alignment
/// @param position The position for searching
/// @param direction The direction for searching
/// @param options The templated navigation options
/// @param logger A @c Logger instance
///
/// @return is the templated boundary intersection
boost::container::small_vector<BoundaryIntersection, 4> compatibleBoundaries(
const GeometryContext& gctx, const Vector3& position,
const Vector3& direction, const NavigationOptions<Surface>& options,
const Logger& logger = getDummyLogger()) const;
/// Constructor from a regular volume
/// @param volume is the volume to be converted
/// @param volumeName is a string identifier
TrackingVolume(const Volume& volume,
const std::string& volumeName = "undefined");

// @TODO: This needs to be refactored to include Gen3 volumes
/// Return the associated sub Volume, returns THIS if no subVolume exists
///
/// @param gctx The current geometry context object, e.g. alignment
/// @param position is the global position associated with that search
/// @param tol Search position tolerance for dense volumes
Expand All @@ -198,16 +171,6 @@ class TrackingVolume : public Volume {
const Vector3& position,
const double tol = 0.) const;

/// Return the confined static layer array - if it exists
/// @return the BinnedArray of static layers if exists
const LayerArray* confinedLayers() const;

/// Return the confined volumes of this container array - if it exists
std::shared_ptr<const TrackingVolumeArray> confinedVolumes() const;

/// Return the confined dense volumes
const MutableTrackingVolumeVector denseVolumes() const;

/// @brief Visit all reachable surfaces
///
/// @tparam visitor_t Type of the callable visitor
Expand Down Expand Up @@ -292,40 +255,133 @@ class TrackingVolume : public Volume {
volume->visitVolumes(visitor);
}
}

for (const auto& volume : m_volumes) {
volume->visitVolumes(visitor);
}
}

/// Returns the VolumeName - for debug reason, might be depreciated later
const std::string& volumeName() const;

/// Method to return the BoundarySurfaces
const TrackingVolumeBoundaries& boundarySurfaces() const;

/// Return the material of the volume
const IVolumeMaterial* volumeMaterial() const;

/// Return the material of the volume as shared pointer
const std::shared_ptr<const IVolumeMaterial>& volumeMaterialSharedPtr() const;

/// Set the boundary surface material description
/// Set the volume material description
///
/// The material is usually derived in a complicated way and loaded from
/// a framework given source. As various volumes could potentially share the
/// the same material description, it is provided as a shared object
///
/// @param surfaceMaterial Material description of this volume
/// @param bsFace Specifies which boundary surface to assign the material to
void assignBoundaryMaterial(
std::shared_ptr<const ISurfaceMaterial> surfaceMaterial,
BoundarySurfaceFace bsFace);
/// @param material Material description of this volume
void assignVolumeMaterial(std::shared_ptr<const IVolumeMaterial> material);

/// Set the volume material description
/// Return the MotherVolume - if it exists
const TrackingVolume* motherVolume() const;

/// Return the MotherVolume - if it exists
TrackingVolume* motherVolume();

/// Set the MotherVolume
///
/// @param mvol is the mother volume
void setMotherVolume(TrackingVolume* mvol);

using MutableVolumeRange =
detail::TransformRange<detail::Dereference,
std::vector<std::unique_ptr<TrackingVolume>>>;
using VolumeRange = detail::TransformRange<
detail::ConstDereference,
const std::vector<std::unique_ptr<TrackingVolume>>>;

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

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

/// 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.
/// It will throw if @p volume already has a mother volume set
/// @return Reference to the added volume
TrackingVolume& addVolume(std::unique_ptr<TrackingVolume> volume);

/// Interface of @c TrackingVolume in the Gen1 geometry model
/// @note This interface is being replaced, and is subject to removal
///
/// @{

/// Return the associated Layer to the global position
///
/// @param gctx The current geometry context object, e.g. alignment
/// @param position is the associated global position
///
/// @return plain pointer to layer object
const Layer* associatedLayer(const GeometryContext& gctx,
const Vector3& position) const;

/// @brief Resolves the volume into (compatible) Layers
///
/// This is the method for the propagator/extrapolator
/// @tparam options_t Type of navigation options object for decomposition
///
/// @param gctx The current geometry context object, e.g. alignment
/// @param position Position for the search
/// @param direction Direction for the search
/// @param options The templated navigation options
///
/// @return vector of compatible intersections with layers
boost::container::small_vector<LayerIntersection, 10> compatibleLayers(
const GeometryContext& gctx, const Vector3& position,
const Vector3& direction, const NavigationOptions<Layer>& options) const;

/// @brief Returns all boundary surfaces sorted by the user.
///
/// @tparam options_t Type of navigation options object for decomposition
/// @tparam sorter_t Type of the boundary surface sorter
///
/// @param gctx The current geometry context object, e.g. alignment
/// @param position The position for searching
/// @param direction The direction for searching
/// @param options The templated navigation options
/// @param logger A @c Logger instance
///
/// @return is the templated boundary intersection
boost::container::small_vector<BoundaryIntersection, 4> compatibleBoundaries(
const GeometryContext& gctx, const Vector3& position,
const Vector3& direction, const NavigationOptions<Surface>& options,
const Logger& logger = getDummyLogger()) const;

/// Return the confined static layer array - if it exists
/// @return the BinnedArray of static layers if exists
const LayerArray* confinedLayers() const;

/// Return the confined volumes of this container array - if it exists
std::shared_ptr<const TrackingVolumeArray> confinedVolumes() const;

/// Return the confined dense volumes
const MutableTrackingVolumeVector denseVolumes() const;

/// Method to return the BoundarySurfaces
const TrackingVolumeBoundaries& boundarySurfaces() const;

/// Set the boundary surface material description
///
/// The material is usually derived in a complicated way and loaded from
/// a framework given source. As various volumes could potentially share the
/// the same material description, it is provided as a shared object
///
/// @param material Material description of this volume
void assignVolumeMaterial(std::shared_ptr<const IVolumeMaterial> material);
/// @param surfaceMaterial Material description of this volume
/// @param bsFace Specifies which boundary surface to assign the material to
void assignBoundaryMaterial(
std::shared_ptr<const ISurfaceMaterial> surfaceMaterial,
BoundarySurfaceFace bsFace);

/// Glue another tracking volume to this one
/// - if common face is set the glued volumes are sharing the boundary, down
Expand Down Expand Up @@ -382,21 +438,13 @@ class TrackingVolume : public Volume {
/// - positiveFaceXY
GlueVolumesDescriptor& glueVolumesDescriptor();

/// Return the MotherVolume - if it exists
const TrackingVolume* motherVolume() const;

/// Return the MotherVolume - if it exists
TrackingVolume* motherVolume();

/// Set the MotherVolume
///
/// @param mvol is the mother volume
void setMotherVolume(TrackingVolume* mvol);

private:
void connectDenseBoundarySurfaces(
MutableTrackingVolumeVector& confinedDenseVolumes);

/// interlink the layers in this TrackingVolume
void interlinkLayers();

/// Create Boundary Surface
void createBoundarySurfaces();

Expand All @@ -406,6 +454,25 @@ class TrackingVolume : public Volume {
/// @param envelope is the clearance between volume boundary and layer
void synchronizeLayers(double envelope = 1.) const;

// the boundary surfaces
std::vector<TrackingVolumeBoundaryPtr> m_boundarySurfaces;

///(a) static configuration ordered by Binned arrays
/// static layers
std::unique_ptr<const LayerArray> m_confinedLayers = nullptr;

/// Array of Volumes inside the Volume when actin as container
std::shared_ptr<const TrackingVolumeArray> m_confinedVolumes = nullptr;

/// confined dense
MutableTrackingVolumeVector m_confinedDenseVolumes;

/// Volumes to glue Volumes from the outside
GlueVolumesDescriptor* m_glueVolumeDescriptor{nullptr};

/// @}

private:
/// close the Geometry, i.e. set the GeometryIdentifier and assign material
///
/// @param materialDecorator is a dedicated decorator for the
Expand All @@ -422,33 +489,16 @@ class TrackingVolume : public Volume {
std::size_t& vol, const GeometryIdentifierHook& hook,
const Logger& logger = getDummyLogger());

/// interlink the layers in this TrackingVolume
void interlinkLayers();

/// The volume based material the TrackingVolume consists of
std::shared_ptr<const IVolumeMaterial> m_volumeMaterial{nullptr};

/// Remember the mother volume
TrackingVolume* m_motherVolume{nullptr};

// the boundary surfaces
std::vector<TrackingVolumeBoundaryPtr> m_boundarySurfaces;

///(a) static configuration ordered by Binned arrays
/// static layers
std::unique_ptr<const LayerArray> m_confinedLayers = nullptr;

/// Array of Volumes inside the Volume when actin as container
std::shared_ptr<const TrackingVolumeArray> m_confinedVolumes = nullptr;

/// confined dense
MutableTrackingVolumeVector m_confinedDenseVolumes;

/// Volumes to glue Volumes from the outside
GlueVolumesDescriptor* m_glueVolumeDescriptor{nullptr};

/// Volume name for debug reasons & screen output
std::string m_name;

std::vector<std::unique_ptr<TrackingVolume>> m_volumes;
};

} // namespace Acts
Loading

0 comments on commit aee8ebb

Please sign in to comment.