Skip to content

Commit

Permalink
Merge branch 'main' into UseConcepts
Browse files Browse the repository at this point in the history
  • Loading branch information
kodiakhq[bot] authored Oct 15, 2024
2 parents 62c6eda + e3b33cc commit 48789fb
Show file tree
Hide file tree
Showing 34 changed files with 1,428 additions and 566 deletions.
35 changes: 25 additions & 10 deletions Core/include/Acts/Geometry/CompositePortalLink.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,9 @@

namespace Acts {

class GridPortalLink;
class Surface;

/// Composite portal links can graft together other portal link instances, for
/// example grids that could not be merged due to invalid binnings.
///
Expand Down Expand Up @@ -49,6 +52,15 @@ class CompositePortalLink final : public PortalLinkBase {
std::unique_ptr<PortalLinkBase> b, BinningValue direction,
bool flatten = true);

/// Construct a composite portal from any number of arbitrary other portal
/// links. The only requirement is that the portal link surfaces are
/// mergeable.
/// @param links The portal links
/// @param direction The binning direction
/// @param flatten If true, the composite will flatten any nested composite
CompositePortalLink(std::vector<std::unique_ptr<PortalLinkBase>> links,
BinningValue direction, bool flatten = true);

/// Print the composite portal link
/// @param os The output stream
void toStream(std::ostream& os) const override;
Expand Down Expand Up @@ -81,19 +93,22 @@ class CompositePortalLink final : public PortalLinkBase {
/// @return The number of children
std::size_t size() const;

private:
/// Helper function to construct a merged surface from two portal links along
/// a given direction
/// @param a The first portal link
/// @param b The second portal link
/// @param direction The merging direction
/// @return The merged surface
static std::shared_ptr<RegularSurface> mergedSurface(const PortalLinkBase* a,
const PortalLinkBase* b,
BinningValue direction);
/// (Potentially) create a grid portal link that represents this composite
/// portal link.
/// @note This only works, if the composite is **flat** and only contains
/// **trivial portal links**. If these preconditions are not met, this
/// function returns a nullptr.
/// @param gctx The geometry context
/// @param logger The logger
/// @return The grid portal link
std::unique_ptr<GridPortalLink> makeGrid(const GeometryContext& gctx,
const Logger& logger) const;

private:
boost::container::small_vector<std::unique_ptr<PortalLinkBase>, 4>
m_children{};

BinningValue m_direction;
};

} // namespace Acts
13 changes: 13 additions & 0 deletions Core/include/Acts/Geometry/CylinderVolumeBounds.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
#pragma once

#include "Acts/Definitions/Algebra.hpp"
#include "Acts/Geometry/BoundarySurfaceFace.hpp"
#include "Acts/Geometry/Volume.hpp"
#include "Acts/Geometry/VolumeBounds.hpp"
#include "Acts/Utilities/BinningType.hpp"
Expand Down Expand Up @@ -80,6 +81,18 @@ class CylinderVolumeBounds : public VolumeBounds {
eSize
};

/// Enum describing the possible faces of a cylinder volume
/// @note These values are synchronized with the BoundarySurfaceFace enum.
/// Once Gen1 is removed, this can be changed.
enum class Face : unsigned int {
PositiveDisc = BoundarySurfaceFace::positiveFaceXY,
NegativeDisc = BoundarySurfaceFace::negativeFaceXY,
OuterCylinder = BoundarySurfaceFace::tubeOuterCover,
InnerCylinder = BoundarySurfaceFace::tubeInnerCover,
NegativePhiPlane = BoundarySurfaceFace::tubeSectorNegativePhi,
PositivePhiPlane = BoundarySurfaceFace::tubeSectorPositivePhi
};

CylinderVolumeBounds() = delete;

