Skip to content

Commit

Permalink
rename array type to darray
Browse files Browse the repository at this point in the history
  • Loading branch information
niermann999 committed Dec 19, 2024
1 parent 3e8f068 commit f459c41
Show file tree
Hide file tree
Showing 65 changed files with 197 additions and 237 deletions.
2 changes: 1 addition & 1 deletion core/include/detray/builders/bin_fillers.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ struct bin_associator {
// Fill the surfaces into the grid by matching their contour onto the
// grid bins
bin_association(ctx, surfaces, transforms, masks, grid,
std::array<scalar_t, 2>{0.1f, 0.1f}, false);
darray<scalar_t, 2>{0.1f, 0.1f}, false);
}
};

Expand Down
3 changes: 1 addition & 2 deletions core/include/detray/builders/detail/bin_association.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@
#include "detray/utils/ranges.hpp"

// System include(s)
#include <array>
#include <vector>

namespace detray::detail {
Expand All @@ -44,7 +43,7 @@ static inline void bin_association(const context_t & /*context*/,
const transform_container_t &transforms,
const mask_container_t &surface_masks,
grid_t &grid,
const std::array<scalar_t, 2> &bin_tolerance,
const darray<scalar_t, 2> &bin_tolerance,
bool absolute_tolerance = true) {

using algebra_t = typename grid_t::local_frame_type::algebra_type;
Expand Down
4 changes: 2 additions & 2 deletions core/include/detray/builders/detector_builder.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -126,9 +126,9 @@ class detector_builder {
0u, 0.f, -constant<scalar_type>::pi,
-2000.f, 180.f, constant<scalar_type>::pi,
2000.f};
std::array<std::size_t, 3> n_vgrid_bins{1u, 1u, 1u};
darray<std::size_t, 3> n_vgrid_bins{1u, 1u, 1u};

std::array<std::vector<scalar_type>, 3UL> bin_edges{
darray<std::vector<scalar_type>, 3UL> bin_edges{
std::vector<scalar_type>{0.f, 180.f},
std::vector<scalar_type>{-constant<scalar_type>::pi,
constant<scalar_type>::pi},
Expand Down
7 changes: 3 additions & 4 deletions core/include/detray/builders/grid_builder.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@
#include "detray/utils/grid/detail/concepts.hpp"

// System include(s)
#include <array>
#include <cassert>
#include <memory>
#include <vector>
Expand Down Expand Up @@ -80,11 +79,11 @@ class grid_builder : public volume_decorator<detector_t> {
template <typename grid_shape_t>
DETRAY_HOST void init_grid(
const mask<grid_shape_t, algebra_type> &m,
const std::array<std::size_t, grid_t::dim> &n_bins,
const darray<std::size_t, grid_t::dim> &n_bins,
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>()) {
const darray<std::vector<scalar_type>, grid_t::dim> &ax_bin_edges =
darray<std::vector<scalar_type>, grid_t::dim>()) {

static_assert(
std::is_same_v<typename grid_shape_t::template local_frame_type<
Expand Down
90 changes: 45 additions & 45 deletions core/include/detray/builders/grid_factory.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -79,13 +79,13 @@ class grid_factory {
typename phi_binning = axis::regular<scalar_type, host_container_types>>
requires std::is_enum_v<decltype(r_bounds::label)> auto new_grid(
const mask<annulus2D, algebra_type> &grid_bounds,
const std::array<std::size_t, 2UL> n_bins,
const darray<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 {
const darray<std::vector<scalar_type>, 2UL> &bin_edges =
darray<std::vector<scalar_type>, 2UL>(),
const darray<std::vector<scalar_type>, 2UL> &axis_spans =
darray<std::vector<scalar_type>, 2UL>()) const {

static_assert(
std::is_same_v<phi_bounds, axis::circular<>>,
Expand Down Expand Up @@ -137,13 +137,13 @@ class grid_factory {
typename z_binning = axis::regular<scalar_type, host_container_types>>
requires std::is_enum_v<decltype(x_bounds::label)> auto new_grid(
const mask<cuboid3D, algebra_type> &grid_bounds,
const std::array<std::size_t, 3UL> n_bins,
const darray<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 {
const darray<std::vector<scalar_type>, 3UL> &bin_edges =
darray<std::vector<scalar_type>, 3UL>(),
const darray<std::vector<scalar_type>, 3UL> &axis_spans =
darray<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 @@ -193,13 +193,13 @@ class grid_factory {
typename z_binning = axis::regular<scalar_type, host_container_types>>
requires std::is_enum_v<decltype(rphi_bounds::label)> auto new_grid(
const mask<cylinder2D, algebra_type> &grid_bounds,
const std::array<std::size_t, 2UL> n_bins,
const darray<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 =
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 {
const darray<std::vector<scalar_type>, 2UL> &bin_edges =
darray<std::vector<scalar_type>, 2UL>(),
const darray<std::vector<scalar_type>, 2UL> &axis_spans =
darray<std::vector<scalar_type>, 2UL>()) const {

static_assert(
std::is_same_v<rphi_bounds, axis::circular<axis::label::e_rphi>>,
Expand Down Expand Up @@ -239,13 +239,13 @@ class grid_factory {
typename z_binning = axis::regular<scalar_type, host_container_types>>
requires std::is_enum_v<decltype(rphi_bounds::label)> auto new_grid(
const mask<concentric_cylinder2D, algebra_type> &grid_bounds,
const std::array<std::size_t, 2UL> n_bins,
const darray<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 {
const darray<std::vector<scalar_type>, 2UL> &bin_edges =
darray<std::vector<scalar_type>, 2UL>(),
const darray<std::vector<scalar_type>, 2UL> &axis_spans =
darray<std::vector<scalar_type>, 2UL>()) const {

static_assert(
std::is_same_v<rphi_bounds, axis::circular<axis::label::e_rphi>>,
Expand Down Expand Up @@ -287,13 +287,13 @@ class grid_factory {
typename z_binning = axis::regular<scalar_type, host_container_types>>
requires std::is_enum_v<decltype(r_bounds::label)> auto new_grid(
const mask<cylinder3D, algebra_type> &grid_bounds,
const std::array<std::size_t, 3UL> n_bins,
const darray<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 =
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 {
const darray<std::vector<scalar_type>, 3UL> &bin_edges =
darray<std::vector<scalar_type>, 3UL>(),
const darray<std::vector<scalar_type>, 3UL> &axis_spans =
darray<std::vector<scalar_type>, 3UL>()) const {

static_assert(
std::is_same_v<phi_bounds, axis::circular<>>,
Expand Down Expand Up @@ -350,13 +350,13 @@ class grid_factory {
typename phi_binning = axis::regular<scalar_type, host_container_types>>
requires std::is_enum_v<decltype(r_bounds::label)> auto new_grid(
const mask<ring2D, algebra_type> &grid_bounds,
const std::array<std::size_t, 2UL> n_bins,
const darray<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 {
const darray<std::vector<scalar_type>, 2UL> &bin_edges =
darray<std::vector<scalar_type>, 2UL>(),
const darray<std::vector<scalar_type>, 2UL> &axis_spans =
darray<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 @@ -396,13 +396,13 @@ class grid_factory {
typename y_binning = axis::regular<scalar_type, host_container_types>>
requires std::is_enum_v<decltype(x_bounds::label)> auto new_grid(
const mask<rectangle2D, algebra_type> &grid_bounds,
const std::array<std::size_t, 2UL> n_bins,
const darray<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 =
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 {
const darray<std::vector<scalar_type>, 2UL> &bin_edges =
darray<std::vector<scalar_type>, 2UL>(),
const darray<std::vector<scalar_type>, 2UL> &axis_spans =
darray<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 @@ -441,13 +441,13 @@ class grid_factory {
typename y_binning = axis::regular<scalar_type, host_container_types>>
requires std::is_enum_v<decltype(x_bounds::label)> auto new_grid(
const mask<trapezoid2D, algebra_type> &grid_bounds,
const std::array<std::size_t, 2UL> n_bins,
const darray<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 =
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 {
const darray<std::vector<scalar_type>, 2UL> &bin_edges =
darray<std::vector<scalar_type>, 2UL>(),
const darray<std::vector<scalar_type>, 2UL> &axis_spans =
darray<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 Expand Up @@ -538,11 +538,11 @@ class grid_factory {
template <concepts::grid grid_t, typename grid_shape_t>
auto new_grid(
const mask<grid_shape_t, algebra_type> &m,
const std::array<std::size_t, grid_t::dim> &n_bins,
const darray<std::size_t, grid_t::dim> &n_bins,
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 =
{}) const {
const darray<std::vector<scalar_type>, grid_t::dim> &ax_bin_edges = {})
const {

return new_grid(m, n_bins, bin_capacities, ax_bin_edges,
typename grid_t::axes_type::bounds{},
Expand All @@ -558,11 +558,11 @@ class grid_factory {
std::enable_if_t<std::is_enum_v<typename grid_shape_t::boundaries>,
bool> = true>
auto new_grid(const mask<grid_shape_t, algebra_type> &m,
const std::array<std::size_t, grid_shape_t::dim> &n_bins,
const darray<std::size_t, grid_shape_t::dim> &n_bins,
const std::vector<
std::pair<axis::multi_bin<sizeof...(bound_ts)>, dindex>>
&bin_capacities = {},
const std::array<std::vector<scalar_type>, grid_shape_t::dim>
const darray<std::vector<scalar_type>, grid_shape_t::dim>
&ax_bin_edges = {},
const types::list<bound_ts...> & = {},
const types::list<binning_ts...> & = {}) const {
Expand Down
12 changes: 5 additions & 7 deletions core/include/detray/builders/material_map_builder.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@
#include "detray/materials/material_map.hpp"

// System include(s)
#include <array>
#include <cassert>
#include <map>
#include <memory>
Expand Down Expand Up @@ -118,7 +117,7 @@ class material_map_builder final : public volume_decorator<detector_t> {
}

// Construct and append the material map for a given surface shape
std::array<std::vector<scalar_type>, DIM> axis_spans{};
darray<std::vector<scalar_type>, DIM> axis_spans{};
auto axis_spans_itr = m_axis_spans.find(sf_idx);
if (axis_spans_itr != m_axis_spans.end()) {
axis_spans = axis_spans_itr->second;
Expand Down Expand Up @@ -195,9 +194,9 @@ class material_map_builder final : public volume_decorator<detector_t> {
/// The surface this material map belongs to (index is volume local)
std::map<dindex, std::vector<bin_data_type>> m_bin_data;
/// Number of bins for the material grid axes
std::map<dindex, std::array<std::size_t, DIM>> m_n_bins{};
std::map<dindex, darray<std::size_t, DIM>> m_n_bins{};
/// The Axis spans for the material grid axes
std::map<dindex, std::array<std::vector<scalar_type>, DIM>> m_axis_spans{};
std::map<dindex, darray<std::vector<scalar_type>, DIM>> m_axis_spans{};
/// Helper to generate empty grids
mat_map_factory_t m_factory{};
};
Expand Down Expand Up @@ -227,9 +226,8 @@ struct add_sf_material_map {
[[maybe_unused]] const index_t& index,
[[maybe_unused]] const mat_factory_t& mat_factory,
[[maybe_unused]] std::vector<bin_data_t>& bin_data,
[[maybe_unused]] const std::array<std::size_t, DIM>& n_bins,
[[maybe_unused]] const std::array<std::vector<scalar_t>, DIM>&
axis_spans,
[[maybe_unused]] const darray<std::size_t, DIM>& n_bins,
[[maybe_unused]] const darray<std::vector<scalar_t>, DIM>& axis_spans,
[[maybe_unused]] material_store_t& mat_store) const {

using mask_shape_t = typename coll_t::value_type::shape;
Expand Down
6 changes: 3 additions & 3 deletions core/include/detray/builders/material_map_factory.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -144,8 +144,8 @@ class material_map_factory final : public factory_decorator<detector_t> {
DETRAY_HOST auto operator()(
typename detector_t::surface_lookup_container &surfaces,
std::map<dindex, std::vector<bin_data_t>> &material_map,
std::map<dindex, std::array<std::size_t, N>> &n_bins,
std::map<dindex, std::array<std::vector<scalar_type>, N>> &axis_spans) {
std::map<dindex, darray<std::size_t, N>> &n_bins,
std::map<dindex, darray<std::vector<scalar_type>, N>> &axis_spans) {

using link_t = typename detector_t::surface_type::material_link;

Expand All @@ -168,7 +168,7 @@ class material_map_factory final : public factory_decorator<detector_t> {
n_bins.at(sf_idx).begin());

// Copy the axis spans to the builder (if present)
axis_spans[sf_idx] = std::array<std::vector<scalar_type>, N>{};
axis_spans[sf_idx] = darray<std::vector<scalar_type>, N>{};
for (std::size_t in = 0; in < N; ++in) {
if (m_axis_spans.at(sf_idx).size() > in) {
axis_spans.at(sf_idx).at(in) =
Expand Down
5 changes: 2 additions & 3 deletions core/include/detray/builders/material_map_generator.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@
#include "detray/utils/ranges.hpp"

// System include(s)
#include <array>
#include <functional>
#include <map>
#include <memory>
Expand Down Expand Up @@ -87,7 +86,7 @@ struct material_map_config {
/// Type id value of the material map in a given detector
dindex map_id{dindex_invalid};
/// Number of bins for material maps
std::array<std::size_t, 2> n_bins{20u, 20u};
darray<std::size_t, 2> n_bins{20u, 20u};
/// Along which of the two axes to scale the material
std::size_t axis_index{0u};
/// Material to be filled into the maps
Expand Down Expand Up @@ -198,7 +197,7 @@ class material_map_generator final : public factory_decorator<detector_t> {
typename detector_t::surface_lookup_container &surfaces,
const typename detector_t::mask_container &masks,
std::map<dindex, std::vector<bin_data_t>> &material_map,
std::map<dindex, std::array<std::size_t, N>> &n_bins) {
std::map<dindex, darray<std::size_t, N>> &n_bins) {

static_assert(N == 2u, "This generator only supports 2D material maps");

Expand Down
1 change: 0 additions & 1 deletion core/include/detray/builders/surface_factory.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@
#include <cassert>
#include <exception>
#include <memory>
#include <tuple>
#include <type_traits>
#include <vector>

Expand Down
2 changes: 1 addition & 1 deletion core/include/detray/core/detail/indexing.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ template <typename index_t, std::size_t DIM>
struct multi_index {
using index_type = index_t;

std::array<index_t, DIM> indices{};
darray<index_t, DIM> indices{};

/// @returns the number of conatined indices
DETRAY_HOST_DEVICE
Expand Down
1 change: 0 additions & 1 deletion core/include/detray/definitions/detail/containers.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@
#include <vecmem/containers/vector.hpp>

// System include(s)
#include <array>
#include <map>
#include <type_traits>
#include <vector>
Expand Down
1 change: 0 additions & 1 deletion core/include/detray/geometry/shapes/unbounded.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@
#include "detray/utils/string_view_concat.hpp"

// System include(s)
#include <array>
#include <limits>
#include <ostream>
#include <string>
Expand Down
Loading

0 comments on commit f459c41

Please sign in to comment.