All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
sbncode/sbncode/OpT0Finder/flashmatch/GeoAlgo/GeoTrajectory.h
Go to the documentation of this file.
1 /**
2  * \file GeoObjects.h
3  *
4  * \ingroup GeoAlgo
5  *
6  * \brief Class def header for a class Trajectory
7  *
8  * @author kazuhiro
9  */
10 
11 /** \addtogroup GeoAlgo
12 
13  @{*/
14 #ifndef BASICTOOL_GEOTRAJECTORY_H
15 #define BASICTOOL_GEOTRAJECTORY_H
16 
17 #include "GeoVector.h"
18 
19 namespace geoalgo {
20 
21  /**
22  \class Trajectory
23  This class represents a trajectory which is an ordered list of Point.
24  It is a friend class w/ geoalgo::Point_t hence it has an access to protected functions that avoids
25  dimensionality sanity checks for speed.
26  */
27  class Trajectory : public std::vector<geoalgo::Vector> {
28 
29  public:
30 
31  /// Default ctor to specify # points and dimension of each point
32  Trajectory(size_t npoints=0, size_t ndimension=0);
33 
34  /// Default dtor
35  virtual ~Trajectory(){}
36 
37  /// Alternative ctor (0) using a vector of mere vector point expression
38  Trajectory(const std::vector<std::vector<double> > &obj);
39 
40  /// Alternative ctor (1) using a vector of point
41  Trajectory(const std::vector<geoalgo::Point_t> &obj);
42 
43  //
44  // Getters
45  //
46  double Length(size_t start_step=0,size_t end_step=0) const; ///< The summed-length along all trajectory points
47  bool IsLonger(double) const; ///< Check if the trajectory is longer than specified value
48  Vector Dir(size_t i=0) const; ///< The direction at a specified trajectory point
49 
50  //
51  // Setters
52  //
53  void push_back(const Point_t& obj); ///< push_back overrie w/ dimensionality check
54 
55  inline Trajectory& operator+=(const Point_t& rhs)
56  { push_back(rhs); return *this; }
57 
58  //
59  // utility
60  //
61  void compat(const Point_t& obj) const; ///< Dimensionality check function w/ Trajectory
62  void compat(const Trajectory &obj) const; ///< Dimensionality check function w/ Point_t
63 
64  protected:
65 
66  /// Returns a direction vector at a specified trajectory point w/o size check
67  Vector _Dir_(size_t i) const;
68 
69  public:
70 
71  //
72  // templates
73  //
74  /// push_back template
75  template <class T>
76  void push_back(const T& obj)
77  { Point_t pt(obj); push_back(pt); }
78 
79  public:
80 
81  /// Streamer
82 #ifndef __CINT__
83  friend std::ostream& operator << (std::ostream &o, Trajectory const& a)
84  { o << "Trajectory with " << a.size() << " points " << std::endl;
85  for(auto const& p : a )
86  o << " " << p << std::endl;
87  return o;
88  }
89 #endif
90 
91  };
92 
93  typedef Trajectory Trajectory_t;
94 
95 }
96 
97 #endif
98 /** @} */ // end of doxygen group
99 
void compat(const Point_t &obj) const
Dimensionality check function w/ Trajectory.
pdgs p
Definition: selectors.fcl:22
process_name gaushit a
Trajectory(size_t npoints=0, size_t ndimension=0)
Default ctor to specify # points and dimension of each point.
void push_back(const Point_t &obj)
push_back overrie w/ dimensionality check
auto vector(Vector const &v)
Returns a manipulator which will print the specified array.
Definition: DumpUtils.h:265
friend std::ostream & operator<<(std::ostream &o, Trajectory const &a)
Streamer.
double Length(size_t start_step=0, size_t end_step=0) const
The summed-length along all trajectory points.
Vector Dir(size_t i=0) const
The direction at a specified trajectory point.
bool IsLonger(double) const
Check if the trajectory is longer than specified value.
Vector _Dir_(size_t i) const
Returns a direction vector at a specified trajectory point w/o size check.