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

Container with one element per geometry wire plane. 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

 PlaneDataContainer (unsigned int nCryo, unsigned int nTPCs, unsigned int nPlanes)
 Prepares the container with default-constructed data. More...
 
 PlaneDataContainer (unsigned int nCryo, unsigned int nTPCs, unsigned int nPlanes, 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...
 
bool hasPlane (geo::PlaneID const &id) const
 Returns whether this container hosts data for the specified plane. More...
 
geo::PlaneID firstID () const
 Returns the ID of the first TPC. More...
 
geo::PlaneID lastID () const
 Returns the ID of the last covered TPC. More...
 
Element access
reference operator[] (geo::PlaneID const &id)
 Returns the element for the specified wire plane. More...
 
const_reference operator[] (geo::PlaneID const &id) const
 Returns the element for the specified wire plane (read-only). More...
 
reference at (geo::PlaneID const &id)
 
const_reference at (geo::PlaneID 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
 
using PlaneNo_t = geo::PlaneID::PlaneID_t
 

Private Member Functions

size_type index (CryostatNo_t cryo, TPCNo_t tpc, PlaneNo_t plane) const
 Returns the internal index of the specified TPC in the storage area. More...
 
size_type index (geo::PlaneID const &id) const
 Returns the internal index of the specified TPC in the storage area. More...
 
geo::PlaneID 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, PlaneNo_t nPlanes)
 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 per cryostat. More...
 
PlaneNo_t fNPlanes
 Number of planes per TPC. More...
 
Container_t fData
 Data storage area. More...
 

Detailed Description

template<typename T>
class geo::PlaneDataContainer< T >

Container with one element per geometry wire plane.


Template Parameters
Ttype of the contained datum
See also
geo::GeometryCore::makePlaneData

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(), geom->MaxPlanes());
for (recob::Hit const& hit: hits) {
if (hit.WireID()) hitsPerPlane[hit.WireID().planeID()].push_back(&hit);
} // 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 planes in all TPCs, and of TPCs on all cryostats. While this is not effectively a necessary condition, keep in mind that this container has no notion whether a given plane or TPC actually exists in the geometry or not
  • at least one element is expected to be present

Definition at line 273 of file GeometryDataContainers.h.

Member Typedef Documentation

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

Definition at line 289 of file GeometryDataContainers.h.

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

Definition at line 287 of file GeometryDataContainers.h.

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

Definition at line 285 of file GeometryDataContainers.h.

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

Definition at line 291 of file GeometryDataContainers.h.

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

Definition at line 275 of file GeometryDataContainers.h.

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

Definition at line 424 of file GeometryDataContainers.h.

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

Definition at line 292 of file GeometryDataContainers.h.

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

Definition at line 288 of file GeometryDataContainers.h.

template<typename T >
using geo::PlaneDataContainer< T >::PlaneNo_t = geo::PlaneID::PlaneID_t
private

Definition at line 426 of file GeometryDataContainers.h.

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

Definition at line 286 of file GeometryDataContainers.h.

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

Definition at line 284 of file GeometryDataContainers.h.

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

Definition at line 290 of file GeometryDataContainers.h.

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

Definition at line 293 of file GeometryDataContainers.h.

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

Definition at line 425 of file GeometryDataContainers.h.

Constructor & Destructor Documentation

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

Prepares the container with default-constructed data.

Parameters
nCryonumber of cryostats
nTPCsnumber of TPCs per cryostat
nPlanesnumber of planes per TPC

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

Definition at line 308 of file GeometryDataContainers.h.

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

309  : fNCryo(nCryo)
310  , fNTPCs(nTPCs)
311  , fNPlanes(nPlanes)
312  , fData(computeSize())
313  { assert(!empty()); }
PlaneNo_t fNPlanes
Number of planes per TPC.
CryostatNo_t fNCryo
Number of cryostats.
bool empty() const
Returns whether the container has no elements (false by assumptions).
Container_t fData
Data storage area.
TPCNo_t fNTPCs
Number of TPCs per cryostat.
size_type computeSize() const
Computes the expected size of this container.
template<typename T >
geo::PlaneDataContainer< T >::PlaneDataContainer ( unsigned int  nCryo,
unsigned int  nTPCs,
unsigned int  nPlanes,
T const &  defValue 
)
inline

