TrackBasis.h
Go to the documentation of this file.
1 ///
2 /// \file TrackBasis.h
3 /// \brief Construct a track-based (x,y,z) coordinate system
4 /// \author messier@indiana.edu
5 /// \version $Id:$
6 ///
7 #ifndef BPFIT_TRACKBASEDSYSTEM_H
8 #define BPFIT_TRACKBASEDSYSTEM_H
9 #include <vector>
10 #include "TVector3.h"
11 
12 namespace bpfit {
13  ///
14  /// Construct am (x,y,z) coordinate system where track direction
15  /// defines the z axis.
16  ///
17  /// The track-based coordinate system is hoped to be useful for
18  /// managing the smooth transition from forward going tracks where
19  /// the detector measures x or y as a function of z to highly
20  /// transverse tracks where the detector measures z as a function of
21  /// x or y.
22  ///
23  class TrackBasis {
24  public:
25  ///
26  /// Given a list of detector space points (x,y,z) find the primary
27  /// track axis.
28  ///
29  /// @param x - x track location of hit i
30  /// @param y - y track location of hit i
31  /// @param z - z track location of hit i
32  /// @param dx - uncertainty in x
33  /// @param dy - uncertainty in y
34  /// @param dz - uncertainty in z
35  /// @param z1 - on output, "z prime" axis which follows track
36  ///
37  static void FindAxis(const std::vector<double>& x,
38  const std::vector<double>& y,
39  const std::vector<double>& z,
40  const std::vector<double>& dx,
41  const std::vector<double>& dy,
42  const std::vector<double>& dz,
43  TVector3& z1);
44  ///
45  /// Construct the basis vectors and rotation matrices
46  ///
47  /// @param x - track x coordinates (detector frame)
48  /// @param y - track y coordinates (detector frame)
49  /// @param z - track z coordinates (detector frame)
50  /// @param dx - track x uncertainty
51  /// @param dy - track y uncertainty
52  /// @param dz - track z uncertainty
53  /// @param vx - vertex x coordinate (detector frame)
54  /// @param vy - vertex y coordinate (detector frame)
55  /// @param vz - vertex z coordinate (detector frame)
56  ///
57  void MakeBasis(const std::vector<double>& x,
58  const std::vector<double>& y,
59  const std::vector<double>& z,
60  const std::vector<double>& dx,
61  const std::vector<double>& dy,
62  const std::vector<double>& dz,
63  double vx, double vy, double vz);
64 
65  ///
66  /// Set the origin of the new coordinate system
67  ///
68  /// @param x - x location of origin (detector system)
69  /// @param y - y location of origin (detector system)
70  /// @param z - z location of origin (detector system)
71  ///
72  void SetOrigin(double x, double y, double z);
73 
74  ///
75  /// Compare the new basis vectors to the location of the
76  /// origin to make sure that the new Z axis points in the
77  /// intended direction of the track and adjust the rotation
78  /// matricies if needed.
79  ///
80  /// @param x - track x coordinates (detector frame)
81  /// @param y - track y coordinates (detector frame)
82  /// @param z - track z coordinates (detector frame)
83  /// @param dx - track x uncertainty
84  /// @param dy - track y uncertainty
85  /// @param dz - track z uncertainty
86  ///
87  void AdjustBasisDir(const std::vector<double>& x,
88  const std::vector<double>& y,
89  const std::vector<double>& z,
90  const std::vector<double>& dx,
91  const std::vector<double>& dy,
92  const std::vector<double>& dz);
93 
94  ///
95  /// Transform from detector-based system to track-based system
96  ///
97  /// @param x - detector-based x location
98  /// @param y - detector-based y location
99  /// @param z - detector-based z location
100  /// @param dx - detector-based x location error
101  /// @param dy - detector-based y location error
102  /// @param dz - detector-based z location error
103  /// @param x1 - track-based x location
104  /// @param y1 - track-based y location
105  /// @param z1 - track-based z location
106  /// @param dx1 - track-based dx location error
107  /// @param dy1 - track-based dy location error
108  /// @param dz1 - track-based dz location error
109  ///
110  void DetToTrk(double x, double y, double z,
111  double dx, double dy, double dz,
112  double* x1, double* y1, double* z1,
113  double* dx1, double* dy1, double* dz1);
114 
115  ///
116  /// Transform from track-based system to detector-based system
117  ///
118  /// @param x - track-based x location
119  /// @param y - track-based y location
120  /// @param z - track-based z location
121  /// @param dx - track-based x location error
122  /// @param dy - track-based y location error
123  /// @param dz - track-based z location error
124  /// @param x1 - detector-based x location
125  /// @param y1 - detector-based y location
126  /// @param z1 - detector-based z location
127  /// @param dx1 - detector-based dx location error
128  /// @param dy1 - detector-based dy location error
129  /// @param dz1 - detector-based dz location error
130  ///
131  void TrkToDet(double x, double y, double z,
132  double dx, double dy, double dz,
133  double* x1, double* y1, double* z1,
134  double* dx1, double* dy1, double* dz1);
135 
136  public:
137  TVector3 fO; ///< System origin in detector coordinates
138  TVector3 fX1; ///< x basis vector in detector coordinates
139  TVector3 fY1; ///< y basis vector in detector coordinates
140  TVector3 fZ1; ///< z basis vector in detector coordinates
141  double fU [3][3]; ///< Transformation matrix
142  double fUT[3][3]; ///< Transpose of transformation matrix
143  };
144 }
145 
146 #endif // BPFIT_TRACKBASEDSYSTEM_H
147 ////////////////////////////////////////////////////////////////////////
148 
TVector3 fO
System origin in detector coordinates.
Definition: TrackBasis.h:137
void MakeBasis(const std::vector< double > &x, const std::vector< double > &y, const std::vector< double > &z, const std::vector< double > &dx, const std::vector< double > &dy, const std::vector< double > &dz, double vx, double vy, double vz)
Definition: TrackBasis.cxx:61
Float_t y1[n_points_granero]
Definition: compare.C:5
Float_t x1[n_points_granero]
Definition: compare.C:5
double fU[3][3]
Transformation matrix.
Definition: TrackBasis.h:141
TVector3 fX1
x basis vector in detector coordinates
Definition: TrackBasis.h:138
double fUT[3][3]
Transpose of transformation matrix.
Definition: TrackBasis.h:142
double dy[NP][NC]
double dx[NP][NC]
double dz[NP][NC]
void DetToTrk(double x, double y, double z, double dx, double dy, double dz, double *x1, double *y1, double *z1, double *dx1, double *dy1, double *dz1)
Definition: TrackBasis.cxx:194
z
Definition: test.py:28
static void FindAxis(const std::vector< double > &x, const std::vector< double > &y, const std::vector< double > &z, const std::vector< double > &dx, const std::vector< double > &dy, const std::vector< double > &dz, TVector3 &z1)
Definition: TrackBasis.cxx:15
void AdjustBasisDir(const std::vector< double > &x, const std::vector< double > &y, const std::vector< double > &z, const std::vector< double > &dx, const std::vector< double > &dy, const std::vector< double > &dz)
Definition: TrackBasis.cxx:137
void TrkToDet(double x, double y, double z, double dx, double dy, double dz, double *x1, double *y1, double *z1, double *dx1, double *dy1, double *dz1)
Definition: TrackBasis.cxx:218
void SetOrigin(double x, double y, double z)
Definition: TrackBasis.cxx:187
TVector3 fZ1
z basis vector in detector coordinates
Definition: TrackBasis.h:140
TVector3 fY1
y basis vector in detector coordinates
Definition: TrackBasis.h:139