16 #ifndef LARDATA_UTILITIES_GRIDCONTAINERS_H 17 #define LARDATA_UTILITIES_GRIDCONTAINERS_H 40 template <
typename DATUM,
typename IXMAN>
49 static constexpr
unsigned int dims() {
return IXMAN::dims(); }
97 return indices.offset(origin, cellID);
123 cell(cellID).push_back(std::move(elem));
159 template <
typename DATUM,
typename IXMAN>
162 static_assert(Base_t::dims() >= 1,
"GridContainerBase1D must have dimensions 1 or larger.");
165 using Base_t::GridContainerBase;
188 template <
typename DATUM,
typename IXMAN>
191 static_assert(Base_t::dims() >= 2,
"GridContainerBase2D must have dimensions 2 or larger.");
194 using Base_t::GridContainerBase1D;
217 template <
typename DATUM,
typename IXMAN>
220 static_assert(Base_t::dims() >= 3,
"GridContainerBase3D must have dimensions 3 or larger.");
223 using Base_t::GridContainerBase2D;
247 template <
typename DATUM>
258 template <
typename DATUM>
263 #endif // LARDATA_UTILITIES_GRIDCONTAINERS_H CellIndexOffset_t indexOffset(CellID_t const &origin, CellID_t const &cellID) const
Returns the difference in index from two cells.
static constexpr unsigned int dims()
Namespace for general, non-LArSoft-specific utilities.
Cells_t data
organised collection of points
bool hasX(typename Base_t::CellDimIndex_t index) const
Returns whether the specified x index is valid.
bool hasZ(typename Base_t::CellDimIndex_t index) const
Returns whether the specified x index is valid.
size_t sizeX() const
Returns the size of the container in the first dimension (x)
Cell_t & cell(CellID_t const &cellID)
Returns a reference to the specified cell.
Indexer_t const & indexManager() const
Returns the index manager of the grid.
std::vector< Datum_t > Cell_t
type of a single cell container
typename Cells_t::const_iterator const_iterator
type of iterator to all cells
size_t sizeY() const
Returns the size of the container in the second dimension (y)
size_t sizeZ() const
Returns the size of the container in the third dimension (z)
GridContainerBase(std::array< size_t, dims()> const &dims)
Constructor: specifies the size of the container and allocates it.
void insert(CellID_t const &cellID, Datum_t const &elem)
Copies an element into the specified cell.
std::vector< Cell_t > Cells_t
type of container holding all cells
Cell_t & operator[](CellID_t const &id)
Returns a reference to the specified cell.
typename Indexer_t::CellID_t CellID_t
type of cell coordinate (x, y, z)
auto array(Array const &a)
Returns a manipulator which will print the specified array.
DATUM Datum_t
type of contained datum
Indexer_t indices
manager of the indices of the container
Base class for a container of data arranged on a grid.
typename Indexer_t::CellIndex_t CellIndex_t
type of index for direct access to the cell
Base class for a container of data arranged on a 2D-grid.
constexpr std::array< std::size_t, geo::vect::dimension< Vector >)> indices()
Returns a sequence of indices valid for a vector of the specified type.
typename Indexer_t::CellIndexOffset_t CellIndexOffset_t
type of difference between indices
Cell_t const & cell(CellID_t const &cellID) const
Returns a constant reference to the specified cell.
Cell_t & operator[](CellIndex_t index)
Returns a reference to to the cell with specified index.
typename Indexer_t::CellDimIndex_t CellDimIndex_t
type of difference between indices
void insert(CellID_t const &cellID, Datum_t &&elem)
Moves an element into the specified cell.
bool has(CellIndexOffset_t index) const
Returns whether the specified index is valid.
void insert(CellIndex_t index, Datum_t &&elem)
Moves an element into the cell with the specified index.
Cell_t const & operator[](CellIndex_t index) const
Returns a constant reference to the cell with specified index.
CellIndex_t index(CellID_t const &id) const
Return the index of the element from its cell coordinates (no check!)
void insert(CellIndex_t index, Datum_t const &elem)
Copies an element into the cell with the specified index.
Base class for a container of data arranged on a 1D-grid.
bool hasY(typename Base_t::CellDimIndex_t index) const
Returns whether the specified x index is valid.
Cell_t const & operator[](CellID_t const &id) const
Returns a constant reference to the specified cell.
constexpr Point origin()
Returns a origin position with a point of the specified type.
Base class for a container of data arranged on a 3D-grid.
Classes to manage containers with indices in 1, 2 and 3 dimensions.
size_t size() const
Returns the total size of the container.