From d2e46a38f0a13e5abfcfde2c1f7f087356f92782 Mon Sep 17 00:00:00 2001 From: beomki-yeo Date: Thu, 17 Aug 2023 14:44:53 +0200 Subject: [PATCH 01/29] Refactor measurement ordering --- .../include/detray/coordinates/cartesian2.hpp | 5 +++-- .../detray/coordinates/coordinate_base.hpp | 12 +++++----- .../detray/coordinates/cylindrical2.hpp | 5 +++-- core/include/detray/coordinates/line2.hpp | 7 +++--- core/include/detray/coordinates/polar2.hpp | 5 +++-- core/include/detray/masks/annulus2D.hpp | 5 +---- core/include/detray/masks/cylinder2D.hpp | 5 +---- core/include/detray/masks/line.hpp | 5 +---- core/include/detray/masks/masks.hpp | 8 ++++--- core/include/detray/masks/rectangle2D.hpp | 5 +---- core/include/detray/masks/ring2D.hpp | 5 +---- core/include/detray/masks/single3D.hpp | 5 +---- core/include/detray/masks/trapezoid2D.hpp | 5 +---- core/include/detray/masks/unbounded.hpp | 3 --- tests/unit_tests/cpu/masks_annulus2D.cpp | 1 + tests/unit_tests/cpu/projection_matrix.cpp | 22 ++++++++++++------- .../validation/src/simulation_validation.cpp | 8 +++---- .../include/detray/tutorial/my_square2D.hpp | 4 ++-- .../detray/simulation/measurement_smearer.hpp | 5 ++--- 19 files changed, 54 insertions(+), 66 deletions(-) diff --git a/core/include/detray/coordinates/cartesian2.hpp b/core/include/detray/coordinates/cartesian2.hpp index a38625750..9c20595cb 100644 --- a/core/include/detray/coordinates/cartesian2.hpp +++ b/core/include/detray/coordinates/cartesian2.hpp @@ -158,10 +158,11 @@ struct cartesian2 final : public coordinate_base { // Do nothing } - template + template DETRAY_HOST_DEVICE inline void unsigned_local( matrix_type & /*projection_matrix*/, - const bound_track_parameters & /*bound_params*/) { + const bound_track_parameters & /*bound_params*/, + const bool /*normal_order*/) { // Do nothing return; } diff --git a/core/include/detray/coordinates/coordinate_base.hpp b/core/include/detray/coordinates/coordinate_base.hpp index e5b6dfb8f..5709b1155 100644 --- a/core/include/detray/coordinates/coordinate_base.hpp +++ b/core/include/detray/coordinates/coordinate_base.hpp @@ -241,15 +241,15 @@ struct coordinate_base { } /// @returns the projection matrix for measurement - template + template DETRAY_HOST_DEVICE inline matrix_type - projection_matrix( - const bound_track_parameters& bound_params) { + projection_matrix(const bound_track_parameters& bound_params, + const bool normal_order) { matrix_type proj = matrix_operator().template zero(); // For normal ordering - if constexpr (normal_order == true) { + if (normal_order == true) { // For meas_dim == 1, Return: // [ 1 0 0 0 0 0 ] if constexpr (meas_dim == 1u) { @@ -279,8 +279,8 @@ struct coordinate_base { } } - Derived().template unsigned_local( - proj, bound_params); + Derived().template unsigned_local( + proj, bound_params, normal_order); return proj; } diff --git a/core/include/detray/coordinates/cylindrical2.hpp b/core/include/detray/coordinates/cylindrical2.hpp index a3078fea2..7e17b479f 100644 --- a/core/include/detray/coordinates/cylindrical2.hpp +++ b/core/include/detray/coordinates/cylindrical2.hpp @@ -201,10 +201,11 @@ struct cylindrical2 : public coordinate_base { // Do nothing } - template + template DETRAY_HOST_DEVICE inline void unsigned_local( matrix_type & /*projection_matrix*/, - const bound_track_parameters & /*bound_params*/) { + const bound_track_parameters & /*bound_params*/, + const bool /*normal_order*/) { // Do nothing return; } diff --git a/core/include/detray/coordinates/line2.hpp b/core/include/detray/coordinates/line2.hpp index 54eb47c3f..035ba9abe 100644 --- a/core/include/detray/coordinates/line2.hpp +++ b/core/include/detray/coordinates/line2.hpp @@ -285,16 +285,17 @@ struct line2 : public coordinate_base { theta_to_free_pos_derivative[2]; } - template + template DETRAY_HOST_DEVICE inline void unsigned_local( matrix_type &projection_matrix, - const bound_track_parameters &bound_params) { + const bound_track_parameters &bound_params, + const bool normal_order) { const auto bound_local = bound_params.bound_local(); // Change the sign of radial distance if it is negative if (bound_local[0] < 0.f) { - if constexpr (normal_order == true) { + if (normal_order == true) { matrix_operator().element(projection_matrix, 0u, 0u) = -1.f; } else { if constexpr (meas_dim == 2u) { diff --git a/core/include/detray/coordinates/polar2.hpp b/core/include/detray/coordinates/polar2.hpp index 1bb73b5f4..8233c0c8e 100644 --- a/core/include/detray/coordinates/polar2.hpp +++ b/core/include/detray/coordinates/polar2.hpp @@ -211,10 +211,11 @@ struct polar2 : public coordinate_base { // Do nothing } - template + template DETRAY_HOST_DEVICE inline void unsigned_local( matrix_type & /*projection_matrix*/, - const bound_track_parameters & /*bound_params*/) { + const bound_track_parameters & /*bound_params*/, + const bool /*normal_order*/) { // Do nothing return; } diff --git a/core/include/detray/masks/annulus2D.hpp b/core/include/detray/masks/annulus2D.hpp index fc32309d1..02c6f7372 100644 --- a/core/include/detray/masks/annulus2D.hpp +++ b/core/include/detray/masks/annulus2D.hpp @@ -50,7 +50,7 @@ namespace detray { /// included (bounds[4], bounds[5]). These are the origin shift in x and y /// respectively. template