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