Jpp  master_rocky-43-ge265d140c
the software that should make you happy
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 "JPhysics/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 
26  using JMATH::JMath;
30 
31 
32  /**
33  * Data structure for fit of straight line in positive z-direction.
34  * Note that the position coordinates are defined with respect to the given direction.
35  */
36  class JLine3Z :
37  public JLine1Z,
38  public JVersor3Z,
39  public JMath<JLine3Z>
40  {
41  public:
42 
43  using JLine1Z::add;
44  using JLine1Z::sub;
45  using JLine1Z::getT;
46  using JVersor3Z::add;
47  using JVersor3Z::sub;
49 
50 
51  /**
52  * Default constructor.
53  */
54  JLine3Z() :
55  JLine1Z(),
56  JVersor3Z()
57  {}
58 
59 
60  /**
61  * Constructor.
62  *
63  * \param line line
64  */
65  JLine3Z(const JLine1Z& line) :
66  JLine1Z(line),
67  JVersor3Z()
68  {}
69 
70 
71  /**
72  * Constructor.
73  *
74  * \param line line
75  * \param dir direction
76  */
77  JLine3Z(const JLine1Z& line,
78  const JVersor3Z& dir) :
79  JLine1Z(line),
80  JVersor3Z(dir)
81  {}
82 
83 
84  /**
85  * Move vertex along this line with given velocity.
86  *
87  * \param step step
88  * \param velocity velocity
89  */
90  void move(const double step, const double velocity)
91  {
92  __x += step * getDX();
93  __y += step * getDY();
94  __z += step * getDZ();
95  __t += step / velocity;
96  }
97 
98 
99  /**
100  * Set z-position.
101  *
102  * \param z z-position
103  * \param velocity velocity
104  */
105  void setZ(const double z, const double velocity)
106  {
107  move((z - getZ()) / getDZ(), velocity);
108  }
109 
110 
111  /**
112  * Prefix unary minus.
113  *
114  * \return line
115  */
117  {
120 
121  return *this;
122  }
123 
124 
125  /**
126  * Addition operator.
127  *
128  * \param value line
129  * \return line
130  */
131  JLine3Z& add(const JLine3Z& value)
132  {
133  JLine1Z ::add(value);
134  JVersor3Z::add(value);
135 
136  return *this;
137  }
138 
139 
140  /**
141  * Subtraction operator.
142  *
143  * \param value line
144  * \return line
145  */
146  JLine3Z& sub(const JLine3Z& value)
147  {
148  JLine1Z ::sub(value);
149  JVersor3Z::sub(value);
150 
151  return *this;
152  }
153 
154 
155  /**
156  * Multiplication operator.
157  *
158  * \param value multiplication factor
159  * \return line
160  */
161  JLine3Z& mul(const double value)
162  {
163  JLine1Z ::mul(value);
164  JVersor3Z::mul(value);
165 
166  return *this;
167  }
168 
169 
170  /**
171  * Division operator.
172  *
173  * \param value multiplication factor
174  * \return line
175  */
176  JLine3Z& div(const double value)
177  {
178  JLine1Z ::div(value);
179  JVersor3Z::div(value);
180 
181  return *this;
182  }
183 
184 
185  /**
186  * Type conversion.
187  *
188  * \return track
189  */
190  inline operator JTrack3D() const
191  {
192  return JTrack3D(JAxis3D(this->getPosition(),
193  this->getDirection()),
194  this->getT());
195  }
196 
197 
198  /**
199  * Get distance squared.
200  *
201  * \param pos position
202  * \return square of distance
203  */
204  inline double getDistanceSquared(const JVector3D& pos) const
205  {
206  JPosition3D D(pos);
207 
208  D.sub(this->getPosition());
209 
210  const double dz = D.getDot(this->getDirection());
211 
212  return D.getLengthSquared() - dz*dz;
213  }
214 
215 
216  /**
217  * Get distance.
218  *
219  * \param pos position
220  * \return distance
221  */
222  inline double getDistance(const JVector3D& pos) const
223  {
224  return sqrt(this->getDistanceSquared(pos));
225  }
226 
227 
228  /**
229  * Get arrival time of Cherenkov light at given position.
230  *
231  * \param pos position [m]
232  * \return time [ns]
233  */
234  inline double getT(const JVector3D& pos) const
235  {
236  using namespace JPP;
237 
238  JPosition3D D(pos);
239 
240  D.sub(this->getPosition());
241 
242  const double dz = D.getDot(this->getDirection());
243  const double R = sqrt(D.getLengthSquared() - dz*dz);
244 
245  return this->getT() + (dz + R * getKappaC()) * getInverseSpeedOfLight();
246  }
247 
248 
249  /**
250  * Get photon direction of Cherenkov light on PMT.
251  *
252  * \param pos PMT position
253  * \return direction
254  */
255  inline JVersor3D getDirection(const JVector3D& pos) const
256  {
257  using namespace JPP;
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
Base class for data structures with artithmetic capabilities.
Physics constants.
Data structure for fit of straight line paralel to z-axis.
Definition: JLine1Z.hh:29
double getT(const JVector3D &pos) const
Get arrival time of Cherenkov light at given position.
Definition: JVertex3D.hh:147
double JLine1Z::* parameter_type
Definition: JLine1Z.hh:178
Data structure for fit of straight line in positive z-direction.
Definition: JLine3Z.hh:40
JVersor3D getDirection(const JVector3D &pos) const
Get photon direction of Cherenkov light on PMT.
Definition: JLine3Z.hh:255
JLine3Z(const JLine1Z &line, const JVersor3Z &dir)
Constructor.
Definition: JLine3Z.hh:77
void setZ(const double z, const double velocity)
Set z-position.
Definition: JLine3Z.hh:105
double getDot(const JAxis3D &axis) const
Get cosine angle of impact of Cherenkov light on PMT.
Definition: JLine3Z.hh:278
double getDistanceSquared(const JVector3D &pos) const
Get distance squared.
Definition: JLine3Z.hh:204
JLine3Z()
Default constructor.
Definition: JLine3Z.hh:54
JLine3Z & mul(const double value)
Multiplication operator.
Definition: JLine3Z.hh:161
JLine3Z & div(const double value)
Division operator.
Definition: JLine3Z.hh:176
JLine3Z & sub(const JLine3Z &value)
Subtraction operator.
Definition: JLine3Z.hh:146
double getT(const JVector3D &pos) const
Get arrival time of Cherenkov light at given position.
Definition: JLine1Z.hh:114
JLine3Z & negate()
Prefix unary minus.
Definition: JLine3Z.hh:116
friend std::ostream & operator<<(std::ostream &out, const JLine3Z &object)
Write object to output.
Definition: JLine3Z.hh:307
JLine3Z(const JLine1Z &line)
Constructor.
Definition: JLine3Z.hh:65
double getDistance(const JVector3D &pos) const
Get distance.
Definition: JLine3Z.hh:222
void move(const double step, const double velocity)
Move vertex along this line with given velocity.
Definition: JLine3Z.hh:90
static parameter_type pDY()
Definition: JLine3Z.hh:320
JLine3Z & add(const JLine3Z &value)
Addition operator.
Definition: JLine3Z.hh:131
friend std::istream & operator>>(std::istream &in, JLine3Z &object)
Read object from input.
Definition: JLine3Z.hh:291
static parameter_type pDX()
Definition: JLine3Z.hh:319
double getT(const JVector3D &pos) const
Get arrival time of Cherenkov light at given position.
Definition: JLine3Z.hh:234
const JVersor3Z & getDirection() const
Get direction.
Definition: JVersor3Z.hh:81
double JLine3Z::* parameter_type
Definition: JLine3Z.hh:317
Axis object.
Definition: JAxis3D.hh:41
Data structure for direction in three dimensions.
Definition: JDirection3D.hh:35
const JDirection3D & getDirection() const
Get direction.
Data structure for position in three dimensions.
Definition: JPosition3D.hh:38
const JPosition3D & getPosition() const
Get position.
Definition: JPosition3D.hh:130
double getDot(const JAngle3D &angle) const
Get dot product.
Definition: JPosition3D.hh:378
JPosition3D()
Default constructor.
Definition: JPosition3D.hh:48
Data structure for vector in three dimensions.
Definition: JVector3D.hh:36
double getLengthSquared() const
Get length squared.
Definition: JVector3D.hh:235
double getZ() const
Get z position.
Definition: JVector3D.hh:115
JVector3D & sub(const JVector3D &vector)
Subtract vector.
Definition: JVector3D.hh:158
Data structure for normalised vector in three dimensions.
Definition: JVersor3D.hh:28
Data structure for normalised vector in positive z-direction.
Definition: JVersor3Z.hh:41
JVersor3Z & div(const double value)
Division operator.
Definition: JVersor3Z.hh:245
double getDot(const JVersor3Z &dir) const
Get dot product.
Definition: JVersor3Z.hh:275
JVersor3Z & add(const JVersor3Z &value)
Addition operator.
Definition: JVersor3Z.hh:200
JVersor3Z & negate()
Prefix unary minus.
Definition: JVersor3Z.hh:185
JVersor3Z & mul(const double value)
Multiplication operator.
Definition: JVersor3Z.hh:230
JVersor3Z & sub(const JVersor3Z &value)
Subtraction operator.
Definition: JVersor3Z.hh:215
double getDZ() const
Get z direction.
Definition: JVersor3Z.hh:169
const JVersor3Z & getDirection() const
Get direction.
Definition: JVersor3Z.hh:81
double getDY() const
Get y direction.
Definition: JVersor3Z.hh:158
double getDX() const
Get x direction.
Definition: JVersor3Z.hh:147
JVertex3D & mul(const double value)
Multiplication operator.
Definition: JVertex3D.hh:117
JTime & add(const JTime &value)
Addition operator.
JVertex3D & div(const double value)
Division operator.
Definition: JVertex3D.hh:132
JTime & sub(const JTime &value)
Subtraction operator.
JVertex3D & negate()
Prefix unary minus.
Definition: JVertex3D.hh:73
Auxiliary classes and methods for linear and iterative data regression.
Definition: JEnergy.hh:15
double getKappaC()
Get average R-dependence of arrival time of Cherenkov light (a.k.a.
const double getInverseSpeedOfLight()
Get inverse speed of light.
double getTanThetaC()
Get average tangent of Cherenkov angle of water corresponding to group velocity.
This name space includes all other name spaces (except KM3NETDAQ, KM3NET and ANTARES).
Auxiliary base class for aritmetic operations of derived class types.
Definition: JMath.hh:347