LArSoft  v09_90_00
Liquid Argon Software toolkit - https://larsoft.org/
recob::Edge Class Reference

Edge is an object containing the results of a Principal Components Analysis of a group of space points. More...

#include "Edge.h"

Public Types

using ID_t = unsigned int
 Type to represent recob::Edge IDs. More...
 
using SpacePointID_t = recob::SpacePoint::ID_t
 Type to represent recob::SpacePoint IDs. More...
 

Public Member Functions

 Edge ()=default
 Default constructor (all invalid IDs). More...
 
 Edge (const double length, SpacePointID_t firstPointID, SpacePointID_t secondPointID, ID_t id=InvalidID)
 Constructor: assigns all values. More...
 
 Edge (SpacePoint const &firstPoint, SpacePoint const &secondPoint, ID_t id=InvalidID)
 Constructor: uses the specified spacepoints. More...
 
Access
double Length () const
 Returns the length of this edge [cm]. More...
 
SpacePointID_t FirstPointID () const
 Returns the ID of the SpacePoint this edge emanates from. More...
 
SpacePointID_t SecondPointID () const
 Returns the ID of the SpacePoint this edge ends on. More...
 
ID_t ID () const
 Returns the ID of this edge. More...
 

Static Public Attributes

static constexpr ID_t InvalidID = std::numeric_limits<ID_t>::max()
 Special value for an invalid edge ID. More...
 

Private Attributes

double fLength = 0.0
 Length of this Edge [cm]. More...
 
SpacePointID_t fFirstPointID = recob::SpacePoint::InvalidID
 ID of the SpacePoint edge emanates from. More...
 
SpacePointID_t fSecondPointID = recob::SpacePoint::InvalidID
 ID of the SpacePoint edge ends on. More...
 
ID_t fID = InvalidID
 Edge ID. More...
 

Detailed Description

Edge is an object containing the results of a Principal Components Analysis of a group of space points.

The edge contains references to an emanating space point (FirstPointID()) and to an ending one (SecondPointID()). For convenience, it also stores the distance between those points.

To look up for a referenced space point, the easiest way is to start from a sorted list of space points (recob::SpacePoint sorts by ID value):

if (!std::is_sorted(points.begin(), points.end()))
throw std::runtime_error("Space points not sorted!");
// find the first space point
auto const iFirstPoint = std::lower_bound
(points.begin(), points.end(), edge.FirstPointID());
if ((iFirstPoint == points.end()) || (iFirstPoint->ID() != edge.FirstPointID())) {
throw std::runtime_error
("First point not found: ID=" + std::to_string(edge.FirstPointID()));
}
recob::SpacePoint const& firstPoint = *iFirstPoint;
// find the second space point
auto const iSecondPoint = std::lower_bound
(points.begin(), points.end(), edge.SecondPointID());
if ((iSecondPoint == points.end()) || (iSecondPoint->ID() != edge.SecondPointID())) {
throw std::runtime_error
("Second point not found: ID=" + std::to_string(edge.SecondPointID()));
}
recob::SpacePoint const& secondPoint = *iSecondPoint;

Definition at line 59 of file Edge.h.

Member Typedef Documentation

using recob::Edge::ID_t = unsigned int

Type to represent recob::Edge IDs.

Definition at line 62 of file Edge.h.

Type to represent recob::SpacePoint IDs.

Definition at line 65 of file Edge.h.

Constructor & Destructor Documentation

recob::Edge::Edge ( )
default

Default constructor (all invalid IDs).

recob::Edge::Edge ( const double  length,
SpacePointID_t  firstPointID,
SpacePointID_t  secondPointID,
ID_t  id = InvalidID 
)

Constructor: assigns all values.

Parameters
lengththe length of the edge [cm]
firstPointIDID of the emanating space point
secondPointIDID of the ending space point
id_(default: InvalidID) ID of this edge

Definition at line 35 of file Edge.cxx.

39  : fLength(length), fFirstPointID(firstPointID), fSecondPointID(secondPointID), fID(id)
40  {}
double fLength
Length of this Edge [cm].
Definition: Edge.h:114
SpacePointID_t fSecondPointID
ID of the SpacePoint edge ends on.
Definition: Edge.h:118
SpacePointID_t fFirstPointID
ID of the SpacePoint edge emanates from.
Definition: Edge.h:116
ID_t fID
Edge ID.
Definition: Edge.h:120
recob::Edge::Edge ( SpacePoint const &  firstPoint,
SpacePoint const &  secondPoint,
ID_t  id = InvalidID 
)

Constructor: uses the specified spacepoints.

Parameters
firstPointthe emanating space point
secondPointthe ending space point
id_(default: InvalidID) ID of this edge

Definition at line 43 of file Edge.cxx.

44  : fLength(::spacePointDistance(firstPoint, secondPoint))
45  , fFirstPointID(firstPoint.ID())
46  , fSecondPointID(secondPoint.ID())
47  , fID(id)
48  {}
double fLength
Length of this Edge [cm].
Definition: Edge.h:114
SpacePointID_t fSecondPointID
ID of the SpacePoint edge ends on.
Definition: Edge.h:118
SpacePointID_t fFirstPointID
ID of the SpacePoint edge emanates from.
Definition: Edge.h:116
ID_t fID
Edge ID.
Definition: Edge.h:120

Member Function Documentation

SpacePointID_t recob::Edge::FirstPointID ( ) const
inline

Returns the ID of the SpacePoint this edge emanates from.

Definition at line 102 of file Edge.h.

References fFirstPointID.

Referenced by recob::operator<<().

102 { return fFirstPointID; }
SpacePointID_t fFirstPointID
ID of the SpacePoint edge emanates from.
Definition: Edge.h:116
ID_t recob::Edge::ID ( ) const
inline

Returns the ID of this edge.

Definition at line 108 of file Edge.h.

References fID.

Referenced by recob::operator<(), and recob::operator<<().

108 { return fID; }
ID_t fID
Edge ID.
Definition: Edge.h:120
double recob::Edge::Length ( ) const
inline

Returns the length of this edge [cm].

Definition at line 99 of file Edge.h.

References fLength.

Referenced by recob::operator<<().

99 { return fLength; }
double fLength
Length of this Edge [cm].
Definition: Edge.h:114
SpacePointID_t recob::Edge::SecondPointID ( ) const
inline

Returns the ID of the SpacePoint this edge ends on.

Definition at line 105 of file Edge.h.

References fSecondPointID.

Referenced by recob::operator<<().

105 { return fSecondPointID; }
SpacePointID_t fSecondPointID
ID of the SpacePoint edge ends on.
Definition: Edge.h:118

Member Data Documentation

SpacePointID_t recob::Edge::fFirstPointID = recob::SpacePoint::InvalidID
private

ID of the SpacePoint edge emanates from.

Definition at line 116 of file Edge.h.

Referenced by FirstPointID().

ID_t recob::Edge::fID = InvalidID
private

Edge ID.

Definition at line 120 of file Edge.h.

Referenced by ID().

double recob::Edge::fLength = 0.0
private

Length of this Edge [cm].

Definition at line 114 of file Edge.h.

Referenced by Length().

SpacePointID_t recob::Edge::fSecondPointID = recob::SpacePoint::InvalidID
private

ID of the SpacePoint edge ends on.

Definition at line 118 of file Edge.h.

Referenced by SecondPointID().

constexpr ID_t recob::Edge::InvalidID = std::numeric_limits<ID_t>::max()
static

Special value for an invalid edge ID.

Definition at line 68 of file Edge.h.


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