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

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

#include "GeometryDataContainers.h"

Public Types

STL container types.
using reference = typename Container_t::reference
 
using const_reference = typename Container_t::const_reference
 
using pointer = typename Container_t::pointer
 
using const_pointer = typename Container_t::const_pointer
 
using iterator = typename Container_t::iterator
 
using const_iterator = typename Container_t::const_iterator
 
using reverse_iterator = typename Container_t::reverse_iterator
 
using const_reverse_iterator = typename Container_t::const_reverse_iterator
 
using difference_type = typename Container_t::difference_type
 
using size_type = typename Container_t::size_type
 

Public Member Functions

 TPCDataContainer (unsigned int nCryo, unsigned int nTPCs)
 Prepares the container with default-constructed data. More...
 
 TPCDataContainer (unsigned int nCryo, unsigned int nTPCs, T const &defValue)
 Prepares the container with copies of the specified default value. 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...
 
bool hasCryostat (geo::CryostatID const &cryoid) const
 Returns whether this container hosts data for the specified cryostat. More...
 
bool hasTPC (geo::TPCID const &id) const
 Returns whether this container hosts data for the specified TPC. More...
 
geo::TPCID firstID () const
 Returns the ID of the first TPC. More...
 
geo::TPCID lastID () const
 Returns the ID of the last covered TPC. More...
 
Element access
reference operator[] (geo::TPCID const &id)
 Returns the element for the specified TPC. More...
 
const_reference operator[] (geo::TPCID const &id) const
 Returns the element for the specified TPC (read-only). More...
 
reference at (geo::TPCID const &id)
 
const_reference at (geo::TPCID const &id) const
 
reference first ()
 Returns the element for the first TPC (unchecked). More...
 
const_reference first () const
 Returns the element for the first TPC (unchecked). More...
 
reference last ()
 Returns the element for the last TPC (unchecked). More...
 
const_reference last () const
 Returns the element for the last TPC (unchecked). More...
 

Private Types

using Container_t = std::vector< T >
 
using CryostatNo_t = geo::CryostatID::CryostatID_t
 
using TPCNo_t = geo::TPCID::TPCID_t
 

Private Member Functions

size_type index (CryostatNo_t cryo, TPCNo_t tpc) const
 Returns the internal index of the specified TPC in the storage area. More...
 
size_type index (geo::TPCID const &id) const
 Returns the internal index of the specified TPC in the storage area. More...
 
geo::TPCID ID (size_type index) const
 Returns the ID of the TPC at the specified index (unchecked!) More...
 
size_type computeSize () const
 Computes the expected size of this container. More...
 

Static Private Member Functions

static size_type computeSize (CryostatNo_t nCryo, TPCNo_t nTPCs)
 Returns the size of a container with the specified 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

CryostatNo_t fNCryo
 Number of cryostats. More...
 
TPCNo_t fNTPCs
 Number of TPCs. More...
 
Container_t fData
 Data storage area. 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 65 of file GeometryDataContainers.h.

Member Typedef Documentation

template<typename T >
using geo::TPCDataContainer< T >::const_iterator = typename Container_t::const_iterator

Definition at line 81 of file GeometryDataContainers.h.

template<typename T >
using geo::TPCDataContainer< T >::const_pointer = typename Container_t::const_pointer

Definition at line 79 of file GeometryDataContainers.h.

template<typename T >
using geo::TPCDataContainer< T >::const_reference = typename Container_t::const_reference

Definition at line 77 of file GeometryDataContainers.h.

template<typename T >
using geo::TPCDataContainer< T >::const_reverse_iterator = typename Container_t::const_reverse_iterator

Definition at line 83 of file GeometryDataContainers.h.

template<typename T >
using geo::TPCDataContainer< T >::Container_t = std::vector<T>
private

Definition at line 67 of file GeometryDataContainers.h.

template<typename T >
using geo::TPCDataContainer< T >::CryostatNo_t = geo::CryostatID::CryostatID_t
private

Definition at line 203 of file GeometryDataContainers.h.

template<typename T >
using geo::TPCDataContainer< T >::difference_type = typename Container_t::difference_type

Definition at line 84 of file GeometryDataContainers.h.

template<typename T >
using geo::TPCDataContainer< T >::iterator = typename Container_t::iterator

