Skip to content

Commit

Permalink
Merge branch 'main' into remove-jac-to-global
Browse files Browse the repository at this point in the history
  • Loading branch information
beomki-yeo authored Sep 24, 2024
2 parents 8f20061 + ac96cd3 commit 19887aa
Show file tree
Hide file tree
Showing 9 changed files with 64 additions and 55 deletions.
5 changes: 3 additions & 2 deletions core/include/detray/builders/grid_builder.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ class grid_builder : public volume_decorator<detector_t> {
const std::vector<std::pair<typename grid_t::loc_bin_index, dindex>>
&bin_capacities = {},
const std::array<std::vector<scalar_type>, grid_t::dim> &ax_bin_edges =
{{}}) {
std::array<std::vector<scalar_type>, grid_t::dim>()) {

static_assert(
std::is_same_v<typename grid_shape_t::template local_frame_type<
Expand All @@ -100,7 +100,8 @@ class grid_builder : public volume_decorator<detector_t> {
const std::vector<std::size_t> &n_bins,
const std::vector<std::pair<typename grid_t::loc_bin_index, dindex>>
&bin_capacities = {},
const std::vector<std::vector<scalar_type>> &ax_bin_edges = {{}}) {
const std::vector<std::vector<scalar_type>> &ax_bin_edges =
std::vector<std::vector<scalar_type>>()) {

m_grid = m_factory.template new_grid<grid_t>(
spans, n_bins, bin_capacities, ax_bin_edges);
Expand Down
93 changes: 49 additions & 44 deletions core/include/detray/builders/grid_factory.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -81,14 +81,14 @@ class grid_factory {
typename phi_binning = axis::regular<host_container_types, scalar_type>,
std::enable_if_t<std::is_enum_v<decltype(r_bounds::label)>, bool> =
true>
auto new_grid(
const mask<annulus2D> &grid_bounds,
const std::array<std::size_t, 2UL> n_bins,
const std::vector<std::pair<loc_bin_index<annulus2D>, dindex>>
&bin_capacities = {},
const std::array<std::vector<scalar_type>, 2UL> &bin_edges = {{}},
const std::array<std::vector<scalar_type>, 2UL> &axis_spans = {
{}}) const {
auto new_grid(const mask<annulus2D> &grid_bounds,
const std::array<std::size_t, 2UL> n_bins,
const std::vector<std::pair<loc_bin_index<annulus2D>, dindex>>
&bin_capacities = {},
const std::array<std::vector<scalar_type>, 2UL> &bin_edges =
std::array<std::vector<scalar_type>, 2UL>(),
const std::array<std::vector<scalar_type>, 2UL> &axis_spans =
std::array<std::vector<scalar_type>, 2UL>()) const {

static_assert(
std::is_same_v<phi_bounds, axis::circular<>>,
Expand Down Expand Up @@ -140,14 +140,14 @@ class grid_factory {
typename z_binning = axis::regular<host_container_types, scalar_type>,
std::enable_if_t<std::is_enum_v<decltype(x_bounds::label)>, bool> =
true>
auto new_grid(
const mask<cuboid3D> &grid_bounds,
const std::array<std::size_t, 3UL> n_bins,
const std::vector<std::pair<loc_bin_index<cuboid3D>, dindex>>
&bin_capacities = {},
const std::array<std::vector<scalar_type>, 3UL> &bin_edges = {{}},
const std::array<std::vector<scalar_type>, 3UL> &axis_spans = {
{}}) const {
auto new_grid(const mask<cuboid3D> &grid_bounds,
const std::array<std::size_t, 3UL> n_bins,
const std::vector<std::pair<loc_bin_index<cuboid3D>, dindex>>
&bin_capacities = {},
const std::array<std::vector<scalar_type>, 3UL> &bin_edges =
std::array<std::vector<scalar_type>, 3UL>(),
const std::array<std::vector<scalar_type>, 3UL> &axis_spans =
std::array<std::vector<scalar_type>, 3UL>()) const {
// Axes boundaries and local indices
using boundary = cuboid3D::boundaries;
using axes_t = axes<cuboid3D>::template type<algebra_t>;
Expand Down Expand Up @@ -202,9 +202,10 @@ class grid_factory {
const std::array<std::size_t, 2UL> n_bins,
const std::vector<std::pair<loc_bin_index<cylinder2D>, dindex>>
&bin_capacities = {},
const std::array<std::vector<scalar_type>, 2UL> &bin_edges = {{}},
const std::array<std::vector<scalar_type>, 2UL> &axis_spans = {
{}}) const {
const std::array<std::vector<scalar_type>, 2UL> &bin_edges =
std::array<std::vector<scalar_type>, 2UL>(),
const std::array<std::vector<scalar_type>, 2UL> &axis_spans =
std::array<std::vector<scalar_type>, 2UL>()) const {

static_assert(
std::is_same_v<rphi_bounds, axis::circular<axis::label::e_rphi>>,
Expand Down Expand Up @@ -244,14 +245,15 @@ class grid_factory {
typename z_binning = axis::regular<host_container_types, scalar_type>,
std::enable_if_t<std::is_enum_v<decltype(rphi_bounds::label)>, bool> =
true>
auto new_grid(
const mask<concentric_cylinder2D> &grid_bounds,
const std::array<std::size_t, 2UL> n_bins,
const std::vector<std::pair<loc_bin_index<concentric_cylinder2D>,
dindex>> &bin_capacities = {},
const std::array<std::vector<scalar_type>, 2UL> &bin_edges = {{}},
const std::array<std::vector<scalar_type>, 2UL> &axis_spans = {
{}}) const {
auto new_grid(const mask<concentric_cylinder2D> &grid_bounds,
const std::array<std::size_t, 2UL> n_bins,
const std::vector<
std::pair<loc_bin_index<concentric_cylinder2D>, dindex>>
&bin_capacities = {},
const std::array<std::vector<scalar_type>, 2UL> &bin_edges =
std::array<std::vector<scalar_type>, 2UL>(),
const std::array<std::vector<scalar_type>, 2UL> &axis_spans =
std::array<std::vector<scalar_type>, 2UL>()) const {

static_assert(
std::is_same_v<rphi_bounds, axis::circular<axis::label::e_rphi>>,
Expand Down Expand Up @@ -298,9 +300,10 @@ class grid_factory {
const std::array<std::size_t, 3UL> n_bins,
const std::vector<std::pair<loc_bin_index<cylinder3D>, dindex>>
&bin_capacities = {},
const std::array<std::vector<scalar_type>, 3UL> &bin_edges = {{}},
const std::array<std::vector<scalar_type>, 3UL> &axis_spans = {
{}}) const {
const std::array<std::vector<scalar_type>, 3UL> &bin_edges =
std::array<std::vector<scalar_type>, 3UL>(),
const std::array<std::vector<scalar_type>, 3UL> &axis_spans =
std::array<std::vector<scalar_type>, 3UL>()) const {

static_assert(
std::is_same_v<phi_bounds, axis::circular<>>,
Expand Down Expand Up @@ -357,14 +360,14 @@ class grid_factory {
typename phi_binning = axis::regular<host_container_types, scalar_type>,
std::enable_if_t<std::is_enum_v<decltype(r_bounds::label)>, bool> =
true>
auto new_grid(
const mask<ring2D> &grid_bounds,
const std::array<std::size_t, 2UL> n_bins,
const std::vector<std::pair<loc_bin_index<ring2D>, dindex>>
&bin_capacities = {},
const std::array<std::vector<scalar_type>, 2UL> &bin_edges = {{}},
const std::array<std::vector<scalar_type>, 2UL> &axis_spans = {
{}}) const {
auto new_grid(const mask<ring2D> &grid_bounds,
const std::array<std::size_t, 2UL> n_bins,
const std::vector<std::pair<loc_bin_index<ring2D>, dindex>>
&bin_capacities = {},
const std::array<std::vector<scalar_type>, 2UL> &bin_edges =
std::array<std::vector<scalar_type>, 2UL>(),
const std::array<std::vector<scalar_type>, 2UL> &axis_spans =
std::array<std::vector<scalar_type>, 2UL>()) const {

static_assert(std::is_same_v<phi_bounds, axis::circular<>>,
"Phi axis bounds need to be circular for ring shape");
Expand Down Expand Up @@ -409,9 +412,10 @@ class grid_factory {
const std::array<std::size_t, 2UL> n_bins,
const std::vector<std::pair<loc_bin_index<rectangle2D>, dindex>>
&bin_capacities = {},
const std::array<std::vector<scalar_type>, 2UL> &bin_edges = {{}},
const std::array<std::vector<scalar_type>, 2UL> &axis_spans = {
{}}) const {
const std::array<std::vector<scalar_type>, 2UL> &bin_edges =
std::array<std::vector<scalar_type>, 2UL>(),
const std::array<std::vector<scalar_type>, 2UL> &axis_spans =
std::array<std::vector<scalar_type>, 2UL>()) const {
// Axes boundaries and local indices
using boundary = rectangle2D::boundaries;
using axes_t = axes<rectangle2D>::template type<algebra_t>;
Expand Down Expand Up @@ -455,9 +459,10 @@ class grid_factory {
const std::array<std::size_t, 2UL> n_bins,
const std::vector<std::pair<loc_bin_index<trapezoid2D>, dindex>>
&bin_capacities = {},
const std::array<std::vector<scalar_type>, 2UL> &bin_edges = {{}},
const std::array<std::vector<scalar_type>, 2UL> &axis_spans = {
{}}) const {
const std::array<std::vector<scalar_type>, 2UL> &bin_edges =
std::array<std::vector<scalar_type>, 2UL>(),
const std::array<std::vector<scalar_type>, 2UL> &axis_spans =
std::array<std::vector<scalar_type>, 2UL>()) const {
// Axes boundaries and local indices
using boundary = trapezoid2D::boundaries;
using axes_t = axes<trapezoid2D>::template type<algebra_t>;
Expand Down
4 changes: 3 additions & 1 deletion core/include/detray/geometry/mask.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,9 @@ class mask {

/// Constructor from single mask boundary values @param args and
/// volume link @param link
template <typename... Args>
template <typename... Args,
std::enable_if_t<(sizeof...(Args) == shape::boundaries::e_size),
bool> = true>
DETRAY_HOST_DEVICE explicit constexpr mask(const links_type& link,
Args&&... args)
: _values({{std::forward<Args>(args)...}}), _volume_link(link) {}
Expand Down
4 changes: 2 additions & 2 deletions core/include/detray/utils/curvilinear_frame.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,8 @@ struct curvilinear_frame {
m_trf, mask<rectangle2D>{}, m_bound_vec);
}

transform3_type m_trf;
bound_vector_type m_bound_vec;
transform3_type m_trf{};
bound_vector_type m_bound_vec{};

}; // curvilinear frame

Expand Down
2 changes: 1 addition & 1 deletion tests/include/detray/test/utils/prefill_detector.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ void prefill_detector(detector_t& d,
point3 t2{2.f, 0.f, 0.f};
trfs.emplace_back(ctx, t2);
masks.template emplace_back<mask_id::e_trapezoid2>(empty_ctx, 0u, 1.f, 2.f,
3.f);
3.f, 1.f / 6.f);
materials.template emplace_back<material_id::e_rod>(
empty_ctx, detray::aluminium<scalar_t>(), 4.f);

Expand Down
2 changes: 1 addition & 1 deletion tests/unit_tests/cpu/core/mask_store.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ GTEST_TEST(detray_core, static_mask_store) {
store.emplace_back<mask_ids::e_cylinder3>(empty_context{}, 0u, 1.f, 1.5f,
2.0f);
store.emplace_back<mask_ids::e_trapezoid2>(empty_context{}, 0u, 0.5f, 1.5f,
4.0f);
4.0f, 1.f / 8.f);
store.emplace_back<mask_ids::e_rectangle2>(empty_context{}, 0u, 1.0f, 2.0f);
store.emplace_back<mask_ids::e_rectangle2>(empty_context{}, 0u, 2.0f, 1.0f);
store.emplace_back<mask_ids::e_rectangle2>(empty_context{}, 0u, 10.0f,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ GTEST_TEST(detray_intersection, intersection_kernel_ray) {
mask_container_t mask_store(host_mr);

const rectangle_t rect{0u, 10.f, 10.f};
const trapezoid_t trap{0u, 10.f, 20.f, 30.f};
const trapezoid_t trap{0u, 10.f, 20.f, 30.f, 1.f / 60.f};
const annulus_t annl{0u, 15.f, 55.f, 0.75f, 1.95f, 0.f, 2.f, -2.f};
const cylinder_t cyl{0u, 5.f, -10.f, 10.f};
const cylinder_portal_t cyl_portal{0u, 1.f, 0.f, 1000.f};
Expand Down Expand Up @@ -244,7 +244,7 @@ GTEST_TEST(detray_intersection, intersection_kernel_helix) {
mask_container_t mask_store(host_mr);

const rectangle_t rect{0u, 10.f, 10.f};
const trapezoid_t trap{0u, 10.f, 20.f, 30.f};
const trapezoid_t trap{0u, 10.f, 20.f, 30.f, 1.f / 60.f};
const annulus_t annl{0u, 15.f, 55.f, 0.75f, 1.95f, 0.f, 2.f, -2.f};
mask_store.template push_back<e_rectangle2>(rect, empty_context{});
mask_store.template push_back<e_trapezoid2>(trap, empty_context{});
Expand Down
2 changes: 1 addition & 1 deletion tests/unit_tests/device/cuda/mask_store_cuda.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ TEST(mask_store_cuda, mask_store) {

store.template emplace_back<e_rectangle2>(empty_context{}, 0u, 1.0f, 2.0f);
store.template emplace_back<e_trapezoid2>(empty_context{}, 0u, 0.5f, 1.5f,
4.0f);
4.0f, 1.f / 8.f);
store.template emplace_back<e_ring2>(empty_context{}, 0u, 1.0f, 10.0f);
store.template emplace_back<e_cylinder2>(empty_context{}, 0u, 1.f, 0.5f,
2.0f);
Expand Down
3 changes: 2 additions & 1 deletion tests/unit_tests/svgtools/masks.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,8 @@ GTEST_TEST(svgtools, masks) {

// Visualize a 2D trapezoid.
// e_half_length_0, e_half_length_1, e_half_length_2, e_divisor
detray::mask<detray::trapezoid2D> tra2D{0u, 100.f, 50.f, 200.f};
detray::mask<detray::trapezoid2D> tra2D{0u, 100.f, 50.f, 200.f,
1.f / 400.f};
const auto tra2D_proto =
detray::svgtools::conversion::surface(transform, tra2D);
const auto tra2D_svg = actsvg::display::surface("", tra2D_proto, view);
Expand Down

0 comments on commit 19887aa

Please sign in to comment.