Jpp 20.0.0-rc.2
the software that should make you happy
Loading...
Searching...
No Matches
JTrack3D.hh
Go to the documentation of this file.
1#ifndef __JTRACK3D__
2#define __JTRACK3D__
3
4#include <istream>
5#include <ostream>
6
8
10
12#include "JGeometry3D/JTime.hh"
14
15
16/**
17 * \author mdejong
18 */
19
20namespace JGEOMETRY3D {}
21namespace JPP { using namespace JGEOMETRY3D; }
22
23namespace JGEOMETRY3D {
24
25 using JIO::JReader;
26 using JIO::JWriter;
27
28 /**
29 * 3D track.
30 */
31 class JTrack3D :
32 public JAxis3D,
33 public JTime
34 {
35 public:
36
37 using JTime::getT;
38 using JTime::add;
39 using JTime::sub;
40 using JPosition3D::add;
41 using JPosition3D::sub;
43
44
45 /**
46 * Default constructor.
47 */
49 JAxis3D(),
50 JTime ()
51 {}
52
53
54 /**
55 * Constructor.
56 *
57 * \param axis axis
58 * \param t0 time at position
59 */
60 JTrack3D(const JAxis3D& axis,
61 const JTime& t0) :
62 JAxis3D(axis),
63 JTime (t0)
64 {}
65
66
67 /**
68 * Move position along this track with given velocity.
69 *
70 * \param step step
71 * \param velocity velocity
72 */
73 void move(const double step, const double velocity)
74 {
75 JAxis3D::move(step);
76
77 setT(getT() + step / velocity);
78 }
79
80
81 /**
82 * Get arrival time of Cherenkov light at given position.
83 *
84 * \param pos position [m]
85 * \return time [ns]
86 */
87 inline double getT(const JVector3D& pos) const
88 {
89 using namespace JPHYSICS;
90
91 JPosition3D D(pos);
92
93 D.sub(this->getPosition());
94
95 const double dz = D.getDot(this->getDirection());
96 const double rt = sqrt(D.getLengthSquared() - dz*dz);
97
98 return this->getT() + (dz + rt * getKappaC()) * getInverseSpeedOfLight();
99 }
100
101
102 /**
103 * Get photon direction of Cherenkov light on PMT.
104 *
105 * \param pos PMT position
106 * \return direction
107 */
108 inline JVersor3D getDirection(const JVector3D& pos) const
109 {
110 using namespace JPHYSICS;
111
112 JPosition3D D(pos);
113
114 D.sub(this->getPosition());
115
116 const double dz = D.getDot(this->getDirection());
117 const double R = sqrt(D.getLengthSquared() - dz*dz);
118
119 D.sub(JPosition3D(this->getDirection()) * (dz - R/getTanThetaC()));
120
121 return JDirection3D(D);
122 }
123
124
125 /**
126 * Get cosine angle of impact of Cherenkov light on PMT.
127 *
128 * \param axis PMT axis
129 * \return cosine angle of impact
130 */
131 inline double getDot(const JAxis3D& axis) const
132 {
133 return getDirection(axis.getPosition()).getDot(axis.getDirection());
134 }
135
136
137 /**
138 * Get cosine angle of emission of Cherenkov light on PMT.
139 *
140 * \param pos PMT position
141 * \return cosine angle of impact
142 */
143 inline double getDot(const JVector3D& pos) const
144 {
145 return JDirection3D(pos - getPosition()).getDot(getDirection());
146 }
147
148
149 /**
150 * Read track from input.
151 *
152 * \param in input stream
153 * \param track track
154 * \return input stream
155 */
156 friend inline std::istream& operator>>(std::istream& in, JTrack3D& track)
157 {
158 in >> static_cast<JAxis3D&>(track);
159 in >> static_cast<JTime&> (track);
160
161 return in;
162 }
163
164
165 /**
166 * Write track to output.
167 *
168 * \param out output stream
169 * \param track track
170 * \return output stream
171 */
172 friend inline std::ostream& operator<<(std::ostream& out, const JTrack3D& track)
173 {
174 out << static_cast<const JAxis3D&>(track);
175 out << ' ';
176 out << static_cast<const JTime&> (track);
177
178 return out;
179 }
180
181
182 /**
183 * Read track from input.
184 *
185 * \param in reader
186 * \param track track
187 * \return reader
188 */
189 friend inline JReader& operator>>(JReader& in, JTrack3D& track)
190 {
191 in >> static_cast<JAxis3D&>(track);
192 in >> static_cast<JTime&> (track);
193
194 return in;
195 }
196
197
198 /**
199 * Write track to output.
200 *
201 * \param out writer
202 * \param track track
203 * \return writer
204 */
205 friend inline JWriter& operator<<(JWriter& out, const JTrack3D& track)
206 {
207 out << static_cast<const JAxis3D&>(track);
208 out << static_cast<const JTime&> (track);
209
210 return out;
211 }
212 };
213}
214
215#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.
const JDirection3D & getDirection() const
Get direction.
double getDot(const JAngle3D &angle) const
Get dot product.
Data structure for position in three dimensions.
double getDot(const JAngle3D &angle) const
Get dot product.
JPosition3D()
Default constructor.
const JPosition3D & getPosition() const
Get position.
void setT(const double time)
Set time.
JTime & add(const JTime &value)
Addition operator.
double getT() const
Get time.
JTime & sub(const JTime &value)
Subtraction operator.
friend std::ostream & operator<<(std::ostream &out, const JTrack3D &track)
Write track to output.
Definition JTrack3D.hh:172
double getDot(const JAxis3D &axis) const
Get cosine angle of impact of Cherenkov light on PMT.
Definition JTrack3D.hh:131
JTrack3D()
Default constructor.
Definition JTrack3D.hh:48
double getDot(const JVector3D &pos) const
Get cosine angle of emission of Cherenkov light on PMT.
Definition JTrack3D.hh:143
double getT(const JVector3D &pos) const
Get arrival time of Cherenkov light at given position.
Definition JTrack3D.hh:87
void move(const double step, const double velocity)
Move position along this track with given velocity.
Definition JTrack3D.hh:73
JVersor3D getDirection(const JVector3D &pos) const
Get photon direction of Cherenkov light on PMT.
Definition JTrack3D.hh:108
friend std::istream & operator>>(std::istream &in, JTrack3D &track)
Read track from input.
Definition JTrack3D.hh:156
JTrack3D(const JAxis3D &axis, const JTime &t0)
Constructor.
Definition JTrack3D.hh:60
friend JWriter & operator<<(JWriter &out, const JTrack3D &track)
Write track to output.
Definition JTrack3D.hh:205
const JDirection3D & getDirection() const
Get direction.
double getT() const
Get time.
friend JReader & operator>>(JReader &in, JTrack3D &track)
Read track from input.
Definition JTrack3D.hh:189
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.
This name space includes all other name spaces (except KM3NETDAQ, KM3NET and ANTARES).