LArSoft  v07_13_02
Liquid Argon Software toolkit - http://larsoft.org/
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...
 

Public Attributes

elements
 STL member. More...
 

Protected Member Functions

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...
 

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 27 of file 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 GeoTrajectory.cxx.

Referenced by ~Trajectory().

9  : std::vector<geoalgo::Point_t>(npoints, Point_t(ndimension))
10  {}
Vector Point_t
Definition: GeoVector.h:200
virtual geoalgo::Trajectory::~Trajectory ( )
inlinevirtual

Default dtor.

Definition at line 35 of file GeoTrajectory.h.

References Dir(), IsLonger(), Length(), push_back(), Trajectory(), and lar::dump::vector().

35 {}
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 GeoTrajectory.cxx.

References push_back().

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

Alternative ctor (1) using a vector of point.

Definition at line 18 of file GeoTrajectory.cxx.

References push_back().

19  {
20  this->reserve(obj.size());
21  for(auto const& p : obj) this->push_back(p);
22  }
void push_back(const Point_t &obj)
push_back overrie w/ dimensionality check

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.

Definition at line 104 of file GeoTrajectory.cxx.

Referenced by Dir(), and operator+=().

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.

Definition at line 65 of file GeoTrajectory.cxx.

References evd::details::begin().

Referenced by geoalgo::GeoAlgo::ClosestPt(), geoalgo::GeoAlgo::commonOrigin(), geoalgo::GeoAlgo::Intersection(), operator+=(), push_back(), and geoalgo::GeoAlgo::SqDist().

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::vector< evd::details::RawDigitInfo_t >::const_iterator begin(RawDigitCacheDataClass const &cache)
void geoalgo::Trajectory::compat ( const Trajectory obj) const

Dimensionality check function w/ Point_t.

Definition at line 78 of file GeoTrajectory.cxx.

References evd::details::begin().

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::vector< evd::details::RawDigitInfo_t >::const_iterator begin(RawDigitCacheDataClass const &cache)
Vector geoalgo::Trajectory::Dir ( size_t  i = 0) const

The direction at a specified trajectory point.

Definition at line 93 of file GeoTrajectory.cxx.

References _Dir_().

Referenced by ~Trajectory().

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  }
Vector _Dir_(size_t i) const
Returns a direction vector at a specified trajectory point w/o size check.
bool geoalgo::Trajectory::IsLonger ( double  ref) const

Check if the trajectory is longer than specified value.

Definition at line 44 of file GeoTrajectory.cxx.

Referenced by ~Trajectory().

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  }
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 GeoTrajectory.cxx.

Referenced by ~Trajectory().

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  }
Trajectory& geoalgo::Trajectory::operator+= ( const Point_t rhs)
inline

Definition at line 55 of file GeoTrajectory.h.

References _Dir_(), compat(), and push_back().

56  { 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

Definition at line 59 of file GeoTrajectory.cxx.

References compat().

Referenced by operator+=(), push_back(), Trajectory(), and ~Trajectory().

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.
template<class T >
void geoalgo::Trajectory::push_back ( const T &  obj)
inline

push_back template

Definition at line 76 of file GeoTrajectory.h.

References pt, and push_back().

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
TMarker * pt
Definition: egs.C:25

Friends And Related Function Documentation

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

Streamer.

Definition at line 83 of file 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  }

Member Data Documentation

T std::vector< T >::elements
inherited

STL member.


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