All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Public Member Functions | Protected Member Functions | Friends | List of all members
geoalgo::Trajectory Class Reference

#include <GeoTrajectory.h>

Inheritance diagram for geoalgo::Trajectory:

Public Member Functions

 Trajectory (size_t npoints=0, size_t ndimension=0)
 Default ctor to specify # points and dimension of each point. More...
 
virtual ~Trajectory ()
 Default dtor. More...
 
 Trajectory (const std::vector< std::vector< double > > &obj)
 Alternative ctor (0) using a vector of mere vector point expression. More...
 
 Trajectory (const std::vector< geoalgo::Point_t > &obj)
 Alternative ctor (1) using a vector of point. More...
 
double Length (size_t start_step=0, size_t end_step=0) const
 The summed-length along all trajectory points. More...
 
bool IsLonger (double) const
 Check if the trajectory is longer than specified value. More...
 
Vector Dir (size_t i=0) const
 The direction at a specified trajectory point. More...
 
void push_back (const Point_t &obj)
 push_back overrie w/ dimensionality check More...
 
Trajectoryoperator+= (const Point_t &rhs)
 
void compat (const Point_t &obj) const
 Dimensionality check function w/ Trajectory. More...
 
void compat (const Trajectory &obj) const
 Dimensionality check function w/ Point_t. More...
 
template<class T >
void push_back (const T &obj)
 push_back template More...
 
 Trajectory (size_t npoints=0, size_t ndimension=0)
 Default ctor to specify # points and dimension of each point. More...
 
virtual ~Trajectory ()
 Default dtor. More...
 
 Trajectory (const std::vector< std::vector< double > > &obj)
 Alternative ctor (0) using a vector of mere vector point expression. More...
 
 Trajectory (const std::vector< geoalgo::Point_t > &obj)
 Alternative ctor (1) using a vector of point. More...
 
double Length (size_t start_step=0, size_t end_step=0) const
 The summed-length along all trajectory points. More...
 
bool IsLonger (double) const
 Check if the trajectory is longer than specified value. More...
 
Vector Dir (size_t i=0) const
 The direction at a specified trajectory point. More...
 
void push_back (const Point_t &obj)
 push_back overrie w/ dimensionality check More...
 
Trajectoryoperator+= (const Point_t &rhs)
 
void compat (const Point_t &obj) const
 Dimensionality check function w/ Trajectory. More...
 
void compat (const Trajectory &obj) const
 Dimensionality check function w/ Point_t. More...
 
template<class T >
void push_back (const T &obj)
 push_back template More...
 

Protected Member Functions

Vector _Dir_ (size_t i) const
 Returns a direction vector at a specified trajectory point w/o size check. More...
 
Vector _Dir_ (size_t i) const
 Returns a direction vector at a specified trajectory point w/o size check. More...
 

Friends

std::ostream & operator<< (std::ostream &o, Trajectory const &a)
 Streamer. More...
 
std::ostream & operator<< (std::ostream &o, Trajectory const &a)
 Streamer. More...
 

Additional Inherited Members

- Public Attributes inherited from std::vector< T >
elements
 STL member. More...
 

Detailed Description

This class represents a trajectory which is an ordered list of Point. It is a friend class w/ geoalgo::Point_t hence it has an access to protected functions that avoids dimensionality sanity checks for speed.

Definition at line 31 of file larcorealg/larcorealg/GeoAlgo/GeoTrajectory.h.

Constructor & Destructor Documentation

geoalgo::Trajectory::Trajectory ( size_t  npoints = 0,
size_t  ndimension = 0 
)

Default ctor to specify # points and dimension of each point.

Definition at line 8 of file larcorealg/larcorealg/GeoAlgo/GeoTrajectory.cxx.

9  : std::vector<geoalgo::Point_t>(npoints, Point_t(ndimension))
10  {}
virtual geoalgo::Trajectory::~Trajectory ( )
inlinevirtual

Default dtor.

Definition at line 39 of file larcorealg/larcorealg/GeoAlgo/GeoTrajectory.h.

39 {}
geoalgo::Trajectory::Trajectory ( const std::vector< std::vector< double > > &  obj)

Alternative ctor (0) using a vector of mere vector point expression.

Definition at line 12 of file larcorealg/larcorealg/GeoAlgo/GeoTrajectory.cxx.

13  {
14  this->reserve(obj.size());
15  for(auto const& p : obj) this->push_back(Point_t(p));
16  }
pdgs p
Definition: selectors.fcl:22
void push_back(const Point_t &obj)
push_back overrie w/ dimensionality check
geoalgo::Trajectory::Trajectory ( const std::vector< geoalgo::Point_t > &  obj)

Alternative ctor (1) using a vector of point.

Definition at line 18 of file larcorealg/larcorealg/GeoAlgo/GeoTrajectory.cxx.

19  {
20  this->reserve(obj.size());
21  for(auto const& p : obj) this->push_back(p);
22  }
pdgs p
Definition: selectors.fcl:22
void push_back(const Point_t &obj)
push_back overrie w/ dimensionality check
geoalgo::Trajectory::Trajectory ( size_t  npoints = 0,
size_t  ndimension = 0 
)

Default ctor to specify # points and dimension of each point.

virtual geoalgo::Trajectory::~Trajectory ( )
inlinevirtual

Default dtor.

Definition at line 35 of file sbncode/sbncode/OpT0Finder/flashmatch/GeoAlgo/GeoTrajectory.h.

35 {}
geoalgo::Trajectory::Trajectory ( const std::vector< std::vector< double > > &  obj)

Alternative ctor (0) using a vector of mere vector point expression.

geoalgo::Trajectory::Trajectory ( const std::vector< geoalgo::Point_t > &  obj)

Alternative ctor (1) using a vector of point.

Member Function Documentation

Vector geoalgo::Trajectory::_Dir_ ( size_t  i) const
protected

Returns a direction vector at a specified trajectory point w/o size check.

Vector geoalgo::Trajectory::_Dir_ ( size_t  i) const
protected

Returns a direction vector at a specified trajectory point w/o size check.

Definition at line 104 of file larcorealg/larcorealg/GeoAlgo/GeoTrajectory.cxx.

104  {
105 
106  return ((*this)[i+1] - (*this)[i]);
107 
108  }
void geoalgo::Trajectory::compat ( const Point_t obj) const

Dimensionality check function w/ Trajectory.

void geoalgo::Trajectory::compat ( const Trajectory obj) const

Dimensionality check function w/ Point_t.

void geoalgo::Trajectory::compat ( const Point_t obj) const

Dimensionality check function w/ Trajectory.

Definition at line 65 of file larcorealg/larcorealg/GeoAlgo/GeoTrajectory.cxx.

65  {
66 
67  if(!size()) return;
68  if( (*(this->begin())).size() != obj.size() ) {
69 
70  std::ostringstream msg;
71  msg << "<<" << __FUNCTION__ << ">>"
72  << " size mismatch: "
73  << (*(this->begin())).size() << " != " << obj.size() << std::endl;
74  throw GeoAlgoException(msg.str());
75  }
76  }
std::size_t size(FixedBins< T, C > const &) noexcept
Definition: FixedBins.h:561
auto begin(FixedBins< T, C > const &) noexcept
Definition: FixedBins.h:573
void geoalgo::Trajectory::compat ( const Trajectory obj) const

Dimensionality check function w/ Point_t.

Definition at line 78 of file larcorealg/larcorealg/GeoAlgo/GeoTrajectory.cxx.

78  {
79 
80  if(!size() || !(obj.size())) return;
81 
82  if( (*(this->begin())).size() != (*obj.begin()).size() ) {
83 
84  std::ostringstream msg;
85  msg << "<<" << __FUNCTION__ << ">>"
86  << " size mismatch: "
87  << (*(this->begin())).size() << " != " << (*obj.begin()).size() << std::endl;
88  throw GeoAlgoException(msg.str());
89 
90  }
91  }
std::size_t size(FixedBins< T, C > const &) noexcept
Definition: FixedBins.h:561
auto begin(FixedBins< T, C > const &) noexcept
Definition: FixedBins.h:573
Vector geoalgo::Trajectory::Dir ( size_t  i = 0) const

The direction at a specified trajectory point.

Vector geoalgo::Trajectory::Dir ( size_t  i = 0) const

The direction at a specified trajectory point.

Definition at line 93 of file larcorealg/larcorealg/GeoAlgo/GeoTrajectory.cxx.

93  {
94 
95  if(size() < (i+2)) {
96  std::ostringstream msg;
97  msg << "<<" << __FUNCTION__ << ">>"
98  << " length=" << size() << " is too short to find a direction @ index=" << i << std::endl;
99  throw GeoAlgoException(msg.str());
100  }
101  return _Dir_(i);
102  }
std::size_t size(FixedBins< T, C > const &) noexcept
Definition: FixedBins.h:561
Vector _Dir_(size_t i) const
Returns a direction vector at a specified trajectory point w/o size check.
bool geoalgo::Trajectory::IsLonger ( double  ) const

Check if the trajectory is longer than specified value.

bool geoalgo::Trajectory::IsLonger ( double  ref) const

Check if the trajectory is longer than specified value.

Definition at line 44 of file larcorealg/larcorealg/GeoAlgo/GeoTrajectory.cxx.

44  {
45 
46  if(size()<2) return false;
47 
48  double length = 0;
49  for(size_t i=0; i<size()-1; ++i) {
50 
51  length += (*this)[i]._Dist_((*this)[i+1]);
52 
53  if(length > ref) return true;
54  }
55 
56  return false;
57  }
std::size_t size(FixedBins< T, C > const &) noexcept
Definition: FixedBins.h:561
double geoalgo::Trajectory::Length ( size_t  start_step = 0,
size_t  end_step = 0 
) const

The summed-length along all trajectory points.

double geoalgo::Trajectory::Length ( size_t  start_step = 0,
size_t  end_step = 0 
) const

The summed-length along all trajectory points.

Definition at line 24 of file larcorealg/larcorealg/GeoAlgo/GeoTrajectory.cxx.

24  {
25 
26  if(end_step == 0) end_step = size() - 1; // By default end_step is 0. Then consider the whole trajectory()
27 
28  // Sanity checks
29  if(start_step >= end_step) throw GeoAlgoException("Cannot have start step >= end step!");
30 
31  if(end_step >= size()) throw GeoAlgoException("Requested step index bigger than size!");
32 
33  // if length < 2, no length
34  if(size()<2) return 0;
35 
36  double length = 0;
37  for(size_t i=start_step; i<end_step; ++i)
38 
39  length += (*this)[i]._Dist_((*this)[i+1]);
40 
41  return length;
42  }
std::size_t size(FixedBins< T, C > const &) noexcept
Definition: FixedBins.h:561
Trajectory& geoalgo::Trajectory::operator+= ( const Point_t rhs)
inline

Definition at line 55 of file sbncode/sbncode/OpT0Finder/flashmatch/GeoAlgo/GeoTrajectory.h.

56  { push_back(rhs); return *this; }
void push_back(const Point_t &obj)
push_back overrie w/ dimensionality check
Trajectory& geoalgo::Trajectory::operator+= ( const Point_t rhs)
inline

Definition at line 59 of file larcorealg/larcorealg/GeoAlgo/GeoTrajectory.h.

60  { push_back(rhs); return *this; }
void push_back(const Point_t &obj)
push_back overrie w/ dimensionality check
void geoalgo::Trajectory::push_back ( const Point_t obj)

push_back overrie w/ dimensionality check

void geoalgo::Trajectory::push_back ( const Point_t obj)

push_back overrie w/ dimensionality check

Definition at line 59 of file larcorealg/larcorealg/GeoAlgo/GeoTrajectory.cxx.

59  {
60  compat(obj);
61  if (!(size() && obj == (*rbegin())))
62  std::vector<geoalgo::Point_t>::push_back(obj);
63  }
void compat(const Point_t &obj) const
Dimensionality check function w/ Trajectory.
std::size_t size(FixedBins< T, C > const &) noexcept
Definition: FixedBins.h:561
template<class T >
void geoalgo::Trajectory::push_back ( const T &  obj)
inline

push_back template

Definition at line 76 of file sbncode/sbncode/OpT0Finder/flashmatch/GeoAlgo/GeoTrajectory.h.

77  { Point_t pt(obj); push_back(pt); }
recob::tracking::Point_t Point_t
void push_back(const Point_t &obj)
push_back overrie w/ dimensionality check
template<class T >
void geoalgo::Trajectory::push_back ( const T &  obj)
inline

push_back template

Definition at line 80 of file larcorealg/larcorealg/GeoAlgo/GeoTrajectory.h.

81  { Point_t pt(obj); push_back(pt); }
recob::tracking::Point_t Point_t
void push_back(const Point_t &obj)
push_back overrie w/ dimensionality check

Friends And Related Function Documentation

std::ostream& operator<< ( std::ostream &  o,
Trajectory const &  a 
)
friend

Streamer.

Definition at line 83 of file sbncode/sbncode/OpT0Finder/flashmatch/GeoAlgo/GeoTrajectory.h.

84  { o << "Trajectory with " << a.size() << " points " << std::endl;
85  for(auto const& p : a )
86  o << " " << p << std::endl;
87  return o;
88  }
pdgs p
Definition: selectors.fcl:22
process_name gaushit a
std::ostream& operator<< ( std::ostream &  o,
Trajectory const &  a 
)
friend

Streamer.

Definition at line 87 of file larcorealg/larcorealg/GeoAlgo/GeoTrajectory.h.

88  { o << "Trajectory with " << a.size() << " points " << std::endl;
89  for(auto const& p : a )
90  o << " " << p << std::endl;
91  return o;
92  }
pdgs p
Definition: selectors.fcl:22
process_name gaushit a

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