Track.h
Go to the documentation of this file.
1 ////////////////////////////////////////////////////////////////////////
2 // \file Track.h
3 // \brief A track is a \ref rb::Prong with full reconstructed trajectory.
4 // \version $Id: Track.h,v 1.15 2012-10-26 21:31:55 bckhouse Exp $
5 // \author Christopher Backhouse - bckhouse@caltech.edu
6 // \date $Date: 2012-10-26 21:31:55 $
7 ////////////////////////////////////////////////////////////////////////
8 #ifndef RBTRACK_H
9 #define RBTRACK_H
10 
11 #include "RecoBase/Prong.h"
12 
13 #include <vector>
14 #include <utility>
15 #include <map>
16 
17 namespace rb
18 {
19  /// \brief A \ref rb::Prong with full reconstructed trajectory
20  class Track : public Prong
21  {
22  public:
23  /// \name Constructors
24  ///
25  /// See \ref rb::Prong documentation
26  //@{
27  Track(){}
28 #ifndef __GCCXML__
30  TVector3 start,
31  TVector3 dir,
32  int id = 0);
35  double v0,
36  double z0,
37  double dv,
38  double dz,
39  int id = 0);
40  Track(const std::vector< art::Ptr<rb::CellHit> >& cells,
41  geo::View_t view,
42  double v0,
43  double z0,
44  double dv,
45  double dz,
46  int id = 0);
47  Track(const rb::Cluster& clust,
48  TVector3 start,
49  TVector3 dir,
50  int id = 0);
51  Track(const rb::Cluster& clust,
52  double v0,
53  double z0,
54  double dv,
55  double dz,
56  int id = 0);
57  Track(const rb::Prong& prong,
58  int id = 0);
60  std::vector<double> const& weights,
61  std::vector<TVector3> const& trajectory,
62  TVector3 const& start,
63  TVector3 const& dir,
64  int const& id,
65  geo::View_t view
66  );
67 
68 
69  //@}
70 #endif // __GCCXML__
71  virtual ~Track();
72 #ifndef __GCCXML__
73 
74  void AppendTrajectoryPoint(TVector3 pt);
75  void AppendTrajectoryPoint(double pv, double pz);
76 
77  /// \brief Support constructing tracks backwards
78  ///
79  /// Note: This function also sets the track start to \a pt
80  void PrependTrajectoryPoint(TVector3 pt);
81  void PrependTrajectoryPoint(double pv, double pz);
82 
83  size_t NTrajectoryPoints() const {return fTraj.size();}
84 
85  /// \brief return a constant reference to the track trajectory points
86  std::vector<TVector3> const& Trajectory() const { return fTraj; }
87 
88  /// The ith point on the trajectory, a 3-vector in cm
89  TVector3 TrajectoryPoint(unsigned int i) const;
90 
91  // Need to override these to set the first trajectory point
92  virtual void SetStart(TVector3 start);
93  virtual void SetStart(double v0, double z0);
94 
95  /// Position of the final trajectory point
96  TVector3 Stop() const;
97 
98  /// Get direction at the stop point
99  virtual TVector3 StopDir() const;
100 
101  /// \brief Length (cm) of all the track segments
102  ///
103  /// ie This measure follows any curvature in the track
104  virtual double TotalLength() const;
105 
106  virtual double DistanceFromStart(double z) const;
107  virtual double DistanceFromEnd (double z) const;
108 
109  /// \brief Estimate the unmeasured coordinate of \a chit
110  ///
111  /// For \ref Track, this is calculated by taking the position of the
112  /// straight line defined by the two neighbouring trajectory points at
113  /// the z-coordinate of the cell. In the case of a hit beyond the end of
114  /// the track, the line defined by the two hits at the end is extrapolated.
115  ///
116  /// \param chit Any \ref CellHit, not necessarily owned by this container
117  /// \return Estimated unmeasured coordinate of this hit (cm) assuming
118  /// it to be associated with this reconstructed object.
119  virtual double W(const rb::CellHit* chit) const;
120 
121  /// \param z Coordinate at which trajectory is to be evaluated
122  /// \param [out] x x-position of trajectory at this z
123  /// \param [out] y y-position of trajectory at this z
124  virtual void InterpolateXY(double z, double& x, double& y) const;
125 
126  /// \param z Coordinate at which trajectory is to be evaluated
127  /// \return The track direction estimated at that point
128  virtual TVector3 InterpolateDir(double z) const;
129 
130  /// Forget about all trajectory points
131  void ClearTrajectoryPoints();
132 
133  /// Remove the ith trajectory point from the track
134  void RemoveTrajectoryPoint(unsigned int i);
135 
136  /// Combine with a 2D track from the other view to make a 3D track
137  rb::Track ZipWith(const rb::Track& trk) const;
138 
139 
140  /// map of the direction cosines at each plane (ie z)
141  std::map<unsigned int, TVector3> PlaneDirMap() const;
142 
143 #endif // __GCCXML__
144  protected:
145 
146 #ifndef __GCCXML__
147 
148  /// Helper function for \ref W
149  void FindNeighbouringPoints(double z, TVector3& pt0, TVector3& pt1) const;
150 
151  void FindNeighbouringPointIndices(double z, int& i0, int& i1) const;
152 
153  /// Helper function for \ref InterpolateXY and \ref ZipWith
154  void InterpolatePts(double z,
155  const TVector3& a, const TVector3& b,
156  double& x, double& y) const;
157 
158 #endif // __GCCXML__
159 
160  std::vector<TVector3> fTraj;
161  };
162 
163 #ifndef __GCCXML__
164  /// Helper for \ref SortTracksByTime. Is \a a earlier than \a b?
166  const art::Ptr<rb::Track>& b);
167 
168  /// Sort \a t in time order (earliest to latest).
169  void SortTracksByTime(std::vector<art::Ptr<rb::Track>>& t);
170 
171  /// Sort \a t in time order (earliest to latest).
173 
174 #endif // __GCCXML__
175 
176 }
177 
178 #endif // RBTRACK_H
Track()
Definition: Track.h:27
void FindNeighbouringPointIndices(double z, int &i0, int &i1) const
Definition: Track.cxx:380
size_t NTrajectoryPoints() const
Definition: Track.h:83
virtual void SetStart(TVector3 start)
Definition: Track.cxx:168
TVector3 TrajectoryPoint(unsigned int i) const
The ith point on the trajectory, a 3-vector in cm.
Definition: Track.cxx:158
virtual double W(const rb::CellHit *chit) const
Estimate the unmeasured coordinate of chit.
Definition: Track.cxx:281
enum geo::_plane_proj View_t
Enumerate the possible plane projections.
A collection of associated CellHits.
Definition: Cluster.h:47
A rb::Prong with full reconstructed trajectory.
Definition: Track.h:20
virtual ~Track()
Definition: Track.cxx:107
virtual double TotalLength() const
Length (cm) of all the track segments.
Definition: Track.cxx:213
Track finder for cosmic rays.
void SortTracksByTime(std::vector< art::Ptr< rb::Track >> &t)
Sort t in time order (earliest to latest).
Definition: Track.cxx:539
void InterpolatePts(double z, const TVector3 &a, const TVector3 &b, double &x, double &y) const
Helper function for InterpolateXY and ZipWith.
Definition: Track.cxx:336
double dz[NP][NC]
const double a
void AppendTrajectoryPoint(TVector3 pt)
Definition: Track.cxx:112
void FindNeighbouringPoints(double z, TVector3 &pt0, TVector3 &pt1) const
Helper function for W.
Definition: Track.cxx:432
rb::Track ZipWith(const rb::Track &trk) const
Combine with a 2D track from the other view to make a 3D track.
Definition: Track.cxx:442
void ClearTrajectoryPoints()
Forget about all trajectory points.
Definition: Track.cxx:359
Var weights
void PrependTrajectoryPoint(TVector3 pt)
Support constructing tracks backwards.
Definition: Track.cxx:134
Perform a "2 point" Hough transform on a collection of hits.
z
Definition: test.py:28
virtual double DistanceFromStart(double z) const
Definition: Track.cxx:229
std::map< unsigned int, TVector3 > PlaneDirMap() const
map of the direction cosines at each plane (ie z)
Definition: Track.cxx:496
A rawdata::RawDigit with channel information decoded.
Definition: CellHit.h:27
A Cluster with defined start position and direction.
Definition: Prong.h:19
virtual TVector3 StopDir() const
Get direction at the stop point.
Definition: Track.cxx:193
TDirectory * dir
Definition: macro.C:5
bool CompareTracksByTime(const art::Ptr< rb::Track > &a, const art::Ptr< rb::Track > &b)
Helper for SortTracksByTime. Is a earlier than b?
Definition: Track.cxx:532
std::vector< TVector3 > const & Trajectory() const
return a constant reference to the track trajectory points
Definition: Track.h:86
const hit & b
Definition: hits.cxx:21
virtual TVector3 InterpolateDir(double z) const
Definition: Track.cxx:348
void RemoveTrajectoryPoint(unsigned int i)
Remove the ith trajectory point from the track.
Definition: Track.cxx:367
std::vector< TVector3 > fTraj
Definition: Track.h:160
virtual void InterpolateXY(double z, double &x, double &y) const
Definition: Track.cxx:325
TVector3 Stop() const
Position of the final trajectory point.
Definition: Track.cxx:186
virtual double DistanceFromEnd(double z) const
Definition: Track.cxx:255