ACTS
Experiment-independent tracking
Loading...
Searching...
No Matches
detray::grid_impl< axes_t, bin_t, serializer_t > Class Template Reference

An N-dimensional grid for object storage. More...

#include <detray/utils/grid/grid.hpp>

Inheritance diagram for detray::grid_impl< axes_t, bin_t, serializer_t >:
[legend]

Public Types

using algebra_type = typename axes_type::algebra_type
 Algebra backend used by the axes.
using axes_type = axes_t
 The type of the multi-axis is tied to the type of the grid: a non- owning grid holds a non-owning multi-axis member.
using bin_container_type = typename bin_storage::bin_container_type
 Container holding the bins.
using bin_storage
 Backend storage type for the grid.
using bin_type = bin_t
 Single value in a bin entry.
using buffer_type
 Vecmem based buffer type.
using const_view_type
 Vecmem based grid view type - const.
using glob_bin_index = dindex
 Index of a bin in the flattened grid storage.
using loc_bin_index = typename axes_type::loc_bin_index
 Per-axis indices identifying one bin.
using local_frame_type = typename axes_type::local_frame_type
 Coordinate frame spanned by the grid axes.
using point_type = typename axes_type::point_type
 Point type used for coordinates in the grid frame.
using scalar_type = dscalar<algebra_type>
 Scalar type used by the grid axes.
template<std::size_t DIM>
using serializer_type = serializer_t<DIM>
 Serializer type used for a grid with DIM axes.
template<bool owning>
using type
 Find the corresponding (non-)owning grid type.
using value_type = typename bin_type::entry_type
 Type stored in each bin.
using view_type
 Vecmem based grid view type.

Public Member Functions

 grid_impl ()=default
 Make grid default constructible: Empty grid with empty axis.
 grid_impl (bin_container_type &&bin_data, axes_type &&axes)
 Create grid with well defined axes and bin_data - move.
 grid_impl (bin_container_type *bin_data_ptr, axes_type &&axes, const dindex offset=0u)
 Create grid from container pointers - non-owning (both grid and axes).
 grid_impl (bin_container_type *bin_data_ptr, axes_type &axes, const dindex offset=0u)
 Create grid from container pointers - non-owning (both grid and axes).
 grid_impl (const bin_container_type *bin_data_ptr, axes_type &&axes, const dindex offset=0)
 Create grid from container pointers - non-owning (both grid and axes).
 grid_impl (const bin_container_type *bin_data_ptr, const axes_type &axes, const dindex offset=0)
 Create grid from container pointers - non-owning (both grid and axes).
template<concepts::device_view grid_view_t>
 grid_impl (grid_view_t &view)
 Device-side construction from a vecmem based view type.
 grid_impl (vecmem::memory_resource &resource)
 Create empty grid with empty axes from specific vecmem memory resource.
auto all ()
auto all () const
auto axes () const -> const axes_type &
auto bins () -> bin_storage &
auto bins () const -> const bin_storage &
constexpr auto deserialize (const glob_bin_index gid) const -> loc_bin_index
 Convert a flattened bin index to per-axis bin indices.
template<typename axis_t>
constexpr axis_t get_axis () const
template<axis::label L>
constexpr auto get_axis () const
template<std::size_t index>
constexpr auto get_axis () const
template<bool owning = is_owning>
requires owning
auto get_data () -> view_type
template<bool owning = is_owning>
requires owning
auto get_data () const -> const_view_type
constexpr auto nbins () const -> dindex
constexpr auto operator== (const grid_impl &rhs) const -> bool
 Equality comparison.
template<concepts::transform3D transform3_t, concepts::point3D point3_t, concepts::vector3D vector3_t>
point_type project (const transform3_t &trf, const point3_t &p, const vector3_t &d) const
 Transform a point in global cartesian coordinates to bound coordinates.
constexpr auto serialize (const loc_bin_index &mbin) const -> glob_bin_index
 Convert per-axis bin indices to a flattened bin index.
constexpr auto size () const -> dindex
decltype(auto) bin (const glob_bin_index gbin) const
decltype(auto) bin (const glob_bin_index gbin)
decltype(auto) bin (const loc_bin_index &mbin) const
decltype(auto) bin (const loc_bin_index &mbin)
decltype(auto) bin (const point_type &p) const
 Find the value of a single bin - const.
decltype(auto) bin (const point_type &p)
 Find the value of a single bin.
template<concepts::index... I>
requires (sizeof...(I) == dim)
decltype(auto) bin (I... indices) const
 Access a bin using one index per axis.
