LArSoft  v09_90_00
Liquid Argon Software toolkit - https://larsoft.org/
geo::GeoIDdataContainer< T, Mapper > Class Template Reference

Container with one element per geometry TPC. More...

#include "GeometryDataContainers.h"

Classes

struct  IDextractor
 Functor to extract an ID data member. More...
 

Public Types

using Mapper_t = Mapper
 Type of mapper between IDs and index. More...
 
using ID_t = typename Mapper_t::ID_t
 Type used as ID for this container. More...
 
STL container types.
using value_type = typename Container_t::value_type
 Special iterator dereferencing to pairs ( ID, value ) (see items()). More...
 
using reference = typename Container_t::reference
 Special iterator dereferencing to pairs ( ID, value ) (see items()). More...
 
using const_reference = typename Container_t::const_reference
 Special iterator dereferencing to pairs ( ID, value ) (see items()). More...
 
using pointer = typename Container_t::pointer
 Special iterator dereferencing to pairs ( ID, value ) (see items()). More...
 
using const_pointer = typename Container_t::const_pointer
 Special iterator dereferencing to pairs ( ID, value ) (see items()). More...
 
using iterator = details::GeoIDdataContainerIterator< Mapper_t, BaseIter_t >
 Special iterator dereferencing to pairs ( ID, value ) (see items()). More...
 
using const_iterator = details::GeoIDdataContainerIterator< Mapper_t, BaseConstIter_t >
 Special iterator dereferencing to pairs ( ID, value ) (see items()). More...
 
using difference_type = typename Container_t::difference_type
 Special iterator dereferencing to pairs ( ID, value ) (see items()). More...
 
using size_type = typename Container_t::size_type
 Special iterator dereferencing to pairs ( ID, value ) (see items()). More...
 
using item_iterator = details::GeoIDdataContainerItemIterator< iterator >
 Special iterator dereferencing to pairs ( ID, value ) (see items()). More...
 
using item_const_iterator = details::GeoIDdataContainerItemIterator< const_iterator >
 Special iterator dereferencing to pairs ( ID, value ) (see items()). 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:

  1. "standard" iterators pointing to data values
  2. "item" pseudo-iterators dereferencing to a (ID, value) pair

Reverse iterators are not supported (yet?).

Standard iterators

The STL-like interface provides iterators that go through the entire range of allowed data, i.e. all the size() elements that are also reached via random access (operator[]()).

These iterators have an interface extension: the data member ID() returns the ID of the element the iterator is pointing to. For example:

auto iData = data.begin();
auto const dend = data.end();
while (iData != dend) {
std::cout << "data[" << iData.ID() << "] = " << *iData << std::endl;
++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 iterators

The item iterators are iterators adapted from the standard ones, which when dereferenced return a pair ( ID_t, reference ). They can be accessed with item_begin(), item_end() etc, and range-for loop can be obtained via items() member function:

for (auto&& [ ID, value ]: data.items()) {
std::cout << "data[" << ID << "] = " << value << std::endl;
}

(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...
 

Detailed Description

template<typename T, typename Mapper>
class geo::GeoIDdataContainer< T, Mapper >

Container with one element per geometry TPC.


Template Parameters
Ttype of the contained datum
See also
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:

auto const* geom = lar::providerFrom<geo::GeometryCore>();
(geom->NCryostats(), geom->MaxTPCs());
for (recob::Track const& track: tracks) {
geo::TPCGeo const* tpc = geom->PositionToTPCptr(track.Start());
if (tpc) TracksPerTPC[tpc->ID()].push_back(tpc);
} // for

Assumptions

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):

  • the container assumes the same number of TPCs in each cryostat. While this is not effectively a necessary condition, keep in mind that this container has no notion whether a given TPC actually exists in the geometry or not
  • at least one element is expected to be present

Definition at line 35 of file GeometryDataContainers.h.

Member Typedef Documentation

template<typename T, typename Mapper>
using geo::GeoIDdataContainer< T, Mapper >::BaseConstIter_t = typename Container_t::const_iterator
private

Type of constant iterator to the data.

Definition at line 112 of file GeometryDataContainers.h.

template<typename T, typename Mapper>
using geo::GeoIDdataContainer< T, Mapper >::BaseIter_t = typename Container_t::iterator
private

Type of iterator to the data.

Definition at line 109 of file GeometryDataContainers.h.

template<typename T, typename Mapper>
using geo::GeoIDdataContainer< T, Mapper >::const_iterator = details::GeoIDdataContainerIterator<Mapper_t, BaseConstIter_t>

Special iterator dereferencing to pairs ( ID, value ) (see items()).

Definition at line 138 of file GeometryDataContainers.h.

template<typename T, typename Mapper>
using geo::GeoIDdataContainer< T, Mapper >::const_pointer = typename Container_t::const_pointer

Special iterator dereferencing to pairs ( ID, value ) (see items()).

Definition at line 136 of file GeometryDataContainers.h.

template<typename T, typename Mapper>
using geo::GeoIDdataContainer< T, Mapper >::const_reference = typename Container_t::const_reference

Special iterator dereferencing to pairs ( ID, value ) (see items()).

Definition at line 134 of file GeometryDataContainers.h.

template<typename T, typename Mapper>
using geo::GeoIDdataContainer< T, Mapper >::Container_t = details::GeoContainerData<T>
private

Type of data container helper.

Definition at line 106 of file GeometryDataContainers.h.

template<typename T, typename Mapper>
using geo::GeoIDdataContainer< T, Mapper >::difference_type = typename Container_t::difference_type

Special iterator dereferencing to pairs ( ID, value ) (see items()).

Definition at line 141 of file GeometryDataContainers.h.

template<typename T, typename Mapper>
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.

template<typename T, typename Mapper>
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.

template<typename T, typename Mapper>
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.

template<typename T, typename Mapper>
using geo::GeoIDdataContainer< T, Mapper >::iterator = details::GeoIDdataContainerIterator<Mapper_t, BaseIter_t>

Special iterator dereferencing to pairs ( ID, value ) (see items()).

Definition at line 137 of file GeometryDataContainers.h.

template<typename T, typename Mapper>
using geo::GeoIDdataContainer< T, Mapper >::Mapper_t = Mapper

Type of mapper between IDs and index.

Definition at line 125 of file GeometryDataContainers.h.

template<typename T, typename Mapper>
using geo::GeoIDdataContainer< T, Mapper >::pointer = typename Container_t::pointer

Special iterator dereferencing to pairs ( ID, value ) (see items()).

Definition at line 135 of file GeometryDataContainers.h.

template<typename T, typename Mapper>
using geo::GeoIDdataContainer< T, Mapper >::reference = typename Container_t::reference

Special iterator dereferencing to pairs ( ID, value ) (see items()).

Definition at line 133 of file GeometryDataContainers.h.

template<typename T, typename Mapper>
using geo::GeoIDdataContainer< T, Mapper >::size_type = typename Container_t::size_type

Special iterator dereferencing to pairs ( ID, value ) (see items()).

Definition at line 142 of file GeometryDataContainers.h.

template<typename T, typename Mapper>
using geo::GeoIDdataContainer< T, Mapper >::This_t = geo::GeoIDdataContainer<T, Mapper>
private

Type of this class.

Definition at line 103 of file GeometryDataContainers.h.

template<typename T, typename Mapper>
using geo::GeoIDdataContainer< T, Mapper >::value_type = typename Container_t::value_type

Special iterator dereferencing to pairs ( ID, value ) (see items()).

Definition at line 132 of file GeometryDataContainers.h.

Constructor & Destructor Documentation

template<typename T, typename Mapper>
geo::GeoIDdataContainer< T, Mapper >::GeoIDdataContainer ( )
default

Default constructor: container has no room at all.

See also
resize()

The object must be resized before being of any use.

template<typename T , typename Mapper >
geo::GeoIDdataContainer< T, Mapper >::GeoIDdataContainer ( std::initializer_list< unsigned int >  dims)

Prepares the container with default-constructed data.

Parameters
dimsnumber of elements on all levels of the container
See also
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 1158 of file GeometryDataContainers.h.

References geo::details::GeoContainerData< T >::empty(), and geo::GeoIDdataContainer< T, Mapper >::fData.

1159  : fMapper(dims), fData(fMapper.size())
1160 {
1161  assert(!fData.empty());
1162 }
bool empty() const
Returns whether the container has no elements (false by assumptions).
Mapper_t fMapper
Mapping of IDs to indices.
Container_t fData
Data storage.
template<typename T , typename Mapper >
geo::GeoIDdataContainer< T, Mapper >::GeoIDdataContainer ( std::initializer_list< unsigned int >  dims,
value_type const &  defValue 
)

Prepares the container initializing all its data.

Parameters
dimsnumber of elements on all levels of the container
defValuethe value copied to fill all entries in the container
See also
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 1166 of file GeometryDataContainers.h.

References geo::details::GeoContainerData< T >::empty(), and geo::GeoIDdataContainer< T, Mapper >::fData.

1168  : fMapper(dims), fData(fMapper.computeSize(), defValue)
1169 {
1170  assert(!fData.empty());
1171 }
bool empty() const
Returns whether the container has no elements (false by assumptions).
Mapper_t fMapper
Mapping of IDs to indices.
Container_t fData
Data storage.

Member Function Documentation

template<typename T , typename Mapper >
template<typename Op >
Op geo::GeoIDdataContainer< T, Mapper >::apply ( Op &&  op)

Applies an operation on all elements.

Template Parameters
Optype of operation
Parameters
opOperation
Returns
the operation object after operations took place

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 1413 of file GeometryDataContainers.h.

References geo::details::GeoContainerData< T >::apply(), and geo::GeoIDdataContainer< T, Mapper >::fData.

Referenced by geo::GeoIDdataContainer< T, Mapper >::clear().

1414 {
1415  return fData.apply(std::forward<Op>(op));
1416 }
Op apply(Op &&op)
Applies an operation on all elements.
Container_t fData
Data storage.
template<typename T, typename Mapper>
template<typename Op >
decltype(auto) geo::GeoIDdataContainer< T, Mapper >::apply ( Op &&  op) const

Applies an operation on all elements.

Template Parameters
Optype of operation
Parameters
opOperation
Returns
the operation object after operations took place

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.

template<typename T , typename Mapper >
auto geo::GeoIDdataContainer< T, Mapper >::at ( ID_t const &  id)

Returns the element for the specified geometry element.

Exceptions
std::out_of_rangeif element id is not within the container range

Definition at line 1256 of file GeometryDataContainers.h.

References geo::GeoIDdataContainer< T, Mapper >::hasElement(), and geo::GeoIDdataContainer< T, Mapper >::operator[]().

1257 {
1258  if (hasElement(id)) return operator[](id);
1259  throw std::out_of_range("No data for " + std::string(id));
1260 } // geo::GeoIDdataContainer<>::at()
reference operator[](ID_t const &id)
Returns the element for the specified geometry element.
bool hasElement(GeoID const &id) const
Returns whether this container hosts data for the specified ID.
template<typename T , typename Mapper >
auto geo::GeoIDdataContainer< T, Mapper >::at ( ID_t const &  id) const

Returns the element for the specified geometry element (read-only).

Exceptions
std::out_of_rangeif element id is not within the container range

Definition at line 1264 of file GeometryDataContainers.h.

References geo::GeoIDdataContainer< T, Mapper >::hasElement(), and geo::GeoIDdataContainer< T, Mapper >::operator[]().

1265 {
1266  if (hasElement(id)) return operator[](id);
1267  throw std::out_of_range("No data for " + std::string(id));
1268 } // geo::GeoIDdataContainer<>::at() const
reference operator[](ID_t const &id)
Returns the element for the specified geometry element.
bool hasElement(GeoID const &id) const
Returns whether this container hosts data for the specified ID.
template<typename T , typename Mapper >
auto geo::GeoIDdataContainer< T, Mapper >::begin ( )

Returns an iterator to the beginning of the data.

Definition at line 1300 of file GeometryDataContainers.h.

References geo::details::GeoContainerData< T >::begin(), geo::GeoIDdataContainer< T, Mapper >::fData, and geo::GeoIDdataContainer< T, Mapper >::mapper().

Referenced by geo::GeoIDdataContainer< T, Mapper >::cbegin(), and geo::GeoIDdataContainer< T, Mapper >::item_begin().

1301 {
1302  return {mapper(), fData.begin(), fData.begin()};
1303 }
Mapper_t const & mapper() const
Returns the mapper object used to convert ID&#39;s and container positions.
Container_t fData
Data storage.
template<typename T , typename Mapper >
auto geo::GeoIDdataContainer< T, Mapper >::begin ( ) const

Returns a constant iterator to the beginning of the data.

Definition at line 1314 of file GeometryDataContainers.h.

References geo::details::GeoContainerData< T >::begin(), geo::GeoIDdataContainer< T, Mapper >::fData, and geo::GeoIDdataContainer< T, Mapper >::mapper().

1315 {
1316  return {mapper(), fData.begin(), fData.begin()};
1317 }
Mapper_t const & mapper() const
Returns the mapper object used to convert ID&#39;s and container positions.
Container_t fData
Data storage.
template<typename T , typename Mapper >
auto geo::GeoIDdataContainer< T, Mapper >::capacity ( ) const

Returns the number of elements the container has memory for.

Definition at line 1182 of file GeometryDataContainers.h.

References geo::details::GeoContainerData< T >::capacity(), and geo::GeoIDdataContainer< T, Mapper >::fData.

1183 {
1184  return fData.capacity();
1185 }
size_type capacity() const
Returns the number of elements the container has memory for.
Container_t fData
Data storage.
template<typename T , typename Mapper >
auto geo::GeoIDdataContainer< T, Mapper >::cbegin ( ) const

Returns a constant iterator to the beginning of the data.

Definition at line 1328 of file GeometryDataContainers.h.

References geo::GeoIDdataContainer< T, Mapper >::begin().

1329 {
1330  return begin();
1331 }
iterator begin()
Returns an iterator to the beginning of the data.
template<typename T , typename Mapper >
auto geo::GeoIDdataContainer< T, Mapper >::cend ( ) const

Returns a constant iterator to past the end of the data.

Definition at line 1335 of file GeometryDataContainers.h.

References geo::GeoIDdataContainer< T, Mapper >::end().

1336 {
1337  return end();
1338 }
iterator end()
Returns an iterator to past the end of the data.
template<typename T , typename Mapper >
void geo::GeoIDdataContainer< T, Mapper >::clear ( )

Makes the container empty, with no usable storage space.

See also
resize()

The container needs to be resized before it is useful again.

Definition at line 1458 of file GeometryDataContainers.h.

References geo::GeoIDdataContainer< T, Mapper >::apply(), geo::details::GeoContainerData< T >::apply(), geo::details::GeoContainerData< T >::clear(), geo::GeoIDdataContainer< T, Mapper >::fData, and geo::GeoIDdataContainer< T, Mapper >::fMapper.

1459 {
1460  fMapper.clear();
1461  fData.clear();
1462 } // geo::GeoIDdataContainer<>::clear()
void clear()
Makes the container empty, with no usable storage space.
Mapper_t fMapper
Mapping of IDs to indices.
Container_t fData
Data storage.
template<typename T , typename Mapper >
constexpr unsigned int geo::GeoIDdataContainer< T, Mapper >::dimensions ( )
static

Dimensions of the ID of this container.

Definition at line 1204 of file GeometryDataContainers.h.

1205 {
1206  return Mapper_t::dimensions();
1207 }
template<typename T , typename Mapper >
template<std::size_t Level>
unsigned int geo::GeoIDdataContainer< T, Mapper >::dimSize ( ) const

Dimensions of the Level dimension of this container.

Definition at line 1197 of file GeometryDataContainers.h.

References geo::GeoIDdataContainer< T, Mapper >::mapper().

1198 {
1199  return mapper().template dimSize<Level>();
1200 }
Mapper_t const & mapper() const
Returns the mapper object used to convert ID&#39;s and container positions.
template<typename T , typename Mapper >
bool geo::GeoIDdataContainer< T, Mapper >::empty ( ) const

Returns whether the container has no elements (false by assumptions).

Definition at line 1189 of file GeometryDataContainers.h.

References geo::details::GeoContainerData< T >::empty(), and geo::GeoIDdataContainer< T, Mapper >::fData.

1190 {
1191  return fData.empty();
1192 }
bool empty() const
Returns whether the container has no elements (false by assumptions).
Container_t fData
Data storage.
template<typename T , typename Mapper >
auto geo::GeoIDdataContainer< T, Mapper >::end ( )

Returns an iterator to past the end of the data.

Definition at line 1307 of file GeometryDataContainers.h.

References geo::details::GeoContainerData< T >::begin(), geo::details::GeoContainerData< T >::end(), geo::GeoIDdataContainer< T, Mapper >::fData, and geo::GeoIDdataContainer< T, Mapper >::mapper().

Referenced by geo::GeoIDdataContainer< T, Mapper >::cend(), and geo::GeoIDdataContainer< T, Mapper >::item_end().

1308 {
1309  return {mapper(), fData.begin(), fData.end()};
1310 }
Mapper_t const & mapper() const
Returns the mapper object used to convert ID&#39;s and container positions.
Container_t fData
Data storage.
template<typename T , typename Mapper >
auto geo::GeoIDdataContainer< T, Mapper >::end ( ) const

Returns a constant iterator to past the end of the data.

Definition at line 1321 of file GeometryDataContainers.h.

References geo::details::GeoContainerData< T >::begin(), geo::details::GeoContainerData< T >::end(), geo::GeoIDdataContainer< T, Mapper >::fData, and geo::GeoIDdataContainer< T, Mapper >::mapper().

1322 {
1323  return {mapper(), fData.begin(), fData.end()};
1324 }
Mapper_t const & mapper() const
Returns the mapper object used to convert ID&#39;s and container positions.
Container_t fData
Data storage.
template<typename T , typename Mapper >
void geo::GeoIDdataContainer< T, Mapper >::fill ( value_type  value)

Sets all elements to the specified value (copied).

Definition at line 1398 of file GeometryDataContainers.h.

References geo::GeoIDdataContainer< T, Mapper >::fData, and geo::details::GeoContainerData< T >::fill().

1399 {
1400  fData.fill(value);
1401 }
double value
Definition: spectrum.C:18
Container_t fData
Data storage.
void fill(value_type value)
Sets all elements to the specified value (copied).
template<typename T , typename Mapper >
auto geo::GeoIDdataContainer< T, Mapper >::first ( )

Returns the element for the first ID (unchecked).

Definition at line 1272 of file GeometryDataContainers.h.

References geo::GeoIDdataContainer< T, Mapper >::firstID(), and geo::GeoIDdataContainer< T, Mapper >::operator[]().

1273 {
1274  return operator[](firstID());
1275 }
GeoID firstID() const
Returns the ID of the first element with GeoID type.
reference operator[](ID_t const &id)
Returns the element for the specified geometry element.
template<typename T , typename Mapper >
auto geo::GeoIDdataContainer< T, Mapper >::first ( ) const

Returns the element for the first ID (unchecked).

Definition at line 1279 of file GeometryDataContainers.h.

References geo::GeoIDdataContainer< T, Mapper >::firstID(), and geo::GeoIDdataContainer< T, Mapper >::operator[]().

1280 {
1281  return operator[](firstID());
1282 }
GeoID firstID() const
Returns the ID of the first element with GeoID type.
reference operator[](ID_t const &id)
Returns the element for the specified geometry element.
template<typename T , typename Mapper >
template<typename GeoID >
GeoID geo::GeoIDdataContainer< T, Mapper >::firstID ( ) const

Returns the ID of the first element with GeoID type.

Definition at line 1220 of file GeometryDataContainers.h.

References geo::GeoIDdataContainer< T, Mapper >::mapper().

Referenced by geo::GeoIDdataContainer< T, Mapper >::first().

1221 {
1222  return mapper().template firstID<GeoID>();
1223 }
Mapper_t const & mapper() const
Returns the mapper object used to convert ID&#39;s and container positions.
template<typename T , typename Mapper >
template<typename GeoID >
bool geo::GeoIDdataContainer< T, Mapper >::hasElement ( GeoID const &  id) const

Returns whether this container hosts data for the specified ID.

Definition at line 1212 of file GeometryDataContainers.h.

References geo::GeoIDdataContainer< T, Mapper >::mapper().

Referenced by geo::GeoIDdataContainer< T, Mapper >::at(), readout::TPCsetDataContainer< T >::hasCryostat(), readout::ROPDataContainer< T >::hasCryostat(), readout::ROPDataContainer< T >::hasROP(), readout::TPCsetDataContainer< T >::hasTPCset(), and readout::ROPDataContainer< T >::hasTPCset().

1213 {
1214  return mapper().template hasElement<GeoID>(id);
1215 }
Mapper_t const & mapper() const
Returns the mapper object used to convert ID&#39;s and container positions.
template<typename T , typename Mapper >
auto geo::GeoIDdataContainer< T, Mapper >::ID ( size_type const  index) const
private

Returns the ID corresponding to a internal index in the storage area.

Definition at line 1481 of file GeometryDataContainers.h.

References geo::GeoIDdataContainer< T, Mapper >::index(), and geo::GeoIDdataContainer< T, Mapper >::mapper().

1482 {
1483  return mapper().ID(index);
1484 }
Mapper_t const & mapper() const
Returns the mapper object used to convert ID&#39;s and container positions.
size_type index(ID_t const &id) const
Returns the internal index of the specified ID in the storage area.
template<typename T , typename Mapper >
auto geo::GeoIDdataContainer< T, Mapper >::index ( ID_t const &  id) const
private

Returns the internal index of the specified ID in the storage area.

Definition at line 1474 of file GeometryDataContainers.h.

References geo::GeoIDdataContainer< T, Mapper >::mapper().

Referenced by geo::GeoIDdataContainer< T, Mapper >::ID().

1475 {
1476  return mapper().index(id);
1477 }
Mapper_t const & mapper() const
Returns the mapper object used to convert ID&#39;s and container positions.
template<typename T , typename Mapper >
auto geo::GeoIDdataContainer< T, Mapper >::item_begin ( )

Returns an item iterator to the beginning of the data.

Definition at line 1342 of file GeometryDataContainers.h.

References geo::GeoIDdataContainer< T, Mapper >::begin().

Referenced by geo::GeoIDdataContainer< T, Mapper >::item_cbegin(), and geo::GeoIDdataContainer< T, Mapper >::items().

1343 {
1344  return {begin()};
1345 }
iterator begin()
Returns an iterator to the beginning of the data.
template<typename T , typename Mapper >
auto geo::GeoIDdataContainer< T, Mapper >::item_begin ( ) const

Returns a item constant iterator to the beginning of the data.

Definition at line 1356 of file GeometryDataContainers.h.

References geo::GeoIDdataContainer< T, Mapper >::begin().

1357 {
1358  return {begin()};
1359 }
iterator begin()
Returns an iterator to the beginning of the data.
template<typename T , typename Mapper >
auto geo::GeoIDdataContainer< T, Mapper >::item_cbegin ( ) const

Returns a item constant iterator to the beginning of the data.

Definition at line 1370 of file GeometryDataContainers.h.

References geo::GeoIDdataContainer< T, Mapper >::item_begin().

1371 {
1372  return item_begin();
1373 }
item_iterator item_begin()
Returns an item iterator to the beginning of the data.
template<typename T , typename Mapper >
auto geo::GeoIDdataContainer< T, Mapper >::item_cend ( ) const

Returns a item constant iterator to past the end of the data.

Definition at line 1377 of file GeometryDataContainers.h.

References geo::GeoIDdataContainer< T, Mapper >::item_end().

1378 {
1379  return item_end();
1380 }
item_iterator item_end()
Returns an item iterator to past the end of the data.
template<typename T , typename Mapper >
auto geo::GeoIDdataContainer< T, Mapper >::item_end ( )

Returns an item iterator to past the end of the data.

Definition at line 1349 of file GeometryDataContainers.h.

References geo::GeoIDdataContainer< T, Mapper >::end().

Referenced by geo::GeoIDdataContainer< T, Mapper >::item_cend(), and geo::GeoIDdataContainer< T, Mapper >::items().

1350 {
1351  return {end()};
1352 }
iterator end()
Returns an iterator to past the end of the data.
template<typename T , typename Mapper >
auto geo::GeoIDdataContainer< T, Mapper >::item_end ( ) const

Returns a item constant iterator to past the end of the data.

Definition at line 1363 of file GeometryDataContainers.h.

References geo::GeoIDdataContainer< T, Mapper >::end().

1364 {
1365  return {end()};
1366 }
iterator end()
Returns an iterator to past the end of the data.
template<typename T , typename Mapper >
auto geo::GeoIDdataContainer< T, Mapper >::items ( )

Returns an object suitable for a range-for loop with item_iterator.

Definition at line 1384 of file GeometryDataContainers.h.

References geo::GeoIDdataContainer< T, Mapper >::item_begin(), and geo::GeoIDdataContainer< T, Mapper >::item_end().

1385 {
1386  return util::span{item_begin(), item_end()};
1387 }
Simple class with a begin and an end.
Definition: span.h:129
item_iterator item_begin()
Returns an item iterator to the beginning of the data.
item_iterator item_end()
Returns an item iterator to past the end of the data.
template<typename T , typename Mapper >
auto geo::GeoIDdataContainer< T, Mapper >::items ( ) const

Returns an object suitable for a range-for loop with item_const_iterator.

Definition at line 1391 of file GeometryDataContainers.h.

References geo::GeoIDdataContainer< T, Mapper >::item_begin(), and geo::GeoIDdataContainer< T, Mapper >::item_end().

1392 {
1393  return util::span{item_begin(), item_end()};
1394 }
Simple class with a begin and an end.
Definition: span.h:129
item_iterator item_begin()
Returns an item iterator to the beginning of the data.
item_iterator item_end()
Returns an item iterator to past the end of the data.
template<typename T , typename Mapper >
auto geo::GeoIDdataContainer< T, Mapper >::last ( )

Returns the element for the last ID (unchecked).

Definition at line 1286 of file GeometryDataContainers.h.

References geo::GeoIDdataContainer< T, Mapper >::lastID(), and geo::GeoIDdataContainer< T, Mapper >::operator[]().

1287 {
1288  return operator[](lastID());
1289 }
GeoID lastID() const
Returns the ID of the last covered element with GeoID type.
reference operator[](ID_t const &id)
Returns the element for the specified geometry element.
template<typename T , typename Mapper >
auto geo::GeoIDdataContainer< T, Mapper >::last ( ) const

Returns the element for the last ID (unchecked).

Definition at line 1293 of file GeometryDataContainers.h.

References geo::GeoIDdataContainer< T, Mapper >::lastID(), and geo::GeoIDdataContainer< T, Mapper >::operator[]().

1294 {
1295  return operator[](lastID());
1296 }
GeoID lastID() const
Returns the ID of the last covered element with GeoID type.
reference operator[](ID_t const &id)
Returns the element for the specified geometry element.
template<typename T , typename Mapper >
template<typename GeoID >
GeoID geo::GeoIDdataContainer< T, Mapper >::lastID ( ) const

Returns the ID of the last covered element with GeoID type.

Definition at line 1228 of file GeometryDataContainers.h.

References geo::GeoIDdataContainer< T, Mapper >::mapper().

Referenced by geo::GeoIDdataContainer< T, Mapper >::last().

1229 {
1230  return mapper().template lastID<GeoID>();
1231 }
Mapper_t const & mapper() const
Returns the mapper object used to convert ID&#39;s and container positions.
template<typename T , typename Mapper >
auto geo::GeoIDdataContainer< T, Mapper >::operator[] ( ID_t const &  id)

Returns the element for the specified geometry element.

Definition at line 1242 of file GeometryDataContainers.h.

References geo::GeoIDdataContainer< T, Mapper >::fData, and geo::GeoIDdataContainer< T, Mapper >::mapper().

Referenced by geo::GeoIDdataContainer< T, Mapper >::at(), geo::GeoIDdataContainer< T, Mapper >::first(), and geo::GeoIDdataContainer< T, Mapper >::last().

1243 {
1244  return fData[mapper().index(id)];
1245 }
Mapper_t const & mapper() const
Returns the mapper object used to convert ID&#39;s and container positions.
Container_t fData
Data storage.
template<typename T , typename Mapper >
auto geo::GeoIDdataContainer< T, Mapper >::operator[] ( ID_t const &  id) const

Returns the element for the specified geometry element (read-only).

Definition at line 1249 of file GeometryDataContainers.h.

References geo::GeoIDdataContainer< T, Mapper >::fData, and geo::GeoIDdataContainer< T, Mapper >::mapper().

1250 {
1251  return fData[mapper().index(id)];
1252 }
Mapper_t const & mapper() const
Returns the mapper object used to convert ID&#39;s and container positions.
Container_t fData
Data storage.
template<typename T , typename Mapper >
void geo::GeoIDdataContainer< T, Mapper >::reset ( )

Sets all the elements to a default-constructed value_type.

Definition at line 1405 of file GeometryDataContainers.h.

References geo::GeoIDdataContainer< T, Mapper >::fData, and geo::details::GeoContainerData< T >::reset().

1406 {
1407  fData.reset();
1408 }
void reset()
Sets all the elements to a default-constructed value_type.
Container_t fData
Data storage.
template<typename T , typename Mapper >
void geo::GeoIDdataContainer< T, Mapper >::resize ( std::initializer_list< unsigned int >  dims)

Prepares the container with default-constructed data.

Parameters
dimsnumber of elements on all levels of the container
See also
clear(), fill()

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 1420 of file GeometryDataContainers.h.

References geo::GeoIDdataContainer< T, Mapper >::fData, geo::GeoIDdataContainer< T, Mapper >::fMapper, geo::GeoIDdataContainer< T, Mapper >::mapper(), geo::details::GeoContainerData< T >::resize(), and geo::GeoIDdataContainer< T, Mapper >::size().

Referenced by readout::TPCsetDataContainer< T >::resize(), and readout::ROPDataContainer< T >::resize().

1421 {
1422  fMapper.resize(dims);
1423  fData.resize(mapper().size());
1424 } // geo::GeoIDdataContainer<T, Mapper>::resize()
Mapper_t const & mapper() const
Returns the mapper object used to convert ID&#39;s and container positions.
void resize(size_type size)
Prepares the container with default-constructed data.
size_type size() const
Returns the number of elements in the container.
Mapper_t fMapper
Mapping of IDs to indices.
Container_t fData
Data storage.
template<typename T , typename Mapper >
void geo::GeoIDdataContainer< T, Mapper >::resize ( std::initializer_list< unsigned int >  dims,
value_type const &  defValue 
)

Prepares the container initializing all its data.

Parameters
dimsnumber of elements on all levels of the container
defValuethe value copied to fill all entries in the container
See also
clear(), fill()

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 1428 of file GeometryDataContainers.h.

References geo::GeoIDdataContainer< T, Mapper >::fData, geo::GeoIDdataContainer< T, Mapper >::fMapper, geo::GeoIDdataContainer< T, Mapper >::mapper(), geo::details::GeoContainerData< T >::resize(), and geo::GeoIDdataContainer< T, Mapper >::size().

1430 {
1431  fMapper.resize(dims);
1432  fData.resize(mapper().size(), defValue);
1433 } // geo::GeoIDdataContainer<T, Mapper>::resize(value_type)
Mapper_t const & mapper() const
Returns the mapper object used to convert ID&#39;s and container positions.
void resize(size_type size)
Prepares the container with default-constructed data.
size_type size() const
Returns the number of elements in the container.
Mapper_t fMapper
Mapping of IDs to indices.
Container_t fData
Data storage.
template<typename T , typename Mapper >
template<typename OT >
void geo::GeoIDdataContainer< T, Mapper >::resizeAs ( geo::GeoIDdataContainer< OT, Mapper_t > const &  other)

Prepares the container with default-constructed data.

Parameters
otherdata 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 1438 of file GeometryDataContainers.h.

References geo::GeoIDdataContainer< T, Mapper >::fData, geo::GeoIDdataContainer< T, Mapper >::fMapper, geo::GeoIDdataContainer< T, Mapper >::mapper(), geo::details::GeoContainerData< T >::resize(), and geo::GeoIDdataContainer< T, Mapper >::size().

1440 {
1441  fMapper.resizeAs(other.mapper());
1442  fData.resize(mapper().size());
1443 } // geo::GeoIDdataContainer<T, Mapper>::resizeAs()
Mapper_t const & mapper() const
Returns the mapper object used to convert ID&#39;s and container positions.
void resize(size_type size)
Prepares the container with default-constructed data.
size_type size() const
Returns the number of elements in the container.
Mapper_t fMapper
Mapping of IDs to indices.
Container_t fData
Data storage.
template<typename T , typename Mapper >
template<typename OT >
void geo::GeoIDdataContainer< T, Mapper >::resizeAs ( geo::GeoIDdataContainer< OT, Mapper_t > const &  other,
value_type const &  defValue 
)

Prepares the container initializing all its data.

Parameters
otherdata collection to take dimensions from
defValuethe 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 1448 of file GeometryDataContainers.h.

References geo::GeoIDdataContainer< T, Mapper >::fData, geo::GeoIDdataContainer< T, Mapper >::fMapper, geo::GeoIDdataContainer< T, Mapper >::mapper(), geo::details::GeoContainerData< T >::resize(), and geo::GeoIDdataContainer< T, Mapper >::size().

1451 {
1452  fMapper.resizeAs(other.mapper());
1453  fData.resize(mapper().size(), defValue);
1454 } // geo::GeoIDdataContainer<T, Mapper>::resizeAs(value_type)
Mapper_t const & mapper() const
Returns the mapper object used to convert ID&#39;s and container positions.
void resize(size_type size)
Prepares the container with default-constructed data.
size_type size() const
Returns the number of elements in the container.
Mapper_t fMapper
Mapping of IDs to indices.
Container_t fData
Data storage.
template<typename T , typename Mapper >
auto geo::GeoIDdataContainer< T, Mapper >::size ( ) const

Returns the number of elements in the container.

Definition at line 1175 of file GeometryDataContainers.h.

References geo::GeoIDdataContainer< T, Mapper >::fData, and geo::details::GeoContainerData< T >::size().

Referenced by geo::GeoIDdataContainer< T, Mapper >::resize(), and geo::GeoIDdataContainer< T, Mapper >::resizeAs().

1176 {
1177  return fData.size();
1178 }
size_type size() const
Returns the number of elements in the container.
Container_t fData
Data storage.

Member Data Documentation


The documentation for this class was generated from the following file: