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

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

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

Default dtor.

Definition at line 39 of file 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 GeoTrajectory.cxx.

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
p
Definition: test.py:223
Vector Point_t
Definition: GeoVector.h:196
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.

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
p
Definition: test.py:223

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.

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.

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  }
void msg(const char *fmt,...)
Definition: message.cpp:107
decltype(auto) constexpr size(T &&obj)
ADL-aware version of std::size.
Definition: StdUtils.h:92
decltype(auto) constexpr begin(T &&obj)
ADL-aware version of std::begin.
Definition: StdUtils.h:72
QTextStream & endl(QTextStream &s)
void geoalgo::Trajectory::compat ( const Trajectory obj) const

Dimensionality check function w/ Point_t.

Definition at line 78 of file 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  }
void msg(const char *fmt,...)
Definition: message.cpp:107
decltype(auto) constexpr size(T &&obj)
ADL-aware version of std::size.
Definition: StdUtils.h:92
decltype(auto) constexpr begin(T &&obj)
ADL-aware version of std::begin.
Definition: StdUtils.h:72
QTextStream & endl(QTextStream &s)
Vector geoalgo::Trajectory::Dir ( size_t  i = 0) const

The direction at a specified trajectory point.

Definition at line 93 of file 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  }
void msg(const char *fmt,...)
Definition: message.cpp:107
decltype(auto) constexpr size(T &&obj)
ADL-aware version of std::size.
Definition: StdUtils.h:92
Vector _Dir_(size_t i) const
Returns a direction vector at a specified trajectory point w/o size check.
QTextStream & endl(QTextStream &s)
bool geoalgo::Trajectory::IsLonger ( double  ref) const

Check if the trajectory is longer than specified value.

Definition at line 44 of file 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  }
decltype(auto) constexpr size(T &&obj)
ADL-aware version of std::size.
Definition: StdUtils.h:92
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.

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  }
decltype(auto) constexpr size(T &&obj)
ADL-aware version of std::size.
Definition: StdUtils.h:92
Trajectory& geoalgo::Trajectory::operator+= ( const Point_t rhs)
inline

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

Definition at line 59 of file GeoTrajectory.cxx.

59  {
60  compat(obj);
61  if (!(size() && obj == (*rbegin())))
63  }
void compat(const Point_t &obj) const
Dimensionality check function w/ Trajectory.
decltype(auto) constexpr size(T &&obj)
ADL-aware version of std::size.
Definition: StdUtils.h:92
fInnerVessel push_back(Point(-578.400000, 0.000000, 0.000000))
template<class T >
void geoalgo::Trajectory::push_back ( const T &  obj)
inline

push_back template

Definition at line 80 of file GeoTrajectory.h.

81  { Point_t pt(obj); push_back(pt); }
ROOT::Math::PositionVector3D< ROOT::Math::Cartesian3D< double >> 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 87 of file 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  }
const double a
p
Definition: test.py:223
QTextStream & endl(QTextStream &s)

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