Prepares the container with copies of the specified default value.

Parameters
nCryonumber of cryostats
nTPCsnumber of TPCs
nPlanesnumber of planes per TPC
defValuethe value to be replicated

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

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

Definition at line 331 of file GeometryDataContainers.h.

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

335  : fNCryo(nCryo)
336  , fNTPCs(nTPCs)
337  , fNPlanes(nPlanes)
338  , fData(computeSize(), defValue)
339  { assert(!empty()); }
PlaneNo_t fNPlanes
Number of planes per TPC.
CryostatNo_t fNCryo
Number of cryostats.
bool empty() const
Returns whether the container has no elements (false by assumptions).
Container_t fData
Data storage area.
TPCNo_t fNTPCs
Number of TPCs per cryostat.
size_type computeSize() const
Computes the expected size of this container.

Member Function Documentation

template<typename T >
reference geo::PlaneDataContainer< T >::at ( geo::PlaneID const &  id)
inline

Returns the element for the specified wire plane.

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

Definition at line 392 of file GeometryDataContainers.h.

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

393  {
394  if (hasPlane(id)) return operator[](id);
395  throw std::out_of_range("No data for " + std::string(id));
396  }
reference operator[](geo::PlaneID const &id)
Returns the element for the specified wire plane.
bool hasPlane(geo::PlaneID const &id) const
Returns whether this container hosts data for the specified plane.
template<typename T >
const_reference geo::PlaneDataContainer< T >::at ( geo::PlaneID const &  id) const
inline

Returns the element for the specified wire plane (read-only).

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

Definition at line 400 of file GeometryDataContainers.h.

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

401  {
402  if (hasPlane(id)) return operator[](id);
403  throw std::out_of_range("No data for " + std::string(id));
404  }
reference operator[](geo::PlaneID const &id)
Returns the element for the specified wire plane.
bool hasPlane(geo::PlaneID const &id) const
Returns whether this container hosts data for the specified plane.
template<typename T >
template<typename Value , typename Upper >
static bool geo::PlaneDataContainer< T >::bounded ( Value  v,
Upper  upper 
)
inlinestaticprivate

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

Definition at line 460 of file GeometryDataContainers.h.

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

Returns the number of elements the container has memory for.

Definition at line 350 of file GeometryDataContainers.h.

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

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

Computes the expected size of this container.

Definition at line 450 of file GeometryDataContainers.h.

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

451  { return computeSize(fNCryo, fNTPCs, fNPlanes); }
PlaneNo_t fNPlanes
Number of planes per TPC.
CryostatNo_t fNCryo
Number of cryostats.
TPCNo_t fNTPCs
Number of TPCs per cryostat.
size_type computeSize() const
Computes the expected size of this container.
template<typename T >
static size_type geo::PlaneDataContainer< T >::computeSize ( CryostatNo_t  nCryo,
TPCNo_t  nTPCs,
PlaneNo_t  nPlanes 
)
inlinestaticprivate

Returns the size of a container with the specified dimensions.

Definition at line 455 of file GeometryDataContainers.h.

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

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

Definition at line 353 of file GeometryDataContainers.h.

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

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

Returns the element for the first TPC (unchecked).

Definition at line 408 of file GeometryDataContainers.h.

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

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

Returns the element for the first TPC (unchecked).

Definition at line 411 of file GeometryDataContainers.h.

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

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

Returns the ID of the first TPC.

Definition at line 368 of file GeometryDataContainers.h.

368 { return { 0U, 0U, 0U }; }
template<typename T >
bool geo::PlaneDataContainer< T >::hasCryostat ( geo::CryostatID const &  cryoid) const
inline

Returns whether this container hosts data for the specified cryostat.

Definition at line 356 of file GeometryDataContainers.h.

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