decltype(auto) at (const glob_bin_index gbin, const dindex idx)
 Access a single entry in a bin from the global bin index, as well as the index of the entry in the bin.
decltype(auto) at (const glob_bin_index gbin, const dindex idx) const
decltype(auto) at (const loc_bin_index &mbin, const dindex idx)
decltype(auto) at (const loc_bin_index &mbin, const dindex idx) const
template<typename populator_t, typename V = value_type>
void populate (const loc_bin_index &mbin, V &&v)
 Poupulate a bin with a single one of its corresponding values v.
template<typename populator_t, typename V = value_type>
void populate (const glob_bin_index gbin, V &&v)
template<typename populator_t, typename V = value_type>
void populate (const point_type &p, V &&v)

Static Public Member Functions

static constexpr auto get_local_frame () -> local_frame_type
static constexpr auto serializer () -> serializer_t< dim >

Static Public Attributes

static constexpr unsigned int dim = axes_t::dim
 Grid dimension.
static constexpr bool is_owning {axes_type::is_owning}
 Whether this grid owns its axis and bin storage.

Detailed Description

template<typename axes_t, typename bin_t, template< std::size_t > class serializer_t = simple_serializer>
class detray::grid_impl< axes_t, bin_t, serializer_t >

An N-dimensional grid for object storage.

Template Parameters
axes_tthe types of grid axes
bin_ttype of bin in the (global) bin storage.
serializer_thow to serialize axis-local bin indices into global bin indices in the grid backend storage and vice versa.

Member Typedef Documentation

◆ bin_storage

template<typename axes_t, typename bin_t, template< std::size_t > class serializer_t = simple_serializer>
using detray::grid_impl< axes_t, bin_t, serializer_t >::bin_storage
Initial value:
detray::detail::bin_storage<is_owning, bin_type,
typename axes_type::container_types>
static constexpr bool is_owning
Whether this grid owns its axis and bin storage.
Definition grid.hpp:69
bin_t bin_type
Single value in a bin entry.
Definition grid.hpp:44

Backend storage type for the grid.

◆ buffer_type

template<typename axes_t, typename bin_t, template< std::size_t > class serializer_t = simple_serializer>
using detray::grid_impl< axes_t, bin_t, serializer_t >::buffer_type
Initial value:
dmulti_buffer<typename bin_storage::buffer_type,
typename axes_type::buffer_type>

Vecmem based buffer type.

◆ const_view_type

template<typename axes_t, typename bin_t, template< std::size_t > class serializer_t = simple_serializer>
using detray::grid_impl< axes_t, bin_t, serializer_t >::const_view_type
Initial value:
dmulti_view<typename bin_storage::const_view_type,
typename axes_type::const_view_type>

Vecmem based grid view type - const.

◆ type

template<typename axes_t, typename bin_t, template< std::size_t > class serializer_t = simple_serializer>
template<bool owning>
using detray::grid_impl< axes_t, bin_t, serializer_t >::type
Initial value:
grid_impl()=default
Make grid default constructible: Empty grid with empty axis.

Find the corresponding (non-)owning grid type.

◆ view_type

template<typename axes_t, typename bin_t, template< std::size_t > class serializer_t = simple_serializer>
using detray::grid_impl< axes_t, bin_t, serializer_t >::view_type
Initial value:
dmulti_view<typename bin_storage::view_type,
typename axes_type::view_type>

Vecmem based grid view type.

Constructor & Destructor Documentation

◆ grid_impl() [1/7]

template<typename axes_t, typename bin_t, template< std::size_t > class serializer_t = simple_serializer>
detray::grid_impl< axes_t, bin_t, serializer_t >::grid_impl ( vecmem::memory_resource & resource)
explicit

Create empty grid with empty axes from specific vecmem memory resource.

Parameters
resourceResource used for bin and axis allocations.

◆ grid_impl() [2/7]

template<typename axes_t, typename bin_t, template< std::size_t > class serializer_t = simple_serializer>
detray::grid_impl< axes_t, bin_t, serializer_t >::grid_impl ( bin_container_type && bin_data,
axes_type && axes )

Create grid with well defined axes and bin_data - move.

Parameters
bin_dataBin storage for the grid.
axesAxis definitions for the grid.

◆ grid_impl() [3/7]

template<typename axes_t, typename bin_t, template< std::size_t > class serializer_t = simple_serializer>
detray::grid_impl< axes_t, bin_t, serializer_t >::grid_impl ( const bin_container_type * bin_data_ptr,
const axes_type & axes,
const dindex offset = 0 )

Create grid from container pointers - non-owning (both grid and axes).

