diff --git a/core/include/detray/tracks/bound_track_parameters.hpp b/core/include/detray/tracks/bound_track_parameters.hpp index 870b65dc78..e4297b2b75 100644 --- a/core/include/detray/tracks/bound_track_parameters.hpp +++ b/core/include/detray/tracks/bound_track_parameters.hpp @@ -145,6 +145,9 @@ struct bound_track_parameters { DETRAY_HOST_DEVICE scalar_type qopT() const { return track_helper().qopT(m_vector); } + DETRAY_HOST_DEVICE + scalar_type qopz() const { return track_helper().qopz(m_vector); } + DETRAY_HOST_DEVICE scalar_type p() const { return track_helper().p(m_vector); } @@ -156,6 +159,11 @@ struct bound_track_parameters { return std::abs(1.f / this->qop() * getter::perp(this->dir())); } + DETRAY_HOST_DEVICE + scalar_type pz() const { + return std::abs(1.f / this->qop() * this->dir()[2]); + } + private: geometry::barcode m_barcode; vector_type m_vector; diff --git a/core/include/detray/tracks/detail/track_helper.hpp b/core/include/detray/tracks/detail/track_helper.hpp index 9ec5d711ff..a78427d00c 100644 --- a/core/include/detray/tracks/detail/track_helper.hpp +++ b/core/include/detray/tracks/detail/track_helper.hpp @@ -137,6 +137,21 @@ struct track_helper { sinTheta; } + DETRAY_HOST_DEVICE + inline scalar_type qopz(const free_vector& free_vec) const { + const auto dir = this->dir(free_vec); + return matrix_operator().element(free_vec, e_free_qoverp, 0u) / dir[2]; + } + + DETRAY_HOST_DEVICE + inline scalar_type qopz(const bound_vector& bound_vec) const { + const scalar_type theta{ + matrix_operator().element(bound_vec, e_bound_theta, 0u)}; + const scalar_type cosTheta{math_ns::cos(theta)}; + return matrix_operator().element(bound_vec, e_bound_qoverp, 0u) / + cosTheta; + } + DETRAY_HOST_DEVICE inline scalar_type time(const free_vector& free_vec) const { return matrix_operator().element(free_vec, e_free_time, 0u); diff --git a/core/include/detray/tracks/free_track_parameters.hpp b/core/include/detray/tracks/free_track_parameters.hpp index 8bfbab145b..f61a5198ea 100644 --- a/core/include/detray/tracks/free_track_parameters.hpp +++ b/core/include/detray/tracks/free_track_parameters.hpp @@ -147,6 +147,9 @@ struct free_track_parameters { DETRAY_HOST_DEVICE scalar_type qopT() const { return track_helper().qopT(m_vector); } + DETRAY_HOST_DEVICE + scalar_type qopz() const { return track_helper().qopz(m_vector); } + DETRAY_HOST_DEVICE scalar_type p() const { return track_helper().p(m_vector); } @@ -158,6 +161,11 @@ struct free_track_parameters { return std::abs(1.f / this->qop() * getter::perp(this->dir())); } + DETRAY_HOST_DEVICE + scalar_type pz() const { + return std::abs(1.f / this->qop() * this->dir()[2]); + } + private: vector_type m_vector = matrix_operator().template zero(); covariance_type m_covariance = diff --git a/tests/unit_tests/cpu/tools_track.cpp b/tests/unit_tests/cpu/tools_track.cpp index 9420d42781..9e79886cb2 100644 --- a/tests/unit_tests/cpu/tools_track.cpp +++ b/tests/unit_tests/cpu/tools_track.cpp @@ -59,6 +59,12 @@ GTEST_TEST(detray_tracks, bound_track_parameters) { std::sin(getter::element(bound_vec1, e_bound_theta, 0u)), tol); EXPECT_NEAR(bound_param1.qopT(), -1.f / bound_param1.pT(), tol); + EXPECT_NEAR(bound_param1.pz(), + 1.f / + std::abs(getter::element(bound_vec1, e_bound_qoverp, 0u)) * + std::cos(getter::element(bound_vec1, e_bound_theta, 0u)), + tol); + EXPECT_NEAR(bound_param1.qopz(), -1.f / bound_param1.pz(), tol); // second track dindex sf_idx2 = 1u; @@ -178,6 +184,8 @@ GTEST_TEST(detray_tracks, free_track_parameters) { 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.pz(), mom[2], tol); + EXPECT_NEAR(free_param1.qopz(), charge / free_param1.pz(), 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],