]> git.uio.no Git - u/mrichter/AliRoot.git/blob - ITS/AliITSgeomMatrix.h
245b5209b25b3463da714c453b15a1a11a94a085
[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
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 #include <TObject.h>
14 #include <TString.h>
15 class TPolyLine3D;
16 class TNode;
17 class TShape;
18
19 class AliITSgeomMatrix : public TObject {
20  public:
21         AliITSgeomMatrix(); // Default constructor
22         // Standard constructor #1
23         AliITSgeomMatrix(Int_t idt,const Int_t id[3],
24                          const Double_t rot[3],const Double_t tran[3]);
25         // Standard constructor #2
26         AliITSgeomMatrix(Int_t idt,const Int_t id[3],
27                          Double_t matrix[3][3],const Double_t tran[3]);
28         // Standard constructor #3
29         AliITSgeomMatrix(const Double_t rotd[6]/*degrees GEANT angles*/,
30                          Int_t idt,const Int_t id[3],
31                          const Double_t tran[3]);
32         virtual ~AliITSgeomMatrix(){}; // default constructor.
33         // Prints a line describing the output format of the function Print.
34         void PrintComment(ostream *os) const;
35         // Prints out the content of this class in ASCII format.
36         void Print(ostream *os)const;
37         // Prints out the content of this class in ASCII format but includes
38         // formating and strings that make it more humanly readable.
39         void PrintTitles(ostream *os) const;
40         // Reads in the content of this class in the format of Print
41         void Read(istream *is);
42      virtual void Print(Option_t *option="") const {
43                        TObject::Print(option);}
44      virtual Int_t Read(const char *name) {return TObject::Read(name);}
45
46      // Returns the geometry path corresponding to this transformation
47      TString& GetPath(){return fPath;}
48      // Sets the geometry path
49      void SetPath(const Char_t *p){fPath = p;}
50      void SetPath(const TString &p){fPath = p;}
51         // Given the rotation angles [radians] it fills frot and computes
52         // the rotation matrix fm.
53         void SetAngles(const Double_t rot[3]){// [radians]
54               for(Int_t i=0;i<3;i++)frot[i] = rot[i];this->MatrixFromAngle();}
55         // Sets the translation vector and computes fCylR and fCylPhi.
56         void SetTranslation(const Double_t tran[3]);
57         // sets the rotation matrix and computes the rotation angles [radians]
58         void SetMatrix(const Double_t matrix[3][3]){ for(Int_t i=0;i<3;i++)
59          for(Int_t j=0;j<3;j++) fm[i][j]=matrix[i][j];this->AngleFromMatrix();}
60         // Sets the detector index value
61         void SetDetectorIndex(Int_t idt) {fDetectorIndex = idt;}
62         // Sets the detector layer, ladder, detector (id) values.
63         void SetIndex(const Int_t id[3]){
64                            for(Int_t i=0;i<3;i++) fid[i] = id[i];}
65         // Returns the rotation angles [radians]
66         void GetAngles(Double_t rot[3]) const {// [radians]
67                            for(Int_t i=0;i<3;i++)  rot[i] = frot[i];}
68         // Returns the translation vector [cm]
69         void GetTranslation(Double_t tran[3]) const {
70                             for(Int_t i=0;i<3;i++) tran[i] = ftran[i];}
71         // Returns the translation vector in cylindrical
72         // coordinates [cm,radians]
73         void GetTranslationCylinderical (Double_t tran[3]) const {
74                             tran[0] = fCylR;
75                             tran[1] = fCylPhi;
76                             tran[2] = ftran[2];}
77         // Returns the values of the rotation matrix
78         void GetMatrix(Double_t matrix[3][3]) const {for(Int_t i=0;i<3;i++)
79                          for(Int_t j=0;j<3;j++) matrix[i][j] = fm[i][j];}
80         // Returns the detector index value.
81         Int_t GetDetectorIndex() const {return fDetectorIndex;}
82         // returns the modules index layer, ladder, detector
83         void  GetIndex(Int_t id[3]) const {for(Int_t i=0;i<3;i++) id[i] = fid[i];}
84         // Sets the rotation matrix based on the 6 GEANT rotation
85         // angles [radian]
86         void  MatrixFromSixAngles(const Double_t *ang);
87         // Returns the 6 GEANT rotation angles [radians] from the
88         // existing rotation matrix.
89         void  SixAnglesFromMatrix(Double_t *ang)const;
90
91         // Given a position in Cartesian ALICE global coordinates [cm]
92         // returns the position in Cartesian detector/module local
93         //coordinates [cm]
94         void GtoLPosition(const Double_t g[3],Double_t l[3]) const;
95         // Given a position in Cartesian detector/module local coordinates [cm]
96         // returns the position in Cartesian ALICE global
97         //coordinates [cm]
98         void LtoGPosition(const Double_t l[3],Double_t g[3]) const;
99         // Given a momentum in Cartesian ALICE global coordinates
100         // returns the momentum in Cartesian detector/module local
101         //coordinates
102         void GtoLMomentum(const Double_t g[3],Double_t l[3]) const;
103         // Given a momentum in Cartesian detector/module local coordinates 
104         // returns the momentum in Cartesian ALICE global coordinates
105         void LtoGMomentum(const Double_t l[3],Double_t g[3]) const;
106         // given a position error matrix in ALICE Cartesian global
107         // coordinates [cm] returns a position error matrix in detector/
108         // module local Cartesian local coordinates [cm]
109         void GtoLPositionError(const Double_t g[3][3],Double_t l[3][3]) const;
110         // given a position error matrix in detector/module Cartesian local
111         // coordinates [cm] returns a position error matrix in ALICE
112         // Cartesian global coordinates [cm]
113         void LtoGPositionError(const Double_t l[3][3],Double_t g[3][3]) const;
114         // Tracking Related Routines
115         void GtoLPositionTracking(const Double_t g[3],Double_t l[3]) const;
116         // Given a position in Cartesian Tracking global coordinates [cm]
117         // returns the position in Cartesian detector/module local
118         // coordinates [cm]
119         void LtoGPositionTracking(const Double_t l[3],Double_t g[3]) const;
120         // Given a position in Cartesian detector/module local coordinates [cm]
121         // returns the position in Cartesian Tracking global
122         //coordinates [cm]
123         void GtoLMomentumTracking(const Double_t g[3],Double_t l[3]) const;
124         // Given a momentum in Cartesian detector/module local coordinates 
125         // returns the momentum in Cartesian Tracking global coordinates
126         void LtoGMomentumTracking(const Double_t l[3],Double_t g[3]) const;
127         // given a position error matrix in Tracking Cartesian global
128         // coordinates [cm] returns a position error matrix in detector/
129         // module local Cartesian local coordinates [cm]
130         void GtoLPositionErrorTracking(const Double_t g[3][3],
131                                        Double_t l[3][3]) const;
132         // given a position error matrix in detector/module Cartesian local
133         // coordinates [cm] returns a position error matrix in Tracking
134         // Cartesian global coordinates [cm]
135         void LtoGPositionErrorTracking(const Double_t l[3][3],
136                                        Double_t g[3][3]) const;
137         // Computes the distance squared [cm^2] between a point t[3] and
138         // this module/detector
139         Double_t Distance2(const Double_t t[3]) const {Double_t d=0.0,q;
140                  for(Int_t i=0;i<3;i++){q = t[i]-ftran[i]; d += q*q;}
141                  return d;}
142      //
143      // Documentation related Class
144      TPolyLine3D* CreateLocalAxis() const;
145      TPolyLine3D* CreateLocalAxisTracking() const;
146      TNode* CreateNode(const Char_t *nodeName,const Char_t *nodeTitle,
147                        TNode *mother,TShape *shape,Bool_t axis=kTRUE) const;
148      void MakeFigures() const;
149      //
150  private: // private functions
151         // Copy constructor
152         AliITSgeomMatrix(const AliITSgeomMatrix &source);
153         // Assignment operator
154         void operator=(const AliITSgeomMatrix &sourse); // copy
155         // Given the rotation matrix fm it fills the rotation angles frot
156         void MatrixFromAngle();
157         // Given the rotation angles frot it fills the rotation matrix fm
158         void AngleFromMatrix();
159  private: // Data members.
160         Int_t    fDetectorIndex; // Detector type index (like fShapeIndex was)
161         Int_t    fid[3];         // layer, ladder, detector numbers.
162         Double_t frot[3];        //! vector of rotations about x,y,z [radians].
163         Double_t ftran[3];       // Translation vector of module x,y,z.
164         Double_t fCylR,fCylPhi;  //! Translation vector in Cylindrical coord.
165         Double_t fm[3][3];       // Rotation matrix based on frot.
166         TString  fPath;          // Path within Geometry to this volume
167
168         // Note, fCylR and fCylPhi are added as data members because it costs
169         // about a factor of 10 to compute them over looking them up. Since
170         // they are used in some tracking algorithms this can be a large cost
171         // in computing time. They are not written out but computed.
172
173         ClassDef(AliITSgeomMatrix,2) // Matrix class used by AliITSgeom.
174 };
175 // Input and output function for standard C++ input/output.
176 ostream &operator<<(ostream &os,AliITSgeomMatrix &source);
177 istream &operator>>(istream &os,AliITSgeomMatrix &source);
178
179 #endif