Parameters
bin_data_ptrBin storage to view.
axesAxis definitions to view.
offsetOffset of this grid's bins in the container.

◆ grid_impl() [4/7]

template<typename axes_t, typename bin_t, template< std::size_t > class serializer_t = simple_serializer>
detray::grid_impl< axes_t, bin_t, serializer_t >::grid_impl ( bin_container_type * bin_data_ptr,
axes_type & axes,
const dindex offset = 0u )

Create grid from container pointers - non-owning (both grid and axes).

Parameters
bin_data_ptrBin storage to view.
axesAxis definitions to view.
offsetOffset of this grid's bins in the container.

◆ grid_impl() [5/7]

template<typename axes_t, typename bin_t, template< std::size_t > class serializer_t = simple_serializer>
detray::grid_impl< axes_t, bin_t, serializer_t >::grid_impl ( const bin_container_type * bin_data_ptr,
axes_type && axes,
const dindex offset = 0 )

Create grid from container pointers - non-owning (both grid and axes).

Parameters
bin_data_ptrBin storage to view.
axesAxis definitions moved into the grid view.
offsetOffset of this grid's bins in the container.

◆ grid_impl() [6/7]

template<typename axes_t, typename bin_t, template< std::size_t > class serializer_t = simple_serializer>
detray::grid_impl< axes_t, bin_t, serializer_t >::grid_impl ( bin_container_type * bin_data_ptr,
axes_type && axes,
const dindex offset = 0u )

Create grid from container pointers - non-owning (both grid and axes).

Parameters
bin_data_ptrBin storage to view.
axesAxis definitions moved into the grid view.
offsetOffset of this grid's bins in the container.

◆ grid_impl() [7/7]

template<typename axes_t, typename bin_t, template< std::size_t > class serializer_t = simple_serializer>
template<concepts::device_view grid_view_t>
detray::grid_impl< axes_t, bin_t, serializer_t >::grid_impl ( grid_view_t & view)
explicit

Device-side construction from a vecmem based view type.

Parameters
viewView containing the bin and axis data.

Member Function Documentation

◆ all() [1/2]

template<typename axes_t, typename bin_t, template< std::size_t > class serializer_t = simple_serializer>
auto detray::grid_impl< axes_t, bin_t, serializer_t >::all ( )
Returns
a view over the flattened bin content by joining the bin ranges

◆ all() [2/2]

template<typename axes_t, typename bin_t, template< std::size_t > class serializer_t = simple_serializer>
auto detray::grid_impl< axes_t, bin_t, serializer_t >::all ( ) const
Returns
a view over the flattened bin content by joining the bin ranges

◆ at() [1/4]

template<typename axes_t, typename bin_t, template< std::size_t > class serializer_t = simple_serializer>
decltype(auto) detray::grid_impl< axes_t, bin_t, serializer_t >::at ( const glob_bin_index gbin,
const dindex idx )

Access a single entry in a bin from the global bin index, as well as the index of the entry in the bin.

Parameters
gbinFlattened index of the bin.
idxIndex of the entry within that bin.
Returns
The selected entry.

◆ at() [2/4]

template<typename axes_t, typename bin_t, template< std::size_t > class serializer_t = simple_serializer>
decltype(auto) detray::grid_impl< axes_t, bin_t, serializer_t >::at ( const glob_bin_index gbin,
const dindex idx ) const
Parameters
gbinFlattened index of the bin.
idxIndex of the entry within that bin.
Returns
The selected entry.

◆ at() [3/4]

template<typename axes_t, typename bin_t, template< std::size_t > class serializer_t = simple_serializer>
decltype(auto) detray::grid_impl< axes_t, bin_t, serializer_t >::at ( const loc_bin_index & mbin,
const dindex idx )
Parameters
mbinPer-axis indices of the bin.
idxIndex of the entry within that bin.
Returns
The selected entry.

◆ at() [4/4]

template<typename axes_t, typename bin_t, template< std::size_t > class serializer_t = simple_serializer>
decltype(auto) detray::grid_impl< axes_t, bin_t, serializer_t >::at ( const loc_bin_index & mbin,
const dindex idx ) const
Parameters
mbinPer-axis indices of the bin.
idxIndex of the entry within that bin.
Returns
The selected entry.

◆ axes()

template<typename axes_t, typename bin_t, template< std::size_t > class serializer_t = simple_serializer>
auto detray::grid_impl< axes_t, bin_t, serializer_t >::axes ( ) const->constaxes_type &
Returns
the multi-axis used by the grid - const

◆ bin() [1/7]

