Jpp
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
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
Interface for binary output.
do echo Generating $dir eval D
Definition: JDrawLED.sh:50
friend JReader & operator>>(JReader &in, JVertex3D &vertex)
Read vertex from input.
Definition: JVertex3D.hh:220
JVector3D & mul(const double factor)
Scale vector.
Definition: JVector3D.hh:173
Auxiliary base class for aritmetic operations of derived class types.
Definition: JMath.hh:26
double getT() const
Get time.
friend std::ostream & operator<<(std::ostream &out, const JVertex3D &vertex)
Write vertex to output.
Definition: JVertex3D.hh:203
double getIndexOfRefraction()
Get average index of refraction of water.
Definition: JConstants.hh:111
JTime & sub(const JTime &value)
Subtraction operator.
const JDirection3D & getDirection() const
Get direction.
double getDot(const JAxis3D &axis) const
Get cosine angle of impact of Cherenkov light on PMT.
Definition: JVertex3D.hh:174
esac print_variable DETECTOR INPUT_FILE OUTPUT_FILE CDF for TYPE in
Definition: JSirene.sh:45
JVertex3D & add(const JVertex3D &value)
Addition operator.
Definition: JVertex3D.hh:84
JTime & div(const double value)
Division operator.
JTime & negate()
Prefix unary minus.
double getDistance(const JVector3D &pos) const
Get distance to point.
Definition: JVector3D.hh:269
JVertex3D & negate()
Prefix unary minus.
Definition: JVertex3D.hh:70
JVertex3D & div(const double value)
Division operator.
Definition: JVertex3D.hh:129
JVertex3D & sub(const JVertex3D &value)
Subtraction operator.
Definition: JVertex3D.hh:99
JTime & add(const JTime &value)
Addition operator.
JVertex3D()
Default constructor.
Definition: JVertex3D.hh:46
Axis object.
Definition: JAxis3D.hh:38
JTime & mul(const double value)
Multiplication operator.
const double getInverseSpeedOfLight()
Get inverse speed of light.
Definition: JConstants.hh:100
Constants.
JVector3D & sub(const JVector3D &vector)
Subtract vector.
Definition: JVector3D.hh:157
Data structure for vector in three dimensions.
Definition: JVector3D.hh:33
JVertex3D & mul(const double value)
Multiplication operator.
Definition: JVertex3D.hh:114
Interface for binary input.
const JPosition3D & getPosition() const
Get position.
Definition: JPosition3D.hh:129
JVersor3D getDirection(const JVector3D &pos) const
Get photon direction of Cherenkov light on PMT.
Definition: JVertex3D.hh:158
Base class for data structures with artithmetic capabilities.
JVertex3D(const JVector3D &pos, const double t)
Constructor.
Definition: JVertex3D.hh:58
Data structure for position in three dimensions.
Definition: JPosition3D.hh:35
JVector3D & negate()
Negate vector.
Definition: JVector3D.hh:125
JVector3D & div(const double factor)
Scale vector.
Definition: JVector3D.hh:189
Data structure for normalised vector in three dimensions.
Definition: JVersor3D.hh:23
double getT(const JVector3D &pos) const
Get arrival time of Cherenkov light at given position.
Definition: JVertex3D.hh:144
JVector3D & add(const JVector3D &vector)
Add vector.
Definition: JVector3D.hh:141
friend std::istream & operator>>(std::istream &in, JVertex3D &vertex)
Read vertex from input.
Definition: JVertex3D.hh:187
friend JWriter & operator<<(JWriter &out, const JVertex3D &vertex)
Write vertex to output.
Definition: JVertex3D.hh:236