Public Types | Public Member Functions | Private Member Functions | List of all members
proxy::TrackCollectionProxyElement< CollProxy > Struct Template Reference

Class for track proxy elements. More...

#include <Track.h>

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

Public Types

using base_t = CollectionProxyElement< CollProxy >
 Base type. More...
 
using track_proxy_t = TrackCollectionProxyElement< CollProxy >
 This type. More...
 
using point_iterator = TrackPointIterator< track_proxy_t >
 Iterator for trajectory point information. More...
 
- Public Types inherited from proxy::CollectionProxyElement< CollProxy >
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::Track const & track () const
 Returns the pointed track. More...
 
recob::TrackTrajectory const * operator() (proxy::Tracks::TrackType_t type) const noexcept
 Returns the requested trajectory from the proxy. More...
 
recob::TrackFitHitInfo const * fitInfoAtPoint (std::size_t index) const
 Returns fit info for the specified point (nullptr if not available). More...
 
Direct hit interface.

The track prescription requires one hit per trajectory point.

Note
Remember that in particular cases there might be a hit without point of vice versa. In those cases, the point will have a dummy value, or the hit pointer will have isNull() true. In the former case, the point flag isPointValid() should be unset.

The interface at track proxy level allows for both access to the whole sequence of hits, or to the hit of a specific point:

assert(track.nHits() > 0);
auto const& hits = track.hits();
art::Ptr<recob::Hit> maxHit = hits[0]; // direct access
for (art::Ptr<recob::Hit> const& hit: hits) {
if (hit.isNull()) continue;
if (maxHit.isNull() || maxHit->Charge() < hit->Charge())
maxHit = hit;
} // for
art::Ptr<recob::Hit> lastHit = track.hitAtPoint(track.nHits() - 1U);
auto hits () const -> decltype(auto)
 Returns a collection-like range of hits of this track, at point order. More...
 
auto hitAtPoint (std::size_t index) const -> decltype(auto)
 Returns an art pointer to the hit associated with the specified point. More...
 
std::size_t nHits () const
 Returns the number of hits associated with this track. More...
 
Direct track trajectory interface
See also
proxy::TrackPoint

The interface allows to check if this track has a trajectory associated with it, and to obtain a reference to it or its art pointer.

bool hasTraj = proxy.hasOriginalTrajectory();
if (hasTraj) {
recob::TrackTrajectory const& trajectory = proxy.originalTrajectory();
// ...
}
= proxy.originalTrajectoryPtr();
if (!trajectoryPtr.isNull()) {
recob::TrackTrajectory const& trajectory = *trajectoryPtr;
// ...
}
Note
This interface can't be used if the track trajectory information has not been merged into the proxy (typically via proxy::withOriginalTrajectory()).
bool hasOriginalTrajectory () const
 Returns whether this track is associated to a trajectory. More...
 
art::Ptr< recob::TrackTrajectory > const & originalTrajectoryPtr () const
 
recob::TrackTrajectory const & originalTrajectory () const
 Returns a reference to the associated trajectory. More...
 
Point-by-point iteration interface

The points on track can be accessed individually with a special, non-extensible proxy.

In this example, points are accessed via iteration:

unsigned int nPoints = track.nPoints();
unsigned int nValidHits = 0;
for (auto point: track.points()) {
if (!point.hit().isNull()) ++nValidHits;
}
unsigned int nValidPoints = std::count_if
(track.beginPoint(), track.endPoint(), &TrackPoint::isPointValid);

Random (index-based) access is also available:

if (track.nPoints() > 1) {
auto point = track.point(1); // or track[1]
// ...
}
auto points () const
 Returns an iterable range with point-by-point information. More...
 
template<typename Pred >
auto selectPoints (Pred &&pred) const
 Returns an iterable range with only points matching the mask. More...
 
auto pointsWithFlags (recob::TrackTrajectory::PointFlags_t::Mask_t mask) const
 Returns an iterable range with only points matching the mask. More...
 
std::size_t nPoints () const
 Returns the number of trajectory points in the track. More...
 
point_iterator beginPoint () const
 Returns the iterator to the data of the first point. More...
 
point_iterator endPoint () const
 Returns the iterator past the last point. More...
 
TrackPoint point (std::size_t index) const
 
TrackPoint operator[] (std::size_t index) const
 
- Public Member Functions inherited from proxy::CollectionProxyElement< CollProxy >
 CollectionProxyElement (std::size_t index, main_element_t const &main, aux_elements_t &&auxData)
 
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...
 

Private Member Functions

recob::TrackTrajectory const * originalTrajectoryCPtr () const noexcept
 

Additional Inherited Members

- Static Public Member Functions inherited from proxy::CollectionProxyElement< CollProxy >
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::TrackCollectionProxyElement< CollProxy >

Class for track proxy elements.

Template Parameters
CollProxytype of track proxy collection to get data from
See also
proxy::TrackPoint, proxy::TrackPointWrapper

For details on the track point interface see proxy::TrackPoint.

Definition at line 731 of file Track.h.

Member Typedef Documentation

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

Base type.

Definition at line 734 of file Track.h.

template<typename CollProxy >
using proxy::TrackCollectionProxyElement< CollProxy >::point_iterator = TrackPointIterator<track_proxy_t>

Iterator for trajectory point information.

Definition at line 742 of file Track.h.

template<typename CollProxy >
using proxy::TrackCollectionProxyElement< CollProxy >::track_proxy_t = TrackCollectionProxyElement<CollProxy>

This type.

Definition at line 738 of file Track.h.

Member Function Documentation

template<typename CollProxy >
point_iterator proxy::TrackCollectionProxyElement< CollProxy >::beginPoint ( ) const
inline

Returns the iterator to the data of the first point.

Definition at line 988 of file Track.h.

988 { return { *this, 0 }; }
template<typename CollProxy >
point_iterator proxy::TrackCollectionProxyElement< CollProxy >::endPoint ( ) const
inline

Returns the iterator past the last point.

Definition at line 991 of file Track.h.

991 { return { *this, nPoints() }; }
std::size_t nPoints() const
Returns the number of trajectory points in the track.
Definition: Track.h:985
template<typename CollProxy >
recob::TrackFitHitInfo const * proxy::TrackCollectionProxyElement< CollProxy >::fitInfoAtPoint ( std::size_t  index) const

Returns fit info for the specified point (nullptr if not available).

Definition at line 1410 of file Track.h.

1411  {
1412  if constexpr (base_t::template has<Tracks::TrackFitHitInfoTag>()) {
1413  auto const& fitInfo = base_t::template get<Tracks::TrackFitHitInfoTag>();
1414  return &(fitInfo[index]);
1415  }
1416  else return nullptr;
1417  } // TrackCollectionProxyElement<>::fitInfoAtPoint()
std::size_t index() const
Returns the index of this element in the collection.
template<typename CollProxy >
bool proxy::TrackCollectionProxyElement< CollProxy >::hasOriginalTrajectory ( ) const
inline

Returns whether this track is associated to a trajectory.

Definition at line 838 of file Track.h.

839  { return !originalTrajectoryPtr().isNull(); }
art::Ptr< recob::TrackTrajectory > const & originalTrajectoryPtr() const
Definition: Track.h:843
template<typename CollProxy >
auto proxy::TrackCollectionProxyElement< CollProxy >::hitAtPoint ( std::size_t  index) const -> decltype(auto)
inline

Returns an art pointer to the hit associated with the specified point.

Definition at line 796 of file Track.h.

797  { return hits()[index]; }
auto hits() const -> decltype(auto)
Returns a collection-like range of hits of this track, at point order.
Definition: Track.h:792
std::size_t index() const
Returns the index of this element in the collection.
template<typename CollProxy >
auto proxy::TrackCollectionProxyElement< CollProxy >::hits ( ) const -> decltype(auto)
inline

Returns a collection-like range of hits of this track, at point order.

Returns
a range of art pointers to hits

One hit is expected per trajectory point. Hits can be missing, in which case the art pointer will have isNull() as true.

Definition at line 792 of file Track.h.

