LArSoft  v09_90_00
Liquid Argon Software toolkit - https://larsoft.org/
proxy::ChargedSpacePointsCollectionProxy< MainColl, AuxColl > Class Template Reference

Proxy collection class for space points associated to charge. More...

#include "ChargedSpacePoints.h"

Inheritance diagram for proxy::ChargedSpacePointsCollectionProxy< MainColl, AuxColl >:
proxy::CollectionProxyBase< SpacePointWithCharge, MainColl, AuxColl... > proxy::details::MainCollectionProxy< MainColl >

Public Types

using element_proxy_t = SpacePointWithCharge< collection_proxy_t >
 Type of element of this collection proxy. More...
 
using aux_collections_t = std::tuple< AuxColls... >
 Tuple of all auxiliary data collections (wrappers). More...
 
using value_type = element_proxy_t
 Type of element of this collection proxy. More...
 
using const_iterator = details::IndexBasedIterator< collection_proxy_t >
 Type of iterator to this collection (constant). More...
 
using iterator = const_iterator
 Type of iterator to this collection (still constant). More...
 
using main_element_t = util::collection_value_t< MainColl >
 Type of the elements in the original collection. More...
 
using main_collection_t = MainColl
 Type of the original collection. More...
 

Public Member Functions

auto const & spacePoints () const
 Returns the original collection of space points. More...
 
auto const & charges () const
 Returns the original collection of charge information. More...
 
element_proxy_t const operator[] (std::size_t i) const
 Returns the element of this collection with the specified index. More...
 
const_iterator begin () const
 Returns an iterator to the first element of the collection. More...
 
const_iterator end () const
 Returns an iterator past the last element of the collection. More...
 
bool empty () const
 Returns whether this collection is empty. More...
 
std::size_t size () const
 Returns the size of this collection. More...
 
auto get () const -> decltype(auto)
 Returns the associated data proxy specified by AuxTag. More...
 
auto getIf () const -> decltype(auto)
 Returns the auxiliary data specified by type (Tag). More...
 
main_collection_t const & main () const
 Returns the wrapped collection. More...
 
main_collection_t const & mainRef () const
 Returns a reference to the wrapped collection. More...
 
main_collection_t const * mainPtr () const
 Returns a pointer to the wrapped collection. More...
 

Static Public Member Functions

static constexpr bool has ()
 Returns whether this class knowns about the specified type (Tag). More...
 

Protected Types

using this_t = MainCollectionProxy< main_collection_t >
 This type. More...
 

Protected Member Functions

AuxColl const & aux () const
 Returns the auxiliary data specified by type. More...
 
auto auxByTag () const -> decltype(auto)
 Returns the auxiliary data specified by type. More...
 
auto getIfHas (std::bool_constant< true >) const -> decltype(auto)
 
auto getIfHas (std::bool_constant< false >) const -> T
 
const_iterator makeIterator (std::size_t i) const
 Returns an iterator pointing to the specified index of this collection. More...
 
this_tmainProxy ()
 Return this object as main collection proxy. More...
 
this_t const & mainProxy () const
 Return this object as main collection proxy. More...
 
auto getMainAt (std::size_t i) const -> decltype(auto)
 Returns the specified item in the original collection. More...
 

Private Types

using base_t = CollectionProxyBase< SpacePointWithCharge, MainColl, AuxColl... >
 

Detailed Description

template<typename MainColl, typename... AuxColl>
class proxy::ChargedSpacePointsCollectionProxy< MainColl, AuxColl >

Proxy collection class for space points associated to charge.

Template Parameters
MainColltype of space point collection
AuxColltypes of auxiliary data collections
See also
proxy::SpacePointWithCharge, proxy::CollectionProxyBase

This proxy collection allows access to space point and charge collection directly:

auto points = proxy::getChargedSpacePoints(event, pointsTag);
auto const& spacePoints = points.spacePoints();
auto const& charges = points.charges();

When accessing the collection proxy element by element (that is, charged space point by charged space point), the available interface is documented in proxy::SpacePointWithCharge.

The standard proxy interface is also available (see proxy::CollectionProxyBase).

Definition at line 315 of file ChargedSpacePoints.h.

Member Typedef Documentation

using proxy::CollectionProxyBase< SpacePointWithCharge , MainColl, AuxColls >::aux_collections_t = std::tuple<AuxColls...>
inherited

Tuple of all auxiliary data collections (wrappers).

Definition at line 128 of file CollectionProxy.h.

template<typename MainColl , typename... AuxColl>
using proxy::ChargedSpacePointsCollectionProxy< MainColl, AuxColl >::base_t = CollectionProxyBase<SpacePointWithCharge, MainColl, AuxColl...>
private

Definition at line 317 of file ChargedSpacePoints.h.

Type of iterator to this collection (constant).

Definition at line 134 of file CollectionProxy.h.

Type of element of this collection proxy.

Definition at line 125 of file CollectionProxy.h.