/// Constructor
Expand Down
22 changes: 6 additions & 16 deletions Core/include/Acts/Geometry/CylinderVolumeStack.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -85,23 +85,12 @@ class CylinderVolumeStack : public Volume {
/// construction.
/// @param volbounds is the new bounds
/// @param transform is the new transform
/// @pre The volume bounds need to be of type
/// @c CylinderVolumeBounds.
void update(std::shared_ptr<VolumeBounds> volbounds,
std::optional<Transform3> transform = std::nullopt) override;

/// Update the volume bounds and transform. This
/// will update the bounds of all volumes in the stack
/// to accommodate the new bounds and optionally create
/// gap volumes according to the resize strategy set during
/// construction.
/// @param newBounds is the new bounds
/// @param transform is the new transform
/// @param logger is the logger
/// @pre The volume bounds need to be of type
/// @c CylinderVolumeBounds.
void update(std::shared_ptr<CylinderVolumeBounds> newBounds,
std::optional<Transform3> transform, const Logger& logger);
void update(std::shared_ptr<VolumeBounds> volbounds,
std::optional<Transform3> transform = std::nullopt,
const Logger& logger = getDummyLogger()) override;

/// Access the gap volume that were created during attachment or resizing.
/// @return the vector of gap volumes
Expand Down Expand Up @@ -133,11 +122,12 @@ class CylinderVolumeStack : public Volume {
Acts::Logging::Level lvl);

/// Helper function that prints output helping in debugging overlaps
/// @param direction is the overlap check direction
/// @param a is the first volume
/// @param b is the second volume
/// @param logger is the logger
static void overlapPrint(const VolumeTuple& a, const VolumeTuple& b,
const Logger& logger);
static void overlapPrint(BinningValue direction, const VolumeTuple& a,
const VolumeTuple& b, const Logger& logger);

/// Helper function that checks if volumes are properly aligned
/// for attachment.
Expand Down
11 changes: 5 additions & 6 deletions Core/include/Acts/Geometry/GridPortalLink.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -381,12 +381,12 @@ class GridPortalLink : public PortalLinkBase {
/// Helper function to get grid bin content in type-eraased way.
/// @param indices The bin indices
/// @return The tracking volume at the bin
virtual TrackingVolume*& atLocalBins(IndexType indices) = 0;
virtual const TrackingVolume*& atLocalBins(IndexType indices) = 0;

/// Helper function to get grid bin content in type-eraased way.
/// @param indices The bin indices
/// @return The tracking volume at the bin
virtual TrackingVolume* atLocalBins(IndexType indices) const = 0;
virtual const TrackingVolume* atLocalBins(IndexType indices) const = 0;

private:
BinningValue m_direction;
Expand All @@ -399,7 +399,7 @@ template <typename... Axes>
class GridPortalLinkT final : public GridPortalLink {
public:
/// The internal grid type
using GridType = Grid<TrackingVolume*, Axes...>;
using GridType = Grid<const TrackingVolume*, Axes...>;

/// The dimension of the grid
static constexpr std::size_t DIM = sizeof...(Axes);
Expand Down Expand Up @@ -530,7 +530,6 @@ class GridPortalLinkT final : public GridPortalLink {
return m_grid.atPosition(m_projection(position));
}

protected:
/// Type erased access to the number of bins
/// @return The number of bins in each direction
IndexType numLocalBins() const override {
Expand All @@ -545,7 +544,7 @@ class GridPortalLinkT final : public GridPortalLink {
/// Type erased local bin access
/// @param indices The bin indices
/// @return The tracking volume at the bin
TrackingVolume*& atLocalBins(IndexType indices) override {
const TrackingVolume*& atLocalBins(IndexType indices) override {
throw_assert(indices.size() == DIM, "Invalid number of indices");
typename GridType::index_t idx;
for (std::size_t i = 0; i < DIM; i++) {
Expand All @@ -557,7 +556,7 @@ class GridPortalLinkT final : public GridPortalLink {
/// Type erased local bin access
/// @param indices The bin indices
/// @return The tracking volume at the bin
TrackingVolume* atLocalBins(IndexType indices) const override {
const TrackingVolume* atLocalBins(IndexType indices) const override {
throw_assert(indices.size() == DIM, "Invalid number of indices");
typename GridType::index_t idx;
for (std::size_t i = 0; i < DIM; i++) {
Expand Down
18 changes: 4 additions & 14 deletions Core/include/Acts/Geometry/PortalShell.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

#pragma once

#include "Acts/Geometry/BoundarySurfaceFace.hpp"
#include "Acts/Geometry/CylinderVolumeBounds.hpp"
#include "Acts/Utilities/BinningType.hpp"
#include "Acts/Utilities/Logger.hpp"

Expand Down Expand Up @@ -68,19 +68,9 @@ class PortalShellBase {
/// volumes
class CylinderPortalShell : public PortalShellBase {
public:
/// Enum describing the possible faces of a cylinder portal shell
/// @note These values are synchronized with the BoundarySurfaceFace enum.
/// Once Gen1 is removed, this can be changed.
enum class Face : unsigned int {
PositiveDisc = BoundarySurfaceFace::positiveFaceXY,
NegativeDisc = BoundarySurfaceFace::negativeFaceXY,
OuterCylinder = BoundarySurfaceFace::tubeOuterCover,
InnerCylinder = BoundarySurfaceFace::tubeInnerCover,
NegativePhiPlane = BoundarySurfaceFace::tubeSectorNegativePhi,
PositivePhiPlane = BoundarySurfaceFace::tubeSectorPositivePhi
};

using enum Face;
using Face = CylinderVolumeBounds::Face;

using enum CylinderVolumeBounds::Face;

/// Retrieve the portal associated to the given face. Can be nullptr if unset.
/// @param face The face to retrieve the portal for
Expand Down
4 changes: 4 additions & 0 deletions Core/include/Acts/Geometry/TrivialPortalLink.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,10 @@ class TrivialPortalLink final : public PortalLinkBase {
const GeometryContext& gctx, const Vector3& position,
double tolerance = s_onSurfaceTolerance) const override;

/// Get the single volume that this trivial portal link is associated with
/// @return The target volume
const TrackingVolume& volume() const;

private:
TrackingVolume* m_volume;
};
Expand Down
5 changes: 4 additions & 1 deletion Core/include/Acts/Geometry/Volume.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
#include "Acts/Geometry/GeometryObject.hpp"
#include "Acts/Utilities/BinningType.hpp"
#include "Acts/Utilities/BoundingBox.hpp"
#include "Acts/Utilities/Logger.hpp"

#include <iosfwd>
#include <memory>
Expand Down Expand Up @@ -83,8 +84,10 @@ class Volume : public GeometryObject {
/// Set the volume bounds and optionally also update the volume transform
/// @param volbounds The volume bounds to be assigned
/// @param transform The transform to be assigned, can be optional
/// @param logger A logger object to log messages
virtual void update(std::shared_ptr<VolumeBounds> volbounds,
std::optional<Transform3> transform = std::nullopt);
std::optional<Transform3> transform = std::nullopt,
const Logger& logger = Acts::getDummyLogger());

/// Construct bounding box for this shape
/// @param envelope Optional envelope to add / subtract from min/max
Expand Down
10 changes: 10 additions & 0 deletions Core/include/Acts/Seeding/SeedFinder.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,16 @@ class SeedFinder {
const Acts::Range1D<float>& rMiddleSPRange) const;

private:
/// Given a middle space point candidate, get the proper radius validity range
/// In case the radius range changes according to the z-bin we need to
/// retrieve the proper range. We can do this computation only once, since
/// all the middle space point candidates belong to the same z-bin
/// @param spM space point candidate to be used as middle SP in a seed
/// @param rMiddleSPRange range object containing the minimum and maximum r for middle SP for a certain z bin.
std::pair<float, float> retrieveRadiusRangeForMiddle(
const external_spacepoint_t& spM,
const Acts::Range1D<float>& rMiddleSPRange) const;

/// Iterates over dublets and tests the compatibility between them by applying
/// a series of cuts that can be tested with only two SPs
/// @param options frequently changing configuration (like beam position)
Expand Down
61 changes: 31 additions & 30 deletions Core/include/Acts/Seeding/SeedFinder.ipp
Original file line number Diff line number Diff line change
Expand Up @@ -106,40 +106,20 @@ void SeedFinder<external_spacepoint_t, grid_t, platform_t>::createSeedsForGroup(
return;
}

// we compute this here since all middle space point candidates belong to the
// same z-bin
auto [minRadiusRangeForMiddle, maxRadiusRangeForMiddle] =
retrieveRadiusRangeForMiddle(*middleSPs.front(), rMiddleSPRange);
for (const external_spacepoint_t* spM : middleSPs) {
const float rM = spM->radius();

// check if spM is outside our radial region of interest
if (m_config.useVariableMiddleSPRange) {
if (rM < rMiddleSPRange.min()) {
continue;
}
if (rM > rMiddleSPRange.max()) {
// break because SPs are sorted in r
break;
}
} else if (!m_config.rRangeMiddleSP.empty()) {
/// get zBin position of the middle SP
auto pVal = std::lower_bound(m_config.zBinEdges.begin(),
m_config.zBinEdges.end(), spM->z());
int zBin = std::distance(m_config.zBinEdges.begin(), pVal);
/// protects against zM at the limit of zBinEdges
zBin == 0 ? zBin : --zBin;
if (rM < m_config.rRangeMiddleSP[zBin][0]) {
continue;
}
if (rM > m_config.rRangeMiddleSP[zBin][1]) {
// break because SPs are sorted in r
break;
}
} else {
if (rM < m_config.rMinMiddle) {
continue;
}
if (rM > m_config.rMaxMiddle) {
// break because SPs are sorted in r
break;
}
if (rM < minRadiusRangeForMiddle) {
continue;
}
if (rM > maxRadiusRangeForMiddle) {
// break because SPs are sorted in r
break;
}

const float zM = spM->z();
Expand Down Expand Up @@ -829,4 +809,25 @@ SeedFinder<external_spacepoint_t, grid_t, platform_t>::filterCandidates(
} // loop on bottoms
}

template <typename external_spacepoint_t, typename grid_t, typename platform_t>
std::pair<float, float> SeedFinder<external_spacepoint_t, grid_t, platform_t>::
retrieveRadiusRangeForMiddle(
const external_spacepoint_t& spM,
const Acts::Range1D<float>& rMiddleSPRange) const {
if (m_config.useVariableMiddleSPRange) {
return std::make_pair(rMiddleSPRange.min(), rMiddleSPRange.max());
}
if (!m_config.rRangeMiddleSP.empty()) {
/// get zBin position of the middle SP
auto pVal = std::lower_bound(m_config.zBinEdges.begin(),
m_config.zBinEdges.end(), spM.z());
int zBin = std::distance(m_config.zBinEdges.begin(), pVal);
/// protects against zM at the limit of zBinEdges
zBin == 0 ? zBin : --zBin;
return std::make_pair(m_config.rRangeMiddleSP[zBin][0],
m_config.rRangeMiddleSP[zBin][1]);
}
return std::make_pair(m_config.rMinMiddle, m_config.rMaxMiddle);
}

} // namespace Acts
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,8 @@ template <Acts::CylindricalGridElement external_spacepoint_t>
using CylindricalSpacePointGrid = Acts::Grid<
std::vector<const external_spacepoint_t*>,
Acts::Axis<Acts::AxisType::Equidistant, Acts::AxisBoundaryType::Closed>,
Acts::Axis<Acts::AxisType::Variable, Acts::AxisBoundaryType::Bound>,
Acts::Axis<Acts::AxisType::Variable, Acts::AxisBoundaryType::Bound>>;
Acts::Axis<Acts::AxisType::Variable, Acts::AxisBoundaryType::Open>,
Acts::Axis<Acts::AxisType::Variable, Acts::AxisBoundaryType::Open>>;

/// Cylindrical Binned Group
template <typename external_spacepoint_t>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -139,8 +139,8 @@ Acts::CylindricalSpacePointGridCreator::createGrid(
config.rBinEdges.end());
}

Axis<AxisType::Variable, AxisBoundaryType::Bound> zAxis(std::move(zValues));
Axis<AxisType::Variable, AxisBoundaryType::Bound> rAxis(std::move(rValues));
Axis<AxisType::Variable, AxisBoundaryType::Open> zAxis(std::move(zValues));
Axis<AxisType::Variable, AxisBoundaryType::Open> rAxis(std::move(rValues));
return Acts::CylindricalSpacePointGrid<external_spacepoint_t>(
std::make_tuple(std::move(phiAxis), std::move(zAxis), std::move(rAxis)));
}
Expand Down
Loading

0 comments on commit 48789fb

Please sign in to comment.