Public Types | Public Member Functions | Static Public Attributes | Private Attributes | List of all members
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 61 of file Edge.h.

Member Typedef Documentation

using recob::Edge::ID_t = unsigned int

Type to represent recob::Edge IDs.

Definition at line 66 of file Edge.h.

Type to represent recob::SpacePoint IDs.

Definition at line 69 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 38 of file Edge.cxx.

38  :
39  fLength(length),
40  fFirstPointID(firstPointID),
41  fSecondPointID(secondPointID),
42  fID(id)
43 {
44 }
double fLength
Length of this Edge [cm].
Definition: Edge.h:128
SpacePointID_t fSecondPointID
ID of the SpacePoint edge ends on.
Definition: Edge.h:132
SpacePointID_t fFirstPointID
ID of the SpacePoint edge emanates from.
Definition: Edge.h:130
ID_t fID
Edge ID.
Definition: Edge.h:134
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 47 of file Edge.cxx.

48  :
49  fLength(::spacePointDistance(firstPoint, secondPoint)),
50  fFirstPointID(firstPoint.ID()),
51  fSecondPointID(secondPoint.ID()),
52  fID(id)
53 {
54 }
double fLength
Length of this Edge [cm].
Definition: Edge.h:128
SpacePointID_t fSecondPointID
ID of the SpacePoint edge ends on.
Definition: Edge.h:132
SpacePointID_t fFirstPointID
ID of the SpacePoint edge emanates from.
Definition: Edge.h:130
ID_t fID
Edge ID.
Definition: Edge.h:134

Member Function Documentation

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

Returns the ID of the SpacePoint this edge emanates from.

Definition at line 112 of file Edge.h.

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

Returns the ID of this edge.

Definition at line 120 of file Edge.h.

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

Returns the length of this edge [cm].

Definition at line 108 of file Edge.h.

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

Returns the ID of the SpacePoint this edge ends on.

Definition at line 116 of file Edge.h.

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

Member Data Documentation

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

ID of the SpacePoint edge emanates from.

Definition at line 130 of file Edge.h.

ID_t recob::Edge::fID = InvalidID
private

Edge ID.

Definition at line 134 of file Edge.h.

double recob::Edge::fLength = 0.0
private

Length of this Edge [cm].

Definition at line 128 of file Edge.h.

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

ID of the SpacePoint edge ends on.

Definition at line 132 of file Edge.h.

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

Special value for an invalid edge ID.

Definition at line 72 of file Edge.h.


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