]> git.uio.no Git - u/mrichter/AliRoot.git/blob - ITS/AliITSgeomMatrix.h
New version including the full 3D vertex finder
[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 class AliITSgeomMatrix : public TObject {
15  public:
16         AliITSgeomMatrix(); // Default constructor
17         AliITSgeomMatrix(const Int_t idt,const Int_t id[3],
18                          const Double_t rot[3],const Double_t tran[3]);
19         AliITSgeomMatrix(const Int_t idt,const Int_t id[3],
20                          Double_t matrix[3][3],const Double_t tran[3]);
21         AliITSgeomMatrix(const Double_t rotd[6]/*degrees Geant angles*/,
22                          const Int_t idt,const Int_t id[3],
23                          const Double_t tran[3]);
24         AliITSgeomMatrix(const AliITSgeomMatrix &source);
25         void operator=(const AliITSgeomMatrix &sourse); // copy
26         virtual ~AliITSgeomMatrix(){};
27         void PrintComment(ostream *os);
28         void Print(ostream *os);
29         void PrintTitles(ostream *os);
30         void Read(istream *is);
31
32         void SetAngles(const Double_t rot[3]){// [radians]
33               for(Int_t i=0;i<3;i++)frot[i] = rot[i];this->MatrixFromAngle();}
34         void SetTranslation(const Double_t tran[3]){
35                             for(Int_t i=0;i<3;i++) ftran[i] = tran[i];
36                             fCylR   = TMath::Sqrt(ftran[0]*ftran[0]+
37                                                   ftran[1]*ftran[1]);
38                             fCylPhi = TMath::ATan2(ftran[1],ftran[0]);
39                             if(fCylPhi<0.0) fCylPhi += TMath::Pi();}
40         void SetMatrix(Double_t matrix[3][3]){ for(Int_t i=0;i<3;i++)
41          for(Int_t j=0;j<3;j++) fm[i][j]=matrix[i][j];this->AngleFromMatrix();}
42         void SetDetectorIndex(const Int_t idt) {fDetectorIndex = idt;}
43         void SetIndex(const Int_t id[3]){
44                            for(Int_t i=0;i<3;i++) fid[i] = id[i];}
45         void GetAngles(Double_t rot[3]){// [radians]
46                            for(Int_t i=0;i<3;i++)  rot[i] = frot[i];}
47         void GetTranslation(Double_t tran[3]){
48                             for(Int_t i=0;i<3;i++) tran[i] = ftran[i];}
49         void GetTranslationCylinderical(Double_t tran[3]){
50                             tran[0] = fCylR;
51                             tran[1] = fCylPhi;
52                             tran[2] = ftran[2];}
53         void GetMatrix(Double_t matrix[3][3]){for(Int_t i=0;i<3;i++)
54                          for(Int_t j=0;j<3;j++) matrix[i][j] = fm[i][j];}
55         Int_t GetDetectorIndex() {return fDetectorIndex;}
56         void  GetIndex(Int_t id[3]){for(Int_t i=0;i<3;i++) id[i] = fid[i];}
57         void  MatrixFromSixAngles(const Double_t *ang);
58         void  SixAnglesFromMatrix(Double_t *ang);
59
60         void GtoLPosition(const Double_t g[3],Double_t l[3]);
61         void LtoGPosition(const Double_t l[3],Double_t g[3]);
62         void GtoLMomentum(const Double_t g[3],Double_t l[3]);
63         void LtoGMomentum(const Double_t l[3],Double_t g[3]);
64         void GtoLPositionError(Double_t g[3][3],Double_t l[3][3]);
65         void LtoGPositionError(Double_t l[3][3],Double_t g[3][3]);
66         // Tracking Related Routines
67         void GtoLPositionTracking(const Double_t g[3],Double_t l[3]);
68         void LtoGPositionTracking(const Double_t l[3],Double_t g[3]);
69         void GtoLMomentumTracking(const Double_t g[3],Double_t l[3]);
70         void LtoGMomentumTracking(const Double_t l[3],Double_t g[3]);
71         void GtoLPositionErrorTracking(Double_t g[3][3],
72                                        Double_t l[3][3]);
73         void LtoGPositionErrorTracking(Double_t l[3][3],
74                                        Double_t g[3][3]);
75         Double_t Distance2(const Double_t t[3]){Double_t d=0.0,q;
76                  for(Int_t i=0;i<3;i++){q = t[i]-ftran[i]; d += q*q;}
77                  return d;}
78  private: // private functions
79         void MatrixFromAngle();
80         void AngleFromMatrix();
81  private: // Data members.
82         Int_t    fDetectorIndex; // Detector type index (like fShapeIndex was)
83         Int_t    fid[3];         // layer, ladder, detector numbers.
84         Double_t frot[3];        //! vector of rotations about x,y,z [radians].
85         Double_t ftran[3];       // Translation vector of module x,y,z.
86         Double_t fCylR,fCylPhi;  //! Translation vector in Cylinderical coord.
87         Double_t fm[3][3];       // Rotation matrix based on frot.
88
89         // Note, fCylR and fCylPhi are added as data members because it costs
90         // about a factor of 10 to compute them over looking them up. Since
91         // they are used in some tracking algorithms this can be a large cost
92         // in computing time. They are not written out but computed.
93
94         ClassDef(AliITSgeomMatrix,1) // Matrix class used by AliITSgeom.
95 };
96 // Input and output function for standard C++ input/output.
97 ostream &operator<<(ostream &os,AliITSgeomMatrix &source);
98 istream &operator>>(istream &os,AliITSgeomMatrix &source);
99
100 #endif