LArSoft  v09_90_00
Liquid Argon Software toolkit - https://larsoft.org/
GeoTrajectory.h
Go to the documentation of this file.
1 
14 #ifndef BASICTOOL_GEOTRAJECTORY_H
15 #define BASICTOOL_GEOTRAJECTORY_H
16 
18 
19 #include <ostream>
20 #include <stddef.h>
21 #include <vector>
22 
23 namespace geoalgo {
24 
31  class Trajectory : public std::vector<geoalgo::Vector> {
32 
33  public:
35  Trajectory(size_t npoints = 0, size_t ndimension = 0);
36 
38  virtual ~Trajectory() {}
39 
41  Trajectory(const std::vector<std::vector<double>>& obj);
42 
44  Trajectory(const std::vector<geoalgo::Point_t>& obj);
45 
46  //
47  // Getters
48  //
49  double Length(size_t start_step = 0,
50  size_t end_step = 0) const;
51  bool IsLonger(double) const;
52  Vector Dir(size_t i = 0) const;
53 
54  //
55  // Setters
56  //
57  void push_back(const Point_t& obj);
58 
59  inline Trajectory& operator+=(const Point_t& rhs)
60  {
61  push_back(rhs);
62  return *this;
63  }
64 
65  //
66  // utility
67  //
68  void compat(const Point_t& obj) const;
69  void compat(const Trajectory& obj) const;
70 
71  protected:
73  Vector _Dir_(size_t i) const;
74 
75  public:
76  //
77  // templates
78  //
80  template <class T>
81  void push_back(const T& obj)
82  {
83  Point_t pt(obj);
84  push_back(pt);
85  }
86 
87  public:
89 #ifndef __CINT__
90  friend std::ostream& operator<<(std::ostream& o, Trajectory const& a)
91  {
92  o << "Trajectory with " << a.size() << " points " << std::endl;
93  for (auto const& p : a)
94  o << " " << p << std::endl;
95  return o;
96  }
97 #endif
98  };
99 
101 
102 }
103 
104 #endif
105  // end of doxygen group
void push_back(const T &obj)
push_back template
Definition: GeoTrajectory.h:81
void compat(const Point_t &obj) const
Dimensionality check function w/ Trajectory.
virtual ~Trajectory()
Default dtor.
Definition: GeoTrajectory.h:38
Trajectory & operator+=(const Point_t &rhs)
Definition: GeoTrajectory.h:59
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:289
Class def header for a class Point and Vector.
TMarker * pt
Definition: egs.C:25
friend std::ostream & operator<<(std::ostream &o, Trajectory const &a)
Streamer.
Definition: GeoTrajectory.h:90
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.
Trajectory Trajectory_t
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.