Container with one element per geometry TPC. More...
#include <GeometryDataContainers.h>
Classes | |
struct | IDextractor |
Functor to extract an ID data member. More... | |
Public Member Functions | |
GeoIDdataContainer ()=default | |
Default constructor: container has no room at all. More... | |
GeoIDdataContainer (std::initializer_list< unsigned int > dims) | |
Prepares the container with default-constructed data. More... | |
GeoIDdataContainer (std::initializer_list< unsigned int > dims, value_type const &defValue) | |
Prepares the container initializing all its data. More... | |
Element access | |
reference | operator[] (ID_t const &id) |
Returns the element for the specified geometry element. More... | |
const_reference | operator[] (ID_t const &id) const |
Returns the element for the specified geometry element (read-only). More... | |
reference | at (ID_t const &id) |
const_reference | at (ID_t const &id) const |
reference | first () |
Returns the element for the first ID (unchecked). More... | |
const_reference | first () const |
Returns the element for the first ID (unchecked). More... | |
reference | last () |
Returns the element for the last ID (unchecked). More... | |
const_reference | last () const |
Returns the element for the last ID (unchecked). More... | |
Iterators | |
Two types of iterators are provided:
Reverse iterators are not supported (yet?). Standard iteratorsThe STL-like interface provides iterators that go through the entire range of allowed data, i.e. all the These iterators have an interface extension: the data member auto iData = data.begin();
auto const dend = data.end();
while (iData != dend) {
++iData;
} // while
Note that using the range-for loop, you don't get access to the iterator and therefore not even to the ID. Item iteratorsThe item iterators are iterators adapted from the standard ones, which when dereferenced return a pair ( }
(this loop has the same effect as the one in the example of the standard iterators, but it's more compact). | |
iterator | begin () |
Returns an iterator to the beginning of the data. More... | |
iterator | end () |
Returns an iterator to past the end of the data. More... | |
const_iterator | begin () const |
Returns a constant iterator to the beginning of the data. More... | |
const_iterator | end () const |
Returns a constant iterator to past the end of the data. More... | |
const_iterator | cbegin () const |
Returns a constant iterator to the beginning of the data. More... | |
const_iterator | cend () const |
Returns a constant iterator to past the end of the data. More... | |
item_iterator | item_begin () |
Returns an item iterator to the beginning of the data. More... | |
item_iterator | item_end () |
Returns an item iterator to past the end of the data. More... | |
item_const_iterator | item_begin () const |
Returns a item constant iterator to the beginning of the data. More... | |
item_const_iterator | item_end () const |
Returns a item constant iterator to past the end of the data. More... | |
item_const_iterator | item_cbegin () const |
Returns a item constant iterator to the beginning of the data. More... | |
item_const_iterator | item_cend () const |
Returns a item constant iterator to past the end of the data. More... | |
auto | items () |
Returns an object suitable for a range-for loop with item_iterator . More... | |
auto | items () const |
Returns an object suitable for a range-for loop with item_const_iterator . More... | |
Data modification | |
In general, each single element can be accessed and changed. In addition, this section includes methods acting on multiple elements at once. | |
void | fill (value_type value) |
Sets all elements to the specified value (copied). More... | |
void | reset () |
Sets all the elements to a default-constructed value_type . More... | |
template<typename Op > | |
Op | apply (Op &&op) |
Applies an operation on all elements. More... | |
template<typename Op > | |
decltype(auto) | apply (Op &&op) const |
Applies an operation on all elements. More... | |
Container modification | |
void | resize (std::initializer_list< unsigned int > dims) |
Prepares the container with default-constructed data. More... | |
void | resize (std::initializer_list< unsigned int > dims, value_type const &defValue) |
Prepares the container initializing all its data. More... | |
template<typename OT > | |
void | resizeAs (geo::GeoIDdataContainer< OT, Mapper_t > const &other) |
Prepares the container with default-constructed data. More... | |
template<typename OT > | |
void | resizeAs (geo::GeoIDdataContainer< OT, Mapper_t > const &other, value_type const &defValue) |
Prepares the container initializing all its data. More... | |
void | clear () |
Makes the container empty, with no usable storage space. More... | |
Private Types | |
using | This_t = geo::GeoIDdataContainer< T, Mapper > |
Type of this class. More... | |
using | Container_t = details::GeoContainerData< T > |
Type of data container helper. More... | |
using | BaseIter_t = typename Container_t::iterator |
Type of iterator to the data. More... | |
using | BaseConstIter_t = typename Container_t::const_iterator |
Type of constant iterator to the data. More... | |
Private Member Functions | |
size_type | index (ID_t const &id) const |
Returns the internal index of the specified ID in the storage area. More... | |
ID_t | ID (size_type const index) const |
Returns the ID corresponding to a internal index in the storage area. More... | |
Private Attributes | |
Mapper_t | fMapper |
Mapping of IDs to indices. More... | |
Container_t | fData |
Data storage. More... | |
Container status query | |
size_type | size () const |
Returns the number of elements in the container. More... | |
size_type | capacity () const |
Returns the number of elements the container has memory for. More... | |
bool | empty () const |
Returns whether the container has no elements (false by assumptions). More... | |
template<std::size_t Level> | |
unsigned int | dimSize () const |
Dimensions of the Level dimension of this container. More... | |
template<typename GeoID > | |
bool | hasElement (GeoID const &id) const |
Returns whether this container 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... | |
Mapper_t const & | mapper () const |
Returns the mapper object used to convert ID's and container positions. More... | |
static constexpr unsigned int | dimensions () |
Dimensions of the ID of this container. More... | |
Container with one element per geometry TPC.
T | type of the contained datum |
geo::GeometryCore::makeTPCData
The container is of fixed size and can't be neither resized nor freed before destruction.
This example creates a "map" of tracks starting on each TPC:
The following assumptions should be considered unchecked, and the behavior when they are violated undefined (but note that in debug mode some of them might be actually checked):
Definition at line 36 of file GeometryDataContainers.h.
|
private |
Type of constant iterator to the data.
Definition at line 114 of file GeometryDataContainers.h.
|
private |
Type of iterator to the data.
Definition at line 111 of file GeometryDataContainers.h.
using geo::GeoIDdataContainer< T, Mapper >::const_iterator = details::GeoIDdataContainerIterator<Mapper_t, BaseConstIter_t> |
Definition at line 138 of file GeometryDataContainers.h.
using geo::GeoIDdataContainer< T, Mapper >::const_pointer = typename Container_t::const_pointer |
Definition at line 136 of file GeometryDataContainers.h.
using geo::GeoIDdataContainer< T, Mapper >::const_reference = typename Container_t::const_reference |
Definition at line 134 of file GeometryDataContainers.h.
|
private |
Type of data container helper.
Definition at line 108 of file GeometryDataContainers.h.
using geo::GeoIDdataContainer< T, Mapper >::difference_type = typename Container_t::difference_type |
Definition at line 141 of file GeometryDataContainers.h.
using geo::GeoIDdataContainer< T, Mapper >::ID_t = typename Mapper_t::ID_t |
Type used as ID for this container.
Definition at line 127 of file GeometryDataContainers.h.
using geo::GeoIDdataContainer< T, Mapper >::item_const_iterator = details::GeoIDdataContainerItemIterator<const_iterator> |
Special iterator dereferencing to pairs ( ID, value ) (see items()
).
Definition at line 148 of file GeometryDataContainers.h.
using geo::GeoIDdataContainer< T, Mapper >::item_iterator = details::GeoIDdataContainerItemIterator<iterator> |
Special iterator dereferencing to pairs ( ID, value ) (see items()
).
Definition at line 145 of file GeometryDataContainers.h.
using geo::GeoIDdataContainer< T, Mapper >::iterator = details::GeoIDdataContainerIterator<Mapper_t, BaseIter_t> |
Definition at line 137 of file GeometryDataContainers.h.
using geo::GeoIDdataContainer< T, Mapper >::Mapper_t = Mapper |
Type of mapper between IDs and index.
Definition at line 125 of file GeometryDataContainers.h.
using geo::GeoIDdataContainer< T, Mapper >::pointer = typename Container_t::pointer |
Definition at line 135 of file GeometryDataContainers.h.
using geo::GeoIDdataContainer< T, Mapper >::reference = typename Container_t::reference |
Definition at line 133 of file GeometryDataContainers.h.
using geo::GeoIDdataContainer< T, Mapper >::size_type = typename Container_t::size_type |
Definition at line 142 of file GeometryDataContainers.h.
|
private |
Type of this class.
Definition at line 105 of file GeometryDataContainers.h.
using geo::GeoIDdataContainer< T, Mapper >::value_type = typename Container_t::value_type |
Definition at line 132 of file GeometryDataContainers.h.
|
default |
Default constructor: container has no room at all.
resize()
The object must be resized before being of any use.
geo::GeoIDdataContainer< T, Mapper >::GeoIDdataContainer | ( | std::initializer_list< unsigned int > | dims | ) |
Prepares the container with default-constructed data.
dims | number of elements on all levels of the container |
resize()
The size of each dimension is specified by the corresponding number, starting from the size of the outer dimension (cryostat).
The container is sized to host data for all the elements. Each element in the container is default-constructed.
Definition at line 1226 of file GeometryDataContainers.h.
geo::GeoIDdataContainer< T, Mapper >::GeoIDdataContainer | ( | std::initializer_list< unsigned int > | dims, |
value_type const & | defValue | ||
) |
Prepares the container initializing all its data.
dims | number of elements on all levels of the container |
defValue | the value copied to fill all entries in the container |
resize()
The size of each dimension is specified by the corresponding number, starting from the size of the outer dimension (cryostat).
The container is sized to host data for all the elements. Each element in the container is constructed as copy of defValue
.
Definition at line 1237 of file GeometryDataContainers.h.
Op geo::GeoIDdataContainer< T, Mapper >::apply | ( | Op && | op | ) |
Applies an operation on all elements.
Op | type of operation |
op | Operation |
The operation op
is a unary functor, i.e. an object that supports the call to op(value_type&)
.
The return values of op
calls are discarded.
Definition at line 1461 of file GeometryDataContainers.h.
decltype(auto) geo::GeoIDdataContainer< T, Mapper >::apply | ( | Op && | op | ) | const |
Applies an operation on all elements.
Op | type of operation |
op | Operation |
The operation op
is a unary functor, i.e. an object that supports the call to op(value_type const&)
.
The return values of op
calls are discarded. Note that while the elements of this container can't be modified, the operation itself still can if not constant, and it is returned.
auto geo::GeoIDdataContainer< T, Mapper >::at | ( | ID_t const & | id | ) |
Returns the element for the specified geometry element.
std::out_of_range | if element id is not within the container range |
Definition at line 1318 of file GeometryDataContainers.h.
auto geo::GeoIDdataContainer< T, Mapper >::at | ( | ID_t const & | id | ) | const |
Returns the element for the specified geometry element (read-only).
std::out_of_range | if element id is not within the container range |
Definition at line 1326 of file GeometryDataContainers.h.
auto geo::GeoIDdataContainer< T, Mapper >::begin | ( | ) |
Returns an iterator to the beginning of the data.
Definition at line 1360 of file GeometryDataContainers.h.
auto geo::GeoIDdataContainer< T, Mapper >::begin | ( | ) | const |
Returns a constant iterator to the beginning of the data.
Definition at line 1372 of file GeometryDataContainers.h.
auto geo::GeoIDdataContainer< T, Mapper >::capacity | ( | ) | const |
Returns the number of elements the container has memory for.
Definition at line 1253 of file GeometryDataContainers.h.
auto geo::GeoIDdataContainer< T, Mapper >::cbegin | ( | ) | const |
Returns a constant iterator to the beginning of the data.
Definition at line 1384 of file GeometryDataContainers.h.
auto geo::GeoIDdataContainer< T, Mapper >::cend | ( | ) | const |
Returns a constant iterator to past the end of the data.
Definition at line 1390 of file GeometryDataContainers.h.
void geo::GeoIDdataContainer< T, Mapper >::clear | ( | ) |
Makes the container empty, with no usable storage space.
resize()
The container needs to be resized before it is useful again.
Definition at line 1509 of file GeometryDataContainers.h.
|
static |
unsigned int geo::GeoIDdataContainer< T, Mapper >::dimSize | ( | ) | const |
Dimensions of the Level
dimension of this container.
Definition at line 1266 of file GeometryDataContainers.h.
bool geo::GeoIDdataContainer< T, Mapper >::empty | ( | ) | const |
Returns whether the container has no elements (false
by assumptions).
Definition at line 1259 of file GeometryDataContainers.h.
auto geo::GeoIDdataContainer< T, Mapper >::end | ( | ) |
Returns an iterator to past the end of the data.
Definition at line 1366 of file GeometryDataContainers.h.
auto geo::GeoIDdataContainer< T, Mapper >::end | ( | ) | const |
Returns a constant iterator to past the end of the data.
Definition at line 1378 of file GeometryDataContainers.h.
void geo::GeoIDdataContainer< T, Mapper >::fill | ( | value_type | value | ) |
Sets all elements to the specified value
(copied).
Definition at line 1448 of file GeometryDataContainers.h.
auto geo::GeoIDdataContainer< T, Mapper >::first | ( | ) |
Returns the element for the first ID (unchecked).
Definition at line 1336 of file GeometryDataContainers.h.
auto geo::GeoIDdataContainer< T, Mapper >::first | ( | ) | const |
Returns the element for the first ID (unchecked).
Definition at line 1342 of file GeometryDataContainers.h.
GeoID geo::GeoIDdataContainer< T, Mapper >::firstID | ( | ) | const |
Returns the ID of the first element with GeoID type.
Definition at line 1286 of file GeometryDataContainers.h.
bool geo::GeoIDdataContainer< T, Mapper >::hasElement | ( | GeoID const & | id | ) | const |
Returns whether this container hosts data for the specified ID.
Definition at line 1279 of file GeometryDataContainers.h.
|
private |
Returns the ID corresponding to a internal index in the storage area.
Definition at line 1531 of file GeometryDataContainers.h.
|
private |
Returns the internal index of the specified ID in the storage area.
Definition at line 1524 of file GeometryDataContainers.h.
auto geo::GeoIDdataContainer< T, Mapper >::item_begin | ( | ) |
Returns an item iterator to the beginning of the data.
Definition at line 1396 of file GeometryDataContainers.h.
auto geo::GeoIDdataContainer< T, Mapper >::item_begin | ( | ) | const |
Returns a item constant iterator to the beginning of the data.
Definition at line 1408 of file GeometryDataContainers.h.
auto geo::GeoIDdataContainer< T, Mapper >::item_cbegin | ( | ) | const |
Returns a item constant iterator to the beginning of the data.
Definition at line 1422 of file GeometryDataContainers.h.
auto geo::GeoIDdataContainer< T, Mapper >::item_cend | ( | ) | const |
Returns a item constant iterator to past the end of the data.
Definition at line 1429 of file GeometryDataContainers.h.
auto geo::GeoIDdataContainer< T, Mapper >::item_end | ( | ) |
Returns an item iterator to past the end of the data.
Definition at line 1402 of file GeometryDataContainers.h.
auto geo::GeoIDdataContainer< T, Mapper >::item_end | ( | ) | const |
Returns a item constant iterator to past the end of the data.
Definition at line 1415 of file GeometryDataContainers.h.
auto geo::GeoIDdataContainer< T, Mapper >::items | ( | ) |
Returns an object suitable for a range-for loop with item_iterator
.
Definition at line 1436 of file GeometryDataContainers.h.
auto geo::GeoIDdataContainer< T, Mapper >::items | ( | ) | const |
Returns an object suitable for a range-for loop with item_const_iterator
.
Definition at line 1442 of file GeometryDataContainers.h.
auto geo::GeoIDdataContainer< T, Mapper >::last | ( | ) |
Returns the element for the last ID (unchecked).
Definition at line 1348 of file GeometryDataContainers.h.
auto geo::GeoIDdataContainer< T, Mapper >::last | ( | ) | const |
Returns the element for the last ID (unchecked).
Definition at line 1354 of file GeometryDataContainers.h.
GeoID geo::GeoIDdataContainer< T, Mapper >::lastID | ( | ) | const |
Returns the ID of the last covered element with GeoID type.
Definition at line 1293 of file GeometryDataContainers.h.
auto geo::GeoIDdataContainer< T, Mapper >::mapper | ( | ) | const |
Returns the mapper object used to convert ID's and container positions.
Definition at line 1299 of file GeometryDataContainers.h.
auto geo::GeoIDdataContainer< T, Mapper >::operator[] | ( | ID_t const & | id | ) |
Returns the element for the specified geometry element.
Definition at line 1305 of file GeometryDataContainers.h.
auto geo::GeoIDdataContainer< T, Mapper >::operator[] | ( | ID_t const & | id | ) | const |
Returns the element for the specified geometry element (read-only).
Definition at line 1311 of file GeometryDataContainers.h.
void geo::GeoIDdataContainer< T, Mapper >::reset | ( | ) |
Sets all the elements to a default-constructed value_type
.
Definition at line 1454 of file GeometryDataContainers.h.
void geo::GeoIDdataContainer< T, Mapper >::resize | ( | std::initializer_list< unsigned int > | dims | ) |
Prepares the container with default-constructed data.
dims | number of elements on all levels of the container |
The size of each dimension is specified by the corresponding number, starting from the size of the outer dimension (cryostat).
The container is sized to host data for all the elements. Each new element in the container is default-constructed. Existing data is not touched, but it may be rearranged in a non-straightforward way.
Definition at line 1468 of file GeometryDataContainers.h.
void geo::GeoIDdataContainer< T, Mapper >::resize | ( | std::initializer_list< unsigned int > | dims, |
value_type const & | defValue | ||
) |
Prepares the container initializing all its data.
dims | number of elements on all levels of the container |
defValue | the value copied to fill all entries in the container |
The size of each dimension is specified by the corresponding number, starting from the size of the outer dimension (cryostat).
The container is sized to host data for all the elements. Each new element in the container is constructed as copy of defValue
. Existing data is not touched, but it may be rearranged in a non-straightforward way.
Definition at line 1478 of file GeometryDataContainers.h.
void geo::GeoIDdataContainer< T, Mapper >::resizeAs | ( | geo::GeoIDdataContainer< OT, Mapper_t > const & | other | ) |
Prepares the container with default-constructed data.
other | data collection to take dimensions from |
The size of each dimension is taken by the matching one in other
.
The container is sized to host data for all the elements. Each new element in the container is default-constructed. Existing data is not touched, but it may be rearranged in a non-straightforward way.
Definition at line 1489 of file GeometryDataContainers.h.
void geo::GeoIDdataContainer< T, Mapper >::resizeAs | ( | geo::GeoIDdataContainer< OT, Mapper_t > const & | other, |
value_type const & | defValue | ||
) |
Prepares the container initializing all its data.
other | data collection to take dimensions from |
defValue | the value copied to fill all entries in the container |
The size of each dimension is taken by the matching one in other
.
The container is sized to host data for all the elements. Each new element in the container is constructed as copy of defValue
. Existing data is not touched, but it may be rearranged in a non-straightforward way.
Definition at line 1500 of file GeometryDataContainers.h.
auto geo::GeoIDdataContainer< T, Mapper >::size | ( | ) | const |
Returns the number of elements in the container.
Definition at line 1247 of file GeometryDataContainers.h.
|
private |
Data storage.
Definition at line 500 of file GeometryDataContainers.h.
|
private |
Mapping of IDs to indices.
Definition at line 498 of file GeometryDataContainers.h.