using proxy::CollectionProxyBase< SpacePointWithCharge , MainColl, AuxColls >::iterator = const_iterator
inherited

Type of iterator to this collection (still constant).

Definition at line 137 of file CollectionProxy.h.

using proxy::details::MainCollectionProxy< MainColl >::main_collection_t = MainColl
inherited

Type of the original collection.

Definition at line 41 of file MainCollectionProxy.h.

Type of the elements in the original collection.

Definition at line 44 of file MainCollectionProxy.h.

template<typename MainColl >
using proxy::details::MainCollectionProxy< MainColl >::this_t = MainCollectionProxy<main_collection_t>
protectedinherited

This type.

Definition at line 60 of file MainCollectionProxy.h.

using proxy::CollectionProxyBase< SpacePointWithCharge , MainColl, AuxColls >::value_type = element_proxy_t
inherited

Type of element of this collection proxy.

Definition at line 131 of file CollectionProxy.h.

Member Function Documentation

AuxColl const& proxy::CollectionProxyBase< SpacePointWithCharge , MainColl, AuxColls >::aux ( ) const
inlineprotectedinherited

Returns the auxiliary data specified by type.

Definition at line 258 of file CollectionProxy.h.

259  {
260  return static_cast<AuxColl const&>(*this);
261  }
auto proxy::CollectionProxyBase< SpacePointWithCharge , MainColl, AuxColls >::auxByTag ( ) const-> decltype(auto)
inlineprotectedinherited

Returns the auxiliary data specified by type.

Definition at line 265 of file CollectionProxy.h.

266  {
267  return aux<util::type_with_tag_t<AuxTag, aux_collections_t>>();
268  }
const_iterator proxy::CollectionProxyBase< SpacePointWithCharge , MainColl, AuxColls >::begin ( ) const
inlineinherited

Returns an iterator to the first element of the collection.

Definition at line 169 of file CollectionProxy.h.

169 { return makeIterator(0U); }
const_iterator makeIterator(std::size_t i) const
Returns an iterator pointing to the specified index of this collection.
template<typename MainColl , typename... AuxColl>
auto const& proxy::ChargedSpacePointsCollectionProxy< MainColl, AuxColl >::charges ( ) const
inline

Returns the original collection of charge information.

Definition at line 325 of file ChargedSpacePoints.h.

326  {
327  return base_t::template get<ChargedSpacePoints::ChargeTag>().dataRef();
328  }
bool proxy::CollectionProxyBase< SpacePointWithCharge , MainColl, AuxColls >::empty ( ) const
inlineinherited

Returns whether this collection is empty.

Definition at line 175 of file CollectionProxy.h.

References main().

175 { return main().empty(); }
main_collection_t const & main() const
Returns the wrapped collection.
const_iterator proxy::CollectionProxyBase< SpacePointWithCharge , MainColl, AuxColls >::end ( void  ) const
inlineinherited

Returns an iterator past the last element of the collection.

Definition at line 172 of file CollectionProxy.h.

References util::size().

172 { return makeIterator(size()); }
const_iterator makeIterator(std::size_t i) const
Returns an iterator pointing to the specified index of this collection.
std::size_t size() const
Returns the size of this collection.
auto proxy::CollectionProxyBase< SpacePointWithCharge , MainColl, AuxColls >::get ( ) const-> decltype(auto)
inlineinherited

Returns the associated data proxy specified by AuxTag.

Definition at line 182 of file CollectionProxy.h.

183  {
184  return auxByTag<AuxTag>();
185  }
auto proxy::CollectionProxyBase< SpacePointWithCharge , MainColl, AuxColls >::getIf ( ) const-> decltype(auto)
inherited

Returns the auxiliary data specified by type (Tag).

Template Parameters
Tagtag of the data to fetch (usually, its type)
Texact type returned by the method (by default a vector of tags)
Returns
the auxiliary data specified by type (Tag).
Exceptions
std::logic_errorif the tag is not available.
See also
get(), has()
Deprecated:
C++17 if constexpr should be used instead (see the example below)

This method is a get() which forgives when the requested type is not available (because this proxy was configured not to hold it).

The difference with get() is the following:

if (tracks.has<recob::Hit>()) {
auto hits = tracks.get<recob::Hit>();
// ...
}
if (tracks.has<recob::SpacePoint>()) {
auto spacepoints = tracks.getIf<recob::SpacePoint>();
// ...
}

If the proxy tracks has not been coded with recob::Hit data, the code snippet will not compile, because get() will not compile for tags that were not coded in. On the other end, if recob::Hit is coded in tracks but recob::SpacePoint is not, the snippet will compile. In that case, if the has() check had been omitted, getIt() would throw a std::logic_error exception when executed. With C++17, this will not be necessary any more by using "constexpr if":

if constexpr (tracks.has<recob::Hit>()) {
auto hits = tracks.get<recob::Hit>();
// ...
}
if constexpr (tracks.has<recob::SpacePoint>()) {
auto spacepoints = tracks.get<recob::SpacePoint>();
// ...
}
Note
If the wrapped data product is something different than a vector of space points (which in the example is likely, if space points are associated to tracks), the almost-correct type of return value needs to be specified as second template parameter T.
Warning
This functionality is not trivial to use! It's mostly meant for implementation of higher level wrappers.
Deprecated:
Use C++17 constexpr if instead.
auto proxy::CollectionProxyBase< SpacePointWithCharge , MainColl, AuxColls >::getIfHas ( std::bool_constant< true >  ) const-> decltype(auto)
protectedinherited
auto proxy::CollectionProxyBase< SpacePointWithCharge , MainColl, AuxColls >::getIfHas ( std::bool_constant< false >  ) const-> T
protectedinherited
template<typename MainColl >
auto proxy::details::MainCollectionProxy< MainColl >::getMainAt ( std::size_t  i) const -> decltype(auto)
inlineprotectedinherited

Returns the specified item in the original collection.

Definition at line 69 of file MainCollectionProxy.h.

References proxy::details::MainCollectionProxy< MainColl >::fMain.

69 { return fMain->operator[](i); }
static constexpr bool proxy::CollectionProxyBase< SpacePointWithCharge , MainColl, AuxColls >::has ( )
inlinestaticinherited

Returns whether this class knowns about the specified type (Tag).

Definition at line 246 of file CollectionProxy.h.

References main().

247  {
248  return util::has_tag_v<Tag, aux_collections_t>;
249  }
template<typename MainColl >
main_collection_t const& proxy::details::MainCollectionProxy< MainColl >::main ( ) const
inlineinherited

Returns the wrapped collection.

Definition at line 50 of file MainCollectionProxy.h.

References proxy::details::MainCollectionProxy< MainColl >::mainRef().

50 { return mainRef(); }
main_collection_t const & mainRef() const
Returns a reference to the wrapped collection.
template<typename MainColl >
this_t& proxy::details::MainCollectionProxy< MainColl >::mainProxy ( )
inlineprotectedinherited

Return this object as main collection proxy.

Definition at line 63 of file MainCollectionProxy.h.

63 { return *this; }
template<typename MainColl >
this_t const& proxy::details::MainCollectionProxy< MainColl >::mainProxy ( ) const
inlineprotectedinherited

Return this object as main collection proxy.

Definition at line 66 of file MainCollectionProxy.h.

66 { return *this; }
template<typename MainColl >
main_collection_t const* proxy::details::MainCollectionProxy< MainColl >::mainPtr ( ) const
inlineinherited

Returns a pointer to the wrapped collection.

Definition at line 56 of file MainCollectionProxy.h.

References proxy::details::MainCollectionProxy< MainColl >::fMain.

56 { return fMain; }
template<typename MainColl >
main_collection_t const& proxy::details::MainCollectionProxy< MainColl >::mainRef ( ) const
inlineinherited

Returns a reference to the wrapped collection.

Definition at line 53 of file MainCollectionProxy.h.

References proxy::details::MainCollectionProxy< MainColl >::fMain.

Referenced by proxy::details::MainCollectionProxy< MainColl >::main().

53 { return *fMain; }
const_iterator proxy::CollectionProxyBase< SpacePointWithCharge , MainColl, AuxColls >::makeIterator ( std::size_t  i) const
inlineprotectedinherited

Returns an iterator pointing to the specified index of this collection.

Definition at line 276 of file CollectionProxy.h.

276 { return {*this, i}; }
element_proxy_t const proxy::CollectionProxyBase< SpacePointWithCharge , MainColl, AuxColls >::operator[] ( std::size_t  i) const
inlineinherited

Returns the element of this collection with the specified index.

Parameters
ithe index in the collection
Returns
a value representing an element of the collection

The returned value is an object created on the spot, not a reference to an existing structure. The structure exposes the i-th element in the main collection, plus all objects that are associated to it.

Definition at line 162 of file CollectionProxy.h.

163  {
164  return details::makeCollectionProxyElement<element_proxy_t>(
165  i, getMainAt(i), aux<AuxColls>().operator[](i)...);
166  }
auto getMainAt(std::size_t i) const -> decltype(auto)
Returns the specified item in the original collection.
std::size_t proxy::CollectionProxyBase< SpacePointWithCharge , MainColl, AuxColls >::size ( void  ) const
inlineinherited

Returns the size of this collection.

Definition at line 178 of file CollectionProxy.h.

References main().

178 { return main().size(); }
main_collection_t const & main() const
Returns the wrapped collection.
template<typename MainColl , typename... AuxColl>
auto const& proxy::ChargedSpacePointsCollectionProxy< MainColl, AuxColl >::spacePoints ( ) const
inline

Returns the original collection of space points.

Definition at line 322 of file ChargedSpacePoints.h.

References main().

322 { return base_t::main(); }
main_collection_t const & main() const
Returns the wrapped collection.

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