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

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

#include "GeometryDataContainers.h"

Inheritance diagram for geo::TPCDataContainer< T >:
geo::GeoIDdataContainer< T, geo::TPCIDmapper<> >

Public Types

using value_type = typename BaseContainer_t::value_type
 
using Mapper_t = geo::TPCIDmapper<>
 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 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

 TPCDataContainer ()=default
 Default constructor: empty container. More...
 
 TPCDataContainer (unsigned int nCryo, unsigned int nTPCs)
 Prepares the container with default-constructed data. More...
 
 TPCDataContainer (unsigned int nCryo, unsigned int nTPCs, value_type const &defValue)
 Prepares the container with copies of the specified default value. More...
 
Container modification
void resize (unsigned int nCryo, unsigned int nTPCs)
 Prepares the container with default-constructed data. More...
 
void resize (unsigned int nCryo, unsigned int nTPCs, T const &defValue)
 Prepares the container initializing all its data. More...
 
Container status query
bool hasCryostat (geo::CryostatID const &cryoid) const
 Returns whether this container hosts data for the specified cryostat. More...
 
bool hasTPC (geo::TPCID const &tpcid) const
 Returns whether this container hosts data for the specified TPC. 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...
 
const_iterator begin () const
 Returns a constant iterator to the beginning of the data. More...
 
iterator end ()
 Returns an iterator to past the end 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_const_iterator item_begin () const
 Returns a item constant 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_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...
 
Op apply (Op &&op)
 Applies an operation on all elements. More...
 
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...
 
void resizeAs (geo::GeoIDdataContainer< OT, Mapper_t > const &other)
 Prepares the container with default-constructed data. More...
 
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 BaseContainer_t = geo::GeoIDdataContainer< T, geo::TPCIDmapper<>>
 

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...
 
unsigned int dimSize () const
 Dimensions of the Level dimension of this container. More...
 
bool hasElement (GeoID const &id) const
 Returns whether this container hosts data for the specified ID. More...
 
GeoID firstID () const
 Returns the ID of the first element with GeoID type. More...
 
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>
class geo::TPCDataContainer< T >

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

Member Typedef Documentation

template<typename T >
using geo::TPCDataContainer< T >::BaseContainer_t = geo::GeoIDdataContainer<T, geo::TPCIDmapper<>>
private

Definition at line 529 of file GeometryDataContainers.h.

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

Definition at line 138 of file GeometryDataContainers.h.

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

Definition at line 136 of file GeometryDataContainers.h.

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

Definition at line 134 of file GeometryDataContainers.h.

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

Definition at line 141 of file GeometryDataContainers.h.

using geo::GeoIDdataContainer< T, geo::TPCIDmapper<> >::ID_t = typename Mapper_t::ID_t
inherited

Type used as ID for this container.

Definition at line 127 of file GeometryDataContainers.h.

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

Definition at line 148 of file GeometryDataContainers.h.

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

Definition at line 145 of file GeometryDataContainers.h.

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

Definition at line 137 of file GeometryDataContainers.h.

Type of mapper between IDs and index.

Definition at line 125 of file GeometryDataContainers.h.

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

Definition at line 135 of file GeometryDataContainers.h.

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

Definition at line 133 of file GeometryDataContainers.h.

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

Definition at line 142 of file GeometryDataContainers.h.

template<typename T >
using geo::TPCDataContainer< T >::value_type = typename BaseContainer_t::value_type

Definition at line 532 of file GeometryDataContainers.h.

Constructor & Destructor Documentation

template<typename T >
geo::TPCDataContainer< T >::TPCDataContainer ( )
default

Default constructor: empty container.

See also
resize()

The container starts with no room for any data. The only guarantee is that empty() is true and size() is 0. Use resize() before anything else.

template<typename T >
geo::TPCDataContainer< T >::TPCDataContainer ( unsigned int  nCryo,
unsigned int  nTPCs 
)
inline

Prepares the container with default-constructed data.

Parameters
nCryonumber of cryostats
nTPCsnumber of TPCs

The container is sized to host data for nCryo cryostats, each with nTPCs TPCs. Each element in the container is default-constructed.

Definition at line 552 of file GeometryDataContainers.h.

552 : BaseContainer_t({nCryo, nTPCs}) {}
geo::GeoIDdataContainer< T, geo::TPCIDmapper<>> BaseContainer_t
template<typename T >
geo::TPCDataContainer< T >::TPCDataContainer ( unsigned int  nCryo,
unsigned int  nTPCs,
value_type const &  defValue 
)
inline

Prepares the container with copies of the specified default value.

Parameters
nCryonumber of cryostats
nTPCsnumber of TPCs
defValuethe value to be replicated

