Skip to content

Commit

Permalink
Merge branch 'main' into jonas-refactor
Browse files Browse the repository at this point in the history
  • Loading branch information
Berggren-Jonas authored Sep 11, 2024
2 parents 2464ae5 + ae0c21d commit 48f89fb
Show file tree
Hide file tree
Showing 110 changed files with 770 additions and 1,326 deletions.
7 changes: 4 additions & 3 deletions Core/include/Acts/Detector/detail/IndexedGridFiller.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
#include "Acts/Utilities/Delegate.hpp"
#include "Acts/Utilities/Enumerate.hpp"
#include "Acts/Utilities/GridAccessHelpers.hpp"
#include "Acts/Utilities/Helpers.hpp"
#include "Acts/Utilities/IAxis.hpp"
#include "Acts/Utilities/Logger.hpp"

Expand Down Expand Up @@ -193,7 +194,7 @@ struct IndexedGridFiller {
// Loop over the surfaces to be filled
for (auto [io, o] : enumerate(iObjects)) {
// Exclude indices that should be handled differently
if (std::find(aToAll.begin(), aToAll.end(), io) != aToAll.end()) {
if (rangeContainsValue(aToAll, io)) {
continue;
}
// Get the reference positions
Expand All @@ -216,7 +217,7 @@ struct IndexedGridFiller {
// Now fill the surface indices
for (const auto& li : lIndices) {
auto& bContent = iGrid.grid.atLocalBins(li);
if (std::find(bContent.begin(), bContent.end(), io) == bContent.end()) {
if (!rangeContainsValue(bContent, io)) {
bContent.push_back(io);
}
}
Expand All @@ -238,7 +239,7 @@ struct IndexedGridFiller {
for (std::size_t gi = 0; gi < iGrid.grid.size(true); ++gi) {
auto& bContent = iGrid.grid.at(gi);
for (const auto& io : idcs) {
if (std::find(bContent.begin(), bContent.end(), io) == bContent.end()) {
if (!rangeContainsValue(bContent, io)) {
bContent.push_back(io);
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -262,7 +262,7 @@ class MultiComponentCurvilinearTrackParameters
avgDir += w * dir;
}

auto s = Surface::makeShared<PlaneSurface>(avgPos, avgDir);
auto s = CurvilinearSurface(avgPos, avgDir).planeSurface();

std::vector<std::tuple<double, BoundVector, covariance_t>> bound;
bound.reserve(curvi.size());
Expand Down
4 changes: 2 additions & 2 deletions Core/include/Acts/EventData/MultiTrajectoryHelpers.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
#include "Acts/Geometry/Layer.hpp"
#include "Acts/Geometry/TrackingVolume.hpp"
#include "Acts/Surfaces/Surface.hpp"
#include "Acts/Utilities/Helpers.hpp"

#include <functional>
#include <unordered_map>
Expand Down Expand Up @@ -102,8 +103,7 @@ VolumeTrajectoryStateContainer trajectoryState(
const auto& volume = geoID.volume();
const auto& layer = geoID.layer();
// Check if the track info for this sub-detector is requested
auto it = std::find(volumeIds.begin(), volumeIds.end(), volume);
if (it == volumeIds.end()) {
if (!rangeContainsValue(volumeIds, volume)) {
return true;
}
// The trajectory state for this volume
Expand Down
4 changes: 2 additions & 2 deletions Core/include/Acts/Geometry/CylinderVolumeStack.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ class CylinderVolumeStack : public Volume {
/// @param transform is the new transform
/// @pre The volume bounds need to be of type
/// @c CylinderVolumeBounds.
void update(std::shared_ptr<const VolumeBounds> volbounds,
void update(std::shared_ptr<VolumeBounds> volbounds,
std::optional<Transform3> transform = std::nullopt) override;

/// Update the volume bounds and transform. This
Expand All @@ -100,7 +100,7 @@ class CylinderVolumeStack : public Volume {
/// @param logger is the logger
/// @pre The volume bounds need to be of type
/// @c CylinderVolumeBounds.
void update(std::shared_ptr<const CylinderVolumeBounds> newBounds,
void update(std::shared_ptr<CylinderVolumeBounds> newBounds,
std::optional<Transform3> transform, const Logger& logger);

/// Access the gap volume that were created during attachment or resizing.
Expand Down
70 changes: 38 additions & 32 deletions Core/include/Acts/Geometry/GeometryHierarchyMap.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -64,13 +64,13 @@ class GeometryHierarchyMap {
/// Combined geometry identifier and value element. Only used for input.
using InputElement = typename std::pair<GeometryIdentifier, value_t>;
using Iterator = typename std::vector<value_t>::const_iterator;
using Size = typename std::vector<value_t>::size_type;
using Value = value_t;

/// Construct the container from the given elements.
///
/// @param elements input elements (must be unique with respect to identifier)
GeometryHierarchyMap(std::vector<InputElement> elements);

/// Construct the container from an initializer list.
///
/// @param elements input initializer list
Expand All @@ -86,21 +86,25 @@ class GeometryHierarchyMap {

/// Return an iterator pointing to the beginning of the stored values.
Iterator begin() const { return m_values.begin(); }

/// Return an iterator pointing to the end of the stored values.
Iterator end() const { return m_values.end(); }

/// Check if any elements are stored.
bool empty() const { return m_values.empty(); }

/// Return the number of stored elements.
Size size() const { return m_values.size(); }
std::size_t size() const { return m_values.size(); }

/// Access the geometry identifier for the i-th element with bounds check.
///
/// @throws std::out_of_range for invalid indices
GeometryIdentifier idAt(Size index) const { return m_ids.at(index); }
GeometryIdentifier idAt(std::size_t index) const { return m_ids.at(index); }

/// Access the value of the i-th element in the container with bounds check.
///
/// @throws std::out_of_range for invalid indices
const Value& valueAt(Size index) const { return m_values.at(index); }
const Value& valueAt(std::size_t index) const { return m_values.at(index); }

/// Find the most specific value for a given geometry identifier.
///
Expand All @@ -111,7 +115,7 @@ class GeometryHierarchyMap {
/// @param id geometry identifier for which information is requested
/// @retval iterator to an existing value
/// @retval `.end()` iterator if no matching element exists
Iterator find(GeometryIdentifier id) const;
Iterator find(const GeometryIdentifier& id) const;

private:
// NOTE this class assumes that it knows the ordering of the levels within
Expand Down Expand Up @@ -171,34 +175,35 @@ class GeometryHierarchyMap {
// no valid levels; all bits are zero.
return Identifier{0u};
}

/// Construct a mask where only the highest level is set.
static constexpr Identifier makeHighestLevelMask() {
return makeLeadingLevelsMask(GeometryIdentifier(0u).setVolume(1u));
}

/// Compare the two identifiers only within the masked bits.
static constexpr bool equalWithinMask(Identifier lhs, Identifier rhs,
Identifier mask) {
return (lhs & mask) == (rhs & mask);
}

/// Ensure identifier ordering and uniqueness.
template <typename iterator_t>
static void sortAndCheckDuplicates(iterator_t beg, iterator_t end);
static void sortAndCheckDuplicates(std::vector<InputElement>& elements);

/// Fill the container from the input elements.
///
/// This assumes that the elements are ordered and unique with respect to
/// their identifiers.
template <typename iterator_t>
void fill(iterator_t beg, iterator_t end);
void fill(const std::vector<InputElement>& elements);
};

// implementations

template <typename value_t>
inline GeometryHierarchyMap<value_t>::GeometryHierarchyMap(
std::vector<InputElement> elements) {
sortAndCheckDuplicates(elements.begin(), elements.end());
fill(elements.begin(), elements.end());
sortAndCheckDuplicates(elements);
fill(elements);
}

template <typename value_t>
Expand All @@ -208,43 +213,44 @@ inline GeometryHierarchyMap<value_t>::GeometryHierarchyMap(
std::vector<InputElement>(elements.begin(), elements.end())) {}

template <typename value_t>
template <typename iterator_t>
inline void GeometryHierarchyMap<value_t>::sortAndCheckDuplicates(
iterator_t beg, iterator_t end) {
std::vector<InputElement>& elements) {
// ensure elements are sorted by identifier
std::sort(beg, end, [=](const auto& lhs, const auto& rhs) {
std::ranges::sort(elements, [=](const auto& lhs, const auto& rhs) {
return lhs.first < rhs.first;
});
// check that all elements have unique identifier
auto dup = std::adjacent_find(beg, end, [](const auto& lhs, const auto& rhs) {
return lhs.first == rhs.first;
});
if (dup != end) {

// Check that all elements have unique identifier
auto dup = std::ranges::adjacent_find(
elements,
[](const auto& lhs, const auto& rhs) { return lhs.first == rhs.first; });

if (dup != elements.end()) {
throw std::invalid_argument("Input elements contain duplicates");
}
}

template <typename value_t>
template <typename iterator_t>
inline void GeometryHierarchyMap<value_t>::fill(iterator_t beg,
iterator_t end) {
const auto n = std::distance(beg, end);
inline void GeometryHierarchyMap<value_t>::fill(
const std::vector<InputElement>& elements) {
m_ids.clear();
m_ids.reserve(n);
m_masks.clear();
m_masks.reserve(n);
m_values.clear();
m_values.reserve(n);
for (; beg != end; ++beg) {
m_ids.push_back(beg->first.value());
m_masks.push_back(makeLeadingLevelsMask(beg->first.value()));
m_values.push_back(std::move(beg->second));

m_ids.reserve(elements.size());
m_masks.reserve(elements.size());
m_values.reserve(elements.size());

for (const auto& element : elements) {
m_ids.push_back(element.first.value());
m_masks.push_back(makeLeadingLevelsMask(element.first.value()));
m_values.push_back(std::move(element.second));
}
}

template <typename value_t>
inline auto GeometryHierarchyMap<value_t>::find(GeometryIdentifier id) const
-> Iterator {
inline auto GeometryHierarchyMap<value_t>::find(
const GeometryIdentifier& id) const -> Iterator {
assert((m_ids.size() == m_values.size()) &&
"Inconsistent container state: #ids != # values");
assert((m_masks.size() == m_values.size()) &&
Expand Down
8 changes: 3 additions & 5 deletions Core/include/Acts/Geometry/TrackingVolume.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ class TrackingVolume : public Volume {
/// @param volbounds is the description of the volume boundaries
/// @param volumeName is a string identifier
TrackingVolume(const Transform3& transform,
std::shared_ptr<const VolumeBounds> volbounds,
std::shared_ptr<VolumeBounds> volbounds,
const std::string& volumeName = "undefined");

/// Constructor for a full equipped Tracking Volume
Expand All @@ -140,8 +140,7 @@ class TrackingVolume : public Volume {
/// @param denseVolumeVector The contained dense volumes
/// @param volumeName is a string identifier
TrackingVolume(
const Transform3& transform,
std::shared_ptr<const VolumeBounds> volumeBounds,
const Transform3& transform, std::shared_ptr<VolumeBounds> volumeBounds,
std::shared_ptr<const IVolumeMaterial> volumeMaterial,
std::unique_ptr<const LayerArray> staticLayerArray = nullptr,
std::shared_ptr<const TrackingVolumeArray> containedVolumeArray = nullptr,
Expand All @@ -151,8 +150,7 @@ class TrackingVolume : public Volume {
/// 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");
TrackingVolume(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
Expand Down
19 changes: 13 additions & 6 deletions Core/include/Acts/Geometry/Volume.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,7 @@ class Volume : public GeometryObject {
///
/// @param transform is the transform to position the volume in 3D space
/// @param volbounds is the volume boundary definitions
Volume(const Transform3& transform,
std::shared_ptr<const VolumeBounds> volbounds);
Volume(const Transform3& transform, std::shared_ptr<VolumeBounds> volbounds);

/// Copy Constructor - with optional shift
///
Expand All @@ -65,20 +64,26 @@ class Volume : public GeometryObject {
/// returns the center of the volume
const Vector3& center() const;

/// Returns const reference to the volume bounds
/// Returns a const reference to the volume bounds
const VolumeBounds& volumeBounds() const;

/// Returns a mutable reference to the volume bounds
VolumeBounds& volumeBounds();

/// Returns shared pointer to the volume bounds
std::shared_ptr<const VolumeBounds> volumeBoundsPtr() const;

/// Returns shared pointer to the volume bounds
std::shared_ptr<VolumeBounds> volumeBoundsPtr();

/// Set volume bounds and update volume bounding boxes implicitly
/// @param volbounds The volume bounds to be assigned
void assignVolumeBounds(std::shared_ptr<const VolumeBounds> volbounds);
void assignVolumeBounds(std::shared_ptr<VolumeBounds> volbounds);

/// 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
virtual void update(std::shared_ptr<const VolumeBounds> volbounds,
virtual void update(std::shared_ptr<VolumeBounds> volbounds,
std::optional<Transform3> transform = std::nullopt);

/// Construct bounding box for this shape
Expand Down Expand Up @@ -117,7 +122,9 @@ class Volume : public GeometryObject {
Transform3 m_transform;
Transform3 m_itransform;
Vector3 m_center;
std::shared_ptr<const VolumeBounds> m_volumeBounds;

private:
std::shared_ptr<VolumeBounds> m_volumeBounds;
};

/**Overload of << operator for std::ostream for debug output*/
Expand Down
22 changes: 8 additions & 14 deletions Core/include/Acts/Propagator/EigenStepper.hpp
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// This file is part of the Acts project.
//
// Copyright (C) 2016-2022 CERN for the benefit of the Acts project
// Copyright (C) 2016-2024 CERN for the benefit of the Acts project
//
// This Source Code Form is subject to the terms of the Mozilla Public
// License, v. 2.0. If a copy of the MPL was not distributed with this
Expand All @@ -15,20 +15,18 @@
#include "Acts/Definitions/Tolerance.hpp"
#include "Acts/Definitions/Units.hpp"
#include "Acts/EventData/TrackParameters.hpp"
#include "Acts/EventData/detail/CorrectedTransformationFreeToBound.hpp"
#include "Acts/Geometry/GeometryContext.hpp"
#include "Acts/MagneticField/MagneticFieldContext.hpp"
#include "Acts/MagneticField/MagneticFieldProvider.hpp"
#include "Acts/Propagator/ConstrainedStep.hpp"
#include "Acts/Propagator/DefaultExtension.hpp"
#include "Acts/Propagator/DenseEnvironmentExtension.hpp"
#include "Acts/Propagator/EigenStepperError.hpp"
#include "Acts/Propagator/EigenStepperDefaultExtension.hpp"
#include "Acts/Propagator/PropagatorTraits.hpp"
#include "Acts/Propagator/StepperExtensionList.hpp"
#include "Acts/Propagator/StepperOptions.hpp"
#include "Acts/Propagator/detail/Auctioneer.hpp"
#include "Acts/Propagator/detail/SteppingHelper.hpp"
#include "Acts/Utilities/Intersection.hpp"
#include "Acts/Utilities/Result.hpp"

#include <cmath>
#include <functional>
#include <limits>
#include <type_traits>
Expand All @@ -47,8 +45,7 @@ namespace Acts {
/// with s being the arc length of the track, q the charge of the particle,
/// p the momentum magnitude and B the magnetic field
///
template <typename extensionlist_t = StepperExtensionList<DefaultExtension>,
typename auctioneer_t = detail::VoidAuctioneer>
template <typename extension_t = EigenStepperDefaultExtension>
class EigenStepper {
public:
/// Jacobian, Covariance and State definitions
Expand Down Expand Up @@ -155,11 +152,8 @@ class EigenStepper {
/// The geometry context
std::reference_wrapper<const GeometryContext> geoContext;

/// List of algorithmic extensions
extensionlist_t extension;

/// Auctioneer for choosing the extension
auctioneer_t auctioneer;
/// Algorithmic extension
extension_t extension;

/// @brief Storage of magnetic field and the sub steps during a RKN4 step
struct {
Expand Down
Loading

0 comments on commit 48f89fb

Please sign in to comment.