12#include "detray/definitions/algebra.hpp"
13#include "detray/definitions/containers.hpp"
14#include "detray/definitions/units.hpp"
15#include "detray/geometry/concepts.hpp"
16#include "detray/geometry/mask.hpp"
17#include "detray/geometry/shapes.hpp"
18#include "detray/utils/grid/axis.hpp"
19#include "detray/utils/grid/concepts.hpp"
20#include "detray/utils/grid/detail/axis_helpers.hpp"
21#include "detray/utils/grid/grid.hpp"
22#include "detray/utils/grid/grid_collection.hpp"
23#include "detray/utils/grid/populators.hpp"
24#include "detray/utils/grid/serializers.hpp"
27#include <vecmem/memory/memory_resource.hpp>
48template <
typename bin_t,
template <std::
size_t>
class serializer_t,
59 template <
typename gr
id_shape_t>
62 template <
typename gr
id_shape_t>
73 grid_factory() =
default;
78 : m_resource(&resource) {}
91 typename r_bounds = axis::closed<axis::label::e_r>,
92 typename phi_bounds = axis::circular<>,
93 typename r_binning = axis::regular<scalar_type, host_container_types>,
94 typename phi_binning = axis::regular<scalar_type, host_container_types>>
95 requires std::is_enum_v<
decltype(r_bounds::label)>
105 std::is_same_v<phi_bounds, axis::circular<>>,
106 "Phi axis bounds need to be circular for stereo annulus shape");
110 using axes_t = axes<annulus2D>::template type<algebra_t>;
111 using local_frame =
typename axes_t::template frame<algebra_t>;
113 constexpr auto e_r_axis =
static_cast<dindex>(axes_t::label0);
114 constexpr auto e_phi_axis =
static_cast<dindex>(axes_t::label1);
116 auto b_values = grid_bounds.
values();
118 if (!axis_spans[0UL].empty()) {
119 assert(axis_spans[0UL].size() == 2UL);
120 b_values[boundary::e_min_r] = axis_spans[0UL].at(0UL);
121 b_values[boundary::e_max_r] = axis_spans[0UL].at(1UL);
124 b_values[boundary::e_average_phi] - b_values[boundary::e_min_phi_rel];
126 b_values[boundary::e_average_phi] + b_values[boundary::e_max_phi_rel];
127 if (!axis_spans[1UL].empty()) {
128 assert(axis_spans[1UL].size() == 2UL);
129 min_phi = axis_spans[1UL].at(0UL);
130 max_phi = axis_spans[1UL].at(1UL);
134 {b_values[boundary::e_min_r], b_values[boundary::e_max_r], min_phi,
136 {n_bins[e_r_axis], n_bins[e_phi_axis]}, bin_capacities,
137 {bin_edges[e_r_axis], bin_edges[e_phi_axis]},
138 types::list<r_bounds, phi_bounds>{},
139 types::list<r_binning, phi_binning>{});
153 typename x_bounds = axis::closed<axis::label::e_x>,
154 typename y_bounds = axis::closed<axis::label::e_y>,
155 typename z_bounds = axis::closed<axis::label::e_z>,
156 typename x_binning = axis::regular<scalar_type, host_container_types>,
157 typename y_binning = axis::regular<scalar_type, host_container_types>,
158 typename z_binning = axis::regular<scalar_type, host_container_types>>
159 requires std::is_enum_v<
decltype(x_bounds::label)>
163 &bin_capacities = {},
170 using axes_t = axes<cuboid3D>::template type<algebra_t>;
171 using local_frame =
typename axes_t::template frame<algebra_t>;
173 constexpr auto e_x_axis =
static_cast<dindex>(axes_t::label0);
174 constexpr auto e_y_axis =
static_cast<dindex>(axes_t::label1);
175 constexpr auto e_z_axis =
static_cast<dindex>(axes_t::label2);
178 auto b_values = grid_bounds.
values();
179 if (!axis_spans[0UL].empty()) {
180 assert(axis_spans[0UL].size() == 2UL);
181 b_values[boundary::e_min_x] = axis_spans[0UL].at(0UL);
182 b_values[boundary::e_max_x] = axis_spans[0UL].at(1UL);
184 if (!axis_spans[1UL].empty()) {
185 assert(axis_spans[1UL].size() == 2UL);
186 b_values[boundary::e_min_y] = axis_spans[1UL].at(0UL);
187 b_values[boundary::e_max_y] = axis_spans[1UL].at(1UL);
189 if (!axis_spans[2UL].empty()) {
190 assert(axis_spans[2UL].size() == 2UL);
191 b_values[boundary::e_min_z] = axis_spans[2UL].at(0UL);
192 b_values[boundary::e_max_z] = axis_spans[2UL].at(1UL);
196 {b_values[boundary::e_min_x], b_values[boundary::e_max_x],
197 b_values[boundary::e_min_y], b_values[boundary::e_max_y],
198 b_values[boundary::e_min_z], b_values[boundary::e_max_z]},
199 {n_bins[e_x_axis], n_bins[e_y_axis], n_bins[e_z_axis]}, bin_capacities,
200 {bin_edges[e_x_axis], bin_edges[e_y_axis], bin_edges[e_z_axis]},
201 types::list<x_bounds, y_bounds, z_bounds>{},
202 types::list<x_binning, y_binning, z_binning>{});
216 typename rphi_bounds = axis::circular<axis::label::e_rphi>,
217 typename z_bounds = axis::closed<axis::label::e_cyl_z>,
218 typename rphi_binning = axis::regular<scalar_type, host_container_types>,
219 typename z_binning = axis::regular<scalar_type, host_container_types>>
220 requires std::is_enum_v<
decltype(rphi_bounds::label)>
224 &bin_capacities = {},
230 std::is_same_v<rphi_bounds, axis::circular<axis::label::e_rphi>>,
231 "Phi axis bounds need to be circular for cylinder2D shape");
235 using axes_t = axes<cylinder2D>::template type<algebra_t>;
236 using local_frame =
typename axes_t::template frame<algebra_t>;
238 constexpr auto e_rphi_axis =
static_cast<dindex>(axes_t::label0);
239 constexpr auto e_z_axis =
static_cast<dindex>(axes_t::label1);
241 auto b_values = grid_bounds.
values();
242 if (!axis_spans[1UL].empty()) {
243 assert(axis_spans[1UL].size() == 2UL);
244 b_values[boundary::e_lower_z] = axis_spans[1UL].at(0UL);
245 b_values[boundary::e_upper_z] = axis_spans[1UL].at(1UL);
249 b_values[boundary::e_lower_z], b_values[boundary::e_upper_z]},
250 {n_bins[e_rphi_axis], n_bins[e_z_axis]}, bin_capacities,
251 {bin_edges[e_rphi_axis], bin_edges[e_z_axis]},
252 types::list<rphi_bounds, z_bounds>{},
253 types::list<rphi_binning, z_binning>{});
267 typename rphi_bounds = axis::circular<axis::label::e_rphi>,
268 typename z_bounds = axis::closed<axis::label::e_cyl_z>,
269 typename rphi_binning = axis::regular<scalar_type, host_container_types>,
270 typename z_binning = axis::regular<scalar_type, host_container_types>>
271 requires std::is_enum_v<
decltype(rphi_bounds::label)>
276 &bin_capacities = {},
282 std::is_same_v<rphi_bounds, axis::circular<axis::label::e_rphi>>,
283 "Phi axis bounds need to be circular for cylinder2D portal shape");
287 using axes_t = axes<concentric_cylinder2D>::template type<algebra_t>;
288 using local_frame =
typename axes_t::template frame<algebra_t>;
290 constexpr auto e_rphi_axis =
static_cast<dindex>(axes_t::label0);
291 constexpr auto e_z_axis =
static_cast<dindex>(axes_t::label1);
293 auto b_values = grid_bounds.
values();
294 if (!axis_spans[1UL].empty()) {
295 assert(axis_spans[1UL].size() == 2UL);
296 b_values[boundary::e_lower_z] = axis_spans[1UL].at(0UL);
297 b_values[boundary::e_upper_z] = axis_spans[1UL].at(1UL);
302 b_values[boundary::e_lower_z], b_values[boundary::e_upper_z]},
303 {n_bins[e_rphi_axis], n_bins[e_z_axis]}, bin_capacities,
304 {bin_edges[e_rphi_axis], bin_edges[e_z_axis]},
305 types::list<rphi_bounds, z_bounds>{},
306 types::list<rphi_binning, z_binning>{});
320 typename r_bounds = axis::closed<axis::label::e_r>,
321 typename phi_bounds = axis::circular<>,
322 typename z_bounds = axis::closed<axis::label::e_z>,
323 typename r_binning = axis::regular<scalar_type, host_container_types>,
324 typename phi_binning = axis::regular<scalar_type, host_container_types>,
325 typename z_binning = axis::regular<scalar_type, host_container_types>>
326 requires std::is_enum_v<
decltype(r_bounds::label)>
330 &bin_capacities = {},
335 static_assert(std::is_same_v<phi_bounds, axis::circular<>>,
336 "Phi axis bounds need to be circular for cylinder3D shape");
340 using axes_t = axes<cylinder3D>::template type<algebra_t>;
341 using local_frame =
typename axes_t::template frame<algebra_t>;
343 constexpr auto e_r_axis =
static_cast<dindex>(axes_t::label0);
344 constexpr auto e_phi_axis =
static_cast<dindex>(axes_t::label1);
345 constexpr auto e_z_axis =
static_cast<dindex>(axes_t::label2);
347 auto b_values = grid_bounds.
values();
350 if (!axis_spans[0UL].empty()) {
351 assert(axis_spans[0UL].size() == 2UL);
352 b_values[boundary::e_min_r] = axis_spans[0UL].at(0UL);
353 b_values[boundary::e_max_r] = axis_spans[0UL].at(1UL);
357 if (!axis_spans[1UL].empty()) {
358 assert(axis_spans[1UL].size() == 2UL);
359 min_phi = axis_spans[1UL].at(0UL);
360 max_phi = axis_spans[1UL].at(1UL);
362 if (!axis_spans[2UL].empty()) {
363 assert(axis_spans[2UL].size() == 2UL);
364 b_values[boundary::e_min_z] = axis_spans[2UL].at(0UL);
365 b_values[boundary::e_max_z] = axis_spans[2UL].at(1UL);
369 {b_values[boundary::e_min_r], b_values[boundary::e_max_r], min_phi,
370 max_phi, -b_values[boundary::e_min_z], b_values[boundary::e_max_z]},
371 {n_bins[e_r_axis], n_bins[e_phi_axis], n_bins[e_z_axis]},
373 {bin_edges[e_r_axis], bin_edges[e_phi_axis], bin_edges[e_z_axis]},
374 types::list<r_bounds, phi_bounds, z_bounds>{},
375 types::list<r_binning, phi_binning, z_binning>{});
389 typename r_bounds = axis::closed<axis::label::e_r>,
390 typename phi_bounds = axis::circular<>,
391 typename r_binning = axis::regular<scalar_type, host_container_types>,
392 typename phi_binning = axis::regular<scalar_type, host_container_types>>
393 requires std::is_enum_v<
decltype(r_bounds::label)>
397 &bin_capacities = {},
402 static_assert(std::is_same_v<phi_bounds, axis::circular<>>,
403 "Phi axis bounds need to be circular for ring shape");
407 using axes_t = axes<ring2D>::template type<algebra_t>;
408 using local_frame =
typename axes_t::template frame<algebra_t>;
410 constexpr auto e_r_axis =
static_cast<dindex>(axes_t::label0);
411 constexpr auto e_phi_axis =
static_cast<dindex>(axes_t::label1);
413 auto b_values = grid_bounds.
values();
415 if (!axis_spans[0UL].empty()) {
416 assert(axis_spans[0UL].size() == 2UL);
417 b_values[boundary::e_inner_r] = axis_spans[0UL].at(0UL);
418 b_values[boundary::e_outer_r] = axis_spans[0UL].at(1UL);
422 {b_values[boundary::e_inner_r], b_values[boundary::e_outer_r],
424 {n_bins[e_r_axis], n_bins[e_phi_axis]}, bin_capacities,
425 {bin_edges[e_r_axis], bin_edges[e_phi_axis]},
426 types::list<r_bounds, phi_bounds>{},
427 types::list<r_binning, phi_binning>{});
441 typename x_bounds = axis::closed<axis::label::e_x>,
442 typename y_bounds = axis::closed<axis::label::e_y>,
443 typename x_binning = axis::regular<scalar_type, host_container_types>,
444 typename y_binning = axis::regular<scalar_type, host_container_types>>
445 requires std::is_enum_v<
decltype(x_bounds::label)>
449 &bin_capacities = {},
456 using axes_t = axes<rectangle2D>::template type<algebra_t>;
457 using local_frame =
typename axes_t::template frame<algebra_t>;
459 constexpr auto e_x_axis =
static_cast<dindex>(axes_t::label0);
460 constexpr auto e_y_axis =
static_cast<dindex>(axes_t::label1);
462 auto b_values = grid_bounds.
values();
464 if (!axis_spans[0UL].empty()) {
465 assert(axis_spans[0UL].size() == 2UL);
466 b_values[boundary::e_half_x] = axis_spans[0UL].at(1UL);
468 if (!axis_spans[1UL].empty()) {
469 assert(axis_spans[1UL].size() == 2UL);
470 b_values[boundary::e_half_y] = axis_spans[1UL].at(1UL);
474 {-b_values[boundary::e_half_x], b_values[boundary::e_half_x],
475 -b_values[boundary::e_half_y], b_values[boundary::e_half_y]},
476 {n_bins[e_x_axis], n_bins[e_y_axis]}, bin_capacities,
477 {bin_edges[e_x_axis], bin_edges[e_y_axis]},
478 types::list<x_bounds, y_bounds>{}, types::list<x_binning, y_binning>{});
492 typename x_bounds = axis::closed<axis::label::e_x>,
493 typename y_bounds = axis::closed<axis::label::e_y>,
494 typename x_binning = axis::regular<scalar_type, host_container_types>,
495 typename y_binning = axis::regular<scalar_type, host_container_types>>
496 requires std::is_enum_v<
decltype(x_bounds::label)>
500 &bin_capacities = {},
507 using axes_t = axes<trapezoid2D>::template type<algebra_t>;
508 using local_frame =
typename axes_t::template frame<algebra_t>;
510 constexpr auto e_x_axis =
static_cast<dindex>(axes_t::label0);
511 constexpr auto e_y_axis =
static_cast<dindex>(axes_t::label1);
513 auto b_values = grid_bounds.
values();
515 if (!axis_spans[0UL].empty()) {
516 assert(axis_spans[0UL].size() == 2UL);
517 b_values[boundary::e_half_length_1] = axis_spans[0UL].at(1UL);
519 if (!axis_spans[1UL].empty()) {
520 assert(axis_spans[1UL].size() == 2UL);
521 b_values[boundary::e_half_length_2] = axis_spans[1UL].at(1UL);
525 {-b_values[boundary::e_half_length_1],
526 b_values[boundary::e_half_length_1],
527 -b_values[boundary::e_half_length_2],
528 b_values[boundary::e_half_length_2]},
529 {n_bins[e_x_axis], n_bins[e_y_axis]}, bin_capacities,
530 {bin_edges[e_x_axis], bin_edges[e_y_axis]},
531 types::list<x_bounds, y_bounds>{}, types::list<x_binning, y_binning>{});
551 template <concepts::coordinate_frame grid_frame_t,
typename... bound_ts,
552 typename... binning_ts>
554 const std::vector<scalar_type> &spans,
555 const std::vector<std::size_t> &n_bins,
557 &bin_capacities = {},
558 const std::vector<std::vector<scalar_type>> &ax_bin_edges = {},
559 const types::list<bound_ts...> & = {},
560 const types::list<binning_ts...> & = {})
const {
561 static_assert(
sizeof...(bound_ts) ==
sizeof...(binning_ts),
562 "number of axis bounds and binning types has to match");
565 using axes_t = axis::multi_axis<
is_owning, grid_frame_t,
566 axis::single_axis<bound_ts, binning_ts>...>;
580 template <
typename grid_shape_t,
typename... bound_ts,
typename... binning_ts>
581 requires concepts::shape<grid_shape_t, algebra_t>
583 const std::vector<scalar_type> &spans,
584 const std::vector<std::size_t> &n_bins,
586 &bin_capacities = {},
587 const std::vector<std::vector<scalar_type>> &ax_bin_edges = {},
588 const types::list<bound_ts...> &bounds = {},
589 const types::list<binning_ts...> &binnings = {})
const {
591 typename grid_shape_t::template local_frame_type<algebra_t>>(
592 spans, n_bins, bin_capacities, ax_bin_edges, bounds, binnings);
602 template <concepts::gr
id gr
id_t,
typename gr
id_shape_t>
603 requires concepts::shape<grid_shape_t, algebra_t>
607 const std::vector<std::pair<typename grid_t::loc_bin_index, dindex>>
608 &bin_capacities = {},
611 return new_grid(m, n_bins, bin_capacities, ax_bin_edges,
612 typename grid_t::axes_type::bounds{},
613 typename grid_t::axes_type::binnings{});
623 template <
typename grid_shape_t,
typename... bound_ts,
typename... binning_ts>
624 requires concepts::shape<grid_shape_t, algebra_t>
629 &bin_capacities = {},
632 const types::list<bound_ts...> & = {},
633 const types::list<binning_ts...> & = {})
const {
634 return new_grid<bound_ts..., binning_ts...>(
m, n_bins, bin_capacities,
650 template <concepts::gr
id gr
id_t>
652 const std::vector<scalar_type> &spans,
653 const std::vector<std::size_t> &n_bins,
654 [[maybe_unused]]
const std::vector<
655 std::pair<typename grid_t::loc_bin_index, dindex>> &bin_capacities =
657 const std::vector<std::vector<scalar_type>> &ax_bin_edges = {})
const {
658 using owning_grid_t =
typename grid_t::template type<true>;
659 using axes_t =
typename owning_grid_t::axes_type;
666 unroll_axis_init<typename axes_t::binnings>(
667 spans, n_bins, ax_bin_edges, axes_data, bin_edges,
668 std::make_index_sequence<axes_t::dim>{});
671 axes_t axes(std::move(axes_data), std::move(bin_edges));
673 typename owning_grid_t::bin_container_type bin_data{};
676 if constexpr (std::is_same_v<bin_t, bins::dynamic_array<
677 typename grid_t::value_type>>) {
679 bin_data.bins.resize(axes.nbins());
681 if (!bin_capacities.empty()) {
683 typename grid_t::template serializer_type<grid_t::dim> serializer{};
685 for (
const auto &capacity : bin_capacities) {
687 auto &data = bin_data.bins[serializer(axes, capacity.first)];
689 data.offset = total_cap;
690 data.capacity = capacity.second;
693 total_cap += data.capacity;
695 assert(total_cap > 0);
696 bin_data.entries.resize(
697 total_cap, detail::invalid_value<typename grid_t::value_type>());
701 bin_data.resize(axes.nbins(),
bin_type{});
704 return owning_grid_t(std::move(bin_data), std::move(axes));
710 template <std::
size_t I,
typename binnings>
711 auto axis_init([[maybe_unused]]
const std::vector<scalar_type> &spans,
712 [[maybe_unused]]
const std::vector<std::size_t> &n_bins,
713 [[maybe_unused]]
const std::vector<std::vector<scalar_type>>
717 if constexpr (std::is_same_v<
718 types::at<binnings, I>,
719 axis::regular<scalar_type, host_container_types>>) {
720 axes_data.push_back({
static_cast<dindex>(bin_edges.size()),
721 static_cast<dindex>(n_bins.at(I))});
722 bin_edges.push_back(spans.at(I * 2u));
723 bin_edges.push_back(spans.at(I * 2u + 1u));
725 const auto &bin_edges_loc = ax_bin_edges.at(I);
726 axes_data.push_back({
static_cast<dindex>(bin_edges.size()),
727 static_cast<dindex>(bin_edges_loc.size() - 1u)});
728 bin_edges.insert(bin_edges.end(), bin_edges_loc.begin(),
729 bin_edges_loc.end());
734 template <
typename binnings, std::size_t... I>
735 auto unroll_axis_init(
736 const std::vector<scalar_type> &spans,
737 const std::vector<std::size_t> &n_bins,
738 const std::vector<std::vector<scalar_type>> &ax_bin_edges,
741 std::index_sequence<I...> )
const {
742 (axis_init<I, binnings>(spans, n_bins, ax_bin_edges, axes_data, bin_edges),
746 vecmem::memory_resource *m_resource{};
750template <concepts::gr
id gr
id_t>
754 typename grid_t::algebra_type>;
boundaries
Names for the mask boundary values.
Definition annulus2D.hpp:54
boundaries
Indices describing the entries in the shape boundary array.
Definition concentric_cylinder2D.hpp:38
boundaries
Indices describing the entries in the shape boundary array.
Definition cuboid3D.hpp:38
boundaries
Indices describing the entries in the shape boundary array.
Definition cylinder2D.hpp:39
boundaries
Indices describing the entries in the shape boundary array.
Definition cylinder3D.hpp:38
Provides functionality to instantiate grids and grid collections.
Definition grid_factory.hpp:50
auto new_grid(const mask< grid_shape_t, algebra_type > &m, 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 darray< std::vector< scalar_type >, grid_t::dim > &ax_bin_edges={}) const
Helper overload for grid builder: Build from mask and resolve bounds and binnings from concrete grid ...
Definition grid_factory.hpp:604
host_container_types::template vector_type< T > vector_type
Host vector container type used by grid storage.
Definition grid_factory.hpp:69
auto new_grid(const std::vector< scalar_type > &spans, const std::vector< std::size_t > &n_bins, const std::vector< std::pair< axis::multi_bin< sizeof...(bound_ts)>, dindex > > &bin_capacities={}, const std::vector< std::vector< scalar_type > > &ax_bin_edges={}, const types::list< bound_ts... > &bounds={}, const types::list< binning_ts... > &binnings={}) const
Helper to build grid from shape plus binning and bounds types.
Definition grid_factory.hpp:582
auto new_grid(const mask< cylinder2D, algebra_type > &grid_bounds, const darray< std::size_t, 2UL > n_bins, const std::vector< std::pair< loc_bin_index< cylinder2D >, dindex > > &bin_capacities={}, 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
Build a cylindrical 2D grid from its mask and axis binning.
Definition grid_factory.hpp:221
auto new_grid(const mask< cylinder3D, algebra_type > &grid_bounds, const darray< std::size_t, 3UL > n_bins, const std::vector< std::pair< loc_bin_index< cylinder3D >, dindex > > &bin_capacities={}, 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
Build a cylindrical 3D grid from its mask and axis binning.
Definition grid_factory.hpp:327
auto new_grid(const std::vector< scalar_type > &spans, const std::vector< std::size_t > &n_bins, const std::vector< std::pair< axis::multi_bin< sizeof...(bound_ts)>, dindex > > &bin_capacities={}, const std::vector< std::vector< scalar_type > > &ax_bin_edges={}, const types::list< bound_ts... > &={}, const types::list< binning_ts... > &={}) const
Create and empty grid with fully initialized axes.
Definition grid_factory.hpp:553
auto new_grid(const mask< concentric_cylinder2D, algebra_type > &grid_bounds, const darray< std::size_t, 2UL > n_bins, const std::vector< std::pair< loc_bin_index< concentric_cylinder2D >, dindex > > &bin_capacities={}, 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
Build a concentric cylindrical grid from its mask and axis binning.
Definition grid_factory.hpp:272
typename grid_type< grid_shape_t >::loc_bin_index loc_bin_index
Local index type for bins in a grid of the selected shape.
Definition grid_factory.hpp:63
static constexpr bool is_owning
Definition grid_factory.hpp:54
grid_factory(vecmem::memory_resource &resource)
Takes the resource of the detector to allocate memory correctly.
Definition grid_factory.hpp:77
auto new_grid(const std::vector< scalar_type > &spans, 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
Create and empty grid with fully initialized axes.
Definition grid_factory.hpp:651
bin_t bin_type
Bin container type used for grid values.
Definition grid_factory.hpp:57
auto new_grid(const mask< ring2D, algebra_type > &grid_bounds, const darray< std::size_t, 2UL > n_bins, const std::vector< std::pair< loc_bin_index< ring2D >, dindex > > &bin_capacities={}, 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
Build a ring grid from its mask and axis binning.
Definition grid_factory.hpp:394
algebra_t algebra_type
Linear algebra backend used by the grid.
Definition grid_factory.hpp:71
auto new_grid(const mask< annulus2D, algebra_type > &grid_bounds, const darray< std::size_t, 2UL > n_bins, const std::vector< std::pair< loc_bin_index< annulus2D >, dindex > > &bin_capacities={}, 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
Build an annular grid from its mask and axis binning.
Definition grid_factory.hpp:96
dscalar< algebra_t > scalar_type
Scalar type used by axes and geometry coordinates.
Definition grid_factory.hpp:66
auto new_grid(const mask< grid_shape_t, algebra_type > &m, 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 darray< std::vector< scalar_type >, grid_shape_t::dim > &ax_bin_edges={}, const types::list< bound_ts... > &={}, const types::list< binning_ts... > &={}) const
Helper overload for grid builder: Build from mask and resolve bounds and binnings.
Definition grid_factory.hpp:625
auto new_grid(const mask< rectangle2D, algebra_type > &grid_bounds, const darray< std::size_t, 2UL > n_bins, const std::vector< std::pair< loc_bin_index< rectangle2D >, dindex > > &bin_capacities={}, 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
Build a rectangular grid from its mask and axis binning.
Definition grid_factory.hpp:446
auto new_grid(const mask< cuboid3D, algebra_type > &grid_bounds, const darray< std::size_t, 3UL > n_bins, const std::vector< std::pair< loc_bin_index< cuboid3D >, dindex > > &bin_capacities={}, 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
Build a cuboid grid from its mask and axis binning.
Definition grid_factory.hpp:160
auto new_grid(const mask< trapezoid2D, algebra_type > &grid_bounds, const darray< std::size_t, 2UL > n_bins, const std::vector< std::pair< loc_bin_index< trapezoid2D >, dindex > > &bin_capacities={}, 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
Build a trapezoidal grid from its mask and axis binning.
Definition grid_factory.hpp:497
grid< algebra_t, axes< grid_shape_t >, bin_type, serializer_t > grid_type
Grid type parameterized by a geometric shape.
Definition grid_factory.hpp:60
typename axes_type::loc_bin_index loc_bin_index
Definition grid.hpp:58
Mask a region on a surface and link it to a volume.
Definition mask.hpp:46
auto values() const -> const mask_values &
Definition mask.hpp:251
boundaries
Indices describing the entries in the shape boundary array.
Definition rectangle2D.hpp:36
boundaries
Indices describing the entries in the shape boundary array.
Definition ring2D.hpp:40
boundaries
Indices describing the entries in the shape boundary array.
Definition trapezoid2D.hpp:40
Algebra plugin concept.
Definition concepts.hpp:147
constexpr double m
Meter.
Definition Units.hpp:97
constexpr double u
atomic mass unit u
Definition Units.hpp:155
Detray include(s).
Definition array_operators.hpp:18
get_scalar_t< A, T > dscalar
Scalar type for algebra A and value type T.
Definition algebra.hpp:64
unsigned int dindex
Default index type.
Definition indexing.hpp:18
std::array< value_t, kDIM > darray
Fixed-size array container.
Definition containers.hpp:30
grid_impl< coordinate_axes< axes_t, algebra_t, ownership, containers >, bin_t, simple_serializer > grid
Type alias for easier construction.
Definition grid.hpp:422
grid_factory< typename grid_t::bin_type, simple_serializer, typename grid_t::algebra_type > grid_factory_type
Infer a grid factory type from an already completely assembled grid type.
Definition grid_factory.hpp:751
Multi-bin: contains bin indices from multiple axes.
Definition axis.hpp:36
static constexpr scalar_t pi
π
Definition units.hpp:136