LArSoft  v06_85_00
Liquid Argon Software toolkit - http://larsoft.org/
proxy::SpacePointWithCharge< CollProxy > Struct Template Reference

Proxy class for charged space point proxy elements. More...

#include "ChargedSpacePoints.h"

Inheritance diagram for proxy::SpacePointWithCharge< CollProxy >:
proxy::CollectionProxyElement< CollProxy >

Public Types

using base_t = CollectionProxyElement< CollProxy >
 Base type. More...
 
using collection_proxy_t = CollProxy
 
using main_element_t = typename collection_proxy_t::main_element_t
 
using aux_elements_t = typename details::SubstituteWithAuxList< typename collection_proxy_t::aux_collections_t >::type
 Tuple of elements (expected to be tagged types). More...
 

Public Member Functions

recob::PointCharge const & chargeInfo () const
 
main_element_t const * operator-> () const
 Returns a pointer to the main element. More...
 
main_element_t const & operator* () const
 Returns a reference to the main element. More...
 
std::size_t index () const
 Returns the index of this element in the collection. More...
 
template<typename Tag >
auto get () const -> decltype(auto)
 Returns the auxiliary data specified by type (Tag). More...
 
template<typename Tag , typename T = Tag const&>
auto getIf () const -> decltype(auto)
 Returns the auxiliary data specified by type (Tag). More...
 
Full data object access
recob::SpacePoint const & point () const
 Returns the original space point. More...
 
Direct space point interface
auto ID () const
 Returns the ID of the space point. More...
 
geo::Point_t position () const
 Returns the position of the space point. More...
 
Direct charge interface
recob::PointCharge::Charge_t charge () const
 
bool hasCharge () const
 

Static Public Member Functions

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

Detailed Description

template<typename CollProxy>
struct proxy::SpacePointWithCharge< CollProxy >

Proxy class for charged space point proxy elements.

Template Parameters
CollProxytype of point proxy collection to get data from
See also
proxy::CollectionProxyElement, proxy::ChargedSpacePointsCollectionProxy

For details on the space point interface see proxy::ChargedSpacePoints.

Definition at line 244 of file ChargedSpacePoints.h.

Member Typedef Documentation

template<typename CollProxy >
using proxy::CollectionProxyElement< CollProxy >::aux_elements_t = typename details::SubstituteWithAuxList <typename collection_proxy_t::aux_collections_t>::type
inherited

Tuple of elements (expected to be tagged types).

Definition at line 170 of file CollectionProxyElement.h.

template<typename CollProxy >
using proxy::SpacePointWithCharge< CollProxy >::base_t = CollectionProxyElement<CollProxy>

Base type.

Definition at line 246 of file ChargedSpacePoints.h.

template<typename CollProxy >
using proxy::CollectionProxyElement< CollProxy >::collection_proxy_t = CollProxy
inherited

Definition at line 165 of file CollectionProxyElement.h.

template<typename CollProxy >
using proxy::CollectionProxyElement< CollProxy >::main_element_t = typename collection_proxy_t::main_element_t
inherited

Definition at line 166 of file CollectionProxyElement.h.

Member Function Documentation

template<typename CollProxy >
recob::PointCharge::Charge_t proxy::SpacePointWithCharge< CollProxy >::charge ( ) const
inline

Returns the charge associated to this point

See also
recob::PointCharge::charge()

Definition at line 287 of file ChargedSpacePoints.h.

288  { return chargeInfo().charge(); }
constexpr Charge_t charge() const
Returns the stored value of the reconstructed charge.
Definition: PointCharge.h:65
recob::PointCharge const & chargeInfo() const
template<typename CollProxy >
recob::PointCharge const& proxy::SpacePointWithCharge< CollProxy >::chargeInfo ( ) const
inline

Returns the recob::PointCharge object with the complete charge information.

Definition at line 263 of file ChargedSpacePoints.h.

264  { return base_t::template get<ChargedSpacePoints::ChargeTag>(); }
template<typename CollProxy >
template<typename Tag >
auto proxy::CollectionProxyElement< CollProxy >::get ( ) const -> decltype(auto)
inlineinherited

Returns the auxiliary data specified by type (Tag).

Definition at line 190 of file CollectionProxyElement.h.

191  { return std::get<util::index_of_tag_v<Tag, aux_elements_t>>(fAuxData); }
aux_elements_t fAuxData
Data associated to the main object.
template<typename CollProxy >
template<typename Tag , typename T >
auto proxy::CollectionProxyElement< CollProxy >::getIf ( ) const -> decltype(auto)
inherited

Returns the auxiliary data specified by type (Tag).

