From 2c617b274382543a8b3c30bb581c62d53ed58133 Mon Sep 17 00:00:00 2001 From: Paul Gessinger Date: Thu, 31 Oct 2024 12:34:23 +0100 Subject: [PATCH] refactor: Remove free parameter estimation function --- .../Seeding/EstimateTrackParamsFromSeed.hpp | 99 ------------------- .../EstimateTrackParamsFromSeedTest.cpp | 23 ----- 2 files changed, 122 deletions(-) diff --git a/Core/include/Acts/Seeding/EstimateTrackParamsFromSeed.hpp b/Core/include/Acts/Seeding/EstimateTrackParamsFromSeed.hpp index f3850e102ce..f4f56946c84 100644 --- a/Core/include/Acts/Seeding/EstimateTrackParamsFromSeed.hpp +++ b/Core/include/Acts/Seeding/EstimateTrackParamsFromSeed.hpp @@ -22,105 +22,6 @@ #include namespace Acts { -/// @todo: -/// 1) Implement the simple Line and Circle fit based on Taubin Circle fit -/// 2) Implement the simple Line and Parabola fit (from HPS reconstruction by -/// Robert Johnson) - -/// Estimate the track parameters on the xy plane from at least three space -/// points. It assumes the trajectory projection on the xy plane is a circle, -/// i.e. the magnetic field is along global z-axis. -/// -/// The method is based on V. Karimaki NIM A305 (1991) 187-191: -/// https://doi.org/10.1016/0168-9002(91)90533-V -/// - no weights are used in Karimaki's fit; d0 is the distance of the point of -/// closest approach to the origin, 1/R is the curvature, phi is the angle of -/// the direction propagation (counter clockwise as positive) at the point of -/// cloest approach. -/// -/// @tparam spacepoint_iterator_t The type of space point iterator -/// -/// @param spBegin is the begin iterator for the space points -/// @param spEnd is the end iterator for the space points -/// @param logger A logger instance -/// -/// @return optional bound track parameters with the estimated d0, phi and 1/R -/// stored with the indices, eBoundLoc0, eBoundPhi and eBoundQOverP, -/// respectively. The bound parameters with other indices are set to zero. -template -std::optional estimateTrackParamsFromSeed( - spacepoint_iterator_t spBegin, spacepoint_iterator_t spEnd, - const Logger& logger = getDummyLogger()) { - // Check the number of provided space points - std::size_t numSP = std::distance(spBegin, spEnd); - if (numSP < 3) { - ACTS_ERROR("At least three space points are required."); - return std::nullopt; - } - - ActsScalar x2m = 0., xm = 0.; - ActsScalar xym = 0.; - ActsScalar y2m = 0., ym = 0.; - ActsScalar r2m = 0., r4m = 0.; - ActsScalar xr2m = 0., yr2m = 0.; - - for (spacepoint_iterator_t it = spBegin; it != spEnd; it++) { - if (*it == nullptr) { - ACTS_ERROR("Empty space point found. This should not happen."); - return std::nullopt; - } - - const auto& sp = *it; - - ActsScalar x = sp->x(); - ActsScalar y = sp->y(); - ActsScalar r2 = x * x + y * y; - x2m += x * x; - xm += x; - xym += x * y; - y2m += y * y; - ym += y; - r2m += r2; - r4m += r2 * r2; - xr2m += x * r2; - yr2m += y * r2; - numSP++; - } - x2m = x2m / numSP; - xm = xm / numSP; - xym = xym / numSP; - y2m = y2m / numSP; - ym = ym / numSP; - r2m = r2m / numSP; - r4m = r4m / numSP; - xr2m = xr2m / numSP; - yr2m = yr2m / numSP; - - ActsScalar Cxx = x2m - xm * xm; - ActsScalar Cxy = xym - xm * ym; - ActsScalar Cyy = y2m - ym * ym; - ActsScalar Cxr2 = xr2m - xm * r2m; - ActsScalar Cyr2 = yr2m - ym * r2m; - ActsScalar Cr2r2 = r4m - r2m * r2m; - - ActsScalar q1 = Cr2r2 * Cxy - Cxr2 * Cyr2; - ActsScalar q2 = Cr2r2 * (Cxx - Cyy) - Cxr2 * Cxr2 + Cyr2 * Cyr2; - - ActsScalar phi = 0.5 * std::atan(2 * q1 / q2); - ActsScalar k = (std::sin(phi) * Cxr2 - std::cos(phi) * Cyr2) * (1. / Cr2r2); - ActsScalar delta = -k * r2m + std::sin(phi) * xm - std::cos(phi) * ym; - - ActsScalar rho = (2 * k) / (std::sqrt(1 - 4 * delta * k)); - ActsScalar d0 = (2 * delta) / (1 + std::sqrt(1 - 4 * delta * k)); - - // Initialize the bound parameters vector - BoundVector params = BoundVector::Zero(); - params[eBoundLoc0] = d0; - params[eBoundPhi] = phi; - params[eBoundQOverP] = rho; - - return params; -} /// Estimate the full track parameters from three space points /// diff --git a/Tests/UnitTests/Core/Seeding/EstimateTrackParamsFromSeedTest.cpp b/Tests/UnitTests/Core/Seeding/EstimateTrackParamsFromSeedTest.cpp index de15f7e09c2..6161a8bdd33 100644 --- a/Tests/UnitTests/Core/Seeding/EstimateTrackParamsFromSeedTest.cpp +++ b/Tests/UnitTests/Core/Seeding/EstimateTrackParamsFromSeedTest.cpp @@ -165,9 +165,6 @@ BOOST_AUTO_TEST_CASE(trackparameters_estimation_test) { BOOST_TEST_INFO( "The truth track parameters at the bottom space point: \n" << expParams.transpose()); - // The curvature of track projection on the transverse plane in unit - // of 1/mm - double rho = expParams[eBoundQOverP] * 0.3 * 2. / UnitConstants::m; // The space point pointers std::array spacePointPtrs{}; @@ -175,26 +172,6 @@ BOOST_AUTO_TEST_CASE(trackparameters_estimation_test) { spacePointPtrs.begin(), [](const auto& sp) { return &sp.second; }); - // Test the partial track parameters estimator - auto partialParamsOpt = estimateTrackParamsFromSeed( - spacePointPtrs.begin(), spacePointPtrs.end(), *logger); - BOOST_REQUIRE(partialParamsOpt.has_value()); - const auto& estPartialParams = partialParamsOpt.value(); - BOOST_TEST_INFO( - "The estimated track parameters at the transverse plane: \n" - << estPartialParams.transpose()); - - // The particle starting position is (0, 0, 0). Hence, d0 is zero; the - // phi at the point of cloest approach is exactly the phi of the truth - // particle - CHECK_CLOSE_ABS(estPartialParams[eBoundLoc0], 0., 1e-5); - CHECK_CLOSE_ABS(estPartialParams[eBoundPhi], phi, 1e-5); - CHECK_CLOSE_ABS(estPartialParams[eBoundQOverP], rho, 1e-4); - // The loc1, theta and time are set to zero in the estimator - CHECK_CLOSE_ABS(estPartialParams[eBoundLoc1], 0., 1e-10); - CHECK_CLOSE_ABS(estPartialParams[eBoundTheta], 0., 1e-10); - CHECK_CLOSE_ABS(estPartialParams[eBoundTime], 0., 1e-10); - // Test the full track parameters estimator auto fullParamsOpt = estimateTrackParamsFromSeed( geoCtx, spacePointPtrs.begin(), spacePointPtrs.end(),