From f8c2490e3796d02c5b1f60626328d485e8625eb5 Mon Sep 17 00:00:00 2001 From: Andreas Stefl Date: Fri, 22 Nov 2024 15:53:42 +0100 Subject: [PATCH] pr feedback --- .../Seeding/EstimateTrackParamsFromSeed.hpp | 8 +++---- .../Seeding/EstimateTrackParamsFromSeed.cpp | 12 +++++++---- .../src/TrackParamsEstimationAlgorithm.cpp | 21 +++---------------- .../EstimateTrackParamsFromSeedTest.cpp | 4 ++-- 4 files changed, 17 insertions(+), 28 deletions(-) diff --git a/Core/include/Acts/Seeding/EstimateTrackParamsFromSeed.hpp b/Core/include/Acts/Seeding/EstimateTrackParamsFromSeed.hpp index 7d441c61edf..690a73f1a41 100644 --- a/Core/include/Acts/Seeding/EstimateTrackParamsFromSeed.hpp +++ b/Core/include/Acts/Seeding/EstimateTrackParamsFromSeed.hpp @@ -10,7 +10,7 @@ #include "Acts/Definitions/Algebra.hpp" #include "Acts/Definitions/TrackParametrization.hpp" -#include "Acts/EventData/TrackParameters.hpp" +#include "Acts/Definitions/Units.hpp" #include "Acts/Surfaces/Surface.hpp" #include "Acts/Utilities/Zip.hpp" @@ -65,7 +65,7 @@ Result estimateTrackParamsFromSeedAtSurface( const Surface& surface, const Vector3& sp0, const Vector3& sp1, const Vector3& sp2, const std::shared_ptr& bField, - const std::shared_ptr& propagator, + const std::shared_ptr& propagator = nullptr, const Acts::Logger& logger = getDummyLogger()); /// Estimate the full track parameters from three space points @@ -141,11 +141,11 @@ FreeVector estimateTrackParamsFromSeed(spacepoint_range_t spRange, /// /// @return bound parameters template -Result estimateTrackParamsFromSeed( +Result estimateTrackParamsFromSeedAtSurface( const GeometryContext& gctx, const MagneticFieldContext& mctx, const Surface& surface, spacepoint_range_t spRange, const std::shared_ptr& bField, - const std::shared_ptr& propagator, + const std::shared_ptr& propagator = nullptr, const Acts::Logger& logger = getDummyLogger()) { // Check the number of provided space points if (spRange.size() != 3) { diff --git a/Core/src/Seeding/EstimateTrackParamsFromSeed.cpp b/Core/src/Seeding/EstimateTrackParamsFromSeed.cpp index b0845623829..86477ee7749 100644 --- a/Core/src/Seeding/EstimateTrackParamsFromSeed.cpp +++ b/Core/src/Seeding/EstimateTrackParamsFromSeed.cpp @@ -46,7 +46,8 @@ class EstimateTrackParamsFromSeedErrorCategory : public std::error_category { } // namespace -std::error_code Acts::make_error_code(Acts::PropagatorError e) { +std::error_code Acts::make_error_code( + Acts::EstimateTrackParamsFromSeedError e) { static EstimateTrackParamsFromSeedErrorCategory c; return {static_cast(e), c}; } @@ -195,8 +196,9 @@ Acts::Result Acts::estimateTrackParamsFromSeedAtSurface( if (!lpResult.ok()) { // no cov transport matrix is needed here // particle hypothesis does not matter here - CurvilinearTrackParameters estimatedParams( - origin, direction, qOverPt, std::nullopt, ParticleHypothesis::pion()); + CurvilinearTrackParameters estimatedParams(freeParams.segment<4>(eFreePos0), + direction, qOverPt, std::nullopt, + ParticleHypothesis::pion()); auto surfaceIntersection = surface.intersect(gctx, origin, direction).closest(); @@ -221,7 +223,9 @@ Acts::Result Acts::estimateTrackParamsFromSeedAtSurface( ? propagator->propagateToSurface(estimatedParams, surface, propagatorOptions) : Propagator(EigenStepper<>(bField), VoidNavigator(), - logger().cloneWithSuffix("Propagator")); + logger().cloneWithSuffix("Propagator")) + .propagateToSurface(estimatedParams, surface, + propagatorOptions); if (!result.ok()) { ACTS_INFO("The propagation failed."); return Result::failure( diff --git a/Examples/Algorithms/TrackFinding/src/TrackParamsEstimationAlgorithm.cpp b/Examples/Algorithms/TrackFinding/src/TrackParamsEstimationAlgorithm.cpp index f2711ce1d1a..b8dbd2f99c1 100644 --- a/Examples/Algorithms/TrackFinding/src/TrackParamsEstimationAlgorithm.cpp +++ b/Examples/Algorithms/TrackFinding/src/TrackParamsEstimationAlgorithm.cpp @@ -8,7 +8,6 @@ #include "ActsExamples/TrackFinding/TrackParamsEstimationAlgorithm.hpp" -#include "Acts/Definitions/Algebra.hpp" #include "Acts/Definitions/TrackParametrization.hpp" #include "Acts/EventData/Seed.hpp" #include "Acts/Geometry/GeometryIdentifier.hpp" @@ -101,24 +100,10 @@ ProcessCode TrackParamsEstimationAlgorithm::execute( continue; } - // Get the magnetic field at the bottom space point - auto fieldRes = m_cfg.magneticField->getField( - {bottomSP->x(), bottomSP->y(), bottomSP->z()}, bCache); - if (!fieldRes.ok()) { - ACTS_ERROR("Field lookup error: " << fieldRes.error()); - return ProcessCode::ABORT; - } - Acts::Vector3 field = *fieldRes; - - if (field.norm() < m_cfg.bFieldMin) { - ACTS_WARNING("Magnetic field at seed " << iseed << " is too small " - << field.norm()); - continue; - } - // Estimate the track parameters from seed - const auto paramsResult = Acts::estimateTrackParamsFromSeed( - ctx.geoContext, seed.sp(), *surface, field); + const auto paramsResult = Acts::estimateTrackParamsFromSeedAtSurface( + ctx.geoContext, ctx.magFieldContext, *surface, seed.sp(), + m_cfg.magneticField); if (!paramsResult.ok()) { ACTS_WARNING("Skip track because param estimation failed " << paramsResult.error()); diff --git a/Tests/UnitTests/Core/Seeding/EstimateTrackParamsFromSeedTest.cpp b/Tests/UnitTests/Core/Seeding/EstimateTrackParamsFromSeedTest.cpp index 45dbbd9d0bb..592dfcd1dbd 100644 --- a/Tests/UnitTests/Core/Seeding/EstimateTrackParamsFromSeedTest.cpp +++ b/Tests/UnitTests/Core/Seeding/EstimateTrackParamsFromSeedTest.cpp @@ -174,8 +174,8 @@ BOOST_AUTO_TEST_CASE(trackparameters_estimation_test) { BOOST_CHECK(!estFreeParams.hasNaN()); // Test the bound track parameters estimator - auto estFullParamsResult = estimateTrackParamsFromSeed( - geoCtx, spacePointPtrs, *bottomSurface, bField); + auto estFullParamsResult = estimateTrackParamsFromSeedAtSurface( + geoCtx, magCtx, *bottomSurface, spacePointPtrs, field); BOOST_CHECK(estFullParamsResult.ok()); const auto& estFullParams = estFullParamsResult.value(); BOOST_TEST_INFO(