3 /* Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
4 * See cxx source for full Copyright notice */
8 /////////////////////////////////////////////////////////////////////////
9 // ITS geometry manipulation routines.
10 // Created April 15 1999.
12 // By: Bjorn S. Nilsen
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 /////////////////////////////////////////////////////////////////////////
21 #include "TObjArray.h"
22 #include "AliITSgeomSPD.h"
23 #include "AliITSgeomSDD.h"
24 #include "AliITSgeomSSD.h"
28 Int_t fShapeIndex; // Shape index for this volume
29 Float_t fx0,fy0,fz0; // Translation vector
30 Float_t frx,fry,frz; // Rotation about axis, angle radians
31 Float_t fr[9]; // the rotation matrix
34 //_______________________________________________________________________
36 class AliITSgeom : public TObject {
39 Int_t fNlayers; // The number of layers.
40 Int_t *fNlad; // Array of the number of ladders/layer(layer)
41 Int_t *fNdet; // Array of the number of detectors/ladder(layer)
42 ITS_geom **fg; // Structure of translation and rotation.
43 TObjArray *fShape; // Array of shapes and detector information.
46 AliITSgeom(); // Default constructor
47 AliITSgeom(const char *filename); // Constructor
48 AliITSgeom(AliITSgeom &source); // Copy constructor
49 void operator=(AliITSgeom &source);// = operator
50 virtual ~AliITSgeom(); // Default destructor
51 // this is a dummy routine for now.
52 Int_t GetNdetectors(Int_t layer) const {return fNdet[layer-1];}
53 Int_t GetNladders(Int_t layer) const {return fNlad[layer-1];}
54 Int_t GetNlayers() const {return fNlayers;}
55 void GetAngles(Int_t lay,Int_t lad,Int_t det,
56 Float_t &rx,Float_t &ry,Float_t &rz)const {
57 rx = fg[lay-1][fNdet[lay-1]*(lad-1)+det-1].frx;
58 ry = fg[lay-1][fNdet[lay-1]*(lad-1)+det-1].fry;
59 rz = fg[lay-1][fNdet[lay-1]*(lad-1)+det-1].frz;}
60 void GetTrans(Int_t lay,Int_t lad,Int_t det,
61 Float_t &x,Float_t &y,Float_t &z)const {
62 x = fg[lay-1][fNdet[lay-1]*(lad-1)+det-1].fx0;
63 y = fg[lay-1][fNdet[lay-1]*(lad-1)+det-1].fy0;
64 z = fg[lay-1][fNdet[lay-1]*(lad-1)+det-1].fz0;}
65 void SetByAngles(Int_t lay,Int_t lad,Int_t det,
66 Float_t rx,Float_t ry,Float_t rz);
67 void SetByAngles(Int_t index,Double_t angl[]);
68 void SetTrans(Int_t lay,Int_t lad,Int_t det,
69 Float_t x,Float_t y,Float_t z){
70 fg[lay-1][fNdet[lay-1]*(lad-1)+det-1].fx0 = x;
71 fg[lay-1][fNdet[lay-1]*(lad-1)+det-1].fy0 = y;
72 fg[lay-1][fNdet[lay-1]*(lad-1)+det-1].fz0 = z;}
73 void SetTrans(Int_t index,Double_t x[]);
74 void GetRotMatrix(Int_t lay,Int_t lad,Int_t det,Float_t *mat);
75 void GetRotMatrix(Int_t lay,Int_t lad,Int_t det,Double_t *mat);
76 void GetRotMatrix(Int_t index,Float_t *mat);
77 void GetRotMatrix(Int_t index,Double_t *mat);
78 Int_t GetStartSPD() {return GetModuleIndex(1,1,1);}
79 Int_t GetLastSPD() {return GetModuleIndex(2,fNlad[1],fNdet[1]);}
80 Int_t GetStartSDD() {return GetModuleIndex(3,1,1);}
81 Int_t GetLastSDD() {return GetModuleIndex(4,fNlad[3],fNdet[3]);}
82 Int_t GetStartSSD() {return GetModuleIndex(5,1,1);}
83 Int_t GetLastSSD() {return GetModuleIndex(6,fNlad[5],fNdet[5]);}
84 Int_t GetIndexMax() {return GetModuleIndex(fNlayers,fNlad[fNlayers-1],
85 fNdet[fNlayers-1])+1;}
86 void GtoL(Int_t lay,Int_t lad,Int_t det,const Float_t *g,Float_t *l);
87 void GtoL(const Int_t *id,const Float_t *g,Float_t *l);
88 void GtoL(const Int_t index,const Float_t *g,Float_t *l);
89 void GtoL(Int_t lay,Int_t lad,Int_t det,const Double_t *g,Double_t *l);
90 void GtoL(const Int_t *id,const Double_t *g,Double_t *l);
91 void GtoL(const Int_t index,const Double_t *g,Double_t *l);
92 void GtoLMomentum(Int_t lay,Int_t lad,Int_t det,
93 const Float_t *g,Float_t *l);
94 void GtoLMomentum(Int_t lay,Int_t lad,Int_t det,
95 const Double_t *g,Double_t *l);
96 void LtoG(Int_t lay,Int_t lad,Int_t det,const Float_t *l,Float_t *g);
97 void LtoG(const Int_t *id,const Float_t *l,Float_t *g);
98 void LtoG(const Int_t index,const Float_t *l,Float_t *g);
99 void LtoG(Int_t lay,Int_t lad,Int_t det,const Double_t *l,Double_t *g);
100 void LtoG(const Int_t *id,const Double_t *l,Double_t *g);
101 void LtoG(const Int_t index,const Double_t *l,Double_t *g);
102 void LtoGMomentum(Int_t lay,Int_t lad,Int_t det,
103 const Float_t *l,Float_t *g);
104 void LtoGMomentum(Int_t lay,Int_t lad,Int_t det,
105 const Double_t *l,Double_t *g);
106 void LtoL(const Int_t *id1,const Int_t *id2,Double_t *l1,Double_t *l2);
107 void LtoL(const Int_t index1,const Int_t index2,Double_t *l1,Double_t *l2);
108 void LtoLMomentum(const Int_t *id1,const Int_t *id2,
109 const Double_t *l1,Double_t *l2);
110 void GtoLErrorMatrix(const Int_t index,Double_t **g,Double_t **l);
111 void LtoGErrorMatrix(const Int_t index,Double_t **l,Double_t **g);
112 void LtoLErrorMatrix(const Int_t index1,const Int_t index2,
113 Double_t **l1,Double_t **l2);
114 Int_t GetModuleIndex(Int_t lay,Int_t lad,Int_t det);
115 void GetModuleId(Int_t index,Int_t &lay,Int_t &lad,Int_t &det);
116 void GlobalChange(Float_t *tran,Float_t *rot);
117 void GlobalCylindericalChange(Float_t *tran,Float_t *rot);
118 void RandomChange(Float_t *stran,Float_t *srot);
119 void RandomCylindericalChange(Float_t *stran,Float_t *srot);
120 void PrintComparison(FILE *fp,AliITSgeom *other);
121 void PrintData(FILE *fp,Int_t lay,Int_t lad,Int_t det);
122 ofstream &PrintGeom(ofstream &out);
123 ifstream &ReadGeom(ifstream &in);
124 virtual Int_t IsVersion() const {return 1;}
125 void AddShape(TObject *shp){fShape->AddLast(shp);}
126 virtual TObject *GetShape(Int_t lay,Int_t lad,Int_t det)
127 const {return fShape->At(fg[lay-1][fNdet[lay-1]*(lad-1)+det-1].
130 void GeantToTracking(AliITSgeom &source); // This converts the geometry
131 // transformations from that used by the ITS and it's Monte Carlo to that
132 // used by the track finding code.
134 // AliITSgeom *gm,*gt;
135 // gm = ((AliITS *) ITS)->GetITSgeom();
136 // gt->GeantToTracking(*gm);
137 // This allocates and fills gt with the geometry transforms between the
138 // global coordinate system to the local coordinate system used to do
141 ClassDef(AliITSgeom,1) // ITS geometry class