LArSoft
v09_90_00
Liquid Argon Software toolkit - https://larsoft.org/
|
Class managing the mapping between geometry/readout ID and flat index. More...
#include "GeometryIDmapper.h"
Public Types | |
using | ID_t = IDType |
Type used as ID for this mapping. More... | |
using | index_type = Index |
Type of flat index. More... | |
Public Member Functions | |
GeoIDmapper () | |
Default constructor: all dimensions empty. More... | |
GeoIDmapper (std::initializer_list< unsigned int > dims) | |
Prepares the indexer. More... | |
template<std::size_t Level, typename GeoID > | |
auto | indexLevel (GeoID const &id) const -> index_type |
template<std::size_t Level, typename Dims > | |
auto | sizeLevel (Dims const &dimSizes) -> index_type |
Mapping transformations | |
index_type | index (ID_t const &id) const |
Returns the linear index corresponding to the specified ID. More... | |
ID_t | ID (index_type const index) const |
Returns the ID corresponding to the specified linear index . More... | |
index_type | operator() (ID_t const &id) const |
Returns the linear index corresponding to the specified ID. More... | |
ID_t | operator() (index_type const index) const |
Returns the ID corresponding to the specified linear index . More... | |
Mapping modification | |
void | resize (std::initializer_list< unsigned int > dims) |
Resizes the mapping to accommodate the specified dimension sizes. More... | |
template<typename OIDType , typename OIndex > | |
void | resizeAs (geo::GeoIDmapper< OIDType, OIndex > const &other) |
Resizes the mapping to reflect the one from another mapping. More... | |
void | clear () |
Sets all dimension sizes to 0 . More... | |
Private Types | |
using | Dimensions_t = std::array< unsigned int, dimensions()> |
< Type of dimension sizes. More... | |
Private Member Functions | |
template<std::size_t Level, typename GeoID > | |
index_type | indexLevel (GeoID const &id) const |
template<std::size_t Level, typename GeoID > | |
void | fillID (GeoID &id, index_type index) const |
Fills the specified ID with its index. More... | |
template<std::size_t Level, typename GeoID > | |
bool | hasElementLevel (GeoID const &id) const |
Returns whether all levels of id up to Level are within range. More... | |
index_type | computeSize () const |
Computes the expected size of this mapping. More... | |
template<typename OIDType , typename OIndex , std::size_t... Indices> | |
void | resizeAsImpl (geo::GeoIDmapper< OIDType, OIndex > const &other, std::index_sequence< Indices... >) |
Implementation for resizeAs() . More... | |
Static Private Member Functions | |
template<std::size_t Level, typename Dims > | |
static index_type | sizeLevel (Dims const &dimSizes) |
static Dimensions_t | zeroDimensions () |
Initializer with zero size for each of the dimensions. More... | |
template<typename Value , typename Upper > | |
static bool | bounded (Value v, Upper upper) |
Returns whether the specified value is between 0 and the upper limit. More... | |
Private Attributes | |
Dimensions_t | fN = zeroDimensions() |
Number of maximum entries per ID level. More... | |
Indexer status query | |
index_type | size () const |
Returns the number of elements in the mapping. More... | |
bool | empty () const |
Returns whether the mapping has no elements (false by assumptions). More... | |
template<std::size_t Level> | |
unsigned int | dimSize () const |
Dimensions of the Level dimension of this mapping. More... | |
template<typename GeoID = ID_t> | |
bool | hasElement (GeoID const &id) const |
Returns whether this mapping hosts data for the specified ID. More... | |
template<typename GeoID = ID_t> | |
GeoID | firstID () const |
Returns the ID of the first element with GeoID type. More... | |
template<typename GeoID = ID_t> | |
GeoID | lastID () const |
Returns the ID of the last covered element with GeoID type. More... | |
static constexpr unsigned int | dimensions () |
Dimensions of the ID of this mapping. More... | |
Class managing the mapping between geometry/readout ID and flat index.
IDType | the geometry or readout ID to be managed |
Index | (default: std::size_t ) type of flat index |
This class maps multi-level ID's (e.g. geo::WireID
, readout::TPCsetID
) into a single linear index.
The current implementation guarantees that the indices are ordered like their respective IDs, and that there are no gaps so that each index up to size()
(excluded) corresponds to a "valid" ID. The range of valid IDs is a hyperbox so that all elements of a certain level have the same number of sub-elements (for examples, all planes have the same number of wires, all valid from the mapping point of view).
Note that this mapping is typically not suitable for channel mapping, since usually planes with different wire orientations may have different number of wires, making some of the indices that are valid from the point of view of this ID mapping invalid in that they match wires that do not exist and should not be assigned a channel number.
Definition at line 28 of file GeometryIDmapper.h.
|
private |
< Type of dimension sizes.
Definition at line 186 of file GeometryIDmapper.h.
using geo::GeoIDmapper< IDType, Index >::ID_t = IDType |
Type used as ID for this mapping.
Definition at line 78 of file GeometryIDmapper.h.
using geo::GeoIDmapper< IDType, Index >::index_type = Index |
Type of flat index.
Definition at line 79 of file GeometryIDmapper.h.
geo::GeoIDmapper< IDType, Index >::GeoIDmapper | ( | ) |
Default constructor: all dimensions empty.
resize()
The indexer must be resized before being of any use.
Definition at line 405 of file GeometryIDmapper.h.
geo::GeoIDmapper< IDType, Index >::GeoIDmapper | ( | std::initializer_list< unsigned int > | dims | ) |
Prepares the indexer.
dims | number of elements on all levels of the mapping |
resize()
The size of each dimension is specified by the corresponding number, starting from the size of the outer dimension (cryostat).
Definition at line 412 of file GeometryIDmapper.h.
References geo::GeoIDmapper< IDType, Index >::dimensions().
|
inlinestaticprivate |
Returns whether the specified value is between 0
and the upper limit.
Definition at line 237 of file GeometryIDmapper.h.
Referenced by geo::GeoIDmapper< IDType, Index >::hasElementLevel().
void geo::GeoIDmapper< IDType, Index >::clear | ( | ) |
Sets all dimension sizes to 0
.
resize()
The mapping needs to be resized before it is useful again.
Definition at line 527 of file GeometryIDmapper.h.
References geo::GeoIDmapper< IDType, Index >::fN.
|
private |
Computes the expected size of this mapping.
Definition at line 573 of file GeometryIDmapper.h.
References geo::GeoIDmapper< IDType, Index >::fN.
Referenced by geo::GeoIDmapper< IDType, Index >::size().
|
static |
Dimensions of the ID of this mapping.
Definition at line 445 of file GeometryIDmapper.h.
Referenced by geo::GeoIDmapper< IDType, Index >::dimSize(), geo::GeoIDmapper< IDType, Index >::GeoIDmapper(), geo::GeoIDmapper< IDType, Index >::resizeAs(), geo::GeoIDmapper< IDType, Index >::resizeAsImpl(), and geo::GeoIDmapper< IDType, Index >::sizeLevel().
unsigned int geo::GeoIDmapper< IDType, Index >::dimSize | ( | ) | const |
Dimensions of the Level
dimension of this mapping.
Definition at line 435 of file GeometryIDmapper.h.
References geo::GeoIDmapper< IDType, Index >::dimensions(), and geo::GeoIDmapper< IDType, Index >::fN.
bool geo::GeoIDmapper< IDType, Index >::empty | ( | ) | const |
Returns whether the mapping has no elements (false
by assumptions).
Definition at line 427 of file GeometryIDmapper.h.
References geo::GeoIDmapper< IDType, Index >::size().
|
private |
Fills the specified ID with its index.
Level | the level of the index to fill (0 for cryostat level, etc._ |
GeoID | type of ID to be filled |
id | the ID to be filled |
index | the index corresponding to the ID |
indexLevel()
, index()
Fills the specified ID with its index. This can be considered the inverse operation of the index()
method. The index
argument is local to the level to be filled, e.g. for cryostats it goes from 0
to the number of cryostats.
Definition at line 547 of file GeometryIDmapper.h.
References geo::GeoIDmapper< IDType, Index >::fN.
GeoID geo::GeoIDmapper< IDType, Index >::firstID | ( | ) | const |
Returns the ID of the first element with GeoID
type.
Definition at line 461 of file GeometryIDmapper.h.
bool geo::GeoIDmapper< IDType, Index >::hasElement | ( | GeoID const & | id | ) | const |
Returns whether this mapping hosts data for the specified ID.
Definition at line 453 of file GeometryIDmapper.h.
|
private |
Returns whether all levels of id
up to Level
are within range.
Definition at line 562 of file GeometryIDmapper.h.
References geo::GeoIDmapper< IDType, Index >::bounded(), and geo::GeoIDmapper< IDType, Index >::fN.
auto geo::GeoIDmapper< IDType, Index >::ID | ( | index_type const | index | ) | const |
Returns the ID corresponding to the specified linear index
.
Definition at line 489 of file GeometryIDmapper.h.
References geo::GeoIDmapper< IDType, Index >::index().
Referenced by geo::GeoIDmapper< IDType, Index >::operator()().
auto geo::GeoIDmapper< IDType, Index >::index | ( | ID_t const & | id | ) | const |
Returns the linear index corresponding to the specified ID.
Definition at line 482 of file GeometryIDmapper.h.
Referenced by geo::GeoIDmapper< IDType, Index >::ID(), and geo::GeoIDmapper< IDType, Index >::operator()().
|
private |
Referenced by geo::GeoIDmapper< IDType, Index >::indexLevel().
auto geo::GeoIDmapper< IDType, Index >::indexLevel | ( | GeoID const & | id | ) | const -> index_type |
Definition at line 535 of file GeometryIDmapper.h.
References geo::GeoIDmapper< IDType, Index >::fN, and geo::GeoIDmapper< IDType, Index >::indexLevel().
GeoID geo::GeoIDmapper< IDType, Index >::lastID | ( | ) | const |
Returns the ID of the last covered element with GeoID
type.
Definition at line 472 of file GeometryIDmapper.h.
References geo::GeoIDmapper< IDType, Index >::fN.
auto geo::GeoIDmapper< IDType, Index >::operator() | ( | ID_t const & | id | ) | const |
Returns the linear index corresponding to the specified ID.
Definition at line 498 of file GeometryIDmapper.h.
References geo::GeoIDmapper< IDType, Index >::index().
auto geo::GeoIDmapper< IDType, Index >::operator() | ( | index_type const | index | ) | const |
Returns the ID corresponding to the specified linear index
.
Definition at line 505 of file GeometryIDmapper.h.
References geo::GeoIDmapper< IDType, Index >::ID(), and geo::GeoIDmapper< IDType, Index >::index().
void geo::GeoIDmapper< IDType, Index >::resize | ( | std::initializer_list< unsigned int > | dims | ) |
Resizes the mapping to accommodate the specified dimension sizes.
dims | number of elements on all levels of the mapping |
resizeAs()
The size of each dimension is specified by the corresponding number, starting from the size of the outer dimension (cryostat).
Definition at line 512 of file GeometryIDmapper.h.
References geo::GeoIDmapper< IDType, Index >::fN.
Referenced by geo::GeoIDmapper< IDType, Index >::resizeAsImpl().
void geo::GeoIDmapper< IDType, Index >::resizeAs | ( | geo::GeoIDmapper< OIDType, OIndex > const & | other | ) |
Resizes the mapping to reflect the one from another mapping.
other | ID mapping to take dimensions from |
The size of each dimension is taken by the matching one in other
.
Definition at line 520 of file GeometryIDmapper.h.
References geo::GeoIDmapper< IDType, Index >::dimensions(), and geo::GeoIDmapper< IDType, Index >::resizeAsImpl().
|
private |
Implementation for resizeAs()
.
Definition at line 581 of file GeometryIDmapper.h.
References geo::GeoIDmapper< IDType, Index >::dimensions(), and geo::GeoIDmapper< IDType, Index >::resize().
Referenced by geo::GeoIDmapper< IDType, Index >::resizeAs().
auto geo::GeoIDmapper< IDType, Index >::size | ( | ) | const |
Returns the number of elements in the mapping.
Definition at line 420 of file GeometryIDmapper.h.
References geo::GeoIDmapper< IDType, Index >::computeSize().
Referenced by geo::GeoIDmapper< IDType, Index >::empty().
|
staticprivate |
Returns the number of elements at the specified Level
.
dimSizes | the sizes of each of the levels |
auto geo::GeoIDmapper< IDType, Index >::sizeLevel | ( | Dims const & | dimSizes | ) | -> index_type |
Definition at line 593 of file GeometryIDmapper.h.
References geo::GeoIDmapper< IDType, Index >::dimensions().
|
inlinestaticprivate |
Initializer with zero size for each of the dimensions.
Definition at line 228 of file GeometryIDmapper.h.
|
private |
Number of maximum entries per ID level.
Definition at line 189 of file GeometryIDmapper.h.
Referenced by geo::GeoIDmapper< IDType, Index >::clear(), geo::GeoIDmapper< IDType, Index >::computeSize(), geo::GeoIDmapper< IDType, Index >::dimSize(), geo::GeoIDmapper< IDType, Index >::fillID(), geo::GeoIDmapper< IDType, Index >::hasElementLevel(), geo::GeoIDmapper< IDType, Index >::indexLevel(), geo::GeoIDmapper< IDType, Index >::lastID(), and geo::GeoIDmapper< IDType, Index >::resize().