Jpp
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
JGEOMETRY3D::JVersor3Z::negate
JVersor3Z & negate()
Prefix unary minus.
Definition: JVersor3Z.hh:183
JGEOMETRY3D::JVertex3D::sub
JVertex3D & sub(const JVertex3D &value)
Subtraction operator.
Definition: JVertex3D.hh:99
JFIT::JLine3Z::getDot
double getDot(const JAxis3D &axis) const
Get cosine angle of impact of Cherenkov light on PMT.
Definition: JLine3Z.hh:278
JVector3D.hh
JGEOMETRY3D::JVersor3Z::div
JVersor3Z & div(const double value)
Division operator.
Definition: JVersor3Z.hh:243
JFIT::JLine3Z::getDistance
double getDistance(const JVector3D &pos) const
Get distance.
Definition: JLine3Z.hh:221
JFIT
Auxiliary classes and methods for linear and iterative data regression.
Definition: JEnergy.hh:15
JFIT::JLine3Z
Data structure for fit of straight line in positive z-direction.
Definition: JLine3Z.hh:35
JFIT::JLine3Z::negate
JLine3Z & negate()
Prefix unary minus.
Definition: JLine3Z.hh:115
JTrack3D.hh
JGEOMETRY3D::JVector3D::__y
double __y
Definition: JVector3D.hh:310
JGEOMETRY3D::JVector3D::getLengthSquared
double getLengthSquared() const
Get length squared.
Definition: JVector3D.hh:234
JFIT::JLine3Z::getDistanceSquared
double getDistanceSquared(const JVector3D &pos) const
Get distance squared.
Definition: JLine3Z.hh:203
JPosition3D.hh
JDirection3D.hh
JGEOMETRY3D::JVersor3Z
Data structure for normalised vector in positive z-direction.
Definition: JVersor3Z.hh:37
JFIT::JLine3Z::JLine3Z
JLine3Z(const JLine1Z &line, const JVersor3Z &dir)
Constructor.
Definition: JLine3Z.hh:76
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::JVector3D::getZ
double getZ() const
Get z position.
Definition: JVector3D.hh:114
JGEOMETRY3D::JAxis3D
Axis object.
Definition: JAxis3D.hh:38
JGEOMETRY3D::JVersor3Z::add
JVersor3Z & add(const JVersor3Z &value)
Addition operator.
Definition: JVersor3Z.hh:198
JFIT::JLine3Z::JLine3Z
JLine3Z(const JLine1Z &line)
Constructor.
Definition: JLine3Z.hh:64
JGEOMETRY3D::JVersor3Z::mul
JVersor3Z & mul(const double value)
Multiplication operator.
Definition: JVersor3Z.hh:228
JFIT::JLine3Z::parameter_type
double JLine3Z::* parameter_type
Definition: JLine3Z.hh:317
JGEOMETRY3D::JTime::getT
double getT() const
Get time.
Definition: JGeometry3D/JTime.hh:121
JGEOMETRY3D::JPosition3D::JPosition3D
JPosition3D()
Default constructor.
Definition: JPosition3D.hh:47
JGEOMETRY3D::JDirection3D
Data structure for direction in three dimensions.
Definition: JDirection3D.hh:32
JGEOMETRY3D::JVersor3D
Data structure for normalised vector in three dimensions.
Definition: JVersor3D.hh:23
JMATH::JMath
Auxiliary base class for aritmetic operations of derived class types.
Definition: JMath.hh:26
JGEOMETRY3D::JPosition3D::getDot
double getDot(const JAngle3D &angle) const
Get dot product.
Definition: JPosition3D.hh:377
JPP
This name space includes all other name spaces (except KM3NETDAQ, KM3NET and ANTARES).
Definition: JAAnetToolkit.hh:37
JGEOMETRY3D::JVersor3Z::__dx
double __dx
Definition: JVersor3Z.hh:379
JFIT::JLine3Z::getDirection
JVersor3D getDirection(const JVector3D &pos) const
Get photon direction of Cherenkov light on PMT.
Definition: JLine3Z.hh:254
JGEOMETRY3D::JVector3D
Data structure for vector in three dimensions.
Definition: JVector3D.hh:33
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
JGEOMETRY3D::JTime::__t
double __t
Definition: JGeometry3D/JTime.hh:188
JConstants.hh
JFIT::JLine3Z::operator>>
friend std::istream & operator>>(std::istream &in, JLine3Z &object)
Read object from input.
Definition: JLine3Z.hh:291
JGEOMETRY3D::JPosition3D
Data structure for position in three dimensions.
Definition: JPosition3D.hh:35
JFIT::JLine3Z::getT
double getT(const JVector3D &pos) const
Get arrival time of Cherenkov light at given position.
Definition: JLine3Z.hh:233
JVersor3Z.hh
JGEOMETRY3D::JVersor3Z::sub
JVersor3Z & sub(const JVersor3Z &value)
Subtraction operator.
Definition: JVersor3Z.hh:213
JFIT::JLine3Z::setZ
void setZ(const double z, const double velocity)
Set z-position.
Definition: JLine3Z.hh:104
JFIT::JLine1Z
Data structure for fit of straight line paralel to z-axis.
Definition: JLine1Z.hh:27
JFIT::JLine1Z::parameter_type
double JLine1Z::* parameter_type
Definition: JLine1Z.hh:178
JMath.hh
JTOOLS::getTanThetaC
double getTanThetaC()
Get average tangent of Cherenkov angle of water.
Definition: JConstants.hh:133
JTOOLS::getKappaC
double getKappaC()
Get average kappa of Cherenkov light in water.
Definition: JConstants.hh:166
JFIT::JLine3Z::pDX
static parameter_type pDX()
Definition: JLine3Z.hh:319
JGEOMETRY3D::JPosition3D::getPosition
const JPosition3D & getPosition() const
Get position.
Definition: JPosition3D.hh:129
JGEOMETRY3D::JVersor3Z::getDirection
const JVersor3Z & getDirection() const
Get direction.
Definition: JVersor3Z.hh:79
JGEOMETRY3D::JVertex3D::add
JVertex3D & add(const JVertex3D &value)
Addition operator.
Definition: JVertex3D.hh:84
JFIT::JLine3Z::operator<<
friend std::ostream & operator<<(std::ostream &out, const JLine3Z &object)
Write object to output.
Definition: JLine3Z.hh:307
JFIT::JLine3Z::div
JLine3Z & div(const double value)
Division operator.
Definition: JLine3Z.hh:175
JFIT::JLine3Z::sub
JLine3Z & sub(const JLine3Z &value)
Subtraction operator.
Definition: JLine3Z.hh:145
JGEOMETRY3D::JTrack3D
3D track.
Definition: JTrack3D.hh:30
JGEOMETRY3D::JVersor3Z::getDY
double getDY() const
Get y direction.
Definition: JVersor3Z.hh:156
JFIT::JLine3Z::pDY
static parameter_type pDY()
Definition: JLine3Z.hh:320
JFIT::JLine3Z::mul
JLine3Z & mul(const double value)
Multiplication operator.
Definition: JLine3Z.hh:160
JGEOMETRY3D
Auxiliary classes and methods for 3D geometrical objects and operations.
Definition: JAngle3D.hh:18
JGEOMETRY3D::JVector3D::__z
double __z
Definition: JVector3D.hh:311
JFIT::JLine3Z::JLine3Z
JLine3Z()
Default constructor.
Definition: JLine3Z.hh:53
JGEOMETRY3D::JVector3D::__x
double __x
Definition: JVector3D.hh:309
JTOOLS
Auxiliary classes and methods for multi-dimensional interpolations and histograms.
Definition: JAbstractCollection.hh:9
JGEOMETRY3D::JVersor3Z::getDZ
double getDZ() const
Get z direction.
Definition: JVersor3Z.hh:167
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
JFIT::JLine3Z::add
JLine3Z & add(const JLine3Z &value)
Addition operator.
Definition: JLine3Z.hh:130
JFIT::JLine3Z::move
void move(const double step, const double velocity)
Move vertex along this line with given velocity.
Definition: JLine3Z.hh:89
JGEOMETRY3D::JVersor3Z::__dy
double __dy
Definition: JVersor3Z.hh:380
JGEOMETRY3D::JVersor3Z::getDX
double getDX() const
Get x direction.
Definition: JVersor3Z.hh:145
JLine1Z.hh