]> git.uio.no Git - u/mrichter/AliRoot.git/blob - ITS/AliITSgeom.h
Release version of ITS code
[u/mrichter/AliRoot.git] / ITS / AliITSgeom.h
1 #ifndef ALIITSGEOM_H
2 #define ALIITSGEOM_H
3 /* Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
4  * See cxx source for full Copyright notice                               */
5
6 /* $Id$ */
7
8 /////////////////////////////////////////////////////////////////////////
9 //  ITS geometry manipulation routines.
10 //  Created April 15 1999.
11 //  version: 0.0.0
12 //  By: Bjorn S. Nilsen
13 //
14 //     A package of geometry routines to do transformations between
15 // local, detector active area, and ALICE global coordinate system in such
16 // a way as to allow for detector alignment studies and the like. All of
17 // the information needed to do the coordinate transformation are kept in
18 // a specialized structure for ease of implementation.
19 /////////////////////////////////////////////////////////////////////////
20 #include <fstream.h>
21 #include <TObjArray.h>
22 #include <TVector.h>
23
24 #include "AliITSgeomSPD.h"
25 #include "AliITSgeomSDD.h"
26 #include "AliITSgeomSSD.h"
27
28
29 struct AliITSgeomS {
30     Int_t   fShapeIndex; // Shape index for this volume
31     Float_t fx0,fy0,fz0; // Translation vector
32     Float_t frx,fry,frz; // Rotation about axis, angle radians
33     Float_t fr[9];       // the rotation matrix
34     Float_t angles[6];   // module center, theta and phi
35     Double_t rottrack[3][3]; // the tracking rotation matrix
36 };
37
38 //_______________________________________________________________________
39
40 class AliITSgeom : public TObject {
41
42  public:
43     AliITSgeom();                            // Default constructor
44     AliITSgeom(const char *filename);        // Constructor
45     AliITSgeom(const AliITSgeom &source);    // Copy constructor
46     //    void operator=(const AliITSgeom &source);// = operator
47     AliITSgeom& operator=(const AliITSgeom &source);// = operator
48
49     virtual ~AliITSgeom();                   // Default destructor
50
51     Int_t GetNdetectors(Int_t layer) const {return fNdet[layer-1];}// return number of detector a ladder has
52     Int_t GetNladders(Int_t layer)   const {return fNlad[layer-1];}// return number of laders a layer has
53     Int_t GetNlayers()               const {return fNlayers;} // return number of layer the ITS has
54     void GetAngles(Int_t lay,Int_t lad,Int_t det,
55                           Float_t &rx,Float_t &ry,Float_t &rz)const {
56                           rx = fGm[lay-1][fNdet[lay-1]*(lad-1)+det-1].frx;
57                           ry = fGm[lay-1][fNdet[lay-1]*(lad-1)+det-1].fry;
58                           rz = fGm[lay-1][fNdet[lay-1]*(lad-1)+det-1].frz;} // Get agnles of roations for a give module
59     void GetTrans(Int_t lay,Int_t lad,Int_t det,
60                          Float_t &x,Float_t &y,Float_t &z)const {
61                          x = fGm[lay-1][fNdet[lay-1]*(lad-1)+det-1].fx0;
62                          y = fGm[lay-1][fNdet[lay-1]*(lad-1)+det-1].fy0;
63                          z = fGm[lay-1][fNdet[lay-1]*(lad-1)+det-1].fz0;} // get translation for a given module
64     void SetByAngles(Int_t lay,Int_t lad,Int_t det,
65                      Float_t rx,Float_t ry,Float_t rz);
66     void SetByAngles(Int_t index,Double_t angl[]);
67     void SetTrans(Int_t lay,Int_t lad,Int_t det,
68                          Float_t x,Float_t y,Float_t z){
69                          fGm[lay-1][fNdet[lay-1]*(lad-1)+det-1].fx0 = x;
70                          fGm[lay-1][fNdet[lay-1]*(lad-1)+det-1].fy0 = y;
71                          fGm[lay-1][fNdet[lay-1]*(lad-1)+det-1].fz0 = z;}// Set translation vector for a give module
72     void SetTrans(Int_t index,Double_t x[]);
73     void GetRotMatrix(Int_t lay,Int_t lad,Int_t det,Float_t *mat);
74     void GetRotMatrix(Int_t lay,Int_t lad,Int_t det,Double_t *mat);
75     void GetRotMatrix(Int_t index,Float_t *mat);
76     void GetRotMatrix(Int_t index,Double_t *mat);
77     Int_t GetStartDet(Int_t dtype );
78     Int_t GetLastDet(Int_t dtype);
79     Int_t GetStartSPD() {return GetModuleIndex(1,1,1);} // return starting index for SPD
80     Int_t GetLastSPD() {return GetModuleIndex(2,fNlad[1],fNdet[1]);}// return Ending index for SPD
81     Int_t GetStartSDD() {return GetModuleIndex(3,1,1);} // return starting index for SDD
82     Int_t GetLastSDD() {return GetModuleIndex(4,fNlad[3],fNdet[3]);}// return Ending index for SDD
83     Int_t GetStartSSD() {return GetModuleIndex(5,1,1);} // return starting index for SSD
84     Int_t GetLastSSD() {return GetModuleIndex(6,fNlad[5],fNdet[5]);}// return Ending index for SSD
85     Int_t GetIndexMax() {return GetModuleIndex(fNlayers,fNlad[fNlayers-1],
86                                                fNdet[fNlayers-1])+1;}// return Ending index for all ITS
87     void GtoL(Int_t lay,Int_t lad,Int_t det,const Float_t *g,Float_t *l);
88     void GtoL(const Int_t *id,const Float_t *g,Float_t *l);
89     void GtoL(const Int_t index,const Float_t *g,Float_t *l);
90     void GtoL(Int_t lay,Int_t lad,Int_t det,const Double_t *g,Double_t *l);
91     void GtoL(const Int_t *id,const Double_t *g,Double_t *l);
92     void GtoL(const Int_t index,const Double_t *g,Double_t *l);
93     void GtoLMomentum(Int_t lay,Int_t lad,Int_t det,
94                       const Float_t *g,Float_t *l);
95     void GtoLMomentum(Int_t lay,Int_t lad,Int_t det,
96                       const Double_t *g,Double_t *l);
97     void LtoG(Int_t lay,Int_t lad,Int_t det,const Float_t *l,Float_t *g);
98     void LtoG(const Int_t *id,const Float_t *l,Float_t *g);
99     void LtoG(const Int_t index,const Float_t *l,Float_t *g);
100     void LtoG(Int_t lay,Int_t lad,Int_t det,const Double_t *l,Double_t *g);
101     void LtoG(const Int_t *id,const Double_t *l,Double_t *g);
102     void LtoG(const Int_t index,const Double_t *l,Double_t *g);
103     void LtoGMomentum(Int_t lay,Int_t lad,Int_t det,
104                       const Float_t *l,Float_t *g);
105     void LtoGMomentum(Int_t lay,Int_t lad,Int_t det,
106                       const Double_t *l,Double_t *g);
107     void LtoL(const Int_t *id1,const Int_t *id2,Double_t *l1,Double_t *l2);
108     void LtoL(const Int_t index1,const Int_t index2,Double_t *l1,Double_t *l2);
109     void LtoLMomentum(const Int_t *id1,const Int_t *id2,
110                       const Double_t *l1,Double_t *l2);
111     void GtoLErrorMatrix(const Int_t index,Double_t **g,Double_t **l);
112     void LtoGErrorMatrix(const Int_t index,Double_t **l,Double_t **g);
113     void LtoLErrorMatrix(const Int_t index1,const Int_t index2,
114                          Double_t **l1,Double_t **l2);
115     Int_t GetModuleIndex(Int_t lay,Int_t lad,Int_t det);
116     void GetModuleId(Int_t index,Int_t &lay,Int_t &lad,Int_t &det);
117     void GlobalChange(Float_t  *tran,Float_t  *rot);
118     void GlobalCylindericalChange(Float_t *tran,Float_t *rot);
119     void RandomChange(Float_t *stran,Float_t *srot);
120     void RandomCylindericalChange(Float_t *stran,Float_t *srot);
121     void PrintComparison(FILE *fp,AliITSgeom *other);
122     void PrintData(FILE *fp,Int_t lay,Int_t lad,Int_t det);
123     ofstream &PrintGeom(ofstream &out);
124     ifstream &ReadGeom(ifstream &in);
125     virtual Int_t IsVersion() const {return 1;} // return version number
126     void AddShape(TObject *shp){fShape->AddLast(shp);} // Add Shapes
127     virtual TObject *GetShape(Int_t lay,Int_t lad,Int_t det)
128         const {return fShape->At(fGm[lay-1][fNdet[lay-1]*(lad-1)+det-1].
129                                  fShapeIndex);} // return specific TShape
130
131     TObjArray *Shape() {return fShape;} // return Shapes array
132
133     void GeantToTracking(AliITSgeom &source); // This converts the geometry
134     // transformations from that used by the ITS and it's Monte Carlo to that
135     // used by the track finding code.
136     // Usage:
137     // AliITSgeom *gm,*gt;
138     // gm = ((AliITS *) ITS)->GetITSgeom();
139     // gt->GeantToTracking(*gm);
140     // This allocates and fills gt with the geometry transforms between the
141     // global coordinate system to the local coordinate system used to do
142     // tracking.
143
144     void GtoLtracking(Int_t lay,Int_t lad,Int_t det,const Double_t *g,Double_t *l);
145     void LtoGtracking(Int_t lay,Int_t lad,Int_t det,const Double_t *l,Double_t *g);
146     void GetCenterThetaPhi(Int_t lay,Int_t lad,Int_t det, TVector &x) const {
147                        x(0) = fGm[lay-1][fNdet[lay-1]*(lad-1)+det-1].fx0;
148                        x(1) = fGm[lay-1][fNdet[lay-1]*(lad-1)+det-1].fy0;
149                        x(2) = fGm[lay-1][fNdet[lay-1]*(lad-1)+det-1].fz0;                                                
150                        x(3) = fGm[lay-1][fNdet[lay-1]*(lad-1)+det-1].angles[0];
151                        x(4) = fGm[lay-1][fNdet[lay-1]*(lad-1)+det-1].angles[1];
152                        x(5) = fGm[lay-1][fNdet[lay-1]*(lad-1)+det-1].angles[2];
153                        x(6) = fGm[lay-1][fNdet[lay-1]*(lad-1)+det-1].angles[3];
154                        x(7) = fGm[lay-1][fNdet[lay-1]*(lad-1)+det-1].angles[4];
155                        x(8) = fGm[lay-1][fNdet[lay-1]*(lad-1)+det-1].angles[5];
156
157 }
158
159  private:
160     Int_t        fNlayers; // The number of layers.
161     Int_t        *fNlad;   // Array of the number of ladders/layer(layer)
162     Int_t        *fNdet;   // Array of the number of detectors/ladder(layer)
163     AliITSgeomS  **fGm;     // Structure of translation and rotation.
164     TObjArray    *fShape;  // Array of shapes and detector information.
165     
166     ClassDef(AliITSgeom,1) // ITS geometry class
167 };
168
169 #endif