EIC Software
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
3d.h
Go to the documentation of this file. Or view the newest version in sPHENIX GitHub for file 3d.h
1 /* -------------------------------------------------------------------------- */
2 /* 3d.h */
3 /* */
4 /* Include file for the 3d algebra routines. */
5 /* */
6 /* A.Kisselev, PNPI, St.Petersburg, Russia. */
7 /* e-mail: kisselev@hermes.desy.de */
8 /* -------------------------------------------------------------------------- */
9 
10 #include <TVector3.h>
11 #include <TRotation.h>
12 
13 #ifndef _3D_H
14 #define _3D_H
15 
16 #define _X_ 0
17 #define _Y_ 1
18 #define _Z_ 2
19 
20 #define _PARALLEL_ 1
21 #define _COINSIDE_ 2
22 #define _BELONG_ 3
23 
24 // Trivial but useful;
25 #define VZERO(vec) ((vec).SetXYZ(0.0, 0.0, 0.0))
26 
27 class t_3d_line {
28  public:
30  t_3d_line(TVector3 _x, TVector3 _nx) {
31  x = _x;
32  nx = _nx;
33  nx.SetMag(1.0);
34  }
35  t_3d_line(double S[4], double z);
36  ~t_3d_line() {};
37 
38  TVector3 x, nx;
39 };
40 
41 // Plane parametrization; want to keep it
42 // separate from the t_line although they
43 // are essentially the same;
44 class t_3d_plane {
45  public:
47  t_3d_plane(TVector3 _x, TVector3 _nx) {
48  x = _x;
49  nx = _nx;
50  nx.SetMag(1.0);
51  }
53 
54  const TVector3 GetCoord() const { return x; };
55 
56  TVector3 x, nx;
57 };
58 
59 #ifdef __cplusplus
60 extern "C" {
61 #endif
62  //int build_line_from_2_points(TVector3 &x1, TVector3 &x2, t_3d_line *line);
63  int cross_p_l(const t_3d_plane *pl, const t_3d_line *ll, TVector3 &crs);
64  double point_to_line_dist(TVector3 &xx, t_3d_line *ll, TVector3 &bridge);
65  double point_to_plane_dist(TVector3 &xx, t_3d_plane *pl);
66  int build_plane_from_point_and_line(TVector3 &xx, t_3d_line *ll, t_3d_plane *pl);
67 
68  // FIXME: unify these two cases later; for now just leave this call in such
69  // a way, that it is explicitely useable under Linux (gcc) and Mac OS (Clang);
70  //#ifndef __APPLE__
71  //t_3d_line parametrize_straight_line(double S[4], double z);
72  //#endif
73 
74  int cross_l_l(const t_3d_line *l1, const t_3d_line *l2, t_3d_line *crs, double *rx,
75  double *theta, double tt[]);
76  double line_to_line_dist(t_3d_line *l1, t_3d_line *l2);
77 
78  int deparametrize_straight_line(t_3d_line *line, double z, double S[4]);
79 #ifdef __cplusplus
80 }
81 #endif
82 
83 //#ifdef _APPLE_
84 //t_3d_line parametrize_straight_line(double S[4], double z);
85 //#endif
86 
87 #endif