Skip to content

Commit

Permalink
Merge branch 'acts-project:main' into visualization/surfaces
Browse files Browse the repository at this point in the history
  • Loading branch information
fredevb authored Aug 15, 2023
2 parents 7726a87 + 1dd4855 commit d5a9248
Show file tree
Hide file tree
Showing 8 changed files with 48 additions and 23 deletions.
2 changes: 1 addition & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

# Set up the project.
cmake_minimum_required( VERSION 3.11 )
project( detray VERSION 0.37.0 LANGUAGES CXX )
project( detray VERSION 0.41.0 LANGUAGES CXX )

# Set up the used C++ standard(s).
set( CMAKE_CXX_STANDARD 17 CACHE STRING "The (host) C++ standard to use" )
Expand Down
11 changes: 11 additions & 0 deletions core/include/detray/geometry/detail/surface_kernels.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,17 @@ struct surface_kernels {
}
};

/// A functor get the measurement dimension
struct meas_dim {
template <typename mask_group_t, typename index_t>
DETRAY_HOST_DEVICE inline unsigned int operator()(
const mask_group_t& /*mask_group*/,
const index_t& /*index*/) const {

return mask_group_t::value_type::shape::meas_dim;
}
};

/// A functor get the surface normal at a given local/bound position
struct normal {
template <typename mask_group_t, typename index_t>
Expand Down
6 changes: 6 additions & 0 deletions core/include/detray/geometry/surface.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -139,6 +139,12 @@ class surface {
return transform(ctx).translation();
}

/// @returns the measurement dimesntion of surface
DETRAY_HOST_DEVICE
constexpr auto meas_dim() const -> unsigned int {
return visit_mask<typename kernels::meas_dim>();
}

/// @returns the surface normal in global coordinates at a given bound/local
/// position @param p
template <typename point_t = point2,
Expand Down
5 changes: 3 additions & 2 deletions core/include/detray/masks/line.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
#include "detray/coordinates/cartesian3.hpp"
#include "detray/coordinates/line2.hpp"
#include "detray/definitions/containers.hpp"
#include "detray/definitions/math.hpp"
#include "detray/definitions/qualifiers.hpp"
#include "detray/intersection/line_intersector.hpp"
#include "detray/surface_finders/grid/detail/axis_binning.hpp"
Expand Down Expand Up @@ -122,9 +123,9 @@ class line {
// size and (2) the distance to the point of closest approach on thw
// line from the line center is less than the half line length
if constexpr (square_cross_sect) {
return (std::abs(loc_p[0] * std::cos(loc_p[2])) <=
return (std::abs(loc_p[0] * math_ns::cos(loc_p[2])) <=
bounds[e_cross_section] + tol &&
std::abs(loc_p[0] * std::sin(loc_p[2])) <=
std::abs(loc_p[0] * math_ns::sin(loc_p[2])) <=
bounds[e_cross_section] + tol &&
std::abs(loc_p[1]) <= bounds[e_half_z] + tol);

Expand Down
3 changes: 3 additions & 0 deletions tests/unit_tests/cpu/geometry_surface.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -147,4 +147,7 @@ GTEST_TEST(detray_geometry, surface) {
ASSERT_NEAR(global2[1], glob_pos[1], tol);
// The bound transform assumes the point is on surface
ASSERT_NEAR(global2[2], disc_translation[2], tol);

// WARNING: This should be 0u for portal
ASSERT_EQ(disc.meas_dim(), 2u);
}
22 changes: 11 additions & 11 deletions tests/unit_tests/cpu/tools_navigator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -289,7 +289,7 @@ GTEST_TEST(detray_navigator, wire_chamber) {

// test track
point3 pos{0.f, 0.f, 0.f};
vector3 mom{1.f, 0.f, 0.f};
vector3 mom{0.f, 1.f, 0.f};
free_track_parameters<transform3> traj(pos, 0.f, mom, -1.f);

stepper_t stepper;
Expand Down Expand Up @@ -364,16 +364,16 @@ GTEST_TEST(detray_navigator, wire_chamber) {
std::map<dindex, std::vector<dindex>> sf_sequences;

// layer 1 to 10
sf_sequences[1] = {3u, 7u, 4u};
sf_sequences[2] = {167u, 171u, 168u};
sf_sequences[3] = {337u, 341u, 338u};
sf_sequences[4] = {513u, 517u, 514u};
sf_sequences[5] = {696u, 700u, 697u};
sf_sequences[6] = {885u, 889u, 886u};
sf_sequences[7] = {1080u, 1084u, 1081u};
sf_sequences[8] = {1281u, 1285u, 1282u};
sf_sequences[9] = {1489u, 1493u, 1490u};
sf_sequences[10] = {1703u, 1707u, 1704u};
sf_sequences[1] = {3u, 47u, 4u};
sf_sequences[2] = {168u, 214u, 169u};
sf_sequences[3] = {339u, 386u, 340u};
sf_sequences[4] = {516u, 565u, 517u};
sf_sequences[5] = {700u, 750u, 701u};
sf_sequences[6] = {890u, 942u, 891u};
sf_sequences[7] = {1086u, 1139u, 1087u};
sf_sequences[8] = {1288u, 1343u, 1289u};
sf_sequences[9] = {1497u, 1554u, 1498u};
sf_sequences[10] = {1712u, 1770u, 1713u};

// Every iteration steps through one wire layer
for (const auto &[vol_id, sf_seq] : sf_sequences) {
Expand Down
3 changes: 2 additions & 1 deletion utils/include/detray/detectors/create_toy_geometry.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -453,7 +453,8 @@ void create_endcap_modules(context_t &ctx, volume_type &vol,
// the module transform from the position
scalar m_phi{algebra::getter::phi(m_position)};
// the center position of the modules
point3 m_center{static_cast<scalar>(cfg.side) * m_position};
point3 m_center{m_position};
m_center[2] *= static_cast<scalar>(cfg.side);
// the rotation matrix of the module
vector3 m_local_y{math_ns::cos(m_phi), std::sin(m_phi), 0.f};
// take different axis to have the same readout direction
Expand Down
19 changes: 11 additions & 8 deletions utils/include/detray/detectors/create_wire_chamber.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -151,9 +151,7 @@ auto create_wire_chamber(vecmem::memory_resource &resource,

// Layer configuration
const scalar center_layer_rad = inner_layer_rad + cell_size;
const scalar theta = 2 * cell_size / center_layer_rad;
const unsigned int n_wires_per_layer =
static_cast<unsigned int>(2 * constant<scalar>::pi / theta);
const scalar delta = 2 * cell_size / center_layer_rad;

// Get volume ID
auto volume_idx = vol.index();
Expand All @@ -169,14 +167,19 @@ auto create_wire_chamber(vecmem::memory_resource &resource,

// Wire center positions
detray::dvector<point3> m_centers{};
for (unsigned int i_w = 0u; i_w < n_wires_per_layer; i_w++) {
const scalar x =
center_layer_rad * std::cos(theta * static_cast<scalar>(i_w));
const scalar y =
center_layer_rad * std::sin(theta * static_cast<scalar>(i_w));

unsigned int n_wires_per_layer{0u};
scalar theta{0.f};
while (theta <= 2.f * constant<scalar>::pi) {

const scalar x = center_layer_rad * std::cos(theta);
const scalar y = center_layer_rad * std::sin(theta);
const scalar z = 0.f;

m_centers.push_back({x, y, z});

n_wires_per_layer++;
theta += delta;
}

for (auto &m_center : m_centers) {
Expand Down

0 comments on commit d5a9248

Please sign in to comment.