Jpp 20.0.0-rc.2
the software that should make you happy
Loading...
Searching...
No Matches
JVertex3D.hh
Go to the documentation of this file.
1#ifndef __JVERTEX3D__
2#define __JVERTEX3D__
3
4#include <istream>
5#include <ostream>
6
7#include "JMath/JMath.hh"
9
11#include "JGeometry3D/JTime.hh"
13
14#include "JIO/JSerialisable.hh"
15
16
17/**
18 * \author mdejong
19 */
20
21namespace JGEOMETRY3D {}
22namespace JPP { using namespace JGEOMETRY3D; }
23
24namespace JGEOMETRY3D {
25
26 using JIO::JReader;
27 using JIO::JWriter;
28 using JMATH::JMath;
29
30
31 /**
32 * 3D vertex.
33 */
34 class JVertex3D :
35 public JPosition3D,
36 public JTime,
37 public JMath<JVertex3D>
38 {
39 public:
40
41 using JPosition3D::add;
42 using JPosition3D::sub;
43 using JTime::add;
44 using JTime::sub;
45 using JTime::getT;
46
47
48 /**
49 * Default constructor.
50 */
53 JTime()
54 {}
55
56
57 /**
58 * Constructor.
59 *
60 * \param pos position
61 * \param t0 time at position
62 */
63 JVertex3D(const JVector3D& pos,
64 const JTime& t0) :
65 JPosition3D(pos),
66 JTime(t0)
67 {}
68
69
70 /**
71 * Get vertex.
72 *
73 * \return vertex
74 */
75 const JVertex3D& getVertex() const
76 {
77 return static_cast<const JVertex3D&>(*this);
78 }
79
80
81 /**
82 * Prefix unary minus.
83 *
84 * \return vertex
85 */
87 {
89 JTime ::negate();
90
91 return *this;
92 }
93
94 /**
95 * Addition operator.
96 *
97 * \param value vertex
98 * \return vertex
99 */
100 JVertex3D& add(const JVertex3D& value)
101 {
102 JPosition3D::add(value);
103 JTime ::add(value);
104
105 return *this;
106 }
107
108
109 /**
110 * Subtraction operator.
111 *
112 * \param value vertex
113 * \return vertex
114 */
115 JVertex3D& sub(const JVertex3D& value)
116 {
117 JPosition3D::sub(value);
118 JTime ::sub(value);
119
120 return *this;
121 }
122
123
124 /**
125 * Multiplication operator.
126 *
127 * \param value multiplication factor
128 * \return vertex
129 */
130 JVertex3D& mul(const double value)
131 {
132 JPosition3D::mul(value);
133 JTime ::mul(value);
134
135 return *this;
136 }
137
138
139 /**
140 * Division operator.
141 *
142 * \param value multiplication factor
143 * \return vertex
144 */
145 JVertex3D& div(const double value)
146 {
147 JPosition3D::div(value);
148 JTime ::div(value);
149
150 return *this;
151 }
152
153
154 /**
155 * Get arrival time of Cherenkov light at given position.
156 *
157 * \param pos position [m]
158 * \return time [ns]
159 */
160 inline double getT(const JVector3D& pos) const
161 {
162 using namespace JPHYSICS;
163
164 return this->getT() + this->getDistance(pos) * getInverseSpeedOfLight() * getIndexOfRefraction();
165 }
166
167
168 /**
169 * Get photon direction of Cherenkov light on PMT.
170 *
171 * \param pos PMT position
172 * \return direction
173 */
174 inline JVersor3D getDirection(const JVector3D& pos) const
175 {
176 JPosition3D D(pos);
177
178 D.sub(this->getPosition());
179
180 return JVersor3D(D);
181 }
182
183
184 /**
185 * Get cosine angle of impact of Cherenkov light on PMT.
186 *
187 * \param axis PMT axis
188 * \return cosine angle of impact
189 */
190 inline double getDot(const JAxis3D& axis) const
191 {
192 return getDirection(axis.getPosition()).getDot(axis.getDirection());
193 }
194
195
196 /**
197 * Read vertex from input.
198 *
199 * \param in input stream
200 * \param vertex vertex
201 * \return input stream
202 */
203 friend inline std::istream& operator>>(std::istream& in, JVertex3D& vertex)
204 {
205 in >> static_cast<JPosition3D&>(vertex);
206 in >> static_cast<JTime&> (vertex);
207
208 return in;
209 }
210
211
212 /**
213 * Write vertex to output.
214 *
215 * \param out output stream
216 * \param vertex vertex
217 * \return output stream
218 */
219 friend inline std::ostream& operator<<(std::ostream& out, const JVertex3D& vertex)
220 {
221 out << static_cast<const JPosition3D&>(vertex);
222 out << ' ';
223 out << static_cast<const JTime&> (vertex);
224
225 return out;
226 }
227
228
229 /**
230 * Read vertex from input.
231 *
232 * \param in reader
233 * \param vertex vertex
234 * \return reader
235 */
236 friend inline JReader& operator>>(JReader& in, JVertex3D& vertex)
237 {
238 in >> static_cast<JPosition3D&>(vertex);
239 in >> static_cast<JTime&> (vertex);
240
241 return in;
242 }
243
244
245 /**
246 * Write vertex to output.
247 *
248 * \param out writer
249 * \param vertex vertex
250 * \return writer
251 */
252 friend inline JWriter& operator<<(JWriter& out, const JVertex3D& vertex)
253 {
254 out << static_cast<const JPosition3D&>(vertex);
255 out << static_cast<const JTime&> (vertex);
256
257 return out;
258 }
259 };
260}
261
262#endif
Base class for data structures with artithmetic capabilities.
Physics constants.
Axis object.
Definition JAxis3D.hh:41
const JDirection3D & getDirection() const
Get direction.
Data structure for position in three dimensions.
const JPosition3D & getPosition() const
Get position.
JTime & add(const JTime &value)
Addition operator.
double getT() const
Get time.
JTime & sub(const JTime &value)
Subtraction operator.
Data structure for vector in three dimensions.
Definition JVector3D.hh:36
JVector3D & add(const JVector3D &vector)
Add vector.
Definition JVector3D.hh:142
JVector3D & div(const double factor)
Scale vector.
Definition JVector3D.hh:190
double getDistance(const JVector3D &pos) const
Get distance to point.
Definition JVector3D.hh:270
JVector3D & sub(const JVector3D &vector)
Subtract vector.
Definition JVector3D.hh:158
JVector3D & negate()
Negate vector.
Definition JVector3D.hh:126
JVector3D & mul(const double factor)
Scale vector.
Definition JVector3D.hh:174
Data structure for normalised vector in three dimensions.
Definition JVersor3D.hh:28
double getDot(const JVersor3D &versor) const
Get dot product.
Definition JVersor3D.hh:156
JVertex3D & sub(const JVertex3D &value)
Subtraction operator.
Definition JVertex3D.hh:115
friend JWriter & operator<<(JWriter &out, const JVertex3D &vertex)
Write vertex to output.
Definition JVertex3D.hh:252
friend std::ostream & operator<<(std::ostream &out, const JVertex3D &vertex)
Write vertex to output.
Definition JVertex3D.hh:219
JVertex3D & negate()
Prefix unary minus.
Definition JVertex3D.hh:86
double getT(const JVector3D &pos) const
Get arrival time of Cherenkov light at given position.
Definition JVertex3D.hh:160
friend std::istream & operator>>(std::istream &in, JVertex3D &vertex)
Read vertex from input.
Definition JVertex3D.hh:203
JVertex3D(const JVector3D &pos, const JTime &t0)
Constructor.
Definition JVertex3D.hh:63
JVertex3D & div(const double value)
Division operator.
Definition JVertex3D.hh:145
double getDot(const JAxis3D &axis) const
Get cosine angle of impact of Cherenkov light on PMT.
Definition JVertex3D.hh:190
const JVertex3D & getVertex() const
Get vertex.
Definition JVertex3D.hh:75
JVertex3D & mul(const double value)
Multiplication operator.
Definition JVertex3D.hh:130
double getT() const
Get time.
friend JReader & operator>>(JReader &in, JVertex3D &vertex)
Read vertex from input.
Definition JVertex3D.hh:236
JVertex3D()
Default constructor.
Definition JVertex3D.hh:51
JVersor3D getDirection(const JVector3D &pos) const
Get photon direction of Cherenkov light on PMT.
Definition JVertex3D.hh:174
JVertex3D & add(const JVertex3D &value)
Addition operator.
Definition JVertex3D.hh:100
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).
Auxiliary base class for aritmetic operations of derived class types.
Definition JMath.hh:347