Jpp  master_rocky
the software that should make you happy
JTrack3D.hh
Go to the documentation of this file.
1 #ifndef __JTRACK3D__
2 #define __JTRACK3D__
3 
4 #include <istream>
5 #include <ostream>
6 
7 #include "JPhysics/JConstants.hh"
8 #include "JGeometry3D/JAxis3D.hh"
9 #include "JGeometry3D/JTime.hh"
10 #include "JGeometry3D/JVertex3D.hh"
11 #include "JIO/JSerialisable.hh"
12 
13 
14 /**
15  * \author mdejong
16  */
17 
18 namespace JGEOMETRY3D {}
19 namespace JPP { using namespace JGEOMETRY3D; }
20 
21 namespace JGEOMETRY3D {
22 
23  using JIO::JReader;
24  using JIO::JWriter;
25 
26 
27  /**
28  * 3D track.
29  */
30  class JTrack3D :
31  public JAxis3D,
32  public JTime
33  {
34  public:
35 
36  using JTime::getT;
37  using JTime::add;
38  using JTime::sub;
39  using JAxis3D::add;
40  using JAxis3D::sub;
42 
43 
44  /**
45  * Default constructor.
46  */
48  JAxis3D(),
49  JTime ()
50  {}
51 
52 
53  /**
54  * Constructor.
55  *
56  * \param axis track axis
57  * \param t0 time at vertex
58  */
59  JTrack3D(const JAxis3D& axis,
60  const JTime& t0) :
61  JAxis3D(axis),
62  JTime (t0)
63  {}
64 
65 
66  /**
67  * Constructor.
68  *
69  * \param pos position
70  * \param dir direction
71  * \param t0 time at vertex
72  */
73  JTrack3D(const JVector3D& pos,
74  const JVersor3D& dir,
75  const JTime& t0) :
76  JAxis3D(pos, dir),
77  JTime (t0)
78  {}
79 
80 
81  /**
82  * Constructor.
83  *
84  * \param vertex vertex
85  * \param dir direction
86  */
87  JTrack3D(const JVertex3D& vertex,
88  const JVersor3D& dir) :
89  JAxis3D(vertex.getPosition(), dir),
90  JTime (vertex.getT())
91  {}
92 
93 
94  /**
95  * Get vertex of this track.
96  *
97  * \return vertex
98  */
100  {
101  return JVertex3D(getPosition(), getT());
102  }
103 
104 
105 
106  /**
107  * Move vertex along this track with given velocity.
108  *
109  * \param step step
110  * \param velocity velocity
111  */
112  void move(const double step, const double velocity)
113  {
114  JAxis3D::move(step);
115 
116  __t += step / velocity;
117  }
118 
119 
120  /**
121  * Get arrival time of Cherenkov light at given position.
122  *
123  * \param pos position [m]
124  * \return time [ns]
125  */
126  inline double getT(const JVector3D& pos) const
127  {
128  using namespace JPHYSICS;
129 
130  JPosition3D D(pos);
131 
132  D.sub(this->getPosition());
133 
134  const double dz = D.getDot(this->getDirection());
135  const double rt = sqrt(D.getLengthSquared() - dz*dz);
136 
137  return this->getT() + (dz + rt * getKappaC()) * getInverseSpeedOfLight();
138  }
139 
140 
141  /**
142  * Get photon direction of Cherenkov light on PMT.
143  *
144  * \param pos PMT position
145  * \return direction
146  */
147  inline JVersor3D getDirection(const JVector3D& pos) const
148  {
149  using namespace JPHYSICS;
150 
151  JPosition3D D(pos);
152 
153  D.sub(this->getPosition());
154 
155  const double dz = D.getDot(this->getDirection());
156  const double R = sqrt(D.getLengthSquared() - dz*dz);
157 
158  D.sub(JPosition3D(this->getDirection()) * (dz - R/getTanThetaC()));
159 
160  return JDirection3D(D);
161  }
162 
163 
164  /**
165  * Get cosine angle of impact of Cherenkov light on PMT.
166  *
167  * \param axis PMT axis
168  * \return cosine angle of impact
169  */
170  inline double getDot(const JAxis3D& axis) const
171  {
172  return getDirection(axis.getPosition()).getDot(axis.getDirection());
173  }
174 
175 
176  /**
177  * Get cosine angle of emission of Cherenkov light on PMT.
178  *
179  * \param pos PMT position
180  * \return cosine angle of impact
181  */
182  inline double getDot(const JVector3D& pos) const
183  {
184  return JDirection3D(pos - getPosition()).getDot(getDirection());
185  }
186 
187 
188  /**
189  * Read track from input.
190  *
191  * \param in input stream
192  * \param track track
193  * \return input stream
194  */
195  friend inline std::istream& operator>>(std::istream& in, JTrack3D& track)
196  {
197  in >> static_cast<JAxis3D&>(track);
198  in >> static_cast<JTime&> (track);
199 
200  return in;
201  }
202 
203 
204  /**
205  * Write track to output.
206  *
207  * \param out output stream
208  * \param track track
209  * \return output stream
210  */
211  friend inline std::ostream& operator<<(std::ostream& out, const JTrack3D& track)
212  {
213  out << static_cast<const JAxis3D&>(track);
214  out << ' ';
215  out << static_cast<const JTime&> (track);
216 
217  return out;
218  }
219 
220 
221  /**
222  * Read track from input.
223  *
224  * \param in reader
225  * \param track track
226  * \return reader
227  */
228  friend inline JReader& operator>>(JReader& in, JTrack3D& track)
229  {
230  in >> static_cast<JAxis3D&>(track);
231  in >> static_cast<JTime&> (track);
232 
233  return in;
234  }
235 
236 
237  /**
238  * Write track to output.
239  *
240  * \param out writer
241  * \param track track
242  * \return writer
243  */
244  friend inline JWriter& operator<<(JWriter& out, const JTrack3D& track)
245  {
246  out << static_cast<const JAxis3D&>(track);
247  out << static_cast<const JTime&> (track);
248 
249  return out;
250  }
251  };
252 }
253 
254 #endif
Physics constants.
Axis object.
Definition: JAxis3D.hh:41
void move(const double step)
Move vertex along this axis.
Definition: JAxis3D.hh:134
JDirection3D()
Default constructor.
Definition: JDirection3D.hh:43
const JDirection3D & getDirection() const
Get direction.
double getDot(const JAngle3D &angle) const
Get dot product.
Data structure for position in three dimensions.
Definition: JPosition3D.hh:38
const JPosition3D & getPosition() const
Get position.
Definition: JPosition3D.hh:130
double getDot(const JAngle3D &angle) const
Get dot product.
Definition: JPosition3D.hh:378
JPosition3D()
Default constructor.
Definition: JPosition3D.hh:48
JTime & add(const JTime &value)
Addition operator.
JTime & sub(const JTime &value)
Subtraction operator.
double getT() const
Get time.
friend JWriter & operator<<(JWriter &out, const JTrack3D &track)
Write track to output.
Definition: JTrack3D.hh:244
JTrack3D(const JVector3D &pos, const JVersor3D &dir, const JTime &t0)
Constructor.
Definition: JTrack3D.hh:73
friend std::ostream & operator<<(std::ostream &out, const JTrack3D &track)
Write track to output.
Definition: JTrack3D.hh:211
double getDot(const JAxis3D &axis) const
Get cosine angle of impact of Cherenkov light on PMT.
Definition: JTrack3D.hh:170
JTrack3D()
Default constructor.
Definition: JTrack3D.hh:47
double getDot(const JVector3D &pos) const
Get cosine angle of emission of Cherenkov light on PMT.
Definition: JTrack3D.hh:182
double getT(const JVector3D &pos) const
Get arrival time of Cherenkov light at given position.
Definition: JTrack3D.hh:126
void move(const double step, const double velocity)
Move vertex along this track with given velocity.
Definition: JTrack3D.hh:112
JVersor3D getDirection(const JVector3D &pos) const
Get photon direction of Cherenkov light on PMT.
Definition: JTrack3D.hh:147
friend JReader & operator>>(JReader &in, JTrack3D &track)
Read track from input.
Definition: JTrack3D.hh:228
JTrack3D(const JAxis3D &axis, const JTime &t0)
Constructor.
Definition: JTrack3D.hh:59
double getT() const
Get time.
friend std::istream & operator>>(std::istream &in, JTrack3D &track)
Read track from input.
Definition: JTrack3D.hh:195
JTrack3D(const JVertex3D &vertex, const JVersor3D &dir)
Constructor.
Definition: JTrack3D.hh:87
JVertex3D getVertex() const
Get vertex of this track.
Definition: JTrack3D.hh:99
Data structure for vector in three dimensions.
Definition: JVector3D.hh:36
JVector3D & add(const JVector3D &vector)
Add vector.
Definition: JVector3D.hh:142
double getLengthSquared() const
Get length squared.
Definition: JVector3D.hh:235
JVector3D & sub(const JVector3D &vector)
Subtract vector.
Definition: JVector3D.hh:158
Data structure for normalised vector in three dimensions.
Definition: JVersor3D.hh:28
Interface for binary input.
Interface for binary output.
Auxiliary classes and methods for 3D geometrical objects and operations.
Definition: JAngle3D.hh:19
Auxiliary methods for light properties of deep-sea water.
double getKappaC()
Get average R-dependence of arrival time of Cherenkov light (a.k.a.
const double getInverseSpeedOfLight()
Get inverse speed of light.
double getTanThetaC()
Get average tangent of Cherenkov angle of water corresponding to group velocity.
This name space includes all other name spaces (except KM3NETDAQ, KM3NET and ANTARES).