Jpp
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
JLine3Z.hh
Go to the documentation of this file.
1 #ifndef __JLINE3Z__
2 #define __JLINE3Z__
3 
4 #include <istream>
5 #include <ostream>
6 
7 #include "JMath/JMath.hh"
8 #include "JTools/JConstants.hh"
10 #include "JGeometry3D/JVersor3Z.hh"
13 #include "JGeometry3D/JTrack3D.hh"
14 #include "JFit/JLine1Z.hh"
15 
16 
17 /**
18  * \author mdejong
19  */
20 
21 namespace JFIT {}
22 namespace JPP { using namespace JFIT; }
23 
24 namespace JFIT {
25 
29 
30 
31  /**
32  * Data structure for fit of straight line in positive z-direction.
33  * Note that the position coordinates are defined with respect to the given direction.
34  */
35  class JLine3Z :
36  public JLine1Z,
37  public JVersor3Z,
38  public JMATH::JMath<JLine3Z>
39  {
40  public:
41 
42  using JLine1Z::add;
43  using JLine1Z::sub;
44  using JLine1Z::getT;
45  using JVersor3Z::add;
46  using JVersor3Z::sub;
48 
49 
50  /**
51  * Default constructor.
52  */
53  JLine3Z() :
54  JLine1Z(),
55  JVersor3Z()
56  {}
57 
58 
59  /**
60  * Constructor.
61  *
62  * \param line line
63  */
64  JLine3Z(const JLine1Z& line) :
65  JLine1Z(line),
66  JVersor3Z()
67  {}
68 
69 
70  /**
71  * Constructor.
72  *
73  * \param line line
74  * \param dir direction
75  */
76  JLine3Z(const JLine1Z& line,
77  const JVersor3Z& dir) :
78  JLine1Z(line),
79  JVersor3Z(dir)
80  {}
81 
82 
83  /**
84  * Move vertex along this line with given velocity.
85  *
86  * \param step step
87  * \param velocity velocity
88  */
89  void move(const double step, const double velocity)
90  {
91  __x += step * getDX();
92  __y += step * getDY();
93  __z += step * getDZ();
94  __t += step / velocity;
95  }
96 
97 
98  /**
99  * Set z-position.
100  *
101  * \param z z-position
102  * \param velocity velocity
103  */
104  void setZ(const double z, const double velocity)
105  {
106  move((z - getZ()) / getDZ(), velocity);
107  }
108 
109 
110  /**
111  * Prefix unary minus.
112  *
113  * \return line
114  */
116  {
119 
120  return *this;
121  }
122 
123 
124  /**
125  * Addition operator.
126  *
127  * \param value line
128  * \return line
129  */
130  JLine3Z& add(const JLine3Z& value)
131  {
132  JLine1Z ::add(value);
133  JVersor3Z::add(value);
134 
135  return *this;
136  }
137 
138 
139  /**
140  * Subtraction operator.
141  *
142  * \param value line
143  * \return line
144  */
145  JLine3Z& sub(const JLine3Z& value)
146  {
147  JLine1Z ::sub(value);
148  JVersor3Z::sub(value);
149 
150  return *this;
151  }
152 
153 
154  /**
155  * Multiplication operator.
156  *
157  * \param value multiplication factor
158  * \return line
159  */
160  JLine3Z& mul(const double value)
161  {
162  JLine1Z ::mul(value);
163  JVersor3Z::mul(value);
164 
165  return *this;
166  }
167 
168 
169  /**
170  * Division operator.
171  *
172  * \param value multiplication factor
173  * \return line
174  */
175  JLine3Z& div(const double value)
176  {
177  JLine1Z ::div(value);
178  JVersor3Z::div(value);
179 
180  return *this;
181  }
182 
183 
184  /**
185  * Type conversion.
186  *
187  * \return track
188  */
189  inline operator JTrack3D() const
190  {
191  return JTrack3D(JAxis3D(this->getPosition(),
192  this->getDirection()),
193  this->getT());
194  }
195 
196 
197  /**
198  * Get distance squared.
199  *
200  * \param pos position
201  * \return square of distance
202  */
203  inline double getDistanceSquared(const JVector3D& pos) const
204  {
205  JPosition3D D(pos);
206 
207  D.sub(this->getPosition());
208 
209  const double dz = D.getDot(this->getDirection());
210 
211  return D.getLengthSquared() - dz*dz;
212  }
213 
214 
215  /**
216  * Get distance.
217  *
218  * \param pos position
219  * \return distance
220  */
221  inline double getDistance(const JVector3D& pos) const
222  {
223  return sqrt(this->getDistanceSquared(pos));
224  }
225 
226 
227  /**
228  * Get arrival time of Cherenkov light at given position.
229  *
230  * \param pos position [m]
231  * \return time [ns]
232  */
233  inline double getT(const JVector3D& pos) const
234  {
235  using namespace JTOOLS;
236 
237  JPosition3D D(pos);
238 
239  D.sub(this->getPosition());
240 
241  const double dz = D.getDot(this->getDirection());
242  const double R = sqrt(D.getLengthSquared() - dz*dz);
243 
244  return this->getT() + (dz + R * getKappaC()) * getInverseSpeedOfLight();
245  }
246 
247 
248  /**
249  * Get photon direction of Cherenkov light on PMT.
250  *
251  * \param pos PMT position
252  * \return direction
253  */
254  inline JVersor3D getDirection(const JVector3D& pos) const
255  {
256  using namespace JTOOLS;
257  using namespace JGEOMETRY3D;
258 
259  JPosition3D D(pos);
260 
261  D.sub(this->getPosition());
262 
263  const double dz = D.getDot(this->getDirection());
264  const double R = sqrt(D.getLengthSquared() - dz*dz);
265 
266  D.sub(JPosition3D(this->getDirection()) * (dz - R/getTanThetaC()));
267 
268  return JDirection3D(D);
269  }
270 
271 
272  /**
273  * Get cosine angle of impact of Cherenkov light on PMT.
274  *
275  * \param axis PMT axis
276  * \return cosine angle of impact
277  */
278  inline double getDot(const JAxis3D& axis) const
279  {
280  return getDirection(axis.getPosition()).getDot(axis.getDirection());
281  }
282 
283 
284  /**
285  * Read object from input.
286  *
287  * \param in input stream
288  * \param object object
289  * \return input stream
290  */
291  friend inline std::istream& operator>>(std::istream& in, JLine3Z& object)
292  {
293  in >> static_cast<JLine1Z&> (object);
294  in >> static_cast<JVersor3Z&>(object);
295 
296  return in;
297  }
298 
299 
300  /**
301  * Write object to output.
302  *
303  * \param out output stream
304  * \param object object
305  * \return output stream
306  */
307  friend inline std::ostream& operator<<(std::ostream& out, const JLine3Z& object)
308  {
309  out << static_cast<const JLine1Z&> (object);
310  out << ' ';
311  out << static_cast<const JVersor3Z&>(object);
312 
313  return out;
314  }
315 
316 
317  typedef double JLine3Z::*parameter_type;
318 
319  static parameter_type pDX() { return &JLine3Z::__dx; }
320  static parameter_type pDY() { return &JLine3Z::__dy; }
321  };
322 }
323 
324 #endif
double getDot(const JAngle3D &angle) const
Get dot product.
Definition: JPosition3D.hh:368
Auxiliary base class for aritmetic operations of derived class types.
Definition: JMath.hh:26
double getT() const
Get time.
Data structure for direction in three dimensions.
Definition: JDirection3D.hh:32
JVersor3Z & negate()
Prefix unary minus.
Definition: JVersor3Z.hh:182
double getDistance(const JVector3D &pos) const
Get distance.
Definition: JLine3Z.hh:221
friend std::istream & operator>>(std::istream &in, JLine3Z &object)
Read object from input.
Definition: JLine3Z.hh:291
double getT(const JVector3D &pos) const
Get arrival time of Cherenkov light at given position.
Definition: JLine3Z.hh:233
const JDirection3D & getDirection() const
Get direction.
JVersor3Z & sub(const JVersor3Z &value)
Subtraction operator.
Definition: JVersor3Z.hh:212
Data structure for fit of straight line in positive z-direction.
Definition: JLine3Z.hh:35
JVertex3D & add(const JVertex3D &value)
Addition operator.
Definition: JVertex3D.hh:84
JVertex3D & negate()
Prefix unary minus.
Definition: JVertex3D.hh:70
double JLine3Z::* parameter_type
Definition: JLine3Z.hh:317
JVertex3D & div(const double value)
Division operator.
Definition: JVertex3D.hh:129
JVersor3Z & add(const JVersor3Z &value)
Addition operator.
Definition: JVersor3Z.hh:197
JVertex3D & sub(const JVertex3D &value)
Subtraction operator.
Definition: JVertex3D.hh:99
double getDot(const JAxis3D &axis) const
Get cosine angle of impact of Cherenkov light on PMT.
Definition: JLine3Z.hh:278
double getDY() const
Get y direction.
Definition: JVersor3Z.hh:155
JVersor3Z & mul(const double value)
Multiplication operator.
Definition: JVersor3Z.hh:227
Axis object.
Definition: JAxis3D.hh:37
const double getInverseSpeedOfLight()
Get inverse speed of light.
Definition: JConstants.hh:100
double getDistanceSquared(const JVector3D &pos) const
Get distance squared.
Definition: JLine3Z.hh:203
JVersor3D getDirection(const JVector3D &pos) const
Get photon direction of Cherenkov light on PMT.
Definition: JLine3Z.hh:254
Constants.
JVector3D & sub(const JVector3D &vector)
Subtract vector.
Definition: JVector3D.hh:156
static parameter_type pDX()
Definition: JLine3Z.hh:319
JLine3Z & div(const double value)
Division operator.
Definition: JLine3Z.hh:175
Data structure for vector in three dimensions.
Definition: JVector3D.hh:32
JVertex3D & mul(const double value)
Multiplication operator.
Definition: JVertex3D.hh:114
double JLine1Z::* parameter_type
Definition: JLine1Z.hh:178
JVersor3Z & div(const double value)
Division operator.
Definition: JVersor3Z.hh:242
JLine3Z & add(const JLine3Z &value)
Addition operator.
Definition: JLine3Z.hh:130
const JPosition3D & getPosition() const
Get position.
Definition: JPosition3D.hh:129
double getLengthSquared() const
Get length squared.
Definition: JVector3D.hh:231
static parameter_type pDY()
Definition: JLine3Z.hh:320
void move(const double step, const double velocity)
Move vertex along this line with given velocity.
Definition: JLine3Z.hh:89
JLine3Z & mul(const double value)
Multiplication operator.
Definition: JLine3Z.hh:160
const JVersor3Z & getDirection() const
Get direction.
Definition: JVersor3Z.hh:78
JLine3Z()
Default constructor.
Definition: JLine3Z.hh:53
friend std::ostream & operator<<(std::ostream &out, const JLine3Z &object)
Write object to output.
Definition: JLine3Z.hh:307
void setZ(const double z, const double velocity)
Set z-position.
Definition: JLine3Z.hh:104
JLine3Z(const JLine1Z &line)
Constructor.
Definition: JLine3Z.hh:64
JPosition3D()
Default constructor.
Definition: JPosition3D.hh:47
double getDX() const
Get x direction.
Definition: JVersor3Z.hh:144
Data structure for fit of straight line paralel to z-axis.
Definition: JLine1Z.hh:27
Base class for data structures with artithmetic capabilities.
JLine3Z & sub(const JLine3Z &value)
Subtraction operator.
Definition: JLine3Z.hh:145
Data structure for position in three dimensions.
Definition: JPosition3D.hh:35
double getDZ() const
Get z direction.
Definition: JVersor3Z.hh:166
Data structure for normalised vector in three dimensions.
Definition: JVersor3D.hh:23
double getTanThetaC()
Get average tangent of Cherenkov angle of water.
Definition: JConstants.hh:122
Data structure for normalised vector in positive z-direction.
Definition: JVersor3Z.hh:36
JLine3Z(const JLine1Z &line, const JVersor3Z &dir)
Constructor.
Definition: JLine3Z.hh:76
double getKappaC()
Get average kappa of Cherenkov light in water.
Definition: JConstants.hh:155
double getZ() const
Get z position.
Definition: JVector3D.hh:113
JLine3Z & negate()
Prefix unary minus.
Definition: JLine3Z.hh:115