793  { return base_t::template get<Tracks::HitTag>(); }
template<typename CollProxy >
std::size_t proxy::TrackCollectionProxyElement< CollProxy >::nHits ( ) const
inline

Returns the number of hits associated with this track.

Definition at line 800 of file Track.h.

800 { return hits().size(); }
auto hits() const -> decltype(auto)
Returns a collection-like range of hits of this track, at point order.
Definition: Track.h:792
template<typename CollProxy >
std::size_t proxy::TrackCollectionProxyElement< CollProxy >::nPoints ( ) const
inline

Returns the number of trajectory points in the track.

Definition at line 985 of file Track.h.

985 { return track().NPoints(); }
size_t NPoints() const
Definition: Track.h:103
recob::Track const & track() const
Returns the pointed track.
Definition: Track.h:745
template<typename CollProxy >
recob::TrackTrajectory const * proxy::TrackCollectionProxyElement< CollProxy >::operator() ( proxy::Tracks::TrackType_t  type) const
noexcept

Returns the requested trajectory from the proxy.

Parameters
typetype of the track trajectory to be returned
Returns
a reference to the requested track trajectory

Definition at line 1393 of file Track.h.

1394  {
1395  switch (type) {
1396  case proxy::Tracks::Fitted:
1397  return &(track().Trajectory());
1399  return originalTrajectoryCPtr();
1400  default:
1401  return nullptr;
1402  } // switch
1403  } // TrackCollectionProxyElement<>::operator()
const recob::TrackTrajectory & Trajectory() const
Access to the stored recob::TrackTrajectory.
Definition: Track.h:98
recob::TrackTrajectory const * originalTrajectoryCPtr() const noexcept
Definition: Track.h:1014
Represents a track trajectory before the final fit.
Definition: Track.h:514
Represents a track trajectory from the final fit.
Definition: Track.h:515
recob::Track const & track() const
Returns the pointed track.
Definition: Track.h:745
template<typename CollProxy >
TrackPoint proxy::TrackCollectionProxyElement< CollProxy >::operator[] ( std::size_t  index) const
inline

Definition at line 998 of file Track.h.

999  { return point(index); }
std::size_t index() const
Returns the index of this element in the collection.
TrackPoint point(std::size_t index) const
Definition: Track.h:995
template<typename CollProxy >
recob::TrackTrajectory const& proxy::TrackCollectionProxyElement< CollProxy >::originalTrajectory ( ) const
inline

Returns a reference to the associated trajectory.

Returns
the associated trajectory as a constant reference
See also
originalTrajectoryPtr(), hasOriginalTrajectory()

If the track is not associated to any trajectory, the return value is undefined. This condition should be checked beforehand, e.g. with hasTrajectory().

Definition at line 855 of file Track.h.

856  { return *originalTrajectoryPtr(); }
art::Ptr< recob::TrackTrajectory > const & originalTrajectoryPtr() const
Definition: Track.h:843
template<typename CollProxy >
recob::TrackTrajectory const* proxy::TrackCollectionProxyElement< CollProxy >::originalTrajectoryCPtr ( ) const
inlineprivatenoexcept

Definition at line 1014 of file Track.h.

1015  { return hasOriginalTrajectory()? &originalTrajectory(): nullptr; }
bool hasOriginalTrajectory() const
Returns whether this track is associated to a trajectory.
Definition: Track.h:838
recob::TrackTrajectory const & originalTrajectory() const
Returns a reference to the associated trajectory.
Definition: Track.h:855
template<typename CollProxy >
art::Ptr<recob::TrackTrajectory> const& proxy::TrackCollectionProxyElement< CollProxy >::originalTrajectoryPtr ( ) const
inline

Returns an art pointer to the associated trajectory.

Returns
pointer to the associated trajectory (isNull() true if none)

Definition at line 843 of file Track.h.

844  { return base_t::template get<Tracks::TrackTrajectoryTag>(); }
template<typename CollProxy >
TrackPoint proxy::TrackCollectionProxyElement< CollProxy >::point ( std::size_t  index) const
inline