template<typename axes_t, typename bin_t, template< std::size_t > class serializer_t = simple_serializer>
decltype(auto) detray::grid_impl< axes_t, bin_t, serializer_t >::bin ( const glob_bin_index gbin)
Parameters
gbinthe global bin index
Returns
An iterable view of the bin contents.

◆ bin() [2/7]

template<typename axes_t, typename bin_t, template< std::size_t > class serializer_t = simple_serializer>
decltype(auto) detray::grid_impl< axes_t, bin_t, serializer_t >::bin ( const glob_bin_index gbin) const
Returns
the iterable view of the bin content
Parameters
gbinthe global bin index - const

◆ bin() [3/7]

template<typename axes_t, typename bin_t, template< std::size_t > class serializer_t = simple_serializer>
decltype(auto) detray::grid_impl< axes_t, bin_t, serializer_t >::bin ( const loc_bin_index & mbin)
Parameters
mbinthe multi-index of bins over all axes
Returns
An iterable view of the bin contents.

◆ bin() [4/7]

template<typename axes_t, typename bin_t, template< std::size_t > class serializer_t = simple_serializer>
decltype(auto) detray::grid_impl< axes_t, bin_t, serializer_t >::bin ( const loc_bin_index & mbin) const
Parameters
mbinthe multi-index of bins over all axes - const
Returns
An iterable view of the bin contents.

◆ bin() [5/7]

template<typename axes_t, typename bin_t, template< std::size_t > class serializer_t = simple_serializer>
decltype(auto) detray::grid_impl< axes_t, bin_t, serializer_t >::bin ( const point_type & p)

Find the value of a single bin.

Parameters
pis point in the local (bound) frame
Returns
the iterable view of the bin content

◆ bin() [6/7]

template<typename axes_t, typename bin_t, template< std::size_t > class serializer_t = simple_serializer>
decltype(auto) detray::grid_impl< axes_t, bin_t, serializer_t >::bin ( const point_type & p) const

Find the value of a single bin - const.

Parameters
pis point in the local (bound) frame
Returns
the iterable view of the bin content

◆ bin() [7/7]

template<typename axes_t, typename bin_t, template< std::size_t > class serializer_t = simple_serializer>
template<concepts::index... I>
requires (sizeof...(I) == dim)
decltype(auto) detray::grid_impl< axes_t, bin_t, serializer_t >::bin ( I... indices) const

Access a bin using one index per axis.

Parameters
indicesthe single indices corresponding to a multi_bin
Returns
An iterable view of the bin contents.

◆ bins() [1/2]

template<typename axes_t, typename bin_t, template< std::size_t > class serializer_t = simple_serializer>
auto detray::grid_impl< axes_t, bin_t, serializer_t >::bins ( ) ->bin_storage &
Returns
the full range of bins

◆ bins() [2/2]

template<typename axes_t, typename bin_t, template< std::size_t > class serializer_t = simple_serializer>
auto detray::grid_impl< axes_t, bin_t, serializer_t >::bins ( ) const->constbin_storage &
Returns
the full range of bins - const

◆ deserialize()

template<typename axes_t, typename bin_t, template< std::size_t > class serializer_t = simple_serializer>
auto detray::grid_impl< axes_t, bin_t, serializer_t >::deserialize ( const glob_bin_index gid) const->loc_bin_index
constexpr

Convert a flattened bin index to per-axis bin indices.

Parameters
gidFlattened index of the bin.
Returns
a local multi-bin index from a global bin index gid

◆ get_axis() [1/3]

template<typename axes_t, typename bin_t, template< std::size_t > class serializer_t = simple_serializer>
template<typename axis_t>
axis_t detray::grid_impl< axes_t, bin_t, serializer_t >::get_axis ( ) const
constexpr
Returns
an axis object of the given type.

◆ get_axis() [2/3]

template<typename axes_t, typename bin_t, template< std::size_t > class serializer_t = simple_serializer>
template<axis::label L>
auto detray::grid_impl< axes_t, bin_t, serializer_t >::get_axis ( ) const
constexpr
Returns
an axis object, corresponding to the label.

◆ get_axis() [3/3]

template<typename axes_t, typename bin_t, template< std::size_t > class serializer_t = simple_serializer>
template<std::size_t index>
auto detray::grid_impl< axes_t, bin_t, serializer_t >::get_axis ( ) const
constexpr
Returns
an axis object, corresponding to the index.

◆ get_data() [1/2]

