Skip to content

Commit

Permalink
Merge branch 'main' into feat-gen2-geomodel-json
Browse files Browse the repository at this point in the history
  • Loading branch information
asalzburger authored Aug 8, 2024
2 parents d4e3748 + d49e2f8 commit 89fc123
Show file tree
Hide file tree
Showing 56 changed files with 1,842 additions and 362 deletions.
6 changes: 0 additions & 6 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,6 @@ option(ACTS_BUILD_PLUGIN_ONNX "Build ONNX plugin" OFF)
option(ACTS_USE_SYSTEM_COVFIE "Use a system-provided covfie installation" ${ACTS_USE_SYSTEM_LIBS})
option(ACTS_USE_SYSTEM_DETRAY "Use a system-provided detray installation" ${ACTS_USE_SYSTEM_LIBS})
option(ACTS_USE_SYSTEM_TRACCC "Use a system-provided traccc installation" ${ACTS_USE_SYSTEM_LIBS})
option(ACTS_USE_SYSTEM_DFELIBS "Use a system-provided dfelibs installation" ${ACTS_USE_SYSTEM_LIBS})
option(ACTS_USE_SYSTEM_VECMEM "Use a system-provided vecmem installation" ${ACTS_USE_SYSTEM_LIBS})
option(ACTS_USE_SYSTEM_ALGEBRAPLUGINS "Use a system-provided algebra-plugins installation" ${ACTS_USE_SYSTEM_LIBS})
option(ACTS_BUILD_PLUGIN_TGEO "Build TGeo plugin" OFF)
Expand Down Expand Up @@ -254,11 +253,6 @@ if (ACTS_SETUP_EIGEN3)
endif()
endif()

if (ACTS_USE_SYSTEM_DFELIBS)
find_package(dfelibs ${_acts_dfelibs_version} REQUIRED)
else()
add_subdirectory(thirdparty/dfelibs)
endif()

find_package(Filesystem REQUIRED)

Expand Down
9 changes: 6 additions & 3 deletions Core/include/Acts/EventData/MultiTrajectory.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -642,9 +642,12 @@ class MultiTrajectory {
self().allocateCalibrated_impl(istate, measdim);
}

