Skip to content

Commit

Permalink
Merge branch 'main' into remove-deprecated-api
Browse files Browse the repository at this point in the history
  • Loading branch information
kodiakhq[bot] authored Sep 6, 2024
2 parents 3888f99 + f3a5477 commit 095e937
Show file tree
Hide file tree
Showing 94 changed files with 1,888 additions and 1,455 deletions.
2 changes: 2 additions & 0 deletions .github/workflows/sonarcloud.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@ jobs:
- name: "Checkout repository"
uses: actions/checkout@v4
with:
fetch-depth: 0 # To prevent shallow clone

- name: 'Download artifact'
uses: actions/github-script@v7
Expand Down
2 changes: 1 addition & 1 deletion .gitlab-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ build_exatrkx_cpu:
- git checkout $HEAD_SHA
- cd ..
- mkdir build
# Here we only do a minimal build without examples to save ressources
# Here we only do a minimal build without examples to save resources
- >
cmake -B build -S src
--preset=gitlab-ci-exatrkx
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
#include "Acts/EventData/MultiTrajectoryHelpers.hpp"
#include "Acts/EventData/SourceLink.hpp"
#include "Acts/EventData/TrackContainer.hpp"
#include "Acts/EventData/TrackContainerFrontendConcept.hpp"
#include "Acts/Utilities/Delegate.hpp"
#include "Acts/Utilities/Logger.hpp"

