diff --git a/Core/include/Acts/AmbiguityResolution/GreedyAmbiguityResolution.hpp b/Core/include/Acts/AmbiguityResolution/GreedyAmbiguityResolution.hpp index 39f967b3494..1e59440b534 100644 --- a/Core/include/Acts/AmbiguityResolution/GreedyAmbiguityResolution.hpp +++ b/Core/include/Acts/AmbiguityResolution/GreedyAmbiguityResolution.hpp @@ -1,6 +1,6 @@ // This file is part of the Acts project. // -// Copyright (C) 2020 CERN for the benefit of the Acts project +// Copyright (C) 2023-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 @@ -77,13 +77,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 class holder_t, typename source_link_hash_t, + template - void computeInitialState( - const TrackContainer& tracks, - State& state, source_link_hash_t&& sourceLinkHash, - source_link_equality_t&& sourceLinkEquality) const; + 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. diff --git a/Core/include/Acts/AmbiguityResolution/GreedyAmbiguityResolution.ipp b/Core/include/Acts/AmbiguityResolution/GreedyAmbiguityResolution.ipp index ee2d14b1564..7fd3a1ce9b4 100644 --- a/Core/include/Acts/AmbiguityResolution/GreedyAmbiguityResolution.ipp +++ b/Core/include/Acts/AmbiguityResolution/GreedyAmbiguityResolution.ipp @@ -14,12 +14,11 @@ namespace Acts { -template class holder_t, typename source_link_hash_t, +template void GreedyAmbiguityResolution::computeInitialState( - const TrackContainer& 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 class holder_t, bool ReadOnly = true> + template struct OptionalCuts { - using OptionalFilter = - std::function&)>; + using OptionalFilter = std::function; - using OptionalScoreModifier = std::function&, - double&)>; + using OptionalScoreModifier = + std::function; std::vector cuts = {}; std::vector weights = {}; @@ -146,12 +142,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 class holder_t, typename source_link_hash_t, + template std::vector> computeInitialState( - const TrackContainer& tracks, - source_link_hash_t sourceLinkHash, + const track_container_t& tracks, source_link_hash_t sourceLinkHash, source_link_equality_t sourceLinkEquality, std::vector>& trackFeaturesVectors) const; @@ -161,12 +155,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 class holder_t, bool ReadOnly = true> + template std::vector simpleScore( - const TrackContainer& tracks, + const track_container_t& tracks, const std::vector>& trackFeaturesVectors, - const OptionalCuts& + const OptionalCuts& optionalCuts = {}) const; /// Compute the score of each track based on the ambiguity function. @@ -175,12 +168,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 class holder_t, bool ReadOnly = true> + template std::vector ambiguityScore( - const TrackContainer& tracks, + const track_container_t& tracks, const std::vector>& trackFeaturesVectors, - const OptionalCuts& + const OptionalCuts& optionalCuts = {}) const; /// Remove hits that are not good enough for each track and removes tracks @@ -205,13 +197,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 class holder_t, bool ReadOnly = true> + template std::vector solveAmbiguity( - const TrackContainer& tracks, + const track_container_t& tracks, const std::vector>& measurementsPerTrack, const std::vector>& trackFeaturesVectors, - const OptionalCuts& + const OptionalCuts& optionalCuts = {}) const; private: diff --git a/Core/include/Acts/AmbiguityResolution/ScoreBasedAmbiguityResolution.ipp b/Core/include/Acts/AmbiguityResolution/ScoreBasedAmbiguityResolution.ipp index cb3f5803342..903b1bb63d4 100644 --- a/Core/include/Acts/AmbiguityResolution/ScoreBasedAmbiguityResolution.ipp +++ b/Core/include/Acts/AmbiguityResolution/ScoreBasedAmbiguityResolution.ipp @@ -20,13 +20,11 @@ inline const Logger& ScoreBasedAmbiguityResolution::logger() const { return *m_logger; } -template class holder_t, typename source_link_hash_t, +template std::vector> ScoreBasedAmbiguityResolution::computeInitialState( - const TrackContainer& tracks, - source_link_hash_t sourceLinkHash, + const track_container_t& tracks, source_link_hash_t sourceLinkHash, source_link_equality_t sourceLinkEquality, std::vector>& trackFeaturesVectors) const { auto MeasurementIndexMap = @@ -98,12 +96,11 @@ ScoreBasedAmbiguityResolution::computeInitialState( return measurementsPerTrack; } -template class holder_t, bool ReadOnly> +template std::vector Acts::ScoreBasedAmbiguityResolution::simpleScore( - const TrackContainer& tracks, + const track_container_t& tracks, const std::vector>& trackFeaturesVectors, - const OptionalCuts& + const OptionalCuts& optionalCuts) const { std::vector trackScore; trackScore.reserve(tracks.size()); @@ -248,12 +245,11 @@ std::vector Acts::ScoreBasedAmbiguityResolution::simpleScore( return trackScore; } -template class holder_t, bool ReadOnly> +template std::vector Acts::ScoreBasedAmbiguityResolution::ambiguityScore( - const TrackContainer& tracks, + const track_container_t& tracks, const std::vector>& trackFeaturesVectors, - const OptionalCuts& + const OptionalCuts& optionalCuts) const { std::vector trackScore; trackScore.reserve(tracks.size()); @@ -425,13 +421,13 @@ std::vector Acts::ScoreBasedAmbiguityResolution::ambiguityScore( return trackScore; } -template class holder_t, bool ReadOnly> + +template std::vector Acts::ScoreBasedAmbiguityResolution::solveAmbiguity( - const TrackContainer& tracks, + const track_container_t& tracks, const std::vector>& measurementsPerTrack, const std::vector>& trackFeaturesVectors, - const OptionalCuts& + const OptionalCuts& optionalCuts) const { ACTS_INFO("Number of tracks before Ambiguty Resolution: " << tracks.size()); // vector of trackFeaturesVectors. where each trackFeaturesVector contains the diff --git a/Core/include/Acts/EventData/TrackHelpers.hpp b/Core/include/Acts/EventData/TrackHelpers.hpp index d88d1104850..2ee615fa656 100644 --- a/Core/include/Acts/EventData/TrackHelpers.hpp +++ b/Core/include/Acts/EventData/TrackHelpers.hpp @@ -15,16 +15,10 @@ namespace Acts { /// Helper function to calculate a number of track level quantities and store /// them on the track itself /// @note The input track needs to be mutable, so @c ReadOnly=false -/// @tparam track_container_t the track container backend -/// @tparam track_state_container_t the track state container backend -/// @tparam holder_t the holder type for the track container backends +/// @tparam track_proxy_t The type of the track proxy /// @param track A mutable track proxy to operate on -template class holder_t> -void calculateTrackQuantities( - Acts::TrackProxy - track) { +template +void calculateTrackQuantities(track_proxy_t track) { track.chi2() = 0; track.nDoF() = 0; diff --git a/Core/include/Acts/TrackFitting/GaussianSumFitter.hpp b/Core/include/Acts/TrackFitting/GaussianSumFitter.hpp index 49debb5d4cc..d5342a82443 100644 --- a/Core/include/Acts/TrackFitting/GaussianSumFitter.hpp +++ b/Core/include/Acts/TrackFitting/GaussianSumFitter.hpp @@ -91,13 +91,12 @@ struct GaussianSumFitter { /// @brief The fit function for the Direct navigator template class holder_t> + typename track_container_t> auto fit(source_link_it_t begin, source_link_it_t end, const start_parameters_t& sParameters, const GsfOptions& options, const std::vector& sSequence, - TrackContainer& trackContainer) - const { + track_container_t& trackContainer) const { // Check if we have the correct navigator static_assert( std::is_same_v); @@ -148,12 +147,11 @@ struct GaussianSumFitter { /// @brief The fit function for the standard navigator template class holder_t> + typename track_container_t> auto fit(source_link_it_t begin, source_link_it_t end, const start_parameters_t& sParameters, const GsfOptions& options, - TrackContainer& trackContainer) - const { + track_container_t& trackContainer) const { // Check if we have the correct navigator static_assert(std::is_same_v); @@ -200,16 +198,13 @@ struct GaussianSumFitter { /// first measurementSurface template class holder_t> - Acts::Result< - typename TrackContainer::TrackProxy> - fit_impl(source_link_it_t begin, source_link_it_t end, - const start_parameters_t& sParameters, - const GsfOptions& options, - const fwd_prop_initializer_t& fwdPropInitializer, - const bwd_prop_initializer_t& bwdPropInitializer, - TrackContainer& trackContainer) - const { + typename track_container_t> + Acts::Result fit_impl( + source_link_it_t begin, source_link_it_t end, + const start_parameters_t& sParameters, const GsfOptions& options, + const fwd_prop_initializer_t& fwdPropInitializer, + const bwd_prop_initializer_t& bwdPropInitializer, + track_container_t& trackContainer) const { // return or abort utility auto return_error_or_abort = [&](auto error) { if (options.abortOnError) { diff --git a/Core/include/Acts/TrackFitting/GlobalChiSquareFitter.hpp b/Core/include/Acts/TrackFitting/GlobalChiSquareFitter.hpp index 49da43f4dcf..bdc59d26646 100644 --- a/Core/include/Acts/TrackFitting/GlobalChiSquareFitter.hpp +++ b/Core/include/Acts/TrackFitting/GlobalChiSquareFitter.hpp @@ -656,15 +656,13 @@ class Gx2Fitter { /// @return the output as an output track template class holder_t, - bool _isdn = isDirectNavigator> + typename track_container_t, bool _isdn = isDirectNavigator> auto fit(source_link_iterator_t it, source_link_iterator_t end, const start_parameters_t& sParameters, const Gx2FitterOptions& gx2fOptions, - TrackContainer& trackContainer) - const -> std::enable_if_t< - !_isdn, Result::TrackProxy>> { + track_container_t& trackContainer) const + -> std::enable_if_t> { // Preprocess Measurements (SourceLinks -> map) // To be able to find measurements later, we put them into a map // We need to copy input SourceLinks anyway, so the map can own them. diff --git a/Core/include/Acts/TrackFitting/KalmanFitter.hpp b/Core/include/Acts/TrackFitting/KalmanFitter.hpp index 7492e55cd9f..c4072d78b75 100644 --- a/Core/include/Acts/TrackFitting/KalmanFitter.hpp +++ b/Core/include/Acts/TrackFitting/KalmanFitter.hpp @@ -1067,8 +1067,7 @@ class KalmanFitter { /// @tparam source_link_iterator_t Iterator type used to pass source links /// @tparam start_parameters_t Type of the initial parameters /// @tparam parameters_t Type of parameters used for local parameters - /// @tparam track_container_t Type of the track container backend - /// @tparam holder_t Type defining track container backend ownership + /// @tparam track_container_t Type of the track container /// /// @param it Begin iterator for the fittable uncalibrated measurements /// @param end End iterator for the fittable uncalibrated measurements @@ -1082,15 +1081,13 @@ class KalmanFitter { /// @return the output as an output track template class holder_t, - bool _isdn = isDirectNavigator> + typename track_container_t, bool _isdn = isDirectNavigator> auto fit(source_link_iterator_t it, source_link_iterator_t end, const start_parameters_t& sParameters, const KalmanFitterOptions& kfOptions, - TrackContainer& trackContainer) - const -> std::enable_if_t< - !_isdn, Result::TrackProxy>> { + track_container_t& trackContainer) const + -> std::enable_if_t> { // To be able to find measurements later, we put them into a map // We need to copy input SourceLinks anyway, so the map can own them. ACTS_VERBOSE("Preparing " << std::distance(it, end) @@ -1144,9 +1141,9 @@ class KalmanFitter { kalmanActor.extensions = kfOptions.extensions; kalmanActor.actorLogger = m_actorLogger.get(); - return fit_impl(sParameters, propagatorOptions, - trackContainer); + return fit_impl(sParameters, propagatorOptions, + trackContainer); } /// Fit implementation of the forward filter, calls the @@ -1155,8 +1152,7 @@ class KalmanFitter { /// @tparam source_link_iterator_t Iterator type used to pass source links /// @tparam start_parameters_t Type of the initial parameters /// @tparam parameters_t Type of parameters used for local parameters - /// @tparam track_container_t Type of the track container backend - /// @tparam holder_t Type defining track container backend ownership + /// @tparam track_container_t Type of the track container /// /// @param it Begin iterator for the fittable uncalibrated measurements /// @param end End iterator for the fittable uncalibrated measurements @@ -1172,16 +1168,14 @@ class KalmanFitter { /// @return the output as an output track template class holder_t, - bool _isdn = isDirectNavigator> + typename track_container_t, bool _isdn = isDirectNavigator> auto fit(source_link_iterator_t it, source_link_iterator_t end, const start_parameters_t& sParameters, const KalmanFitterOptions& kfOptions, const std::vector& sSequence, - TrackContainer& trackContainer) - const -> std::enable_if_t< - _isdn, Result::TrackProxy>> { + track_container_t& trackContainer) const + -> std::enable_if_t<_isdn, + Result> { // To be able to find measurements later, we put them into a map // We need to copy input SourceLinks anyway, so the map can own them. ACTS_VERBOSE("Preparing " << std::distance(it, end) @@ -1229,9 +1223,9 @@ class KalmanFitter { // Set the surface sequence propagatorOptions.navigation.surfaces = sSequence; - return fit_impl(sParameters, propagatorOptions, - trackContainer); + return fit_impl(sParameters, propagatorOptions, + trackContainer); } private: @@ -1241,8 +1235,7 @@ class KalmanFitter { /// @tparam actor_list_t Type of the actor list /// @tparam aborter_list_t Type of the abort list /// @tparam kalman_result_t Type of the KF result - /// @tparam track_container_t Type of the track container backend - /// @tparam holder_t Type defining track container backend ownership + /// @tparam track_container_t Type of the track container /// /// @param sParameters The initial track parameters /// @param propagatorOptions The Propagator Options @@ -1250,14 +1243,11 @@ class KalmanFitter { /// /// @return the output as an output track template class holder_t> - auto fit_impl( - const start_parameters_t& sParameters, - const propagator_options_t& propagatorOptions, - TrackContainer& trackContainer) const - -> Result::TrackProxy> { + typename kalman_result_t, typename track_container_t> + auto fit_impl(const start_parameters_t& sParameters, + const propagator_options_t& propagatorOptions, + track_container_t& trackContainer) const + -> Result { auto propagatorState = m_propagator.template makeState(sParameters, propagatorOptions); @@ -1310,6 +1300,6 @@ class KalmanFitter { // Return the converted Track return track; } -}; +}; // namespace Acts } // namespace Acts diff --git a/Examples/Algorithms/AmbiguityResolution/src/ScoreBasedAmbiguityResolutionAlgorithm.cpp b/Examples/Algorithms/AmbiguityResolution/src/ScoreBasedAmbiguityResolutionAlgorithm.cpp index f3c7b99219c..41446543dc7 100644 --- a/Examples/Algorithms/AmbiguityResolution/src/ScoreBasedAmbiguityResolutionAlgorithm.cpp +++ b/Examples/Algorithms/AmbiguityResolution/src/ScoreBasedAmbiguityResolutionAlgorithm.cpp @@ -124,9 +124,7 @@ ActsExamples::ScoreBasedAmbiguityResolutionAlgorithm::execute( measurementsPerTracks = m_ambi.computeInitialState( tracks, &sourceLinkHash, &sourceLinkEquality, trackFeaturesVectors); - Acts::ScoreBasedAmbiguityResolution::OptionalCuts< - Acts::ConstVectorTrackContainer, Acts::ConstVectorMultiTrajectory, - std::shared_ptr, true> + Acts::ScoreBasedAmbiguityResolution::OptionalCuts optionalCuts; optionalCuts.cuts.push_back(doubleHolesFilter); std::vector goodTracks = m_ambi.solveAmbiguity( diff --git a/Examples/Algorithms/TrackFindingML/include/ActsExamples/TrackFindingML/AmbiguityDBScanClustering.hpp b/Examples/Algorithms/TrackFindingML/include/ActsExamples/TrackFindingML/AmbiguityDBScanClustering.hpp index 16a5801f971..071d15b81a4 100644 --- a/Examples/Algorithms/TrackFindingML/include/ActsExamples/TrackFindingML/AmbiguityDBScanClustering.hpp +++ b/Examples/Algorithms/TrackFindingML/include/ActsExamples/TrackFindingML/AmbiguityDBScanClustering.hpp @@ -25,13 +25,11 @@ namespace Acts { /// @param epsilon Maximum distance between 2 tracks to be clustered /// @param minPoints Minimum number of tracks to create a cluster /// @return an unordered map representing the clusters, the keys the ID of the primary track of each cluster and the store a vector of track IDs. -template class holder_t> +template std::unordered_map> dbscanTrackClustering( std::multimap>>& trackMap, - const Acts::TrackContainer& tracks, - float epsilon = 0.07, int minPoints = 2) { + const track_container_t& tracks, float epsilon = 0.07, int minPoints = 2) { // Unordered map associating a vector with all the track ID of a cluster to // the ID of the first track of the cluster std::unordered_map> cluster; diff --git a/Plugins/EDM4hep/include/Acts/Plugins/EDM4hep/EDM4hepUtil.hpp b/Plugins/EDM4hep/include/Acts/Plugins/EDM4hep/EDM4hepUtil.hpp index 505f9bbe1cc..7d494154a33 100644 --- a/Plugins/EDM4hep/include/Acts/Plugins/EDM4hep/EDM4hepUtil.hpp +++ b/Plugins/EDM4hep/include/Acts/Plugins/EDM4hep/EDM4hepUtil.hpp @@ -60,14 +60,10 @@ BoundTrackParameters convertTrackParametersFromEdm4hep( } // namespace detail -template class holder_t> -void writeTrack( - const Acts::GeometryContext& gctx, - Acts::TrackProxy - track, - edm4hep::MutableTrack to, double Bz, - const Logger& logger = getDummyLogger()) { +template +void writeTrack(const Acts::GeometryContext& gctx, track_proxy_t track, + edm4hep::MutableTrack to, double Bz, + const Logger& logger = getDummyLogger()) { ACTS_VERBOSE("Converting track to EDM4hep"); to.setChi2(track.chi2()); to.setNdf(track.nDoF()); @@ -164,13 +160,9 @@ void writeTrack( } } -template class holder_t> -void readTrack(const edm4hep::Track& from, - Acts::TrackProxy - track, - double Bz, const Logger& logger = getDummyLogger()) { +template +void readTrack(const edm4hep::Track& from, track_proxy_t track, double Bz, + const Logger& logger = getDummyLogger()) { ACTS_VERBOSE("Reading track from EDM4hep"); TrackStatePropMask mask = TrackStatePropMask::Smoothed; diff --git a/Plugins/Onnx/include/Acts/Plugins/Onnx/AmbiguityTrackClassifier.hpp b/Plugins/Onnx/include/Acts/Plugins/Onnx/AmbiguityTrackClassifier.hpp index 8759450abd4..420c0fc9761 100644 --- a/Plugins/Onnx/include/Acts/Plugins/Onnx/AmbiguityTrackClassifier.hpp +++ b/Plugins/Onnx/include/Acts/Plugins/Onnx/AmbiguityTrackClassifier.hpp @@ -36,12 +36,10 @@ class AmbiguityTrackClassifier { /// @param clusters is a map of clusters, each cluster correspond to a vector of track ID /// @param tracks is the input track container /// @return a vector of vector of track score. Due to the architecture of the network each track only have a size 1 score vector. - template class holder_t> + template std::vector> inferScores( std::unordered_map>& clusters, - const Acts::TrackContainer& tracks) - const { + const track_proxy_t& tracks) const { // Compute the number of entry (since it is smaller than the number of // track) int trackNb = 0; @@ -107,12 +105,10 @@ class AmbiguityTrackClassifier { /// @param clusters is a map of clusters, each cluster correspond to a vector of track ID /// @param tracks is the input track container /// @return a vector of trackID corresponding tho the good tracks - template class holder_t> + template std::vector solveAmbiguity( std::unordered_map>& clusters, - const Acts::TrackContainer& tracks) - const { + const track_container_t& tracks) const { std::vector> outputTensor = inferScores(clusters, tracks); std::vector goodTracks =