Skip to content

Commit

Permalink
refactor!: Remove free parameter estimation function (acts-project#3802)
Browse files Browse the repository at this point in the history
This removes a track parameter estimate function that we currently don't use anymore, and is easy to not use correctly.
I propose to remove this overload entirely if we don't need it.
  • Loading branch information
paulgessinger authored and Rosie-Hasan committed Nov 19, 2024
1 parent 91223f2 commit ca496e9
Show file tree
Hide file tree
Showing 2 changed files with 0 additions and 122 deletions.
99 changes: 0 additions & 99 deletions Core/include/Acts/Seeding/EstimateTrackParamsFromSeed.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,105 +22,6 @@
#include <optional>

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 <typename spacepoint_iterator_t>
std::optional<BoundVector> 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
///
Expand Down
23 changes: 0 additions & 23 deletions Tests/UnitTests/Core/Seeding/EstimateTrackParamsFromSeedTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -165,36 +165,13 @@ 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<const SpacePoint*, 3> spacePointPtrs{};
std::transform(spacePoints.begin(), std::next(spacePoints.begin(), 3),
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(),
Expand Down

0 comments on commit ca496e9

Please sign in to comment.