void setUncalibratedSourceLink(IndexType istate,
SourceLink sourceLink) requires(!ReadOnly) {
self().setUncalibratedSourceLink_impl(istate, std::move(sourceLink));
// This function will move to an rvalue reference in the next major version
template <typename source_link_t>
void setUncalibratedSourceLink(
IndexType istate, source_link_t&& sourceLink) requires(!ReadOnly) {
self().setUncalibratedSourceLink_impl(
istate, std::forward<source_link_t>(sourceLink));
}

SourceLink getUncalibratedSourceLink(IndexType istate) const {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@ concept MutableMultiTrajectoryBackend = CommonMultiTrajectoryBackend<T> &&

{v.allocateCalibrated_impl(istate, dim)};

{v.setUncalibratedSourceLink_impl(istate, sl)};
{v.setUncalibratedSourceLink_impl(istate, std::move(sl))};

{v.setReferenceSurface_impl(istate, surface)};

Expand Down
8 changes: 1 addition & 7 deletions Core/include/Acts/EventData/SourceLink.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -39,15 +39,9 @@ class SourceLink final {
/// @param upstream The upstream source link to store
template <typename T, typename = std::enable_if_t<
!std::is_same_v<std::decay_t<T>, SourceLink>>>
explicit SourceLink(T&& upstream) {
explicit SourceLink(T&& upstream) : m_upstream(std::forward<T>(upstream)) {
static_assert(!std::is_same_v<std::decay_t<T>, SourceLink>,
"Cannot wrap SourceLink in SourceLink");

if constexpr (std::is_same_v<T, std::decay_t<T>>) {
m_upstream = any_type{std::forward<T>(upstream)};
} else {
m_upstream = any_type{static_cast<std::decay_t<T>>(upstream)};
}
}

/// Concrete source link class getter
Expand Down
17 changes: 15 additions & 2 deletions Core/include/Acts/EventData/TrackStateProxy.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -676,10 +676,23 @@ class TrackStateProxy {
/// @return The uncalibrated measurement source link
SourceLink getUncalibratedSourceLink() const;

// This function will move to an rvalue reference in the next major version
/// Set an uncalibrated source link
/// @param sourceLink The uncalibrated source link to set
void setUncalibratedSourceLink(SourceLink sourceLink) requires(!ReadOnly) {
m_traj->setUncalibratedSourceLink(m_istate, std::move(sourceLink));
template <typename source_link_t>
void setUncalibratedSourceLink(source_link_t&& sourceLink) requires(
!ReadOnly) {
m_traj->setUncalibratedSourceLink(m_istate,
std::forward<source_link_t>(sourceLink));
}

/// Set an uncalibrated source link
/// @param sourceLink The uncalibrated source link to set
/// @note Use the overload with an rvalue reference, this
/// overload will be removed ith the next major version
void setUncalibratedSourceLink(const SourceLink& sourceLink) requires(
!ReadOnly) {
m_traj->setUncalibratedSourceLink(m_istate, SourceLink{sourceLink});
}

/// Check if the point has an associated uncalibrated measurement.
Expand Down
3 changes: 2 additions & 1 deletion Core/include/Acts/EventData/VectorMultiTrajectory.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -484,7 +484,8 @@ class VectorMultiTrajectory final
m_measCov.resize(m_measCov.size() + measdim * measdim);
}

void setUncalibratedSourceLink_impl(IndexType istate, SourceLink sourceLink) {
void setUncalibratedSourceLink_impl(IndexType istate,
SourceLink&& sourceLink) {
m_sourceLinks[m_index[istate].iuncalibrated] = std::move(sourceLink);
}

Expand Down
2 changes: 1 addition & 1 deletion Core/include/Acts/EventData/detail/TestSourceLink.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@ void testSourceLinkCalibratorReturn(
typename trajectory_t::TrackStateProxy trackState) {
TestSourceLink sl = sourceLink.template get<TestSourceLink>();

trackState.setUncalibratedSourceLink(sourceLink);
trackState.setUncalibratedSourceLink(SourceLink{sourceLink});

if ((sl.indices[0] != Acts::eBoundSize) &&
(sl.indices[1] != Acts::eBoundSize)) {
Expand Down
12 changes: 7 additions & 5 deletions Core/include/Acts/Surfaces/CylinderSurface.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -252,14 +252,16 @@ class CylinderSurface : public RegularSurface {
/// @image html Cylinder_Merging.svg
/// @note The surfaces need to be *compatible*, i.e. have cylinder bounds
/// that align, and have the same radius
/// @param gctx The current geometry context object, e.g. alignment
/// @param other The other cylinder surface to merge with
/// @param direction The binning direction: either @c binZ or @c binRPhi
/// @param externalRotation If true, any phi rotation is done in the transform
/// @param logger The logger to use
/// @return The merged cylinder surface
std::shared_ptr<CylinderSurface> mergedWith(
const GeometryContext& gctx, const CylinderSurface& other,
BinningValue direction, const Logger& logger = getDummyLogger()) const;
/// @return The merged cylinder surface and a boolean indicating if surfaces are reversed
/// @note The returned boolean is `false` if `this` is *left* or
/// *counter-clockwise* of @p other, and `true` if not.
std::pair<std::shared_ptr<CylinderSurface>, bool> mergedWith(
const CylinderSurface& other, BinningValue direction,
bool externalRotation, const Logger& logger = getDummyLogger()) const;

protected:
std::shared_ptr<const CylinderBounds> m_bounds; //!< bounds (shared)
Expand Down
12 changes: 7 additions & 5 deletions Core/include/Acts/Surfaces/DiscSurface.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -335,14 +335,16 @@ class DiscSurface : public RegularSurface {
/// @image html Disc_Merging.svg
/// @note The surfaces need to be *compatible*, i.e. have disc bounds
/// that align
/// @param gctx The current geometry context object, e.g. alignment
/// @param other The other disc surface to merge with
/// @param direction The binning direction: either @c binR or @c binPhi
/// @param externalRotation If true, any phi rotation is done in the transform
/// @param logger The logger to use
/// @return The merged disc surface
std::shared_ptr<DiscSurface> mergedWith(
const GeometryContext& gctx, const DiscSurface& other,
BinningValue direction, const Logger& logger = getDummyLogger()) const;
/// @return The merged disc surface and a boolean indicating if surfaces are reversed
/// @note The returned boolean is `false` if `this` is *left* or
/// *counter-clockwise* of @p other, and `true` if not.
std::pair<std::shared_ptr<DiscSurface>, bool> mergedWith(
const DiscSurface& other, BinningValue direction, bool externalRotation,
const Logger& logger = getDummyLogger()) const;

protected:
std::shared_ptr<const DiscBounds> m_bounds; ///< bounds (shared)
Expand Down
2 changes: 1 addition & 1 deletion Core/include/Acts/Surfaces/detail/MergeHelper.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ namespace Acts::detail {
/// a half phi sector in the range [0,pi). The two
/// ranges need to line up, i.e. that one of the sector
/// ends exactly where the other one starts.
std::pair<ActsScalar, ActsScalar> mergedPhiSector(
std::tuple<ActsScalar, ActsScalar, bool> mergedPhiSector(
ActsScalar hlPhi1, ActsScalar avgPhi1, ActsScalar hlPhi2,
ActsScalar avgPhi2, const Logger& logger = getDummyLogger(),
ActsScalar tolerance = s_onSurfaceTolerance);
Expand Down
7 changes: 6 additions & 1 deletion Core/include/Acts/Utilities/Any.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@
#include <array>
#include <cassert>
#include <cstddef>
#include <memory>
#include <utility>

// #define _ACTS_ANY_ENABLE_VERBOSE
Expand Down Expand Up @@ -130,6 +129,7 @@ class AnyBase : public AnyBaseAll {
} else {
// too large, heap allocate
U* heap = new U(std::forward<Args>(args)...);
_ACTS_ANY_DEBUG("Allocate type: " << typeid(U).name() << " at " << heap);
_ACTS_ANY_TRACK_ALLOCATION(T, heap);
setDataPtr(heap);
}
Expand Down Expand Up @@ -335,6 +335,7 @@ class AnyBase : public AnyBaseAll {
void destroy() {
_ACTS_ANY_VERBOSE("Destructor this=" << this << " handler: " << m_handler);
if (m_handler != nullptr && m_handler->destroy != nullptr) {
_ACTS_ANY_VERBOSE("Non-trivial destruction");
m_handler->destroy(dataPtr());
}
m_handler = nullptr;
Expand All @@ -356,6 +357,7 @@ class AnyBase : public AnyBaseAll {
}

if (m_handler->moveConstruct == nullptr) {
_ACTS_ANY_VERBOSE("Trivially move construct");
// trivially move constructible
m_data = std::move(fromAny.m_data);
} else {
Expand All @@ -381,6 +383,7 @@ class AnyBase : public AnyBaseAll {
}

if (m_handler->move == nullptr) {
_ACTS_ANY_VERBOSE("Trivially move");
// trivially movable
m_data = std::move(fromAny.m_data);
} else {
Expand All @@ -397,6 +400,7 @@ class AnyBase : public AnyBaseAll {
const void* from = fromAny.dataPtr();

if (m_handler->copyConstruct == nullptr) {
_ACTS_ANY_VERBOSE("Trivially copy construct");
// trivially copy constructible
m_data = fromAny.m_data;
} else {
Expand All @@ -418,6 +422,7 @@ class AnyBase : public AnyBaseAll {
const void* from = fromAny.dataPtr();

if (m_handler->copy == nullptr) {
_ACTS_ANY_VERBOSE("Trivially copy");
// trivially copyable
m_data = fromAny.m_data;
} else {
Expand Down
24 changes: 24 additions & 0 deletions Core/include/Acts/Utilities/Axis.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -392,6 +392,17 @@ class Axis<AxisType::Equidistant, bdt> final : public IAxis {
return binEdges;
}

friend std::ostream& operator<<(std::ostream& os, const Axis& axis) {
os << "Axis<Equidistant, " << bdt << ">(";
os << axis.m_min << ", ";
os << axis.m_max << ", ";
os << axis.m_bins << ")";
return os;
}

protected:
void toStream(std::ostream& os) const override { os << *this; }

private:
/// minimum of binning range
ActsScalar m_min{};
Expand Down Expand Up @@ -695,6 +706,19 @@ class Axis<AxisType::Variable, bdt> final : public IAxis {
/// @return Vector which contains the bin edges
std::vector<ActsScalar> getBinEdges() const override { return m_binEdges; }

friend std::ostream& operator<<(std::ostream& os, const Axis& axis) {
os << "Axis<Variable, " << bdt << ">(";
os << axis.m_binEdges.front();
for (std::size_t i = 1; i < axis.m_binEdges.size(); i++) {
os << ", " << axis.m_binEdges[i];
}
os << ")";
return os;
}

protected:
void toStream(std::ostream& os) const override { os << *this; }

private:
/// vector of bin edges (sorted in ascending order)
std::vector<ActsScalar> m_binEdges;
Expand Down
38 changes: 38 additions & 0 deletions Core/include/Acts/Utilities/Grid.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
#include <set>
#include <tuple>
#include <type_traits>
#include <utility>
#include <vector>

namespace Acts {
Expand All @@ -39,6 +40,26 @@ class IGrid {
/// Get a dynamically sized vector of axis objects for inspection
/// @return a vector of axis pointers
virtual boost::container::small_vector<const IAxis*, 3> axes() const = 0;

/// Helper to print out the grid
/// @param os the output stream
/// @param grid the grid to print
/// @return the output stream
friend std::ostream& operator<<(std::ostream& os, const IGrid& grid) {
grid.toStream(os);
return os;
}

friend bool operator==(const IGrid& lhs, const IGrid& rhs) {
auto lhsAxes = lhs.axes();
auto rhsAxes = rhs.axes();
return lhsAxes.size() == rhsAxes.size() &&
std::equal(lhsAxes.begin(), lhsAxes.end(), rhsAxes.begin(),
[](const IAxis* a, const IAxis* b) { return *a == *b; });
}

protected:
virtual void toStream(std::ostream& os) const = 0;
};

/// @brief class for describing a regular multi-dimensional grid
Expand Down Expand Up @@ -583,6 +604,11 @@ class Grid final : public IGrid {
return local_iterator_t(*this, std::move(endline), navigator);
}

protected:
void toStream(std::ostream& os) const override {
printAxes(os, std::make_index_sequence<sizeof...(Axes)>());
}

private:
/// set of axis defining the multi-dimensional grid
std::tuple<Axes...> m_axes;
Expand All @@ -596,6 +622,18 @@ class Grid final : public IGrid {
const index_t& localBins) const {
return detail::grid_helper::closestPointsIndices(localBins, m_axes);
}

template <std::size_t... Is>
void printAxes(std::ostream& os, std::index_sequence<Is...> /*s*/) const {
auto printOne = [&os, this]<std::size_t index>(
std::integral_constant<std::size_t, index>) {
if constexpr (index > 0) {
os << ", ";
}
os << std::get<index>(m_axes);
};
(printOne(std::integral_constant<std::size_t, Is>()), ...);
}
};

template <typename T, class... Axes>
Expand Down
62 changes: 62 additions & 0 deletions Core/include/Acts/Utilities/IAxis.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
#include "Acts/Definitions/Algebra.hpp"
#include "Acts/Utilities/AxisFwd.hpp"

#include <iosfwd>
#include <vector>

namespace Acts {
Expand Down Expand Up @@ -56,5 +57,66 @@ class IAxis {
///
/// @return total number of bins (excluding under-/overflow bins)
virtual std::size_t getNBins() const = 0;

/// Helper function that dispatches from the @c IAxis base class
/// to a concrete axis type. It will call the provided @p callable
/// with a const reference to the concrete axis type.
/// @tparam callable_t the callable type
/// @param callable the callable object
template <typename callable_t>
decltype(auto) visit(const callable_t& callable) const {
auto switchOnType =
[this, &callable]<AxisBoundaryType bdt>(AxisBoundaryTypeTag<bdt>) {
switch (getType()) {
using enum AxisType;
case Equidistant:
return callable(
dynamic_cast<const Axis<AxisType::Equidistant, bdt>&>(*this));
case Variable:
return callable(
dynamic_cast<const Axis<AxisType::Variable, bdt>&>(*this));
}
};

switch (getBoundaryType()) {
using enum AxisBoundaryType;
case Open:
return switchOnType(AxisOpen);
case Bound:
return switchOnType(AxisBound);
case Closed:
return switchOnType(AxisClosed);
}
}

/// Check if two axes are equal
/// @param lhs first axis
/// @param rhs second axis
/// @return true if the axes are equal
friend bool operator==(const IAxis& lhs, const IAxis& rhs) {
return lhs.getType() == rhs.getType() &&
lhs.getBoundaryType() == rhs.getBoundaryType() &&
lhs.getMin() == rhs.getMin() && lhs.getMax() == rhs.getMax() &&
lhs.getNBins() == rhs.getNBins() &&
lhs.getBinEdges() == rhs.getBinEdges();
}

/// Output stream operator
/// @param os output stream
/// @param axis the axis to be printed
/// @return the output stream
friend std::ostream& operator<<(std::ostream& os, const IAxis& axis) {
axis.toStream(os);
return os;
}

protected:
/// Dispatch to the correct stream operator
/// @param os output stream
virtual void toStream(std::ostream& os) const = 0;
};

template <typename T>
concept AxisConcept = std::derived_from<T, IAxis>;

} // namespace Acts
Loading

0 comments on commit 89fc123

Please sign in to comment.