diff --git a/Core/include/Acts/AmbiguityResolution/GreedyAmbiguityResolution.hpp b/Core/include/Acts/AmbiguityResolution/GreedyAmbiguityResolution.hpp index cffdb128220..078d155a27a 100644 --- a/Core/include/Acts/AmbiguityResolution/GreedyAmbiguityResolution.hpp +++ b/Core/include/Acts/AmbiguityResolution/GreedyAmbiguityResolution.hpp @@ -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" @@ -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 class holder_t, typename source_link_hash_t, - typename source_link_equality_t> - void computeInitialState( - const TrackContainer& tracks, - State& state, source_link_hash_t&& sourceLinkHash, - source_link_equality_t&& sourceLinkEquality) const; + template + 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 2f231ff216b..ec79c36260d 100644 --- a/Core/include/Acts/AmbiguityResolution/GreedyAmbiguityResolution.ipp +++ b/Core/include/Acts/AmbiguityResolution/GreedyAmbiguityResolution.ipp @@ -15,12 +15,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 +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 class holder_t, typename source_link_hash_t, - typename source_link_equality_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 +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 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 +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 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 +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 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 5175248a05c..8041188b5cf 100644 --- a/Core/include/Acts/AmbiguityResolution/ScoreBasedAmbiguityResolution.ipp +++ b/Core/include/Acts/AmbiguityResolution/ScoreBasedAmbiguityResolution.ipp @@ -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 @@ -20,13 +21,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 +97,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 +246,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 +422,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/TrackContainerFrontendConcept.hpp b/Core/include/Acts/EventData/TrackContainerFrontendConcept.hpp new file mode 100644 index 00000000000..fdbb496ba9f --- /dev/null +++ b/Core/include/Acts/EventData/TrackContainerFrontendConcept.hpp @@ -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 + +namespace Acts { + +template +concept TrackContainerFrontend = requires() { + { T::ReadOnly } -> std::same_as; + + requires std::same_as; + + requires TrackContainerBackend; + requires CommonMultiTrajectoryBackend; + + typename T::TrackProxy; + typename T::ConstTrackProxy; + typename T::TrackStateProxy; + typename T::ConstTrackStateProxy; +}; + +} // namespace Acts diff --git a/Core/include/Acts/EventData/TrackHelpers.hpp b/Core/include/Acts/EventData/TrackHelpers.hpp deleted file mode 100644 index f51e5428af0..00000000000 --- a/Core/include/Acts/EventData/TrackHelpers.hpp +++ /dev/null @@ -1,27 +0,0 @@ -// This file is part 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 -// file, You can obtain one at http://mozilla.org/MPL/2.0/. - -#pragma once - -// This header is deprecated and will be removed in the future. -// Please use the new header instead: -#include "Acts/Utilities/TrackHelpers.hpp" - -namespace Acts { - -// Funny header deprecation strategy -namespace { -[[deprecated( - "This header is deprecated - use " - "Acts/Utilities/TrackHelpers.hpp")]] constexpr static int - utilities_trackhelpers_hpp_is_deprecated = 0; -constexpr static int please_dont_use_utilities_trackhelpers_hpp = - utilities_trackhelpers_hpp_is_deprecated; -} // namespace - -} // namespace Acts diff --git a/Core/include/Acts/EventData/TrackProxy.hpp b/Core/include/Acts/EventData/TrackProxy.hpp index faa56651e1e..81bc0f41715 100644 --- a/Core/include/Acts/EventData/TrackProxy.hpp +++ b/Core/include/Acts/EventData/TrackProxy.hpp @@ -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" @@ -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 + template void copyFrom(const track_proxy_t& other, bool copyTrackStates = true) requires(!ReadOnly) { diff --git a/Core/include/Acts/EventData/TrackProxyConcept.hpp b/Core/include/Acts/EventData/TrackProxyConcept.hpp new file mode 100644 index 00000000000..619799905e4 --- /dev/null +++ b/Core/include/Acts/EventData/TrackProxyConcept.hpp @@ -0,0 +1,30 @@ +// 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/MultiTrajectoryBackendConcept.hpp" +#include "Acts/EventData/TrackContainerBackendConcept.hpp" +#include "Acts/EventData/Types.hpp" + +#include + +namespace Acts { + +template +concept TrackProxyConcept = requires() { + { T::ReadOnly } -> std::same_as; + + requires TrackContainerBackend; + + requires CommonMultiTrajectoryBackend; + + requires std::same_as; +}; + +} // namespace Acts diff --git a/Core/include/Acts/Material/ISurfaceMaterial.hpp b/Core/include/Acts/Material/ISurfaceMaterial.hpp index d76254f2224..34d3d25c938 100644 --- a/Core/include/Acts/Material/ISurfaceMaterial.hpp +++ b/Core/include/Acts/Material/ISurfaceMaterial.hpp @@ -1,6 +1,6 @@ // This file is part of the Acts project. // -// Copyright (C) 2016-2020 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 @@ -139,7 +139,7 @@ inline MaterialSlab ISurfaceMaterial::materialSlab( // The plain material properties associated to this bin MaterialSlab plainMatProp = materialSlab(lp); // Scale if you have material to scale - if (plainMatProp) { + if (plainMatProp.isValid()) { double scaleFactor = factor(pDir, mStage); if (scaleFactor == 0.) { return MaterialSlab(); @@ -154,7 +154,7 @@ inline MaterialSlab ISurfaceMaterial::materialSlab( // The plain material properties associated to this bin MaterialSlab plainMatProp = materialSlab(gp); // Scale if you have material to scale - if (plainMatProp) { + if (plainMatProp.isValid()) { double scaleFactor = factor(pDir, mStage); if (scaleFactor == 0.) { return MaterialSlab(); diff --git a/Core/include/Acts/Material/Material.hpp b/Core/include/Acts/Material/Material.hpp index bccea094a90..2984a26a18d 100644 --- a/Core/include/Acts/Material/Material.hpp +++ b/Core/include/Acts/Material/Material.hpp @@ -1,6 +1,6 @@ // This file is part of the Acts project. // -// Copyright (C) 2016-2020 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 @@ -74,7 +74,7 @@ class Material { /// Construct a vacuum representation. Material() = default; /// Construct from an encoded parameters vector. - Material(const ParametersVector& parameters); + explicit Material(const ParametersVector& parameters); Material(Material&& mat) = default; Material(const Material& mat) = default; @@ -83,9 +83,9 @@ class Material { Material& operator=(const Material& mat) = default; /// Check if the material is valid, i.e. it is not vacuum. - constexpr operator bool() const { return 0.0f < m_ar; } + bool isValid() const { return 0.0f < m_ar; } - /// Return the radition length. Infinity in case of vacuum. + /// Return the radiation length. Infinity in case of vacuum. constexpr float X0() const { return m_x0; } /// Return the nuclear interaction length. Infinity in case of vacuum. constexpr float L0() const { return m_l0; } diff --git a/Core/include/Acts/Material/MaterialSlab.hpp b/Core/include/Acts/Material/MaterialSlab.hpp index cfa531a9ff4..1942498daba 100644 --- a/Core/include/Acts/Material/MaterialSlab.hpp +++ b/Core/include/Acts/Material/MaterialSlab.hpp @@ -1,6 +1,6 @@ // This file is part of the Acts project. // -// Copyright (C) 2016-2020 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 @@ -45,7 +45,7 @@ class MaterialSlab { /// Construct vacuum without thickness. MaterialSlab() = default; /// Construct vacuum with thickness. - MaterialSlab(float thickness); + explicit MaterialSlab(float thickness); /// Construct from material description. /// /// @param material is the material description @@ -62,7 +62,7 @@ class MaterialSlab { void scaleThickness(float scale); /// Check if the material is valid, i.e. it is finite and not vacuum. - constexpr operator bool() const { return m_material && (0.0f < m_thickness); } + bool isValid() const { return m_material.isValid() && (0.0f < m_thickness); } /// Access the (average) material parameters. constexpr const Material& material() const { return m_material; } diff --git a/Core/include/Acts/Propagator/detail/PointwiseMaterialInteraction.hpp b/Core/include/Acts/Propagator/detail/PointwiseMaterialInteraction.hpp index e3c32247b64..66624b4ca11 100644 --- a/Core/include/Acts/Propagator/detail/PointwiseMaterialInteraction.hpp +++ b/Core/include/Acts/Propagator/detail/PointwiseMaterialInteraction.hpp @@ -1,6 +1,6 @@ // This file is part of the Acts project. // -// Copyright (C) 2019 CERN for the benefit of the Acts project +// Copyright (C) 2019-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 @@ -50,7 +50,7 @@ struct PointwiseMaterialInteraction { const Direction navDir; /// The effective, passed material properties including the path correction. - MaterialSlab slab; + MaterialSlab slab = MaterialSlab(0.); /// The path correction factor due to non-zero incidence on the surface. double pathCorrection = 0.; /// Expected phi variance due to the interactions. @@ -89,6 +89,7 @@ struct PointwiseMaterialInteraction { navDir(state.options.direction) {} /// @brief This function evaluates the material properties to interact with + /// This updates the slab and then returns, if the resulting slab is valid /// /// @tparam propagator_state_t Type of the propagator state /// @tparam navigator_t Type of the navigator @@ -119,8 +120,8 @@ struct PointwiseMaterialInteraction { pathCorrection = surface->pathCorrection(state.geoContext, pos, dir); slab.scaleThickness(pathCorrection); - // Get the surface material & properties from them - return slab; + // Check if the evaluated material is valid + return slab.isValid(); } /// @brief This function evaluate the material effects diff --git a/Core/include/Acts/Propagator/detail/VolumeMaterialInteraction.hpp b/Core/include/Acts/Propagator/detail/VolumeMaterialInteraction.hpp index 8fd72f38aa8..e5a8efbd29f 100644 --- a/Core/include/Acts/Propagator/detail/VolumeMaterialInteraction.hpp +++ b/Core/include/Acts/Propagator/detail/VolumeMaterialInteraction.hpp @@ -1,6 +1,6 @@ // This file is part of the Acts project. // -// Copyright (C) 2019-2020 CERN for the benefit of the Acts project +// Copyright (C) 2019-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 @@ -119,7 +119,7 @@ struct VolumeMaterialInteraction { } else { slab = MaterialSlab(); } - return slab; + return slab.isValid(); } }; diff --git a/Core/include/Acts/TrackFinding/TrackSelector.hpp b/Core/include/Acts/TrackFinding/TrackSelector.hpp index 3849b4a9dc5..0695bf08a8b 100644 --- a/Core/include/Acts/TrackFinding/TrackSelector.hpp +++ b/Core/include/Acts/TrackFinding/TrackSelector.hpp @@ -8,6 +8,7 @@ #pragma once +#include "Acts/EventData/TrackProxyConcept.hpp" #include "Acts/EventData/TrackStateType.hpp" #include "Acts/Geometry/GeometryHierarchyMap.hpp" #include "Acts/Geometry/GeometryIdentifier.hpp" @@ -37,7 +38,7 @@ class TrackSelector { boost::container::small_vector counters; - template + template bool isValidTrack(const track_proxy_t& track) const; void addCounter(const std::vector& identifiers, @@ -227,7 +228,7 @@ class TrackSelector { /// @tparam track_proxy_t is the type of the track proxy /// @param track is the track proxy /// @return true if the track is valid - template + template bool isValidTrack(const track_proxy_t& track) const; /// Get readonly access to the config parameters @@ -389,7 +390,7 @@ void TrackSelector::selectTracks(const input_tracks_t& inputTracks, } } -template +template bool TrackSelector::isValidTrack(const track_proxy_t& track) const { auto checkMin = [](auto x, auto min) { return min <= x; }; auto checkMax = [](auto x, auto max) { return x <= max; }; @@ -478,7 +479,7 @@ inline TrackSelector::TrackSelector( inline TrackSelector::TrackSelector(const Config& config) : TrackSelector{EtaBinnedConfig{config}} {} -template +template bool TrackSelector::MeasurementCounter::isValidTrack( const track_proxy_t& track) const { // No hit cuts, accept everything diff --git a/Core/include/Acts/TrackFitting/GaussianSumFitter.hpp b/Core/include/Acts/TrackFitting/GaussianSumFitter.hpp index 0b1f9d5e78d..ada401ba401 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> + TrackContainerFrontend 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> + TrackContainerFrontend 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 { + TrackContainerFrontend 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 e2d255ced42..e87a52410d8 100644 --- a/Core/include/Acts/TrackFitting/GlobalChiSquareFitter.hpp +++ b/Core/include/Acts/TrackFitting/GlobalChiSquareFitter.hpp @@ -16,6 +16,7 @@ #include "Acts/EventData/MultiTrajectory.hpp" #include "Acts/EventData/MultiTrajectoryHelpers.hpp" #include "Acts/EventData/SourceLink.hpp" +#include "Acts/EventData/TrackContainerFrontendConcept.hpp" #include "Acts/EventData/TrackParameters.hpp" #include "Acts/EventData/VectorMultiTrajectory.hpp" #include "Acts/EventData/VectorTrackContainer.hpp" @@ -996,13 +997,12 @@ class Gx2Fitter { /// @return the output as an output track template class holder_t> - auto fit(source_link_iterator_t it, source_link_iterator_t end, - const start_parameters_t& sParameters, - const Gx2FitterOptions& gx2fOptions, - TrackContainer& trackContainer) - const -> Result::TrackProxy> + TrackContainerFrontend track_container_t> + Result fit( + source_link_iterator_t it, source_link_iterator_t end, + const start_parameters_t& sParameters, + const Gx2FitterOptions& gx2fOptions, + track_container_t& trackContainer) const requires(!isDirectNavigator) { // Preprocess Measurements (SourceLinks -> map) @@ -1046,7 +1046,7 @@ class Gx2Fitter { // new track and delete it after updating the parameters. However, if we // would work on the externally provided track container, it would be // difficult to remove the correct track, if it contains more than one. - track_container_t trackContainerTempBackend; + typename track_container_t::TrackContainerBackend trackContainerTempBackend; traj_t trajectoryTempBackend; TrackContainer trackContainerTemp{trackContainerTempBackend, trajectoryTempBackend}; diff --git a/Core/include/Acts/TrackFitting/KalmanFitter.hpp b/Core/include/Acts/TrackFitting/KalmanFitter.hpp index f5e2a10e7ff..7e7001d00ad 100644 --- a/Core/include/Acts/TrackFitting/KalmanFitter.hpp +++ b/Core/include/Acts/TrackFitting/KalmanFitter.hpp @@ -1,6 +1,6 @@ // This file is part of the Acts project. // -// Copyright (C) 2016-2023 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 @@ -14,6 +14,7 @@ #include "Acts/EventData/MultiTrajectory.hpp" #include "Acts/EventData/MultiTrajectoryHelpers.hpp" #include "Acts/EventData/SourceLink.hpp" +#include "Acts/EventData/TrackContainerFrontendConcept.hpp" #include "Acts/EventData/TrackParameters.hpp" #include "Acts/EventData/VectorMultiTrajectory.hpp" #include "Acts/Geometry/GeometryContext.hpp" @@ -1067,8 +1068,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,13 +1082,12 @@ class KalmanFitter { /// @return the output as an output track template class holder_t> - auto fit(source_link_iterator_t it, source_link_iterator_t end, - const start_parameters_t& sParameters, - const KalmanFitterOptions& kfOptions, - TrackContainer& trackContainer) - const -> Result::TrackProxy> + TrackContainerFrontend track_container_t> + Result fit( + source_link_iterator_t it, source_link_iterator_t end, + const start_parameters_t& sParameters, + const KalmanFitterOptions& kfOptions, + track_container_t& trackContainer) const requires(!isDirectNavigator) { // To be able to find measurements later, we put them into a map @@ -1145,8 +1144,8 @@ class KalmanFitter { kalmanActor.actorLogger = m_actorLogger.get(); return fit_impl(sParameters, propagatorOptions, - trackContainer); + track_container_t>(sParameters, propagatorOptions, + trackContainer); } /// Fit implementation of the forward filter, calls the @@ -1155,8 +1154,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,14 +1170,13 @@ class KalmanFitter { /// @return the output as an output track template class holder_t> - 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 -> Result::TrackProxy> + TrackContainerFrontend track_container_t> + Result fit( + source_link_iterator_t it, source_link_iterator_t end, + const start_parameters_t& sParameters, + const KalmanFitterOptions& kfOptions, + const std::vector& sSequence, + track_container_t& trackContainer) const requires(isDirectNavigator) { // To be able to find measurements later, we put them into a map @@ -1230,8 +1227,8 @@ class KalmanFitter { propagatorOptions.navigation.surfaces = sSequence; return fit_impl(sParameters, propagatorOptions, - trackContainer); + track_container_t>(sParameters, propagatorOptions, + trackContainer); } private: @@ -1241,8 +1238,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 +1246,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, TrackContainerFrontend 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); diff --git a/Core/include/Acts/Utilities/TrackHelpers.hpp b/Core/include/Acts/Utilities/TrackHelpers.hpp index 2fe845f6c39..11589981b9b 100644 --- a/Core/include/Acts/Utilities/TrackHelpers.hpp +++ b/Core/include/Acts/Utilities/TrackHelpers.hpp @@ -10,7 +10,9 @@ #include "Acts/Definitions/Tolerance.hpp" #include "Acts/EventData/MultiTrajectoryHelpers.hpp" +#include "Acts/EventData/TrackContainerFrontendConcept.hpp" #include "Acts/EventData/TrackParameters.hpp" +#include "Acts/EventData/TrackProxyConcept.hpp" #include "Acts/EventData/TrackStateType.hpp" #include "Acts/Geometry/GeometryContext.hpp" #include "Acts/Propagator/StandardAborters.hpp" @@ -40,7 +42,7 @@ enum class TrackExtrapolationError { std::error_code make_error_code(TrackExtrapolationError e); -template +template Result findFirstMeasurementState( const track_proxy_t &track) { using TrackStateProxy = typename track_proxy_t::ConstTrackStateProxy; @@ -63,7 +65,7 @@ Result findFirstMeasurementState( return result; } -template +template Result findLastMeasurementState( const track_proxy_t &track) { using TrackStateProxy = typename track_proxy_t::ConstTrackStateProxy; @@ -93,7 +95,8 @@ Result findLastMeasurementState( /// @param smoother The smoother /// /// @return The result of the smoothing -template +template Result smoothTrack( const GeometryContext &geoContext, track_proxy_t &track, const Logger &logger = *getDefaultLogger("TrackSmoother", Logging::INFO), @@ -128,7 +131,7 @@ Result smoothTrack( /// @param logger The logger /// /// @return The result of the smoothing -template +template Result smoothTracks( const GeometryContext &geoContext, const track_container_t &trackContainer, const Logger &logger = *getDefaultLogger("TrackSmoother", Logging::INFO)) { @@ -158,7 +161,7 @@ Result smoothTracks( /// /// @return The result of the search containing the track state /// and the distance to the reference surface -template +template Result> findTrackStateForExtrapolation( const GeometryContext &geoContext, const track_proxy_t &track, @@ -283,7 +286,7 @@ findTrackStateForExtrapolation( /// @param logger The logger /// /// @return The result of the extrapolation -template Result extrapolateTrackToReferenceSurface( track_proxy_t &track, const Surface &referenceSurface, @@ -340,7 +343,7 @@ Result extrapolateTrackToReferenceSurface( /// @param logger The logger /// /// @return The result of the extrapolation -template Result extrapolateTracksToReferenceSurface( const track_container_t &trackContainer, const Surface &referenceSurface, @@ -370,12 +373,8 @@ Result extrapolateTracksToReferenceSurface( /// @tparam track_state_container_t the track state container backend /// @tparam holder_t the holder type for the track container backends /// @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/src/Material/AverageMaterials.cpp b/Core/src/Material/AverageMaterials.cpp index af81781c8d5..29d07bd814d 100644 --- a/Core/src/Material/AverageMaterials.cpp +++ b/Core/src/Material/AverageMaterials.cpp @@ -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) 2020-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 @@ -29,10 +29,11 @@ Acts::MaterialSlab Acts::detail::combineSlabs(const MaterialSlab& slab1, // to properly account for the energy loss in multiple material. // use double for (intermediate) computations to avoid precision loss + const double thickness1 = static_cast(slab1.thickness()); + const double thickness2 = static_cast(slab2.thickness()); // the thickness properties are purely additive - double thickness = static_cast(slab1.thickness()) + - static_cast(slab2.thickness()); + const double thickness = thickness1 + thickness2; // if the two materials are the same there is no need for additional // computation @@ -40,30 +41,30 @@ Acts::MaterialSlab Acts::detail::combineSlabs(const MaterialSlab& slab1, return {mat1, static_cast(thickness)}; } - double thicknessInX0 = static_cast(slab1.thicknessInX0()) + - static_cast(slab2.thicknessInX0()); - double thicknessInL0 = static_cast(slab1.thicknessInL0()) + - static_cast(slab2.thicknessInL0()); - - // radiation/interaction length follows from consistency argument - float x0 = thickness / thicknessInX0; - float l0 = thickness / thicknessInL0; - // molar amount-of-substance assuming a unit area, i.e. volume = thickness*1*1 - double molarAmount1 = static_cast(mat1.molarDensity()) * - static_cast(slab1.thickness()); - double molarAmount2 = static_cast(mat2.molarDensity()) * - static_cast(slab2.thickness()); - double molarAmount = molarAmount1 + molarAmount2; + const double molarDensity1 = static_cast(mat1.molarDensity()); + const double molarDensity2 = static_cast(mat2.molarDensity()); + + const double molarAmount1 = molarDensity1 * thickness1; + const double molarAmount2 = molarDensity2 * thickness2; + const double molarAmount = molarAmount1 + molarAmount2; // handle vacuum specially if (!(0.0 < molarAmount)) { return {Material(), static_cast(thickness)}; } - // compute average molar density by dividing the total amount-of-substance by - // the total volume for the same unit area, i.e. volume = totalThickness*1*1 - float molarDensity = molarAmount / thickness; + // radiation/interaction length follows from consistency argument + const double thicknessX01 = static_cast(slab1.thicknessInX0()); + const double thicknessX02 = static_cast(slab2.thicknessInX0()); + const double thicknessL01 = static_cast(slab1.thicknessInL0()); + const double thicknessL02 = static_cast(slab2.thicknessInL0()); + + const double thicknessInX0 = thicknessX01 + thicknessX02; + const double thicknessInL0 = thicknessL01 + thicknessL02; + + const float x0 = static_cast(thickness / thicknessInX0); + const float l0 = static_cast(thickness / thicknessInL0); // assume two slabs of materials with N1,N2 atoms/molecules each with atomic // masses A1,A2 and nuclear charges. We have a total of N = N1 + N2 @@ -82,10 +83,12 @@ Acts::MaterialSlab Acts::detail::combineSlabs(const MaterialSlab& slab1, // = (Vi*rhoi) / (V1*rho1 + V2*rho2) // // which can be computed from the molar amount-of-substance above. + const double ar1 = static_cast(mat1.Ar()); + const double ar2 = static_cast(mat2.Ar()); - double molarWeight1 = molarAmount1 / molarAmount; - double molarWeight2 = molarAmount2 / molarAmount; - float ar = molarWeight1 * mat1.Ar() + molarWeight2 * mat2.Ar(); + const double molarWeight1 = molarAmount1 / molarAmount; + const double molarWeight2 = molarAmount2 / molarAmount; + const float ar = static_cast(molarWeight1 * ar1 + molarWeight2 * ar2); // In the case of the atomic number, its main use is the computation // of the mean excitation energy approximated in ATL-SOFT-PUB-2008-003 as : @@ -100,17 +103,23 @@ Acts::MaterialSlab Acts::detail::combineSlabs(const MaterialSlab& slab1, // To respect this the average atomic number thus need to be defined as : // ln(Z)*t = ln(Z1)*t1 + ln(Z2)*t2 // Z = Exp( ln(Z1)*t1/t + ln(Z2)*t2/t ) - - double thicknessWeight1 = slab1.thickness() / thickness; - double thicknessWeight2 = slab2.thickness() / thickness; - float z = 0; - if (mat1.Z() != 0 && mat2.Z() != 0) { - z = exp(thicknessWeight1 * log(mat1.Z()) + - thicknessWeight2 * log(mat2.Z())); + const double z1 = static_cast(mat1.Z()); + const double z2 = static_cast(mat2.Z()); + + const double thicknessWeight1 = thickness1 / thickness; + const double thicknessWeight2 = thickness2 / thickness; + float z = 0.f; + if (z1 > 0. && z2 > 0.) { + z = static_cast(std::exp(thicknessWeight1 * std::log(z1) + + thicknessWeight2 * std::log(z2))); } else { - z = thicknessWeight1 * mat1.Z() + thicknessWeight2 * mat2.Z(); + z = static_cast(thicknessWeight1 * z1 + thicknessWeight2 * z2); } + // compute average molar density by dividing the total amount-of-substance by + // the total volume for the same unit area, i.e. volume = totalThickness*1*1 + const float molarDensity = static_cast(molarAmount / thickness); + return {Material::fromMolarDensity(x0, l0, ar, z, molarDensity), static_cast(thickness)}; } diff --git a/Core/src/Material/Interactions.cpp b/Core/src/Material/Interactions.cpp index db3c4f9d483..b6a725cb4ca 100644 --- a/Core/src/Material/Interactions.cpp +++ b/Core/src/Material/Interactions.cpp @@ -1,6 +1,6 @@ // This file is part of the Acts project. // -// Copyright (C) 2019-2020 CERN for the benefit of the Acts project +// Copyright (C) 2019-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 @@ -154,7 +154,7 @@ namespace detail { inline float computeEnergyLossLandauFwhm(const Acts::MaterialSlab& slab, const RelativisticQuantities& rq) { // return early in case of vacuum or zero thickness - if (!slab) { + if (!slab.isValid()) { return 0.0f; } @@ -171,7 +171,7 @@ inline float computeEnergyLossLandauFwhm(const Acts::MaterialSlab& slab, float Acts::computeEnergyLossBethe(const MaterialSlab& slab, float m, float qOverP, float absQ) { // return early in case of vacuum or zero thickness - if (!slab) { + if (!slab.isValid()) { return 0.0f; } @@ -196,7 +196,7 @@ float Acts::computeEnergyLossBethe(const MaterialSlab& slab, float m, float Acts::deriveEnergyLossBetheQOverP(const MaterialSlab& slab, float m, float qOverP, float absQ) { // return early in case of vacuum or zero thickness - if (!slab) { + if (!slab.isValid()) { return 0.0f; } @@ -233,7 +233,7 @@ float Acts::deriveEnergyLossBetheQOverP(const MaterialSlab& slab, float m, float Acts::computeEnergyLossLandau(const MaterialSlab& slab, float m, float qOverP, float absQ) { // return early in case of vacuum or zero thickness - if (!slab) { + if (!slab.isValid()) { return 0.0f; } @@ -253,7 +253,7 @@ float Acts::computeEnergyLossLandau(const MaterialSlab& slab, float m, float Acts::deriveEnergyLossLandauQOverP(const MaterialSlab& slab, float m, float qOverP, float absQ) { // return early in case of vacuum or zero thickness - if (!slab) { + if (!slab.isValid()) { return 0.0f; } @@ -288,7 +288,7 @@ float Acts::deriveEnergyLossLandauQOverP(const MaterialSlab& slab, float m, float Acts::computeEnergyLossLandauSigma(const MaterialSlab& slab, float m, float qOverP, float absQ) { // return early in case of vacuum or zero thickness - if (!slab) { + if (!slab.isValid()) { return 0.0f; } @@ -386,7 +386,7 @@ float Acts::computeEnergyLossRadiative(const MaterialSlab& slab, "pdg is not absolute"); // return early in case of vacuum or zero thickness - if (!slab) { + if (!slab.isValid()) { return 0.0f; } @@ -415,7 +415,7 @@ float Acts::deriveEnergyLossRadiativeQOverP(const MaterialSlab& slab, "pdg is not absolute"); // return early in case of vacuum or zero thickness - if (!slab) { + if (!slab.isValid()) { return 0.0f; } @@ -504,7 +504,7 @@ float Acts::computeMultipleScatteringTheta0(const MaterialSlab& slab, "pdg is not absolute"); // return early in case of vacuum or zero thickness - if (!slab) { + if (!slab.isValid()) { return 0.0f; } diff --git a/Core/src/Material/Material.cpp b/Core/src/Material/Material.cpp index 9056c937fa7..21325f6e900 100644 --- a/Core/src/Material/Material.cpp +++ b/Core/src/Material/Material.cpp @@ -1,6 +1,6 @@ // This file is part of the Acts project. // -// Copyright (C) 2019-2020 CERN for the benefit of the Acts project +// Copyright (C) 2019-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 @@ -96,7 +96,7 @@ Acts::Material::ParametersVector Acts::Material::parameters() const { } std::ostream& Acts::operator<<(std::ostream& os, const Material& material) { - if (!material) { + if (!material.isValid()) { os << "vacuum"; } else { os << "x0=" << material.X0(); 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..efe7ef0aa5f 100644 --- a/Examples/Algorithms/TrackFindingML/include/ActsExamples/TrackFindingML/AmbiguityDBScanClustering.hpp +++ b/Examples/Algorithms/TrackFindingML/include/ActsExamples/TrackFindingML/AmbiguityDBScanClustering.hpp @@ -9,6 +9,7 @@ #pragma once #include "Acts/EventData/TrackContainer.hpp" +#include "Acts/EventData/TrackContainerFrontendConcept.hpp" #include "Acts/TrackFinding/detail/AmbiguityTrackClustering.hpp" #include "Acts/Utilities/DBScan.hpp" @@ -25,13 +26,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/Examples/Io/Root/src/RootMaterialWriter.cpp b/Examples/Io/Root/src/RootMaterialWriter.cpp index be43994f192..692036667a9 100644 --- a/Examples/Io/Root/src/RootMaterialWriter.cpp +++ b/Examples/Io/Root/src/RootMaterialWriter.cpp @@ -1,6 +1,6 @@ // This file is part of the Acts project. // -// Copyright (C) 2017-2018 CERN for the benefit of the Acts project +// Copyright (C) 2017-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 @@ -297,7 +297,7 @@ void ActsExamples::RootMaterialWriter::writeMaterial( Acts::MaterialGrid3D grid = bvMaterial3D->getMapper().getGrid(); for (std::size_t point = 0; point < points; point++) { auto mat = Acts::Material(grid.at(point)); - if (mat) { + if (mat.isValid()) { x0->SetBinContent(point + 1, mat.X0()); l0->SetBinContent(point + 1, mat.L0()); A->SetBinContent(point + 1, mat.Ar()); @@ -311,7 +311,7 @@ void ActsExamples::RootMaterialWriter::writeMaterial( Acts::MaterialGrid2D grid = bvMaterial2D->getMapper().getGrid(); for (std::size_t point = 0; point < points; point++) { auto mat = Acts::Material(grid.at(point)); - if (mat) { + if (mat.isValid()) { x0->SetBinContent(point + 1, mat.X0()); l0->SetBinContent(point + 1, mat.L0()); A->SetBinContent(point + 1, mat.Ar()); diff --git a/Fatras/include/ActsFatras/Kernel/detail/SimulationActor.hpp b/Fatras/include/ActsFatras/Kernel/detail/SimulationActor.hpp index 91482d3abd6..1e5deef90b5 100644 --- a/Fatras/include/ActsFatras/Kernel/detail/SimulationActor.hpp +++ b/Fatras/include/ActsFatras/Kernel/detail/SimulationActor.hpp @@ -1,6 +1,6 @@ // This file is part of the Acts project. // -// Copyright (C) 2018-2021 CERN for the benefit of the Acts project +// Copyright (C) 2018-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 @@ -183,7 +183,7 @@ struct SimulationActor { Acts::MaterialSlab slab = surface.surfaceMaterial()->materialSlab(local); // again: interact only if there is valid material to interact with - if (slab) { + if (slab.isValid()) { // adapt material for non-zero incidence auto normal = surface.normal(state.geoContext, before.position(), before.direction()); diff --git a/Plugins/EDM4hep/include/Acts/Plugins/EDM4hep/EDM4hepUtil.hpp b/Plugins/EDM4hep/include/Acts/Plugins/EDM4hep/EDM4hepUtil.hpp index 505f9bbe1cc..9b55768f70b 100644 --- a/Plugins/EDM4hep/include/Acts/Plugins/EDM4hep/EDM4hepUtil.hpp +++ b/Plugins/EDM4hep/include/Acts/Plugins/EDM4hep/EDM4hepUtil.hpp @@ -14,6 +14,7 @@ #include "Acts/EventData/MultiTrajectory.hpp" #include "Acts/EventData/TrackContainer.hpp" #include "Acts/EventData/TrackParameters.hpp" +#include "Acts/EventData/TrackProxyConcept.hpp" #include "Acts/EventData/TrackStatePropMask.hpp" #include "Acts/Geometry/GeometryContext.hpp" #include "Acts/Surfaces/PerigeeSurface.hpp" @@ -60,14 +61,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 +161,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/Json/src/MaterialJsonConverter.cpp b/Plugins/Json/src/MaterialJsonConverter.cpp index 8d523229435..7213f4bca17 100644 --- a/Plugins/Json/src/MaterialJsonConverter.cpp +++ b/Plugins/Json/src/MaterialJsonConverter.cpp @@ -1,6 +1,6 @@ // This file is part of the Acts project. // -// Copyright (C) 2021 CERN for the benefit of the Acts project +// Copyright (C) 2021-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 @@ -283,7 +283,7 @@ Acts::ISurfaceMaterial* indexedMaterialFromJson(nlohmann::json& jMaterial) { } // namespace void Acts::to_json(nlohmann::json& j, const Material& t) { - if (!t) { + if (!t.isValid()) { return; } for (unsigned i = 0; i < t.parameters().size(); ++i) { diff --git a/Plugins/Onnx/include/Acts/Plugins/Onnx/AmbiguityTrackClassifier.hpp b/Plugins/Onnx/include/Acts/Plugins/Onnx/AmbiguityTrackClassifier.hpp index 8759450abd4..c2dd49c1294 100644 --- a/Plugins/Onnx/include/Acts/Plugins/Onnx/AmbiguityTrackClassifier.hpp +++ b/Plugins/Onnx/include/Acts/Plugins/Onnx/AmbiguityTrackClassifier.hpp @@ -10,6 +10,8 @@ #include "Acts/EventData/MultiTrajectoryHelpers.hpp" #include "Acts/EventData/TrackContainer.hpp" +#include "Acts/EventData/TrackContainerFrontendConcept.hpp" +#include "Acts/EventData/TrackProxyConcept.hpp" #include "Acts/Plugins/Onnx/OnnxRuntimeBase.hpp" #include "Acts/TrackFinding/detail/AmbiguityTrackClustering.hpp" @@ -36,12 +38,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_container_t& tracks) const { // Compute the number of entry (since it is smaller than the number of // track) int trackNb = 0; @@ -107,12 +107,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 = diff --git a/Tests/UnitTests/Core/Material/AccumulatedMaterialSlabTests.cpp b/Tests/UnitTests/Core/Material/AccumulatedMaterialSlabTests.cpp index f9e0c4ad759..578b562cc8b 100644 --- a/Tests/UnitTests/Core/Material/AccumulatedMaterialSlabTests.cpp +++ b/Tests/UnitTests/Core/Material/AccumulatedMaterialSlabTests.cpp @@ -1,6 +1,6 @@ // This file is part of the Acts project. // -// Copyright (C) 2017-2020 CERN for the benefit of the Acts project +// Copyright (C) 2017-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 @@ -35,7 +35,7 @@ BOOST_AUTO_TEST_CASE(Nothing) { AccumulatedMaterialSlab a; auto [average, trackCount] = a.totalAverage(); // material is vacuum - BOOST_CHECK(!(average)); + BOOST_CHECK(!average.isValid()); BOOST_CHECK_EQUAL(trackCount, 0u); } @@ -46,7 +46,7 @@ BOOST_AUTO_TEST_CASE(EmptyTracksIgnored) { a.trackAverage(); a.trackAverage(); auto [average, trackCount] = a.totalAverage(); - BOOST_CHECK(!(average)); + BOOST_CHECK(!average.isValid()); BOOST_CHECK_EQUAL(trackCount, 0u); } @@ -57,7 +57,7 @@ BOOST_AUTO_TEST_CASE(EmptyTracks) { a.trackAverage(true); a.trackAverage(true); auto [average, trackCount] = a.totalAverage(); - BOOST_CHECK(!(average)); + BOOST_CHECK(!average.isValid()); BOOST_CHECK_EQUAL(trackCount, 3u); } diff --git a/Tests/UnitTests/Core/Material/AccumulatedVolumeMaterialTests.cpp b/Tests/UnitTests/Core/Material/AccumulatedVolumeMaterialTests.cpp index 10fdced1c15..6ededefb715 100644 --- a/Tests/UnitTests/Core/Material/AccumulatedVolumeMaterialTests.cpp +++ b/Tests/UnitTests/Core/Material/AccumulatedVolumeMaterialTests.cpp @@ -1,6 +1,6 @@ // This file is part of the Acts project. // -// Copyright (C) 2019 CERN for the benefit of the Acts project +// Copyright (C) 2019-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 @@ -23,11 +23,11 @@ BOOST_AUTO_TEST_CASE(vacuum) { AccumulatedVolumeMaterial avm; // averaging over nothing is vacuum - BOOST_CHECK(!avm.average()); + BOOST_CHECK(!avm.average().isValid()); // averaging over vacuum is still vacuum avm.accumulate(MaterialSlab(1)); - BOOST_CHECK(!avm.average()); + BOOST_CHECK(!avm.average().isValid()); } BOOST_AUTO_TEST_CASE(single_material) { diff --git a/Tests/UnitTests/Core/Material/AverageMaterialsTests.cpp b/Tests/UnitTests/Core/Material/AverageMaterialsTests.cpp index 599c7f739c4..fcfe8eaee08 100644 --- a/Tests/UnitTests/Core/Material/AverageMaterialsTests.cpp +++ b/Tests/UnitTests/Core/Material/AverageMaterialsTests.cpp @@ -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) 2020-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 @@ -41,7 +41,8 @@ BOOST_AUTO_TEST_CASE(CombineSlabsVacuum) { // vacuum with zero thickness { auto slab = combineSlabs(zeroVacuum, zeroVacuum); - BOOST_CHECK(!slab.material()); + BOOST_CHECK(!slab.isValid()); + BOOST_CHECK(!slab.material().isValid()); BOOST_CHECK_EQUAL(slab.thickness(), 0.0f); BOOST_CHECK_EQUAL(slab.thicknessInX0(), 0.0f); BOOST_CHECK_EQUAL(slab.thicknessInL0(), 0.0f); @@ -49,7 +50,8 @@ BOOST_AUTO_TEST_CASE(CombineSlabsVacuum) { // vacuum with unit thickness { auto slab = combineSlabs(unitVacuum, unitVacuum); - BOOST_CHECK(!slab.material()); + BOOST_CHECK(!slab.isValid()); + BOOST_CHECK(!slab.material().isValid()); BOOST_CHECK_EQUAL(slab.thickness(), 2.0f); BOOST_CHECK_EQUAL(slab.thicknessInX0(), 0.0f); BOOST_CHECK_EQUAL(slab.thicknessInL0(), 0.0f); @@ -59,8 +61,9 @@ BOOST_AUTO_TEST_CASE(CombineSlabsVacuum) { BOOST_AUTO_TEST_CASE(CombineSlabsPercent) { auto slab = combineSlabs(percent, percent); // combining two identical slabs must give the same average material - BOOST_CHECK(slab.material()); - BOOST_CHECK_EQUAL(slab.material(), percent); + BOOST_CHECK(slab.isValid()); + BOOST_CHECK(slab.material().isValid()); + BOOST_CHECK_EQUAL(slab.material(), percent.material()); // thickness-like properties must double BOOST_CHECK_EQUAL(slab.thickness(), 2 * percent.thickness()); BOOST_CHECK_EQUAL(slab.thicknessInX0(), 2 * percent.thicknessInX0()); @@ -70,8 +73,9 @@ BOOST_AUTO_TEST_CASE(CombineSlabsPercent) { BOOST_AUTO_TEST_CASE(CombineSlabsUnit) { auto slab = combineSlabs(unit, unit); // combining two identical slabs must give the same average material - BOOST_CHECK(slab.material()); - BOOST_CHECK_EQUAL(slab.material(), unit); + BOOST_CHECK(slab.isValid()); + BOOST_CHECK(slab.material().isValid()); + BOOST_CHECK_EQUAL(slab.material(), unit.material()); // thickness-like properties must double BOOST_CHECK_EQUAL(slab.thickness(), 2 * unit.thickness()); BOOST_CHECK_EQUAL(slab.thicknessInX0(), 2 * unit.thicknessInX0()); @@ -83,8 +87,9 @@ BOOST_AUTO_TEST_CASE(CombineSlabsUnit) { BOOST_AUTO_TEST_CASE(CombineSlabsPercentZeroVacuum) { { auto slab = combineSlabs(percent, zeroVacuum); - BOOST_CHECK(slab.material()); - BOOST_CHECK_EQUAL(slab.material(), percent); + BOOST_CHECK(slab.isValid()); + BOOST_CHECK(slab.material().isValid()); + BOOST_CHECK_EQUAL(slab.material(), percent.material()); BOOST_CHECK_EQUAL(slab.thickness(), percent.thickness()); BOOST_CHECK_EQUAL(slab.thicknessInX0(), percent.thicknessInX0()); BOOST_CHECK_EQUAL(slab.thicknessInL0(), percent.thicknessInL0()); @@ -92,8 +97,9 @@ BOOST_AUTO_TEST_CASE(CombineSlabsPercentZeroVacuum) { // reverse input order { auto slab = combineSlabs(zeroVacuum, percent); - BOOST_CHECK(slab.material()); - BOOST_CHECK_EQUAL(slab.material(), percent); + BOOST_CHECK(slab.isValid()); + BOOST_CHECK(slab.material().isValid()); + BOOST_CHECK_EQUAL(slab.material(), percent.material()); BOOST_CHECK_EQUAL(slab.thickness(), percent.thickness()); BOOST_CHECK_EQUAL(slab.thicknessInX0(), percent.thicknessInX0()); BOOST_CHECK_EQUAL(slab.thicknessInL0(), percent.thicknessInL0()); @@ -103,8 +109,9 @@ BOOST_AUTO_TEST_CASE(CombineSlabsPercentZeroVacuum) { BOOST_AUTO_TEST_CASE(CombineSlabsUnitZeroVacuum) { { auto slab = combineSlabs(unit, zeroVacuum); - BOOST_CHECK(slab.material()); - BOOST_CHECK_EQUAL(slab.material(), unit); + BOOST_CHECK(slab.isValid()); + BOOST_CHECK(slab.material().isValid()); + BOOST_CHECK_EQUAL(slab.material(), unit.material()); BOOST_CHECK_EQUAL(slab.thickness(), unit.thickness()); BOOST_CHECK_EQUAL(slab.thicknessInX0(), unit.thicknessInX0()); BOOST_CHECK_EQUAL(slab.thicknessInL0(), unit.thicknessInL0()); @@ -112,8 +119,9 @@ BOOST_AUTO_TEST_CASE(CombineSlabsUnitZeroVacuum) { // reverse input order { auto slab = combineSlabs(zeroVacuum, unit); - BOOST_CHECK(slab.material()); - BOOST_CHECK_EQUAL(slab.material(), unit); + BOOST_CHECK(slab.isValid()); + BOOST_CHECK(slab.material().isValid()); + BOOST_CHECK_EQUAL(slab.material(), unit.material()); BOOST_CHECK_EQUAL(slab.thickness(), unit.thickness()); BOOST_CHECK_EQUAL(slab.thicknessInX0(), unit.thicknessInX0()); BOOST_CHECK_EQUAL(slab.thicknessInL0(), unit.thicknessInL0()); @@ -126,8 +134,9 @@ BOOST_AUTO_TEST_CASE(CombineSlabsPercentUnit) { // the two slabs have the same material -> average should be identical { auto slab = combineSlabs(percent, unit); - BOOST_CHECK(slab.material()); - BOOST_CHECK_EQUAL(slab.material(), percent); + BOOST_CHECK(slab.isValid()); + BOOST_CHECK(slab.material().isValid()); + BOOST_CHECK_EQUAL(slab.material(), percent.material()); BOOST_CHECK_EQUAL(slab.thickness(), percent.thickness() + unit.thickness()); BOOST_CHECK_EQUAL(slab.thicknessInX0(), percent.thicknessInX0() + unit.thicknessInX0()); @@ -137,8 +146,9 @@ BOOST_AUTO_TEST_CASE(CombineSlabsPercentUnit) { // reverse input order { auto slab = combineSlabs(unit, percent); - BOOST_CHECK(slab.material()); - BOOST_CHECK_EQUAL(slab.material(), unit); + BOOST_CHECK(slab.isValid()); + BOOST_CHECK(slab.material().isValid()); + BOOST_CHECK_EQUAL(slab.material(), unit.material()); BOOST_CHECK_EQUAL(slab.thickness(), unit.thickness() + percent.thickness()); BOOST_CHECK_EQUAL(slab.thicknessInX0(), percent.thicknessInX0() + unit.thicknessInX0()); @@ -153,8 +163,9 @@ BOOST_AUTO_TEST_CASE(CombineSlabsUnitZero) { // the two slabs have the same material -> average should be identical { auto slab = combineSlabs(unit, zero); - BOOST_CHECK(slab.material()); - BOOST_CHECK_EQUAL(slab.material(), unit); + BOOST_CHECK(slab.isValid()); + BOOST_CHECK(slab.material().isValid()); + BOOST_CHECK_EQUAL(slab.material(), unit.material()); BOOST_CHECK_EQUAL(slab.thickness(), unit.thickness()); BOOST_CHECK_EQUAL(slab.thicknessInX0(), unit.thicknessInX0()); BOOST_CHECK_EQUAL(slab.thicknessInL0(), unit.thicknessInL0()); @@ -162,8 +173,9 @@ BOOST_AUTO_TEST_CASE(CombineSlabsUnitZero) { // reverse input order { auto slab = combineSlabs(zero, unit); - BOOST_CHECK(slab.material()); - BOOST_CHECK_EQUAL(slab.material(), unit); + BOOST_CHECK(slab.isValid()); + BOOST_CHECK(slab.material().isValid()); + BOOST_CHECK_EQUAL(slab.material(), unit.material()); BOOST_CHECK_EQUAL(slab.thickness(), unit.thickness()); BOOST_CHECK_EQUAL(slab.thicknessInX0(), unit.thicknessInX0()); BOOST_CHECK_EQUAL(slab.thicknessInL0(), unit.thicknessInL0()); @@ -178,10 +190,11 @@ BOOST_AUTO_TEST_CASE(CombineSlabsEqualThicknessVacuum) { const auto slabVac = Acts::MaterialSlab(Acts::Material(), 1.0f); { auto slab = combineSlabs(slabMat, slabVac); + BOOST_CHECK(slab.isValid()); + BOOST_CHECK(slab.material().isValid()); BOOST_CHECK_EQUAL(slab.thickness(), 2.0f); BOOST_CHECK_EQUAL(slab.thicknessInX0(), slabMat.thicknessInX0()); BOOST_CHECK_EQUAL(slab.thicknessInL0(), slabMat.thicknessInL0()); - BOOST_CHECK(slab.material()); // atomic mass and nuclear charge are per atom, adding any amount vacuum // does not change the average atom properties only their density BOOST_CHECK_EQUAL(slab.material().Ar(), mat.Ar()); @@ -196,7 +209,8 @@ BOOST_AUTO_TEST_CASE(CombineSlabsEqualThicknessVacuum) { // reverse input order { auto slab = combineSlabs(slabVac, slabMat); - BOOST_CHECK(slab.material()); + BOOST_CHECK(slab.isValid()); + BOOST_CHECK(slab.material().isValid()); BOOST_CHECK_EQUAL(slab.thickness(), 2.0f); BOOST_CHECK_EQUAL(slab.thicknessInX0(), slabMat.thicknessInX0()); BOOST_CHECK_EQUAL(slab.thicknessInL0(), slabMat.thicknessInL0()); @@ -222,16 +236,21 @@ BOOST_AUTO_TEST_CASE(CombineSlabs) { const auto slabMat1 = Acts::MaterialSlab(mat1, 1.0f); // verify derived quantities for the input slabs. these tests are not really // needed, but to show the input values for the tests below. + BOOST_CHECK(slabMat0.isValid()); + BOOST_CHECK(slabMat0.material().isValid()); BOOST_CHECK_EQUAL(slabMat0.thickness(), 0.5f); BOOST_CHECK_EQUAL(slabMat0.thicknessInX0(), 0.5f); BOOST_CHECK_EQUAL(slabMat0.thicknessInL0(), 0.5f); + BOOST_CHECK(slabMat1.isValid()); + BOOST_CHECK(slabMat1.material().isValid()); BOOST_CHECK_EQUAL(slabMat1.thickness(), 1.0f); BOOST_CHECK_EQUAL(slabMat1.thicknessInX0(), 0.5f); BOOST_CHECK_EQUAL(slabMat1.thicknessInL0(), 0.5f); // check combined slabs { auto slab = combineSlabs(slabMat0, slabMat1); - BOOST_CHECK(slab.material()); + BOOST_CHECK(slab.isValid()); + BOOST_CHECK(slab.material().isValid()); BOOST_CHECK_EQUAL(slab.thickness(), 1.5f); BOOST_CHECK_EQUAL(slab.thicknessInX0(), 1.0f); BOOST_CHECK_EQUAL(slab.thicknessInL0(), 1.0f); @@ -246,7 +265,8 @@ BOOST_AUTO_TEST_CASE(CombineSlabs) { // reverse input order { auto slab = combineSlabs(slabMat0, slabMat1); - BOOST_CHECK(slab.material()); + BOOST_CHECK(slab.isValid()); + BOOST_CHECK(slab.material().isValid()); BOOST_CHECK_EQUAL(slab.thickness(), 1.5f); BOOST_CHECK_EQUAL(slab.thicknessInX0(), 1.0f); BOOST_CHECK_EQUAL(slab.thicknessInL0(), 1.0f); diff --git a/Tests/UnitTests/Core/Material/GridSurfaceMaterialTests.cpp b/Tests/UnitTests/Core/Material/GridSurfaceMaterialTests.cpp index 910f6c9960f..ed47cfcaf96 100644 --- a/Tests/UnitTests/Core/Material/GridSurfaceMaterialTests.cpp +++ b/Tests/UnitTests/Core/Material/GridSurfaceMaterialTests.cpp @@ -152,7 +152,7 @@ BOOST_AUTO_TEST_CASE(GridIndexedMaterial1D) { const Acts::MaterialSlab& mg4 = ism.materialSlab(g4); BOOST_CHECK_EQUAL(mg0.material().X0(), 1.); - BOOST_CHECK(!mg1.material()); + BOOST_CHECK(!mg1.material().isValid()); BOOST_CHECK_EQUAL(mg2.material().X0(), 11.); BOOST_CHECK_EQUAL(mg3.material().X0(), 11.); BOOST_CHECK_EQUAL(mg4.material().X0(), 21.); @@ -171,7 +171,7 @@ BOOST_AUTO_TEST_CASE(GridIndexedMaterial1D) { const Acts::MaterialSlab& ml4 = ism.materialSlab(l4); BOOST_CHECK_EQUAL(ml0.material().X0(), 1.); - BOOST_CHECK(!ml1.material()); + BOOST_CHECK(!ml1.material().isValid()); BOOST_CHECK_EQUAL(ml2.material().X0(), 11.); BOOST_CHECK_EQUAL(ml3.material().X0(), 11.); BOOST_CHECK_EQUAL(ml4.material().X0(), 21.); @@ -185,7 +185,7 @@ BOOST_AUTO_TEST_CASE(GridIndexedMaterial1D) { const Acts::MaterialSlab& sml4 = ism.materialSlab(l4); BOOST_CHECK_EQUAL(sml0.thickness(), 2.); - BOOST_CHECK(!sml1.material()); + BOOST_CHECK(!sml1.material().isValid()); BOOST_CHECK_EQUAL(sml2.thickness(), 4.); BOOST_CHECK_EQUAL(sml3.thickness(), 4.); BOOST_CHECK_EQUAL(sml4.thickness(), 6.); @@ -245,7 +245,7 @@ BOOST_AUTO_TEST_CASE(GridIndexedMaterial2D) { Acts::Vector3 g2(0.5, 0.5, -10.5); const Acts::MaterialSlab& mg2 = ism.materialSlab(g2); - BOOST_CHECK(!mg2.material()); // vacuum + BOOST_CHECK(!mg2.material().isValid()); // vacuum Acts::Vector3 g3(0.5, 0.5, -9.5); // should be material 3, same phi but different z @@ -306,7 +306,7 @@ BOOST_AUTO_TEST_CASE(GridGloballyIndexedMaterialNonShared) { const Acts::MaterialSlab& ml4 = ism.materialSlab(l4); BOOST_CHECK_EQUAL(ml0.material().X0(), 1.); - BOOST_CHECK(!ml1.material()); + BOOST_CHECK(!ml1.material().isValid()); BOOST_CHECK_EQUAL(ml2.material().X0(), 11.); BOOST_CHECK_EQUAL(ml3.material().X0(), 11.); BOOST_CHECK_EQUAL(ml4.material().X0(), 21.); diff --git a/Tests/UnitTests/Core/Material/InterpolatedMaterialMapTests.cpp b/Tests/UnitTests/Core/Material/InterpolatedMaterialMapTests.cpp index f75bd1e5176..60bdafc7062 100644 --- a/Tests/UnitTests/Core/Material/InterpolatedMaterialMapTests.cpp +++ b/Tests/UnitTests/Core/Material/InterpolatedMaterialMapTests.cpp @@ -1,6 +1,6 @@ // This file is part of the Acts project. // -// Copyright (C) 2019 CERN for the benefit of the Acts project +// Copyright (C) 2019-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 @@ -57,8 +57,7 @@ BOOST_AUTO_TEST_CASE(InterpolatedMaterialMap_MaterialCell_test) { BOOST_CHECK_EQUAL(materialCell.isInside(Vector3(0., 0., 2.)), true); // Test the getter - CHECK_CLOSE_REL(materialCell.getMaterial({0.5, 0.5, 0.5}), Material(mat), - 1e-4); + BOOST_CHECK_EQUAL(materialCell.getMaterial({0.5, 0.5, 0.5}), Material(mat)); } BOOST_AUTO_TEST_CASE(InterpolatedMaterialMap_MaterialMapper_test) { @@ -77,12 +76,12 @@ BOOST_AUTO_TEST_CASE(InterpolatedMaterialMap_MaterialMapper_test) { MaterialMapper matMap(trafoGlobalToLocal, grid); // Test Material getter - CHECK_CLOSE_REL(matMap.getMaterial({0.5, 0.5, 0.5}), Material(mat), 1e-4); + BOOST_CHECK_EQUAL(matMap.getMaterial({0.5, 0.5, 0.5}), Material(mat)); // Test the MaterialCell getter MaterialMapper::MaterialCell matCell = matMap.getMaterialCell({0.5, 0.5, 0.5}); - CHECK_CLOSE_REL(matCell.getMaterial({0.5, 0.5, 0.5}), Material(mat), 1e-4); + BOOST_CHECK_EQUAL(matCell.getMaterial({0.5, 0.5, 0.5}), Material(mat)); // Test the number of bins getter std::vector nBins = matMap.getNBins(); @@ -137,7 +136,7 @@ BOOST_AUTO_TEST_CASE(InterpolatedMaterialMap_test) { InterpolatedMaterialMap ipolMatMap(std::move(matMap)); // Test the material getter - CHECK_CLOSE_REL(ipolMatMap.material({0.5, 0.5, 0.5}), Material(mat), 1e-4); + BOOST_CHECK_EQUAL(ipolMatMap.material({0.5, 0.5, 0.5}), Material(mat)); // Test the material getter with a cache // Build a material cell @@ -151,8 +150,8 @@ BOOST_AUTO_TEST_CASE(InterpolatedMaterialMap_test) { InterpolatedMaterialMap>::Cache cache; cache.matCell = materialCell; cache.initialized = true; - CHECK_CLOSE_REL(ipolMatMap.getMaterial(Vector3(0.5, 0.5, 0.5), cache), - Material(mat), 1e-4); + BOOST_CHECK_EQUAL(ipolMatMap.getMaterial(Vector3(0.5, 0.5, 0.5), cache), + Material(mat)); // Test the inside check BOOST_CHECK_EQUAL(ipolMatMap.isInside(Vector3(1., 1., 1.)), true); diff --git a/Tests/UnitTests/Core/Material/MaterialTests.cpp b/Tests/UnitTests/Core/Material/MaterialTests.cpp index 2df7c8c6183..0f339c3733e 100644 --- a/Tests/UnitTests/Core/Material/MaterialTests.cpp +++ b/Tests/UnitTests/Core/Material/MaterialTests.cpp @@ -1,6 +1,6 @@ // This file is part of the Acts project. // -// Copyright (C) 2017-2018 CERN for the benefit of the Acts project +// Copyright (C) 2017-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 @@ -30,13 +30,13 @@ BOOST_AUTO_TEST_SUITE(Material) BOOST_AUTO_TEST_CASE(ConstructVacuum) { // default constructor builds invalid material a.k.a. vacuum Acts::Material vacuum; - BOOST_CHECK(!vacuum); + BOOST_CHECK(!vacuum.isValid()); } BOOST_AUTO_TEST_CASE(ConstructSomething) { // anything with non-zero Ar is a valid material auto notVacuum = Acts::Material::fromMolarDensity(1, 2, 3, 4, 5); - BOOST_CHECK(!!notVacuum); + BOOST_CHECK(notVacuum.isValid()); } BOOST_AUTO_TEST_CASE(Units) { diff --git a/Tests/UnitTests/Core/Material/VolumeMaterialMapperTests.cpp b/Tests/UnitTests/Core/Material/VolumeMaterialMapperTests.cpp index 98c10e33767..fca2ae2fd98 100644 --- a/Tests/UnitTests/Core/Material/VolumeMaterialMapperTests.cpp +++ b/Tests/UnitTests/Core/Material/VolumeMaterialMapperTests.cpp @@ -280,7 +280,8 @@ BOOST_AUTO_TEST_CASE(VolumeMaterialMapper_comparison_tests) { std::vector matvector; double gridX0 = 0., gridL0 = 0., trueX0 = 0., trueL0 = 0.; for (unsigned int i = 0; i < stepResult.position.size(); i++) { - matvector.push_back(matGrid.atPosition(stepResult.position[i])); + matvector.push_back( + Acts::Material{matGrid.atPosition(stepResult.position[i])}); gridX0 += 1 / matvector[i].X0(); gridL0 += 1 / matvector[i].L0(); trueX0 += 1 / stepResult.matTrue[i].X0(); diff --git a/Tests/UnitTests/Core/TrackFinding/TrackSelectorTests.cpp b/Tests/UnitTests/Core/TrackFinding/TrackSelectorTests.cpp index 7c7a265d4d4..dfdf33885ed 100644 --- a/Tests/UnitTests/Core/TrackFinding/TrackSelectorTests.cpp +++ b/Tests/UnitTests/Core/TrackFinding/TrackSelectorTests.cpp @@ -1,6 +1,6 @@ // This file is part of the Acts project. // -// Copyright (C) 2023 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 @@ -25,6 +25,11 @@ using namespace Acts; namespace bdata = boost::unit_test::data; struct MockTrack { + static constexpr bool ReadOnly = true; + using Container = VectorTrackContainer; + using Trajectory = VectorMultiTrajectory; + using IndexType = TrackIndexType; + double m_theta; double m_phi; double m_pt; diff --git a/docs/core/eventdata/tracks.md b/docs/core/eventdata/tracks.md index 4249af5a983..33662b6e397 100644 --- a/docs/core/eventdata/tracks.md +++ b/docs/core/eventdata/tracks.md @@ -442,7 +442,7 @@ std::cout << extraConst(track) << std::endl; // prints 42.2 For both const and mutable proxy accessors you do not actually need a mutable reference, as the internal accessor state is not mutated after construction. You can safely use a static instance of these accessors to avoid constructing them over and over again: ```cpp -template +template void doSomething(track_proxy_t track, float value) { // only created once, never changed static const Acts::ProxyAccessor extra("extra");