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 29 of file GeometryIDmapper.h.
|
private |
< Type of dimension sizes.
Definition at line 196 of file GeometryIDmapper.h.
using geo::GeoIDmapper< IDType, Index >::ID_t = IDType |
Type used as ID for this mapping.
Definition at line 81 of file GeometryIDmapper.h.
using geo::GeoIDmapper< IDType, Index >::index_type = Index |
Type of flat index.
Definition at line 82 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 432 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 441 of file GeometryIDmapper.h.
|
inlinestaticprivate |
Returns whether the specified value is between 0
and the upper limit.
Definition at line 247 of file GeometryIDmapper.h.
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 552 of file GeometryIDmapper.h.
|
private |
Computes the expected size of this mapping.
Definition at line 600 of file GeometryIDmapper.h.
|
static |
Dimensions of the ID of this mapping.
Definition at line 471 of file GeometryIDmapper.h.
unsigned int geo::GeoIDmapper< IDType, Index >::dimSize | ( | ) | const |
Dimensions of the Level
dimension of this mapping.
Definition at line 463 of file GeometryIDmapper.h.
bool geo::GeoIDmapper< IDType, Index >::empty | ( | ) | const |
Returns whether the mapping has no elements (false
by assumptions).
Definition at line 456 of file GeometryIDmapper.h.
|
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 574 of file GeometryIDmapper.h.
GeoID geo::GeoIDmapper< IDType, Index >::firstID | ( | ) | const |
Returns the ID of the first element with GeoID
type.
Definition at line 485 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 478 of file GeometryIDmapper.h.
|
private |
Returns whether all levels of id
up to Level
are within range.
Definition at line 590 of file GeometryIDmapper.h.
auto geo::GeoIDmapper< IDType, Index >::ID | ( | index_type const | index | ) | const |
Returns the ID corresponding to the specified linear index
.
Definition at line 509 of file GeometryIDmapper.h.
auto geo::GeoIDmapper< IDType, Index >::index | ( | ID_t const & | id | ) | const |
Returns the linear index corresponding to the specified ID.
Definition at line 503 of file GeometryIDmapper.h.
|
private |
auto geo::GeoIDmapper< IDType, Index >::indexLevel | ( | GeoID const & | id | ) | const -> index_type |
Definition at line 560 of file GeometryIDmapper.h.
GeoID geo::GeoIDmapper< IDType, Index >::lastID | ( | ) | const |
Returns the ID of the last covered element with GeoID
type.
Definition at line 494 of file GeometryIDmapper.h.
auto geo::GeoIDmapper< IDType, Index >::operator() | ( | ID_t const & | id | ) | const |
Returns the linear index corresponding to the specified ID.
Definition at line 519 of file GeometryIDmapper.h.
auto geo::GeoIDmapper< IDType, Index >::operator() | ( | index_type const | index | ) | const |
Returns the ID corresponding to the specified linear index
.
Definition at line 526 of file GeometryIDmapper.h.
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 534 of file GeometryIDmapper.h.
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 544 of file GeometryIDmapper.h.
|
private |
Implementation for resizeAs()
.
Definition at line 607 of file GeometryIDmapper.h.
auto geo::GeoIDmapper< IDType, Index >::size | ( | ) | const |
Returns the number of elements in the mapping.
Definition at line 450 of file GeometryIDmapper.h.
|
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 622 of file GeometryIDmapper.h.
|
inlinestaticprivate |
Initializer with zero size for each of the dimensions.
Definition at line 242 of file GeometryIDmapper.h.
|
private |
Number of maximum entries per ID level.
Definition at line 199 of file GeometryIDmapper.h.