]> git.uio.no Git - u/mrichter/AliRoot.git/blob - ITS/AliITSgeomMatrix.h
Macro to calculate the resolution and the efficiency of chamber(s) (Nicolas)
[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         // Copy constructor
33         AliITSgeomMatrix(const AliITSgeomMatrix &source);
34         // Assignment operator
35         AliITSgeomMatrix& operator=(const AliITSgeomMatrix &source); 
36         virtual ~AliITSgeomMatrix(){}; // default constructor.
37         // Prints a line describing the output format of the function Print.
38         void PrintComment(ostream *os) const;
39         // Prints out the content of this class in ASCII format.
40         void Print(ostream *os)const;
41         // Prints out the content of this class in ASCII format but includes
42         // formating and strings that make it more humanly readable.
43         void PrintTitles(ostream *os) const;
44         // Reads in the content of this class in the format of Print
45         void Read(istream *is);
46      virtual void Print(Option_t *option="") const {
47                        TObject::Print(option);}
48      virtual Int_t Read(const char *name) {return TObject::Read(name);}
49
50      // Returns the geometry path corresponding to this transformation
51      TString& GetPath(){return fPath;}
52      // Sets the geometry path
53      void SetPath(const Char_t *p){fPath = p;}
54      void SetPath(const TString &p){fPath = p;}
55         // Given the rotation angles [radians] it fills frot and computes
56         // the rotation matrix fm.
57         void SetAngles(const Double_t rot[3]){// [radians]
58               for(Int_t i=0;i<3;i++)frot[i] = rot[i];this->MatrixFromAngle();}
59         // Sets the translation vector and computes fCylR and fCylPhi.
60         void SetTranslation(const Double_t tran[3]);
61         // sets the rotation matrix and computes the rotation angles [radians]
62         void SetMatrix(const Double_t matrix[3][3]){ for(Int_t i=0;i<3;i++)
63          for(Int_t j=0;j<3;j++) fm[i][j]=matrix[i][j];this->AngleFromMatrix();}
64         // Sets the detector index value
65         void SetDetectorIndex(Int_t idt) {fDetectorIndex = idt;}
66         // Sets the detector layer, ladder, detector (id) values.
67         void SetIndex(const Int_t id[3]){
68                            for(Int_t i=0;i<3;i++) fid[i] = id[i];}
69         // Returns the rotation angles [radians]
70         void GetAngles(Double_t rot[3]) const {// [radians]
71                            for(Int_t i=0;i<3;i++)  rot[i] = frot[i];}
72         // Returns the translation vector [cm]
73         void GetTranslation(Double_t tran[3]) const {
74                             for(Int_t i=0;i<3;i++) tran[i] = ftran[i];}
75         // Returns the translation vector in cylindrical
76         // coordinates [cm,radians]
77         void GetTranslationCylinderical (Double_t tran[3]) const {
78                             tran[0] = fCylR;
79                             tran[1] = fCylPhi;
80                             tran[2] = ftran[2];}
81         // Returns the values of the rotation matrix
82         void GetMatrix(Double_t matrix[3][3]) const {for(Int_t i=0;i<3;i++)
83                          for(Int_t j=0;j<3;j++) matrix[i][j] = fm[i][j];}
84         // Returns the detector index value.
85         Int_t GetDetectorIndex() const {return fDetectorIndex;}
86         // returns the modules index layer, ladder, detector
87         void  GetIndex(Int_t id[3]) const {for(Int_t i=0;i<3;i++) id[i] = fid[i];}
88         // Sets the rotation matrix based on the 6 GEANT rotation
89         // angles [radian]
90         void  MatrixFromSixAngles(const Double_t *ang);
91         // Returns the 6 GEANT rotation angles [radians] from the
92         // existing rotation matrix.
93         void  SixAnglesFromMatrix(Double_t *ang)const;
94
95         // Given a position in Cartesian ALICE global coordinates [cm]
96         // returns the position in Cartesian detector/module local
97         //coordinates [cm]
98         void GtoLPosition(const Double_t g[3],Double_t l[3]) const;
99         // Given a position in Cartesian detector/module local coordinates [cm]
100         // returns the position in Cartesian ALICE global
101         //coordinates [cm]
102         void LtoGPosition(const Double_t l[3],Double_t g[3]) const;
103         // Given a momentum in Cartesian ALICE global coordinates
104         // returns the momentum in Cartesian detector/module local
105         //coordinates
106         void GtoLMomentum(const Double_t g[3],Double_t l[3]) const;
107         // Given a momentum in Cartesian detector/module local coordinates 
108         // returns the momentum in Cartesian ALICE global coordinates
109         void LtoGMomentum(const Double_t l[3],Double_t g[3]) const;
110         // given a position error matrix in ALICE Cartesian global
111         // coordinates [cm] returns a position error matrix in detector/
112         // module local Cartesian local coordinates [cm]
113         void GtoLPositionError(const Double_t g[3][3],Double_t l[3][3]) const;
114         // given a position error matrix in detector/module Cartesian local
115         // coordinates [cm] returns a position error matrix in ALICE
116         // Cartesian global coordinates [cm]
117         void LtoGPositionError(const Double_t l[3][3],Double_t g[3][3]) const;
118         // Tracking Related Routines
119         void GtoLPositionTracking(const Double_t g[3],Double_t l[3]) const;
120         // Given a position in Cartesian Tracking global coordinates [cm]
121         // returns the position in Cartesian detector/module local
122         // coordinates [cm]
123         void LtoGPositionTracking(const Double_t l[3],Double_t g[3]) const;
124         // Given a position in Cartesian detector/module local coordinates [cm]
125         // returns the position in Cartesian Tracking global
126         //coordinates [cm]
127         void GtoLMomentumTracking(const Double_t g[3],Double_t l[3]) const;
128         // Given a momentum in Cartesian detector/module local coordinates 
129         // returns the momentum in Cartesian Tracking global coordinates
130         void LtoGMomentumTracking(const Double_t l[3],Double_t g[3]) const;
131         // given a position error matrix in Tracking Cartesian global
132         // coordinates [cm] returns a position error matrix in detector/
133         // module local Cartesian local coordinates [cm]
134         void GtoLPositionErrorTracking(const Double_t g[3][3],
135                                        Double_t l[3][3]) const;
136         // given a position error matrix in detector/module Cartesian local
137         // coordinates [cm] returns a position error matrix in Tracking
138         // Cartesian global coordinates [cm]
139         void LtoGPositionErrorTracking(const Double_t l[3][3],
140                                        Double_t g[3][3]) const;
141         // Computes the distance squared [cm^2] between a point t[3] and
142         // this module/detector
143         Double_t Distance2(const Double_t t[3]) const {Double_t d=0.0,q;
144                  for(Int_t i=0;i<3;i++){q = t[i]-ftran[i]; d += q*q;}
145                  return d;}
146      //
147      // Documentation related Class
148      TPolyLine3D* CreateLocalAxis() const;
149      TPolyLine3D* CreateLocalAxisTracking() const;
150      TNode* CreateNode(const Char_t *nodeName,const Char_t *nodeTitle,
151                        TNode *mother,TShape *shape,Bool_t axis=kTRUE) const;
152      void MakeFigures() const;
153      //
154  private: // private functions
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