Extracts information from the specified point.

Definition at line 995 of file Track.h.

996  { return { makeTrackPointData(track(), index) }; }
TrackPointData makeTrackPointData(TrackProxy const &track, std::size_t index)
Returns an object with information about the specified track point.
Definition: Track.h:709
std::size_t index() const
Returns the index of this element in the collection.
recob::Track const & track() const
Returns the pointed track.
Definition: Track.h:745
template<typename CollProxy >
auto proxy::TrackCollectionProxyElement< CollProxy >::points ( ) const
inline

Returns an iterable range with point-by-point information.

See also
proxy::TrackPoint, proxy::TrackPointWrapper

The interface of the elements is documented in TrackPointWrapper. Example:

for (auto const& pointInfo: track.points()) {
if (!pointInfo.flags().isPointValid()) continue;
auto const& pos = pointInfo.position();
// ...
} // for point

will iterate through all points (including the invalid ones, hence the check).

Definition at line 909 of file Track.h.

910  { return details::TrackPointIteratorBox<CollProxy>(*this); }
template<typename CollProxy >
auto proxy::TrackCollectionProxyElement< CollProxy >::pointsWithFlags ( recob::TrackTrajectory::PointFlags_t::Mask_t  mask) const

Returns an iterable range with only points matching the mask.

Parameters
maskpoint flag mask to be matched
Returns
an object that can be forward-iterated
See also
points(), util::flags::BitMask::match()

This methods is used in a way similar to points(), with the addition of specifying a mask of flags. The iteration will happen only through the points which match the mask. that is for which pointInfo.flags().match(mask) is true.

The interface of the elements is documented in TrackPointWrapper. Example:

for (auto const& pointInfo
)
{
auto const& pos = pointInfo.position();
// ...
} // for point

will iterate through only the points which do not have the NoPoint flag set (which have in fact a valid position).

Definition at line 1430 of file Track.h.

1431  {
1432  return
1433  selectPoints([mask](auto&& point) { return point.flags().match(mask); });
1434  } // TrackCollectionProxyElement<>::pointsWithFlags()
auto selectPoints(Pred &&pred) const
Returns an iterable range with only points matching the mask.
Definition: Track.h:1423
auto flags() const -> decltype(auto)
Definition: Track.h:636
TrackPoint point(std::size_t index) const
Definition: Track.h:995
template<typename CollProxy >
template<typename Pred >
auto proxy::TrackCollectionProxyElement< CollProxy >::selectPoints ( Pred &&  pred) const

Returns an iterable range with only points matching the mask.

Template Parameters
Predtype of predicate to test on points
Parameters
predpredicate to be fulfilled by the points
Returns
an object that can be forward-iterated
See also
points(), pointsWithFlags()

This methods is used in a way similar to points(), with the addition of specifying a criterium (predicate) defining the selected points. The iteration will happen only through the points which fulfil the predicate.

The interface of the elements is documented in TrackPointWrapper. Example:

auto farPoints = [](auto const& pointInfo)
{ return pointInfo.isPointValid() && pointInfo.position().Z() > 50.; };
for (auto const& pointInfo: track.selectPoints(farPoints)) {
auto const& pos = pointInfo.position();
// ...
} // for point

will iterate through all points which are valid and whose position is at z absolute coordinate larger than 50 centimeters (whatever it means).

Requirements

  • Pred is a unary function object which can accept a TrackPoint object as its sole argument and which returns a value convertible to bool

Definition at line 1423 of file Track.h.

1424  { return util::filterRangeFor(points(), std::forward<Pred>(pred)); }
auto filterRangeFor(Range &&range, Pred &&pred) -> decltype(auto)
Provides iteration only through elements passing a condition.
auto points() const
Returns an iterable range with point-by-point information.
Definition: Track.h:909
template<typename CollProxy >
recob::Track const& proxy::TrackCollectionProxyElement< CollProxy >::track ( ) const
inline

Returns the pointed track.

Definition at line 745 of file Track.h.

745 { return base_t::operator*(); }
main_element_t const & operator*() const
Returns a reference to the main element.

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