The container is sized to host data for nCryo cryostats, each with nTPCs TPCs. Each element in the container is a copy of defValue.

auto const* geom = lar::providerFrom<geo::GeometryCore>();
(geom->NCryostats(), geom->MaxTPCs(), 3U);
for (geo::TPCGeo const& TPC: geom->IterateTPC())
assert(PlanesPerTPC[TPC.ID()] == TPC.Nplanes());

Definition at line 570 of file GeometryDataContainers.h.

571  : BaseContainer_t({nCryo, nTPCs}, defValue)
572  {}
geo::GeoIDdataContainer< T, geo::TPCIDmapper<>> BaseContainer_t

Member Function Documentation

Op geo::GeoIDdataContainer< T, geo::TPCIDmapper<> >::apply ( Op &&  op)
inherited

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.

decltype(auto) geo::GeoIDdataContainer< T, geo::TPCIDmapper<> >::apply ( Op &&  op) const
inherited

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.

reference geo::GeoIDdataContainer< T, geo::TPCIDmapper<> >::at ( ID_t const &  id)
inherited

Returns the element for the specified geometry element.

Exceptions
std::out_of_rangeif element id is not within the container range
const_reference geo::GeoIDdataContainer< T, geo::TPCIDmapper<> >::at ( ID_t const &  id) const
inherited

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

Exceptions
std::out_of_rangeif element id is not within the container range
iterator geo::GeoIDdataContainer< T, geo::TPCIDmapper<> >::begin ( )
inherited

Returns an iterator to the beginning of the data.

const_iterator geo::GeoIDdataContainer< T, geo::TPCIDmapper<> >::begin ( ) const
inherited

Returns a constant iterator to the beginning of the data.

size_type geo::GeoIDdataContainer< T, geo::TPCIDmapper<> >::capacity ( ) const
inherited

Returns the number of elements the container has memory for.

const_iterator geo::GeoIDdataContainer< T, geo::TPCIDmapper<> >::cbegin ( ) const
inherited

Returns a constant iterator to the beginning of the data.

const_iterator geo::GeoIDdataContainer< T, geo::TPCIDmapper<> >::cend ( ) const
inherited

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

void geo::GeoIDdataContainer< T, geo::TPCIDmapper<> >::clear ( )
inherited

Makes the container empty, with no usable storage space.

See also
resize()

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

static constexpr unsigned int geo::GeoIDdataContainer< T, geo::TPCIDmapper<> >::dimensions ( )
staticinherited

Dimensions of the ID of this container.

unsigned int geo::GeoIDdataContainer< T, geo::TPCIDmapper<> >::dimSize ( ) const
inherited

Dimensions of the Level dimension of this container.

bool geo::GeoIDdataContainer< T, geo::TPCIDmapper<> >::empty ( ) const
inherited

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

iterator geo::GeoIDdataContainer< T, geo::TPCIDmapper<> >::end ( void  )
inherited

Returns an iterator to past the end of the data.

const_iterator geo::GeoIDdataContainer< T, geo::TPCIDmapper<> >::end ( void  ) const
inherited

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

void geo::GeoIDdataContainer< T, geo::TPCIDmapper<> >::fill ( value_type  value)
inherited

Sets all elements to the specified value (copied).

reference geo::GeoIDdataContainer< T, geo::TPCIDmapper<> >::first ( )
inherited

Returns the element for the first ID (unchecked).

const_reference geo::GeoIDdataContainer< T, geo::TPCIDmapper<> >::first ( ) const
inherited

Returns the element for the first ID (unchecked).

GeoID geo::GeoIDdataContainer< T, geo::TPCIDmapper<> >::firstID ( ) const
inherited

Returns the ID of the first element with GeoID type.

template<typename T >
bool geo::TPCDataContainer< T >::hasCryostat ( geo::CryostatID const &  cryoid) const
inline

Returns whether this container hosts data for the specified cryostat.

Definition at line 623 of file GeometryDataContainers.h.

624  {
625  return BaseContainer_t::hasElement(cryoid);
626  }
bool hasElement(GeoID const &id) const
Returns whether this container hosts data for the specified ID.
bool geo::GeoIDdataContainer< T, geo::TPCIDmapper<> >::hasElement ( GeoID const &  id) const
inherited

Returns whether this container hosts data for the specified ID.

template<typename T >
bool geo::TPCDataContainer< T >::hasTPC ( geo::TPCID const &  tpcid) const
inline

Returns whether this container hosts data for the specified TPC.

Definition at line 629 of file GeometryDataContainers.h.

