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 /////////////////////////////////////////////////////////////////////////
20 #include <Riostream.h>
22 #include <TObjArray.h>
28 #include "AliITSgeomMatrix.h"
30 typedef enum {kND=-1,kSPD=0, kSDD=1, kSSD=2, kSSDp=3,kSDDp=4} AliITSDetector;
32 //_______________________________________________________________________
34 class AliITSgeom : public TObject {
37 AliITSgeom(); // Default constructor
38 AliITSgeom(const char *filename); // Constructor
39 AliITSgeom(Int_t itype,Int_t nlayers,const Int_t *nlads,const Int_t *ndets,
40 Int_t nmods); // Constructor
41 virtual ~AliITSgeom(); // Default destructor
42 // Zero and reinitilizes this class.
43 void Init(Int_t itype,Int_t nlayers,const Int_t *nlads,
44 const Int_t *ndets,Int_t mods);
45 // this function allocates a AliITSgeomMatrix for a particular module.
46 void CreateMatrix(Int_t mod,Int_t lay,Int_t lad,Int_t det,
47 AliITSDetector idet,const Double_t tran[3],
48 const Double_t rot[10]);
49 void ReadNewFile(const char *filename); // Constructor for new format.
50 void WriteNewFile(const char *filename)const; // Output for new format.
52 Int_t GetTransformationType() const {return fTrans;}
54 // returns kTRUE if the transformation defined by this class is
55 // for Global GEANT coordinate system to the local GEANT coordinate system
56 // of the detector. These are the transformation used by GEANT.
57 Bool_t IsGeantToGeant() const {return (fTrans == 0);}
58 // returns kTRUE if the transformation defined by this class is
59 // for Global GEANT coordinate system to the local "Tracking" coordinate
60 // system of the detector. These are the transformation used by the
62 Bool_t IsGeantToTracking() const {return ((fTrans&&0xfffe)!= 0);}
63 // returns kTRUE if the transformation defined by this class is
64 // for Global GEANT coordinate system to the local GEANT coordinate system
65 // of the detector but may have been displaced by some typically small
66 // amount. These are modified transformation similar to that used by GEANT.
67 Bool_t IsGeantToDisplaced() const {return ((fTrans&&0xfffd)!= 0);}
68 // returns kTRUE if the shape defined by ishape has been defined in this
69 // set of transformations. Typical values of ishape are kSPD, kSDD, kSSD,
71 Bool_t IsShapeDefined(Int_t ishape)const {
72 return ((fShape.At(ishape))!=0);}
74 // This function returns a pointer to the particular AliITSgeomMatrix
75 // class for a specific module index.
76 AliITSgeomMatrix *GetGeomMatrix(Int_t index){if(index<fGm.GetSize()&&index>=0)
77 return (AliITSgeomMatrix*)(fGm.At(index));else Error("GetGeomMatrix","index=%d<0||>=GetSize()=%d",index,fGm.GetSize());return 0;}
78 AliITSgeomMatrix *GetGeomMatrix(Int_t index)const{if(index<fGm.GetSize()&&index>=0)
79 return (AliITSgeomMatrix*)(fGm.At(index));else Error("GetGeomMatrix","index=%d<0||>=GetSize()=%d",index,fGm.GetSize());return 0;}
80 // This function find and return the number of detector types only.
81 Int_t GetNDetTypes()const{Int_t max;return GetNDetTypes(max);};
82 // This function find and return the number of detector types and the
83 // maximum det type value.
84 Int_t GetNDetTypes(Int_t &max)const;
85 // This function finds and return the number of detector types and the
86 // and the number of each type in the TArrayI and their types.
87 Int_t GetNDetTypes(TArrayI &maxs,AliITSDetector *types)const;
88 // This function returns the number of detectors/ladder for a give
89 // layer. In particular it returns fNdet[layer-1].
90 Int_t GetNdetectors(Int_t lay) const {return fNdet[lay-1];}
91 // This function returns the number of ladders for a give layer. In
92 // particular it returns fNlad[layer-1].
93 Int_t GetNladders(Int_t lay) const {return fNlad[lay-1];};
94 // This function returns the number of layers defined in the ITS
95 // geometry. In particular it returns fNlayers.
96 Int_t GetNlayers() const {return fNlayers;}
97 Int_t GetModuleIndex(Int_t lay,Int_t lad,Int_t det)const;
98 // This function returns the module index number given the layer,
99 // ladder and detector numbers put into the array id[3].
100 Int_t GetModuleIndex(const Int_t *id)const{
101 return GetModuleIndex(id[0],id[1],id[2]);}
102 void GetModuleId(Int_t index,Int_t &lay,Int_t &lad,Int_t &det)const;
103 // Returns the detector type
104 //Int_t GetModuleType(Int_t index)const{
105 // return GetGeomMatrix(index)->GetDetectorIndex();}
106 AliITSDetector GetModuleType(Int_t index)const{
107 return (AliITSDetector)(GetGeomMatrix(index)->GetDetectorIndex());}
108 // Returns the detector type as a string
109 const char * GetModuleTypeName(Int_t index)const{
110 return GetDetectorTypeName(GetModuleType(index));}
111 // Returns the detector type as a string
112 const char * GetDetectorTypeName(Int_t index)const{switch(index) {
113 case kSPD : return "kSPD" ; case kSDD : return "kSDD" ;
114 case kSSD : return "kSSD" ; case kSSDp: return "kSSDp";
115 case kSDDp: return "kSDDp"; default : return "Undefined";};}
117 Int_t GetStartDet(Int_t dtype )const;
118 Int_t GetLastDet(Int_t dtype)const;
119 // Returns the starting module index number for SPD detector,
120 // assuming the modules are placed in the "standard" cylindrical
122 Int_t GetStartSPD()const{return GetStartDet(kSPD);}
123 // Returns the ending module index number for SPD detector,
124 // assuming the modules are placed in the "standard" cylindrical
126 Int_t GetLastSPD()const{return GetLastDet(kSPD);}
127 // Returns the starting module index number for SDD detector,
128 // assuming the modules are placed in the "standard" cylindrical
130 Int_t GetStartSDD()const{return GetStartDet(kSDD);}
131 // Returns the ending module index number for SDD detector,
132 // assuming the modules are placed in the "standard" cylindrical
134 Int_t GetLastSDD()const{return GetLastDet(kSDD);}
135 // Returns the starting module index number for SSD detector,
136 // assuming the modules are placed in the "standard" cylindrical
138 Int_t GetStartSSD()const{return GetStartDet(kSSD);}
139 // Returns the ending module index number for SSD detector,
140 // assuming the modules are placed in the "standard" cylindrical
142 Int_t GetLastSSD()const{return GetLastDet(kSSD);}
143 // Returns the last module index number.
144 Int_t GetIndexMax() const {return fNmodules;}
146 // This function returns the rotation angles for a give module
147 // in the Double point array ang[3]. The angles are in radians
148 void GetAngles(Int_t index,Double_t *ang)const{
149 GetGeomMatrix(index)->GetAngles(ang);}
150 // This function returns the rotation angles for a give module
151 // in the three floating point variables provided. rx = frx,
152 // fy = fry, rz = frz. The angles are in radians
153 void GetAngles(Int_t index,Float_t &rx,Float_t &ry,Float_t &rz)const{
154 Double_t a[3];GetAngles(index,a);rx = a[0];ry = a[1];rz = a[2];}
155 // This function returns the rotation angles for a give detector on
156 // a give ladder in a give layer in the three floating point variables
157 // provided. rx = frx, fy = fry, rz = frz. The angles are in radians
158 void GetAngles(Int_t lay,Int_t lad,Int_t det,
159 Float_t &rx,Float_t &ry,Float_t &rz)const{
160 GetAngles(GetModuleIndex(lay,lad,det),rx,ry,rz);}
162 // This function returns the 6 GEANT rotation angles for a give
163 // module in the double point array ang[3]. The angles are in degrees
164 void GetGeantAngles(Int_t index,Double_t *ang)const{
165 GetGeomMatrix(index)->SixAnglesFromMatrix(ang);}
167 // This function returns the Cartesian translation for a give
168 // module in the Double array t[3]. The units are
169 // those of the Monte Carlo, generally cm.
170 void GetTrans(Int_t index,Double_t *t)const{
171 GetGeomMatrix(index)->GetTranslation(t);}
172 // This function returns the Cartesian translation for a give
173 // module index in the three floating point variables provided.
174 // x = fx0, y = fy0, z = fz0. The units are those of the Mont
175 // Carlo, generally cm.
176 void GetTrans(Int_t index,Float_t &x,Float_t &y,Float_t &z)const{
177 Double_t t[3];GetTrans(index,t);x = t[0];y = t[1];z = t[2];}
178 // This function returns the Cartesian translation for a give
179 // detector on a give ladder in a give layer in the three floating
180 // point variables provided. x = fx0, y = fy0, z = fz0. The units are
181 // those of the Monte Carlo, generally cm.
182 void GetTrans(Int_t lay,Int_t lad,Int_t det,
183 Float_t &x,Float_t &y,Float_t &z)const{
184 GetTrans(GetModuleIndex(lay,lad,det),x,y,z);}
186 // This function returns the Cartesian translation for a give
187 // module in the Double array t[3]. The units are
188 // those of the Monte Carlo, generally cm.
189 void GetTransCyln(Int_t index,Double_t *t)const{
190 GetGeomMatrix(index)->GetTranslationCylinderical(t);}
191 // This function returns the Cartesian translation for a give
192 // module index in the three floating point variables provided.
193 // x = fx0, y = fy0, z = fz0. The units are those of the Mont
194 // Carlo, generally cm.
195 void GetTransCyln(Int_t index,Float_t &x,Float_t &y,Float_t &z)const{
196 Double_t t[3];GetTransCyln(index,t);x = t[0];y = t[1];z = t[2];}
197 // This function returns the Cartesian translation for a give
198 // detector on a give ladder in a give layer in the three floating
199 // point variables provided. x = fx0, y = fy0, z = fz0. The units are
200 // those of the Monte Carlo, generally cm.
201 void GetTransCyln(Int_t lay,Int_t lad,Int_t det,
202 Float_t &x,Float_t &y,Float_t &z)const{
203 GetTransCyln(GetModuleIndex(lay,lad,det),x,y,z);}
205 // This function returns the Cartesian translation [cm] and the
206 // 6 GEANT rotation angles [degrees]for a given layer ladder and
207 // detector number, in the TVector x (at least 9 elements large).
208 // This function is required to be in-lined for speed.
209 void GetCenterThetaPhi(Int_t lay,Int_t lad,Int_t det,TVector &x)const{
210 Double_t t[3],a[6];Int_t i=GetModuleIndex(lay,lad,det);GetTrans(i,t);
211 GetGeantAngles(i,a);x(0)=t[0];x(1)=t[1];x(2)=t[2];x(3)=a[0];x(4)=a[1];
212 x(5)=a[2];x(6)=a[3];x(7)=a[4];x(8)=a[5];}
214 // This function returns the rotation matrix in Double
215 // precision for a given module.
216 void GetRotMatrix(Int_t index,Double_t mat[3][3])const{
217 GetGeomMatrix(index)->GetMatrix(mat);}
218 // This function returns the rotation matrix in a Double
219 // precision pointer for a given module. mat[i][j] => mat[3*i+j].
220 void GetRotMatrix(Int_t index,Double_t *mat)const{
221 Double_t rot[3][3];GetRotMatrix(index,rot);
222 for(Int_t i=0;i<3;i++)for(Int_t j=0;j<3;j++) mat[3*i+j] = rot[i][j];}
223 // This function returns the rotation matrix in a floating
224 // precision pointer for a given layer ladder and detector module.
225 // mat[i][j] => mat[3*i+j].
226 void GetRotMatrix(Int_t lay,Int_t lad,Int_t det,Float_t *mat)const{
227 GetRotMatrix(GetModuleIndex(lay,lad,det),mat);}
228 // This function returns the rotation matrix in a Double
229 // precision pointer for a given layer ladder and detector module.
230 // mat[i][j] => mat[3*i+j].
231 void GetRotMatrix(Int_t lay,Int_t lad,Int_t det,Double_t *mat)const{
232 GetRotMatrix(GetModuleIndex(lay,lad,det),mat);}
233 // This function returns the rotation matrix in a floating
234 // precision pointer for a given module. mat[i][j] => mat[3*i+j].
235 void GetRotMatrix(Int_t index,Float_t *mat)const{
237 GetGeomMatrix(index)->GetMatrix(rot);
238 for(Int_t i=0;i<3;i++)for(Int_t j=0;j<3;j++) mat[3*i+j] = rot[i][j];}
239 // This function sets the rotation matrix in a Double
240 // precision pointer for a given module. mat[i][j] => mat[3*i+j].
241 void SetRotMatrix(Int_t index,Double_t *mat){Double_t rot[3][3];
242 for(Int_t i=0;i<3;i++)for(Int_t j=0;j<3;j++) rot[i][j]=mat[3*i+j];
243 GetGeomMatrix(index)->SetMatrix(rot);}
245 // Will define fShape if it isn't already defined.
246 void DefineShapes(Int_t size=5){fShape.Expand(size);}
247 // this function returns a pointer to the array of detector
248 // descriptions, Segmentation.
249 virtual TObjArray *GetShapeArray(){return &fShape;};
250 // this function returns a pointer to the class describing a particular
251 // detector type based on AliITSDetector value. This will return a pointer
252 // to one of the classes AliITSgeomSPD, AliITSgeomSDD, or
253 // AliITSgeomSSD, for example.
254 virtual TObject *GetShape(AliITSDetector idet){
255 return fShape.At((Int_t)idet);};
256 virtual TObject *GetShape(AliITSDetector idet)const{
257 return fShape.At((Int_t)idet);};
258 // This function returns a pointer to the class describing the
259 // detector for a particular module index. This will return a pointer
260 // to one of the classes AliITSgeomSPD, AliITSgeomSDD,
261 // or AliITSgeomSSD, for example.
262 virtual TObject *GetShape(Int_t index){
263 return fShape.At(GetGeomMatrix(index)->GetDetectorIndex());}
264 virtual TObject *GetShape(Int_t index)const{
265 return fShape.At(GetGeomMatrix(index)->GetDetectorIndex());}
266 // This function returns a pointer to the class describing the
267 // detector for a particular layer ladder and detector numbers. This
268 // will return a pointer to one of the classes AliITSgeomSPD,
269 // AliITSgeomSDD, or AliITSgeomSSD, for example.
270 virtual TObject *GetShape(Int_t lay,Int_t lad,Int_t det)
271 {return GetShape(GetModuleIndex(lay,lad,det));}
274 // Sets the rotation angles and matrix for a give module index
275 // via the double precision array a[3] [radians].
276 void SetByAngles(Int_t index,const Double_t a[]){
277 GetGeomMatrix(index)->SetAngles(a);}
278 // Sets the rotation angles and matrix for a give module index
279 // via the 3 floating precision variables rx, ry, and rz [radians].
280 void SetByAngles(Int_t index,Float_t rx, Float_t ry, Float_t rz) {
281 Double_t a[3];a[0] = rx;a[1] = ry;a[2] = rz;
282 GetGeomMatrix(index)->SetAngles(a);}
283 // Sets the rotation angles and matrix for a give layer, ladder,
284 // and detector numbers via the 3 floating precision variables rx,
285 // ry, and rz [radians].
286 void SetByAngles(Int_t lay,Int_t lad,Int_t det,
287 Float_t rx, Float_t ry, Float_t rz) {
288 SetByAngles(GetModuleIndex(lay,lad,det),rx,ry,rz);}
290 // Sets the rotation angles and matrix for a give module index
291 // via the Double precision array a[6] [degree]. The angles are those
292 // defined by GEANT 3.12.
293 void SetByGeantAngles(Int_t index,const Double_t *ang){
294 GetGeomMatrix(index)->MatrixFromSixAngles(ang);}
295 // Sets the rotation angles and matrix for a give layer, ladder
296 // and detector, in the array id[3] via the Double precision array
297 // a[6] [degree]. The angles are those defined by GEANT 3.12.
298 void SetByGeantAngles(const Int_t *id,const Double_t *ang){
299 SetByGeantAngles(GetModuleIndex(id),ang);}
300 // Sets the rotation angles and matrix for a give layer, ladder
301 // and detector, via the Double precision array a[6] [degree]. The
302 // angles are those defined by GEANT 3.12.
303 void SetByGeantAngles(Int_t lay,Int_t lad,Int_t det,
304 const Double_t *ang){
305 SetByGeantAngles(GetModuleIndex(lay,lad,det),ang);}
307 // This function sets a new translation vector, given by the
308 // array x[3], for the Cartesian coordinate transformation
309 // for a give module index.
310 void SetTrans(Int_t index,Double_t x[]){
311 GetGeomMatrix(index)->SetTranslation(x);}
312 // This function sets a new translation vector, given by the three
313 // variables x, y, and z, for the Cartesian coordinate transformation
314 // for the detector defined by layer, ladder and detector.
315 void SetTrans(Int_t lay,Int_t lad,Int_t det,
316 Float_t x,Float_t y,Float_t z){Double_t t[3];
317 t[0] = x;t[1] = y;t[2] = z;
318 SetTrans(GetModuleIndex(lay,lad,det),t);}
320 // This function adds one more shape element to the TObjArray
321 // fShape. It is primarily used in the constructor functions of the
322 // AliITSgeom class. The pointer *shape can be the pointer to any
323 // class that is derived from TObject (this is true for nearly every
324 // ROOT class). This does not appear to be working properly at this time.
325 void AddShape(TObject *shp){fShape.AddLast(shp);}
326 // This function deletes an existing shape element, of type TObject,
327 // and replaces it with the one specified. This is primarily used to
328 // changes the parameters to the geom class for a particular
330 void ReSetShape(Int_t dtype,TObject *shp){
331 delete (fShape.At(dtype));fShape.AddAt(shp,dtype);}
334 // Transforms from the ALICE Global coordinate system
335 // to the detector local coordinate system for the detector
336 // defined by the layer, ladder, and detector numbers. The
337 // global and local coordinate are given in two floating point
338 // arrays g[3], and l[3].
339 void GtoL(Int_t lay,Int_t lad,Int_t det,
340 const Float_t *g,Float_t *l)const{
341 GtoL(GetModuleIndex(lay,lad,det),g,l);}
342 // Transforms from the ALICE Global coordinate system
343 // to the detector local coordinate system for the detector
344 // defined by the id[0], id[1], and id[2] numbers. The
345 // global and local coordinate are given in two floating point
346 // arrays g[3], and l[3].
347 void GtoL(const Int_t *id,const Float_t *g,Float_t *l)const{
348 GtoL(GetModuleIndex(id),g,l);}
349 // Transforms from the ALICE Global coordinate system
350 // to the detector local coordinate system for the detector
351 // module index number. The global and local coordinate are
352 // given in two floating point arrays g[3], and l[3].
353 void GtoL(Int_t index,const Float_t *g,Float_t *l)const{
354 Double_t dg[3],dl[3];Int_t i;for(i=0;i<3;i++) dg[i] = g[i];
355 GetGeomMatrix(index)->GtoLPosition(dg,dl);
356 for(i=0;i<3;i++) l[i] =dl[i];}
357 // Transforms from the ALICE Global coordinate system
358 // to the detector local coordinate system for the detector
359 // defined by the layer, ladder, and detector numbers. The
360 // global and local coordinate are given in two Double point
361 // arrays g[3], and l[3].
362 void GtoL(Int_t lay,Int_t lad,Int_t det,
363 const Double_t *g,Double_t *l)const{
364 GtoL(GetModuleIndex(lay,lad,det),g,l);}
365 // Transforms from the ALICE Global coordinate system
366 // to the detector local coordinate system for the detector
367 // defined by the id[0], id[1], and id[2] numbers. The
368 // global and local coordinate are given in two Double point
369 // arrays g[3], and l[3].
370 void GtoL(const Int_t *id,const Double_t *g,Double_t *l)const{
371 GtoL(GetModuleIndex(id),g,l);}
372 // Transforms from the ALICE Global coordinate system
373 // to the detector local coordinate system for the detector
374 // module index number. The global and local coordinate are
375 // given in two Double point arrays g[3], and l[3].
376 void GtoL(Int_t index,const Double_t g[3],Double_t l[3])const{
377 GetGeomMatrix(index)->GtoLPosition(g,l);}
379 // Transforms from the ALICE Global coordinate system
380 // to the detector local coordinate system (used for ITS tracking)
381 // for the detector module index number. The global and local
382 // coordinate are given in two Double point arrays g[3], and l[3].
383 void GtoLtracking(Int_t index,const Double_t *g,Double_t *l)const{
384 if(IsGeantToTracking()) GtoL(index,g,l);
385 else GetGeomMatrix(index)->GtoLPositionTracking(g,l);}
386 // Transforms from the ALICE Global coordinate system
387 // to the detector local coordinate system (used for ITS tracking)
388 // for the detector id[3]. The global and local
389 // coordinate are given in two Double point arrays g[3], and l[3].
390 void GtoLtracking(const Int_t *id,const Double_t *g,Double_t *l)const{
391 GtoLtracking(GetModuleIndex(id),g,l);}
392 // Transforms from the ALICE Global coordinate system
393 // to the detector local coordinate system (used for ITS tracking)
394 // for the detector layer ladder and detector numbers. The global
395 // and local coordinate are given in two Double point arrays g[3],
397 void GtoLtracking(Int_t lay,Int_t lad,Int_t det,
398 const Double_t *g,Double_t *l)const{
399 GtoLtracking(GetModuleIndex(lay,lad,det),g,l);}
401 // Transforms of momentum types of quantities from the ALICE
402 // Global coordinate system to the detector local coordinate system
403 // for the detector layer ladder and detector numbers. The global
404 // and local coordinate are given in two float point arrays g[3],
406 void GtoLMomentum(Int_t lay,Int_t lad,Int_t det,
407 const Float_t *g,Float_t *l)const{
408 GtoLMomentum(GetModuleIndex(lay,lad,det),g,l);}
409 // Transforms of momentum types of quantities from the ALICE
410 // Global coordinate system to the detector local coordinate system
411 // for the detector module index number. The global and local
412 // coordinate are given in two float point arrays g[3], and l[3].
413 void GtoLMomentum(Int_t index,const Float_t *g,Float_t *l)const{
414 Double_t dg[3],dl[3];Int_t i;for(i=0;i<3;i++) dg[i] = g[i];
415 GetGeomMatrix(index)->GtoLMomentum(dg,dl);
416 for(i=0;i<3;i++) l[i] =dl[i];}
417 // Transforms of momentum types of quantities from the ALICE
418 // Global coordinate system to the detector local coordinate system
419 // for the detector layer ladder and detector numbers. The global
420 // and local coordinate are given in two Double point arrays g[3],
422 void GtoLMomentum(Int_t lay,Int_t lad,Int_t det,
423 const Double_t *g,Double_t *l)const{
424 GtoLMomentum(GetModuleIndex(lay,lad,det),g,l);}
425 // Transforms of momentum types of quantities from the ALICE
426 // Global coordinate system to the detector local coordinate system
427 // for the detector module index number. The global and local
428 // coordinate are given in two Double point arrays g[3], and l[3].
429 void GtoLMomentum(Int_t index,const Double_t *g,Double_t *l)const{
430 Double_t dg[3],dl[3];Int_t i;for(i=0;i<3;i++) dg[i] = g[i];
431 GetGeomMatrix(index)->GtoLMomentum(dg,dl);
432 for(i=0;i<3;i++) l[i] =dl[i];}
434 // Transforms of momentum types of quantities from the ALICE
435 // Global coordinate system to the detector local coordinate system
436 // (used for ITS tracking) for the detector module index number.
437 // The global and local coordinate are given in two Double point
438 // arrays g[3], and l[3].
439 void GtoLMomentumTracking(Int_t index,const Double_t *g,Double_t *l)const{
440 if(IsGeantToTracking()) GtoLMomentum(index,g,l);
441 else GetGeomMatrix(index)->GtoLMomentumTracking(g,l);}
442 // Transforms of momentum types of quantities from the ALICE
443 // Global coordinate system to the detector local coordinate system
444 // (used for ITS tracking) for the detector id[3].
445 // The global and local coordinate are given in two Double point
446 // arrays g[3], and l[3].
447 void GtoLMomentumTracking(const Int_t *id,
448 const Double_t *g,Double_t *l)const{
449 GtoLMomentumTracking(GetModuleIndex(id),g,l);}
450 // Transforms of momentum types of quantities from the ALICE
451 // Global coordinate system to the detector local coordinate system
452 // (used for ITS tracking) for the detector layer ladder and detector
453 // numbers. The global and local coordinate are given in two Double point
454 // arrays g[3], and l[3].
455 void GtoLMomentumTracking(Int_t lay,Int_t lad,Int_t det,
456 const Double_t *g,Double_t *l)const{
457 GtoLMomentumTracking(GetModuleIndex(lay,lad,det),g,l);}
459 // Transforms from the detector local coordinate system
460 // to the ALICE Global coordinate system for the detector
461 // defined by the layer, ladder, and detector numbers. The
462 // global and local coordinate are given in two floating point
463 // arrays g[3], and l[3].
464 void LtoG(Int_t lay,Int_t lad,Int_t det,
465 const Float_t *l,Float_t *g)const{
466 LtoG(GetModuleIndex(lay,lad,det),l,g);}
467 // Transforms from the detector local coordinate system
468 // to the ALICE Global coordinate system for the detector
469 // defined by the id[0], id[1], and id[2] numbers. The
470 // global and local coordinate are given in two floating point
471 // arrays g[3], and l[3].
472 void LtoG(const Int_t *id,const Float_t *l,Float_t *g)const{
473 LtoG(GetModuleIndex(id),l,g);}
474 // Transforms from the detector local coordinate system
475 // to the ALICE Global coordinate system for the detector
476 // module index number. The global and local coordinate are
477 // given in two floating point arrays g[3], and l[3].
478 void LtoG(Int_t index,const Float_t *l,Float_t *g)const{
479 Double_t dg[3],dl[3];Int_t i;for(i=0;i<3;i++) dl[i] = l[i];
480 GetGeomMatrix(index)->LtoGPosition(dl,dg);
481 for(i=0;i<3;i++) g[i] =dg[i];}
482 // Transforms from the detector local coordinate system
483 // to the ALICE Global coordinate system for the detector
484 // defined by the layer, ladder, and detector numbers. The
485 // global and local coordinate are given in two Double point
486 // arrays g[3], and l[3].
487 void LtoG(Int_t lay,Int_t lad,Int_t det,
488 const Double_t *l,Double_t *g)const{
489 LtoG(GetModuleIndex(lay,lad,det),l,g);}
490 // Transforms from the detector local coordinate system
491 // to the ALICE Global coordinate system for the detector
492 // defined by the id[0], id[1], and id[2] numbers. The
493 // global and local coordinate are given in two Double point
494 // arrays g[3], and l[3].
495 void LtoG(const Int_t *id,const Double_t *l,Double_t *g)const{
496 LtoG(GetModuleIndex(id),l,g);}
497 // Transforms from the detector local coordinate system
498 // to the ALICE Global coordinate system for the detector
499 // module index number. The global and local coordinate are
500 // given in two Double point arrays g[3], and l[3].
501 void LtoG(Int_t index,const Double_t *l,Double_t *g)const{
502 GetGeomMatrix(index)->LtoGPosition(l,g);}
504 // Transforms from the detector local coordinate system (used
505 // for ITS tracking) to the ALICE Global coordinate system
506 // for the detector module index number. The global and local
507 // coordinate are given in two Double point arrays g[3], and l[3].
508 void LtoGtracking(Int_t index,const Double_t *l,Double_t *g)const{
509 if(IsGeantToTracking()) LtoG(index,l,g);
510 else GetGeomMatrix(index)->LtoGPositionTracking(l,g);}
511 // Transforms from the detector local coordinate system (used
512 // for ITS tracking) to the ALICE Global coordinate system
513 // for the detector id[3]. The global and local
514 // coordinate are given in two Double point arrays g[3], and l[3].
515 void LtoGtracking(const Int_t *id,const Double_t *l,Double_t *g)const{
516 LtoGtracking(GetModuleIndex(id),l,g);}
517 // Transforms from the detector local coordinate system (used
518 // for ITS tracking) to the detector local coordinate system
519 // for the detector layer ladder and detector numbers. The global
520 // and local coordinate are given in two Double point arrays g[3],
522 void LtoGtracking(Int_t lay,Int_t lad,Int_t det,
523 const Double_t *l,Double_t *g)const{
524 LtoGtracking(GetModuleIndex(lay,lad,det),l,g);}
526 // Transforms of momentum types of quantities from the detector
527 // local coordinate system to the ALICE Global coordinate system
528 // for the detector layer ladder and detector numbers. The global
529 // and local coordinate are given in two float point arrays g[3],
531 void LtoGMomentum(Int_t lay,Int_t lad,Int_t det,
532 const Float_t *l,Float_t *g)const{
533 LtoGMomentum(GetModuleIndex(lay,lad,det),l,g);}
534 // Transforms of momentum types of quantities from the detector
535 // local coordinate system to the ALICE Global coordinate system
536 // for the detector module index number. The global and local
537 // coordinate are given in two float point arrays g[3], and l[3].
538 void LtoGMomentum(Int_t index,const Float_t *l,Float_t *g)const{
539 Double_t dg[3],dl[3];Int_t i;for(i=0;i<3;i++) dl[i] = l[i];
540 GetGeomMatrix(index)->LtoGMomentum(dl,dg);
541 for(i=0;i<3;i++) g[i] =dg[i];}
542 // Transforms of momentum types of quantities from the detector
543 // local coordinate system to the ALICE Global coordinate system
544 // for the detector layer ladder and detector numbers. The global
545 // and local coordinate are given in two Double point arrays g[3],
547 void LtoGMomentum(Int_t lay,Int_t lad,Int_t det,
548 const Double_t *l,Double_t *g)const{
549 LtoGMomentum(GetModuleIndex(lay,lad,det),l,g);}
550 // Transforms of momentum types of quantities from the detector
551 // local coordinate system to the ALICE Global coordinate system
552 // for the detector module index number. The global and local
553 // coordinate are given in two Double point arrays g[3], and l[3].
554 void LtoGMomentum(Int_t index,const Double_t *l,Double_t *g)const{
555 GetGeomMatrix(index)->LtoGMomentum(l,g);}
557 // Transforms of momentum types of quantities from the detector
558 // local coordinate system (used for ITS tracking) to the detector
559 // system ALICE Global for the detector module index number.
560 // The global and local coordinate are given in two Double point
561 // arrays g[3], and l[3].
562 void LtoGMomentumTracking(Int_t index,const Double_t *l,Double_t *g)const{
563 if(IsGeantToTracking()) LtoGMomentum(index,l,g);
564 else GetGeomMatrix(index)->LtoGMomentumTracking(l,g);}
565 // Transforms of momentum types of quantities from the detector
566 // local coordinate system (used for ITS tracking) to the ALICE
567 // Global coordinate system for the detector id[3].
568 // The global and local coordinate are given in two Double point
569 // arrays g[3], and l[3].
570 void LtoGMomentumTracking(const Int_t *id,const Double_t *l,Double_t *g)const{
571 LtoGMomentumTracking(GetModuleIndex(id),l,g);}
572 // Transforms of momentum types of quantities from the detector
573 // local coordinate system (used for ITS tracking) to the ALICE
574 // Global coordinate system for the detector layer ladder and detector
575 // numbers. The global and local coordinate are given in two Double point
576 // arrays g[3], and l[3].
577 void LtoGMomentumTracking(Int_t lay,Int_t lad,Int_t det,
578 const Double_t *l,Double_t *g)const{
579 LtoGMomentumTracking(GetModuleIndex(lay,lad,det),l,g);}
581 // Transforms from one detector local coordinate system
582 // to another detector local coordinate system for the detector
583 // module index1 number to the detector module index2 number. The
584 // local coordinates are given in two Double point arrays l1[3],
586 void LtoL(Int_t index1,Int_t index2,Double_t *l1,Double_t *l2)const{
587 Double_t g[3]; LtoG(index1,l1,g);GtoL(index2,g,l2);}
588 // Transforms from one detector local coordinate system
589 // to another detector local coordinate system for the detector
590 // id1[3] to the detector id2[3]. The local coordinates are given
591 // in two Double point arrays l1[3], and l2[3].
592 void LtoL(const Int_t *id1,const Int_t *id2,Double_t *l1,Double_t *l2)const{
593 LtoL(GetModuleIndex(id1[0],id1[1],id1[2]),
594 GetModuleIndex(id2[0],id2[1],id2[2]),l1,l2);}
596 // Transforms from one detector local coordinate system (used for
597 // ITS tracking) to another detector local coordinate system (used
598 // for ITS tracking) for the detector module index1 number to the
599 // detector module index2 number. The local coordinates are given
600 // in two Double point arrays l1[3], and l2[3].
601 void LtoLtracking(Int_t index1,Int_t index2,
602 Double_t *l1,Double_t *l2)const{
603 Double_t g[3]; LtoGtracking(index1,l1,g);GtoLtracking(index2,g,l2);}
604 // Transforms from one detector local coordinate system (used for
605 // ITS tracking) to another detector local coordinate system (used
606 // for ITS tracking) for the detector id1[3] to the detector id2[3].
607 // The local coordinates are given in two Double point arrays l1[3],
609 void LtoLtracking(const Int_t *id1,const Int_t *id2,
610 Double_t *l1,Double_t *l2)const{
611 LtoLtracking(GetModuleIndex(id1[0],id1[1],id1[2]),
612 GetModuleIndex(id2[0],id2[1],id2[2]),l1,l2);}
614 // Transforms of momentum types of quantities from one detector
615 // local coordinate system to another detector local coordinate
616 // system for the detector module index1 number to the detector
617 // module index2 number. The local coordinates are given in two
618 // Double point arrays l1[3], and l2[3].
619 void LtoLMomentum(Int_t index1,Int_t index2,
620 const Double_t *l1,Double_t *l2)const{
621 Double_t g[3]; LtoGMomentum(index1,l1,g);GtoLMomentum(index2,g,l2);}
622 // Transforms of momentum types of quantities from one detector
623 // local coordinate system to another detector local coordinate
624 // system for the detector id1[3] to the detector id2[3]. The local
625 // coordinates are given in two Double point arrays l1[3], and l2[3].
626 void LtoLMomentum(const Int_t *id1,const Int_t *id2,
627 const Double_t *l1,Double_t *l2)const{
628 LtoLMomentum(GetModuleIndex(id1[0],id1[1],id1[2]),
629 GetModuleIndex(id2[0],id2[1],id2[2]),l1,l2);}
631 // Transforms of momentum types of quantities from one detector
632 // local coordinate system (used by ITS tracking) to another detector
633 // local coordinate system (used by ITS tracking) for the detector
634 // module index1 number to the detector module index2 number. The
635 // local coordinates are given in two Double point arrays l1[3],
637 void LtoLMomentumTracking(Int_t index1,Int_t index2,
638 Double_t *l1,Double_t *l2)const{
639 Double_t g[3]; LtoGMomentumTracking(index1,l1,g);
640 GtoLMomentumTracking(index2,g,l2);}
641 // Transforms of momentum types of quantities from one detector
642 // local coordinate system (used by ITS tracking) to another detector
643 // local coordinate system (used by ITS tracking) for the detector
644 // id1[3] to the detector id2[3]. The local coordinates are given in
645 // two Double point arrays l1[3], and l2[3].
646 void LtoLMomentumTracking(const Int_t *id1,const Int_t *id2,
647 Double_t *l1,Double_t *l2)const{
648 LtoLMomentumTracking(GetModuleIndex(id1[0],id1[1],id1[2]),
649 GetModuleIndex(id2[0],id2[1],id2[2]),l1,l2);}
651 // Transforms a matrix, like an Uncertainty or Error matrix from
652 // the ALICE Global coordinate system to a detector local coordinate
653 // system. The specific detector is determined by the module index
655 void GtoLErrorMatrix(Int_t index,const Double_t **g,Double_t **l)const{
656 GetGeomMatrix(index)->GtoLPositionError((Double_t (*)[3])g,(Double_t (*)[3])l);}
658 // Transforms a matrix, like an Uncertainty or Error matrix from
659 // the ALICE Global coordinate system to a detector local coordinate
660 // system (used by ITS tracking). The specific detector is determined
661 // by the module index number.
662 void GtoLErrorMatrixTracking(Int_t index,const Double_t **g,
664 if(IsGeantToTracking()) GetGeomMatrix(index)->GtoLPositionError((
665 Double_t (*)[3])g,(Double_t (*)[3])l);
666 else GetGeomMatrix(index)->GtoLPositionErrorTracking(
667 (Double_t (*)[3])g,(Double_t (*)[3])l);}
669 // Transforms a matrix, like an Uncertainty or Error matrix from
670 // the detector local coordinate system to a ALICE Global coordinate
671 // system. The specific detector is determined by the module index
673 void LtoGErrorMatrix(Int_t index,const Double_t **l,Double_t **g)const{
674 GetGeomMatrix(index)->LtoGPositionError((Double_t (*)[3])l,(Double_t (*)[3])g);}
676 // Transforms a matrix, like an Uncertainty or Error matrix from
677 // the detector local coordinate system (used by ITS tracking) to a
678 // ALICE Global coordinate system. The specific detector is determined
679 // by the module index number.
680 void LtoGErrorMatrixTracking(Int_t index,const Double_t **l,
682 if(IsGeantToTracking()) GetGeomMatrix(index)->LtoGPositionError((
683 Double_t (*)[3])g,(Double_t (*)[3])l);
684 else GetGeomMatrix(index)->LtoGPositionErrorTracking((Double_t (*)[3])l,
685 (Double_t (*)[3])g);}
687 // Transforms a matrix, like an Uncertainty or Error matrix from
688 // one detector local coordinate system to another detector local
689 // coordinate system. The specific detector is determined by the
690 // two module index number index1 and index2.
691 void LtoLErrorMatrix(Int_t index1,Int_t index2,
692 const Double_t **l1,Double_t **l2)const{
694 LtoGErrorMatrix(index1,l1,(Double_t **)g);
695 GtoLErrorMatrix(index2,(const Double_t **)g,l2);}
697 // Transforms a matrix, like an Uncertainty or Error matrix from
698 // one detector local coordinate system (used by ITS tracking) to
699 // another detector local coordinate system (used by ITS tracking).
700 // The specific detector is determined by the two module index number
701 // index1 and index2.
702 void LtoLErrorMatrixTraking(Int_t index1,Int_t index2,
703 const Double_t **l1,Double_t **l2)const{
705 LtoGErrorMatrixTracking(index1,l1,(Double_t **)g);
706 GtoLErrorMatrixTracking(index2,(const Double_t **)g,l2);}
707 // Find Specific Modules
708 // Locate the nearest module to the point g, in ALICE global Cartesian
709 // coordinates [cm] in a give layer. If layer = 0 then it search in
711 Int_t GetNearest(const Double_t g[3],Int_t lay=0)const;
712 // Locates the nearest 27 modules, in nearest order, to the point g, in
713 // ALICE global Cartesian coordinates [cm] in a give layer. If layer = 0
714 // then it searches in all layers. (there are 27 elements in a 3x3x3
716 void GetNearest27(const Double_t g[3],Int_t n[27],Int_t lay=0)const;
717 // Returns the distance [cm] between the point g[3] and the center of
718 // the detector/module specified by the the module index number.
719 Double_t Distance(Int_t index,const Double_t g[3])const{
720 return TMath::Sqrt(GetGeomMatrix(index)->Distance2(g));}
721 // loops over modules and computes the average cylindrical
722 // radius to a given layer and the range.
723 Double_t GetAverageRadiusOfLayer(Int_t layer,Double_t &range)const;
724 // Geometry manipulation
725 // This function performs a Cartesian translation and rotation of
726 // the full ITS from its default position by an amount determined by
727 // the three element arrays tran and rot.
728 void GlobalChange(const Float_t *tran,const Float_t *rot);
729 // This function performs a Cylindrical translation and rotation of
730 // the full ITS from its default position by an amount determined by
731 // the three element arrays tran and rot.
732 void GlobalCylindericalChange(const Float_t *tran,const Float_t *rot);
733 // This function performs a Gaussian random displacement and/or
734 // rotation about the present global position of each active
735 // volume/detector of the ITS with variances given by stran and srot.
736 void RandomChange(const Float_t *stran,const Float_t *srot);
737 // This function performs a Gaussian random displacement and/or
738 // rotation about the present global position of each active
739 // volume/detector of the ITS with variances given by stran and srot.
740 // But in Cylindrical coordinates.
741 void RandomCylindericalChange(const Float_t *stran,const Float_t *srot);
742 // This function converts these transformations from Alice global and
743 // local to Tracking global and local.
744 void GeantToTracking(const AliITSgeom &source); // This converts the geometry
746 // This routine prints, to a file, the difference between this class
748 void PrintComparison(FILE *fp,AliITSgeom *other)const;
749 // This routine prints, to a file, the contents of this class.
750 void PrintData(FILE *fp,Int_t lay,Int_t lad,Int_t det)const;
751 // This function prints out this class in a single stream. This steam
752 // can be read by ReadGeom.
753 ofstream &PrintGeom(ofstream &out)const;
754 // This function reads in that single steam printed out by PrintGeom.
755 ifstream &ReadGeom(ifstream &in);
757 //Conversion from det. local coordinates to local ("V2") coordinates
760 void DetLToTrackingV2(Int_t md, Float_t xin, Float_t zin, Float_t &yout, Float_t &zout);
762 void TrackingV2ToDetL(Int_t md,Float_t yin,Float_t zin,Float_t &xout,Float_t &zout);
765 AliITSgeom(const AliITSgeom &source); // Copy constructor
766 AliITSgeom& operator=(const AliITSgeom &source);// = operator
769 TString fVersion; // Transformation version.
770 Int_t fTrans; // Flag to keep track of which transformation
771 Int_t fNmodules;// The total number of modules
772 Int_t fNlayers; // The number of layers.
773 TArrayI fNlad; // Array of the number of ladders/layer(layer)
774 TArrayI fNdet; // Array of the number of detector/ladder(layer)
775 TObjArray fGm; // Structure of translation. and rotation.
776 TObjArray fShape; // Array of shapes and detector information.
778 ClassDef(AliITSgeom,3) // ITS geometry class