From 0f48e3b7bff28549de7a5f3566b98bd9cc2cf864 Mon Sep 17 00:00:00 2001 From: Andreas Stefl Date: Fri, 6 Sep 2024 11:49:12 +0200 Subject: [PATCH 01/12] refactor!: Remove deprecated API (#3591) Removes deprecated API - `PlaneSurface(const Vector3& center, const Vector3& normal);` is replaced by `CurvilinearSurface(const Vector3& center, const Vector3& normal).planeSurface()` - `Intersection::operator bool()` is replaced by `Intersection::isValid()` - `ObjectIntersection::operator bool()` is replaced by `ObjectIntersection::isValid()` - `Vertex::setPosition(const Vector3& position, ActsScalar time)` is removed and can be replaced by `setPosition` and `setTime` or `setFullPosition` --- .../MultiComponentTrackParameters.hpp | 2 +- Core/include/Acts/Surfaces/PlaneSurface.hpp | 9 ---- Core/include/Acts/Utilities/Intersection.hpp | 14 ------ Core/include/Acts/Vertexing/Vertex.hpp | 9 ---- Core/src/Surfaces/PlaneSurface.cpp | 6 --- Core/src/Vertexing/Vertex.cpp | 5 -- .../EventData/BoundTrackParametersTests.cpp | 6 +-- .../CorrectedTransformFreeToBoundTests.cpp | 5 +- ...ultiComponentBoundTrackParametersTests.cpp | 11 ++-- .../EventData/TrackParametersDatasets.hpp | 7 +-- .../Core/EventData/TrackTestsExtra.cpp | 6 ++- .../Core/Propagator/AtlasStepperTests.cpp | 9 ++-- .../Core/Propagator/CovarianceEngineTests.cpp | 2 +- .../Core/Propagator/EigenStepperTests.cpp | 5 +- .../Core/Propagator/JacobianEngineTests.cpp | 8 +-- .../Core/Propagator/JacobianTests.cpp | 3 +- .../Core/Propagator/MultiStepperTests.cpp | 50 +++++++++++-------- .../Core/Propagator/PropagatorTests.cpp | 8 +-- .../Propagator/StraightLineStepperTests.cpp | 5 +- .../Core/Propagator/SympyStepperTests.cpp | 5 +- .../Core/Surfaces/CylinderSurfaceTests.cpp | 4 +- .../Surfaces/IntersectionHelper2DTests.cpp | 16 +++--- .../Core/Surfaces/LineSurfaceTests.cpp | 3 +- .../Core/Surfaces/PlaneSurfaceTests.cpp | 2 +- .../Surfaces/SurfaceIntersectionTests.cpp | 34 ++++++------- .../SurfaceLocalToGlobalRoundtripTests.cpp | 7 +-- .../CombinatorialKalmanFilterTests.cpp | 11 ++-- .../Core/TrackFinding/TrackSelectorTests.cpp | 5 +- .../Core/TrackFitting/FitterTestsCommon.hpp | 5 +- .../TrackFitting/GsfComponentMergingTests.cpp | 3 +- .../TrackFitting/GsfMixtureReductionTests.cpp | 9 ++-- .../UnitTests/Core/TrackFitting/GsfTests.cpp | 4 +- .../Core/Utilities/IntersectionTests.cpp | 21 ++++---- .../Fatras/Digitization/ChannelizerTests.cpp | 6 ++- .../Digitization/PlanarSurfaceDriftTests.cpp | 3 +- .../Fatras/Kernel/SimulationActorTests.cpp | 6 ++- .../EDM4hep/ConvertTrackEDM4hepTest.cpp | 11 ++-- .../Plugins/Json/PortalJsonConverterTests.cpp | 16 +++--- 38 files changed, 172 insertions(+), 169 deletions(-) diff --git a/Core/include/Acts/EventData/MultiComponentTrackParameters.hpp b/Core/include/Acts/EventData/MultiComponentTrackParameters.hpp index dd3496910f7..749435066de 100644 --- a/Core/include/Acts/EventData/MultiComponentTrackParameters.hpp +++ b/Core/include/Acts/EventData/MultiComponentTrackParameters.hpp @@ -262,7 +262,7 @@ class MultiComponentCurvilinearTrackParameters avgDir += w * dir; } - auto s = Surface::makeShared(avgPos, avgDir); + auto s = CurvilinearSurface(avgPos, avgDir).planeSurface(); std::vector> bound; bound.reserve(curvi.size()); diff --git a/Core/include/Acts/Surfaces/PlaneSurface.hpp b/Core/include/Acts/Surfaces/PlaneSurface.hpp index bbfa1374362..da15e3bd794 100644 --- a/Core/include/Acts/Surfaces/PlaneSurface.hpp +++ b/Core/include/Acts/Surfaces/PlaneSurface.hpp @@ -58,15 +58,6 @@ class PlaneSurface : public RegularSurface { PlaneSurface(const GeometryContext& gctx, const PlaneSurface& other, const Transform3& transform); - /// @deprecated Use `CurvilinearSurface` instead - /// - /// Dedicated Constructor with normal vector - /// This is for curvilinear surfaces which are by definition boundless - /// - /// @param center is the center position of the surface - /// @param normal is thenormal vector of the plane surface - PlaneSurface(const Vector3& center, const Vector3& normal); - /// Constructor from DetectorElementBase : Element proxy /// /// @param pbounds are the provided planar bounds diff --git a/Core/include/Acts/Utilities/Intersection.hpp b/Core/include/Acts/Utilities/Intersection.hpp index 30b986f6d24..03cce17ffb9 100644 --- a/Core/include/Acts/Utilities/Intersection.hpp +++ b/Core/include/Acts/Utilities/Intersection.hpp @@ -59,13 +59,6 @@ class Intersection { Status status) : m_position(position), m_pathLength(pathLength), m_status(status) {} - /// Returns whether the intersection was successful or not - /// @deprecated - [[deprecated("Use isValid() instead")]] constexpr explicit operator bool() - const { - return isValid(); - } - /// Returns whether the intersection was successful or not constexpr bool isValid() const { return m_status != Status::missed; } @@ -149,13 +142,6 @@ class ObjectIntersection { const object_t* object, std::uint8_t index = 0) : m_intersection(intersection), m_object(object), m_index(index) {} - /// Returns whether the intersection was successful or not - /// @deprecated - [[deprecated("Use isValid() instead")]] constexpr explicit operator bool() - const { - return isValid(); - } - /// Returns whether the intersection was successful or not constexpr bool isValid() const { return m_intersection.isValid(); } diff --git a/Core/include/Acts/Vertexing/Vertex.hpp b/Core/include/Acts/Vertexing/Vertex.hpp index 1ce6e0ae7c5..10fbf6a2df0 100644 --- a/Core/include/Acts/Vertexing/Vertex.hpp +++ b/Core/include/Acts/Vertexing/Vertex.hpp @@ -78,15 +78,6 @@ class Vertex { /// @param position Vertex position void setPosition(const Vector3& position); - /// @brief Set position and time - /// - /// @deprecated Use setFullPosition instead - /// - /// @param position Vertex position - /// @param time The time - [[deprecated("Use setFullPosition instead")]] void setPosition( - const Vector3& position, ActsScalar time); - /// @brief Set position and time /// /// @param fullPosition Vertex position and time diff --git a/Core/src/Surfaces/PlaneSurface.cpp b/Core/src/Surfaces/PlaneSurface.cpp index e8b0e90a76f..f3bf814e97e 100644 --- a/Core/src/Surfaces/PlaneSurface.cpp +++ b/Core/src/Surfaces/PlaneSurface.cpp @@ -37,12 +37,6 @@ Acts::PlaneSurface::PlaneSurface(const GeometryContext& gctx, RegularSurface(gctx, other, transform), m_bounds(other.m_bounds) {} -Acts::PlaneSurface::PlaneSurface(const Vector3& center, const Vector3& normal) - : RegularSurface(), m_bounds(nullptr) { - m_transform = std::make_unique( - CurvilinearSurface(center, normal).transform()); -} - Acts::PlaneSurface::PlaneSurface(std::shared_ptr pbounds, const Acts::DetectorElementBase& detelement) : RegularSurface(detelement), m_bounds(std::move(pbounds)) { diff --git a/Core/src/Vertexing/Vertex.cpp b/Core/src/Vertexing/Vertex.cpp index f8373ba774a..6d1fa9bf902 100644 --- a/Core/src/Vertexing/Vertex.cpp +++ b/Core/src/Vertexing/Vertex.cpp @@ -81,11 +81,6 @@ void Vertex::setPosition(const Vector3& position) { m_position.head<3>() = position; } -void Vertex::setPosition(const Vector3& position, ActsScalar time) { - m_position.head<3>() = position; - m_position[eTime] = time; -} - void Vertex::setFullPosition(const Vector4& fullPosition) { m_position = fullPosition; } diff --git a/Tests/UnitTests/Core/EventData/BoundTrackParametersTests.cpp b/Tests/UnitTests/Core/EventData/BoundTrackParametersTests.cpp index 4410679256e..5e79730056b 100644 --- a/Tests/UnitTests/Core/EventData/BoundTrackParametersTests.cpp +++ b/Tests/UnitTests/Core/EventData/BoundTrackParametersTests.cpp @@ -252,9 +252,9 @@ const auto perigees = bdata::make({ Surface::makeShared(Vector3(0, 0, -1.5)), }); const auto planes = bdata::make({ - Surface::makeShared(Vector3(1, 2, 3), Vector3::UnitX()), - Surface::makeShared(Vector3(-2, -3, -4), Vector3::UnitY()), - Surface::makeShared(Vector3(3, -4, 5), Vector3::UnitZ()), + CurvilinearSurface(Vector3(1, 2, 3), Vector3::UnitX()).planeSurface(), + CurvilinearSurface(Vector3(-2, -3, -4), Vector3::UnitY()).planeSurface(), + CurvilinearSurface(Vector3(3, -4, 5), Vector3::UnitZ()).planeSurface(), }); const auto straws = bdata::make({ Surface::makeShared(Transform3::Identity(), 2.0 /* radius */, diff --git a/Tests/UnitTests/Core/EventData/CorrectedTransformFreeToBoundTests.cpp b/Tests/UnitTests/Core/EventData/CorrectedTransformFreeToBoundTests.cpp index 0697c965bb2..c5eca8fca6c 100644 --- a/Tests/UnitTests/Core/EventData/CorrectedTransformFreeToBoundTests.cpp +++ b/Tests/UnitTests/Core/EventData/CorrectedTransformFreeToBoundTests.cpp @@ -14,6 +14,7 @@ #include "Acts/EventData/detail/CorrectedTransformationFreeToBound.hpp" #include "Acts/Geometry/GeometryContext.hpp" #include "Acts/Surfaces/BoundaryTolerance.hpp" +#include "Acts/Surfaces/CurvilinearSurface.hpp" #include "Acts/Surfaces/PlaneSurface.hpp" #include "Acts/Surfaces/Surface.hpp" #include "Acts/Tests/CommonHelpers/FloatComparisons.hpp" @@ -54,8 +55,8 @@ BOOST_AUTO_TEST_CASE(CorrectedFreeToBoundTrackParameters) { // construct two parallel plane surfaces with normal in x direction ActsScalar distance = 10_mm; - auto eSurface = Surface::makeShared(Vector3(distance, 0, 0), - Vector3::UnitX()); + auto eSurface = CurvilinearSurface(Vector3(distance, 0, 0), Vector3::UnitX()) + .planeSurface(); // the bound parameters at the starting plane BoundVector sBoundParams = BoundVector::Zero(); diff --git a/Tests/UnitTests/Core/EventData/MultiComponentBoundTrackParametersTests.cpp b/Tests/UnitTests/Core/EventData/MultiComponentBoundTrackParametersTests.cpp index 29f90c2a6de..62425e23c03 100644 --- a/Tests/UnitTests/Core/EventData/MultiComponentBoundTrackParametersTests.cpp +++ b/Tests/UnitTests/Core/EventData/MultiComponentBoundTrackParametersTests.cpp @@ -14,6 +14,7 @@ #include "Acts/EventData/GenericBoundTrackParameters.hpp" #include "Acts/EventData/ParticleHypothesis.hpp" #include "Acts/Geometry/GeometryContext.hpp" +#include "Acts/Surfaces/CurvilinearSurface.hpp" #include "Acts/Surfaces/Surface.hpp" #include #include @@ -38,8 +39,9 @@ BOOST_AUTO_TEST_CASE(test_constructors) { b; b.push_back({1.0, BoundVector::Ones(), BoundSquareMatrix::Identity()}); - auto surface = Acts::Surface::makeShared( - Vector3::Ones(), Vector3::Ones().normalized()); + auto surface = + CurvilinearSurface(Vector3::Ones(), Vector3::Ones().normalized()) + .planeSurface(); const auto ap = MultiComponentBoundTrackParameters(surface, a, particleHypothesis); @@ -62,8 +64,9 @@ BOOST_AUTO_TEST_CASE(test_accessors) { using cov_t = std::optional; for (const auto &cov : {cov_t{}, cov_t{BoundSquareMatrix::Identity()}, cov_t{BoundSquareMatrix::Identity()}}) { - auto surface = Acts::Surface::makeShared( - Vector3::Ones(), Vector3::Ones().normalized()); + auto surface = + CurvilinearSurface(Vector3::Ones(), Vector3::Ones().normalized()) + .planeSurface(); const BoundTrackParameters single_pars(surface, BoundVector::Ones(), cov, particleHypothesis); diff --git a/Tests/UnitTests/Core/EventData/TrackParametersDatasets.hpp b/Tests/UnitTests/Core/EventData/TrackParametersDatasets.hpp index d7781058557..05e256fd434 100644 --- a/Tests/UnitTests/Core/EventData/TrackParametersDatasets.hpp +++ b/Tests/UnitTests/Core/EventData/TrackParametersDatasets.hpp @@ -11,6 +11,7 @@ #include #include "Acts/Definitions/Units.hpp" +#include "Acts/Surfaces/CurvilinearSurface.hpp" #include "Acts/Surfaces/CylinderSurface.hpp" #include "Acts/Surfaces/DiscSurface.hpp" #include "Acts/Surfaces/PerigeeSurface.hpp" @@ -34,9 +35,9 @@ const auto surfaces = Transform3::Identity(), 10 /* radius */, 100 /* half-length z */), // TODO perigee roundtrip local->global->local does not seem to work // Surface::makeShared(Vector3(0, 0, -1.5)), - Surface::makeShared(Vector3::Zero(), Vector3::UnitX()), - Surface::makeShared(Vector3::Zero(), Vector3::UnitY()), - Surface::makeShared(Vector3::Zero(), Vector3::UnitZ()), + CurvilinearSurface(Vector3::Zero(), Vector3::UnitX()).planeSurface(), + CurvilinearSurface(Vector3::Zero(), Vector3::UnitY()).planeSurface(), + CurvilinearSurface(Vector3::Zero(), Vector3::UnitZ()).planeSurface(), }); // positions const auto posAngle = bdata::xrange(-M_PI, M_PI, 0.50); diff --git a/Tests/UnitTests/Core/EventData/TrackTestsExtra.cpp b/Tests/UnitTests/Core/EventData/TrackTestsExtra.cpp index 811c3cd3770..2f7df54f055 100644 --- a/Tests/UnitTests/Core/EventData/TrackTestsExtra.cpp +++ b/Tests/UnitTests/Core/EventData/TrackTestsExtra.cpp @@ -12,6 +12,7 @@ #include "Acts/EventData/ProxyAccessor.hpp" #include "Acts/EventData/VectorMultiTrajectory.hpp" #include "Acts/EventData/VectorTrackContainer.hpp" +#include "Acts/Surfaces/CurvilinearSurface.hpp" #include "Acts/Surfaces/PlaneSurface.hpp" #include "Acts/Utilities/Zip.hpp" @@ -216,8 +217,9 @@ BOOST_AUTO_TEST_CASE_TEMPLATE(Build, factory_t, holder_types) { t.covariance() = cov; BOOST_CHECK_EQUAL(t.covariance(), cov); - auto surface = Acts::Surface::makeShared( - Acts::Vector3{-3_m, 0., 0.}, Acts::Vector3{1., 0., 0}); + auto surface = + CurvilinearSurface(Acts::Vector3{-3_m, 0., 0.}, Acts::Vector3{1., 0., 0}) + .planeSurface(); t.setReferenceSurface(surface); BOOST_CHECK_EQUAL(surface.get(), &t.referenceSurface()); diff --git a/Tests/UnitTests/Core/Propagator/AtlasStepperTests.cpp b/Tests/UnitTests/Core/Propagator/AtlasStepperTests.cpp index 90860e0cc44..72f00bcdc9d 100644 --- a/Tests/UnitTests/Core/Propagator/AtlasStepperTests.cpp +++ b/Tests/UnitTests/Core/Propagator/AtlasStepperTests.cpp @@ -27,6 +27,7 @@ #include "Acts/Propagator/AtlasStepper.hpp" #include "Acts/Propagator/ConstrainedStep.hpp" #include "Acts/Surfaces/BoundaryTolerance.hpp" +#include "Acts/Surfaces/CurvilinearSurface.hpp" #include "Acts/Surfaces/DiscSurface.hpp" #include "Acts/Surfaces/PerigeeSurface.hpp" #include "Acts/Surfaces/PlaneSurface.hpp" @@ -183,7 +184,7 @@ BOOST_AUTO_TEST_CASE(UpdateFromBound) { auto newAbsMom = 0.9 * absMom; // example surface and bound parameters at the updated position - auto plane = Surface::makeShared(newPos, newUnitDir); + auto plane = CurvilinearSurface(newPos, newUnitDir).planeSurface(); auto params = BoundTrackParameters::create(plane, geoCtx, newPos4, newUnitDir, charge / absMom, cov, particleHypothesis) @@ -242,7 +243,7 @@ BOOST_AUTO_TEST_CASE(BuildBound) { particleHypothesis), stepSize, tolerance); // example surface at the current state position - auto plane = Surface::makeShared(pos, unitDir); + auto plane = CurvilinearSurface(pos, unitDir).planeSurface(); auto&& [pars, jac, pathLength] = stepper.boundState(state, *plane).value(); // check parameters @@ -578,8 +579,8 @@ BOOST_AUTO_TEST_CASE(StepSizeSurface) { stepSize, tolerance); auto distance = 10_mm; - auto target = Surface::makeShared( - pos + navDir * distance * unitDir, unitDir); + auto target = CurvilinearSurface(pos + navDir * distance * unitDir, unitDir) + .planeSurface(); stepper.updateSurfaceStatus(state, *target, 0, navDir, BoundaryTolerance::Infinite()); diff --git a/Tests/UnitTests/Core/Propagator/CovarianceEngineTests.cpp b/Tests/UnitTests/Core/Propagator/CovarianceEngineTests.cpp index b8fd2280852..d914374ac23 100644 --- a/Tests/UnitTests/Core/Propagator/CovarianceEngineTests.cpp +++ b/Tests/UnitTests/Core/Propagator/CovarianceEngineTests.cpp @@ -97,7 +97,7 @@ BOOST_AUTO_TEST_CASE(covariance_engine_test) { // Repeat transport to surface FreeToBoundCorrection freeToBoundCorrection(false); - auto surface = Surface::makeShared(position, direction); + auto surface = CurvilinearSurface(position, direction).planeSurface(); detail::transportCovarianceToBound( tgContext, *surface, covariance, jacobian, transportJacobian, derivatives, boundToFreeJacobian, parameters, freeToBoundCorrection); diff --git a/Tests/UnitTests/Core/Propagator/EigenStepperTests.cpp b/Tests/UnitTests/Core/Propagator/EigenStepperTests.cpp index dbf6b7b8ad4..1fb907d25e8 100644 --- a/Tests/UnitTests/Core/Propagator/EigenStepperTests.cpp +++ b/Tests/UnitTests/Core/Propagator/EigenStepperTests.cpp @@ -44,6 +44,7 @@ #include "Acts/Propagator/StepperExtensionList.hpp" #include "Acts/Propagator/detail/Auctioneer.hpp" #include "Acts/Surfaces/BoundaryTolerance.hpp" +#include "Acts/Surfaces/CurvilinearSurface.hpp" #include "Acts/Surfaces/PlaneSurface.hpp" #include "Acts/Surfaces/RectangleBounds.hpp" #include "Acts/Surfaces/Surface.hpp" @@ -448,7 +449,7 @@ BOOST_AUTO_TEST_CASE(eigen_stepper_test) { BOOST_CHECK_EQUAL(esStateCopy.previousStepSize, ps.stepping.previousStepSize); /// Repeat with surface related methods - auto plane = Surface::makeShared(pos, dir.normalized()); + auto plane = CurvilinearSurface(pos, dir.normalized()).planeSurface(); auto bp = BoundTrackParameters::create( plane, tgContext, makeVector4(pos, time), dir, charge / absMom, cov, ParticleHypothesis::pion()) @@ -458,7 +459,7 @@ BOOST_AUTO_TEST_CASE(eigen_stepper_test) { // Test the intersection in the context of a surface auto targetSurface = - Surface::makeShared(pos + navDir * 2. * dir, dir); + CurvilinearSurface(pos + navDir * 2. * dir, dir).planeSurface(); es.updateSurfaceStatus(esState, *targetSurface, 0, navDir, BoundaryTolerance::Infinite()); CHECK_CLOSE_ABS(esState.stepSize.value(ConstrainedStep::actor), navDir * 2., diff --git a/Tests/UnitTests/Core/Propagator/JacobianEngineTests.cpp b/Tests/UnitTests/Core/Propagator/JacobianEngineTests.cpp index 6371c03afd5..899caf97277 100644 --- a/Tests/UnitTests/Core/Propagator/JacobianEngineTests.cpp +++ b/Tests/UnitTests/Core/Propagator/JacobianEngineTests.cpp @@ -33,11 +33,11 @@ BOOST_AUTO_TEST_CASE(jacobian_engine_to_bound) { double qop = 0.125; // Build a surface - auto pSurface = Surface::makeShared(position, direction); + auto pSurface = CurvilinearSurface(position, direction).planeSurface(); // Other rotated surface Vector3 odirection = Vector3(6., 2., 8.).normalized(); - auto oSurface = Surface::makeShared(position, odirection); + auto oSurface = CurvilinearSurface(position, odirection).planeSurface(); // The free parameter vector FreeVector freeParameters; @@ -108,7 +108,7 @@ BOOST_AUTO_TEST_CASE(jacobian_engine_to_curvilinear) { Vector3 direction = Vector3(5., 2., 7.).normalized(); // Build a surface, starting surface for curvilinear - auto pSurface = Surface::makeShared(position, direction); + auto pSurface = CurvilinearSurface(position, direction).planeSurface(); // Build covariance matrices for bound and free case BoundSquareMatrix boundCovariance = 0.025 * BoundSquareMatrix::Identity(); @@ -160,7 +160,7 @@ BOOST_AUTO_TEST_CASE(jacobian_engine_to_free) { Vector3 direction = Vector3(5., 2., 7.).normalized(); // Build a surface, starting surface for curvilinear - auto pSurface = Surface::makeShared(position, direction); + auto pSurface = CurvilinearSurface(position, direction).planeSurface(); // Build covariance matrices for bound and free case BoundSquareMatrix boundCovariance = 0.025 * BoundSquareMatrix::Identity(); diff --git a/Tests/UnitTests/Core/Propagator/JacobianTests.cpp b/Tests/UnitTests/Core/Propagator/JacobianTests.cpp index c58bab9ee69..9d43d22dbd1 100644 --- a/Tests/UnitTests/Core/Propagator/JacobianTests.cpp +++ b/Tests/UnitTests/Core/Propagator/JacobianTests.cpp @@ -18,6 +18,7 @@ #include "Acts/MagneticField/MagneticFieldContext.hpp" #include "Acts/Propagator/AtlasStepper.hpp" #include "Acts/Propagator/EigenStepper.hpp" +#include "Acts/Surfaces/CurvilinearSurface.hpp" #include "Acts/Surfaces/CylinderSurface.hpp" #include "Acts/Surfaces/DiscSurface.hpp" #include "Acts/Surfaces/PerigeeSurface.hpp" @@ -209,7 +210,7 @@ BOOST_AUTO_TEST_CASE(JacobianPlaneToGlobalTest) { Vector3 sNormal = Vector3(1.2, -0.3, 0.05).normalized(); // Create a surface & parameters with covariance on the surface - auto pSurface = Surface::makeShared(sPosition, sNormal); + auto pSurface = CurvilinearSurface(sPosition, sNormal).planeSurface(); Covariance cov; cov << 10_mm, 0, 0, 0, 0, 0, 0, 10_mm, 0, 0, 0, 0, 0, 0, 0.1, 0, 0, 0, 0, 0, diff --git a/Tests/UnitTests/Core/Propagator/MultiStepperTests.cpp b/Tests/UnitTests/Core/Propagator/MultiStepperTests.cpp index 0d1638b43b4..2005e954e21 100644 --- a/Tests/UnitTests/Core/Propagator/MultiStepperTests.cpp +++ b/Tests/UnitTests/Core/Propagator/MultiStepperTests.cpp @@ -26,6 +26,7 @@ #include "Acts/Propagator/Navigator.hpp" #include "Acts/Propagator/Propagator.hpp" #include "Acts/Propagator/StepperExtensionList.hpp" +#include "Acts/Surfaces/CurvilinearSurface.hpp" #include "Acts/Surfaces/PlaneSurface.hpp" #include "Acts/Surfaces/Surface.hpp" #include "Acts/Utilities/Helpers.hpp" @@ -131,8 +132,8 @@ auto makeDefaultBoundPars(bool cov = true, std::size_t n = 4, cov ? Opt{make_random_sym_matrix()} : Opt{}}); } - auto surface = Acts::Surface::makeShared( - Vector3::Zero(), Vector3{1., 0., 0.}); + auto surface = Acts::CurvilinearSurface(Vector3::Zero(), Vector3{1., 0., 0.}) + .planeSurface(); return MultiComponentBoundTrackParameters(surface, cmps, particleHypothesis); } @@ -295,8 +296,9 @@ void test_multi_stepper_vs_eigen_stepper() { std::vector>> cmps(4, {0.25, pars, cov}); - auto surface = Acts::Surface::makeShared( - Vector3::Zero(), Vector3::Ones().normalized()); + auto surface = + Acts::CurvilinearSurface(Vector3::Zero(), Vector3::Ones().normalized()) + .planeSurface(); MultiComponentBoundTrackParameters multi_pars(surface, cmps, particleHypothesis); @@ -445,11 +447,13 @@ void test_multi_stepper_surface_status_update() { using MultiState = typename multi_stepper_t::State; using MultiStepper = multi_stepper_t; - auto start_surface = Acts::Surface::makeShared( - Vector3::Zero(), Vector3{1.0, 0.0, 0.0}); + auto start_surface = + Acts::CurvilinearSurface(Vector3::Zero(), Vector3{1.0, 0.0, 0.0}) + .planeSurface(); - auto right_surface = Acts::Surface::makeShared( - Vector3{1.0, 0.0, 0.0}, Vector3{1.0, 0.0, 0.0}); + auto right_surface = + Acts::CurvilinearSurface(Vector3{1.0, 0.0, 0.0}, Vector3{1.0, 0.0, 0.0}) + .planeSurface(); std::vector>> cmps(2, {0.5, BoundVector::Zero(), std::nullopt}); @@ -554,11 +558,13 @@ void test_component_bound_state() { using MultiState = typename multi_stepper_t::State; using MultiStepper = multi_stepper_t; - auto start_surface = Acts::Surface::makeShared( - Vector3::Zero(), Vector3{1.0, 0.0, 0.0}); + auto start_surface = + Acts::CurvilinearSurface(Vector3::Zero(), Vector3{1.0, 0.0, 0.0}) + .planeSurface(); - auto right_surface = Acts::Surface::makeShared( - Vector3{1.0, 0.0, 0.0}, Vector3{1.0, 0.0, 0.0}); + auto right_surface = + Acts::CurvilinearSurface(Vector3{1.0, 0.0, 0.0}, Vector3{1.0, 0.0, 0.0}) + .planeSurface(); std::vector>> cmps(2, {0.5, BoundVector::Zero(), std::nullopt}); @@ -632,8 +638,9 @@ void test_combined_bound_state_function() { using MultiState = typename multi_stepper_t::State; using MultiStepper = multi_stepper_t; - auto surface = Acts::Surface::makeShared( - Vector3::Zero(), Vector3{1.0, 0.0, 0.0}); + auto surface = + Acts::CurvilinearSurface(Vector3::Zero(), Vector3{1.0, 0.0, 0.0}) + .planeSurface(); // Use Ones() here, so that the angles are in correct range const auto pars = BoundVector::Ones().eval(); @@ -677,8 +684,9 @@ void test_combined_curvilinear_state_function() { using MultiState = typename multi_stepper_t::State; using MultiStepper = multi_stepper_t; - auto surface = Acts::Surface::makeShared( - Vector3::Zero(), Vector3{1.0, 0.0, 0.0}); + auto surface = + Acts::CurvilinearSurface(Vector3::Zero(), Vector3{1.0, 0.0, 0.0}) + .planeSurface(); // Use Ones() here, so that the angles are in correct range const auto pars = BoundVector::Ones().eval(); @@ -729,8 +737,9 @@ void test_single_component_interface_function() { cmps.push_back({0.25, BoundVector::Random(), BoundSquareMatrix::Random()}); } - auto surface = Acts::Surface::makeShared( - Vector3::Zero(), Vector3::Ones().normalized()); + auto surface = + Acts::CurvilinearSurface(Vector3::Zero(), Vector3::Ones().normalized()) + .planeSurface(); MultiComponentBoundTrackParameters multi_pars(surface, cmps, particleHypothesis); @@ -815,8 +824,9 @@ void propagator_instatiation_test_function() { Propagator propagator( std::move(multi_stepper), Navigator{Navigator::Config{}}); - auto surface = Acts::Surface::makeShared( - Vector3::Zero(), Vector3{1.0, 0.0, 0.0}); + auto surface = + Acts::CurvilinearSurface(Vector3::Zero(), Vector3{1.0, 0.0, 0.0}) + .planeSurface(); using PropagatorOptions = typename Propagator::template Options<>; PropagatorOptions options(geoCtx, magCtx); diff --git a/Tests/UnitTests/Core/Propagator/PropagatorTests.cpp b/Tests/UnitTests/Core/Propagator/PropagatorTests.cpp index dad3439cba7..01d02be6e3c 100644 --- a/Tests/UnitTests/Core/Propagator/PropagatorTests.cpp +++ b/Tests/UnitTests/Core/Propagator/PropagatorTests.cpp @@ -30,6 +30,7 @@ #include "Acts/Propagator/StandardAborters.hpp" #include "Acts/Propagator/StepperExtensionList.hpp" #include "Acts/Propagator/StraightLineStepper.hpp" +#include "Acts/Surfaces/CurvilinearSurface.hpp" #include "Acts/Surfaces/CylinderBounds.hpp" #include "Acts/Surfaces/CylinderSurface.hpp" #include "Acts/Surfaces/PlaneSurface.hpp" @@ -396,9 +397,10 @@ BOOST_AUTO_TEST_CASE(BasicPropagatorInterface) { VoidNavigator navigator{}; auto startSurface = - Surface::makeShared(Vector3::Zero(), Vector3::UnitX()); - auto targetSurface = Surface::makeShared( - Vector3::UnitX() * 20_mm, Vector3::UnitX()); + CurvilinearSurface(Vector3::Zero(), Vector3::UnitX()).planeSurface(); + auto targetSurface = + CurvilinearSurface(Vector3::UnitX() * 20_mm, Vector3::UnitX()) + .planeSurface(); BoundVector startPars; startPars << 0, 0, 0, M_PI / 2, 1 / 1_GeV, 0; diff --git a/Tests/UnitTests/Core/Propagator/StraightLineStepperTests.cpp b/Tests/UnitTests/Core/Propagator/StraightLineStepperTests.cpp index bbb9cb9b83a..527c727146f 100644 --- a/Tests/UnitTests/Core/Propagator/StraightLineStepperTests.cpp +++ b/Tests/UnitTests/Core/Propagator/StraightLineStepperTests.cpp @@ -22,6 +22,7 @@ #include "Acts/Propagator/ConstrainedStep.hpp" #include "Acts/Propagator/StraightLineStepper.hpp" #include "Acts/Surfaces/BoundaryTolerance.hpp" +#include "Acts/Surfaces/CurvilinearSurface.hpp" #include "Acts/Surfaces/PlaneSurface.hpp" #include "Acts/Surfaces/Surface.hpp" #include "Acts/Tests/CommonHelpers/FloatComparisons.hpp" @@ -319,7 +320,7 @@ BOOST_AUTO_TEST_CASE(straight_line_stepper_test) { BOOST_CHECK_EQUAL(slsStateCopy.tolerance, ps.stepping.tolerance); /// Repeat with surface related methods - auto plane = Surface::makeShared(pos, dir); + auto plane = CurvilinearSurface(pos, dir).planeSurface(); auto bp = BoundTrackParameters::create( plane, tgContext, makeVector4(pos, time), dir, charge / absMom, cov, ParticleHypothesis::pion()) @@ -329,7 +330,7 @@ BOOST_AUTO_TEST_CASE(straight_line_stepper_test) { // Test the intersection in the context of a surface auto targetSurface = - Surface::makeShared(pos + navDir * 2. * dir, dir); + CurvilinearSurface(pos + navDir * 2. * dir, dir).planeSurface(); sls.updateSurfaceStatus(slsState, *targetSurface, 0, navDir, BoundaryTolerance::Infinite()); CHECK_CLOSE_ABS(slsState.stepSize.value(ConstrainedStep::actor), navDir * 2., diff --git a/Tests/UnitTests/Core/Propagator/SympyStepperTests.cpp b/Tests/UnitTests/Core/Propagator/SympyStepperTests.cpp index 1ea875e5735..676246bce15 100644 --- a/Tests/UnitTests/Core/Propagator/SympyStepperTests.cpp +++ b/Tests/UnitTests/Core/Propagator/SympyStepperTests.cpp @@ -43,6 +43,7 @@ #include "Acts/Propagator/SympyStepper.hpp" #include "Acts/Propagator/detail/Auctioneer.hpp" #include "Acts/Surfaces/BoundaryTolerance.hpp" +#include "Acts/Surfaces/CurvilinearSurface.hpp" #include "Acts/Surfaces/PlaneSurface.hpp" #include "Acts/Surfaces/RectangleBounds.hpp" #include "Acts/Surfaces/Surface.hpp" @@ -445,7 +446,7 @@ BOOST_AUTO_TEST_CASE(sympy_stepper_test) { BOOST_CHECK_EQUAL(esStateCopy.previousStepSize, ps.stepping.previousStepSize); /// Repeat with surface related methods - auto plane = Surface::makeShared(pos, dir.normalized()); + auto plane = CurvilinearSurface(pos, dir.normalized()).planeSurface(); auto bp = BoundTrackParameters::create( plane, tgContext, makeVector4(pos, time), dir, charge / absMom, cov, ParticleHypothesis::pion()) @@ -455,7 +456,7 @@ BOOST_AUTO_TEST_CASE(sympy_stepper_test) { // Test the intersection in the context of a surface auto targetSurface = - Surface::makeShared(pos + navDir * 2. * dir, dir); + CurvilinearSurface(pos + navDir * 2. * dir, dir).planeSurface(); es.updateSurfaceStatus(esState, *targetSurface, 0, navDir, BoundaryTolerance::None()); CHECK_CLOSE_ABS(esState.stepSize.value(ConstrainedStep::actor), navDir * 2., diff --git a/Tests/UnitTests/Core/Surfaces/CylinderSurfaceTests.cpp b/Tests/UnitTests/Core/Surfaces/CylinderSurfaceTests.cpp index 131e257c491..22f69a64109 100644 --- a/Tests/UnitTests/Core/Surfaces/CylinderSurfaceTests.cpp +++ b/Tests/UnitTests/Core/Surfaces/CylinderSurfaceTests.cpp @@ -195,13 +195,13 @@ BOOST_AUTO_TEST_CASE(CylinderSurfaceProperties) { testContext, offSurface, direction, BoundaryTolerance::Infinite()); Intersection3D expectedIntersect{Vector3{1, 1, 2}, 99., Intersection3D::Status::reachable}; - BOOST_CHECK(sfIntersection[0]); + BOOST_CHECK(sfIntersection[0].isValid()); CHECK_CLOSE_ABS(sfIntersection[0].position(), expectedIntersect.position(), 1e-9); CHECK_CLOSE_ABS(sfIntersection[0].pathLength(), expectedIntersect.pathLength(), 1e-9); // there is a second solution & and it should be valid - BOOST_CHECK(sfIntersection[1]); + BOOST_CHECK(sfIntersection[1].isValid()); // And it's path should be further away then the primary solution double pn = sfIntersection[0].pathLength(); double pa = sfIntersection[1].pathLength(); diff --git a/Tests/UnitTests/Core/Surfaces/IntersectionHelper2DTests.cpp b/Tests/UnitTests/Core/Surfaces/IntersectionHelper2DTests.cpp index 67c3d2a3555..5fc1c882378 100644 --- a/Tests/UnitTests/Core/Surfaces/IntersectionHelper2DTests.cpp +++ b/Tests/UnitTests/Core/Surfaces/IntersectionHelper2DTests.cpp @@ -117,13 +117,13 @@ BOOST_AUTO_TEST_CASE(EllipseIntersection) { radiusX, radiusY, start, direction); // Numerically checked / per hand calculated - BOOST_CHECK(solution[0]); + BOOST_CHECK(solution[0].isValid()); CHECK_CLOSE_ABS(solution[0].position().x(), -283.68, 0.01); CHECK_CLOSE_ABS(solution[0].position().y(), -213.47, 0.01); BOOST_CHECK_GT(solution[0].pathLength(), 0.); - BOOST_CHECK(solution[1]); + BOOST_CHECK(solution[1].isValid()); CHECK_CLOSE_ABS(solution[1].position().x(), 433.65, 0.01); CHECK_CLOSE_ABS(solution[1].position().y(), 73.46, 0.01); @@ -147,13 +147,13 @@ BOOST_AUTO_TEST_CASE(CircleIntersection) { detail::IntersectionHelper2D::intersectCircle(radius, start, direction); // Numerically checked / per hand calculated - BOOST_CHECK(solution[0]); + BOOST_CHECK(solution[0].isValid()); CHECK_CLOSE_ABS(solution[0].position().x(), -266.771, 0.001); CHECK_CLOSE_ABS(solution[0].position().y(), -66.771, 0.001); BOOST_CHECK_GT(solution[0].pathLength(), 0.); - BOOST_CHECK(solution[1]); + BOOST_CHECK(solution[1].isValid()); CHECK_CLOSE_ABS(solution[1].position().x(), 66.771, 0.001); CHECK_CLOSE_ABS(solution[1].position().y(), 266.771, 0.001); @@ -165,12 +165,12 @@ BOOST_AUTO_TEST_CASE(CircleIntersection) { solution = detail::IntersectionHelper2D::intersectCircle(radius, start, direction); - BOOST_CHECK(solution[0]); + BOOST_CHECK(solution[0].isValid()); CHECK_CLOSE_ABS(solution[0].position().x(), 66.771, 0.001); CHECK_CLOSE_ABS(solution[0].position().y(), 266.771, 0.001); BOOST_CHECK_LT(solution[0].pathLength(), 0.); - BOOST_CHECK(solution[1]); + BOOST_CHECK(solution[1].isValid()); CHECK_CLOSE_ABS(solution[1].position().x(), -266.771, 0.001); CHECK_CLOSE_ABS(solution[1].position().y(), -66.771, 0.001); BOOST_CHECK_LT(solution[1].pathLength(), 0.); @@ -180,12 +180,12 @@ BOOST_AUTO_TEST_CASE(CircleIntersection) { solution = detail::IntersectionHelper2D::intersectCircle(radius, start, direction); - BOOST_CHECK(solution[0]); + BOOST_CHECK(solution[0].isValid()); CHECK_CLOSE_ABS(solution[0].position().x(), 66.771, 0.001); CHECK_CLOSE_ABS(solution[0].position().y(), 266.771, 0.001); BOOST_CHECK_GT(solution[0].pathLength(), 0.); - BOOST_CHECK(solution[1]); + BOOST_CHECK(solution[1].isValid()); CHECK_CLOSE_ABS(solution[1].position().x(), -266.771, 0.001); CHECK_CLOSE_ABS(solution[1].position().y(), -66.771, 0.001); BOOST_CHECK_GT(solution[1].pathLength(), 0.); diff --git a/Tests/UnitTests/Core/Surfaces/LineSurfaceTests.cpp b/Tests/UnitTests/Core/Surfaces/LineSurfaceTests.cpp index 90a48df6a00..d52a15da8be 100644 --- a/Tests/UnitTests/Core/Surfaces/LineSurfaceTests.cpp +++ b/Tests/UnitTests/Core/Surfaces/LineSurfaceTests.cpp @@ -121,7 +121,7 @@ BOOST_AUTO_TEST_CASE(LineSurface_allNamedMethods_test) { line.intersect(tgContext, {0., 0., 0.}, direction.normalized(), BoundaryTolerance::Infinite()) .closest(); - BOOST_CHECK(sfIntersection); + BOOST_CHECK(sfIntersection.isValid()); Vector3 expectedIntersection(0, 1., 2.); CHECK_CLOSE_ABS(sfIntersection.position(), expectedIntersection, 1e-6); // need more tests.. @@ -357,4 +357,5 @@ BOOST_AUTO_TEST_CASE(LineSurfaceIntersection) { } BOOST_AUTO_TEST_SUITE_END() + } // namespace Acts::Test diff --git a/Tests/UnitTests/Core/Surfaces/PlaneSurfaceTests.cpp b/Tests/UnitTests/Core/Surfaces/PlaneSurfaceTests.cpp index 96f0371735d..a6e8da997d6 100644 --- a/Tests/UnitTests/Core/Surfaces/PlaneSurfaceTests.cpp +++ b/Tests/UnitTests/Core/Surfaces/PlaneSurfaceTests.cpp @@ -167,7 +167,7 @@ BOOST_AUTO_TEST_CASE(PlaneSurfaceProperties) { .closest(); Intersection3D expectedIntersect{Vector3{0, 1, 2}, 4., Intersection3D::Status::reachable}; - BOOST_CHECK(sfIntersection); + BOOST_CHECK(sfIntersection.isValid()); BOOST_CHECK_EQUAL(sfIntersection.position(), expectedIntersect.position()); BOOST_CHECK_EQUAL(sfIntersection.pathLength(), expectedIntersect.pathLength()); diff --git a/Tests/UnitTests/Core/Surfaces/SurfaceIntersectionTests.cpp b/Tests/UnitTests/Core/Surfaces/SurfaceIntersectionTests.cpp index eb7671e6733..55cbe668d58 100644 --- a/Tests/UnitTests/Core/Surfaces/SurfaceIntersectionTests.cpp +++ b/Tests/UnitTests/Core/Surfaces/SurfaceIntersectionTests.cpp @@ -68,14 +68,14 @@ BOOST_AUTO_TEST_CASE(CylinderIntersectionTests) { BoundaryTolerance::None()); // Check the validity of the intersection - BOOST_CHECK(aIntersection[0]); + BOOST_CHECK(aIntersection[0].isValid()); // The status of this one should be on surface BOOST_CHECK_EQUAL(aIntersection[0].status(), Intersection3D::Status::reachable); // The intersection is at 2 meter distance CHECK_CLOSE_ABS(aIntersection[0].pathLength(), -2_m, s_onSurfaceTolerance); // There MUST be a second solution - BOOST_CHECK(aIntersection[1]); + BOOST_CHECK(aIntersection[1].isValid()); // The other intersection MUST be reachable BOOST_CHECK_EQUAL(aIntersection[1].status(), Intersection3D::Status::onSurface); @@ -85,12 +85,12 @@ BOOST_AUTO_TEST_CASE(CylinderIntersectionTests) { BoundaryTolerance::None()); // Check the validity of the intersection - BOOST_CHECK(cIntersection[0]); + BOOST_CHECK(cIntersection[0].isValid()); // The status of this one MUST be reachable BOOST_CHECK_EQUAL(cIntersection[0].status(), Intersection3D::Status::reachable); // There MUST be a second solution - BOOST_CHECK(cIntersection[1]); + BOOST_CHECK(cIntersection[1].isValid()); // The other intersection MUST be reachable BOOST_CHECK_EQUAL(cIntersection[1].status(), Intersection3D::Status::reachable); @@ -103,12 +103,12 @@ BOOST_AUTO_TEST_CASE(CylinderIntersectionTests) { BoundaryTolerance::None()); // Check the validity of the intersection - BOOST_CHECK(oIntersection[0]); + BOOST_CHECK(oIntersection[0].isValid()); // The status of this one MUST be reachable BOOST_CHECK_EQUAL(oIntersection[0].status(), Intersection3D::Status::reachable); // There MUST be a second solution - BOOST_CHECK(oIntersection[1]); + BOOST_CHECK(oIntersection[1].isValid()); // The other intersection MUST be reachable BOOST_CHECK_EQUAL(oIntersection[1].status(), Intersection3D::Status::reachable); @@ -128,14 +128,14 @@ BOOST_AUTO_TEST_CASE(CylinderIntersectionTests) { BoundaryTolerance::Infinite()); // Check the validity of the intersection - BOOST_CHECK(eIntersection[0]); + BOOST_CHECK(eIntersection[0].isValid()); // This should be the positive one BOOST_CHECK_LT(eIntersection[0].pathLength(), 0.); // The status of this one should be reachable BOOST_CHECK_EQUAL(eIntersection[0].status(), Intersection3D::Status::reachable); // There MUST be a second solution - BOOST_CHECK(eIntersection[1]); + BOOST_CHECK(eIntersection[1].isValid()); // The other intersection MUST be reachable BOOST_CHECK_EQUAL(eIntersection[1].status(), Intersection3D::Status::reachable); @@ -192,14 +192,14 @@ BOOST_AUTO_TEST_CASE(ConeIntersectionTest) { aCone->intersect(tgContext, onCone, transXY, BoundaryTolerance::None()); // Check the validity of the intersection - BOOST_CHECK(aIntersection[0]); + BOOST_CHECK(aIntersection[0].isValid()); // The status of this one should be on surface BOOST_CHECK_EQUAL(aIntersection[0].status(), Intersection3D::Status::reachable); // The intersection is at 4 mm distance CHECK_CLOSE_ABS(aIntersection[0].pathLength(), -4., s_onSurfaceTolerance); // There MUST be a second solution - BOOST_CHECK(aIntersection[1]); + BOOST_CHECK(aIntersection[1].isValid()); // The other intersection MUST be reachable BOOST_CHECK_EQUAL(aIntersection[1].status(), Intersection3D::Status::onSurface); @@ -250,7 +250,7 @@ BOOST_AUTO_TEST_CASE(PlanarIntersectionTest) { BoundaryTolerance::None()); // The intersection MUST be valid - BOOST_CHECK(fIntersection[0]); + BOOST_CHECK(fIntersection[0].isValid()); // The intersection MUST be reachable BOOST_CHECK_EQUAL(fIntersection[0].status(), Intersection3D::Status::reachable); @@ -263,7 +263,7 @@ BOOST_AUTO_TEST_CASE(PlanarIntersectionTest) { auto oIntersection = aPlane->intersect(tgContext, onit, direction, BoundaryTolerance::None()); // The intersection MUST be valid - BOOST_CHECK(oIntersection[0]); + BOOST_CHECK(oIntersection[0].isValid()); // The intersection MUST be reachable BOOST_CHECK_EQUAL(oIntersection[0].status(), Intersection3D::Status::onSurface); @@ -277,7 +277,7 @@ BOOST_AUTO_TEST_CASE(PlanarIntersectionTest) { auto bIntersection = aPlane->intersect(tgContext, after, direction, BoundaryTolerance::None()); // The intersection MUST be valid - BOOST_CHECK(bIntersection[0]); + BOOST_CHECK(bIntersection[0].isValid()); // The intersection MUST be reachable BOOST_CHECK_EQUAL(bIntersection[0].status(), Intersection3D::Status::reachable); @@ -348,7 +348,7 @@ BOOST_AUTO_TEST_CASE(LineIntersectionTest) { auto fIntersection = aLine->intersect(tgContext, before, direction, BoundaryTolerance::None()); // The intersection MUST be valid - BOOST_CHECK(fIntersection[0]); + BOOST_CHECK(fIntersection[0].isValid()); // The intersection MUST be reachable BOOST_CHECK_EQUAL(fIntersection[0].status(), Intersection3D::Status::reachable); @@ -361,7 +361,7 @@ BOOST_AUTO_TEST_CASE(LineIntersectionTest) { auto oIntersection = aLine->intersect(tgContext, onit1, direction, BoundaryTolerance::None()); // The intersection MUST be valid - BOOST_CHECK(oIntersection[0]); + BOOST_CHECK(oIntersection[0].isValid()); // The intersection MUST be reachable BOOST_CHECK_EQUAL(oIntersection[0].status(), Intersection3D::Status::onSurface); @@ -375,7 +375,7 @@ BOOST_AUTO_TEST_CASE(LineIntersectionTest) { oIntersection = aLine->intersect(tgContext, onitP, normalP, BoundaryTolerance::None()); // The intersection MUST be valid - BOOST_CHECK(oIntersection[0]); + BOOST_CHECK(oIntersection[0].isValid()); // The intersection MUST be reachable BOOST_CHECK_EQUAL(oIntersection[0].status(), Intersection3D::Status::onSurface); @@ -389,7 +389,7 @@ BOOST_AUTO_TEST_CASE(LineIntersectionTest) { auto bIntersection = aLine->intersect(tgContext, after, direction, BoundaryTolerance::None()); // The intersection MUST be valid - BOOST_CHECK(bIntersection[0]); + BOOST_CHECK(bIntersection[0].isValid()); // The intersection MUST be reachable BOOST_CHECK_EQUAL(bIntersection[0].status(), Intersection3D::Status::reachable); diff --git a/Tests/UnitTests/Core/Surfaces/SurfaceLocalToGlobalRoundtripTests.cpp b/Tests/UnitTests/Core/Surfaces/SurfaceLocalToGlobalRoundtripTests.cpp index 005295928a4..8f3ff6e5f02 100644 --- a/Tests/UnitTests/Core/Surfaces/SurfaceLocalToGlobalRoundtripTests.cpp +++ b/Tests/UnitTests/Core/Surfaces/SurfaceLocalToGlobalRoundtripTests.cpp @@ -17,6 +17,7 @@ #include "Acts/Definitions/Common.hpp" #include "Acts/Geometry/GeometryContext.hpp" #include "Acts/Surfaces/ConeSurface.hpp" +#include "Acts/Surfaces/CurvilinearSurface.hpp" #include "Acts/Surfaces/CylinderSurface.hpp" #include "Acts/Surfaces/DiscSurface.hpp" #include "Acts/Surfaces/PerigeeSurface.hpp" @@ -102,9 +103,9 @@ const auto perigees = bdata::make({ Surface::makeShared(Vector3(0, 0, -1.5)), }); const auto planes = bdata::make({ - Surface::makeShared(Vector3(1, 2, 3), Vector3::UnitX()), - Surface::makeShared(Vector3(-2, -3, -4), Vector3::UnitY()), - Surface::makeShared(Vector3(3, -4, 5), Vector3::UnitZ()), + CurvilinearSurface(Vector3(1, 2, 3), Vector3::UnitX()).planeSurface(), + CurvilinearSurface(Vector3(-2, -3, -4), Vector3::UnitY()).planeSurface(), + CurvilinearSurface(Vector3(3, -4, 5), Vector3::UnitZ()).planeSurface(), }); const auto straws = bdata::make({ Surface::makeShared(Transform3::Identity(), 2.0 /* radius */, diff --git a/Tests/UnitTests/Core/TrackFinding/CombinatorialKalmanFilterTests.cpp b/Tests/UnitTests/Core/TrackFinding/CombinatorialKalmanFilterTests.cpp index 3569f6c9a9d..cb730f470a9 100644 --- a/Tests/UnitTests/Core/TrackFinding/CombinatorialKalmanFilterTests.cpp +++ b/Tests/UnitTests/Core/TrackFinding/CombinatorialKalmanFilterTests.cpp @@ -31,6 +31,7 @@ #include "Acts/Propagator/Navigator.hpp" #include "Acts/Propagator/Propagator.hpp" #include "Acts/Propagator/StraightLineStepper.hpp" +#include "Acts/Surfaces/CurvilinearSurface.hpp" #include "Acts/Surfaces/PlaneSurface.hpp" #include "Acts/Surfaces/Surface.hpp" #include "Acts/Tests/CommonHelpers/CubicTrackingGeometry.hpp" @@ -307,8 +308,9 @@ BOOST_AUTO_TEST_CASE(ZeroFieldForward) { // this is the default option. set anyway for consistency options.propagatorPlainOptions.direction = Acts::Direction::Forward; // Construct a plane surface as the target surface - auto pSurface = Acts::Surface::makeShared( - Acts::Vector3{-3_m, 0., 0.}, Acts::Vector3{1., 0., 0}); + auto pSurface = Acts::CurvilinearSurface(Acts::Vector3{-3_m, 0., 0.}, + Acts::Vector3{1., 0., 0}) + .planeSurface(); Fixture::TestSourceLinkAccessor slAccessor; slAccessor.container = &f.sourceLinks; @@ -364,8 +366,9 @@ BOOST_AUTO_TEST_CASE(ZeroFieldBackward) { auto options = f.makeCkfOptions(); options.propagatorPlainOptions.direction = Acts::Direction::Backward; // Construct a plane surface as the target surface - auto pSurface = Acts::Surface::makeShared( - Acts::Vector3{3_m, 0., 0.}, Acts::Vector3{1., 0., 0}); + auto pSurface = Acts::CurvilinearSurface(Acts::Vector3{3_m, 0., 0.}, + Acts::Vector3{1., 0., 0}) + .planeSurface(); Fixture::TestSourceLinkAccessor slAccessor; slAccessor.container = &f.sourceLinks; diff --git a/Tests/UnitTests/Core/TrackFinding/TrackSelectorTests.cpp b/Tests/UnitTests/Core/TrackFinding/TrackSelectorTests.cpp index dfdf33885ed..01de2790874 100644 --- a/Tests/UnitTests/Core/TrackFinding/TrackSelectorTests.cpp +++ b/Tests/UnitTests/Core/TrackFinding/TrackSelectorTests.cpp @@ -15,6 +15,7 @@ #include "Acts/EventData/VectorMultiTrajectory.hpp" #include "Acts/EventData/VectorTrackContainer.hpp" #include "Acts/Geometry/GeometryIdentifier.hpp" +#include "Acts/Surfaces/CurvilinearSurface.hpp" #include "Acts/Surfaces/PerigeeSurface.hpp" #include "Acts/Surfaces/PlaneSurface.hpp" #include "Acts/TrackFinding/TrackSelector.hpp" @@ -60,7 +61,7 @@ struct MockTrack { struct MockTrackState { const Surface& referenceSurface() const { static const auto srf = - Surface::makeShared(Vector3::Zero(), Vector3::UnitZ()); + CurvilinearSurface(Vector3::Zero(), Vector3::UnitZ()).planeSurface(); return *srf; } @@ -613,7 +614,7 @@ BOOST_AUTO_TEST_CASE(TestConstructor) { BOOST_AUTO_TEST_CASE(SubsetHitCountCut) { auto makeSurface = [](GeometryIdentifier id) { auto srf = - Surface::makeShared(Vector3::Zero(), Vector3::UnitZ()); + CurvilinearSurface(Vector3::Zero(), Vector3::UnitZ()).planeSurface(); srf->assignGeometryId(id); return srf; diff --git a/Tests/UnitTests/Core/TrackFitting/FitterTestsCommon.hpp b/Tests/UnitTests/Core/TrackFitting/FitterTestsCommon.hpp index bef7ba52cd6..1b2500dc32a 100644 --- a/Tests/UnitTests/Core/TrackFitting/FitterTestsCommon.hpp +++ b/Tests/UnitTests/Core/TrackFitting/FitterTestsCommon.hpp @@ -22,6 +22,7 @@ #include "Acts/MagneticField/MagneticFieldContext.hpp" #include "Acts/Propagator/Navigator.hpp" #include "Acts/Propagator/StraightLineStepper.hpp" +#include "Acts/Surfaces/CurvilinearSurface.hpp" #include "Acts/Tests/CommonHelpers/CubicTrackingGeometry.hpp" #include "Acts/Tests/CommonHelpers/FloatComparisons.hpp" #include "Acts/Tests/CommonHelpers/MeasurementsCreator.hpp" @@ -340,7 +341,7 @@ struct FitterTester { Acts::Vector3 center(3._m, 0., 0.); Acts::Vector3 normal(1., 0., 0.); auto targetSurface = - Acts::Surface::makeShared(center, normal); + Acts::CurvilinearSurface(center, normal).planeSurface(); options.referenceSurface = targetSurface.get(); @@ -561,7 +562,7 @@ struct FitterTester { Acts::Vector3 center(-3._m, 0., 0.); Acts::Vector3 normal(1., 0., 0.); auto targetSurface = - Acts::Surface::makeShared(center, normal); + Acts::CurvilinearSurface(center, normal).planeSurface(); options.referenceSurface = targetSurface.get(); diff --git a/Tests/UnitTests/Core/TrackFitting/GsfComponentMergingTests.cpp b/Tests/UnitTests/Core/TrackFitting/GsfComponentMergingTests.cpp index d9fc6581dc1..f547ea89503 100644 --- a/Tests/UnitTests/Core/TrackFitting/GsfComponentMergingTests.cpp +++ b/Tests/UnitTests/Core/TrackFitting/GsfComponentMergingTests.cpp @@ -13,6 +13,7 @@ #include "Acts/Definitions/Units.hpp" #include "Acts/EventData/TransformationHelpers.hpp" #include "Acts/Geometry/GeometryContext.hpp" +#include "Acts/Surfaces/CurvilinearSurface.hpp" #include "Acts/Surfaces/CylinderBounds.hpp" #include "Acts/Surfaces/CylinderSurface.hpp" #include "Acts/Surfaces/DiscSurface.hpp" @@ -314,7 +315,7 @@ BOOST_AUTO_TEST_CASE(test_plane_surface) { const auto desc = detail::AngleDescription::Desc{}; const auto surface = - Surface::makeShared(Vector3{0, 0, 0}, Vector3{1, 0, 0}); + CurvilinearSurface(Vector3{0, 0, 0}, Vector3{1, 0, 0}).planeSurface(); const LocPosArray p{{{1, 1}, {1, -1}, {-1, 1}, {-1, -1}}}; diff --git a/Tests/UnitTests/Core/TrackFitting/GsfMixtureReductionTests.cpp b/Tests/UnitTests/Core/TrackFitting/GsfMixtureReductionTests.cpp index 3daa93a59f6..6a8b1ff7cd4 100644 --- a/Tests/UnitTests/Core/TrackFitting/GsfMixtureReductionTests.cpp +++ b/Tests/UnitTests/Core/TrackFitting/GsfMixtureReductionTests.cpp @@ -11,6 +11,7 @@ #include "Acts/Definitions/Algebra.hpp" #include "Acts/Definitions/TrackParametrization.hpp" #include "Acts/Definitions/Units.hpp" +#include "Acts/Surfaces/CurvilinearSurface.hpp" #include "Acts/TrackFitting/GsfMixtureReduction.hpp" #include "Acts/TrackFitting/detail/SymmetricKlDistanceMatrix.hpp" @@ -116,8 +117,8 @@ BOOST_AUTO_TEST_CASE(test_mixture_reduction) { }; // Assume that the components are on a generic plane surface - auto surface = Acts::Surface::makeShared(Vector3{0, 0, 0}, - Vector3{1, 0, 0}); + auto surface = Acts::CurvilinearSurface(Vector3{0, 0, 0}, Vector3{1, 0, 0}) + .planeSurface(); const std::size_t NComps = 4; std::vector cmps; @@ -165,8 +166,8 @@ BOOST_AUTO_TEST_CASE(test_mixture_reduction) { } BOOST_AUTO_TEST_CASE(test_weight_cut_reduction) { - auto dummy = Acts::Surface::makeShared(Vector3{0, 0, 0}, - Vector3{1, 0, 0}); + auto dummy = Acts::CurvilinearSurface(Vector3{0, 0, 0}, Vector3{1, 0, 0}) + .planeSurface(); std::vector cmps; // weights do not need to be normalized for this test diff --git a/Tests/UnitTests/Core/TrackFitting/GsfTests.cpp b/Tests/UnitTests/Core/TrackFitting/GsfTests.cpp index 5549e63f631..47f6539a36c 100644 --- a/Tests/UnitTests/Core/TrackFitting/GsfTests.cpp +++ b/Tests/UnitTests/Core/TrackFitting/GsfTests.cpp @@ -30,6 +30,7 @@ #include "Acts/Propagator/Navigator.hpp" #include "Acts/Propagator/Propagator.hpp" #include "Acts/Propagator/StraightLineStepper.hpp" +#include "Acts/Surfaces/CurvilinearSurface.hpp" #include "Acts/Surfaces/PlaneSurface.hpp" #include "Acts/Surfaces/Surface.hpp" #include "Acts/Tests/CommonHelpers/LineSurfaceStub.hpp" @@ -240,8 +241,7 @@ BOOST_AUTO_TEST_CASE(WithFinalMultiComponentState) { // create a boundless target surface near the tracker exit Acts::Vector3 center(-3._m, 0., 0.); Acts::Vector3 normal(1., 0., 0.); - auto targetSurface = - Acts::Surface::makeShared(center, normal); + auto targetSurface = Acts::CurvilinearSurface(center, normal).planeSurface(); options.referenceSurface = targetSurface.get(); diff --git a/Tests/UnitTests/Core/Utilities/IntersectionTests.cpp b/Tests/UnitTests/Core/Utilities/IntersectionTests.cpp index 076abbfe088..644371c45a4 100644 --- a/Tests/UnitTests/Core/Utilities/IntersectionTests.cpp +++ b/Tests/UnitTests/Core/Utilities/IntersectionTests.cpp @@ -9,6 +9,7 @@ #include #include "Acts/Definitions/Algebra.hpp" +#include "Acts/Surfaces/CurvilinearSurface.hpp" #include "Acts/Surfaces/PlaneSurface.hpp" #include "Acts/Surfaces/Surface.hpp" #include "Acts/Utilities/Intersection.hpp" @@ -140,16 +141,16 @@ BOOST_AUTO_TEST_CASE(IntersectionTest) { /// test of the object intersection class BOOST_AUTO_TEST_CASE(ObjectIntersectionTest) { - auto psf6 = Surface::makeShared(Vector3(6., 0., 0.), - Vector3(1., 0., 0.)); - auto psf7 = Surface::makeShared(Vector3(7., 0., 0.), - Vector3(1., 0., 0.)); - auto psf8 = Surface::makeShared(Vector3(8., 0., 0.), - Vector3(1., 0., 0.)); - auto psf9 = Surface::makeShared(Vector3(9., 0., 0.), - Vector3(1., 0., 0.)); - auto psf10 = Surface::makeShared(Vector3(10., 0., 0.), - Vector3(1., 0., 0.)); + auto psf6 = CurvilinearSurface(Vector3(6., 0., 0.), Vector3(1., 0., 0.)) + .planeSurface(); + auto psf7 = CurvilinearSurface(Vector3(7., 0., 0.), Vector3(1., 0., 0.)) + .planeSurface(); + auto psf8 = CurvilinearSurface(Vector3(8., 0., 0.), Vector3(1., 0., 0.)) + .planeSurface(); + auto psf9 = CurvilinearSurface(Vector3(9., 0., 0.), Vector3(1., 0., 0.)) + .planeSurface(); + auto psf10 = CurvilinearSurface(Vector3(10., 0., 0.), Vector3(1., 0., 0.)) + .planeSurface(); using PlaneIntersection = ObjectIntersection; diff --git a/Tests/UnitTests/Fatras/Digitization/ChannelizerTests.cpp b/Tests/UnitTests/Fatras/Digitization/ChannelizerTests.cpp index b437bd78167..a498f0f5f75 100644 --- a/Tests/UnitTests/Fatras/Digitization/ChannelizerTests.cpp +++ b/Tests/UnitTests/Fatras/Digitization/ChannelizerTests.cpp @@ -9,6 +9,7 @@ #include #include "Acts/Definitions/Units.hpp" +#include "Acts/Surfaces/CurvilinearSurface.hpp" #include "Acts/Surfaces/PlaneSurface.hpp" #include "Acts/Utilities/BinUtility.hpp" #include "ActsFatras/Digitization/Channelizer.hpp" @@ -30,8 +31,9 @@ struct Helper { ActsFatras::Channelizer channelizer; Helper() { - surface = Acts::Surface::makeShared( - Acts::Vector3::Zero(), Acts::Vector3{0.0, 0.0, 1.0}); + surface = Acts::CurvilinearSurface(Acts::Vector3::Zero(), + Acts::Vector3{0.0, 0.0, 1.0}) + .planeSurface(); float pitchSize = 50_um; float min = -200_um; diff --git a/Tests/UnitTests/Fatras/Digitization/PlanarSurfaceDriftTests.cpp b/Tests/UnitTests/Fatras/Digitization/PlanarSurfaceDriftTests.cpp index 70de42ee6c4..171564af1b9 100644 --- a/Tests/UnitTests/Fatras/Digitization/PlanarSurfaceDriftTests.cpp +++ b/Tests/UnitTests/Fatras/Digitization/PlanarSurfaceDriftTests.cpp @@ -11,6 +11,7 @@ #include "Acts/Definitions/Algebra.hpp" #include "Acts/Definitions/Tolerance.hpp" #include "Acts/Geometry/GeometryContext.hpp" +#include "Acts/Surfaces/CurvilinearSurface.hpp" #include "Acts/Surfaces/PlaneSurface.hpp" #include "Acts/Surfaces/Surface.hpp" #include "Acts/Tests/CommonHelpers/FloatComparisons.hpp" @@ -32,7 +33,7 @@ BOOST_AUTO_TEST_CASE(PlanarSurfaceDrift) { Acts::Vector3 cNormal = Acts::Vector3(1., 1., 1.).normalized(); auto planeSurface = - Acts::Surface::makeShared(cPosition, cNormal); + Acts::CurvilinearSurface(cPosition, cNormal).planeSurface(); double depletion = 0.250; diff --git a/Tests/UnitTests/Fatras/Kernel/SimulationActorTests.cpp b/Tests/UnitTests/Fatras/Kernel/SimulationActorTests.cpp index ee463e5a729..748bbb9af5e 100644 --- a/Tests/UnitTests/Fatras/Kernel/SimulationActorTests.cpp +++ b/Tests/UnitTests/Fatras/Kernel/SimulationActorTests.cpp @@ -16,6 +16,7 @@ #include "Acts/Material/MaterialSlab.hpp" #include "Acts/Propagator/ConstrainedStep.hpp" #include "Acts/Propagator/Propagator.hpp" +#include "Acts/Surfaces/CurvilinearSurface.hpp" #include "Acts/Surfaces/PlaneSurface.hpp" #include "Acts/Surfaces/Surface.hpp" #include "Acts/Tests/CommonHelpers/FloatComparisons.hpp" @@ -203,8 +204,9 @@ struct Fixture { // make a surface without material. std::shared_ptr makeEmptySurface() { - auto surface = Acts::Surface::makeShared( - Acts::Vector3(1, 2, 3), Acts::Vector3(1, 0, 0)); + auto surface = + Acts::CurvilinearSurface(Acts::Vector3(1, 2, 3), Acts::Vector3(1, 0, 0)) + .planeSurface(); return surface; } diff --git a/Tests/UnitTests/Plugins/EDM4hep/ConvertTrackEDM4hepTest.cpp b/Tests/UnitTests/Plugins/EDM4hep/ConvertTrackEDM4hepTest.cpp index ffd2ef2e7d4..58c430f4e4c 100644 --- a/Tests/UnitTests/Plugins/EDM4hep/ConvertTrackEDM4hepTest.cpp +++ b/Tests/UnitTests/Plugins/EDM4hep/ConvertTrackEDM4hepTest.cpp @@ -19,6 +19,7 @@ #include "Acts/Plugins/EDM4hep/EDM4hepUtil.hpp" #include "Acts/Propagator/detail/CovarianceEngine.hpp" #include "Acts/Propagator/detail/JacobianEngine.hpp" +#include "Acts/Surfaces/CurvilinearSurface.hpp" #include "Acts/Surfaces/PerigeeSurface.hpp" #include "Acts/Surfaces/PlaneSurface.hpp" #include "Acts/Surfaces/Surface.hpp" @@ -106,8 +107,9 @@ BOOST_AUTO_TEST_CASE(ConvertTrackParametersToEdm4hepWithPerigee) { } BOOST_AUTO_TEST_CASE(ConvertTrackParametersToEdm4hepWithOutPerigee) { - auto planeSurface = Surface::makeShared( - Vector3{50, 30, 20}, Vector3{1, 1, 0.3}.normalized()); + auto planeSurface = + CurvilinearSurface(Vector3{50, 30, 20}, Vector3{1, 1, 0.3}.normalized()) + .planeSurface(); BoundVector par; par << 1_mm, 5_mm, M_PI / 4., M_PI_2 * 0.9, -1 / 1_GeV, 5_ns; @@ -204,8 +206,9 @@ BOOST_AUTO_TEST_CASE(ConvertTrackParametersToEdm4hepWithPerigeeNoCov) { } BOOST_AUTO_TEST_CASE(ConvertTrackParametersToEdm4hepWithOutPerigeeNoCov) { - auto refSurface = Surface::makeShared( - Vector3{50, 30, 20}, Vector3{1, 1, 0.3}.normalized()); + auto refSurface = + CurvilinearSurface(Vector3{50, 30, 20}, Vector3{1, 1, 0.3}.normalized()) + .planeSurface(); BoundVector par; par << 1_mm, 5_mm, M_PI / 4., M_PI_2, -1 / 1_GeV, 5_ns; diff --git a/Tests/UnitTests/Plugins/Json/PortalJsonConverterTests.cpp b/Tests/UnitTests/Plugins/Json/PortalJsonConverterTests.cpp index 7bc829a1c88..7004216a790 100644 --- a/Tests/UnitTests/Plugins/Json/PortalJsonConverterTests.cpp +++ b/Tests/UnitTests/Plugins/Json/PortalJsonConverterTests.cpp @@ -14,6 +14,7 @@ #include "Acts/Detector/detail/PortalHelper.hpp" #include "Acts/Geometry/GeometryContext.hpp" #include "Acts/Plugins/Json/PortalJsonConverter.hpp" +#include "Acts/Surfaces/CurvilinearSurface.hpp" #include "Acts/Surfaces/PlaneSurface.hpp" #include "Acts/Surfaces/Surface.hpp" #include "Acts/Tests/CommonHelpers/FloatComparisons.hpp" @@ -33,8 +34,9 @@ BOOST_AUTO_TEST_SUITE(PortalJsonConverter) BOOST_AUTO_TEST_CASE(PortalUnconnected) { std::ofstream out; - auto surface = Acts::Surface::makeShared( - Acts::Vector3(0., 0., 0.), Acts::Vector3(0., 1., 0.)); + auto surface = Acts::CurvilinearSurface(Acts::Vector3(0., 0., 0.), + Acts::Vector3(0., 1., 0.)) + .planeSurface(); auto portal = std::make_shared(std::move(surface)); @@ -66,8 +68,9 @@ BOOST_AUTO_TEST_CASE(PortalSingleConnected) { auto forwardVolume = std::make_shared(); auto backwardVolume = std::make_shared(); - auto surface = Acts::Surface::makeShared( - Acts::Vector3(0., 0., 0.), Acts::Vector3(0., 1., 0.)); + auto surface = Acts::CurvilinearSurface(Acts::Vector3(0., 0., 0.), + Acts::Vector3(0., 1., 0.)) + .planeSurface(); auto portal = std::make_shared(std::move(surface)); @@ -112,8 +115,9 @@ BOOST_AUTO_TEST_CASE(PortalMultiConnected) { auto backwardVolume = std::make_shared(); - auto surface = Acts::Surface::makeShared( - Acts::Vector3(0., 0., 0.), Acts::Vector3(0., 1., 0.)); + auto surface = Acts::CurvilinearSurface(Acts::Vector3(0., 0., 0.), + Acts::Vector3(0., 1., 0.)) + .planeSurface(); auto portal = std::make_shared(std::move(surface)); From 26b059f3af094df85f5826f4bde95b793f0106d0 Mon Sep 17 00:00:00 2001 From: Andreas Stefl Date: Fri, 6 Sep 2024 16:25:29 +0200 Subject: [PATCH 02/12] feat: Allow user to supply root branch to Core CKF (#3534) Adding an overload to the Core CKF which allows the user to supply a root branch. This is useful if the finding has multiple stages, i.e. forward and backward, and the tip state quantities like `nMeasurements` and `nHoles` should persist so the branch stopper can observe them. blocked by - https://github.com/acts-project/acts/pull/3586 - https://github.com/acts-project/acts/pull/3587 --- .../CombinatorialKalmanFilter.hpp | 36 +++++++++++++++++-- .../TrackFinding/TrackFindingAlgorithm.hpp | 2 +- .../src/TrackFindingAlgorithm.cpp | 12 ++++--- .../src/TrackFindingAlgorithmFunction.cpp | 6 ++-- .../TrackFindingFromPrototrackAlgorithm.cpp | 4 ++- 5 files changed, 49 insertions(+), 11 deletions(-) diff --git a/Core/include/Acts/TrackFinding/CombinatorialKalmanFilter.hpp b/Core/include/Acts/TrackFinding/CombinatorialKalmanFilter.hpp index 4a7920646cc..baa4cc2e2b1 100644 --- a/Core/include/Acts/TrackFinding/CombinatorialKalmanFilter.hpp +++ b/Core/include/Acts/TrackFinding/CombinatorialKalmanFilter.hpp @@ -1235,7 +1235,9 @@ class CombinatorialKalmanFilter { /// @param initialParameters The initial track parameters /// @param tfOptions CombinatorialKalmanFilterOptions steering the track /// finding - /// @param trackContainer Input track container to use + /// @param trackContainer Track container in which to store the results + /// @param rootBranch The track to be used as the root branch + /// /// @note The input measurements are given in the form of @c SourceLinks. /// It's @c calibrator_t's job to turn them into calibrated measurements /// used in the track finding. @@ -1247,7 +1249,8 @@ class CombinatorialKalmanFilter { auto findTracks(const start_parameters_t& initialParameters, const CombinatorialKalmanFilterOptions< source_link_iterator_t, track_container_t>& tfOptions, - track_container_t& trackContainer) const + track_container_t& trackContainer, + typename track_container_t::TrackProxy rootBranch) const -> Result::TrackProxy>> { using SourceLinkAccessor = @@ -1310,7 +1313,6 @@ class CombinatorialKalmanFilter { r.tracks = &trackContainer; r.trackStates = &trackContainer.trackStateContainer(); - auto rootBranch = trackContainer.makeTrack(); r.activeBranches.push_back(rootBranch); auto propagationResult = m_propagator.propagate(propState); @@ -1349,6 +1351,34 @@ class CombinatorialKalmanFilter { return std::move(combKalmanResult.collectedTracks); } + + /// Combinatorial Kalman Filter implementation, calls the Kalman filter + /// + /// @tparam source_link_iterator_t Type of the source link iterator + /// @tparam start_parameters_t Type of the initial parameters + /// @tparam parameters_t Type of parameters used for local parameters + /// + /// @param initialParameters The initial track parameters + /// @param tfOptions CombinatorialKalmanFilterOptions steering the track + /// finding + /// @param trackContainer Track container in which to store the results + /// @note The input measurements are given in the form of @c SourceLinks. + /// It's @c calibrator_t's job to turn them into calibrated measurements + /// used in the track finding. + /// + /// @return a container of track finding result for all the initial track + /// parameters + template + auto findTracks(const start_parameters_t& initialParameters, + const CombinatorialKalmanFilterOptions< + source_link_iterator_t, track_container_t>& tfOptions, + track_container_t& trackContainer) const + -> Result::TrackProxy>> { + auto rootBranch = trackContainer.makeTrack(); + return findTracks(initialParameters, tfOptions, trackContainer, rootBranch); + } }; } // namespace Acts diff --git a/Examples/Algorithms/TrackFinding/include/ActsExamples/TrackFinding/TrackFindingAlgorithm.hpp b/Examples/Algorithms/TrackFinding/include/ActsExamples/TrackFinding/TrackFindingAlgorithm.hpp index 8d31a99b0f8..784bb74176a 100644 --- a/Examples/Algorithms/TrackFinding/include/ActsExamples/TrackFinding/TrackFindingAlgorithm.hpp +++ b/Examples/Algorithms/TrackFinding/include/ActsExamples/TrackFinding/TrackFindingAlgorithm.hpp @@ -69,7 +69,7 @@ class TrackFindingAlgorithm final : public IAlgorithm { virtual ~TrackFinderFunction() = default; virtual TrackFinderResult operator()(const TrackParameters&, const TrackFinderOptions&, - TrackContainer&) const = 0; + TrackContainer&, TrackProxy) const = 0; }; /// Create the track finder function implementation. diff --git a/Examples/Algorithms/TrackFinding/src/TrackFindingAlgorithm.cpp b/Examples/Algorithms/TrackFinding/src/TrackFindingAlgorithm.cpp index bb88f0e0208..432e546d4a3 100644 --- a/Examples/Algorithms/TrackFinding/src/TrackFindingAlgorithm.cpp +++ b/Examples/Algorithms/TrackFinding/src/TrackFindingAlgorithm.cpp @@ -470,8 +470,9 @@ ProcessCode TrackFindingAlgorithm::execute(const AlgorithmContext& ctx) const { const Acts::BoundTrackParameters& firstInitialParameters = initialParameters.at(iSeed); - auto firstResult = - (*m_cfg.findTracks)(firstInitialParameters, firstOptions, tracksTemp); + auto firstRootBranch = tracksTemp.makeTrack(); + auto firstResult = (*m_cfg.findTracks)(firstInitialParameters, firstOptions, + tracksTemp, firstRootBranch); nSeed++; if (!firstResult.ok()) { @@ -531,8 +532,11 @@ ProcessCode TrackFindingAlgorithm::execute(const AlgorithmContext& ctx) const { Acts::BoundTrackParameters secondInitialParameters = trackCandidate.createParametersFromState(*firstMeasurement); - auto secondResult = (*m_cfg.findTracks)(secondInitialParameters, - secondOptions, tracksTemp); + auto secondRootBranch = tracksTemp.makeTrack(); + secondRootBranch.copyFrom(trackCandidate, false); + auto secondResult = + (*m_cfg.findTracks)(secondInitialParameters, secondOptions, + tracksTemp, secondRootBranch); if (!secondResult.ok()) { ACTS_WARNING("Second track finding failed for seed " diff --git a/Examples/Algorithms/TrackFinding/src/TrackFindingAlgorithmFunction.cpp b/Examples/Algorithms/TrackFinding/src/TrackFindingAlgorithmFunction.cpp index 71298d98767..0ffef02588f 100644 --- a/Examples/Algorithms/TrackFinding/src/TrackFindingAlgorithmFunction.cpp +++ b/Examples/Algorithms/TrackFinding/src/TrackFindingAlgorithmFunction.cpp @@ -49,8 +49,10 @@ struct TrackFinderFunctionImpl ActsExamples::TrackFindingAlgorithm::TrackFinderResult operator()( const ActsExamples::TrackParameters& initialParameters, const ActsExamples::TrackFindingAlgorithm::TrackFinderOptions& options, - ActsExamples::TrackContainer& tracks) const override { - return trackFinder.findTracks(initialParameters, options, tracks); + ActsExamples::TrackContainer& tracks, + ActsExamples::TrackProxy rootBranch) const override { + return trackFinder.findTracks(initialParameters, options, tracks, + rootBranch); }; }; diff --git a/Examples/Algorithms/TrackFindingExaTrkX/src/TrackFindingFromPrototrackAlgorithm.cpp b/Examples/Algorithms/TrackFindingExaTrkX/src/TrackFindingFromPrototrackAlgorithm.cpp index 69d281110cf..bd4b57dd4e5 100644 --- a/Examples/Algorithms/TrackFindingExaTrkX/src/TrackFindingFromPrototrackAlgorithm.cpp +++ b/Examples/Algorithms/TrackFindingExaTrkX/src/TrackFindingFromPrototrackAlgorithm.cpp @@ -142,7 +142,9 @@ ActsExamples::ProcessCode TrackFindingFromPrototrackAlgorithm::execute( } } - auto result = (*m_cfg.findTracks)(initialParameters.at(i), options, tracks); + auto rootBranch = tracks.makeTrack(); + auto result = (*m_cfg.findTracks)(initialParameters.at(i), options, tracks, + rootBranch); nSeed++; if (!result.ok()) { From bd9d6dca7b8a852baca1fcf99dd86370fd603825 Mon Sep 17 00:00:00 2001 From: "Alexander J. Pfleger" <70842573+AJPfleger@users.noreply.github.com> Date: Mon, 9 Sep 2024 15:15:22 +0200 Subject: [PATCH 03/12] fix: remove pre-C++20 `std::identity` implementation (#3599) --- .../detail/GsfComponentMerging.hpp | 5 ++- Core/include/Acts/Utilities/Identity.hpp | 36 ------------------- .../TrackFitting/GsfComponentMergingTests.cpp | 7 ++-- 3 files changed, 5 insertions(+), 43 deletions(-) delete mode 100644 Core/include/Acts/Utilities/Identity.hpp diff --git a/Core/include/Acts/TrackFitting/detail/GsfComponentMerging.hpp b/Core/include/Acts/TrackFitting/detail/GsfComponentMerging.hpp index cf5bc4bf1b0..8881bf8a298 100644 --- a/Core/include/Acts/TrackFitting/detail/GsfComponentMerging.hpp +++ b/Core/include/Acts/TrackFitting/detail/GsfComponentMerging.hpp @@ -12,7 +12,6 @@ #include "Acts/Definitions/TrackParametrization.hpp" #include "Acts/Surfaces/CylinderSurface.hpp" #include "Acts/TrackFitting/GsfOptions.hpp" -#include "Acts/Utilities/Identity.hpp" #include "Acts/Utilities/detail/periodic.hpp" #include @@ -123,7 +122,7 @@ auto gaussianMixtureCov(const components_t components, /// std::tuple< weight, mean, std::optional< cov > > /// @tparam angle_desc_t A angle description object which defines the cyclic /// angles in the bound parameters -template ::Desc> auto gaussianMixtureMeanCov(const components_t components, projector_t &&projector = projector_t{}, @@ -212,7 +211,7 @@ auto gaussianMixtureMeanCov(const components_t components, /// like a std::tuple< double, BoundVector, BoundMatrix > /// /// @return parameters and covariance as std::tuple< BoundVector, BoundMatrix > -template +template auto mergeGaussianMixture(const mixture_t &mixture, const Surface &surface, ComponentMergeMethod method, projector_t &&projector = projector_t{}) { diff --git a/Core/include/Acts/Utilities/Identity.hpp b/Core/include/Acts/Utilities/Identity.hpp deleted file mode 100644 index 2d5c759b595..00000000000 --- a/Core/include/Acts/Utilities/Identity.hpp +++ /dev/null @@ -1,36 +0,0 @@ -// This file is part of the Acts project. -// -// Copyright (C) 2021 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 - -#if __cplusplus >= 202002L - -#include - -namespace Acts { -using Identity = std::identity; -} - -#else - -#include - -namespace Acts { - -/// @brief Function object which maps a value to itself by perfect forwarding -/// This is a backport of C++20's std::identity -struct Identity { - template - constexpr auto operator()(T &&v) const { - return std::forward(v); - } -}; - -} // namespace Acts - -#endif diff --git a/Tests/UnitTests/Core/TrackFitting/GsfComponentMergingTests.cpp b/Tests/UnitTests/Core/TrackFitting/GsfComponentMergingTests.cpp index f547ea89503..39959dfa0de 100644 --- a/Tests/UnitTests/Core/TrackFitting/GsfComponentMergingTests.cpp +++ b/Tests/UnitTests/Core/TrackFitting/GsfComponentMergingTests.cpp @@ -22,7 +22,6 @@ #include "Acts/Surfaces/Surface.hpp" #include "Acts/Surfaces/SurfaceBounds.hpp" #include "Acts/TrackFitting/detail/GsfComponentMerging.hpp" -#include "Acts/Utilities/Identity.hpp" #include "Acts/Utilities/Intersection.hpp" #include "Acts/Utilities/Result.hpp" #include "Acts/Utilities/detail/periodic.hpp" @@ -216,7 +215,7 @@ using LocPosArray = std::array, 4>; template void test_surface(const Surface &surface, const angle_description_t &desc, const LocPosArray &loc_pos, double expectedError) { - const auto proj = Identity{}; + const auto proj = std::identity{}; for (auto phi : {-175_degree, 0_degree, 175_degree}) { for (auto theta : {5_degree, 90_degree, 175_degree}) { @@ -271,7 +270,7 @@ BOOST_AUTO_TEST_CASE(test_with_data) { const auto boundCov_data = boundCov(samples, mean_data); const auto [mean_test, boundCov_test] = - detail::gaussianMixtureMeanCov(cmps, Identity{}, std::tuple<>{}); + detail::gaussianMixtureMeanCov(cmps, std::identity{}, std::tuple<>{}); CHECK_CLOSE_MATRIX(mean_data, mean_test, 1.e-1); CHECK_CLOSE_MATRIX(boundCov_data, boundCov_test, 1.e-1); @@ -302,7 +301,7 @@ BOOST_AUTO_TEST_CASE(test_with_data_circular) { using detail::CyclicAngle; const auto d = std::tuple, CyclicAngle>{}; const auto [mean_test, boundCov_test] = - detail::gaussianMixtureMeanCov(cmps, Identity{}, d); + detail::gaussianMixtureMeanCov(cmps, std::identity{}, d); BOOST_CHECK(std::abs(detail::difference_periodic(mean_data[0], mean_test[0], 2 * M_PI)) < 1.e-1); From 2798d98247ce73c3055ff38f54d586cd7f184ea5 Mon Sep 17 00:00:00 2001 From: Paul Gessinger Date: Mon, 9 Sep 2024 17:29:51 +0200 Subject: [PATCH 04/12] refactor: Volume holds bounds as mutable (#3595) This PR changes the internal storage of `VolumeBounds` inside `Volume` to be mutable. This allows transitive mutable access (which we need in a few cases). To prevent accidental mutable use of the contained bounds object (which can be shared with other objects), I'm moving the shared pointer member to be private, and allow access only via setters and getters. This way, in a const function of a derived class, only const access to the volume bounds is possible. --- .../Acts/Geometry/CylinderVolumeStack.hpp | 4 ++-- Core/include/Acts/Geometry/TrackingVolume.hpp | 8 +++----- Core/include/Acts/Geometry/Volume.hpp | 19 +++++++++++++------ Core/src/Geometry/CylinderVolumeStack.cpp | 19 +++++++++---------- Core/src/Geometry/TrackingVolume.cpp | 8 +++----- Core/src/Geometry/Volume.cpp | 14 +++++++++++--- Examples/Python/src/Base.cpp | 9 ++++++--- Examples/Python/src/Geometry.cpp | 7 ++----- 8 files changed, 49 insertions(+), 39 deletions(-) diff --git a/Core/include/Acts/Geometry/CylinderVolumeStack.hpp b/Core/include/Acts/Geometry/CylinderVolumeStack.hpp index 4c83b6c0678..1f1eb748947 100644 --- a/Core/include/Acts/Geometry/CylinderVolumeStack.hpp +++ b/Core/include/Acts/Geometry/CylinderVolumeStack.hpp @@ -87,7 +87,7 @@ class CylinderVolumeStack : public Volume { /// @param transform is the new transform /// @pre The volume bounds need to be of type /// @c CylinderVolumeBounds. - void update(std::shared_ptr volbounds, + void update(std::shared_ptr volbounds, std::optional transform = std::nullopt) override; /// Update the volume bounds and transform. This @@ -100,7 +100,7 @@ class CylinderVolumeStack : public Volume { /// @param logger is the logger /// @pre The volume bounds need to be of type /// @c CylinderVolumeBounds. - void update(std::shared_ptr newBounds, + void update(std::shared_ptr newBounds, std::optional transform, const Logger& logger); /// Access the gap volume that were created during attachment or resizing. diff --git a/Core/include/Acts/Geometry/TrackingVolume.hpp b/Core/include/Acts/Geometry/TrackingVolume.hpp index 9cea4b8653c..a343f40bf2d 100644 --- a/Core/include/Acts/Geometry/TrackingVolume.hpp +++ b/Core/include/Acts/Geometry/TrackingVolume.hpp @@ -125,7 +125,7 @@ class TrackingVolume : public Volume { /// @param volbounds is the description of the volume boundaries /// @param volumeName is a string identifier TrackingVolume(const Transform3& transform, - std::shared_ptr volbounds, + std::shared_ptr volbounds, const std::string& volumeName = "undefined"); /// Constructor for a full equipped Tracking Volume @@ -140,8 +140,7 @@ class TrackingVolume : public Volume { /// @param denseVolumeVector The contained dense volumes /// @param volumeName is a string identifier TrackingVolume( - const Transform3& transform, - std::shared_ptr volumeBounds, + const Transform3& transform, std::shared_ptr volumeBounds, std::shared_ptr volumeMaterial, std::unique_ptr staticLayerArray = nullptr, std::shared_ptr containedVolumeArray = nullptr, @@ -151,8 +150,7 @@ class TrackingVolume : public Volume { /// Constructor from a regular volume /// @param volume is the volume to be converted /// @param volumeName is a string identifier - TrackingVolume(const Volume& volume, - const std::string& volumeName = "undefined"); + TrackingVolume(Volume& volume, const std::string& volumeName = "undefined"); // @TODO: This needs to be refactored to include Gen3 volumes /// Return the associated sub Volume, returns THIS if no subVolume exists diff --git a/Core/include/Acts/Geometry/Volume.hpp b/Core/include/Acts/Geometry/Volume.hpp index 3df0b339fd9..65e3e8b9219 100644 --- a/Core/include/Acts/Geometry/Volume.hpp +++ b/Core/include/Acts/Geometry/Volume.hpp @@ -37,8 +37,7 @@ class Volume : public GeometryObject { /// /// @param transform is the transform to position the volume in 3D space /// @param volbounds is the volume boundary definitions - Volume(const Transform3& transform, - std::shared_ptr volbounds); + Volume(const Transform3& transform, std::shared_ptr volbounds); /// Copy Constructor - with optional shift /// @@ -65,20 +64,26 @@ class Volume : public GeometryObject { /// returns the center of the volume const Vector3& center() const; - /// Returns const reference to the volume bounds + /// Returns a const reference to the volume bounds const VolumeBounds& volumeBounds() const; + /// Returns a mutable reference to the volume bounds + VolumeBounds& volumeBounds(); + /// Returns shared pointer to the volume bounds std::shared_ptr volumeBoundsPtr() const; + /// Returns shared pointer to the volume bounds + std::shared_ptr volumeBoundsPtr(); + /// Set volume bounds and update volume bounding boxes implicitly /// @param volbounds The volume bounds to be assigned - void assignVolumeBounds(std::shared_ptr volbounds); + void assignVolumeBounds(std::shared_ptr volbounds); /// Set the volume bounds and optionally also update the volume transform /// @param volbounds The volume bounds to be assigned /// @param transform The transform to be assigned, can be optional - virtual void update(std::shared_ptr volbounds, + virtual void update(std::shared_ptr volbounds, std::optional transform = std::nullopt); /// Construct bounding box for this shape @@ -117,7 +122,9 @@ class Volume : public GeometryObject { Transform3 m_transform; Transform3 m_itransform; Vector3 m_center; - std::shared_ptr m_volumeBounds; + + private: + std::shared_ptr m_volumeBounds; }; /**Overload of << operator for std::ostream for debug output*/ diff --git a/Core/src/Geometry/CylinderVolumeStack.cpp b/Core/src/Geometry/CylinderVolumeStack.cpp index b6c75afb54f..9b4f05fc43e 100644 --- a/Core/src/Geometry/CylinderVolumeStack.cpp +++ b/Core/src/Geometry/CylinderVolumeStack.cpp @@ -150,7 +150,7 @@ void CylinderVolumeStack::initializeOuterVolume(BinningValue direction, const auto* cylBounds = dynamic_cast( &m_volumes.front()->volumeBounds()); assert(cylBounds != nullptr && "Volume bounds are not cylinder bounds"); - m_volumeBounds = std::make_shared(*cylBounds); + Volume::update(std::make_shared(*cylBounds)); return; } @@ -211,8 +211,8 @@ void CylinderVolumeStack::initializeOuterVolume(BinningValue direction, m_transform = m_groupTransform * Translation3{0, 0, midZ}; - m_volumeBounds = std::make_shared(minR, maxR, hlZ); - ACTS_DEBUG("Outer bounds are:\n" << *m_volumeBounds); + Volume::update(std::make_shared(minR, maxR, hlZ)); + ACTS_DEBUG("Outer bounds are:\n" << volumeBounds()); ACTS_DEBUG("Outer transform / new group transform is:\n" << m_transform.matrix()); @@ -269,9 +269,9 @@ void CylinderVolumeStack::initializeOuterVolume(BinningValue direction, m_transform = m_groupTransform * Translation3{0, 0, midZ}; - m_volumeBounds = std::make_shared(minR, maxR, hlZ); + Volume::update(std::make_shared(minR, maxR, hlZ)); - ACTS_DEBUG("Outer bounds are:\n" << *m_volumeBounds); + ACTS_DEBUG("Outer bounds are:\n" << volumeBounds()); ACTS_DEBUG("Outer transform is:\n" << m_transform.matrix()); // Update group transform to the new center @@ -625,13 +625,12 @@ std::pair CylinderVolumeStack::synchronizeZBounds( return {minZ, maxZ}; } -void CylinderVolumeStack::update(std::shared_ptr volbounds, +void CylinderVolumeStack::update(std::shared_ptr volbounds, std::optional transform) { if (volbounds == nullptr) { throw std::invalid_argument("New bounds are nullptr"); } - auto cylBounds = - std::dynamic_pointer_cast(volbounds); + auto cylBounds = std::dynamic_pointer_cast(volbounds); if (cylBounds == nullptr) { throw std::invalid_argument( "CylinderVolumeStack requires CylinderVolumeBounds"); @@ -641,7 +640,7 @@ void CylinderVolumeStack::update(std::shared_ptr volbounds, } void CylinderVolumeStack::update( - std::shared_ptr newBounds, + std::shared_ptr newBounds, std::optional transform, const Logger& logger) { ACTS_DEBUG( "Resizing CylinderVolumeStack with strategy: " << m_resizeStrategy); @@ -934,7 +933,7 @@ void CylinderVolumeStack::update( } m_transform = newVolume.globalTransform; - m_volumeBounds = std::move(newBounds); + Volume::update(std::move(newBounds)); } void CylinderVolumeStack::checkNoPhiOrBevel(const CylinderVolumeBounds& bounds, diff --git a/Core/src/Geometry/TrackingVolume.cpp b/Core/src/Geometry/TrackingVolume.cpp index dcf9e93a0da..bbed048efdd 100644 --- a/Core/src/Geometry/TrackingVolume.cpp +++ b/Core/src/Geometry/TrackingVolume.cpp @@ -31,8 +31,7 @@ namespace Acts { // constructor for arguments TrackingVolume::TrackingVolume( - const Transform3& transform, - std::shared_ptr volumeBounds, + const Transform3& transform, std::shared_ptr volumeBounds, std::shared_ptr volumeMaterial, std::unique_ptr staticLayerArray, std::shared_ptr containedVolumeArray, @@ -49,14 +48,13 @@ TrackingVolume::TrackingVolume( connectDenseBoundarySurfaces(denseVolumeVector); } -TrackingVolume::TrackingVolume(const Volume& volume, - const std::string& volumeName) +TrackingVolume::TrackingVolume(Volume& volume, const std::string& volumeName) : TrackingVolume(volume.transform(), volume.volumeBoundsPtr(), nullptr, nullptr, nullptr, MutableTrackingVolumeVector{}, volumeName) {} TrackingVolume::TrackingVolume(const Transform3& transform, - std::shared_ptr volbounds, + std::shared_ptr volbounds, const std::string& volumeName) : TrackingVolume(transform, std::move(volbounds), nullptr, nullptr, nullptr, {}, volumeName) {} diff --git a/Core/src/Geometry/Volume.cpp b/Core/src/Geometry/Volume.cpp index 79dcf5598dc..a04cab7b6f7 100644 --- a/Core/src/Geometry/Volume.cpp +++ b/Core/src/Geometry/Volume.cpp @@ -19,7 +19,7 @@ using namespace Acts::UnitLiterals; namespace Acts { Volume::Volume(const Transform3& transform, - std::shared_ptr volbounds) + std::shared_ptr volbounds) : GeometryObject(), m_transform(transform), m_itransform(m_transform.inverse()), @@ -74,11 +74,11 @@ Volume::BoundingBox Volume::orientedBoundingBox() const { this); } -void Volume::assignVolumeBounds(std::shared_ptr volbounds) { +void Volume::assignVolumeBounds(std::shared_ptr volbounds) { update(std::move(volbounds)); } -void Volume::update(std::shared_ptr volbounds, +void Volume::update(std::shared_ptr volbounds, std::optional transform) { if (volbounds) { m_volumeBounds = std::move(volbounds); @@ -104,10 +104,18 @@ const VolumeBounds& Volume::volumeBounds() const { return *m_volumeBounds; } +VolumeBounds& Volume::volumeBounds() { + return *m_volumeBounds; +} + std::shared_ptr Volume::volumeBoundsPtr() const { return m_volumeBounds; } +std::shared_ptr Volume::volumeBoundsPtr() { + return m_volumeBounds; +} + void Volume::setTransform(const Transform3& transform) { m_transform = transform; m_itransform = m_transform.inverse(); diff --git a/Examples/Python/src/Base.cpp b/Examples/Python/src/Base.cpp index b6582c15d1f..aae48a6a3b4 100644 --- a/Examples/Python/src/Base.cpp +++ b/Examples/Python/src/Base.cpp @@ -297,9 +297,12 @@ void addAlgebra(Acts::Python::Context& ctx) { Acts::Vector3(translation[0], translation[1], translation[2])); return t; })) - .def("getTranslation", [](const Acts::Transform3& self) { - return Vector3(self.translation()); - }); + .def("getTranslation", + [](const Acts::Transform3& self) { + return Vector3(self.translation()); + }) + .def_static("Identity", &Acts::Transform3::Identity); + ; } void addBinning(Context& ctx) { diff --git a/Examples/Python/src/Geometry.cpp b/Examples/Python/src/Geometry.cpp index 114e54e29a5..4f4752aa4ef 100644 --- a/Examples/Python/src/Geometry.cpp +++ b/Examples/Python/src/Geometry.cpp @@ -189,11 +189,8 @@ void addGeometry(Context& ctx) { py::class_>(m, "TrackingVolume") - .def(py::init([](std::shared_ptr bounds, - std::string name) { - return std::make_shared(Transform3::Identity(), - bounds, name); - })); + .def(py::init, + std::string>()); } { From 74d9aa24653027858659e28f3e6f0275cf799d6c Mon Sep 17 00:00:00 2001 From: "Alexander J. Pfleger" <70842573+AJPfleger@users.noreply.github.com> Date: Mon, 9 Sep 2024 19:47:39 +0200 Subject: [PATCH 05/12] refactor!: path handling to use `std::filesystem` (#3308) Switch to using `std::filesystem` for path operations to modernize code and improve readability. --- .../Acts/Visualization/GeometryView3D.hpp | 20 ++--- .../Acts/Visualization/IVisualization3D.hpp | 22 +----- .../Acts/Visualization/ObjVisualization3D.hpp | 7 +- .../Acts/Visualization/PlyVisualization3D.hpp | 7 +- .../include/Acts/Visualization/ViewConfig.hpp | 5 +- .../detail/ObjVisualization3D.ipp | 23 +++--- .../detail/PlyVisualization3D.ipp | 12 +-- Core/src/Visualization/CMakeLists.txt | 5 +- Core/src/Visualization/GeometryView3D.cpp | 77 ++++++------------- Core/src/Visualization/IVisualization3D.cpp | 23 ------ .../Io/Obj/src/ObjTrackingGeometryWriter.cpp | 6 +- 11 files changed, 73 insertions(+), 134 deletions(-) delete mode 100644 Core/src/Visualization/IVisualization3D.cpp diff --git a/Core/include/Acts/Visualization/GeometryView3D.hpp b/Core/include/Acts/Visualization/GeometryView3D.hpp index 0243e8e58ad..f1abba71424 100644 --- a/Core/include/Acts/Visualization/GeometryView3D.hpp +++ b/Core/include/Acts/Visualization/GeometryView3D.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) 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 @@ -14,6 +14,7 @@ #include "Acts/Visualization/IVisualization3D.hpp" #include "Acts/Visualization/ViewConfig.hpp" +#include #include namespace Acts { @@ -75,7 +76,7 @@ struct GeometryView3D { const ViewConfig& sensitiveConfig = s_viewSensitive, const ViewConfig& passiveConfig = s_viewPassive, const ViewConfig& gridConfig = s_viewGrid, - const std::string& outputDir = "."); + const std::filesystem::path& outputDir = std::filesystem::path(".")); /// Helper method to draw Volume objects /// @@ -132,12 +133,12 @@ struct GeometryView3D { /// @param sensitiveConfig The drawing configuration for sensitive surfaces /// @param gridConfig The drawing configuration for grid display /// @param outputDir Directory to write to - static void drawLayer(IVisualization3D& helper, const Layer& layer, - const GeometryContext& gctx, - const ViewConfig& layerConfig = s_viewPassive, - const ViewConfig& sensitiveConfig = s_viewSensitive, - const ViewConfig& gridConfig = s_viewGrid, - const std::string& outputDir = "."); + static void drawLayer( + IVisualization3D& helper, const Layer& layer, const GeometryContext& gctx, + const ViewConfig& layerConfig = s_viewPassive, + const ViewConfig& sensitiveConfig = s_viewSensitive, + const ViewConfig& gridConfig = s_viewGrid, + const std::filesystem::path& outputDir = std::filesystem::path(".")); /// Helper method to draw TrackingVolume objects /// @@ -161,7 +162,8 @@ struct GeometryView3D { const ViewConfig& layerView = s_viewPassive, const ViewConfig& sensitiveView = s_viewSensitive, const ViewConfig& gridView = s_viewGrid, bool writeIt = true, - const std::string& tag = "", const std::string& outputDir = "."); + const std::string& tag = "", + const std::filesystem::path& outputDir = std::filesystem::path(".")); /// Helper method to draw lines - base for all lines /// diff --git a/Core/include/Acts/Visualization/IVisualization3D.hpp b/Core/include/Acts/Visualization/IVisualization3D.hpp index 6daf34c4e2f..96af6328979 100644 --- a/Core/include/Acts/Visualization/IVisualization3D.hpp +++ b/Core/include/Acts/Visualization/IVisualization3D.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 @@ -13,6 +13,7 @@ #include #include +#include #include #include #include @@ -67,28 +68,11 @@ class IVisualization3D { /// Write the content of the helper to an outstream. /// @param path is the file system path for writing the file - /// @note will change to std::filesystem::path once gcc9 is standard - virtual void write(const std::string& path) const = 0; + virtual void write(const std::filesystem::path& path) const = 0; /// Remove all contents of this helper /// virtual void clear() = 0; - - protected: - /// Helper: check for extension - /// - /// @note this is a placeholder for std::filesystem::has_extension - /// which needs special linking until gcc9 - /// @param path the path to be checked - bool hasExtension(const std::string& path) const; - - /// Helper: replace the extension - /// - /// @note this is a placeholder for std::filesystem::replace_extension - /// which needs special linking until gcc9 - /// @param path [in,out] the path to be changed - /// @param suffix the extension to be added - void replaceExtension(std::string& path, const std::string& suffix) const; }; /// Overload of the << operator to facilitate writing to streams. diff --git a/Core/include/Acts/Visualization/ObjVisualization3D.hpp b/Core/include/Acts/Visualization/ObjVisualization3D.hpp index a915ecadee8..79da56d3e9c 100644 --- a/Core/include/Acts/Visualization/ObjVisualization3D.hpp +++ b/Core/include/Acts/Visualization/ObjVisualization3D.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 @@ -13,6 +13,7 @@ #include "Acts/Visualization/ViewConfig.hpp" #include +#include #include #include #include @@ -61,8 +62,8 @@ class ObjVisualization3D : public IVisualization3D { const std::vector& faces, ColorRGB color = {0, 0, 0}) final; - /// @copydoc Acts::IVisualization3D::write(const std::string&) const - void write(const std::string& path) const final; + /// @copydoc Acts::IVisualization3D::write(const std::filesystem::path&) const + void write(const std::filesystem::path& path) const final; /// @copydoc Acts::IVisualization3D::write(std::ostream&) const void write(std::ostream& os) const final; diff --git a/Core/include/Acts/Visualization/PlyVisualization3D.hpp b/Core/include/Acts/Visualization/PlyVisualization3D.hpp index b28783a0bcd..95f2fdacd28 100644 --- a/Core/include/Acts/Visualization/PlyVisualization3D.hpp +++ b/Core/include/Acts/Visualization/PlyVisualization3D.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 @@ -13,6 +13,7 @@ #include "Acts/Visualization/ViewConfig.hpp" #include +#include #include #include #include @@ -50,8 +51,8 @@ class PlyVisualization3D : public IVisualization3D { void line(const Vector3& a, const Vector3& b, ColorRGB color = {120, 120, 120}) final; - /// @copydoc Acts::IVisualization3D::write(const std::string&) const - void write(const std::string& path) const final; + /// @copydoc Acts::IVisualization3D::write(const std::filesystem::path&) const + void write(const std::filesystem::path& path) const final; /// @copydoc Acts::IVisualization3D::write(std::ostream&) const void write(std::ostream& os) const final; diff --git a/Core/include/Acts/Visualization/ViewConfig.hpp b/Core/include/Acts/Visualization/ViewConfig.hpp index 06c4f7a675b..7e6e70dbdcc 100644 --- a/Core/include/Acts/Visualization/ViewConfig.hpp +++ b/Core/include/Acts/Visualization/ViewConfig.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) 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 @@ -9,6 +9,7 @@ #pragma once #include +#include #include namespace Acts { @@ -42,7 +43,7 @@ struct ViewConfig { /// Whether to triangulate or not bool triangulate = false; /// Write name - non-empty string indicates writing - std::string outputName = ""; + std::filesystem::path outputName = std::filesystem::path(""); }; } // namespace Acts diff --git a/Core/include/Acts/Visualization/detail/ObjVisualization3D.ipp b/Core/include/Acts/Visualization/detail/ObjVisualization3D.ipp index 51a0854b85e..e43bbb11f19 100644 --- a/Core/include/Acts/Visualization/detail/ObjVisualization3D.ipp +++ b/Core/include/Acts/Visualization/detail/ObjVisualization3D.ipp @@ -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 @@ -69,18 +69,21 @@ void ObjVisualization3D::faces(const std::vector& vtxs, } template -void ObjVisualization3D::write(const std::string& path) const { +void ObjVisualization3D::write(const std::filesystem::path& path) const { std::ofstream os; - std::string objectpath = path; - if (!IVisualization3D::hasExtension(objectpath)) { - objectpath += std::string(".obj"); + std::filesystem::path objectpath = path; + if (!objectpath.has_extension()) { + objectpath.replace_extension(std::filesystem::path("obj")); } - os.open(objectpath); - std::string mtlpath = objectpath; - IVisualization3D::replaceExtension(mtlpath, ".mtl"); - os << "mtllib " << mtlpath << "\n"; + os.open(std::filesystem::absolute(objectpath).string()); + std::filesystem::path mtlpath = objectpath; + mtlpath.replace_extension(std::filesystem::path("mtl")); + + const std::string mtlpathString = std::filesystem::absolute(mtlpath).string(); + os << "mtllib " << mtlpathString << "\n"; std::ofstream mtlos; - mtlos.open(mtlpath); + mtlos.open(mtlpathString); + write(os, mtlos); os.close(); mtlos.close(); diff --git a/Core/include/Acts/Visualization/detail/PlyVisualization3D.ipp b/Core/include/Acts/Visualization/detail/PlyVisualization3D.ipp index b97dbde0fc9..c5c12b2dc89 100644 --- a/Core/include/Acts/Visualization/detail/PlyVisualization3D.ipp +++ b/Core/include/Acts/Visualization/detail/PlyVisualization3D.ipp @@ -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,13 +41,13 @@ void PlyVisualization3D::line(const Vector3& a, const Vector3& b, } template -void PlyVisualization3D::write(const std::string& path) const { +void PlyVisualization3D::write(const std::filesystem::path& path) const { std::ofstream os; - std::string objectpath = path; - if (!IVisualization3D::hasExtension(path)) { - objectpath += std::string(".ply"); + std::filesystem::path objectpath = path; + if (!objectpath.has_extension()) { + objectpath.replace_extension(std::filesystem::path("ply")); } - os.open(objectpath); + os.open(std::filesystem::absolute(objectpath).string()); write(os); os.close(); } diff --git a/Core/src/Visualization/CMakeLists.txt b/Core/src/Visualization/CMakeLists.txt index ea2bd2427e6..5d4f916af1c 100644 --- a/Core/src/Visualization/CMakeLists.txt +++ b/Core/src/Visualization/CMakeLists.txt @@ -1,4 +1 @@ -target_sources( - ActsCore - PRIVATE IVisualization3D.cpp GeometryView3D.cpp EventDataView3D.cpp -) +target_sources(ActsCore PRIVATE GeometryView3D.cpp EventDataView3D.cpp) diff --git a/Core/src/Visualization/GeometryView3D.cpp b/Core/src/Visualization/GeometryView3D.cpp index 93f45c4e91d..14923b66a50 100644 --- a/Core/src/Visualization/GeometryView3D.cpp +++ b/Core/src/Visualization/GeometryView3D.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 @@ -34,36 +34,12 @@ #include #include +#include #include #include #include #include -#include -#include - -namespace { - -std::string joinPaths(const std::string& a, const std::string& b) { - if (b.substr(0, 1) == "/" || a.empty()) { - return b; - } - - if (a.substr(a.size() - 1) == "/") { - return a.substr(a.size() - 1) + "/" + b; - } - - return a + "/" + b; -} - -std::string getWorkingDirectory() { - char buffer[PATH_MAX]; - return (getcwd(buffer, sizeof(buffer)) != nullptr ? std::string(buffer) - : std::string("")); -} - -} // namespace - namespace Acts::Experimental { ViewConfig s_viewSensitive = ViewConfig({0, 180, 240}); ViewConfig s_viewPassive = ViewConfig({240, 280, 0}); @@ -102,9 +78,7 @@ void Acts::GeometryView3D::drawSurfaceArray( IVisualization3D& helper, const SurfaceArray& surfaceArray, const GeometryContext& gctx, const Transform3& transform, const ViewConfig& sensitiveConfig, const ViewConfig& passiveConfig, - const ViewConfig& gridConfig, const std::string& _outputDir) { - std::string outputDir = - _outputDir == "." ? getWorkingDirectory() : _outputDir; + const ViewConfig& gridConfig, const std::filesystem::path& outputDir) { // Draw all the surfaces Extent arrayExtent; for (const auto& sf : surfaceArray.surfaces()) { @@ -117,7 +91,7 @@ void Acts::GeometryView3D::drawSurfaceArray( } if (!sensitiveConfig.outputName.empty()) { - helper.write(joinPaths(outputDir, sensitiveConfig.outputName)); + helper.write(outputDir / sensitiveConfig.outputName); helper.clear(); } @@ -181,7 +155,7 @@ void Acts::GeometryView3D::drawSurfaceArray( } if (!gridConfig.outputName.empty()) { - helper.write(joinPaths(outputDir, gridConfig.outputName)); + helper.write(outputDir / gridConfig.outputName); helper.clear(); } } @@ -239,10 +213,7 @@ void Acts::GeometryView3D::drawDetectorVolume( void Acts::GeometryView3D::drawLayer( IVisualization3D& helper, const Layer& layer, const GeometryContext& gctx, const ViewConfig& layerConfig, const ViewConfig& sensitiveConfig, - const ViewConfig& gridConfig, const std::string& _outputDir) { - std::string outputDir = - _outputDir == "." ? getWorkingDirectory() : _outputDir; - + const ViewConfig& gridConfig, const std::filesystem::path& outputDir) { if (layerConfig.visible) { auto layerVolume = layer.representingVolume(); if (layerVolume != nullptr) { @@ -254,7 +225,7 @@ void Acts::GeometryView3D::drawLayer( layerConfig); } if (!layerConfig.outputName.empty()) { - helper.write(joinPaths(outputDir, layerConfig.outputName)); + helper.write(outputDir / layerConfig.outputName); helper.clear(); } } @@ -273,9 +244,7 @@ void Acts::GeometryView3D::drawTrackingVolume( const GeometryContext& gctx, const ViewConfig& containerView, const ViewConfig& volumeView, const ViewConfig& layerView, const ViewConfig& sensitiveView, const ViewConfig& gridView, bool writeIt, - const std::string& tag, const std::string& _outputDir) { - std::string outputDir = - _outputDir == "." ? getWorkingDirectory() : _outputDir; + const std::string& tag, const std::filesystem::path& outputDir) { if (tVolume.confinedVolumes() != nullptr) { const auto& subVolumes = tVolume.confinedVolumes()->arrayObjects(); for (const auto& tv : subVolumes) { @@ -303,10 +272,9 @@ void Acts::GeometryView3D::drawTrackingVolume( } if (tVolume.confinedVolumes() == nullptr) { vcConfig = vConfig; - vcConfig.outputName = vname + std::string("_boundaries") + tag; + vcConfig.outputName = + std::filesystem::path(vname + std::string("_boundaries") + tag); } else { - std::stringstream vs; - vs << "Container"; std::vector ids{tVolume.geometryId().volume()}; for (const auto* current = &tVolume; current->motherVolume() != nullptr; @@ -314,11 +282,14 @@ void Acts::GeometryView3D::drawTrackingVolume( ids.push_back(current->motherVolume()->geometryId().volume()); } - for (std::size_t i = ids.size() - 1; i < ids.size(); --i) { - vs << "_v" << ids[i]; + std::ranges::reverse(ids); + vname = "Container"; + for (const auto& id : ids) { + vname += "_v" + std::to_string(id); } - vname = vs.str(); - vcConfig.outputName = vname + std::string("_boundaries") + tag; + + vcConfig.outputName = + std::filesystem::path(vname + std::string("_boundaries") + tag); } } @@ -328,7 +299,7 @@ void Acts::GeometryView3D::drawTrackingVolume( Transform3::Identity(), vcConfig); } if (writeIt) { - std::string outputName = joinPaths(outputDir, vcConfig.outputName); + const std::filesystem::path outputName = outputDir / vcConfig.outputName; helper.write(outputName); helper.clear(); } @@ -338,12 +309,12 @@ void Acts::GeometryView3D::drawTrackingVolume( std::size_t il = 0; for (const auto& tl : layers) { if (writeIt) { - lConfig.outputName = - vname + std::string("_passives_l") + std::to_string(il) + tag; - sConfig.outputName = - vname + std::string("_sensitives_l") + std::to_string(il) + tag; - gConfig.outputName = - vname + std::string("_grids_l") + std::to_string(il) + tag; + lConfig.outputName = std::filesystem::path( + vname + std::string("_passives_l") + std::to_string(il) + tag); + sConfig.outputName = std::filesystem::path( + vname + std::string("_sensitives_l") + std::to_string(il) + tag); + gConfig.outputName = std::filesystem::path( + vname + std::string("_grids_l") + std::to_string(il) + tag); } drawLayer(helper, *tl, gctx, lConfig, sConfig, gConfig, outputDir); ++il; diff --git a/Core/src/Visualization/IVisualization3D.cpp b/Core/src/Visualization/IVisualization3D.cpp deleted file mode 100644 index aad131a156d..00000000000 --- a/Core/src/Visualization/IVisualization3D.cpp +++ /dev/null @@ -1,23 +0,0 @@ -// This file is part of the Acts project. -// -// Copyright (C) 2020 CERN for the benefit of the Acts project -// -// This Source Code Form is subject to the terms of the Mozilla Public -// License, v. 2.0. If a copy of the MPL was not distributed with this -// file, You can obtain one at http://mozilla.org/MPL/2.0/. - -#include "Acts/Visualization/IVisualization3D.hpp" - -bool Acts::IVisualization3D::hasExtension(const std::string& path) const { - return (path.find(".") != std::string::npos); -} - -void Acts::IVisualization3D::replaceExtension(std::string& path, - const std::string& suffix) const { - auto ppoint = path.find_last_of("."); - if (ppoint != std::string::npos) { - path.replace(ppoint, path.length(), suffix); - } else { - path += suffix; - } -} diff --git a/Examples/Io/Obj/src/ObjTrackingGeometryWriter.cpp b/Examples/Io/Obj/src/ObjTrackingGeometryWriter.cpp index 707add19bfd..a0f4948a1ff 100644 --- a/Examples/Io/Obj/src/ObjTrackingGeometryWriter.cpp +++ b/Examples/Io/Obj/src/ObjTrackingGeometryWriter.cpp @@ -1,6 +1,6 @@ // This file is part of the Acts project. // -// Copyright (C) 2017 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 @@ -14,6 +14,8 @@ #include #include +#include + ActsExamples::ObjTrackingGeometryWriter::ObjTrackingGeometryWriter( const ActsExamples::ObjTrackingGeometryWriter::Config& config, Acts::Logging::Level level) @@ -43,5 +45,5 @@ void ActsExamples::ObjTrackingGeometryWriter::write( Acts::GeometryView3D::drawTrackingVolume( objVis, tVolume, context.geoContext, m_cfg.containerView, m_cfg.volumeView, m_cfg.passiveView, m_cfg.sensitiveView, m_cfg.gridView, - true, "", m_cfg.outputDir); + true, "", std::filesystem::path(m_cfg.outputDir)); } From 13199a21c173193e83304f0dd96456a200b316a1 Mon Sep 17 00:00:00 2001 From: Andreas Stefl Date: Mon, 9 Sep 2024 21:16:17 +0200 Subject: [PATCH 06/12] refactor!: Replace `EigenStepper` extension list with single extension (#2865) Since we always only use one extension in the stepper and there are cases where it is beneficial to only worry about the state of a single extension I propose to remove the `Auctioneer` and the `StepperExtensionList`. This came up during working on the implementation of the covariance transport where our two default extensions would have to interact via state in the `EigenStepper` which is rather a mess. My proposed solution would move the state consistently to the extension. **issues** - https://github.com/acts-project/acts/issues/2868 --- Core/include/Acts/Propagator/EigenStepper.hpp | 22 +- Core/include/Acts/Propagator/EigenStepper.ipp | 128 +++++----- ...n.hpp => EigenStepperDefaultExtension.hpp} | 30 +-- ...EigenStepperDenseEnvironmentExtension.hpp} | 96 +++----- .../Acts/Propagator/MultiEigenStepperLoop.hpp | 23 +- .../Acts/Propagator/MultiEigenStepperLoop.ipp | 14 +- .../Acts/Propagator/StepperExtensionList.hpp | 232 ------------------ .../Acts/Propagator/detail/Auctioneer.hpp | 108 -------- .../TrackFitting/src/GsfFitterFunction.cpp | 9 +- .../PropagationDenseConstant.cpp | 7 +- .../Core/Propagator/AuctioneerTests.cpp | 52 ---- .../UnitTests/Core/Propagator/CMakeLists.txt | 1 - .../Core/Propagator/EigenStepperTests.cpp | 52 ++-- .../Core/Propagator/MultiStepperTests.cpp | 11 +- .../Core/Propagator/PropagatorTests.cpp | 8 +- .../Core/Propagator/SympyStepperTests.cpp | 4 - docs/core/propagation.md | 17 +- 17 files changed, 168 insertions(+), 646 deletions(-) rename Core/include/Acts/Propagator/{DefaultExtension.hpp => EigenStepperDefaultExtension.hpp} (91%) rename Core/include/Acts/Propagator/{DenseEnvironmentExtension.hpp => EigenStepperDenseEnvironmentExtension.hpp} (89%) delete mode 100644 Core/include/Acts/Propagator/StepperExtensionList.hpp delete mode 100644 Core/include/Acts/Propagator/detail/Auctioneer.hpp delete mode 100644 Tests/UnitTests/Core/Propagator/AuctioneerTests.cpp diff --git a/Core/include/Acts/Propagator/EigenStepper.hpp b/Core/include/Acts/Propagator/EigenStepper.hpp index f1c9f2995eb..52126c46fba 100644 --- a/Core/include/Acts/Propagator/EigenStepper.hpp +++ b/Core/include/Acts/Propagator/EigenStepper.hpp @@ -1,6 +1,6 @@ // This file is part of the Acts project. // -// Copyright (C) 2016-2022 CERN for the benefit of the Acts project +// Copyright (C) 2016-2024 CERN for the benefit of the Acts project // // This Source Code Form is subject to the terms of the Mozilla Public // License, v. 2.0. If a copy of the MPL was not distributed with this @@ -15,20 +15,18 @@ #include "Acts/Definitions/Tolerance.hpp" #include "Acts/Definitions/Units.hpp" #include "Acts/EventData/TrackParameters.hpp" +#include "Acts/EventData/detail/CorrectedTransformationFreeToBound.hpp" +#include "Acts/Geometry/GeometryContext.hpp" +#include "Acts/MagneticField/MagneticFieldContext.hpp" #include "Acts/MagneticField/MagneticFieldProvider.hpp" #include "Acts/Propagator/ConstrainedStep.hpp" -#include "Acts/Propagator/DefaultExtension.hpp" -#include "Acts/Propagator/DenseEnvironmentExtension.hpp" -#include "Acts/Propagator/EigenStepperError.hpp" +#include "Acts/Propagator/EigenStepperDefaultExtension.hpp" #include "Acts/Propagator/PropagatorTraits.hpp" -#include "Acts/Propagator/StepperExtensionList.hpp" #include "Acts/Propagator/StepperOptions.hpp" -#include "Acts/Propagator/detail/Auctioneer.hpp" #include "Acts/Propagator/detail/SteppingHelper.hpp" #include "Acts/Utilities/Intersection.hpp" #include "Acts/Utilities/Result.hpp" -#include #include #include #include @@ -47,8 +45,7 @@ namespace Acts { /// with s being the arc length of the track, q the charge of the particle, /// p the momentum magnitude and B the magnetic field /// -template , - typename auctioneer_t = detail::VoidAuctioneer> +template class EigenStepper { public: /// Jacobian, Covariance and State definitions @@ -155,11 +152,8 @@ class EigenStepper { /// The geometry context std::reference_wrapper geoContext; - /// List of algorithmic extensions - extensionlist_t extension; - - /// Auctioneer for choosing the extension - auctioneer_t auctioneer; + /// Algorithmic extension + extension_t extension; /// @brief Storage of magnetic field and the sub steps during a RKN4 step struct { diff --git a/Core/include/Acts/Propagator/EigenStepper.ipp b/Core/include/Acts/Propagator/EigenStepper.ipp index eb693a9148a..71aa342ed12 100644 --- a/Core/include/Acts/Propagator/EigenStepper.ipp +++ b/Core/include/Acts/Propagator/EigenStepper.ipp @@ -1,6 +1,6 @@ // This file is part of the Acts project. // -// Copyright (C) 2019-2022 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 @@ -8,30 +8,31 @@ #include "Acts/EventData/TransformationHelpers.hpp" #include "Acts/Propagator/ConstrainedStep.hpp" +#include "Acts/Propagator/EigenStepperError.hpp" #include "Acts/Propagator/detail/CovarianceEngine.hpp" #include "Acts/Utilities/QuickMath.hpp" #include -template -Acts::EigenStepper::EigenStepper( +template +Acts::EigenStepper::EigenStepper( std::shared_ptr bField) : m_bField(std::move(bField)) {} -template -auto Acts::EigenStepper::makeState( +template +auto Acts::EigenStepper::makeState( std::reference_wrapper gctx, std::reference_wrapper mctx, const BoundTrackParameters& par, double ssize) const -> State { return State{gctx, m_bField->makeCache(mctx), par, ssize}; } -template -void Acts::EigenStepper::resetState(State& state, - const BoundVector& boundParams, - const BoundSquareMatrix& cov, - const Surface& surface, - const double stepSize) const { +template +void Acts::EigenStepper::resetState(State& state, + const BoundVector& boundParams, + const BoundSquareMatrix& cov, + const Surface& surface, + const double stepSize) const { FreeVector freeParams = transformBoundToFreeParameters(surface, state.geoContext, boundParams); @@ -50,8 +51,8 @@ void Acts::EigenStepper::resetState(State& state, state.derivative = FreeVector::Zero(); } -template -auto Acts::EigenStepper::boundState( +template +auto Acts::EigenStepper::boundState( State& state, const Surface& surface, bool transportCov, const FreeToBoundCorrection& freeToBoundCorrection) const -> Result { @@ -62,36 +63,32 @@ auto Acts::EigenStepper::boundState( freeToBoundCorrection); } -template +template template -bool Acts::EigenStepper::prepareCurvilinearState( +bool Acts::EigenStepper::prepareCurvilinearState( propagator_state_t& prop_state, const navigator_t& navigator) const { // test whether the accumulated path has still its initial value. if (prop_state.stepping.pathAccumulated == 0.) { // if no step was executed the path length derivates have not been // computed but are needed to compute the curvilinear covariance. The // derivates are given by k1 for a zero step width. - if (prop_state.stepping.extension.validExtensionForStep(prop_state, *this, - navigator)) { - // First Runge-Kutta point (at current position) - auto& sd = prop_state.stepping.stepData; - auto pos = position(prop_state.stepping); - auto fieldRes = getField(prop_state.stepping, pos); - if (fieldRes.ok()) { - sd.B_first = *fieldRes; - if (prop_state.stepping.extension.k1(prop_state, *this, navigator, - sd.k1, sd.B_first, sd.kQoP)) { - // dr/ds : - prop_state.stepping.derivative.template head<3>() = - prop_state.stepping.pars.template segment<3>(eFreeDir0); - // d (dr/ds) / ds : - prop_state.stepping.derivative.template segment<3>(4) = sd.k1; - // to set dt/ds : - prop_state.stepping.extension.finalize( - prop_state, *this, navigator, - prop_state.stepping.pathAccumulated); - return true; - } + // First Runge-Kutta point (at current position) + auto& sd = prop_state.stepping.stepData; + auto pos = position(prop_state.stepping); + auto fieldRes = getField(prop_state.stepping, pos); + if (fieldRes.ok()) { + sd.B_first = *fieldRes; + if (prop_state.stepping.extension.template k<0>( + prop_state, *this, navigator, sd.k1, sd.B_first, sd.kQoP)) { + // dr/ds : + prop_state.stepping.derivative.template head<3>() = + prop_state.stepping.pars.template segment<3>(eFreeDir0); + // d (dr/ds) / ds : + prop_state.stepping.derivative.template segment<3>(4) = sd.k1; + // to set dt/ds : + prop_state.stepping.extension.finalize( + prop_state, *this, navigator, prop_state.stepping.pathAccumulated); + return true; } } return false; @@ -99,8 +96,8 @@ bool Acts::EigenStepper::prepareCurvilinearState( return true; } -template -auto Acts::EigenStepper::curvilinearState( +template +auto Acts::EigenStepper::curvilinearState( State& state, bool transportCov) const -> CurvilinearState { return detail::curvilinearState( state.cov, state.jacobian, state.jacTransport, state.derivative, @@ -108,12 +105,11 @@ auto Acts::EigenStepper::curvilinearState( state.covTransport && transportCov, state.pathAccumulated); } -template -void Acts::EigenStepper::update(State& state, - const FreeVector& freeParams, - const BoundVector& /*boundParams*/, - const Covariance& covariance, - const Surface& surface) const { +template +void Acts::EigenStepper::update(State& state, const FreeVector& freeParams, + const BoundVector& /*boundParams*/, + const Covariance& covariance, + const Surface& surface) const { state.pars = freeParams; state.cov = covariance; state.jacToGlobal = surface.boundToFreeJacobian( @@ -121,26 +117,26 @@ void Acts::EigenStepper::update(State& state, freeParams.template segment<3>(eFreeDir0)); } -template -void Acts::EigenStepper::update(State& state, const Vector3& uposition, - const Vector3& udirection, double qOverP, - double time) const { +template +void Acts::EigenStepper::update(State& state, const Vector3& uposition, + const Vector3& udirection, double qOverP, + double time) const { state.pars.template segment<3>(eFreePos0) = uposition; state.pars.template segment<3>(eFreeDir0) = udirection; state.pars[eFreeTime] = time; state.pars[eFreeQOverP] = qOverP; } -template -void Acts::EigenStepper::transportCovarianceToCurvilinear( +template +void Acts::EigenStepper::transportCovarianceToCurvilinear( State& state) const { detail::transportCovarianceToCurvilinear(state.cov, state.jacobian, state.jacTransport, state.derivative, state.jacToGlobal, direction(state)); } -template -void Acts::EigenStepper::transportCovarianceToBound( +template +void Acts::EigenStepper::transportCovarianceToBound( State& state, const Surface& surface, const FreeToBoundCorrection& freeToBoundCorrection) const { detail::transportCovarianceToBound(state.geoContext.get(), surface, state.cov, @@ -149,9 +145,9 @@ void Acts::EigenStepper::transportCovarianceToBound( state.pars, freeToBoundCorrection); } -template +template template -Acts::Result Acts::EigenStepper::step( +Acts::Result Acts::EigenStepper::step( propagator_state_t& state, const navigator_t& navigator) const { // Runge-Kutta integrator state auto& sd = state.stepping.stepData; @@ -169,10 +165,8 @@ Acts::Result Acts::EigenStepper::step( return fieldRes.error(); } sd.B_first = *fieldRes; - if (!state.stepping.extension.validExtensionForStep(state, *this, - navigator) || - !state.stepping.extension.k1(state, *this, navigator, sd.k1, sd.B_first, - sd.kQoP)) { + if (!state.stepping.extension.template k<0>(state, *this, navigator, sd.k1, + sd.B_first, sd.kQoP)) { return 0.; } @@ -230,14 +224,16 @@ Acts::Result Acts::EigenStepper::step( } sd.B_middle = *field; - if (!state.stepping.extension.k2(state, *this, navigator, sd.k2, - sd.B_middle, sd.kQoP, half_h, sd.k1)) { + if (!state.stepping.extension.template k<1>(state, *this, navigator, sd.k2, + sd.B_middle, sd.kQoP, half_h, + sd.k1)) { return success(false); } // Third Runge-Kutta point - if (!state.stepping.extension.k3(state, *this, navigator, sd.k3, - sd.B_middle, sd.kQoP, half_h, sd.k2)) { + if (!state.stepping.extension.template k<2>(state, *this, navigator, sd.k3, + sd.B_middle, sd.kQoP, half_h, + sd.k2)) { return success(false); } @@ -248,8 +244,8 @@ Acts::Result Acts::EigenStepper::step( return failure(field.error()); } sd.B_last = *field; - if (!state.stepping.extension.k4(state, *this, navigator, sd.k4, sd.B_last, - sd.kQoP, h, sd.k3)) { + if (!state.stepping.extension.template k<3>(state, *this, navigator, sd.k4, + sd.B_last, sd.kQoP, h, sd.k3)) { return success(false); } @@ -373,7 +369,7 @@ Acts::Result Acts::EigenStepper::step( return h; } -template -void Acts::EigenStepper::setIdentityJacobian(State& state) const { +template +void Acts::EigenStepper::setIdentityJacobian(State& state) const { state.jacobian = BoundMatrix::Identity(); } diff --git a/Core/include/Acts/Propagator/DefaultExtension.hpp b/Core/include/Acts/Propagator/EigenStepperDefaultExtension.hpp similarity index 91% rename from Core/include/Acts/Propagator/DefaultExtension.hpp rename to Core/include/Acts/Propagator/EigenStepperDefaultExtension.hpp index 1ae901f42eb..cf6cadbbb41 100644 --- a/Core/include/Acts/Propagator/DefaultExtension.hpp +++ b/Core/include/Acts/Propagator/EigenStepperDefaultExtension.hpp @@ -1,6 +1,6 @@ // This file is part of the Acts project. // -// Copyright (C) 2018-2023 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 @@ -18,28 +18,15 @@ namespace Acts { /// @brief Default evaluater of the k_i's and elements of the transport matrix /// D of the RKN4 stepping. This is a pure implementation by textbook. -struct DefaultExtension { +struct EigenStepperDefaultExtension { using Scalar = ActsScalar; /// @brief Vector3 replacement for the custom scalar type using ThisVector3 = Eigen::Matrix; - /// @brief Control function if the step evaluation would be valid - /// - /// @tparam propagator_state_t Type of the state of the propagator - /// @tparam stepper_t Type of the stepper - /// @tparam navigator_t Type of the navigator - /// - /// @return Boolean flag if the step would be valid - template - int bid(const propagator_state_t& /*state*/, const stepper_t& /*stepper*/, - const navigator_t& /*navigator*/) const { - return 1; - } - /// @brief Evaluater of the k_i's of the RKN4. For the case of i = 0 this /// step sets up qop, too. /// + /// @tparam i Index of the k_i, i = [0, 3] /// @tparam propagator_state_t Type of the state of the propagator /// @tparam stepper_t Type of the stepper /// @tparam navigator_t Type of the navigator @@ -49,20 +36,21 @@ struct DefaultExtension { /// @param [out] knew Next k_i that is evaluated /// @param [in] bField B-Field at the evaluation position /// @param [out] kQoP k_i elements of the momenta - /// @param [in] i Index of the k_i, i = [0, 3] /// @param [in] h Step size (= 0. ^ 0.5 * StepSize ^ StepSize) /// @param [in] kprev Evaluated k_{i - 1} /// /// @return Boolean flag if the calculation is valid - template bool k(const propagator_state_t& state, const stepper_t& stepper, const navigator_t& /*navigator*/, ThisVector3& knew, - const Vector3& bField, std::array& kQoP, const int i = 0, - const double h = 0., const ThisVector3& kprev = ThisVector3::Zero()) { + const Vector3& bField, std::array& kQoP, + const double h = 0., const ThisVector3& kprev = ThisVector3::Zero()) + requires(i >= 0 && i <= 3) + { auto qop = stepper.qOverP(state.stepping); // First step does not rely on previous data - if (i == 0) { + if constexpr (i == 0) { knew = qop * stepper.direction(state.stepping).cross(bField); kQoP = {0., 0., 0., 0.}; } else { diff --git a/Core/include/Acts/Propagator/DenseEnvironmentExtension.hpp b/Core/include/Acts/Propagator/EigenStepperDenseEnvironmentExtension.hpp similarity index 89% rename from Core/include/Acts/Propagator/DenseEnvironmentExtension.hpp rename to Core/include/Acts/Propagator/EigenStepperDenseEnvironmentExtension.hpp index eed51e1e847..befab8f96ce 100644 --- a/Core/include/Acts/Propagator/DenseEnvironmentExtension.hpp +++ b/Core/include/Acts/Propagator/EigenStepperDenseEnvironmentExtension.hpp @@ -12,16 +12,11 @@ #include "Acts/Utilities/detail/ReferenceWrapperAnyCompat.hpp" #include "Acts/Definitions/Algebra.hpp" -#include "Acts/Definitions/PdgParticle.hpp" -#include "Acts/Definitions/TrackParametrization.hpp" #include "Acts/Material/Interactions.hpp" -#include "Acts/Propagator/AbortList.hpp" -#include "Acts/Propagator/ActionList.hpp" +#include "Acts/Material/Material.hpp" +#include "Acts/Material/MaterialSlab.hpp" +#include "Acts/Propagator/EigenStepperDefaultExtension.hpp" #include "Acts/Propagator/Propagator.hpp" -#include "Acts/Utilities/VectorHelpers.hpp" - -#include -#include namespace Acts { @@ -30,11 +25,14 @@ namespace Acts { /// ioninisation, bremsstrahlung, pair production and photonuclear interaction /// in the propagation and the jacobian. These effects will only occur if the /// propagation is in a TrackingVolume with attached material. -struct DenseEnvironmentExtension { +struct EigenStepperDenseEnvironmentExtension { using Scalar = ActsScalar; /// @brief Vector3 replacement for the custom scalar type using ThisVector3 = Eigen::Matrix; + /// Fallback extension + EigenStepperDefaultExtension defaultExtension; + /// Momentum at a certain point Scalar currentMomentum = 0.; /// Particles momentum at k1 @@ -59,44 +57,11 @@ struct DenseEnvironmentExtension { /// Energy at each sub-step std::array energy{}; - /// @brief Control function if the step evaluation would be valid - /// - /// @tparam propagator_state_t Type of the state of the propagator - /// @tparam stepper_t Type of the stepper - /// @tparam navigator_t Type of the navigator - /// - /// @param [in] state State of the propagator - /// @param [in] stepper Stepper of the propagator - /// @param [in] navigator Navigator of the propagator - /// - /// @return Boolean flag if the step would be valid - template - int bid(const propagator_state_t& state, const stepper_t& stepper, - const navigator_t& navigator) const { - const auto& particleHypothesis = stepper.particleHypothesis(state.stepping); - float absQ = particleHypothesis.absoluteCharge(); - float mass = particleHypothesis.mass(); - - // Check for valid particle properties - if (absQ == 0. || mass == 0. || - stepper.absoluteMomentum(state.stepping) < - state.options.stepping.dense.momentumCutOff) { - return 0; - } - - // Check existence of a volume with material - if (!navigator.currentVolumeMaterial(state.navigation)) { - return 0; - } - - return 2; - } - /// @brief Evaluater of the k_i's of the RKN4. For the case of i = 0 this /// step sets up member parameters, too. /// - /// @tparam stepper_state_t Type of the state of the propagator + /// @tparam i Index of the k_i, i = [0, 3] + /// @tparam propagator_state_t Type of the state of the propagator /// @tparam stepper_t Type of the stepper /// @tparam navigator_t Type of the navigator /// @@ -106,30 +71,32 @@ struct DenseEnvironmentExtension { /// @param [out] knew Next k_i that is evaluated /// @param [out] kQoP k_i elements of the momenta /// @param [in] bField B-Field at the evaluation position - /// @param [in] i Index of the k_i, i = [0, 3] /// @param [in] h Step size (= 0. ^ 0.5 * StepSize ^ StepSize) /// @param [in] kprev Evaluated k_{i - 1} /// /// @return Boolean flag if the calculation is valid - template bool k(const propagator_state_t& state, const stepper_t& stepper, const navigator_t& navigator, ThisVector3& knew, const Vector3& bField, - std::array& kQoP, const int i = 0, const double h = 0., - const ThisVector3& kprev = ThisVector3::Zero()) { + std::array& kQoP, const double h = 0., + const ThisVector3& kprev = ThisVector3::Zero()) + requires(i >= 0 && i <= 3) + { + const auto* volumeMaterial = + navigator.currentVolumeMaterial(state.navigation); + if (volumeMaterial == nullptr) { + return defaultExtension.template k(state, stepper, navigator, knew, + bField, kQoP, h, kprev); + } + double q = stepper.charge(state.stepping); const auto& particleHypothesis = stepper.particleHypothesis(state.stepping); float mass = particleHypothesis.mass(); // i = 0 is used for setup and evaluation of k - if (i == 0) { - // Set up container for energy loss - const auto* volumeMaterial = - navigator.currentVolumeMaterial(state.navigation); - if (volumeMaterial == nullptr) { - // This function is very hot, so we prefer to terminate here - std::terminate(); - } + if constexpr (i == 0) { + // Set up for energy loss ThisVector3 position = stepper.position(state.stepping); material = volumeMaterial->material(position.template cast()); initialMomentum = stepper.absoluteMomentum(state.stepping); @@ -172,13 +139,20 @@ struct DenseEnvironmentExtension { /// /// @param [in] state State of the propagator /// @param [in] stepper Stepper of the propagator + /// @param [in] navigator Navigator of the propagator /// @param [in] h Step size /// /// @return Boolean flag if the calculation is valid template bool finalize(propagator_state_t& state, const stepper_t& stepper, - const navigator_t& /*navigator*/, const double h) const { + const navigator_t& navigator, const double h) const { + const auto* volumeMaterial = + navigator.currentVolumeMaterial(state.navigation); + if (volumeMaterial == nullptr) { + return defaultExtension.finalize(state, stepper, navigator, h); + } + const auto& particleHypothesis = stepper.particleHypothesis(state.stepping); float mass = particleHypothesis.mass(); @@ -231,6 +205,12 @@ struct DenseEnvironmentExtension { bool finalize(propagator_state_t& state, const stepper_t& stepper, const navigator_t& navigator, const double h, FreeMatrix& D) const { + const auto* volumeMaterial = + navigator.currentVolumeMaterial(state.navigation); + if (volumeMaterial == nullptr) { + return defaultExtension.finalize(state, stepper, navigator, h, D); + } + return finalize(state, stepper, navigator, h) && transportMatrix(state, stepper, h, D); } @@ -398,7 +378,7 @@ struct DenseEnvironmentExtension { energy[0] = std::hypot(initialMomentum, mass); // use unit length as thickness to compute the energy loss per unit length - Acts::MaterialSlab slab(material, 1); + MaterialSlab slab(material, 1); // Use the same energy loss throughout the step. if (state.options.stepping.dense.meanEnergyLoss) { g = -computeEnergyLossMean(slab, absPdg, mass, static_cast(qop[0]), diff --git a/Core/include/Acts/Propagator/MultiEigenStepperLoop.hpp b/Core/include/Acts/Propagator/MultiEigenStepperLoop.hpp index dce5c475bc8..357d6b7b4bb 100644 --- a/Core/include/Acts/Propagator/MultiEigenStepperLoop.hpp +++ b/Core/include/Acts/Propagator/MultiEigenStepperLoop.hpp @@ -1,6 +1,6 @@ // This file is part of the Acts project. // -// Copyright (C) 2021-2023 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 @@ -22,6 +22,7 @@ #include "Acts/Propagator/ConstrainedStep.hpp" #include "Acts/Propagator/EigenStepper.hpp" #include "Acts/Propagator/EigenStepperError.hpp" +#include "Acts/Propagator/MultiStepperError.hpp" #include "Acts/Propagator/Propagator.hpp" #include "Acts/Propagator/StepperOptions.hpp" #include "Acts/Propagator/detail/LoopStepperUtils.hpp" @@ -40,8 +41,6 @@ #include -#include "MultiStepperError.hpp" - namespace Acts { using namespace Acts::UnitLiterals; @@ -235,17 +234,14 @@ using MaxWeightReducerLoop = /// * There are certain redundancies between the global State and the /// component states /// * The components do not share a single magnetic-field-cache -/// @tparam extensionlist_t See EigenStepper for details +/// @tparam extension_t See EigenStepper for details /// @tparam component_reducer_t How to map the multi-component state to a single /// component -/// @tparam auctioneer_t See EigenStepper for details /// @tparam small_vector_size A size-hint how much memory should be allocated /// by the small vector -template , - typename component_reducer_t = WeightedComponentReducerLoop, - typename auctioneer_t = detail::VoidAuctioneer> -class MultiEigenStepperLoop - : public EigenStepper { +template +class MultiEigenStepperLoop : public EigenStepper { /// Limits the number of steps after at least one component reached the /// surface std::size_t m_stepLimitAfterFirstComponentOnSurface = 50; @@ -260,7 +256,7 @@ class MultiEigenStepperLoop public: /// @brief Typedef to the Single-Component Eigen Stepper - using SingleStepper = EigenStepper; + using SingleStepper = EigenStepper; /// @brief Typedef to the State of the single component Stepper using SingleState = typename SingleStepper::State; @@ -366,15 +362,14 @@ class MultiEigenStepperLoop MultiEigenStepperLoop(std::shared_ptr bField, std::unique_ptr logger = getDefaultLogger("GSF", Logging::INFO)) - : EigenStepper(std::move(bField)), + : EigenStepper(std::move(bField)), m_logger(std::move(logger)) {} /// Constructor from a configuration and optionally provided Logger MultiEigenStepperLoop(const Config& config, std::unique_ptr logger = getDefaultLogger("GSF", Logging::INFO)) - : EigenStepper(config), - m_logger(std::move(logger)) {} + : EigenStepper(config), m_logger(std::move(logger)) {} /// Construct and initialize a state State makeState(std::reference_wrapper gctx, diff --git a/Core/include/Acts/Propagator/MultiEigenStepperLoop.ipp b/Core/include/Acts/Propagator/MultiEigenStepperLoop.ipp index f743d059a2f..8f9d3216d6a 100644 --- a/Core/include/Acts/Propagator/MultiEigenStepperLoop.ipp +++ b/Core/include/Acts/Propagator/MultiEigenStepperLoop.ipp @@ -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 @@ -11,8 +11,8 @@ namespace Acts { -template -auto MultiEigenStepperLoop::boundState( +template +auto MultiEigenStepperLoop::boundState( State& state, const Surface& surface, bool transportCov, const FreeToBoundCorrection& freeToBoundCorrection) const -> Result { @@ -62,8 +62,8 @@ auto MultiEigenStepperLoop::boundState( Jacobian::Zero(), accumulatedPathLength}; } -template -auto MultiEigenStepperLoop::curvilinearState( +template +auto MultiEigenStepperLoop::curvilinearState( State& state, bool transportCov) const -> CurvilinearState { assert(!state.components.empty()); @@ -89,9 +89,9 @@ auto MultiEigenStepperLoop::curvilinearState( Jacobian::Zero(), accumulatedPathLength}; } -template +template template -Result MultiEigenStepperLoop::step( +Result MultiEigenStepperLoop::step( propagator_state_t& state, const navigator_t& navigator) const { using Status = Acts::Intersection3D::Status; diff --git a/Core/include/Acts/Propagator/StepperExtensionList.hpp b/Core/include/Acts/Propagator/StepperExtensionList.hpp deleted file mode 100644 index 3454030dd5c..00000000000 --- a/Core/include/Acts/Propagator/StepperExtensionList.hpp +++ /dev/null @@ -1,232 +0,0 @@ -// This file is part of the Acts project. -// -// Copyright (C) 2021 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/Definitions/Algebra.hpp" -#include "Acts/Definitions/TrackParametrization.hpp" -#include "Acts/Propagator/detail/Auctioneer.hpp" -#include "Acts/Utilities/detail/Extendable.hpp" -#include "Acts/Utilities/detail/MPL/all_of.hpp" -#include "Acts/Utilities/detail/MPL/has_duplicates.hpp" - -#include - -namespace Acts { - -/// @brief Container of extensions used in the stepper of the propagation. This -/// struct allows a broadcast of function calls for each element in the list. -/// The broadcasts occur for a certain function at each step in a specific -/// order. -/// The first function is an evaluater if an extension is or how many extensions -/// are applicable for an upcoming step. -/// The next functions called are the evaluations of the k_1 - k_4 or the RKN4 -/// integration. -/// The last function call in a step is the finalize() method. This method is an -/// overloaded function (optionally propagates the covariance). -/// Each method has the possibility to break the evaluation of a given step if -/// an extension reports that something went wrong (e.g. a particle lost too -/// much momentum during the step) -/// @tparam extensions Types of the extensions -template -struct StepperExtensionList : private detail::Extendable { - private: - // Checkout for duplicates in the extensions - static_assert(!detail::has_duplicates_v, - "same extension type specified several times"); - - static constexpr unsigned int nExtensions = sizeof...(extensions); - - static_assert(nExtensions != 0, "no extension type specified"); - - // Access to all extensions - using detail::Extendable::tuple; - - // Vector of valid extensions for a step - std::array validExtensions{}; - - public: - // Access to an extension - using detail::Extendable::get; - - /// @brief Evaluation function to set valid extensions for an upcoming - /// integration step - /// - /// @tparam propagator_state_t Type of the state of the propagator - /// @tparam stepper_t Type of the stepper - /// @tparam navigtor_t Type of the navigator - /// - /// @param [in] state State of the propagator - /// @param [in] stepper Stepper of the propagation - /// @param [in] navigator Navigator of the propagation - template - bool validExtensionForStep(const propagator_state_t& state, - const stepper_t& stepper, - const navigtor_t& navigator) { - const auto bids = std::apply( - [&](const auto&... ext) { - return std::array{ - ext.bid(state, stepper, navigator)...}; - }, - tuple()); - - validExtensions = state.stepping.auctioneer(std::move(bids)); - - return (std::find(validExtensions.begin(), validExtensions.end(), true) != - validExtensions.end()); - } - - /// @brief This functions broadcasts the call for evaluating a generic k. It - /// collects all arguments and extensions, test their validity for the - /// evaluation and passes them forward for evaluation and returns a boolean as - /// indicator if the evaluation is valid. - template - bool k(const propagator_state_t& state, const stepper_t& stepper, - const navigator_t& navigator, Vector3& knew, const Vector3& bField, - std::array& kQoP, const int i, const double h = 0., - const Vector3& kprev = Vector3::Zero()) { - // TODO replace with integer-templated lambda with C++20 - auto impl = [&, i, h](auto intType, auto& implRef) { - constexpr int N = decltype(intType)::value; - - if constexpr (N == 0) { - return true; - } else { - // If element is invalid: continue - if (!std::get(validExtensions)) { - return implRef(std::integral_constant{}, implRef); - } - // Continue as long as evaluations are 'true' - if (std::get(this->tuple()) - .template k(state, stepper, navigator, knew, bField, kQoP, i, h, - kprev)) { - return implRef(std::integral_constant{}, implRef); - } else { - // Break at false - return false; - } - } - }; - - return impl(std::integral_constant{}, impl); - } - - /// @brief This functions broadcasts the call for evaluating k1. It collects - /// all arguments and extensions, test their validity for the evaluation and - /// passes them forward for evaluation and returns a boolean as indicator if - /// the evaluation is valid. - template - bool k1(const propagator_state_t& state, const stepper_t& stepper, - const navigator_t& navigator, Vector3& knew, const Vector3& bField, - std::array& kQoP) { - return k(state, stepper, navigator, knew, bField, kQoP, 0); - } - - /// @brief This functions broadcasts the call for evaluating k2. It collects - /// all arguments and extensions and passes them forward for evaluation and - /// returns a boolean as indicator if the evaluation is valid. - template - bool k2(const propagator_state_t& state, const stepper_t& stepper, - const navigator_t& navigator, Vector3& knew, const Vector3& bField, - std::array& kQoP, const double h, const Vector3& kprev) { - return k(state, stepper, navigator, knew, bField, kQoP, 1, h, kprev); - } - - /// @brief This functions broadcasts the call for evaluating k3. It collects - /// all arguments and extensions and passes them forward for evaluation and - /// returns a boolean as indicator if the evaluation is valid. - template - bool k3(const propagator_state_t& state, const stepper_t& stepper, - const navigator_t& navigator, Vector3& knew, const Vector3& bField, - std::array& kQoP, const double h, const Vector3& kprev) { - return k(state, stepper, navigator, knew, bField, kQoP, 2, h, kprev); - } - - /// @brief This functions broadcasts the call for evaluating k4. It collects - /// all arguments and extensions and passes them forward for evaluation and - /// returns a boolean as indicator if the evaluation is valid. - template - bool k4(const propagator_state_t& state, const stepper_t& stepper, - const navigator_t& navigator, Vector3& knew, const Vector3& bField, - std::array& kQoP, const double h, const Vector3& kprev) { - return k(state, stepper, navigator, knew, bField, kQoP, 3, h, kprev); - } - - /// @brief This functions broadcasts the call of the method finalize(). It - /// collects all extensions and arguments and passes them forward for - /// evaluation and returns a boolean. - template - bool finalize(propagator_state_t& state, const stepper_t& stepper, - const navigator_t& navigator, const double h, FreeMatrix& D) { - // TODO replace with integer-templated lambda with C++20 - auto impl = [&, h](auto intType, auto& implRef) { - constexpr int N = decltype(intType)::value; - - if constexpr (N == 0) { - return true; - } else { - // If element is invalid: continue - if (!std::get(validExtensions)) { - return implRef(std::integral_constant{}, implRef); - } - // Continue as long as evaluations are 'true' - if (std::get(this->tuple()) - .finalize(state, stepper, navigator, h, D)) { - return implRef(std::integral_constant{}, implRef); - } else { - // Break at false - return false; - } - } - }; - - return impl(std::integral_constant{}, impl); - } - - /// @brief This functions broadcasts the call of the method finalize(). It - /// collects all extensions and arguments and passes them forward for - /// evaluation and returns a boolean. - template - bool finalize(propagator_state_t& state, const stepper_t& stepper, - const navigator_t& navigator, const double h) { - // TODO replace with integer-templated lambda with C++20 - auto impl = [&, h](auto intType, auto& implRef) { - constexpr int N = decltype(intType)::value; - - if constexpr (N == 0) { - return true; - } else { - // If element is invalid: continue - if (!std::get(validExtensions)) { - return implRef(std::integral_constant{}, implRef); - } - - // Continue as long as evaluations are 'true' - if (std::get(this->tuple()) - .finalize(state, stepper, navigator, h)) { - return implRef(std::integral_constant{}, implRef); - } else { - // Break at false - return false; - } - } - }; - - return impl(std::integral_constant{}, impl); - } -}; - -} // namespace Acts diff --git a/Core/include/Acts/Propagator/detail/Auctioneer.hpp b/Core/include/Acts/Propagator/detail/Auctioneer.hpp deleted file mode 100644 index e086526d327..00000000000 --- a/Core/include/Acts/Propagator/detail/Auctioneer.hpp +++ /dev/null @@ -1,108 +0,0 @@ -// This file is part of the Acts project. -// -// Copyright (C) 2016-2018 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 -#include - -namespace Acts::detail { -/// The StepperExtensionList allows to add an arbitrary number of step -/// evaluation algorithms for the RKN4 evaluation. These can be categorised in -/// two general types: -/// a) Step evaluation that should not be evaluated along with other -/// extensions, or at least would overwrite partial results. This means that -/// in the best case unnecessary/redundant calculation would be performed, in -/// the worst case the evaluation would go wrong. -/// b) The step evaluation remains untouched and only further calculations are -/// performed (like additional features or data gathering) that can be treated -/// as independent of the basic step evaluation in type a). These types can be -/// added but do not require special treatment in order to not ruin the step -/// evaluation. -/// The concept of the auctioneers aims in the first place to judge which -/// extension of category a) is the one to go. Although every extension can -/// judge if it is valid based on the data given from the state of stepper, -/// multiple extensions from type a) could fulfill their dependencies. Since -/// an extension does not know about other extensions, the decision for the -/// best extension for the step can only be estimated on a global scope. This -/// is the job of the auctioneers. -/// -/// TODO: An anticipation of an optimal concept of the input (and maybe also -/// the output) of the call operator of an auctioneer cannot be performed at -/// the current stage. At the current stage, a real bid-system would be pure -/// guessing. - -/// @brief Auctioneer that takes all extensions as valid that make a valid bid -struct VoidAuctioneer { - /// @brief Default constructor - VoidAuctioneer() = default; - - /// @brief Call operator that returns the list of valid candidates as valids - /// - /// @param [in] vCandidates Candidates that are treated as valid extensions - /// @return The to vCandidates identical list of valid extensions - template - std::array operator()(std::array vCandidates) const { - std::array valids{}; - - for (unsigned int i = 0; i < vCandidates.size(); i++) { - valids[i] = (vCandidates[i] > 0) ? true : false; - } - return valids; - } -}; - -/// @brief Auctioneer that states only the first one that makes a valid bid -struct FirstValidAuctioneer { - /// @brief Default constructor - FirstValidAuctioneer() = default; - - /// @brief Call operator that states the first valid extension as the only - /// valid extension - /// - /// @param [in] vCandidates Candidates for a valid extension - /// @return List with at most one valid extension - template - std::array operator()(std::array vCandidates) const { - std::array valids = {}; - - for (unsigned int i = 0; i < vCandidates.size(); i++) { - if (vCandidates[i] > 0) { - valids[i] = true; - return valids; - } - } - return valids; - } -}; - -/// @brief Auctioneer that makes only the highest bidding extension valid. If -/// multiple elements have the same int, the first one with this value is -/// picked. -struct HighestValidAuctioneer { - /// @brief Default constructor - HighestValidAuctioneer() = default; - - /// @brief Call operator that states the highest bidding extension as the - /// only - /// valid extension - /// - /// @param [in] vCandidates Candidates for a valid extension - /// @return List with at most one valid extension - template - std::array operator()(std::array vCandidates) const { - std::array valids = {}; - - auto highscore = std::max_element(vCandidates.begin(), vCandidates.end()); - valids.at(std::distance(vCandidates.begin(), highscore)) = true; - - return valids; - } -}; - -} // namespace Acts::detail diff --git a/Examples/Algorithms/TrackFitting/src/GsfFitterFunction.cpp b/Examples/Algorithms/TrackFitting/src/GsfFitterFunction.cpp index bfadb103a25..8770b77bf52 100644 --- a/Examples/Algorithms/TrackFitting/src/GsfFitterFunction.cpp +++ b/Examples/Algorithms/TrackFitting/src/GsfFitterFunction.cpp @@ -1,6 +1,6 @@ // This file is part of the Acts project. // -// Copyright (C) 2022 CERN for the benefit of the Acts project +// Copyright (C) 2022-2024 CERN for the benefit of the Acts project // // This Source Code Form is subject to the terms of the Mozilla Public // License, v. 2.0. If a copy of the MPL was not distributed with this @@ -19,7 +19,6 @@ #include "Acts/Propagator/MultiEigenStepperLoop.hpp" #include "Acts/Propagator/Navigator.hpp" #include "Acts/Propagator/Propagator.hpp" -#include "Acts/Propagator/StepperExtensionList.hpp" #include "Acts/TrackFitting/GainMatrixUpdater.hpp" #include "Acts/TrackFitting/GaussianSumFitter.hpp" #include "Acts/TrackFitting/GsfMixtureReduction.hpp" @@ -58,9 +57,9 @@ using namespace ActsExamples; namespace { -using MultiStepper = Acts::MultiEigenStepperLoop< - Acts::StepperExtensionList, - Acts::MaxWeightReducerLoop>; +using MultiStepper = + Acts::MultiEigenStepperLoop; using Propagator = Acts::Propagator; using DirectPropagator = Acts::Propagator; diff --git a/Tests/IntegrationTests/PropagationDenseConstant.cpp b/Tests/IntegrationTests/PropagationDenseConstant.cpp index 381e7639111..c27e38088b4 100644 --- a/Tests/IntegrationTests/PropagationDenseConstant.cpp +++ b/Tests/IntegrationTests/PropagationDenseConstant.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 @@ -15,8 +15,8 @@ #include "Acts/MagneticField/ConstantBField.hpp" #include "Acts/MagneticField/MagneticFieldContext.hpp" #include "Acts/Material/HomogeneousVolumeMaterial.hpp" -#include "Acts/Propagator/DenseEnvironmentExtension.hpp" #include "Acts/Propagator/EigenStepper.hpp" +#include "Acts/Propagator/EigenStepperDenseEnvironmentExtension.hpp" #include "Acts/Propagator/Navigator.hpp" #include "Acts/Propagator/Propagator.hpp" #include "Acts/Propagator/RiddersPropagator.hpp" @@ -34,8 +34,7 @@ namespace ds = ActsTests::PropagationDatasets; using namespace Acts::UnitLiterals; using MagneticField = Acts::ConstantBField; -using Stepper = Acts::EigenStepper< - Acts::StepperExtensionList>; +using Stepper = Acts::EigenStepper; using Propagator = Acts::Propagator; using RiddersPropagator = Acts::RiddersPropagator; diff --git a/Tests/UnitTests/Core/Propagator/AuctioneerTests.cpp b/Tests/UnitTests/Core/Propagator/AuctioneerTests.cpp deleted file mode 100644 index 8d3a96158ea..00000000000 --- a/Tests/UnitTests/Core/Propagator/AuctioneerTests.cpp +++ /dev/null @@ -1,52 +0,0 @@ -// This file is part of the Acts project. -// -// Copyright (C) 2016-2018 CERN for the benefit of the Acts project -// -// This Source Code Form is subject to the terms of the Mozilla Public -// License, v. 2.0. If a copy of the MPL was not distributed with this -// file, You can obtain one at http://mozilla.org/MPL/2.0/. - -#include - -#include "Acts/Propagator/detail/Auctioneer.hpp" - -#include - -namespace Acts::Test { - -BOOST_AUTO_TEST_CASE(AuctioneerTest_VoidAuctioneer) { - // Build arbitrary vector - std::array vecArb = {0, 2, -5, 4}; - std::array vecRes = {false, true, false, true}; - // Let it run through auction - detail::VoidAuctioneer va; - std::array resultVa = va(vecArb); - // Test that vector did not change - BOOST_CHECK_EQUAL_COLLECTIONS(vecRes.begin(), vecRes.end(), resultVa.begin(), - resultVa.end()); -} - -BOOST_AUTO_TEST_CASE(AuctioneerTest_FirstValidAuctioneer) { - // Build arbitrary vector - std::array vecArb = {0, 1, -2, 4}; - // Let it run through auction - detail::FirstValidAuctioneer fva; - std::array resultFva = fva(vecArb); - std::array expected = {false, true, false, false}; - // Test that vector did not change - BOOST_CHECK_EQUAL_COLLECTIONS(expected.begin(), expected.end(), - resultFva.begin(), resultFva.end()); -} - -BOOST_AUTO_TEST_CASE(AuctioneerTest_HighestValidAuctioneer) { - // Build arbitrary vector - std::array vecArb = {0, 1, -2, 4}; - // Let it run through auction - detail::HighestValidAuctioneer fva; - std::array resultFva = fva(vecArb); - std::array expected = {false, false, false, true}; - // Test that vector did not change - BOOST_CHECK_EQUAL_COLLECTIONS(expected.begin(), expected.end(), - resultFva.begin(), resultFva.end()); -} -} // namespace Acts::Test diff --git a/Tests/UnitTests/Core/Propagator/CMakeLists.txt b/Tests/UnitTests/Core/Propagator/CMakeLists.txt index fa90e29b22a..34f3e88f23f 100644 --- a/Tests/UnitTests/Core/Propagator/CMakeLists.txt +++ b/Tests/UnitTests/Core/Propagator/CMakeLists.txt @@ -1,5 +1,4 @@ add_unittest(AtlasStepper AtlasStepperTests.cpp) -add_unittest(Auctioneer AuctioneerTests.cpp) add_unittest(ConstrainedStep ConstrainedStepTests.cpp) add_unittest(CovarianceEngine CovarianceEngineTests.cpp) add_unittest(DirectNavigator DirectNavigatorTests.cpp) diff --git a/Tests/UnitTests/Core/Propagator/EigenStepperTests.cpp b/Tests/UnitTests/Core/Propagator/EigenStepperTests.cpp index 1fb907d25e8..fc7175aaf85 100644 --- a/Tests/UnitTests/Core/Propagator/EigenStepperTests.cpp +++ b/Tests/UnitTests/Core/Propagator/EigenStepperTests.cpp @@ -1,6 +1,6 @@ // This file is part of the Acts project. // -// Copyright (C) 2018-2020 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 @@ -12,7 +12,6 @@ #include "Acts/Definitions/Direction.hpp" #include "Acts/Definitions/TrackParametrization.hpp" #include "Acts/Definitions/Units.hpp" -#include "Acts/EventData/Charge.hpp" #include "Acts/EventData/GenericBoundTrackParameters.hpp" #include "Acts/EventData/GenericCurvilinearTrackParameters.hpp" #include "Acts/EventData/ParticleHypothesis.hpp" @@ -34,15 +33,13 @@ #include "Acts/Propagator/AbortList.hpp" #include "Acts/Propagator/ActionList.hpp" #include "Acts/Propagator/ConstrainedStep.hpp" -#include "Acts/Propagator/DefaultExtension.hpp" -#include "Acts/Propagator/DenseEnvironmentExtension.hpp" #include "Acts/Propagator/EigenStepper.hpp" +#include "Acts/Propagator/EigenStepperDefaultExtension.hpp" +#include "Acts/Propagator/EigenStepperDenseEnvironmentExtension.hpp" #include "Acts/Propagator/EigenStepperError.hpp" #include "Acts/Propagator/MaterialInteractor.hpp" #include "Acts/Propagator/Navigator.hpp" #include "Acts/Propagator/Propagator.hpp" -#include "Acts/Propagator/StepperExtensionList.hpp" -#include "Acts/Propagator/detail/Auctioneer.hpp" #include "Acts/Surfaces/BoundaryTolerance.hpp" #include "Acts/Surfaces/CurvilinearSurface.hpp" #include "Acts/Surfaces/PlaneSurface.hpp" @@ -55,15 +52,11 @@ #include "Acts/Utilities/UnitVectors.hpp" #include -#include #include -#include #include -#include #include #include #include -#include #include #include #include @@ -370,7 +363,6 @@ BOOST_AUTO_TEST_CASE(eigen_stepper_test) { copy.geoContext = state.geoContext; copy.extension = state.extension; - copy.auctioneer = state.auctioneer; copy.stepData = state.stepData; return copy; @@ -544,14 +536,13 @@ BOOST_AUTO_TEST_CASE(eigen_stepper_test) { BOOST_CHECK_EQUAL(res.error(), EigenStepperError::StepSizeAdjustmentFailed); } -/// @brief This function tests the EigenStepper with the DefaultExtension and -/// the DenseEnvironmentExtension. The focus of this tests lies in the -/// choosing of the right extension for the individual use case. This is +/// @brief This function tests the EigenStepper with the EigenStepperDefaultExtension and +/// the EigenStepperDenseEnvironmentExtension. The focus of this tests lies in +/// the choosing of the right extension for the individual use case. This is /// performed with three different detectors: /// a) Pure vacuum -> DefaultExtension needs to act /// b) Pure Be -> DenseEnvironmentExtension needs to act -/// c) Vacuum - Be - Vacuum -> Both should act and switch during the -/// propagation +/// c) Vacuum - Be - Vacuum -> Both should act and switch during the propagation // Test case a). The DenseEnvironmentExtension should state that it is not // valid in this case. @@ -586,9 +577,7 @@ BOOST_AUTO_TEST_CASE(step_extension_vacuum_test) { const CurvilinearTrackParameters sbtp(Vector4::Zero(), startDir, 1_e / 1_GeV, cov, ParticleHypothesis::pion()); - using Stepper = EigenStepper< - StepperExtensionList, - detail::HighestValidAuctioneer>; + using Stepper = EigenStepper; using Propagator = Propagator; using PropagatorOptions = Propagator::Options, AbortList>; @@ -620,9 +609,7 @@ BOOST_AUTO_TEST_CASE(step_extension_vacuum_test) { CHECK_CLOSE_ABS(mom, startMom, 1_keV); } - using DefStepper = EigenStepper< - StepperExtensionList, - detail::HighestValidAuctioneer>; + using DefStepper = EigenStepper; using DefPropagator = Acts::Propagator; using DefPropagatorOptions = DefPropagator::Options, AbortList>; @@ -685,9 +672,7 @@ BOOST_AUTO_TEST_CASE(step_extension_material_test) { const CurvilinearTrackParameters sbtp(Vector4::Zero(), startDir, 1_e / 5_GeV, cov, ParticleHypothesis::pion()); - using Stepper = EigenStepper< - StepperExtensionList, - detail::HighestValidAuctioneer>; + using Stepper = EigenStepper; using Propagator = Propagator; using PropagatorOptions = Propagator::Options, AbortList>; @@ -728,9 +713,7 @@ BOOST_AUTO_TEST_CASE(step_extension_material_test) { } } - using DenseStepper = - EigenStepper, - detail::HighestValidAuctioneer>; + using DenseStepper = EigenStepper; using DensePropagator = Acts::Propagator; using DensePropagatorOptions = DensePropagator::Options, @@ -835,9 +818,7 @@ BOOST_AUTO_TEST_CASE(step_extension_vacmatvac_test) { 1_e / 5_GeV, Covariance::Identity(), ParticleHypothesis::pion()); - using Stepper = EigenStepper< - StepperExtensionList, - detail::HighestValidAuctioneer>; + using Stepper = EigenStepper; using Propagator = Acts::Propagator; using PropagatorOptions = Propagator::Options, AbortList>; @@ -891,7 +872,7 @@ BOOST_AUTO_TEST_CASE(step_extension_vacmatvac_test) { // Build launcher through vacuum // Set options for propagator - using DefStepper = EigenStepper>; + using DefStepper = EigenStepper; using DefPropagator = Acts::Propagator; using DefPropagatorOptions = DefPropagator::Options, AbortList>; @@ -941,8 +922,7 @@ BOOST_AUTO_TEST_CASE(step_extension_vacmatvac_test) { // Set initial parameters for the particle track by using the result of the // first volume - using DenseStepper = EigenStepper< - StepperExtensionList>; + using DenseStepper = EigenStepper; using DensePropagator = Acts::Propagator; using DensePropagatorOptions = DensePropagator::Options, @@ -1072,9 +1052,7 @@ BOOST_AUTO_TEST_CASE(step_extension_trackercalomdt_test) { 1_e / 1_GeV, Covariance::Identity(), ParticleHypothesis::pion()); - using Stepper = EigenStepper< - StepperExtensionList, - detail::HighestValidAuctioneer>; + using Stepper = EigenStepper; using Propagator = Acts::Propagator; using PropagatorOptions = Propagator::Options, diff --git a/Tests/UnitTests/Core/Propagator/MultiStepperTests.cpp b/Tests/UnitTests/Core/Propagator/MultiStepperTests.cpp index 2005e954e21..27625c5ea5c 100644 --- a/Tests/UnitTests/Core/Propagator/MultiStepperTests.cpp +++ b/Tests/UnitTests/Core/Propagator/MultiStepperTests.cpp @@ -1,6 +1,6 @@ // This file is part of the Acts project. // -// Copyright (C) 2018-2020 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 @@ -20,12 +20,11 @@ #include "Acts/MagneticField/ConstantBField.hpp" #include "Acts/MagneticField/MagneticFieldContext.hpp" #include "Acts/MagneticField/NullBField.hpp" -#include "Acts/Propagator/DefaultExtension.hpp" #include "Acts/Propagator/EigenStepper.hpp" +#include "Acts/Propagator/EigenStepperDefaultExtension.hpp" #include "Acts/Propagator/MultiEigenStepperLoop.hpp" #include "Acts/Propagator/Navigator.hpp" #include "Acts/Propagator/Propagator.hpp" -#include "Acts/Propagator/StepperExtensionList.hpp" #include "Acts/Surfaces/CurvilinearSurface.hpp" #include "Acts/Surfaces/PlaneSurface.hpp" #include "Acts/Surfaces/Surface.hpp" @@ -64,10 +63,8 @@ using namespace Acts::VectorHelpers; const MagneticFieldContext magCtx; const GeometryContext geoCtx; -using MultiStepperLoop = - MultiEigenStepperLoop, - MaxWeightReducerLoop>; -using SingleStepper = EigenStepper>; +using MultiStepperLoop = MultiEigenStepperLoop; +using SingleStepper = EigenStepper; const double defaultStepSize = 123.; const auto defaultNDir = Direction::Backward; diff --git a/Tests/UnitTests/Core/Propagator/PropagatorTests.cpp b/Tests/UnitTests/Core/Propagator/PropagatorTests.cpp index 01d02be6e3c..d53ae87eb96 100644 --- a/Tests/UnitTests/Core/Propagator/PropagatorTests.cpp +++ b/Tests/UnitTests/Core/Propagator/PropagatorTests.cpp @@ -1,6 +1,6 @@ // This file is part of the Acts project. // -// Copyright (C) 2016-2019 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 @@ -23,12 +23,11 @@ #include "Acts/Propagator/AbortList.hpp" #include "Acts/Propagator/ActionList.hpp" #include "Acts/Propagator/ConstrainedStep.hpp" -#include "Acts/Propagator/DenseEnvironmentExtension.hpp" #include "Acts/Propagator/EigenStepper.hpp" +#include "Acts/Propagator/EigenStepperDenseEnvironmentExtension.hpp" #include "Acts/Propagator/Navigator.hpp" #include "Acts/Propagator/Propagator.hpp" #include "Acts/Propagator/StandardAborters.hpp" -#include "Acts/Propagator/StepperExtensionList.hpp" #include "Acts/Propagator/StraightLineStepper.hpp" #include "Acts/Surfaces/CurvilinearSurface.hpp" #include "Acts/Surfaces/CylinderBounds.hpp" @@ -477,8 +476,7 @@ BOOST_AUTO_TEST_CASE(BasicPropagatorInterface) { BOOST_CHECK(resultCurv.ok()); } - EigenStepper> - denseEigenStepper{field}; + EigenStepper denseEigenStepper{field}; { Propagator propagator{denseEigenStepper, navigator}; diff --git a/Tests/UnitTests/Core/Propagator/SympyStepperTests.cpp b/Tests/UnitTests/Core/Propagator/SympyStepperTests.cpp index 676246bce15..13edeaeaf91 100644 --- a/Tests/UnitTests/Core/Propagator/SympyStepperTests.cpp +++ b/Tests/UnitTests/Core/Propagator/SympyStepperTests.cpp @@ -34,14 +34,10 @@ #include "Acts/Propagator/AbortList.hpp" #include "Acts/Propagator/ActionList.hpp" #include "Acts/Propagator/ConstrainedStep.hpp" -#include "Acts/Propagator/DefaultExtension.hpp" -#include "Acts/Propagator/DenseEnvironmentExtension.hpp" #include "Acts/Propagator/MaterialInteractor.hpp" #include "Acts/Propagator/Navigator.hpp" #include "Acts/Propagator/Propagator.hpp" -#include "Acts/Propagator/StepperExtensionList.hpp" #include "Acts/Propagator/SympyStepper.hpp" -#include "Acts/Propagator/detail/Auctioneer.hpp" #include "Acts/Surfaces/BoundaryTolerance.hpp" #include "Acts/Surfaces/CurvilinearSurface.hpp" #include "Acts/Surfaces/PlaneSurface.hpp" diff --git a/docs/core/propagation.md b/docs/core/propagation.md index 175278a0157..0c9b8259f76 100644 --- a/docs/core/propagation.md +++ b/docs/core/propagation.md @@ -108,22 +108,17 @@ The {class}`Acts::StraightLineStepper` is a very stripped down stepper that just ### EigenStepper -The {class}`Acts::EigenStepper` implements the same functionality as the ATLAS stepper, however, the stepping code is rewritten by using `Eigen` primitives. Thus, it also uses a 4th-order Runge-Kutta algorithm for the integration of the EOM. Additionally, the {class}`Acts::EigenStepper` allows to customize the concrete integration step via **extensions**. +The {class}`Acts::EigenStepper` implements the same functionality as the ATLAS stepper, however, the stepping code is rewritten by using `Eigen` primitives. Thus, it also uses a 4th-order Runge-Kutta algorithm for the integration of the EOM. Additionally, the {class}`Acts::EigenStepper` allows to customize the concrete integration step via **extension**. -The extensions encapsulate the relevant equations for different environments. There exists a {struct}`Acts::DefaultExtension` that is suited for propagation in a vacuum, and the {struct}`Acts::DenseEnvironmentExtension`, that contains additional code to handle the propagation inside materials. Which extension is used is selected by a bidding-system. +The extension encapsulate the relevant equations for different environments. There exists a {struct}`Acts::EigenStepperDefaultExtension` that is suited for propagation in a vacuum, and the {struct}`Acts::EigenStepperDenseEnvironmentExtension`, that contains additional code to handle the propagation inside materials. Which extension is used is decided by the user. -The extension can be configured via the {struct}`Acts::StepperExtensionList`: +The extension can be configured via the {class}`Acts::EigenStepper`: -```cpp -using Stepper = Acts::EigenStepper< - Acts::StepperExtensionList< - Acts::DefaultExtension, - Acts::DenseEnvironmentExtension - > - >; +```c++ +using Stepper = Acts::EigenStepper; ``` -By default, the {class}`Acts::EigenStepper` only uses the {struct}`Acts::DefaultExtension`. +By default, the {class}`Acts::EigenStepper` only uses the {struct}`Acts::EigenStepperDenseEnvironmentExtension`. ### MultiEigenStepperLoop From d80f91ff3752d895563a69ae01ef7daf0179b5f1 Mon Sep 17 00:00:00 2001 From: Andreas Stefl Date: Mon, 9 Sep 2024 23:30:48 +0200 Subject: [PATCH 07/12] fix: Stitch tracks correctly after second pass in Examples Track Finding (#3597) Stich tracks from first measurement not from first state otherwise we can end up with double counting material states. discovered in https://github.com/acts-project/acts/pull/3391 --- .../src/TrackFindingAlgorithm.cpp | 23 +++++++++++-------- 1 file changed, 13 insertions(+), 10 deletions(-) diff --git a/Examples/Algorithms/TrackFinding/src/TrackFindingAlgorithm.cpp b/Examples/Algorithms/TrackFinding/src/TrackFindingAlgorithm.cpp index 432e546d4a3..03688c2c943 100644 --- a/Examples/Algorithms/TrackFinding/src/TrackFindingAlgorithm.cpp +++ b/Examples/Algorithms/TrackFinding/src/TrackFindingAlgorithm.cpp @@ -508,13 +508,9 @@ ProcessCode TrackFindingAlgorithm::execute(const AlgorithmContext& ctx) const { // has already been updated seedNumber(trackCandidate) = nSeed - 1; - auto firstState = *std::next(trackCandidate.trackStatesReversed().begin(), - trackCandidate.nTrackStates() - 1); - assert(firstState.previous() == Acts::kTrackIndexInvalid); - if (m_cfg.twoWay) { std::optional - firstMeasurement; + firstMeasurementOpt; for (auto trackState : trackCandidate.trackStatesReversed()) { bool isMeasurement = trackState.typeFlags().test( Acts::TrackStateFlag::MeasurementFlag); @@ -524,13 +520,15 @@ ProcessCode TrackFindingAlgorithm::execute(const AlgorithmContext& ctx) const { // decrease resolution because only the smoothing corrected the very // first prediction as filtering is not possible. if (isMeasurement && !isOutlier) { - firstMeasurement = trackState; + firstMeasurementOpt = trackState; } } - if (firstMeasurement.has_value()) { + if (firstMeasurementOpt.has_value()) { + auto& firstMeasurement = firstMeasurementOpt.value(); + Acts::BoundTrackParameters secondInitialParameters = - trackCandidate.createParametersFromState(*firstMeasurement); + trackCandidate.createParametersFromState(firstMeasurement); auto secondRootBranch = tracksTemp.makeTrack(); secondRootBranch.copyFrom(trackCandidate, false); @@ -542,6 +540,9 @@ ProcessCode TrackFindingAlgorithm::execute(const AlgorithmContext& ctx) const { ACTS_WARNING("Second track finding failed for seed " << iSeed << " with error" << secondResult.error()); } else { + // store the original previous state to restore it later + auto originalFirstMeasurementPrevious = firstMeasurement.previous(); + auto& secondTracksForSeed = secondResult.value(); for (auto& secondTrack : secondTracksForSeed) { // TODO a copy of the track should not be necessary but is the @@ -556,7 +557,7 @@ ProcessCode TrackFindingAlgorithm::execute(const AlgorithmContext& ctx) const { // processed secondTrackCopy.reverseTrackStates(true); - firstState.previous() = + firstMeasurement.previous() = secondTrackCopy.outermostTrackState().index(); trackCandidate.copyFrom(secondTrackCopy, false); @@ -609,6 +610,9 @@ ProcessCode TrackFindingAlgorithm::execute(const AlgorithmContext& ctx) const { ++nSecond; } + + // restore the original previous state + firstMeasurement.previous() = originalFirstMeasurementPrevious; } } } @@ -617,7 +621,6 @@ ProcessCode TrackFindingAlgorithm::execute(const AlgorithmContext& ctx) const { if (nSecond == 0) { // restore the track to the original state trackCandidate.copyFrom(firstTrack, false); - firstState.previous() = Acts::kTrackIndexInvalid; auto firstExtrapolationResult = Acts::extrapolateTrackToReferenceSurface( From eebeb36c4bd97348dfcf53d60239598225f18a03 Mon Sep 17 00:00:00 2001 From: "Alexander J. Pfleger" <70842573+AJPfleger@users.noreply.github.com> Date: Tue, 10 Sep 2024 13:54:14 +0200 Subject: [PATCH 08/12] refactor: replace `Acts::min_max` with `std::ranges::minmax_element` (#3601) --- Core/include/Acts/Utilities/Helpers.hpp | 22 ++++--------------- .../detail/CylindricalDetectorHelper.cpp | 6 ++--- .../UnitTests/Core/Utilities/HelpersTests.cpp | 14 ------------ 3 files changed, 7 insertions(+), 35 deletions(-) diff --git a/Core/include/Acts/Utilities/Helpers.hpp b/Core/include/Acts/Utilities/Helpers.hpp index 5d9d2ab22eb..99d068cf361 100644 --- a/Core/include/Acts/Utilities/Helpers.hpp +++ b/Core/include/Acts/Utilities/Helpers.hpp @@ -164,21 +164,7 @@ T clampValue(U value) { static_cast(std::numeric_limits::max())); } -/// Return min/max from a (optionally) sorted series, obsolete with C++20 -/// (ranges) -/// -/// @tparam T a numeric series -/// -/// @param tseries is the number series -/// -/// @return [ min, max ] in an array of length 2 -template -std::array min_max(const T& tseries) { - return {*std::min_element(tseries.begin(), tseries.end()), - *std::max_element(tseries.begin(), tseries.end())}; -} - -/// Return range and medium of a sorted numeric series +/// Return range and medium of an unsorted numeric series /// /// @tparam T a numeric series /// @@ -187,9 +173,9 @@ std::array min_max(const T& tseries) { /// @return [ range, medium ] in an tuple template std::tuple range_medium(const T& tseries) { - auto [min, max] = min_max(tseries); - typename T::value_type range = (max - min); - ActsScalar medium = static_cast((max + min) * 0.5); + auto [minIt, maxIt] = std::ranges::minmax_element(tseries); + typename T::value_type range = (*maxIt - *minIt); + ActsScalar medium = static_cast((*maxIt + *minIt) * 0.5); return std::tie(range, medium); } diff --git a/Core/src/Detector/detail/CylindricalDetectorHelper.cpp b/Core/src/Detector/detail/CylindricalDetectorHelper.cpp index 1a15d527765..7fce725b4f6 100644 --- a/Core/src/Detector/detail/CylindricalDetectorHelper.cpp +++ b/Core/src/Detector/detail/CylindricalDetectorHelper.cpp @@ -88,12 +88,12 @@ Acts::Experimental::PortalReplacement createDiscReplacement( ? Acts::BinningValue::binR : Acts::BinningValue::binPhi; // Estimate ranges - auto [minR, maxR] = Acts::min_max(rBoundaries); + auto [minRit, maxRit] = std::ranges::minmax_element(rBoundaries); auto [sectorPhi, avgPhi] = Acts::range_medium(phiBoundaries); // Transform and bounds - auto bounds = - std::make_unique(minR, maxR, 0.5 * sectorPhi, avgPhi); + auto bounds = std::make_unique(*minRit, *maxRit, + 0.5 * sectorPhi, avgPhi); // A new surface on the negative side over the full range auto surface = Acts::Surface::makeShared( transform, std::move(bounds)); diff --git a/Tests/UnitTests/Core/Utilities/HelpersTests.cpp b/Tests/UnitTests/Core/Utilities/HelpersTests.cpp index 28390a9089c..a92defd466c 100644 --- a/Tests/UnitTests/Core/Utilities/HelpersTests.cpp +++ b/Tests/UnitTests/Core/Utilities/HelpersTests.cpp @@ -193,20 +193,6 @@ BOOST_AUTO_TEST_CASE_TEMPLATE(BlockedMatrixMultiplication, Matrices, } } -BOOST_AUTO_TEST_CASE(min_max) { - std::vector ordered = {-3., -2., -1., 0., 1., 2., 3.}; - auto [min0, max0] = Acts::min_max(ordered); - - CHECK_CLOSE_ABS(min0, -3., std::numeric_limits::epsilon()); - CHECK_CLOSE_ABS(max0, 3., std::numeric_limits::epsilon()); - - std::vector unordered = {3., -3., -2., -1., 0., 1., 2.}; - auto [min1, max1] = Acts::min_max(unordered); - - CHECK_CLOSE_ABS(min1, -3., std::numeric_limits::epsilon()); - CHECK_CLOSE_ABS(max1, 3., std::numeric_limits::epsilon()); -} - BOOST_AUTO_TEST_CASE(range_medium) { std::vector ordered = {-3., -2., -1., 0., 1., 2., 3.}; auto [range0, medium0] = Acts::range_medium(ordered); From c836ca50bbcad3365e60a211d88158d7bc7e962a Mon Sep 17 00:00:00 2001 From: Andreas Stefl Date: Tue, 10 Sep 2024 17:46:20 +0200 Subject: [PATCH 09/12] refactor!: Rename `EigenStepper` dense extension (#3603) During Athena integration I realized that the naming is a bit inconsistent with `EigenStepperDefaultExtension` and `EigenStepperDenseEnvironmentExtension`. I think `EigenStepperDenseExtension` fits better. --- ...ion.hpp => EigenStepperDenseExtension.hpp} | 2 +- .../PropagationDenseConstant.cpp | 4 ++-- .../Core/Propagator/EigenStepperTests.cpp | 20 +++++++++---------- .../Core/Propagator/PropagatorTests.cpp | 4 ++-- docs/core/propagation.md | 6 +++--- 5 files changed, 18 insertions(+), 18 deletions(-) rename Core/include/Acts/Propagator/{EigenStepperDenseEnvironmentExtension.hpp => EigenStepperDenseExtension.hpp} (99%) diff --git a/Core/include/Acts/Propagator/EigenStepperDenseEnvironmentExtension.hpp b/Core/include/Acts/Propagator/EigenStepperDenseExtension.hpp similarity index 99% rename from Core/include/Acts/Propagator/EigenStepperDenseEnvironmentExtension.hpp rename to Core/include/Acts/Propagator/EigenStepperDenseExtension.hpp index befab8f96ce..155bc1637bc 100644 --- a/Core/include/Acts/Propagator/EigenStepperDenseEnvironmentExtension.hpp +++ b/Core/include/Acts/Propagator/EigenStepperDenseExtension.hpp @@ -25,7 +25,7 @@ namespace Acts { /// ioninisation, bremsstrahlung, pair production and photonuclear interaction /// in the propagation and the jacobian. These effects will only occur if the /// propagation is in a TrackingVolume with attached material. -struct EigenStepperDenseEnvironmentExtension { +struct EigenStepperDenseExtension { using Scalar = ActsScalar; /// @brief Vector3 replacement for the custom scalar type using ThisVector3 = Eigen::Matrix; diff --git a/Tests/IntegrationTests/PropagationDenseConstant.cpp b/Tests/IntegrationTests/PropagationDenseConstant.cpp index c27e38088b4..e95b0bc01a1 100644 --- a/Tests/IntegrationTests/PropagationDenseConstant.cpp +++ b/Tests/IntegrationTests/PropagationDenseConstant.cpp @@ -16,7 +16,7 @@ #include "Acts/MagneticField/MagneticFieldContext.hpp" #include "Acts/Material/HomogeneousVolumeMaterial.hpp" #include "Acts/Propagator/EigenStepper.hpp" -#include "Acts/Propagator/EigenStepperDenseEnvironmentExtension.hpp" +#include "Acts/Propagator/EigenStepperDenseExtension.hpp" #include "Acts/Propagator/Navigator.hpp" #include "Acts/Propagator/Propagator.hpp" #include "Acts/Propagator/RiddersPropagator.hpp" @@ -34,7 +34,7 @@ namespace ds = ActsTests::PropagationDatasets; using namespace Acts::UnitLiterals; using MagneticField = Acts::ConstantBField; -using Stepper = Acts::EigenStepper; +using Stepper = Acts::EigenStepper; using Propagator = Acts::Propagator; using RiddersPropagator = Acts::RiddersPropagator; diff --git a/Tests/UnitTests/Core/Propagator/EigenStepperTests.cpp b/Tests/UnitTests/Core/Propagator/EigenStepperTests.cpp index fc7175aaf85..bea4039ad3d 100644 --- a/Tests/UnitTests/Core/Propagator/EigenStepperTests.cpp +++ b/Tests/UnitTests/Core/Propagator/EigenStepperTests.cpp @@ -35,7 +35,7 @@ #include "Acts/Propagator/ConstrainedStep.hpp" #include "Acts/Propagator/EigenStepper.hpp" #include "Acts/Propagator/EigenStepperDefaultExtension.hpp" -#include "Acts/Propagator/EigenStepperDenseEnvironmentExtension.hpp" +#include "Acts/Propagator/EigenStepperDenseExtension.hpp" #include "Acts/Propagator/EigenStepperError.hpp" #include "Acts/Propagator/MaterialInteractor.hpp" #include "Acts/Propagator/Navigator.hpp" @@ -537,7 +537,7 @@ BOOST_AUTO_TEST_CASE(eigen_stepper_test) { } /// @brief This function tests the EigenStepper with the EigenStepperDefaultExtension and -/// the EigenStepperDenseEnvironmentExtension. The focus of this tests lies in +/// the EigenStepperDenseExtension. The focus of this tests lies in /// the choosing of the right extension for the individual use case. This is /// performed with three different detectors: /// a) Pure vacuum -> DefaultExtension needs to act @@ -577,7 +577,7 @@ BOOST_AUTO_TEST_CASE(step_extension_vacuum_test) { const CurvilinearTrackParameters sbtp(Vector4::Zero(), startDir, 1_e / 1_GeV, cov, ParticleHypothesis::pion()); - using Stepper = EigenStepper; + using Stepper = EigenStepper; using Propagator = Propagator; using PropagatorOptions = Propagator::Options, AbortList>; @@ -609,7 +609,7 @@ BOOST_AUTO_TEST_CASE(step_extension_vacuum_test) { CHECK_CLOSE_ABS(mom, startMom, 1_keV); } - using DefStepper = EigenStepper; + using DefStepper = EigenStepper; using DefPropagator = Acts::Propagator; using DefPropagatorOptions = DefPropagator::Options, AbortList>; @@ -672,7 +672,7 @@ BOOST_AUTO_TEST_CASE(step_extension_material_test) { const CurvilinearTrackParameters sbtp(Vector4::Zero(), startDir, 1_e / 5_GeV, cov, ParticleHypothesis::pion()); - using Stepper = EigenStepper; + using Stepper = EigenStepper; using Propagator = Propagator; using PropagatorOptions = Propagator::Options, AbortList>; @@ -713,7 +713,7 @@ BOOST_AUTO_TEST_CASE(step_extension_material_test) { } } - using DenseStepper = EigenStepper; + using DenseStepper = EigenStepper; using DensePropagator = Acts::Propagator; using DensePropagatorOptions = DensePropagator::Options, @@ -818,7 +818,7 @@ BOOST_AUTO_TEST_CASE(step_extension_vacmatvac_test) { 1_e / 5_GeV, Covariance::Identity(), ParticleHypothesis::pion()); - using Stepper = EigenStepper; + using Stepper = EigenStepper; using Propagator = Acts::Propagator; using PropagatorOptions = Propagator::Options, AbortList>; @@ -872,7 +872,7 @@ BOOST_AUTO_TEST_CASE(step_extension_vacmatvac_test) { // Build launcher through vacuum // Set options for propagator - using DefStepper = EigenStepper; + using DefStepper = EigenStepper; using DefPropagator = Acts::Propagator; using DefPropagatorOptions = DefPropagator::Options, AbortList>; @@ -922,7 +922,7 @@ BOOST_AUTO_TEST_CASE(step_extension_vacmatvac_test) { // Set initial parameters for the particle track by using the result of the // first volume - using DenseStepper = EigenStepper; + using DenseStepper = EigenStepper; using DensePropagator = Acts::Propagator; using DensePropagatorOptions = DensePropagator::Options, @@ -1052,7 +1052,7 @@ BOOST_AUTO_TEST_CASE(step_extension_trackercalomdt_test) { 1_e / 1_GeV, Covariance::Identity(), ParticleHypothesis::pion()); - using Stepper = EigenStepper; + using Stepper = EigenStepper; using Propagator = Acts::Propagator; using PropagatorOptions = Propagator::Options, diff --git a/Tests/UnitTests/Core/Propagator/PropagatorTests.cpp b/Tests/UnitTests/Core/Propagator/PropagatorTests.cpp index d53ae87eb96..4dbdc303771 100644 --- a/Tests/UnitTests/Core/Propagator/PropagatorTests.cpp +++ b/Tests/UnitTests/Core/Propagator/PropagatorTests.cpp @@ -24,7 +24,7 @@ #include "Acts/Propagator/ActionList.hpp" #include "Acts/Propagator/ConstrainedStep.hpp" #include "Acts/Propagator/EigenStepper.hpp" -#include "Acts/Propagator/EigenStepperDenseEnvironmentExtension.hpp" +#include "Acts/Propagator/EigenStepperDenseExtension.hpp" #include "Acts/Propagator/Navigator.hpp" #include "Acts/Propagator/Propagator.hpp" #include "Acts/Propagator/StandardAborters.hpp" @@ -476,7 +476,7 @@ BOOST_AUTO_TEST_CASE(BasicPropagatorInterface) { BOOST_CHECK(resultCurv.ok()); } - EigenStepper denseEigenStepper{field}; + EigenStepper denseEigenStepper{field}; { Propagator propagator{denseEigenStepper, navigator}; diff --git a/docs/core/propagation.md b/docs/core/propagation.md index 0c9b8259f76..dbd7b37a1b9 100644 --- a/docs/core/propagation.md +++ b/docs/core/propagation.md @@ -110,15 +110,15 @@ The {class}`Acts::StraightLineStepper` is a very stripped down stepper that just The {class}`Acts::EigenStepper` implements the same functionality as the ATLAS stepper, however, the stepping code is rewritten by using `Eigen` primitives. Thus, it also uses a 4th-order Runge-Kutta algorithm for the integration of the EOM. Additionally, the {class}`Acts::EigenStepper` allows to customize the concrete integration step via **extension**. -The extension encapsulate the relevant equations for different environments. There exists a {struct}`Acts::EigenStepperDefaultExtension` that is suited for propagation in a vacuum, and the {struct}`Acts::EigenStepperDenseEnvironmentExtension`, that contains additional code to handle the propagation inside materials. Which extension is used is decided by the user. +The extension encapsulate the relevant equations for different environments. There exists a {struct}`Acts::EigenStepperDefaultExtension` that is suited for propagation in a vacuum, and the {struct}`Acts::EigenStepperDenseExtension`, that contains additional code to handle the propagation inside materials. Which extension is used is decided by the user. The extension can be configured via the {class}`Acts::EigenStepper`: ```c++ -using Stepper = Acts::EigenStepper; +using Stepper = Acts::EigenStepper; ``` -By default, the {class}`Acts::EigenStepper` only uses the {struct}`Acts::EigenStepperDenseEnvironmentExtension`. +By default, the {class}`Acts::EigenStepper` only uses the {struct}`Acts::EigenStepperDenseExtension`. ### MultiEigenStepperLoop From 415b4e0e512fcbb9beb30fb983e42561d5eeeb91 Mon Sep 17 00:00:00 2001 From: "Alexander J. Pfleger" <70842573+AJPfleger@users.noreply.github.com> Date: Tue, 10 Sep 2024 20:13:30 +0200 Subject: [PATCH 10/12] refactor: update `to_array` (#3600) "This can be abandoned with C++20 to use the `std::to_array` method" I think this is not true, since `std::array` doesn't work with dynamically sized vectors. --- Core/include/Acts/Utilities/Helpers.hpp | 31 ++++++++++--------- Core/src/Detector/VolumeStructureBuilder.cpp | 12 +++---- .../GenericCuboidVolumeBoundsTests.cpp | 2 +- 3 files changed, 24 insertions(+), 21 deletions(-) diff --git a/Core/include/Acts/Utilities/Helpers.hpp b/Core/include/Acts/Utilities/Helpers.hpp index 99d068cf361..53ca997e29d 100644 --- a/Core/include/Acts/Utilities/Helpers.hpp +++ b/Core/include/Acts/Utilities/Helpers.hpp @@ -11,6 +11,7 @@ #include "Acts/Definitions/Algebra.hpp" #include +#include #include #include #include @@ -71,22 +72,24 @@ std::vector unpack_shared_const_vector( return rawPtrs; } -/// This can be abandoned with C++20 to use the std::to_array method +/// @brief Converts a vector to a fixed-size array with truncating or padding. /// -/// @note only the first kDIM elements will obviously be filled, if the -/// vector tends to be longer, it is truncated +/// This function copies elements from the input vector into a fixed-size array. +/// If the vector contains more than `kDIM` elements, the array is truncated to +/// fit. If the vector contains fewer elements than `kDIM`, the remaining array +/// elements are value-initialized (default-initialized, i.e., filled with zero +/// or default values). /// -/// @param vecvals the vector of bound values to be converted -/// @return an array with the filled values -template -std::array to_array(const std::vector& vecvals) { - std::array rarray = {}; - for (const auto [iv, v] : enumerate(vecvals)) { - if (iv < kDIM) { - rarray[iv] = v; - } - } - return rarray; +/// @tparam kDIM The size of the resulting array. +/// @tparam value_t The type of elements in the vector and the array. +/// @param vecvals The input vector to be converted to an array. +/// +/// @return An array containing the first `kDIM` elements of the vector. +template +std::array toArray(const std::vector& vecvals) { + std::array arr = {}; + std::copy_n(vecvals.begin(), std::min(vecvals.size(), kDIM), arr.begin()); + return arr; } /// @brief Dispatch a call based on a runtime value on a function taking the diff --git a/Core/src/Detector/VolumeStructureBuilder.cpp b/Core/src/Detector/VolumeStructureBuilder.cpp index 49dba260a52..afa10e45cd7 100644 --- a/Core/src/Detector/VolumeStructureBuilder.cpp +++ b/Core/src/Detector/VolumeStructureBuilder.cpp @@ -62,7 +62,7 @@ Acts::Experimental::VolumeStructureBuilder::construct( "object. It needs at least 5 parameters, while " + std::to_string(boundValues.size()) + " where given"); } - auto bArray = to_array( + auto bArray = toArray( boundValues); volumeBounds = std::make_unique(bArray); } break; @@ -94,7 +94,7 @@ Acts::Experimental::VolumeStructureBuilder::construct( std::to_string(boundValues.size()) + " where given"); } auto bArray = - to_array(boundValues); + toArray(boundValues); volumeBounds = std::make_unique(bArray); } break; case VolumeBounds::BoundsType::eCutoutCylinder: { @@ -108,7 +108,7 @@ Acts::Experimental::VolumeStructureBuilder::construct( std::to_string(boundValues.size()) + " where given"); } auto bArray = - to_array(boundValues); + toArray(boundValues); volumeBounds = std::make_unique(bArray); } break; case VolumeBounds::BoundsType::eCylinder: { @@ -150,7 +150,7 @@ Acts::Experimental::VolumeStructureBuilder::construct( << boundValues[2] << ", " << boundValues[3] << ", " << boundValues[4]); auto bArray = - to_array(boundValues); + toArray(boundValues); volumeBounds = std::make_unique(bArray); } break; case VolumeBounds::BoundsType::eGenericCuboid: { @@ -164,7 +164,7 @@ Acts::Experimental::VolumeStructureBuilder::construct( std::to_string(boundValues.size()) + " where given"); } auto bArray = - to_array(boundValues); + toArray(boundValues); volumeBounds = std::make_unique(bArray); } break; case VolumeBounds::BoundsType::eTrapezoid: { @@ -178,7 +178,7 @@ Acts::Experimental::VolumeStructureBuilder::construct( std::to_string(boundValues.size()) + " where given"); } auto bArray = - to_array(boundValues); + toArray(boundValues); volumeBounds = std::make_unique(bArray); } break; default: diff --git a/Tests/UnitTests/Core/Geometry/GenericCuboidVolumeBoundsTests.cpp b/Tests/UnitTests/Core/Geometry/GenericCuboidVolumeBoundsTests.cpp index 2fc5a25ca85..b62758ec815 100644 --- a/Tests/UnitTests/Core/Geometry/GenericCuboidVolumeBoundsTests.cpp +++ b/Tests/UnitTests/Core/Geometry/GenericCuboidVolumeBoundsTests.cpp @@ -191,7 +191,7 @@ BOOST_AUTO_TEST_CASE(bounding_box_creation) { BOOST_CHECK_EQUAL(boundValues.size(), 24u); auto bValueArrray = - to_array( + toArray( boundValues); GenericCuboidVolumeBounds gcvbCopy(bValueArrray); BOOST_CHECK_EQUAL(gcvbCopy.values().size(), 24u); From f774b270244352df5949ee0f5f0d44c64218f825 Mon Sep 17 00:00:00 2001 From: "Alexander J. Pfleger" <70842573+AJPfleger@users.noreply.github.com> Date: Tue, 10 Sep 2024 22:57:17 +0200 Subject: [PATCH 11/12] refactor: modernise GeometryHierarchyMap (#3594) - remove template `iterator_t` - remove iterators - range based loop - pass heavy objects by reference - readability --- .../Acts/Geometry/GeometryHierarchyMap.hpp | 70 ++++++++++--------- 1 file changed, 38 insertions(+), 32 deletions(-) diff --git a/Core/include/Acts/Geometry/GeometryHierarchyMap.hpp b/Core/include/Acts/Geometry/GeometryHierarchyMap.hpp index 1106761d372..b2b10b9e52f 100644 --- a/Core/include/Acts/Geometry/GeometryHierarchyMap.hpp +++ b/Core/include/Acts/Geometry/GeometryHierarchyMap.hpp @@ -64,13 +64,13 @@ class GeometryHierarchyMap { /// Combined geometry identifier and value element. Only used for input. using InputElement = typename std::pair; using Iterator = typename std::vector::const_iterator; - using Size = typename std::vector::size_type; using Value = value_t; /// Construct the container from the given elements. /// /// @param elements input elements (must be unique with respect to identifier) GeometryHierarchyMap(std::vector elements); + /// Construct the container from an initializer list. /// /// @param elements input initializer list @@ -86,21 +86,25 @@ class GeometryHierarchyMap { /// Return an iterator pointing to the beginning of the stored values. Iterator begin() const { return m_values.begin(); } + /// Return an iterator pointing to the end of the stored values. Iterator end() const { return m_values.end(); } + /// Check if any elements are stored. bool empty() const { return m_values.empty(); } + /// Return the number of stored elements. - Size size() const { return m_values.size(); } + std::size_t size() const { return m_values.size(); } /// Access the geometry identifier for the i-th element with bounds check. /// /// @throws std::out_of_range for invalid indices - GeometryIdentifier idAt(Size index) const { return m_ids.at(index); } + GeometryIdentifier idAt(std::size_t index) const { return m_ids.at(index); } + /// Access the value of the i-th element in the container with bounds check. /// /// @throws std::out_of_range for invalid indices - const Value& valueAt(Size index) const { return m_values.at(index); } + const Value& valueAt(std::size_t index) const { return m_values.at(index); } /// Find the most specific value for a given geometry identifier. /// @@ -111,7 +115,7 @@ class GeometryHierarchyMap { /// @param id geometry identifier for which information is requested /// @retval iterator to an existing value /// @retval `.end()` iterator if no matching element exists - Iterator find(GeometryIdentifier id) const; + Iterator find(const GeometryIdentifier& id) const; private: // NOTE this class assumes that it knows the ordering of the levels within @@ -171,25 +175,26 @@ class GeometryHierarchyMap { // no valid levels; all bits are zero. return Identifier{0u}; } + /// Construct a mask where only the highest level is set. static constexpr Identifier makeHighestLevelMask() { return makeLeadingLevelsMask(GeometryIdentifier(0u).setVolume(1u)); } + /// Compare the two identifiers only within the masked bits. static constexpr bool equalWithinMask(Identifier lhs, Identifier rhs, Identifier mask) { return (lhs & mask) == (rhs & mask); } + /// Ensure identifier ordering and uniqueness. - template - static void sortAndCheckDuplicates(iterator_t beg, iterator_t end); + static void sortAndCheckDuplicates(std::vector& elements); /// Fill the container from the input elements. /// /// This assumes that the elements are ordered and unique with respect to /// their identifiers. - template - void fill(iterator_t beg, iterator_t end); + void fill(const std::vector& elements); }; // implementations @@ -197,8 +202,8 @@ class GeometryHierarchyMap { template inline GeometryHierarchyMap::GeometryHierarchyMap( std::vector elements) { - sortAndCheckDuplicates(elements.begin(), elements.end()); - fill(elements.begin(), elements.end()); + sortAndCheckDuplicates(elements); + fill(elements); } template @@ -208,43 +213,44 @@ inline GeometryHierarchyMap::GeometryHierarchyMap( std::vector(elements.begin(), elements.end())) {} template -template inline void GeometryHierarchyMap::sortAndCheckDuplicates( - iterator_t beg, iterator_t end) { + std::vector& elements) { // ensure elements are sorted by identifier - std::sort(beg, end, [=](const auto& lhs, const auto& rhs) { + std::ranges::sort(elements, [=](const auto& lhs, const auto& rhs) { return lhs.first < rhs.first; }); - // check that all elements have unique identifier - auto dup = std::adjacent_find(beg, end, [](const auto& lhs, const auto& rhs) { - return lhs.first == rhs.first; - }); - if (dup != end) { + + // Check that all elements have unique identifier + auto dup = std::ranges::adjacent_find( + elements, + [](const auto& lhs, const auto& rhs) { return lhs.first == rhs.first; }); + + if (dup != elements.end()) { throw std::invalid_argument("Input elements contain duplicates"); } } template -template -inline void GeometryHierarchyMap::fill(iterator_t beg, - iterator_t end) { - const auto n = std::distance(beg, end); +inline void GeometryHierarchyMap::fill( + const std::vector& elements) { m_ids.clear(); - m_ids.reserve(n); m_masks.clear(); - m_masks.reserve(n); m_values.clear(); - m_values.reserve(n); - for (; beg != end; ++beg) { - m_ids.push_back(beg->first.value()); - m_masks.push_back(makeLeadingLevelsMask(beg->first.value())); - m_values.push_back(std::move(beg->second)); + + m_ids.reserve(elements.size()); + m_masks.reserve(elements.size()); + m_values.reserve(elements.size()); + + for (const auto& element : elements) { + m_ids.push_back(element.first.value()); + m_masks.push_back(makeLeadingLevelsMask(element.first.value())); + m_values.push_back(std::move(element.second)); } } template -inline auto GeometryHierarchyMap::find(GeometryIdentifier id) const - -> Iterator { +inline auto GeometryHierarchyMap::find( + const GeometryIdentifier& id) const -> Iterator { assert((m_ids.size() == m_values.size()) && "Inconsistent container state: #ids != # values"); assert((m_masks.size() == m_values.size()) && From ae0c21d3e3fc33e3da77a145f4c62465781a4d6b Mon Sep 17 00:00:00 2001 From: "Alexander J. Pfleger" <70842573+AJPfleger@users.noreply.github.com> Date: Wed, 11 Sep 2024 00:58:56 +0200 Subject: [PATCH 12/12] refactor: add C++23 `std::ranges::contains` place holder (#3598) Search-based algorithm that checks whether or not a given range contains a value with iterator-sentinel pairs. This utility simplifies range-based searches and will be replaceable with [`std::ranges::contains`](https://en.cppreference.com/w/cpp/algorithm/ranges/contains) in C++23. --- .../Detector/detail/IndexedGridFiller.hpp | 7 +- .../Acts/EventData/MultiTrajectoryHelpers.hpp | 4 +- .../Acts/TrackFitting/GaussianSumFitter.hpp | 5 +- .../Acts/TrackFitting/detail/GsfActor.hpp | 5 +- Core/include/Acts/Utilities/BinnedArrayXD.hpp | 7 +- Core/include/Acts/Utilities/Helpers.hpp | 17 +++ Core/src/Detector/LayerStructureBuilder.cpp | 5 +- .../detail/CuboidalDetectorHelper.cpp | 5 +- .../detail/CylindricalDetectorHelper.cpp | 25 +-- Core/src/Geometry/Layer.cpp | 5 +- .../Vertexing/AdaptiveMultiVertexFitter.cpp | 3 +- .../Digitization/src/ModuleClusters.cpp | 10 +- .../Geant4/src/SensitiveSurfaceMapper.cpp | 13 +- .../Geant4HepMC/src/EventAction.cpp | 5 +- .../Geant4HepMC/src/SteppingAction.cpp | 10 +- .../src/TrackFindingAlgorithmExaTrkX.cpp | 7 +- .../Framework/ML/src/NeuralCalibrator.cpp | 4 +- .../ActsExamples/Io/Csv/CsvInputOutput.hpp | 7 +- .../TrackFitterPerformanceWriter.cpp | 6 +- Examples/Python/src/Geometry.cpp | 9 +- Examples/Python/src/Svg.cpp | 18 +-- .../MaterialMapping/Mat_map_detector_plot.C | 4 +- .../Detray/src/DetrayMaterialConverter.cpp | 9 +- .../GeoModel/src/GeoModelBlueprintCreater.cpp | 4 +- Plugins/Json/src/DetectorJsonConverter.cpp | 2 +- .../Plugins/Podio/PodioTrackContainer.hpp | 4 +- .../Podio/PodioTrackStateContainer.hpp | 9 +- .../Clusterization/ClusterizationTests2D.cpp | 3 +- .../UnitTests/Core/Utilities/KDTreeTests.cpp | 142 +++++++++--------- .../ExaTrkXBoostTrackBuildingTests.cpp | 4 +- 30 files changed, 172 insertions(+), 186 deletions(-) diff --git a/Core/include/Acts/Detector/detail/IndexedGridFiller.hpp b/Core/include/Acts/Detector/detail/IndexedGridFiller.hpp index b79cafa93ad..c8f7d416f31 100644 --- a/Core/include/Acts/Detector/detail/IndexedGridFiller.hpp +++ b/Core/include/Acts/Detector/detail/IndexedGridFiller.hpp @@ -17,6 +17,7 @@ #include "Acts/Utilities/Delegate.hpp" #include "Acts/Utilities/Enumerate.hpp" #include "Acts/Utilities/GridAccessHelpers.hpp" +#include "Acts/Utilities/Helpers.hpp" #include "Acts/Utilities/IAxis.hpp" #include "Acts/Utilities/Logger.hpp" @@ -193,7 +194,7 @@ struct IndexedGridFiller { // Loop over the surfaces to be filled for (auto [io, o] : enumerate(iObjects)) { // Exclude indices that should be handled differently - if (std::find(aToAll.begin(), aToAll.end(), io) != aToAll.end()) { + if (rangeContainsValue(aToAll, io)) { continue; } // Get the reference positions @@ -216,7 +217,7 @@ struct IndexedGridFiller { // Now fill the surface indices for (const auto& li : lIndices) { auto& bContent = iGrid.grid.atLocalBins(li); - if (std::find(bContent.begin(), bContent.end(), io) == bContent.end()) { + if (!rangeContainsValue(bContent, io)) { bContent.push_back(io); } } @@ -238,7 +239,7 @@ struct IndexedGridFiller { for (std::size_t gi = 0; gi < iGrid.grid.size(true); ++gi) { auto& bContent = iGrid.grid.at(gi); for (const auto& io : idcs) { - if (std::find(bContent.begin(), bContent.end(), io) == bContent.end()) { + if (!rangeContainsValue(bContent, io)) { bContent.push_back(io); } } diff --git a/Core/include/Acts/EventData/MultiTrajectoryHelpers.hpp b/Core/include/Acts/EventData/MultiTrajectoryHelpers.hpp index 84d4c763a7b..2a5fac9b2d6 100644 --- a/Core/include/Acts/EventData/MultiTrajectoryHelpers.hpp +++ b/Core/include/Acts/EventData/MultiTrajectoryHelpers.hpp @@ -14,6 +14,7 @@ #include "Acts/Geometry/Layer.hpp" #include "Acts/Geometry/TrackingVolume.hpp" #include "Acts/Surfaces/Surface.hpp" +#include "Acts/Utilities/Helpers.hpp" #include #include @@ -102,8 +103,7 @@ VolumeTrajectoryStateContainer trajectoryState( const auto& volume = geoID.volume(); const auto& layer = geoID.layer(); // Check if the track info for this sub-detector is requested - auto it = std::find(volumeIds.begin(), volumeIds.end(), volume); - if (it == volumeIds.end()) { + if (!rangeContainsValue(volumeIds, volume)) { return true; } // The trajectory state for this volume diff --git a/Core/include/Acts/TrackFitting/GaussianSumFitter.hpp b/Core/include/Acts/TrackFitting/GaussianSumFitter.hpp index ada401ba401..e94ab519902 100644 --- a/Core/include/Acts/TrackFitting/GaussianSumFitter.hpp +++ b/Core/include/Acts/TrackFitting/GaussianSumFitter.hpp @@ -16,6 +16,7 @@ #include "Acts/Surfaces/BoundaryTolerance.hpp" #include "Acts/TrackFitting/GsfOptions.hpp" #include "Acts/TrackFitting/detail/GsfActor.hpp" +#include "Acts/Utilities/Helpers.hpp" #include "Acts/Utilities/Logger.hpp" #include "Acts/Utilities/TrackHelpers.hpp" @@ -432,8 +433,8 @@ struct GaussianSumFitter { for (auto state : fwdGsfResult.fittedStates->reverseTrackStateRange( fwdGsfResult.currentTip)) { - const bool found = std::find(foundBwd.begin(), foundBwd.end(), - &state.referenceSurface()) != foundBwd.end(); + const bool found = + rangeContainsValue(foundBwd, &state.referenceSurface()); if (!found && state.typeFlags().test(MeasurementFlag)) { state.typeFlags().set(OutlierFlag); state.typeFlags().reset(MeasurementFlag); diff --git a/Core/include/Acts/TrackFitting/detail/GsfActor.hpp b/Core/include/Acts/TrackFitting/detail/GsfActor.hpp index 56d6cecd262..7db377d1ced 100644 --- a/Core/include/Acts/TrackFitting/detail/GsfActor.hpp +++ b/Core/include/Acts/TrackFitting/detail/GsfActor.hpp @@ -23,6 +23,7 @@ #include "Acts/TrackFitting/detail/GsfComponentMerging.hpp" #include "Acts/TrackFitting/detail/GsfUtils.hpp" #include "Acts/TrackFitting/detail/KalmanUpdateHelpers.hpp" +#include "Acts/Utilities/Helpers.hpp" #include "Acts/Utilities/Zip.hpp" #include @@ -195,9 +196,7 @@ struct GsfActor { // Early return if we already were on this surface TODO why is this // necessary - const bool visited = - std::find(result.visitedSurfaces.begin(), result.visitedSurfaces.end(), - &surface) != result.visitedSurfaces.end(); + const bool visited = rangeContainsValue(result.visitedSurfaces, &surface); if (visited) { ACTS_VERBOSE("Already visited surface, return"); diff --git a/Core/include/Acts/Utilities/BinnedArrayXD.hpp b/Core/include/Acts/Utilities/BinnedArrayXD.hpp index 4b78b1026bc..281bd9d11b3 100644 --- a/Core/include/Acts/Utilities/BinnedArrayXD.hpp +++ b/Core/include/Acts/Utilities/BinnedArrayXD.hpp @@ -13,6 +13,7 @@ #pragma once #include "Acts/Utilities/BinUtility.hpp" #include "Acts/Utilities/BinnedArray.hpp" +#include "Acts/Utilities/Helpers.hpp" #include #include @@ -74,8 +75,7 @@ class BinnedArrayXD : public BinnedArray { /// fill the data m_objectGrid[bins[2]][bins[1]][bins[0]] = tap.first; /// fill the unique m_arrayObjects - if (std::find(m_arrayObjects.begin(), m_arrayObjects.end(), - tap.first) == m_arrayObjects.end()) { + if (!rangeContainsValue(m_arrayObjects, tap.first)) { m_arrayObjects.push_back(tap.first); } } @@ -103,8 +103,7 @@ class BinnedArrayXD : public BinnedArray { for (auto& o0 : o1) { if (o0) { /// fill the unique m_arrayObjects - if (std::find(m_arrayObjects.begin(), m_arrayObjects.end(), o0) == - m_arrayObjects.end()) { + if (!rangeContainsValue(m_arrayObjects, o0)) { m_arrayObjects.push_back(o0); } } diff --git a/Core/include/Acts/Utilities/Helpers.hpp b/Core/include/Acts/Utilities/Helpers.hpp index 53ca997e29d..34248fd9047 100644 --- a/Core/include/Acts/Utilities/Helpers.hpp +++ b/Core/include/Acts/Utilities/Helpers.hpp @@ -187,4 +187,21 @@ constexpr std::underlying_type_t toUnderlying(enum_t value) { return static_cast>(value); } +/// This can be replaced with C++23 to use the std::ranges::contains method +/// +/// This function searches through the given range for a specified value +/// and returns `true` if the value is found, or `false` otherwise. +/// +/// @tparam R The type of the range (e.g., vector, list, array). +/// @tparam T The type of the value to search for within the range. +/// +/// @param range The range to search within. This can be any range-compatible container. +/// @param value The value to search for in the range. +/// +/// @return `true` if the value is found within the range, `false` otherwise. +template +bool rangeContainsValue(const R& range, const T& value) { + return std::ranges::find(range, value) != std::ranges::end(range); +} + } // namespace Acts diff --git a/Core/src/Detector/LayerStructureBuilder.cpp b/Core/src/Detector/LayerStructureBuilder.cpp index 6a421671cf1..260cecf656a 100644 --- a/Core/src/Detector/LayerStructureBuilder.cpp +++ b/Core/src/Detector/LayerStructureBuilder.cpp @@ -23,6 +23,7 @@ #include "Acts/Utilities/Enumerate.hpp" #include "Acts/Utilities/Grid.hpp" #include "Acts/Utilities/GridAxisGenerators.hpp" +#include "Acts/Utilities/Helpers.hpp" #include #include @@ -242,9 +243,7 @@ Acts::Experimental::LayerStructureBuilder::construct( // the binning value that are not constrained by the internal surfaces for (const auto& bv : allBinningValues()) { if (support.volumeExtent.constrains(bv) && - std::find(support.internalConstraints.begin(), - support.internalConstraints.end(), - bv) == support.internalConstraints.end()) { + !rangeContainsValue(support.internalConstraints, bv)) { ACTS_VERBOSE(" Support surface is constrained by volume extent in " << binningValueName(bv)); supportExtent.set(bv, support.volumeExtent.min(bv), diff --git a/Core/src/Detector/detail/CuboidalDetectorHelper.cpp b/Core/src/Detector/detail/CuboidalDetectorHelper.cpp index 4bf7edbabd2..b292db6b15f 100644 --- a/Core/src/Detector/detail/CuboidalDetectorHelper.cpp +++ b/Core/src/Detector/detail/CuboidalDetectorHelper.cpp @@ -19,6 +19,7 @@ #include "Acts/Surfaces/Surface.hpp" #include "Acts/Utilities/BinningData.hpp" #include "Acts/Utilities/Enumerate.hpp" +#include "Acts/Utilities/Helpers.hpp" #include "Acts/Utilities/StringHelpers.hpp" #include @@ -190,9 +191,7 @@ Acts::Experimental::detail::CuboidalDetectorHelper::connect( for (auto [is, index] : enumerate(portalSets[toUnderlying(mergeValue)])) { // Check if you need to skip due to selections - if (!selectedOnly.empty() && - std::find(selectedOnly.begin(), selectedOnly.end(), index) == - selectedOnly.end()) { + if (!selectedOnly.empty() && !rangeContainsValue(selectedOnly, index)) { continue; } diff --git a/Core/src/Detector/detail/CylindricalDetectorHelper.cpp b/Core/src/Detector/detail/CylindricalDetectorHelper.cpp index 7fce725b4f6..2ed29f0b35a 100644 --- a/Core/src/Detector/detail/CylindricalDetectorHelper.cpp +++ b/Core/src/Detector/detail/CylindricalDetectorHelper.cpp @@ -325,9 +325,7 @@ Acts::Experimental::detail::CylindricalDetectorHelper::connectInR( rBoundaries.push_back(refValues[CylinderVolumeBounds::BoundValues::eMaxR]); // Connect in R ? (2u is the index of the outer cylinder) - bool connectR = selectedOnly.empty() || - std::find(selectedOnly.begin(), selectedOnly.end(), 2u) != - selectedOnly.end(); + bool connectR = selectedOnly.empty() || rangeContainsValue(selectedOnly, 2u); // Get phi sector and average phi ActsScalar phiSector = @@ -376,9 +374,7 @@ Acts::Experimental::detail::CylindricalDetectorHelper::connectInR( std::vector discDirs = {Acts::Direction::Forward, Acts::Direction::Backward}; for (const auto [iu, idir] : enumerate(discDirs)) { - if (selectedOnly.empty() || - std::find(selectedOnly.begin(), selectedOnly.end(), iu) != - selectedOnly.end()) { + if (selectedOnly.empty() || rangeContainsValue(selectedOnly, iu)) { const Surface& refSurface = volumes[0u]->portals()[iu]->surface(); const Transform3& refTransform = refSurface.transform(gctx); pReplacements.push_back(createDiscReplacement( @@ -397,9 +393,7 @@ Acts::Experimental::detail::CylindricalDetectorHelper::connectInR( for (const auto [iu, idir] : enumerate(sectorDirs)) { // (iu + 4u) corresponds to the indices of the phi-low and phi-high sector // planes. - if (selectedOnly.empty() || - std::find(selectedOnly.begin(), selectedOnly.end(), iu + 4u) != - selectedOnly.end()) { + if (selectedOnly.empty() || rangeContainsValue(selectedOnly, iu + 4u)) { // As it is r-wrapping, the inner tube is guaranteed const Surface& refSurface = volumes[volumes.size() - 1u]->portals()[iu + 4u]->surface(); @@ -471,9 +465,8 @@ Acts::Experimental::detail::CylindricalDetectorHelper::connectInZ( // Connect in Z ? // - 1u corresponds to the index of the high-z disc portal for the reference // volume. - bool connectZ = selectedOnly.empty() || - std::find(selectedOnly.begin(), selectedOnly.end(), 1u) != - selectedOnly.end(); + const bool connectZ = + selectedOnly.empty() || rangeContainsValue(selectedOnly, 1u); // Reference z axis const auto rotation = volumes[0u]->transform(gctx).rotation(); @@ -586,9 +579,7 @@ Acts::Experimental::detail::CylindricalDetectorHelper::connectInZ( unsigned int iSecOffset = innerPresent ? 4u : 3u; // Prepare the cylinder replacements for (const auto [iu, idir] : enumerate(cylinderDirs)) { - if (selectedOnly.empty() || - std::find(selectedOnly.begin(), selectedOnly.end(), iu + 2u) != - selectedOnly.end()) { + if (selectedOnly.empty() || rangeContainsValue(selectedOnly, iu + 2u)) { pReplacements.push_back(createCylinderReplacement( combinedTransform, cylinderR[iu], zBoundaries, {avgPhi - phiSector, avgPhi + phiSector}, iu + 2u, idir)); @@ -603,9 +594,7 @@ Acts::Experimental::detail::CylindricalDetectorHelper::connectInZ( Acts::Direction::Backward}; for (const auto [iu, idir] : enumerate(sectorDirs)) { // Access with 3u or 4u but always write 4u (to be caught later) - if (selectedOnly.empty() || - std::find(selectedOnly.begin(), selectedOnly.end(), iu + 4u) != - selectedOnly.end()) { + if (selectedOnly.empty() || rangeContainsValue(selectedOnly, iu + 4u)) { const Surface& refSurface = volumes[0u]->portals()[iu + iSecOffset]->surface(); pReplacements.push_back(createSectorReplacement( diff --git a/Core/src/Geometry/Layer.cpp b/Core/src/Geometry/Layer.cpp index 5598a854a41..af9ea08da42 100644 --- a/Core/src/Geometry/Layer.cpp +++ b/Core/src/Geometry/Layer.cpp @@ -14,6 +14,7 @@ #include "Acts/Propagator/Navigator.hpp" #include "Acts/Surfaces/BoundaryTolerance.hpp" #include "Acts/Surfaces/Surface.hpp" +#include "Acts/Utilities/Helpers.hpp" #include "Acts/Utilities/Intersection.hpp" #include @@ -159,9 +160,7 @@ Acts::Layer::compatibleSurfaces( return; } BoundaryTolerance boundaryTolerance = options.boundaryTolerance; - if (std::find(options.externalSurfaces.begin(), - options.externalSurfaces.end(), - sf.geometryId()) != options.externalSurfaces.end()) { + if (rangeContainsValue(options.externalSurfaces, sf.geometryId())) { boundaryTolerance = BoundaryTolerance::Infinite(); } // the surface intersection diff --git a/Core/src/Vertexing/AdaptiveMultiVertexFitter.cpp b/Core/src/Vertexing/AdaptiveMultiVertexFitter.cpp index 6a6a879278a..cc70cee6b15 100644 --- a/Core/src/Vertexing/AdaptiveMultiVertexFitter.cpp +++ b/Core/src/Vertexing/AdaptiveMultiVertexFitter.cpp @@ -9,6 +9,7 @@ #include "Acts/Vertexing/AdaptiveMultiVertexFitter.hpp" #include "Acts/Surfaces/PerigeeSurface.hpp" +#include "Acts/Utilities/Helpers.hpp" #include "Acts/Vertexing/KalmanVertexUpdater.hpp" #include "Acts/Vertexing/VertexingError.hpp" @@ -189,7 +190,7 @@ Acts::Result Acts::AdaptiveMultiVertexFitter::addVtxToFit( bool Acts::AdaptiveMultiVertexFitter::isAlreadyInList( Vertex* vtx, const std::vector& vertices) const { - return std::find(vertices.begin(), vertices.end(), vtx) != vertices.end(); + return rangeContainsValue(vertices, vtx); } Acts::Result Acts::AdaptiveMultiVertexFitter::prepareVertexForFit( diff --git a/Examples/Algorithms/Digitization/src/ModuleClusters.cpp b/Examples/Algorithms/Digitization/src/ModuleClusters.cpp index f82ec7063c4..b5e7ab8e462 100644 --- a/Examples/Algorithms/Digitization/src/ModuleClusters.cpp +++ b/Examples/Algorithms/Digitization/src/ModuleClusters.cpp @@ -9,6 +9,7 @@ #include "ActsExamples/Digitization/ModuleClusters.hpp" #include "Acts/Clusterization/Clusterization.hpp" +#include "Acts/Utilities/Helpers.hpp" #include "ActsExamples/Digitization/MeasurementCreation.hpp" #include "ActsFatras/Digitization/Channelizer.hpp" @@ -139,8 +140,7 @@ std::vector ModuleClusters::nonGeoEntries( std::vector retv; for (std::size_t i = 0; i < indices.size(); i++) { auto idx = indices.at(i); - if (std::find(m_geoIndices.begin(), m_geoIndices.end(), idx) == - m_geoIndices.end()) { + if (!rangeContainsValue(m_geoIndices, idx)) { retv.push_back(i); } } @@ -245,10 +245,8 @@ ModuleValue ModuleClusters::squash(std::vector& values) { ModuleValue& other = values.at(i); for (std::size_t j = 0; j < other.paramIndices.size(); j++) { auto idx = other.paramIndices.at(j); - if (std::find(m_geoIndices.begin(), m_geoIndices.end(), idx) == - m_geoIndices.end()) { - if (std::find(mval.paramIndices.begin(), mval.paramIndices.end(), - idx) == mval.paramIndices.end()) { + if (!rangeContainsValue(m_geoIndices, idx)) { + if (!rangeContainsValue(mval.paramIndices, idx)) { mval.paramIndices.push_back(idx); } if (mval.paramValues.size() < (j + 1)) { diff --git a/Examples/Algorithms/Geant4/src/SensitiveSurfaceMapper.cpp b/Examples/Algorithms/Geant4/src/SensitiveSurfaceMapper.cpp index 341e0531b07..9500671c7b3 100644 --- a/Examples/Algorithms/Geant4/src/SensitiveSurfaceMapper.cpp +++ b/Examples/Algorithms/Geant4/src/SensitiveSurfaceMapper.cpp @@ -11,6 +11,7 @@ #include "Acts/Definitions/Units.hpp" #include "Acts/Surfaces/AnnulusBounds.hpp" #include "Acts/Surfaces/ConvexPolygonBounds.hpp" +#include "Acts/Utilities/Helpers.hpp" #include "Acts/Visualization/GeometryView3D.hpp" #include "Acts/Visualization/ObjVisualization3D.hpp" @@ -185,13 +186,11 @@ void ActsExamples::SensitiveSurfaceMapper::remapSensitiveNames( std::string volumeName = g4LogicalVolume->GetName(); std::string volumeMaterialName = g4LogicalVolume->GetMaterial()->GetName(); - bool isSensitive = g4SensitiveDetector != nullptr; - bool isMappedMaterial = - std::find(m_cfg.materialMappings.begin(), m_cfg.materialMappings.end(), - volumeMaterialName) != m_cfg.materialMappings.end(); - bool isMappedVolume = - std::find(m_cfg.volumeMappings.begin(), m_cfg.volumeMappings.end(), - volumeName) != m_cfg.volumeMappings.end(); + const bool isSensitive = g4SensitiveDetector != nullptr; + const bool isMappedMaterial = + Acts::rangeContainsValue(m_cfg.materialMappings, volumeMaterialName); + const bool isMappedVolume = + Acts::rangeContainsValue(m_cfg.volumeMappings, volumeName); if (!(isSensitive || isMappedMaterial || isMappedVolume)) { ACTS_VERBOSE("Did not try mapping '" diff --git a/Examples/Algorithms/Geant4HepMC/src/EventAction.cpp b/Examples/Algorithms/Geant4HepMC/src/EventAction.cpp index b9e5b07c22f..eb5de237061 100644 --- a/Examples/Algorithms/Geant4HepMC/src/EventAction.cpp +++ b/Examples/Algorithms/Geant4HepMC/src/EventAction.cpp @@ -8,6 +8,8 @@ #include "EventAction.hpp" +#include "Acts/Utilities/Helpers.hpp" + #include #include @@ -32,8 +34,7 @@ bool findAttribute(const HepMC3::ConstGenVertexPtr& vertex, const std::vector vertexAttributes = vertex->attribute_names(); for (const auto& att : vertexAttributes) { const std::string process = vertex->attribute_as_string(att); - if (std::find(processFilter.begin(), processFilter.end(), process) != - processFilter.end()) { + if (Acts::rangeContainsValue(processFilter, process)) { return true; } } diff --git a/Examples/Algorithms/Geant4HepMC/src/SteppingAction.cpp b/Examples/Algorithms/Geant4HepMC/src/SteppingAction.cpp index ad9b91ac7b4..8852349dc60 100644 --- a/Examples/Algorithms/Geant4HepMC/src/SteppingAction.cpp +++ b/Examples/Algorithms/Geant4HepMC/src/SteppingAction.cpp @@ -8,6 +8,8 @@ #include "SteppingAction.hpp" +#include "Acts/Utilities/Helpers.hpp" + #include #include @@ -43,10 +45,10 @@ SteppingAction::~SteppingAction() { void SteppingAction::UserSteppingAction(const G4Step* step) { // Test if the event should be aborted - if (std::find(m_eventRejectionProcess.begin(), m_eventRejectionProcess.end(), - step->GetPostStepPoint() - ->GetProcessDefinedStep() - ->GetProcessName()) != m_eventRejectionProcess.end()) { + if (Acts::rangeContainsValue(m_eventRejectionProcess, + step->GetPostStepPoint() + ->GetProcessDefinedStep() + ->GetProcessName())) { m_eventAborted = true; G4RunManager::GetRunManager()->AbortEvent(); return; diff --git a/Examples/Algorithms/TrackFindingExaTrkX/src/TrackFindingAlgorithmExaTrkX.cpp b/Examples/Algorithms/TrackFindingExaTrkX/src/TrackFindingAlgorithmExaTrkX.cpp index 6bd254a0120..dbc123fc4d3 100644 --- a/Examples/Algorithms/TrackFindingExaTrkX/src/TrackFindingAlgorithmExaTrkX.cpp +++ b/Examples/Algorithms/TrackFindingExaTrkX/src/TrackFindingAlgorithmExaTrkX.cpp @@ -11,6 +11,7 @@ #include "Acts/Definitions/Units.hpp" #include "Acts/Plugins/ExaTrkX/TorchGraphStoreHook.hpp" #include "Acts/Plugins/ExaTrkX/TorchTruthGraphMetricsHook.hpp" +#include "Acts/Utilities/Helpers.hpp" #include "Acts/Utilities/Zip.hpp" #include "ActsExamples/EventData/Index.hpp" #include "ActsExamples/EventData/IndexSourceLink.hpp" @@ -97,10 +98,8 @@ ActsExamples::TrackFindingAlgorithmExaTrkX::TrackFindingAlgorithmExaTrkX( NodeFeature::eCellSum, NodeFeature::eCluster1R, NodeFeature::eCluster2R}; auto wantClFeatures = std::any_of( - m_cfg.nodeFeatures.begin(), m_cfg.nodeFeatures.end(), [&](const auto& f) { - return std::find(clFeatures.begin(), clFeatures.end(), f) != - clFeatures.end(); - }); + m_cfg.nodeFeatures.begin(), m_cfg.nodeFeatures.end(), + [&](const auto& f) { return Acts::rangeContainsValue(clFeatures, f); }); if (wantClFeatures && !m_inputClusters.isInitialized()) { throw std::invalid_argument("Cluster features requested, but not provided"); diff --git a/Examples/Framework/ML/src/NeuralCalibrator.cpp b/Examples/Framework/ML/src/NeuralCalibrator.cpp index 54003b3bfc1..8b0e07f1a62 100644 --- a/Examples/Framework/ML/src/NeuralCalibrator.cpp +++ b/Examples/Framework/ML/src/NeuralCalibrator.cpp @@ -12,6 +12,7 @@ #include "Acts/EventData/MeasurementHelpers.hpp" #include "Acts/EventData/SourceLink.hpp" #include "Acts/Utilities/CalibrationContext.hpp" +#include "Acts/Utilities/Helpers.hpp" #include "Acts/Utilities/UnitVectors.hpp" #include "ActsExamples/EventData/Measurement.hpp" @@ -84,8 +85,7 @@ void ActsExamples::NeuralCalibrator::calibrate( assert((idxSourceLink.index() < measurements.size()) and "Source link index is outside the container bounds"); - if (std::find(m_volumeIds.begin(), m_volumeIds.end(), - idxSourceLink.geometryId().volume()) == m_volumeIds.end()) { + if (!rangeContainsValue(m_volumeIds, idxSourceLink.geometryId())) { m_fallback.calibrate(measurements, clusters, gctx, cctx, sourceLink, trackState); return; diff --git a/Examples/Io/Csv/include/ActsExamples/Io/Csv/CsvInputOutput.hpp b/Examples/Io/Csv/include/ActsExamples/Io/Csv/CsvInputOutput.hpp index 7c4ede4659c..3006f498cc6 100644 --- a/Examples/Io/Csv/include/ActsExamples/Io/Csv/CsvInputOutput.hpp +++ b/Examples/Io/Csv/include/ActsExamples/Io/Csv/CsvInputOutput.hpp @@ -36,6 +36,7 @@ // SOFTWARE. #include "Acts/Utilities/Concepts.hpp" +#include "Acts/Utilities/Helpers.hpp" #include #include @@ -590,13 +591,11 @@ inline void NamedTupleDsvReader::parse_header( // check that all non-optional columns are available for (const auto& name : names) { // no need to for availability if the column is optional - auto o = std::find(optional_columns.begin(), optional_columns.end(), name); - if (o != optional_columns.end()) { + if (Acts::rangeContainsValue(optional_columns, name)) { continue; } // missing, non-optional column mean we can not continue - auto c = std::find(m_columns.begin(), m_columns.end(), name); - if (c == m_columns.end()) { + if (!Acts::rangeContainsValue(m_columns, name)) { throw std::runtime_error("Missing header column '" + name + "'"); } } diff --git a/Examples/Io/Performance/ActsExamples/Io/Performance/TrackFitterPerformanceWriter.cpp b/Examples/Io/Performance/ActsExamples/Io/Performance/TrackFitterPerformanceWriter.cpp index 3c4c263b533..a420d07aee0 100644 --- a/Examples/Io/Performance/ActsExamples/Io/Performance/TrackFitterPerformanceWriter.cpp +++ b/Examples/Io/Performance/ActsExamples/Io/Performance/TrackFitterPerformanceWriter.cpp @@ -161,10 +161,8 @@ ActsExamples::ProcessCode ActsExamples::TrackFitterPerformanceWriter::writeT( // one truth track) for (const auto& particle : particles) { bool isReconstructed = false; - // Find if the particle has been reconstructed - auto it = std::find(reconParticleIds.begin(), reconParticleIds.end(), - particle.particleId()); - if (it != reconParticleIds.end()) { + // Check if the particle has been reconstructed + if (rangeContainsValue(reconParticleIds, particle.particleId())) { isReconstructed = true; } // Loop over all the other truth particle and find the distance to the diff --git a/Examples/Python/src/Geometry.cpp b/Examples/Python/src/Geometry.cpp index 4f4752aa4ef..89e2493c764 100644 --- a/Examples/Python/src/Geometry.cpp +++ b/Examples/Python/src/Geometry.cpp @@ -35,6 +35,7 @@ #include "Acts/Plugins/Python/Utilities.hpp" #include "Acts/Surfaces/Surface.hpp" #include "Acts/Surfaces/SurfaceArray.hpp" +#include "Acts/Utilities/Helpers.hpp" #include "Acts/Utilities/RangeXD.hpp" #include "ActsExamples/Geometry/VolumeAssociationTest.hpp" @@ -66,11 +67,9 @@ struct MaterialSurfaceSelector { /// @param surface is the test surface void operator()(const Acts::Surface* surface) { - if (surface->surfaceMaterial() != nullptr) { - if (std::find(surfaces.begin(), surfaces.end(), surface) == - surfaces.end()) { - surfaces.push_back(surface); - } + if (surface->surfaceMaterial() != nullptr && + !rangeContainsValue(surfaces, surface)) { + surfaces.push_back(surface); } } }; diff --git a/Examples/Python/src/Svg.cpp b/Examples/Python/src/Svg.cpp index 74d6197ea2f..36bec574e22 100644 --- a/Examples/Python/src/Svg.cpp +++ b/Examples/Python/src/Svg.cpp @@ -20,6 +20,7 @@ #include "Acts/Plugins/ActSVG/TrackingGeometrySvgConverter.hpp" #include "Acts/Plugins/Python/Utilities.hpp" #include "Acts/Utilities/Enumerate.hpp" +#include "Acts/Utilities/Helpers.hpp" #include "ActsExamples/EventData/GeometryContainers.hpp" #include "ActsExamples/EventData/SimHit.hpp" #include "ActsExamples/EventData/SimSpacePoint.hpp" @@ -68,17 +69,13 @@ actsvg::svg::object viewDetectorVolume(const Svg::ProtoVolume& pVolume, svgDet._id = identification; svgDet._tag = "g"; - auto [view, selection, viewRange] = viewAndRange; + const auto& [view, selection, viewRange] = viewAndRange; // Translate selection into booleans - bool all = - std::find(selection.begin(), selection.end(), "all") != selection.end(); - bool sensitives = std::find(selection.begin(), selection.end(), - "sensitives") != selection.end(); - bool portals = std::find(selection.begin(), selection.end(), "portals") != - selection.end(); - bool materials = std::find(selection.begin(), selection.end(), "materials") != - selection.end(); + const bool all = rangeContainsValue(selection, "all"); + const bool sensitives = rangeContainsValue(selection, "sensitives"); + const bool portals = rangeContainsValue(selection, "portals"); + const bool materials = rangeContainsValue(selection, "materials"); // Helper lambda for material selection auto materialSel = [&](const Svg::ProtoSurface& s) -> bool { @@ -138,8 +135,7 @@ actsvg::svg::object viewDetectorVolume(const Svg::ProtoVolume& pVolume, gpIDs = pgID->second._id; } - if (std::find(portalCache.begin(), portalCache.end(), gpIDs) != - portalCache.end()) { + if (rangeContainsValue(portalCache, gpIDs)) { continue; } diff --git a/Examples/Scripts/MaterialMapping/Mat_map_detector_plot.C b/Examples/Scripts/MaterialMapping/Mat_map_detector_plot.C index deeb7c275a3..ae4c7c5588b 100644 --- a/Examples/Scripts/MaterialMapping/Mat_map_detector_plot.C +++ b/Examples/Scripts/MaterialMapping/Mat_map_detector_plot.C @@ -8,6 +8,8 @@ #include +#include "Acts/Utilities/Helpers.hpp" + #include "materialPlotHelper.cpp" #include @@ -153,7 +155,7 @@ void Fill(std::vector& detector_hist, const std::string& input_file, std: } // Check if the volume/surface is part of the selected ones - if(std::find(detectors.begin(), detectors.end(), ID.volume()) != detectors.end()) { + if(rangeContainsValue(detectors, ID.volume())) { matX0 += mat_step_length->at(j) / mat_X0->at(j); matL0 += mat_step_length->at(j) / mat_L0->at(j); } diff --git a/Plugins/Detray/src/DetrayMaterialConverter.cpp b/Plugins/Detray/src/DetrayMaterialConverter.cpp index 14fdd2163df..b31a1d2e81a 100644 --- a/Plugins/Detray/src/DetrayMaterialConverter.cpp +++ b/Plugins/Detray/src/DetrayMaterialConverter.cpp @@ -16,6 +16,7 @@ #include "Acts/Surfaces/Surface.hpp" #include "Acts/Utilities/BinUtility.hpp" #include "Acts/Utilities/BinningType.hpp" +#include "Acts/Utilities/Helpers.hpp" #include @@ -26,11 +27,9 @@ struct MaterialSurfaceSelector { /// @param surface is the test surface void operator()(const Acts::Surface* surface) { - if (surface->surfaceMaterial() != nullptr) { - if (std::find(surfaces.begin(), surfaces.end(), surface) == - surfaces.end()) { - surfaces.push_back(surface); - } + if (surface->surfaceMaterial() != nullptr && + !rangeContainsValue(surfaces, surface)) { + surfaces.push_back(surface); } } }; diff --git a/Plugins/GeoModel/src/GeoModelBlueprintCreater.cpp b/Plugins/GeoModel/src/GeoModelBlueprintCreater.cpp index 7495f8cca39..84a6476a8e4 100644 --- a/Plugins/GeoModel/src/GeoModelBlueprintCreater.cpp +++ b/Plugins/GeoModel/src/GeoModelBlueprintCreater.cpp @@ -17,6 +17,7 @@ #include "Acts/Plugins/GeoModel/detail/GeoModelExtentHelper.hpp" #include "Acts/Utilities/BinningType.hpp" #include "Acts/Utilities/Enumerate.hpp" +#include "Acts/Utilities/Helpers.hpp" #include "Acts/Utilities/RangeXD.hpp" #include @@ -147,8 +148,7 @@ Acts::GeoModelBlueprintCreater::createNode( detail::GeoModelExentHelper::readBinningConstraints(entry.binnings); // Concatenate the binning constraints for (const auto& bc : binningConstraints) { - if (std::find(internalConstraints.begin(), internalConstraints.end(), bc) == - internalConstraints.end()) { + if (!rangeContainsValue(internalConstraints, bc)) { internalConstraints.push_back(bc); } } diff --git a/Plugins/Json/src/DetectorJsonConverter.cpp b/Plugins/Json/src/DetectorJsonConverter.cpp index 0dd8d7520f8..80b737b3447 100644 --- a/Plugins/Json/src/DetectorJsonConverter.cpp +++ b/Plugins/Json/src/DetectorJsonConverter.cpp @@ -44,7 +44,7 @@ nlohmann::json Acts::DetectorJsonConverter::toJson( for (const auto* volume : detector.volumes()) { nSurfaces += volume->surfaces().size(); for (const auto& portal : volume->portals()) { - if (std::find(portals.begin(), portals.end(), portal) == portals.end()) { + if (!rangeContainsValue(portals, portal)) { portals.push_back(portal); } } diff --git a/Plugins/Podio/include/Acts/Plugins/Podio/PodioTrackContainer.hpp b/Plugins/Podio/include/Acts/Plugins/Podio/PodioTrackContainer.hpp index a4c71eb2c7c..f04cf6d7c6a 100644 --- a/Plugins/Podio/include/Acts/Plugins/Podio/PodioTrackContainer.hpp +++ b/Plugins/Podio/include/Acts/Plugins/Podio/PodioTrackContainer.hpp @@ -15,6 +15,7 @@ #include "Acts/EventData/detail/DynamicColumn.hpp" #include "Acts/Plugins/Podio/PodioDynamicColumns.hpp" #include "Acts/Plugins/Podio/PodioUtil.hpp" +#include "Acts/Utilities/Helpers.hpp" #include "ActsPodioEdm/Surface.h" #pragma GCC diagnostic push @@ -339,8 +340,7 @@ class ConstPodioTrackContainer : public PodioTrackContainerBase { std::string tracksKey = "tracks" + s; std::vector available = frame.getAvailableCollections(); - if (std::find(available.begin(), available.end(), tracksKey) == - available.end()) { + if (!rangeContainsValue(available, tracksKey)) { throw std::runtime_error{"Track collection '" + tracksKey + "' not found in frame"}; } diff --git a/Plugins/Podio/include/Acts/Plugins/Podio/PodioTrackStateContainer.hpp b/Plugins/Podio/include/Acts/Plugins/Podio/PodioTrackStateContainer.hpp index 60951942618..590d62a8d87 100644 --- a/Plugins/Podio/include/Acts/Plugins/Podio/PodioTrackStateContainer.hpp +++ b/Plugins/Podio/include/Acts/Plugins/Podio/PodioTrackStateContainer.hpp @@ -224,20 +224,17 @@ class ConstPodioTrackStateContainer final std::string paramsKey = "trackStateParameters" + s; std::string jacsKey = "trackStateJacobians" + s; - if (std::find(available.begin(), available.end(), trackStatesKey) == - available.end()) { + if (!rangeContainsValue(available, trackStatesKey)) { throw std::runtime_error{"Track state collection '" + trackStatesKey + "' not found in frame"}; } - if (std::find(available.begin(), available.end(), paramsKey) == - available.end()) { + if (!rangeContainsValue(available, paramsKey)) { throw std::runtime_error{"Track state parameters collection '" + paramsKey + "' not found in frame"}; } - if (std::find(available.begin(), available.end(), jacsKey) == - available.end()) { + if (!rangeContainsValue(available, jacsKey)) { throw std::runtime_error{"Track state jacobian collection '" + jacsKey + "' not found in frame"}; } diff --git a/Tests/UnitTests/Core/Clusterization/ClusterizationTests2D.cpp b/Tests/UnitTests/Core/Clusterization/ClusterizationTests2D.cpp index e850d213551..d4ebb6f2c37 100644 --- a/Tests/UnitTests/Core/Clusterization/ClusterizationTests2D.cpp +++ b/Tests/UnitTests/Core/Clusterization/ClusterizationTests2D.cpp @@ -9,6 +9,7 @@ #include #include "Acts/Clusterization/Clusterization.hpp" +#include "Acts/Utilities/Helpers.hpp" #include #include @@ -133,7 +134,7 @@ void genclusterw(int x, int y, int x0, int y0, int x1, int y1, auto maybe_add = [&](int x_, int y_) { Cell2D c(x_, y_); if (std::uniform_real_distribution()(rng) < startp && - std::find(cells.begin(), cells.end(), c) == cells.end()) { + !rangeContainsValue(cells, c)) { cells.push_back(c); add.push_back(c); } diff --git a/Tests/UnitTests/Core/Utilities/KDTreeTests.cpp b/Tests/UnitTests/Core/Utilities/KDTreeTests.cpp index 9c4a4d2fe64..d1fd310d1c5 100644 --- a/Tests/UnitTests/Core/Utilities/KDTreeTests.cpp +++ b/Tests/UnitTests/Core/Utilities/KDTreeTests.cpp @@ -8,6 +8,7 @@ #include +#include "Acts/Utilities/Helpers.hpp" #include "Acts/Utilities/KDTree.hpp" #include "Acts/Utilities/RangeXD.hpp" @@ -236,12 +237,12 @@ BOOST_FIXTURE_TEST_CASE(range_search_1, TreeFixture1DDoubleInt2) { std::vector result = tree.rangeSearch(range); BOOST_CHECK_EQUAL(result.size(), 3); - BOOST_CHECK((std::find(result.begin(), result.end(), 5) != result.end())); - BOOST_CHECK((std::find(result.begin(), result.end(), 6) != result.end())); - BOOST_CHECK((std::find(result.begin(), result.end(), 10) != result.end())); - BOOST_CHECK((std::find(result.begin(), result.end(), 7) == result.end())); - BOOST_CHECK((std::find(result.begin(), result.end(), 2) == result.end())); - BOOST_CHECK((std::find(result.begin(), result.end(), 9) == result.end())); + BOOST_CHECK(rangeContainsValue(result, 5)); + BOOST_CHECK(rangeContainsValue(result, 6)); + BOOST_CHECK(rangeContainsValue(result, 10)); + BOOST_CHECK(!rangeContainsValue(result, 7)); + BOOST_CHECK(!rangeContainsValue(result, 2)); + BOOST_CHECK(!rangeContainsValue(result, 9)); } BOOST_FIXTURE_TEST_CASE(range_search_2, TreeFixture1DDoubleInt2) { @@ -250,13 +251,13 @@ BOOST_FIXTURE_TEST_CASE(range_search_2, TreeFixture1DDoubleInt2) { std::vector result = tree.rangeSearch(range); BOOST_CHECK_EQUAL(result.size(), 7); - BOOST_CHECK((std::find(result.begin(), result.end(), 1) != result.end())); - BOOST_CHECK((std::find(result.begin(), result.end(), 2) != result.end())); - BOOST_CHECK((std::find(result.begin(), result.end(), 3) != result.end())); - BOOST_CHECK((std::find(result.begin(), result.end(), 5) != result.end())); - BOOST_CHECK((std::find(result.begin(), result.end(), 6) != result.end())); - BOOST_CHECK((std::find(result.begin(), result.end(), 9) != result.end())); - BOOST_CHECK((std::find(result.begin(), result.end(), 10) != result.end())); + BOOST_CHECK(rangeContainsValue(result, 1)); + BOOST_CHECK(rangeContainsValue(result, 2)); + BOOST_CHECK(rangeContainsValue(result, 3)); + BOOST_CHECK(rangeContainsValue(result, 5)); + BOOST_CHECK(rangeContainsValue(result, 6)); + BOOST_CHECK(rangeContainsValue(result, 9)); + BOOST_CHECK(rangeContainsValue(result, 10)); } BOOST_FIXTURE_TEST_CASE(range_search_3, TreeFixture1DDoubleInt2) { @@ -274,7 +275,7 @@ BOOST_FIXTURE_TEST_CASE(range_search_4, TreeFixture2DDoubleInt1) { std::vector result = tree.rangeSearch(range); BOOST_CHECK_EQUAL(result.size(), 1); - BOOST_CHECK((std::find(result.begin(), result.end(), 5) != result.end())); + BOOST_CHECK(rangeContainsValue(result, 5)); } BOOST_FIXTURE_TEST_CASE(range_search_5, TreeFixture2DDoubleInt1) { @@ -284,8 +285,8 @@ BOOST_FIXTURE_TEST_CASE(range_search_5, TreeFixture2DDoubleInt1) { std::vector result = tree.rangeSearch(range); BOOST_CHECK_EQUAL(result.size(), 2); - BOOST_CHECK((std::find(result.begin(), result.end(), 5) != result.end())); - BOOST_CHECK((std::find(result.begin(), result.end(), 6) != result.end())); + BOOST_CHECK(rangeContainsValue(result, 5)); + BOOST_CHECK(rangeContainsValue(result, 6)); } BOOST_FIXTURE_TEST_CASE(range_search_6, TreeFixture10DDoubleInt1) { @@ -294,11 +295,11 @@ BOOST_FIXTURE_TEST_CASE(range_search_6, TreeFixture10DDoubleInt1) { std::vector result = tree.rangeSearch(range); BOOST_CHECK_EQUAL(result.size(), 5); - BOOST_CHECK((std::find(result.begin(), result.end(), -66) != result.end())); - BOOST_CHECK((std::find(result.begin(), result.end(), -51) != result.end())); - BOOST_CHECK((std::find(result.begin(), result.end(), -19) != result.end())); - BOOST_CHECK((std::find(result.begin(), result.end(), -13) != result.end())); - BOOST_CHECK((std::find(result.begin(), result.end(), -83) != result.end())); + BOOST_CHECK(rangeContainsValue(result, -66)); + BOOST_CHECK(rangeContainsValue(result, -51)); + BOOST_CHECK(rangeContainsValue(result, -19)); + BOOST_CHECK(rangeContainsValue(result, -13)); + BOOST_CHECK(rangeContainsValue(result, -83)); } BOOST_FIXTURE_TEST_CASE(range_search_7, TreeFixture10DDoubleInt1) { @@ -307,8 +308,8 @@ BOOST_FIXTURE_TEST_CASE(range_search_7, TreeFixture10DDoubleInt1) { std::vector result = tree.rangeSearch(range); BOOST_CHECK_EQUAL(result.size(), 2); - BOOST_CHECK((std::find(result.begin(), result.end(), 27) != result.end())); - BOOST_CHECK((std::find(result.begin(), result.end(), -56) != result.end())); + BOOST_CHECK(rangeContainsValue(result, 27)); + BOOST_CHECK(rangeContainsValue(result, -56)); } BOOST_FIXTURE_TEST_CASE(range_search_8, TreeFixture3DDoubleString1) { @@ -319,8 +320,7 @@ BOOST_FIXTURE_TEST_CASE(range_search_8, TreeFixture3DDoubleString1) { std::vector result = tree.rangeSearch(range); BOOST_CHECK_EQUAL(result.size(), 1); - BOOST_CHECK( - (std::find(result.begin(), result.end(), "string0") != result.end())); + BOOST_CHECK(rangeContainsValue(result, "string0")); } BOOST_FIXTURE_TEST_CASE(range_search_9, TreeFixture3DDoubleString1) { @@ -331,14 +331,10 @@ BOOST_FIXTURE_TEST_CASE(range_search_9, TreeFixture3DDoubleString1) { std::vector result = tree.rangeSearch(range); BOOST_CHECK_EQUAL(result.size(), 4); - BOOST_CHECK( - (std::find(result.begin(), result.end(), "string0") != result.end())); - BOOST_CHECK( - (std::find(result.begin(), result.end(), "string3") != result.end())); - BOOST_CHECK( - (std::find(result.begin(), result.end(), "string4") != result.end())); - BOOST_CHECK( - (std::find(result.begin(), result.end(), "string9") != result.end())); + BOOST_CHECK(rangeContainsValue(result, "string0")); + BOOST_CHECK(rangeContainsValue(result, "string3")); + BOOST_CHECK(rangeContainsValue(result, "string4")); + BOOST_CHECK(rangeContainsValue(result, "string9")); } BOOST_FIXTURE_TEST_CASE(range_search_10, TreeFixture1DIntInt1) { @@ -347,8 +343,8 @@ BOOST_FIXTURE_TEST_CASE(range_search_10, TreeFixture1DIntInt1) { std::vector result = tree.rangeSearch(range); BOOST_CHECK_EQUAL(result.size(), 2); - BOOST_CHECK((std::find(result.begin(), result.end(), 5) != result.end())); - BOOST_CHECK((std::find(result.begin(), result.end(), 6) != result.end())); + BOOST_CHECK(rangeContainsValue(result, 5)); + BOOST_CHECK(rangeContainsValue(result, 6)); } BOOST_FIXTURE_TEST_CASE(range_search_11, TreeFixture2DIntInt1) { @@ -357,8 +353,8 @@ BOOST_FIXTURE_TEST_CASE(range_search_11, TreeFixture2DIntInt1) { std::vector result = tree.rangeSearch(range); BOOST_CHECK_EQUAL(result.size(), 2); - BOOST_CHECK((std::find(result.begin(), result.end(), 5) != result.end())); - BOOST_CHECK((std::find(result.begin(), result.end(), 6) != result.end())); + BOOST_CHECK(rangeContainsValue(result, 5)); + BOOST_CHECK(rangeContainsValue(result, 6)); } BOOST_FIXTURE_TEST_CASE(range_search_inplace_1, TreeFixture10DDoubleInt1) { @@ -369,11 +365,11 @@ BOOST_FIXTURE_TEST_CASE(range_search_inplace_1, TreeFixture10DDoubleInt1) { tree.rangeSearch(range, result); BOOST_CHECK_EQUAL(result.size(), 5); - BOOST_CHECK((std::find(result.begin(), result.end(), -66) != result.end())); - BOOST_CHECK((std::find(result.begin(), result.end(), -51) != result.end())); - BOOST_CHECK((std::find(result.begin(), result.end(), -19) != result.end())); - BOOST_CHECK((std::find(result.begin(), result.end(), -13) != result.end())); - BOOST_CHECK((std::find(result.begin(), result.end(), -83) != result.end())); + BOOST_CHECK(rangeContainsValue(result, -66)); + BOOST_CHECK(rangeContainsValue(result, -51)); + BOOST_CHECK(rangeContainsValue(result, -19)); + BOOST_CHECK(rangeContainsValue(result, -13)); + BOOST_CHECK(rangeContainsValue(result, -83)); } BOOST_FIXTURE_TEST_CASE(range_search_inserter_1, TreeFixture10DDoubleInt1) { @@ -384,11 +380,11 @@ BOOST_FIXTURE_TEST_CASE(range_search_inserter_1, TreeFixture10DDoubleInt1) { tree.rangeSearchInserter(range, std::back_inserter(result)); BOOST_CHECK_EQUAL(result.size(), 5); - BOOST_CHECK((std::find(result.begin(), result.end(), -66) != result.end())); - BOOST_CHECK((std::find(result.begin(), result.end(), -51) != result.end())); - BOOST_CHECK((std::find(result.begin(), result.end(), -19) != result.end())); - BOOST_CHECK((std::find(result.begin(), result.end(), -13) != result.end())); - BOOST_CHECK((std::find(result.begin(), result.end(), -83) != result.end())); + BOOST_CHECK(rangeContainsValue(result, -66)); + BOOST_CHECK(rangeContainsValue(result, -51)); + BOOST_CHECK(rangeContainsValue(result, -19)); + BOOST_CHECK(rangeContainsValue(result, -13)); + BOOST_CHECK(rangeContainsValue(result, -83)); } BOOST_FIXTURE_TEST_CASE(range_search_map_1, TreeFixture10DDoubleInt1) { @@ -400,11 +396,11 @@ BOOST_FIXTURE_TEST_CASE(range_search_map_1, TreeFixture10DDoubleInt1) { [](const std::array&, const int& i) -> int { return 2 * i; }); BOOST_CHECK_EQUAL(result.size(), 5); - BOOST_CHECK((std::find(result.begin(), result.end(), -132) != result.end())); - BOOST_CHECK((std::find(result.begin(), result.end(), -102) != result.end())); - BOOST_CHECK((std::find(result.begin(), result.end(), -38) != result.end())); - BOOST_CHECK((std::find(result.begin(), result.end(), -26) != result.end())); - BOOST_CHECK((std::find(result.begin(), result.end(), -166) != result.end())); + BOOST_CHECK(rangeContainsValue(result, -132)); + BOOST_CHECK(rangeContainsValue(result, -102)); + BOOST_CHECK(rangeContainsValue(result, -38)); + BOOST_CHECK(rangeContainsValue(result, -26)); + BOOST_CHECK(rangeContainsValue(result, -166)); } BOOST_FIXTURE_TEST_CASE(range_search_map_inserter_1, TreeFixture10DDoubleInt1) { @@ -421,11 +417,11 @@ BOOST_FIXTURE_TEST_CASE(range_search_map_inserter_1, TreeFixture10DDoubleInt1) { std::back_inserter(result)); BOOST_CHECK_EQUAL(result.size(), 5); - BOOST_CHECK((std::find(result.begin(), result.end(), "-66") != result.end())); - BOOST_CHECK((std::find(result.begin(), result.end(), "-51") != result.end())); - BOOST_CHECK((std::find(result.begin(), result.end(), "-19") != result.end())); - BOOST_CHECK((std::find(result.begin(), result.end(), "-13") != result.end())); - BOOST_CHECK((std::find(result.begin(), result.end(), "-83") != result.end())); + BOOST_CHECK(rangeContainsValue(result, "-66")); + BOOST_CHECK(rangeContainsValue(result, "-51")); + BOOST_CHECK(rangeContainsValue(result, "-19")); + BOOST_CHECK(rangeContainsValue(result, "-13")); + BOOST_CHECK(rangeContainsValue(result, "-83")); } BOOST_FIXTURE_TEST_CASE(range_search_map_inserter_2, TreeFixture2DIntInt1) { @@ -441,8 +437,8 @@ BOOST_FIXTURE_TEST_CASE(range_search_map_inserter_2, TreeFixture2DIntInt1) { std::back_inserter(result)); BOOST_CHECK_EQUAL(result.size(), 2); - BOOST_CHECK((std::find(result.begin(), result.end(), 40) != result.end())); - BOOST_CHECK((std::find(result.begin(), result.end(), 18) != result.end())); + BOOST_CHECK(rangeContainsValue(result, 40)); + BOOST_CHECK(rangeContainsValue(result, 18)); } BOOST_FIXTURE_TEST_CASE(range_search_map_discard_1, TreeFixture2DIntInt1) { @@ -500,8 +496,7 @@ BOOST_FIXTURE_TEST_CASE(range_search_combinatorial, TreeFixture3DDoubleInt2) { BOOST_CHECK_EQUAL(result.size(), valid.size()); for (int j : valid) { - BOOST_CHECK((std::find(result.begin(), result.end(), j) != - result.end())); + BOOST_CHECK(rangeContainsValue(result, j)); } } } @@ -517,10 +512,10 @@ BOOST_FIXTURE_TEST_CASE(range_search_dominate1, TreeFixture3DDoubleInt3) { std::vector result = tree.rangeSearch(range1); BOOST_CHECK_EQUAL(result.size(), 4); - BOOST_CHECK((std::find(result.begin(), result.end(), 0) != result.end())); - BOOST_CHECK((std::find(result.begin(), result.end(), 1) != result.end())); - BOOST_CHECK((std::find(result.begin(), result.end(), 2) != result.end())); - BOOST_CHECK((std::find(result.begin(), result.end(), 3) != result.end())); + BOOST_CHECK(rangeContainsValue(result, 0)); + BOOST_CHECK(rangeContainsValue(result, 1)); + BOOST_CHECK(rangeContainsValue(result, 2)); + BOOST_CHECK(rangeContainsValue(result, 3)); } BOOST_FIXTURE_TEST_CASE(range_search_dominate2, TreeFixture3DDoubleInt3) { @@ -529,10 +524,10 @@ BOOST_FIXTURE_TEST_CASE(range_search_dominate2, TreeFixture3DDoubleInt3) { std::vector result = tree.rangeSearch(range1); BOOST_CHECK_EQUAL(result.size(), 4); - BOOST_CHECK((std::find(result.begin(), result.end(), 4) != result.end())); - BOOST_CHECK((std::find(result.begin(), result.end(), 5) != result.end())); - BOOST_CHECK((std::find(result.begin(), result.end(), 6) != result.end())); - BOOST_CHECK((std::find(result.begin(), result.end(), 7) != result.end())); + BOOST_CHECK(rangeContainsValue(result, 4)); + BOOST_CHECK(rangeContainsValue(result, 5)); + BOOST_CHECK(rangeContainsValue(result, 6)); + BOOST_CHECK(rangeContainsValue(result, 7)); } BOOST_AUTO_TEST_CASE(range_search_very_big) { @@ -580,8 +575,7 @@ BOOST_AUTO_TEST_CASE(range_search_very_big) { BOOST_CHECK_EQUAL(result.size(), valid.size()); for (int j : valid) { - BOOST_CHECK( - (std::find(result.begin(), result.end(), j) != result.end())); + BOOST_CHECK(rangeContainsValue(result, j)); } } } @@ -620,13 +614,11 @@ BOOST_AUTO_TEST_CASE(range_search_many_same) { BOOST_CHECK_EQUAL(result2.size(), 50); for (int i = 0; i < 50; ++i) { - BOOST_CHECK( - (std::find(result1.begin(), result1.end(), i) != result1.end())); + BOOST_CHECK(rangeContainsValue(result1, i)); } for (int i = 50; i < 100; ++i) { - BOOST_CHECK( - (std::find(result2.begin(), result2.end(), i) != result2.end())); + BOOST_CHECK(rangeContainsValue(result2, i)); } } diff --git a/Tests/UnitTests/Plugins/ExaTrkX/ExaTrkXBoostTrackBuildingTests.cpp b/Tests/UnitTests/Plugins/ExaTrkX/ExaTrkXBoostTrackBuildingTests.cpp index 7fad2d0b071..65261563e34 100644 --- a/Tests/UnitTests/Plugins/ExaTrkX/ExaTrkXBoostTrackBuildingTests.cpp +++ b/Tests/UnitTests/Plugins/ExaTrkX/ExaTrkXBoostTrackBuildingTests.cpp @@ -10,6 +10,7 @@ #include "Acts/Plugins/ExaTrkX/BoostTrackBuilding.hpp" #include "Acts/Plugins/ExaTrkX/detail/TensorVectorConversion.hpp" +#include "Acts/Utilities/Helpers.hpp" #include @@ -56,7 +57,6 @@ BOOST_AUTO_TEST_CASE(test_track_building) { // Check what we have here for (const auto &refTrack : refTracks) { - auto found = std::find(testTracks.begin(), testTracks.end(), refTrack); - BOOST_CHECK(found != testTracks.end()); + BOOST_CHECK(Acts::rangeContainsValue(testTracks, refTrack)); } }