629 { return BaseContainer_t::hasElement(tpcid); }
bool hasElement(GeoID const &id) const
Returns whether this container hosts data for the specified ID.
item_iterator geo::GeoIDdataContainer< T, geo::TPCIDmapper<> >::item_begin ( )
inherited

Returns an item iterator to the beginning of the data.

item_const_iterator geo::GeoIDdataContainer< T, geo::TPCIDmapper<> >::item_begin ( ) const
inherited

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

item_const_iterator geo::GeoIDdataContainer< T, geo::TPCIDmapper<> >::item_cbegin ( ) const
inherited

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

item_const_iterator geo::GeoIDdataContainer< T, geo::TPCIDmapper<> >::item_cend ( ) const
inherited

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

item_iterator geo::GeoIDdataContainer< T, geo::TPCIDmapper<> >::item_end ( )
inherited

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

item_const_iterator geo::GeoIDdataContainer< T, geo::TPCIDmapper<> >::item_end ( ) const
inherited

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

auto geo::GeoIDdataContainer< T, geo::TPCIDmapper<> >::items ( )
inherited

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

auto geo::GeoIDdataContainer< T, geo::TPCIDmapper<> >::items ( ) const
inherited

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

reference geo::GeoIDdataContainer< T, geo::TPCIDmapper<> >::last ( )
inherited

Returns the element for the last ID (unchecked).

const_reference geo::GeoIDdataContainer< T, geo::TPCIDmapper<> >::last ( ) const
inherited

Returns the element for the last ID (unchecked).

GeoID geo::GeoIDdataContainer< T, geo::TPCIDmapper<> >::lastID ( ) const
inherited

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

Mapper_t const& geo::GeoIDdataContainer< T, geo::TPCIDmapper<> >::mapper ( ) const
inherited

Returns the mapper object used to convert ID's and container positions.

reference geo::GeoIDdataContainer< T, geo::TPCIDmapper<> >::operator[] ( ID_t const &  id)
inherited

Returns the element for the specified geometry element.

const_reference geo::GeoIDdataContainer< T, geo::TPCIDmapper<> >::operator[] ( ID_t const &  id) const
inherited

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

void geo::GeoIDdataContainer< T, geo::TPCIDmapper<> >::reset ( )
inherited

Sets all the elements to a default-constructed value_type.

void geo::GeoIDdataContainer< T, geo::TPCIDmapper<> >::resize ( std::initializer_list< unsigned int >  dims)
inherited

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.

void geo::GeoIDdataContainer< T, geo::TPCIDmapper<> >::resize ( std::initializer_list< unsigned int >  dims,
value_type const &  defValue 
)
inherited

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.

template<typename T >
void geo::TPCDataContainer< T >::resize ( unsigned int  nCryo,
unsigned int  nTPCs 
)
inline

Prepares the container with default-constructed data.

Parameters
nCryonumber of cryostats
nTPCsnumber of TPCs
See also
clear(), fill()

The container is sized to host data for nCryo cryostats, each with nTPCs TPCs. Each 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 590 of file GeometryDataContainers.h.

590 { BaseContainer_t::resize({nCryo, nTPCs}); }
void resize(std::initializer_list< unsigned int > dims)
Prepares the container with default-constructed data.
template<typename T >
void geo::TPCDataContainer< T >::resize ( unsigned int  nCryo,
unsigned int  nTPCs,
T const &  defValue 
)
inline

Prepares the container initializing all its data.

Parameters
nCryonumber of cryostats
nTPCsnumber of TPCs
defValuethe value copied to fill all entries in the container
See also
clear(), fill()

The container is sized to host data for nCryo cryostats, each with nTPCs TPCs. Each element in the container is a copy of defValue.

auto const* geom = lar::providerFrom<geo::GeometryCore>();
countPerPlane.resize(geom->NCryostats(), geom->MaxTPCs(), 0U);

Existing data is not touched, but it may be rearranged in a non-straightforward way.

Definition at line 610 of file GeometryDataContainers.h.

611  {
612  BaseContainer_t::resize({nCryo, nTPCs}, defValue);
613  }
void resize(std::initializer_list< unsigned int > dims)
Prepares the container with default-constructed data.
void geo::GeoIDdataContainer< T, geo::TPCIDmapper<> >::resizeAs ( geo::GeoIDdataContainer< OT, Mapper_t > const &  other)
inherited

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.

void geo::GeoIDdataContainer< T, geo::TPCIDmapper<> >::resizeAs ( geo::GeoIDdataContainer< OT, Mapper_t > const &  other,
value_type const &  defValue 
)
inherited

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.

size_type geo::GeoIDdataContainer< T, geo::TPCIDmapper<> >::size ( void  ) const
inherited

Returns the number of elements in the container.


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