Definition at line 80 of file GeometryDataContainers.h.

template<typename T >
using geo::TPCDataContainer< T >::pointer = typename Container_t::pointer

Definition at line 78 of file GeometryDataContainers.h.

template<typename T >
using geo::TPCDataContainer< T >::reference = typename Container_t::reference

Definition at line 76 of file GeometryDataContainers.h.

template<typename T >
using geo::TPCDataContainer< T >::reverse_iterator = typename Container_t::reverse_iterator

Definition at line 82 of file GeometryDataContainers.h.

template<typename T >
using geo::TPCDataContainer< T >::size_type = typename Container_t::size_type

Definition at line 85 of file GeometryDataContainers.h.

template<typename T >
using geo::TPCDataContainer< T >::TPCNo_t = geo::TPCID::TPCID_t
private

Definition at line 204 of file GeometryDataContainers.h.

Constructor & Destructor Documentation

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

References geo::TPCDataContainer< T >::empty().

98  : fNCryo(nCryo)
99  , fNTPCs(nTPCs)
100  , fData(computeSize())
101  { assert(!empty()); }
bool empty() const
Returns whether the container has no elements (false by assumptions).
TPCNo_t fNTPCs
Number of TPCs.
CryostatNo_t fNCryo
Number of cryostats.
size_type computeSize() const
Computes the expected size of this container.
Container_t fData
Data storage area.
template<typename T >
geo::TPCDataContainer< T >::TPCDataContainer ( unsigned int  nCryo,
unsigned int  nTPCs,
T 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 119 of file GeometryDataContainers.h.

References geo::TPCDataContainer< T >::empty().

120  : fNCryo(nCryo)
121  , fNTPCs(nTPCs)
122  , fData(computeSize(), defValue)
123  { assert(!empty()); }
bool empty() const
Returns whether the container has no elements (false by assumptions).
TPCNo_t fNTPCs
Number of TPCs.
CryostatNo_t fNCryo
Number of cryostats.
size_type computeSize() const
Computes the expected size of this container.
Container_t fData
Data storage area.

Member Function Documentation

template<typename T >
reference geo::TPCDataContainer< T >::at ( geo::TPCID const &  id)
inline

Returns the element for the specified TPC.

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

Definition at line 171 of file GeometryDataContainers.h.

References geo::TPCDataContainer< T >::hasTPC(), and geo::TPCDataContainer< T >::operator[]().

172  {
173  if (hasTPC(id)) return operator[](id);
174  throw std::out_of_range("No data for " + std::string(id));
175  }
reference operator[](geo::TPCID const &id)
Returns the element for the specified TPC.
bool hasTPC(geo::TPCID const &id) const
Returns whether this container hosts data for the specified TPC.
template<typename T >
const_reference geo::TPCDataContainer< T >::at ( geo::TPCID const &  id) const
inline

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

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

Definition at line 179 of file GeometryDataContainers.h.

References geo::TPCDataContainer< T >::hasTPC(), and geo::TPCDataContainer< T >::operator[]().

180  {
181  if (hasTPC(id)) return operator[](id);
182  throw std::out_of_range("No data for " + std::string(id));
183  }
reference operator[](geo::TPCID const &id)
Returns the element for the specified TPC.
bool hasTPC(geo::TPCID const &id) const
Returns whether this container hosts data for the specified TPC.
template<typename T >
template<typename Value , typename Upper >
static bool geo::TPCDataContainer< T >::bounded ( Value  v,
Upper  upper 
)
inlinestaticprivate

Returns whether the specified value is between 0 and the upper limit.

Definition at line 232 of file GeometryDataContainers.h.

Referenced by geo::TPCDataContainer< T >::hasCryostat(), geo::PlaneDataContainer< T >::hasCryostat(), geo::PlaneDataContainer< T >::hasPlane(), geo::TPCDataContainer< T >::hasTPC(), and geo::PlaneDataContainer< T >::hasTPC().

233  { return (v >= 0) && (static_cast<size_type>(v) < upper); }
typename Container_t::size_type size_type
template<typename T >
size_type geo::TPCDataContainer< T >::capacity ( ) const
inline

Returns the number of elements the container has memory for.

Definition at line 134 of file GeometryDataContainers.h.

References geo::TPCDataContainer< T >::fData.

134 { return fData.capacity(); }
Container_t fData
Data storage area.
template<typename T >
size_type geo::TPCDataContainer< T >::computeSize ( ) const
inlineprivate

Computes the expected size of this container.

Definition at line 224 of file GeometryDataContainers.h.

References geo::TPCDataContainer< T >::computeSize().

Referenced by geo::TPCDataContainer< T >::computeSize(), and geo::PlaneDataContainer< T >::computeSize().

224 { return computeSize(fNCryo, fNTPCs); }
TPCNo_t fNTPCs
Number of TPCs.
CryostatNo_t fNCryo
Number of cryostats.
size_type computeSize() const
Computes the expected size of this container.
template<typename T >
static size_type geo::TPCDataContainer< T >::computeSize ( CryostatNo_t  nCryo,
TPCNo_t  nTPCs 
)
inlinestaticprivate

Returns the size of a container with the specified dimensions.

Definition at line 227 of file GeometryDataContainers.h.

228  { return nCryo * nTPCs; }
template<typename T >
bool geo::TPCDataContainer< T >::empty ( ) const
inline

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

Definition at line 137 of file GeometryDataContainers.h.

References geo::TPCDataContainer< T >::fData.

Referenced by geo::PlaneDataContainer< T >::PlaneDataContainer(), and geo::TPCDataContainer< T >::TPCDataContainer().

137 { return fData.empty(); }
Container_t fData
Data storage area.
template<typename T >
reference geo::TPCDataContainer< T >::first ( )
inline

Returns the element for the first TPC (unchecked).

Definition at line 187 of file GeometryDataContainers.h.

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

187 { return operator[](firstID()); }
reference operator[](geo::TPCID const &id)
Returns the element for the specified TPC.
geo::TPCID firstID() const
Returns the ID of the first TPC.
template<typename T >
const_reference geo::TPCDataContainer< T >::first ( ) const
inline

Returns the element for the first TPC (unchecked).

Definition at line 190 of file GeometryDataContainers.h.

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

190 { return operator[](firstID()); }
reference operator[](geo::TPCID const &id)
Returns the element for the specified TPC.
geo::TPCID firstID() const
Returns the ID of the first TPC.
template<typename T >
geo::TPCID geo::TPCDataContainer< T >::firstID ( ) const
inline

Returns the ID of the first TPC.

Definition at line 148 of file GeometryDataContainers.h.

Referenced by geo::TPCDataContainer< T >::first(), and geo::PlaneDataContainer< T >::first().

148 { return { 0U, 0U }; }
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 140 of file GeometryDataContainers.h.

References geo::TPCDataContainer< T >::bounded(), geo::CryostatID::Cryostat, and geo::TPCDataContainer< T >::fNCryo.

Referenced by geo::TPCDataContainer< T >::hasTPC(), and geo::PlaneDataContainer< T >::hasTPC().

141  { return bounded(cryoid.Cryostat, fNCryo); }
CryostatNo_t fNCryo
Number of cryostats.
static bool bounded(Value v, Upper upper)
Returns whether the specified value is between 0 and the upper limit.
template<typename T >
bool geo::TPCDataContainer< T >::hasTPC ( geo::TPCID const &  id) const
inline

Returns whether this container hosts data for the specified TPC.

Definition at line 144 of file GeometryDataContainers.h.

References geo::TPCDataContainer< T >::bounded(), geo::TPCDataContainer< T >::fNTPCs, and geo::TPCDataContainer< T >::hasCryostat().

Referenced by geo::TPCDataContainer< T >::at(), and geo::PlaneDataContainer< T >::hasPlane().

145  { return hasCryostat(id) && bounded(id.TPC, fNTPCs); }
bool hasCryostat(geo::CryostatID const &cryoid) const
Returns whether this container hosts data for the specified cryostat.
TPCNo_t fNTPCs
Number of TPCs.
static bool bounded(Value v, Upper upper)
Returns whether the specified value is between 0 and the upper limit.
template<typename T >
geo::TPCID geo::TPCDataContainer< T >::ID ( size_type  index) const
inlineprivate

Returns the ID of the TPC at the specified index (unchecked!)

Definition at line 220 of file GeometryDataContainers.h.

References geo::TPCDataContainer< T >::fNCryo.

221  { return { index / fNCryo, index % fNCryo }; }
size_type index(CryostatNo_t cryo, TPCNo_t tpc) const
Returns the internal index of the specified TPC in the storage area.
CryostatNo_t fNCryo
Number of cryostats.
template<typename T >
size_type geo::TPCDataContainer< T >::index ( CryostatNo_t  cryo,
TPCNo_t  tpc 
) const
inlineprivate

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

Definition at line 212 of file GeometryDataContainers.h.

Referenced by geo::TPCDataContainer< T >::index(), geo::PlaneDataContainer< T >::index(), geo::TPCDataContainer< T >::operator[](), and geo::PlaneDataContainer< T >::operator[]().

213  { return (fNTPCs * cryo) + tpc; }
TPCNo_t fNTPCs
Number of TPCs.
template<typename T >
size_type geo::TPCDataContainer< T >::index ( geo::TPCID const &  id) const
inlineprivate

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

Definition at line 216 of file GeometryDataContainers.h.

References geo::TPCDataContainer< T >::index().

217  { return index(id.Cryostat, id.TPC); }
size_type index(CryostatNo_t cryo, TPCNo_t tpc) const
Returns the internal index of the specified TPC in the storage area.
template<typename T >
reference geo::TPCDataContainer< T >::last ( )
inline

Returns the element for the last TPC (unchecked).

Definition at line 194 of file GeometryDataContainers.h.

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

194 { return operator[](lastID()); }
reference operator[](geo::TPCID const &id)
Returns the element for the specified TPC.
geo::TPCID lastID() const
Returns the ID of the last covered TPC.
template<typename T >
const_reference geo::TPCDataContainer< T >::last ( ) const
inline

Returns the element for the last TPC (unchecked).

Definition at line 197 of file GeometryDataContainers.h.

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

197 { return operator[](lastID()); }
reference operator[](geo::TPCID const &id)
Returns the element for the specified TPC.
geo::TPCID lastID() const
Returns the ID of the last covered TPC.
template<typename T >
geo::TPCID geo::TPCDataContainer< T >::lastID ( ) const
inline

Returns the ID of the last covered TPC.

Definition at line 151 of file GeometryDataContainers.h.

References geo::TPCDataContainer< T >::fNCryo, and geo::TPCDataContainer< T >::fNTPCs.

Referenced by geo::TPCDataContainer< T >::last(), and geo::PlaneDataContainer< T >::last().

151 { return { fNCryo - 1U, fNTPCs - 1U }; }
TPCNo_t fNTPCs
Number of TPCs.
CryostatNo_t fNCryo
Number of cryostats.
template<typename T >
reference geo::TPCDataContainer< T >::operator[] ( geo::TPCID const &  id)
inline

Returns the element for the specified TPC.

Definition at line 162 of file GeometryDataContainers.h.

References geo::TPCDataContainer< T >::fData, and geo::TPCDataContainer< T >::index().

Referenced by geo::TPCDataContainer< T >::at(), geo::PlaneDataContainer< T >::at(), geo::TPCDataContainer< T >::first(), geo::PlaneDataContainer< T >::first(), geo::TPCDataContainer< T >::last(), and geo::PlaneDataContainer< T >::last().

163  { return fData[index(id)]; }
size_type index(CryostatNo_t cryo, TPCNo_t tpc) const
Returns the internal index of the specified TPC in the storage area.
Container_t fData
Data storage area.
template<typename T >
const_reference geo::TPCDataContainer< T >::operator[] ( geo::TPCID const &  id) const
inline

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

Definition at line 166 of file GeometryDataContainers.h.

References geo::TPCDataContainer< T >::fData, and geo::TPCDataContainer< T >::index().

167  { return fData[index(id)]; }
size_type index(CryostatNo_t cryo, TPCNo_t tpc) const
Returns the internal index of the specified TPC in the storage area.
Container_t fData
Data storage area.
template<typename T >
size_type geo::TPCDataContainer< T >::size ( ) const
inline

Returns the number of elements in the container.

Definition at line 131 of file GeometryDataContainers.h.

References geo::TPCDataContainer< T >::fData.

131 { return fData.size(); }
Container_t fData
Data storage area.

Member Data Documentation


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