357  { 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::PlaneDataContainer< T >::hasPlane ( geo::PlaneID const &  id) const
inline

Returns whether this container hosts data for the specified plane.

Definition at line 364 of file GeometryDataContainers.h.

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

365  { return hasTPC(id) && bounded(id.Plane, fNPlanes); }
PlaneNo_t fNPlanes
Number of planes per TPC.
bool hasTPC(geo::TPCID const &id) const
Returns whether this container hosts data for the specified TPC.
static bool bounded(Value v, Upper upper)
Returns whether the specified value is between 0 and the upper limit.
recob::tracking::Plane Plane
Definition: TrackState.h:17
template<typename T >
bool geo::PlaneDataContainer< T >::hasTPC ( geo::TPCID const &  id) const
inline

Returns whether this container hosts data for the specified TPC.

Definition at line 360 of file GeometryDataContainers.h.

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

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

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

Definition at line 443 of file GeometryDataContainers.h.

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

444  {
445  return
447  }
PlaneNo_t fNPlanes
Number of planes per TPC.
CryostatNo_t fNCryo
Number of cryostats.
size_type index(CryostatNo_t cryo, TPCNo_t tpc, PlaneNo_t plane) const
Returns the internal index of the specified TPC in the storage area.
template<typename T >
size_type geo::PlaneDataContainer< T >::index ( CryostatNo_t  cryo,
TPCNo_t  tpc,
PlaneNo_t  plane 
) const
inlineprivate

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

Definition at line 435 of file GeometryDataContainers.h.

436  { return ((cryo) * fNTPCs + tpc) * fNPlanes + plane; }
PlaneNo_t fNPlanes
Number of planes per TPC.
TPCNo_t fNTPCs
Number of TPCs per cryostat.
template<typename T >
size_type geo::PlaneDataContainer< T >::index ( geo::PlaneID const &  id) const
inlineprivate

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

Definition at line 439 of file GeometryDataContainers.h.

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

440  { return index(id.Cryostat, id.TPC, id.Plane); }
size_type index(CryostatNo_t cryo, TPCNo_t tpc, PlaneNo_t plane) const
Returns the internal index of the specified TPC in the storage area.
recob::tracking::Plane Plane
Definition: TrackState.h:17
template<typename T >
reference geo::PlaneDataContainer< T >::last ( )
inline

Returns the element for the last TPC (unchecked).

Definition at line 415 of file GeometryDataContainers.h.

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

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

Returns the element for the last TPC (unchecked).

Definition at line 418 of file GeometryDataContainers.h.

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

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

Returns the ID of the last covered TPC.

Definition at line 371 of file GeometryDataContainers.h.

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

372  { return { fNCryo - 1U, fNTPCs - 1U, fNPlanes - 1U }; }
PlaneNo_t fNPlanes
Number of planes per TPC.
CryostatNo_t fNCryo
Number of cryostats.
TPCNo_t fNTPCs
Number of TPCs per cryostat.
template<typename T >
reference geo::PlaneDataContainer< T >::operator[] ( geo::PlaneID const &  id)
inline

Returns the element for the specified wire plane.

Definition at line 383 of file GeometryDataContainers.h.

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

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

Returns the element for the specified wire plane (read-only).

Definition at line 387 of file GeometryDataContainers.h.

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

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

Returns the number of elements in the container.

Definition at line 347 of file GeometryDataContainers.h.

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

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

Member Data Documentation

template<typename T >
Container_t geo::PlaneDataContainer< T >::fData
private

Data storage area.

Definition at line 432 of file GeometryDataContainers.h.

template<typename T >
CryostatNo_t geo::PlaneDataContainer< T >::fNCryo
private

Number of cryostats.

Definition at line 428 of file GeometryDataContainers.h.

template<typename T >
PlaneNo_t geo::PlaneDataContainer< T >::fNPlanes
private

Number of planes per TPC.

Definition at line 430 of file GeometryDataContainers.h.

template<typename T >
TPCNo_t geo::PlaneDataContainer< T >::fNTPCs
private

Number of TPCs per cryostat.

Definition at line 429 of file GeometryDataContainers.h.


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