Skip to content

Commit

Permalink
Merge remote-tracking branch 'upstream/main'
Browse files Browse the repository at this point in the history
  • Loading branch information
cvarni committed Sep 24, 2024
2 parents 21ae7f0 + 9ee3a10 commit ba7903c
Show file tree
Hide file tree
Showing 213 changed files with 2,402 additions and 1,599 deletions.
2 changes: 1 addition & 1 deletion CI/physmon/workflows/physmon_simulation.py
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@
rnd,
preSelectParticles=None,
postSelectParticles=ParticleSelectorConfig(removeSecondaries=True),
killVolume=setup.trackingGeometry.worldVolume,
killVolume=setup.trackingGeometry.highestTrackingVolume,
killAfterTime=25 * u.ns,
killSecondaries=True,
inputParticles="particles_input",
Expand Down
14 changes: 9 additions & 5 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -168,6 +168,10 @@ set_option_if(
ACTS_BUILD_PLUGIN_JSON
ACTS_BUILD_PLUGIN_TRACCC
)
set_option_if(
ACTS_BUILD_PLUGIN_ACTSVG
ACTS_BUILD_PLUGIN_TRACCC
)
set_option_if(
ACTS_BUILD_PLUGIN_HASHING
ACTS_BUILD_EXAMPLES_HASHING
Expand Down Expand Up @@ -221,8 +225,7 @@ endif()
# minimal dependency versions. they are defined here in a single place so
# they can be easily upgraded, although they might not be used if the
# dependency is included via `add_subdirectory(...)`.
set(_acts_actsvg_version 0.4.40)
set(_acts_autodiff_version 0.6)
set(_acts_actsvg_version 0.4.47)
set(_acts_boost_version 1.71.0)
set(_acts_dd4hep_version 1.21)
set(_acts_edm4hep_version 0.7)
Expand All @@ -232,13 +235,14 @@ set(_acts_podio_version 1.0.1) # will try this first
set(_acts_podio_fallback_version 0.16) # if not found, will try this one
set(_acts_doxygen_version 1.9.4)
set(_acts_hepmc3_version 3.2.1)
set(_acts_nlohmanjson_version 3.2.0)
set(_acts_nlohmanjson_version 3.10.5)
set(_acts_onnxruntime_version 1.12.0)
set(_acts_root_version 6.20)
set(_acts_tbb_version 2020.1)
set(_acts_pythia8_version 8.309)
set(_acts_detray_version 0.72.0)
set(_acts_traccc_version 0.13.0)
set(_acts_pybind11_version 2.13.1)
set(_acts_detray_version 0.75.2)
set(_acts_traccc_version 0.16.0)
set(_acts_covfie_version 0.10.0)
set(_acts_vecmem_version 1.4.0)
set(_acts_algebraplugins_version 0.22.0)
Expand Down
1 change: 0 additions & 1 deletion CMakePresets.json
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,6 @@
"displayName": "GitLab-CI",
"inherits": "ci-common",
"cacheVariables": {
"ACTS_BUILD_PLUGIN_ACTSVG": "OFF",
"ACTS_BUILD_ODD": "OFF",
"ACTS_BUILD_EXAMPLES_PYTHON_BINDINGS": "OFF",
"ACTS_RUN_CLANG_TIDY": "ON"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ ScoreBasedAmbiguityResolution::computeInitialState(

for (const auto& ts : track.trackStatesReversed()) {
if (!ts.hasReferenceSurface()) {
ACTS_ERROR("Track state has no reference surface");
ACTS_DEBUG("Track state has no reference surface");
continue;
}
auto iVolume = ts.referenceSurface().geometryId().volume();
Expand Down
9 changes: 4 additions & 5 deletions Core/include/Acts/Clusterization/Clusterization.ipp
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
// This file is part of the Acts project.
//
// Copyright (C) 2022 CERN for the benefit of the Acts project
// Copyright (C) 2022-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
// file, You can obtain one at http://mozilla.org/MPL/2.0/.

#include <algorithm>
#include <array>
#include <vector>

Expand Down Expand Up @@ -273,7 +274,7 @@ void labelClusters(CellCollection& cells, Connect connect) {
internal::DisjointSets ds{};

// Sort cells by position to enable in-order scan
std::sort(cells.begin(), cells.end(), internal::Compare<Cell, GridDim>());
std::ranges::sort(cells, internal::Compare<Cell, GridDim>());

// First pass: Allocate labels and record equivalences
for (auto it = cells.begin(); it != cells.end(); ++it) {
Expand Down Expand Up @@ -308,9 +309,7 @@ ClusterCollection mergeClusters(CellCollection& cells) {
if constexpr (GridDim > 1) {
// Sort the cells by their cluster label, only needed if more than
// one spatial dimension
std::sort(cells.begin(), cells.end(), [](Cell& lhs, Cell& rhs) {
return getCellLabel(lhs) < getCellLabel(rhs);
});
std::ranges::sort(cells, {}, [](Cell& c) { return getCellLabel(c); });
}

return internal::mergeClustersImpl<CellCollection, ClusterCollection>(cells);
Expand Down
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
16 changes: 11 additions & 5 deletions Core/include/Acts/EventData/MultiTrajectory.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,12 @@ class TrackStateRange {
}
}

Iterator operator++(int) {
Iterator tmp(*this);
operator++();
return tmp;
}

bool operator==(const Iterator& other) const {
if (!proxy && !other.proxy) {
return true;
Expand All @@ -109,6 +115,9 @@ class TrackStateRange {
Iterator begin() { return m_begin; }
Iterator end() { return Iterator{std::nullopt}; }

Iterator cbegin() const { return m_begin; }
Iterator cend() const { return Iterator{std::nullopt}; }

private:
Iterator m_begin;
};
Expand Down Expand Up @@ -689,13 +698,10 @@ class MultiTrajectory {
self().allocateCalibrated_impl(istate, measdim);
}

// 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)
void setUncalibratedSourceLink(IndexType istate, SourceLink&& sourceLink)
requires(!ReadOnly)
{
self().setUncalibratedSourceLink_impl(
istate, std::forward<source_link_t>(sourceLink));
self().setUncalibratedSourceLink_impl(istate, std::move(sourceLink));
}

SourceLink getUncalibratedSourceLink(IndexType istate) const {
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
17 changes: 2 additions & 15 deletions Core/include/Acts/EventData/TrackStateProxy.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -767,25 +767,12 @@ 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
template <typename source_link_t>
void setUncalibratedSourceLink(source_link_t&& sourceLink)
void setUncalibratedSourceLink(SourceLink&& 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});
m_traj->setUncalibratedSourceLink(m_istate, std::move(sourceLink));
}

/// Check if the point has an associated uncalibrated measurement.
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
Loading

0 comments on commit ba7903c

Please sign in to comment.