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