template<typename axes_t, typename bin_t, template< std::size_t > class serializer_t = simple_serializer>
template<bool owning = is_owning>
requires owning
auto detray::grid_impl< axes_t, bin_t, serializer_t >::get_data ( ) ->view_type
Returns
view of a grid, including the grids multi_axis. Also valid if the value type of the grid is cv qualified (then value_t propagates quialifiers) - non-const

◆ get_data() [2/2]

template<typename axes_t, typename bin_t, template< std::size_t > class serializer_t = simple_serializer>
template<bool owning = is_owning>
requires owning
auto detray::grid_impl< axes_t, bin_t, serializer_t >::get_data ( ) const->const_view_type
Returns
view of a grid, including the grids multi_axis. Also valid if the value type of the grid is cv qualified (then value_t propagates quialifiers) - const

◆ get_local_frame()

template<typename axes_t, typename bin_t, template< std::size_t > class serializer_t = simple_serializer>
constexpr auto detray::grid_impl< axes_t, bin_t, serializer_t >::get_local_frame ( ) ->local_frame_type
staticconstexpr
Returns
the grid local coordinate system

◆ nbins()

template<typename axes_t, typename bin_t, template< std::size_t > class serializer_t = simple_serializer>
auto detray::grid_impl< axes_t, bin_t, serializer_t >::nbins ( ) const->dindex
constexpr
Returns
the total number of bins in the grid

◆ operator==()

template<typename axes_t, typename bin_t, template< std::size_t > class serializer_t = simple_serializer>
auto detray::grid_impl< axes_t, bin_t, serializer_t >::operator== ( const grid_impl< axes_t, bin_t, serializer_t > & rhs) const->bool
constexpr

Equality comparison.

Parameters
rhsthe right-hand side of the comparison
Note
grids could have different bin storage ranges, but could still be identical, hence compare the actual grid content
Returns
whether the two grids are equal

◆ populate() [1/3]

template<typename axes_t, typename bin_t, template< std::size_t > class serializer_t = simple_serializer>
template<typename populator_t, typename V = value_type>
void detray::grid_impl< axes_t, bin_t, serializer_t >::populate ( const glob_bin_index gbin,
V && v )
Parameters
gbinthe global bin index to be populated
vValue to insert into the bin.

◆ populate() [2/3]

template<typename axes_t, typename bin_t, template< std::size_t > class serializer_t = simple_serializer>
template<typename populator_t, typename V = value_type>
void detray::grid_impl< axes_t, bin_t, serializer_t >::populate ( const loc_bin_index & mbin,
V && v )

Poupulate a bin with a single one of its corresponding values v.

Parameters
mbinthe multi bin index to be populated
vValue to insert into the bin.

◆ populate() [3/3]

template<typename axes_t, typename bin_t, template< std::size_t > class serializer_t = simple_serializer>
template<typename populator_t, typename V = value_type>
void detray::grid_impl< axes_t, bin_t, serializer_t >::populate ( const point_type & p,
V && v )
Parameters
pthe point in local coordinates that defines the bin to be populated
vValue to insert into the bin.

◆ project()

template<typename axes_t, typename bin_t, template< std::size_t > class serializer_t = simple_serializer>
template<concepts::transform3D transform3_t, concepts::point3D point3_t, concepts::vector3D vector3_t>
point_type detray::grid_impl< axes_t, bin_t, serializer_t >::project ( const transform3_t & trf,
const point3_t & p,
const vector3_t & d ) const

Transform a point in global cartesian coordinates to bound coordinates.

Parameters
trfthe placement transform of the grid (e.g. from a volume or a surface).
pthe point in global coordinates
ddirection of a track at position p
Returns
a point in the coordinate system that is spanned by the grid's axes.

◆ serialize()

template<typename axes_t, typename bin_t, template< std::size_t > class serializer_t = simple_serializer>
auto detray::grid_impl< axes_t, bin_t, serializer_t >::serialize ( const loc_bin_index & mbin) const->glob_bin_index
constexpr

Convert per-axis bin indices to a flattened bin index.

Parameters
mbinPer-axis indices of the bin.
Returns
a global bin index from a local bin index mbin

◆ serializer()

template<typename axes_t, typename bin_t, template< std::size_t > class serializer_t = simple_serializer>
constexpr auto detray::grid_impl< axes_t, bin_t, serializer_t >::serializer ( ) ->serializer_t< dim >
staticconstexpr
Returns
an instance of the grid serializer

◆ size()

template<typename axes_t, typename bin_t, template< std::size_t > class serializer_t = simple_serializer>
auto detray::grid_impl< axes_t, bin_t, serializer_t >::size ( ) const->dindex
constexpr
Returns
the total number of values in the grid
Note
this has to query every bin for the number of elements