Skip to content

Commit

Permalink
Define pz funtions
Browse files Browse the repository at this point in the history
  • Loading branch information
beomki-yeo committed Nov 19, 2023
1 parent d32b266 commit 2c0e34c
Show file tree
Hide file tree
Showing 4 changed files with 39 additions and 0 deletions.
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 @@ -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); }

Expand All @@ -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;
Expand Down
15 changes: 15 additions & 0 deletions core/include/detray/tracks/detail/track_helper.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
8 changes: 8 additions & 0 deletions core/include/detray/tracks/free_track_parameters.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -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); }

Expand All @@ -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<e_free_size, 1>();
covariance_type m_covariance =
Expand Down
8 changes: 8 additions & 0 deletions tests/unit_tests/cpu/tools_track.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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],
Expand Down

0 comments on commit 2c0e34c

Please sign in to comment.