Expand Down Expand Up @@ -77,13 +78,11 @@ class GreedyAmbiguityResolution {
/// @param state An empty state object which is expected to be default constructed.
/// @param sourceLinkHash A functor to acquire a hash from a given source link.
/// @param sourceLinkEquality A functor to check equality of two source links.
template <typename track_container_t, typename traj_t,
template <typename> class holder_t, typename source_link_hash_t,
typename source_link_equality_t>
void computeInitialState(
const TrackContainer<track_container_t, traj_t, holder_t>& tracks,
State& state, source_link_hash_t&& sourceLinkHash,
source_link_equality_t&& sourceLinkEquality) const;
template <TrackContainerFrontend track_container_t,
typename source_link_hash_t, typename source_link_equality_t>
void computeInitialState(const track_container_t& tracks, State& state,
source_link_hash_t&& sourceLinkHash,
source_link_equality_t&& sourceLinkEquality) const;

/// Updates the state iteratively by evicting one track after the other until
/// the final state conditions are met.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,11 @@

namespace Acts {

template <typename track_container_t, typename traj_t,
template <typename> class holder_t, typename source_link_hash_t,
template <TrackContainerFrontend track_container_t, typename source_link_hash_t,
typename source_link_equality_t>
void GreedyAmbiguityResolution::computeInitialState(
const TrackContainer<track_container_t, traj_t, holder_t>& tracks,
State& state, source_link_hash_t&& sourceLinkHash,
const track_container_t& tracks, State& state,
source_link_hash_t&& sourceLinkHash,
source_link_equality_t&& sourceLinkEquality) const {
auto measurementIndexMap =
std::unordered_map<SourceLink, std::size_t, source_link_hash_t,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@

#include "Acts/Definitions/Units.hpp"
#include "Acts/EventData/TrackContainer.hpp"
#include "Acts/EventData/TrackContainerFrontendConcept.hpp"
#include "Acts/EventData/TrackProxyConcept.hpp"
#include "Acts/Utilities/Delegate.hpp"
#include "Acts/Utilities/Logger.hpp"

Expand Down Expand Up @@ -116,16 +118,12 @@ class ScoreBasedAmbiguityResolution {
/// The optional cuts,weights and score are used to remove tracks that are not
/// good enough, based on some criteria. Users are free to add their own cuts
/// with the help of this struct.
template <typename track_container_t, typename traj_t,
template <typename> class holder_t, bool ReadOnly = true>
template <TrackProxyConcept track_proxy_t>
struct OptionalCuts {
using OptionalFilter =
std::function<bool(const Acts::TrackProxy<track_container_t, traj_t,
holder_t, ReadOnly>&)>;
using OptionalFilter = std::function<bool(const track_proxy_t&)>;

using OptionalScoreModifier = std::function<void(
const Acts::TrackProxy<track_container_t, traj_t, holder_t, ReadOnly>&,
double&)>;
using OptionalScoreModifier =
std::function<void(const track_proxy_t&, double&)>;
std::vector<OptionalFilter> cuts = {};
std::vector<OptionalScoreModifier> weights = {};

Expand All @@ -146,12 +144,10 @@ class ScoreBasedAmbiguityResolution {
/// @param sourceLinkEquality is the equality function for the source links
/// @param trackFeaturesVectors is the trackFeatures map from detector ID to trackFeatures
/// @return a vector of the initial state of the tracks
template <typename track_container_t, typename traj_t,
template <typename> class holder_t, typename source_link_hash_t,
typename source_link_equality_t>
template <TrackContainerFrontend track_container_t,
typename source_link_hash_t, typename source_link_equality_t>
std::vector<std::vector<MeasurementInfo>> computeInitialState(
const TrackContainer<track_container_t, traj_t, holder_t>& tracks,
source_link_hash_t sourceLinkHash,
const track_container_t& tracks, source_link_hash_t sourceLinkHash,
source_link_equality_t sourceLinkEquality,
std::vector<std::vector<TrackFeatures>>& trackFeaturesVectors) const;

Expand All @@ -161,12 +157,11 @@ class ScoreBasedAmbiguityResolution {
/// @param trackFeaturesVectors is the trackFeatures map from detector ID to trackFeatures
/// @param optionalCuts is the user defined optional cuts to be applied.
/// @return a vector of scores for each track
template <typename track_container_t, typename traj_t,
template <typename> class holder_t, bool ReadOnly = true>
template <TrackContainerFrontend track_container_t>
std::vector<double> simpleScore(
const TrackContainer<track_container_t, traj_t, holder_t>& tracks,
const track_container_t& tracks,
const std::vector<std::vector<TrackFeatures>>& trackFeaturesVectors,
const OptionalCuts<track_container_t, traj_t, holder_t, ReadOnly>&
const OptionalCuts<typename track_container_t::ConstTrackProxy>&
optionalCuts = {}) const;

/// Compute the score of each track based on the ambiguity function.
Expand All @@ -175,12 +170,11 @@ class ScoreBasedAmbiguityResolution {
/// @param trackFeaturesVectors is the trackFeatures map from detector ID to trackFeatures
/// @param optionalCuts is the user defined optional cuts to be applied.
/// @return a vector of scores for each track
template <typename track_container_t, typename traj_t,
template <typename> class holder_t, bool ReadOnly = true>
template <TrackContainerFrontend track_container_t>
std::vector<double> ambiguityScore(
const TrackContainer<track_container_t, traj_t, holder_t>& tracks,
const track_container_t& tracks,
const std::vector<std::vector<TrackFeatures>>& trackFeaturesVectors,
const OptionalCuts<track_container_t, traj_t, holder_t, ReadOnly>&
const OptionalCuts<typename track_container_t::ConstTrackProxy>&
optionalCuts = {}) const;

/// Remove hits that are not good enough for each track and removes tracks
Expand All @@ -205,13 +199,12 @@ class ScoreBasedAmbiguityResolution {
/// @param trackFeaturesVectors is the map of detector id to trackFeatures for each track
/// @param optionalCuts is the optional cuts to be applied
/// @return a vector of IDs of the tracks we want to keep
template <typename track_container_t, typename traj_t,
template <typename> class holder_t, bool ReadOnly = true>
template <TrackContainerFrontend track_container_t>
std::vector<int> solveAmbiguity(
const TrackContainer<track_container_t, traj_t, holder_t>& tracks,
const track_container_t& tracks,
const std::vector<std::vector<MeasurementInfo>>& measurementsPerTrack,
const std::vector<std::vector<TrackFeatures>>& trackFeaturesVectors,
const OptionalCuts<track_container_t, traj_t, holder_t, ReadOnly>&
const OptionalCuts<typename track_container_t::ConstTrackProxy>&
optionalCuts = {}) const;

private:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@

#include "Acts/AmbiguityResolution/ScoreBasedAmbiguityResolution.hpp"
#include "Acts/Definitions/Units.hpp"
#include "Acts/EventData/TrackContainerFrontendConcept.hpp"
#include "Acts/Utilities/VectorHelpers.hpp"

#include <unordered_map>
Expand All @@ -20,13 +21,11 @@ inline const Logger& ScoreBasedAmbiguityResolution::logger() const {
return *m_logger;
}

template <typename track_container_t, typename traj_t,
template <typename> class holder_t, typename source_link_hash_t,
template <TrackContainerFrontend track_container_t, typename source_link_hash_t,
typename source_link_equality_t>
std::vector<std::vector<ScoreBasedAmbiguityResolution::MeasurementInfo>>
ScoreBasedAmbiguityResolution::computeInitialState(
const TrackContainer<track_container_t, traj_t, holder_t>& tracks,
source_link_hash_t sourceLinkHash,
const track_container_t& tracks, source_link_hash_t sourceLinkHash,
source_link_equality_t sourceLinkEquality,
std::vector<std::vector<TrackFeatures>>& trackFeaturesVectors) const {
auto MeasurementIndexMap =
Expand Down Expand Up @@ -98,12 +97,11 @@ ScoreBasedAmbiguityResolution::computeInitialState(
return measurementsPerTrack;
}

template <typename track_container_t, typename traj_t,
template <typename> class holder_t, bool ReadOnly>
template <TrackContainerFrontend track_container_t>
std::vector<double> Acts::ScoreBasedAmbiguityResolution::simpleScore(
const TrackContainer<track_container_t, traj_t, holder_t>& tracks,
const track_container_t& tracks,
const std::vector<std::vector<TrackFeatures>>& trackFeaturesVectors,
const OptionalCuts<track_container_t, traj_t, holder_t, ReadOnly>&
const OptionalCuts<typename track_container_t::ConstTrackProxy>&
optionalCuts) const {
std::vector<double> trackScore;
trackScore.reserve(tracks.size());
Expand Down Expand Up @@ -248,12 +246,11 @@ std::vector<double> Acts::ScoreBasedAmbiguityResolution::simpleScore(
return trackScore;
}

template <typename track_container_t, typename traj_t,
template <typename> class holder_t, bool ReadOnly>
template <TrackContainerFrontend track_container_t>
std::vector<double> Acts::ScoreBasedAmbiguityResolution::ambiguityScore(
const TrackContainer<track_container_t, traj_t, holder_t>& tracks,
const track_container_t& tracks,
const std::vector<std::vector<TrackFeatures>>& trackFeaturesVectors,
const OptionalCuts<track_container_t, traj_t, holder_t, ReadOnly>&
const OptionalCuts<typename track_container_t::ConstTrackProxy>&
optionalCuts) const {
std::vector<double> trackScore;
trackScore.reserve(tracks.size());
Expand Down Expand Up @@ -425,13 +422,13 @@ std::vector<double> Acts::ScoreBasedAmbiguityResolution::ambiguityScore(

return trackScore;
}
template <typename track_container_t, typename traj_t,
template <typename> class holder_t, bool ReadOnly>

template <TrackContainerFrontend track_container_t>
std::vector<int> Acts::ScoreBasedAmbiguityResolution::solveAmbiguity(
const TrackContainer<track_container_t, traj_t, holder_t>& tracks,
const track_container_t& tracks,
const std::vector<std::vector<MeasurementInfo>>& measurementsPerTrack,
const std::vector<std::vector<TrackFeatures>>& trackFeaturesVectors,
const OptionalCuts<track_container_t, traj_t, holder_t, ReadOnly>&
const OptionalCuts<typename track_container_t::ConstTrackProxy>&
optionalCuts) const {
ACTS_INFO("Number of tracks before Ambiguty Resolution: " << tracks.size());
// vector of trackFeaturesVectors. where each trackFeaturesVector contains the
Expand Down
34 changes: 33 additions & 1 deletion Core/include/Acts/EventData/SubspaceHelpers.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ inline static bool checkSubspaceIndices(const Container& container,
if (subspaceSize > fullSize) {
return false;
}
if (container.size() != subspaceSize) {
if (static_cast<std::size_t>(container.size()) != subspaceSize) {
return false;
}
for (auto it = container.begin(); it != container.end();) {
Expand Down Expand Up @@ -115,6 +115,36 @@ class SubspaceHelperBase {
auto begin() const { return self().begin(); }
auto end() const { return self().end(); }

bool contains(std::uint8_t index) const {
return std::find(begin(), end(), index) != end();
}
std::size_t indexOf(std::uint8_t index) const {
auto it = std::find(begin(), end(), index);
return it != end() ? std::distance(begin(), it) : kFullSize;
}

template <typename EigenDerived>
ActsVector<kFullSize> expandVector(
const Eigen::DenseBase<EigenDerived>& vector) const {
ActsVector<kFullSize> result = ActsVector<kFullSize>::Zero();
for (auto [i, index] : enumerate(*this)) {
result(index) = vector(i);
}
return result;
}

template <typename EigenDerived>
FullSquareMatrix expandMatrix(
const Eigen::DenseBase<EigenDerived>& matrix) const {
FullSquareMatrix result = FullSquareMatrix::Zero();
for (auto [i, indexI] : enumerate(*this)) {
for (auto [j, indexJ] : enumerate(*this)) {
result(indexI, indexJ) = matrix(i, j);
}
}
return result;
}

FullSquareMatrix fullProjector() const {
FullSquareMatrix result = FullSquareMatrix::Zero();
for (auto [i, index] : enumerate(*this)) {
Expand Down Expand Up @@ -168,6 +198,7 @@ class VariableSubspaceHelper

bool empty() const { return m_indices.empty(); }
std::size_t size() const { return m_indices.size(); }
const Container& indices() const { return m_indices; }

IndexType operator[](std::size_t i) const { return m_indices[i]; }

Expand Down Expand Up @@ -215,6 +246,7 @@ class FixedSubspaceHelper

bool empty() const { return m_indices.empty(); }
std::size_t size() const { return m_indices.size(); }
const Container& indices() const { return m_indices; }

IndexType operator[](std::uint32_t i) const { return m_indices[i]; }

Expand Down
33 changes: 33 additions & 0 deletions Core/include/Acts/EventData/TrackContainerFrontendConcept.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
// This file is part of the Acts project.
//
// Copyright (C) 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/.

#pragma once

#include "Acts/EventData/TrackContainerBackendConcept.hpp"
#include "Acts/EventData/Types.hpp"

#include <concepts>

namespace Acts {

template <typename T>
concept TrackContainerFrontend = requires() {
{ T::ReadOnly } -> std::same_as<const bool &>;

requires std::same_as<typename T::IndexType, TrackIndexType>;

requires TrackContainerBackend<typename T::TrackContainerBackend>;
requires CommonMultiTrajectoryBackend<typename T::TrackStateContainerBackend>;

typename T::TrackProxy;
typename T::ConstTrackProxy;
typename T::TrackStateProxy;
typename T::ConstTrackStateProxy;
};

} // namespace Acts
27 changes: 0 additions & 27 deletions Core/include/Acts/EventData/TrackHelpers.hpp

This file was deleted.

5 changes: 4 additions & 1 deletion Core/include/Acts/EventData/TrackProxy.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
#include "Acts/EventData/ParticleHypothesis.hpp"
#include "Acts/EventData/TrackContainerBackendConcept.hpp"
#include "Acts/EventData/TrackParameters.hpp"
#include "Acts/EventData/TrackProxyConcept.hpp"
#include "Acts/EventData/TrackStatePropMask.hpp"
#include "Acts/Utilities/HashedString.hpp"
#include "Acts/Utilities/UnitVectors.hpp"
Expand Down Expand Up @@ -682,7 +683,7 @@ class TrackProxy {
/// @tparam track_proxy_t the other track proxy's type
/// @param other The track proxy
/// @param copyTrackStates Copy the track state sequence from @p other
template <typename track_proxy_t>
template <TrackProxyConcept track_proxy_t>
void copyFrom(const track_proxy_t& other, bool copyTrackStates = true)
requires(!ReadOnly)
{
Expand Down Expand Up @@ -710,6 +711,8 @@ class TrackProxy {
setReferenceSurface(other.referenceSurface().getSharedPtr());
parameters() = other.parameters();
covariance() = other.covariance();
} else {
setReferenceSurface(nullptr);
}

nMeasurements() = other.nMeasurements();
Expand Down
Loading

0 comments on commit 095e937

Please sign in to comment.