]> git.uio.no Git - u/mrichter/AliRoot.git/blob - ITS/AliITSgeomMatrix.h
Temporary fix waiting for the real changes
[u/mrichter/AliRoot.git] / ITS / AliITSgeomMatrix.h
1 #ifndef ALIITSGEOMMATRIX_H
2 #define ALIITSGEOMMATRIX_H
3 /* Copyright(c) 2000, ALICE Experiment at CERN, All rights reserved. *
4  * see cxx source for full Copyright notice.                         */
5 /* $Id: */
6 ////////////////////////////////////////////////////////////////////////
7 // ITS geometry manipulation routines on the module level. This class is
8 // to replace the structure ITS_geom in the class AliITSgeom.
9 // Created May 30 2000.
10 // version 0.0.0
11 // By Bjorn S. Nilsen
12 ////////////////////////////////////////////////////////////////////////
13
14 #include <TObject.h>
15
16 class AliITSgeomMatrix : public TObject {
17  public:
18         AliITSgeomMatrix(); // Default constructor
19         // Standard constructor #1
20         AliITSgeomMatrix(Int_t idt,const Int_t id[3],
21                          const Double_t rot[3],const Double_t tran[3]);
22         // Standard constructor #2
23         AliITSgeomMatrix(Int_t idt,const Int_t id[3],
24                          Double_t matrix[3][3],const Double_t tran[3]);
25         // Standard constructor #3
26         AliITSgeomMatrix(const Double_t rotd[6]/*degrees GEANT angles*/,
27                          Int_t idt,const Int_t id[3],
28                          const Double_t tran[3]);
29         // Copy operator
30         AliITSgeomMatrix(const AliITSgeomMatrix &source);
31         // Alignment operator
32         void operator=(const AliITSgeomMatrix &sourse); // copy
33         virtual ~AliITSgeomMatrix(){}; // default constructor.
34         // Prints a line describing the output format of the function Print.
35         void PrintComment(ostream *os) const;
36         // Prints out the content of this class in ASCII format.
37         void Print(ostream *os);
38         // Prints out the content of this class in ASCII format but includes
39         // formating and strings that make it more humanly readable.
40         void PrintTitles(ostream *os) const;
41         // Reads in the content of this class in the format of Print
42         void Read(istream *is);
43
44         // Given the rotation angles [radians] it fills frot and computes
45         // the rotation matrix fm.
46         void SetAngles(const Double_t rot[3]){// [radians]
47               for(Int_t i=0;i<3;i++)frot[i] = rot[i];this->MatrixFromAngle();}
48         // Sets the translation vector and computes fCylR and fCylPhi.
49         void SetTranslation(const Double_t tran[3]);
50         // sets the rotation matrix and computes the rotation angles [radians]
51         void SetMatrix(Double_t matrix[3][3]){ for(Int_t i=0;i<3;i++)
52          for(Int_t j=0;j<3;j++) fm[i][j]=matrix[i][j];this->AngleFromMatrix();}
53         // Sets the detector index value
54         void SetDetectorIndex(Int_t idt) {fDetectorIndex = idt;}
55         // Sets the detector layer, ladder, detector (id) values.
56         void SetIndex(const Int_t id[3]){
57                            for(Int_t i=0;i<3;i++) fid[i] = id[i];}
58         // Returns the rotation angles [radians]
59         void GetAngles(Double_t rot[3]) const {// [radians]
60                            for(Int_t i=0;i<3;i++)  rot[i] = frot[i];}
61         // Returns the translation vector [cm]
62         void GetTranslation(Double_t tran[3]) const {
63                             for(Int_t i=0;i<3;i++) tran[i] = ftran[i];}
64         // Returns the translation vector in cylindrical
65         // coordinates [cm,radians]
66         void GetTranslationCylinderical (Double_t tran[3]) const {
67                             tran[0] = fCylR;
68                             tran[1] = fCylPhi;
69                             tran[2] = ftran[2];}
70         // Returns the values of the rotation matrix
71         void GetMatrix(Double_t matrix[3][3]) const {for(Int_t i=0;i<3;i++)
72                          for(Int_t j=0;j<3;j++) matrix[i][j] = fm[i][j];}
73         // Returns the detector index value.
74         Int_t GetDetectorIndex() const {return fDetectorIndex;}
75         // returns the modules index layer, ladder, detector
76         void  GetIndex(Int_t id[3]) const {for(Int_t i=0;i<3;i++) id[i] = fid[i];}
77         // Sets the rotation matrix based on the 6 GEANT rotation
78         // angles [radian]
79         void  MatrixFromSixAngles(const Double_t *ang);
80         // Returns the 6 GEANT rotation angles [radians] from the
81         // existing rotation matrix.
82         void  SixAnglesFromMatrix(Double_t *ang);
83
84         // Given a position in Cartesian ALICE global coordinates [cm]
85         // returns the position in Cartesian detector/module local
86         //coordinates [cm]
87         void GtoLPosition(const Double_t g[3],Double_t l[3]) const;
88         // Given a position in Cartesian detector/module local coordinates [cm]
89         // returns the position in Cartesian ALICE global
90         //coordinates [cm]
91         void LtoGPosition(const Double_t l[3],Double_t g[3]) const;
92         // Given a momentum in Cartesian ALICE global coordinates
93         // returns the momentum in Cartesian detector/module local
94         //coordinates
95         void GtoLMomentum(const Double_t g[3],Double_t l[3]) const;
96         // Given a momentum in Cartesian detector/module local coordinates 
97         // returns the momentum in Cartesian ALICE global coordinates
98         void LtoGMomentum(const Double_t l[3],Double_t g[3]) const;
99         // given a position error matrix in ALICE Cartesian global
100         // coordinates [cm] returns a position error matrix in detector/
101         // module local Cartesian local coordinates [cm]
102         void GtoLPositionError(Double_t g[3][3],Double_t l[3][3]) const;
103         // given a position error matrix in detector/module Cartesian local
104         // coordinates [cm] returns a position error matrix in ALICE
105         // Cartesian global coordinates [cm]
106         void LtoGPositionError(Double_t l[3][3],Double_t g[3][3]) const;
107         // Tracking Related Routines
108         void GtoLPositionTracking(const Double_t g[3],Double_t l[3]) const;
109         // Given a position in Cartesian Tracking global coordinates [cm]
110         // returns the position in Cartesian detector/module local
111         // coordinates [cm]
112         void LtoGPositionTracking(const Double_t l[3],Double_t g[3]) const;
113         // Given a position in Cartesian detector/module local coordinates [cm]
114         // returns the position in Cartesian Tracking global
115         //coordinates [cm]
116         void GtoLMomentumTracking(const Double_t g[3],Double_t l[3]) const;
117         // Given a momentum in Cartesian detector/module local coordinates 
118         // returns the momentum in Cartesian Tracking global coordinates
119         void LtoGMomentumTracking(const Double_t l[3],Double_t g[3]) const;
120         // given a position error matrix in Tracking Cartesian global
121         // coordinates [cm] returns a position error matrix in detector/
122         // module local Cartesian local coordinates [cm]
123         void GtoLPositionErrorTracking(Double_t g[3][3],
124                                        Double_t l[3][3]) const;
125         // given a position error matrix in detector/module Cartesian local
126         // coordinates [cm] returns a position error matrix in Tracking
127         // Cartesian global coordinates [cm]
128         void LtoGPositionErrorTracking(Double_t l[3][3],
129                                        Double_t g[3][3]) const;
130         // Computes the distance squared [cm^2] between a point t[3] and
131         // this module/detector
132         Double_t Distance2(const Double_t t[3]) const {Double_t d=0.0,q;
133                  for(Int_t i=0;i<3;i++){q = t[i]-ftran[i]; d += q*q;}
134                  return d;}
135  private: // private functions
136         // Given the rotation matrix fm it fills the rotation angles frot
137         void MatrixFromAngle();
138         // Given the rotation angles frot it fills the rotation matrix fm
139         void AngleFromMatrix();
140  private: // Data members.
141         Int_t    fDetectorIndex; // Detector type index (like fShapeIndex was)
142         Int_t    fid[3];         // layer, ladder, detector numbers.
143         Double_t frot[3];        //! vector of rotations about x,y,z [radians].
144         Double_t ftran[3];       // Translation vector of module x,y,z.
145         Double_t fCylR,fCylPhi;  //! Translation vector in Cylindrical coord.
146         Double_t fm[3][3];       // Rotation matrix based on frot.
147
148         // Note, fCylR and fCylPhi are added as data members because it costs
149         // about a factor of 10 to compute them over looking them up. Since
150         // they are used in some tracking algorithms this can be a large cost
151         // in computing time. They are not written out but computed.
152
153         ClassDef(AliITSgeomMatrix,1) // Matrix class used by AliITSgeom.
154 };
155 // Input and output function for standard C++ input/output.
156 ostream &operator<<(ostream &os,AliITSgeomMatrix &source);
157 istream &operator>>(istream &os,AliITSgeomMatrix &source);
158
159 #endif