Jpp  pmt_effective_area_update_2
the software that should make you happy
 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 "JPhysics/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  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::getT;
42 
43 
44  /**
45  * Default constructor.
46  */
48  JPosition3D(),
49  JTime()
50  {}
51 
52 
53  /**
54  * Constructor.
55  *
56  * \param pos position
57  * \param t time at position
58  */
59  JVertex3D(const JVector3D& pos,
60  const double t) :
61  JPosition3D(pos),
62  JTime(t)
63  {}
64 
65 
66  /**
67  * Prefix unary minus.
68  *
69  * \return line
70  */
72  {
75 
76  return *this;
77  }
78 
79  /**
80  * Addition operator.
81  *
82  * \param value line
83  * \return line
84  */
85  JVertex3D& add(const JVertex3D& value)
86  {
87  JPosition3D::add(value);
88  JTime ::add(value);
89 
90  return *this;
91  }
92 
93 
94  /**
95  * Subtraction operator.
96  *
97  * \param value line
98  * \return line
99  */
100  JVertex3D& sub(const JVertex3D& value)
101  {
102  JPosition3D::sub(value);
103  JTime ::sub(value);
104 
105  return *this;
106  }
107 
108 
109  /**
110  * Multiplication operator.
111  *
112  * \param value multiplication factor
113  * \return line
114  */
115  JVertex3D& mul(const double value)
116  {
117  JPosition3D::mul(value);
118  JTime ::mul(value);
119 
120  return *this;
121  }
122 
123 
124  /**
125  * Division operator.
126  *
127  * \param value multiplication factor
128  * \return line
129  */
130  JVertex3D& div(const double value)
131  {
132  JPosition3D::div(value);
133  JTime ::div(value);
134 
135  return *this;
136  }
137 
138 
139  /**
140  * Get arrival time of Cherenkov light at given position.
141  *
142  * \param pos position [m]
143  * \return time [ns]
144  */
145  inline double getT(const JVector3D& pos) const
146  {
147  using namespace JPHYSICS;
148 
149  return this->getT() + this->getDistance(pos) * getInverseSpeedOfLight() * getIndexOfRefraction();
150  }
151 
152 
153  /**
154  * Get photon direction of Cherenkov light on PMT.
155  *
156  * \param pos PMT position
157  * \return direction
158  */
159  inline JVersor3D getDirection(const JVector3D& pos) const
160  {
161  JPosition3D D(pos);
162 
163  D.sub(this->getPosition());
164 
165  return JVersor3D(D);
166  }
167 
168 
169  /**
170  * Get cosine angle of impact of Cherenkov light on PMT.
171  *
172  * \param axis PMT axis
173  * \return cosine angle of impact
174  */
175  inline double getDot(const JAxis3D& axis) const
176  {
177  return getDirection(axis.getPosition()).getDot(axis.getDirection());
178  }
179 
180 
181  /**
182  * Read vertex from input.
183  *
184  * \param in input stream
185  * \param vertex vertex
186  * \return input stream
187  */
188  friend inline std::istream& operator>>(std::istream& in, JVertex3D& vertex)
189  {
190  in >> static_cast<JPosition3D&>(vertex);
191  in >> static_cast<JTime&> (vertex);
192 
193  return in;
194  }
195 
196 
197  /**
198  * Write vertex to output.
199  *
200  * \param out output stream
201  * \param vertex vertex
202  * \return output stream
203  */
204  friend inline std::ostream& operator<<(std::ostream& out, const JVertex3D& vertex)
205  {
206  out << static_cast<const JPosition3D&>(vertex);
207  out << ' ';
208  out << static_cast<const JTime&> (vertex);
209 
210  return out;
211  }
212 
213 
214  /**
215  * Read vertex from input.
216  *
217  * \param in reader
218  * \param vertex vertex
219  * \return reader
220  */
221  friend inline JReader& operator>>(JReader& in, JVertex3D& vertex)
222  {
223  in >> static_cast<JPosition3D&>(vertex);
224  in >> static_cast<JTime&> (vertex);
225 
226  return in;
227  }
228 
229 
230  /**
231  * Write vertex to output.
232  *
233  * \param out writer
234  * \param vertex vertex
235  * \return writer
236  */
237  friend inline JWriter& operator<<(JWriter& out, const JVertex3D& vertex)
238  {
239  out << static_cast<const JPosition3D&>(vertex);
240  out << static_cast<const JTime&> (vertex);
241 
242  return out;
243  }
244  };
245 }
246 
247 #endif
Interface for binary output.
friend JReader & operator>>(JReader &in, JVertex3D &vertex)
Read vertex from input.
Definition: JVertex3D.hh:221
JVector3D & mul(const double factor)
Scale vector.
Definition: JVector3D.hh:174
Auxiliary base class for aritmetic operations of derived class types.
Definition: JMath.hh:110
double getT() const
Get time.
friend std::ostream & operator<<(std::ostream &out, const JVertex3D &vertex)
Write vertex to output.
Definition: JVertex3D.hh:204
JTime & sub(const JTime &value)
Subtraction operator.
double getIndexOfRefraction()
Get average index of refraction of water corresponding to group velocity.
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:175
JVertex3D & add(const JVertex3D &value)
Addition operator.
Definition: JVertex3D.hh:85
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:270
JVertex3D & negate()
Prefix unary minus.
Definition: JVertex3D.hh:71
JVertex3D & div(const double value)
Division operator.
Definition: JVertex3D.hh:130
JVertex3D & sub(const JVertex3D &value)
Subtraction operator.
Definition: JVertex3D.hh:100
JTime & add(const JTime &value)
Addition operator.
JVertex3D()
Default constructor.
Definition: JVertex3D.hh:47
Axis object.
Definition: JAxis3D.hh:38
JTime & mul(const double value)
Multiplication operator.
JVector3D & sub(const JVector3D &vector)
Subtract vector.
Definition: JVector3D.hh:158
Data structure for vector in three dimensions.
Definition: JVector3D.hh:34
JVertex3D & mul(const double value)
Multiplication operator.
Definition: JVertex3D.hh:115
Physics constants.
Interface for binary input.
const JPosition3D & getPosition() const
Get position.
Definition: JPosition3D.hh:130
JVersor3D getDirection(const JVector3D &pos) const
Get photon direction of Cherenkov light on PMT.
Definition: JVertex3D.hh:159
const double getInverseSpeedOfLight()
Get inverse speed of light.
Base class for data structures with artithmetic capabilities.
JVertex3D(const JVector3D &pos, const double t)
Constructor.
Definition: JVertex3D.hh:59
Data structure for position in three dimensions.
Definition: JPosition3D.hh:36
JVector3D & negate()
Negate vector.
Definition: JVector3D.hh:126
JVector3D & div(const double factor)
Scale vector.
Definition: JVector3D.hh:190
Data structure for normalised vector in three dimensions.
Definition: JVersor3D.hh:26
double getT(const JVector3D &pos) const
Get arrival time of Cherenkov light at given position.
Definition: JVertex3D.hh:145
then fatal Wrong number of arguments fi set_variable DETECTOR $argv[1] set_variable INPUT_FILE $argv[2] eval JPrintDetector a $DETECTOR O IDENTIFIER eval JPrintDetector a $DETECTOR O SUMMARY source JAcoustics sh $DETECTOR_ID CHECK_EXIT_CODE typeset A TRIPODS get_tripods $WORKDIR tripod txt TRIPODS for EMITTER in
Definition: JCanberra.sh:40
do echo Generating $dir eval D
Definition: JDrawLED.sh:53
JVector3D & add(const JVector3D &vector)
Add vector.
Definition: JVector3D.hh:142
friend std::istream & operator>>(std::istream &in, JVertex3D &vertex)
Read vertex from input.
Definition: JVertex3D.hh:188
friend JWriter & operator<<(JWriter &out, const JVertex3D &vertex)
Write vertex to output.
Definition: JVertex3D.hh:237