Template Parameters
Tagtag of the data to fetch (usually, its type)
Ttype to return (by default, a constant reference to Tag)
Returns
the auxiliary data specified by type (Tag).
Exceptions
std::logic_errorif the tag is not available.
See also
get(), has()

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:

decltype(auto) elem = tracks[0];
if (elem.has<recob::Hit>()) {
auto hits = elem.get<recob::Hit>();
// ...
}
if (elem.has<recob::SpacePoint>()) {
auto spacepoints = elem.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":

decltype(auto) elem = tracks[0];
if constexpr (elem.has<recob::Hit>()) {
auto hits = elem.get<recob::Hit>();
// ...
}
if constexpr (elem.has<recob::SpacePoint>()) {
auto spacepoints = elem.get<recob::SpacePoint>();
// ...
}
Note
The second template argument contains the exact type returned by the function. That information is needed because this method needs to return the same type (or compatible types) whether the required tag is present or not, in order for user code like
if (elem.has<recob::SpacePoint>()) {
recob::SpacePoint const* spacepoints
= elem.getIf<recob::SpacePoint>(); // won't do
// ...
}
to work; it becomes:
if (elem.has<recob::SpacePoint>()) {
recob::SpacePoint const* spacepoints
= elem.getIf<recob::SpacePoint, recob::SpacePoint const*>();
// ...
}
This is necessary because when the tag (in the example, recob::SpacePoint) is not registered in the proxy, getIf() has no clue of what the return value should be ("which is the type of the data that does not exist?").

Definition at line 359 of file CollectionProxyElement.h.

References proxy::CollectionProxyElement< CollProxy >::getIfHas().

360  { return getIfHas<Tag, T>(util::bool_constant<has<Tag>()>{}); }
std::integral_constant< bool, Value > bool_constant
Definition: MetaUtils.h:168
template<typename CollProxy >
template<typename Tag >
static constexpr bool proxy::CollectionProxyElement< CollProxy >::has ( )
inlinestaticinherited

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

Definition at line 267 of file CollectionProxyElement.h.

267 { return util::has_tag_v<Tag, aux_elements_t>; }
template<typename CollProxy >
bool proxy::SpacePointWithCharge< CollProxy >::hasCharge ( ) const
inline

Returns whether the charge associated to the space point is valid.

See also
recob::PointCharge::hasCharge()

Definition at line 292 of file ChargedSpacePoints.h.

292 { return chargeInfo().hasCharge(); }
constexpr bool hasCharge() const
Returns whether the reconstructed charge value is valid.
Definition: PointCharge.h:76
recob::PointCharge const & chargeInfo() const
template<typename CollProxy >
auto proxy::SpacePointWithCharge< CollProxy >::ID ( ) const
inline

Returns the ID of the space point.

Definition at line 271 of file ChargedSpacePoints.h.

271 { return point().ID(); }
recob::SpacePoint const & point() const
Returns the original space point.
ID_t ID() const
Definition: SpacePoint.h:63
template<typename CollProxy >
std::size_t proxy::CollectionProxyElement< CollProxy >::index ( ) const
inlineinherited

Returns the index of this element in the collection.

Definition at line 186 of file CollectionProxyElement.h.

186 { return fIndex; };
std::size_t fIndex
Index of this element in the proxy.
template<typename CollProxy >
main_element_t const& proxy::CollectionProxyElement< CollProxy >::operator* ( ) const
inlineinherited

Returns a reference to the main element.

Definition at line 183 of file CollectionProxyElement.h.

183 { return *fMain; }
main_element_t const * fMain
Pointer to the main object of the element.
template<typename CollProxy >
main_element_t const* proxy::CollectionProxyElement< CollProxy >::operator-> ( ) const
inlineinherited

Returns a pointer to the main element.

Definition at line 180 of file CollectionProxyElement.h.

180 { return fMain; }
main_element_t const * fMain
Pointer to the main object of the element.
template<typename CollProxy >
recob::SpacePoint const& proxy::SpacePointWithCharge< CollProxy >::point ( ) const
inline

Returns the original space point.

Definition at line 256 of file ChargedSpacePoints.h.

References operator*().

256 { return base_t::operator*(); }
main_element_t const & operator*() const
Returns a reference to the main element.
template<typename CollProxy >
geo::Point_t proxy::SpacePointWithCharge< CollProxy >::position ( ) const
inline

Returns the position of the space point.

Definition at line 274 of file ChargedSpacePoints.h.

References geo::vect::makePointFromCoords().

275  { return geo::vect::makePointFromCoords(point().XYZ()); }
recob::SpacePoint const & point() const
Returns the original space point.
GENVECTOR_CONSTEXPR::geo::Point_t makePointFromCoords(Coords &&coords)
Creates a geo::Point_t from its coordinates (see makeFromCoords()).

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