Skip to content

Commit

Permalink
Make track parameter estimation work for low curvature
Browse files Browse the repository at this point in the history
  • Loading branch information
beomki-yeo committed Feb 22, 2024
1 parent fd145d8 commit 19054c3
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 15 deletions.
15 changes: 6 additions & 9 deletions core/include/traccc/seeding/track_params_estimation_helper.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -81,15 +81,12 @@ inline TRACCC_HOST_DEVICE bound_vector seed_to_bound_vector(
scalar A = (uv2[1] - uv1[1]) / (uv2[0] - uv1[0]);
scalar B = uv2[1] - A * uv2[0];

// Curvature (with a sign) estimate
scalar rho = -2.0f * B / getter::perp(vector2{1., A});
// The projection of the top space point on the transverse plane of
// the new frame
scalar rn = local2[0] * local2[0] + local2[1] * local2[1];
// The (1/tanTheta) of momentum in the new frame
static constexpr scalar G = static_cast<scalar>(1.f / 24.f);
// Radius is a signed distance between circleCenter and first sp, which is
// at (0, 0) in the new frame. Sign depends on B
const scalar signed_R = -0.5f * getter::perp(vector2{1., A}) / B;
scalar invTanTheta =
local2[2] * std::sqrt(1.f / rn) / (1.f + G * rho * rho * rn);
local2[2] /
(2.f * signed_R * std::asin(getter::perp(local2) / (2.f * signed_R)));

// The momentum direction in the new frame (the center of the circle
// has the coordinate (-1.*A/(2*B), 1./(2*B)))
Expand All @@ -110,7 +107,7 @@ inline TRACCC_HOST_DEVICE bound_vector seed_to_bound_vector(

// The estimated q/pt in [GeV/c]^-1 (note that the pt is the
// projection of momentum on the transverse plane of the new frame)
scalar qOverPt = rho / getter::norm(bfield);
scalar qOverPt = 1.f / (signed_R * getter::norm(bfield));
// The estimated q/p in [GeV/c]^-1
getter::element(params, e_bound_qoverp, 0) =
qOverPt / getter::perp(vector2{1., invTanTheta});
Expand Down
27 changes: 21 additions & 6 deletions tests/cpu/test_track_params_estimation.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,14 @@

using namespace traccc;

TEST(track_params_estimation, helix) {
// Track parameter estimation with 10 X momentum input
class TrackParameterEstimationTest
: public testing::TestWithParam<traccc::scalar> {};

TEST_P(TrackParameterEstimationTest, helix) {

// Momentum = 0.1 * input parameter
const scalar p0 = static_cast<scalar>(GetParam() * 0.1f);

// Memory resource used by the EDM.
vecmem::host_memory_resource host_mr;
Expand All @@ -34,17 +41,19 @@ TEST(track_params_estimation, helix) {
// Track property
const point3 pos{0.f, 0.f, 0.f};
const scalar time{0.f};
const vector3 mom{1.f, 0.f, 1.f * unit<scalar>::GeV};
vector3 mom{1.f, 0.f, 1.f * unit<scalar>::GeV};
mom = p0 * vector::normalize(mom);

const scalar q{-1.f * unit<scalar>::e};

// Make a helix
detray::detail::helix<transform3> hlx(pos, time, mom, q, &B);

// Make three spacepoints with the helix
spacepoint_collection_types::host spacepoints;
spacepoints.push_back({hlx(50 * unit<scalar>::mm), {}});
spacepoints.push_back({hlx(100 * unit<scalar>::mm), {}});
spacepoints.push_back({hlx(150 * unit<scalar>::mm), {}});
spacepoints.push_back({hlx(200 * unit<scalar>::mm), {}});
spacepoints.push_back({hlx(400 * unit<scalar>::mm), {}});
spacepoints.push_back({hlx(600 * unit<scalar>::mm), {}});

// Make a seed from the three spacepoints
seed_collection_types::host seeds;
Expand All @@ -58,4 +67,10 @@ TEST(track_params_estimation, helix) {
// momentum
ASSERT_EQ(bound_params.size(), 1u);
ASSERT_NEAR(bound_params[0].p(), getter::norm(mom), 1e-4);
}
}

// Test from 0.1 to 10 GeV/c
INSTANTIATE_TEST_SUITE_P(TrackParameterEstimationGroup,
TrackParameterEstimationTest,
testing::Range(1.f, 100.f),
testing::PrintToStringParamName());

0 comments on commit 19054c3

Please sign in to comment.