Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add pT function for bound track parameters #581

Merged
merged 1 commit into from
Oct 30, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions core/include/detray/tracks/bound_track_parameters.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -142,12 +142,20 @@ struct bound_track_parameters {
matrix_operator().element(m_vector, e_bound_qoverp, 0u) = qop;
}

DETRAY_HOST_DEVICE
scalar_type qopT() const { return track_helper().qopT(m_vector); }

DETRAY_HOST_DEVICE
scalar_type p() const { return track_helper().p(m_vector); }

DETRAY_HOST_DEVICE
vector3 mom() const { return track_helper().mom(m_vector); }

DETRAY_HOST_DEVICE
scalar_type pT() const {
return std::abs(1.f / this->qop() * getter::perp(this->dir()));
}

private:
geometry::barcode m_barcode;
vector_type m_vector;
Expand Down
16 changes: 16 additions & 0 deletions core/include/detray/tracks/detail/track_helper.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,22 @@ struct track_helper {
return matrix_operator().element(bound_vec, e_bound_qoverp, 0u);
}

DETRAY_HOST_DEVICE
inline scalar_type qopT(const free_vector& free_vec) const {
const auto dir = this->dir(free_vec);
return matrix_operator().element(free_vec, e_free_qoverp, 0u) /
getter::perp(dir);
}

DETRAY_HOST_DEVICE
inline scalar_type qopT(const bound_vector& bound_vec) const {
const scalar_type theta{
matrix_operator().element(bound_vec, e_bound_theta, 0u)};
const scalar_type sinTheta{math_ns::sin(theta)};
return matrix_operator().element(bound_vec, e_bound_qoverp, 0u) /
sinTheta;
}

DETRAY_HOST_DEVICE
inline scalar_type time(const free_vector& free_vec) const {
return matrix_operator().element(free_vec, e_free_time, 0u);
Expand Down
3 changes: 3 additions & 0 deletions core/include/detray/tracks/free_track_parameters.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -144,6 +144,9 @@ struct free_track_parameters {
matrix_operator().element(m_vector, e_free_qoverp, 0u) = qop;
}

DETRAY_HOST_DEVICE
scalar_type qopT() const { return track_helper().qopT(m_vector); }

DETRAY_HOST_DEVICE
scalar_type p() const { return track_helper().p(m_vector); }

Expand Down
7 changes: 7 additions & 0 deletions tests/unit_tests/cpu/tools_track.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,12 @@ GTEST_TEST(detray_tracks, bound_track_parameters) {

bound_track_parameters<transform3> bound_param1(
geometry::barcode{}.set_index(sf_idx1), bound_vec1, bound_cov1);
EXPECT_NEAR(bound_param1.pT(),
1.f /
std::abs(getter::element(bound_vec1, e_bound_qoverp, 0u)) *
std::sin(getter::element(bound_vec1, e_bound_theta, 0u)),
tol);
EXPECT_NEAR(bound_param1.qopT(), -1.f / bound_param1.pT(), tol);

// second track
dindex sf_idx2 = 1u;
Expand Down Expand Up @@ -171,6 +177,7 @@ GTEST_TEST(detray_tracks, free_track_parameters) {
tol);
EXPECT_NEAR(free_param1.pT(),
std::sqrt(std::pow(mom[0], 2.f) + std::pow(mom[1], 2.f)), tol);
EXPECT_NEAR(free_param1.qopT(), charge / free_param1.pT(), tol);
EXPECT_NEAR(free_param1.mom()[0], free_param1.p() * free_param1.dir()[0],
tol);
EXPECT_NEAR(free_param1.mom()[1], free_param1.p() * free_param1.dir()[1],
Expand Down