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"
31 typedef enum {kND=-1,kSPD=0, kSDD=1, kSSD=2, kSSDp=3,kSDDp=4} AliITSDetector;
33 //_______________________________________________________________________
35 class AliITSgeom : public TObject {
38 AliITSgeom(); // Default constructor
39 AliITSgeom(Int_t itype,Int_t nlayers,const Int_t *nlads,const Int_t *ndets,
40 Int_t nmods); // Constructor
41 AliITSgeom(const AliITSgeom &source); // Copy constructor
42 AliITSgeom& operator=(const AliITSgeom &source);// = operator
43 virtual ~AliITSgeom(); // Default destructor
44 // Zero and reinitilizes this class.
45 void Init(Int_t itype,Int_t nlayers,const Int_t *nlads,
46 const Int_t *ndets,Int_t mods);
47 // this function allocates a AliITSgeomMatrix for a particular module.
48 void CreateMatrix(Int_t mod,Int_t lay,Int_t lad,Int_t det,
49 AliITSDetector idet,const Double_t tran[3],
50 const Double_t rot[10]);
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);}
69 // This function returns a pointer to the particular AliITSgeomMatrix
70 // class for a specific module index.
71 AliITSgeomMatrix *GetGeomMatrix(Int_t index){if(index<fGm.GetSize()&&index>=0)
72 return (AliITSgeomMatrix*)(fGm.At(index));else
73 Error("GetGeomMatrix","index=%d<0||>=GetSize()=%d",index,fGm.GetSize());return 0;}
74 AliITSgeomMatrix *GetGeomMatrix(Int_t index)const{if(index<fGm.GetSize()&&index>=0)
75 return (AliITSgeomMatrix*)(fGm.At(index));else
76 Error("GetGeomMatrix","index=%d<0||>=GetSize()=%d",index,fGm.GetSize());return 0;}
77 // This function find and return the number of detector types only.
78 Int_t GetNDetTypes()const{Int_t max;return GetNDetTypes(max);};
79 // This function find and return the number of detector types and the
80 // maximum det type value.
81 Int_t GetNDetTypes(Int_t &max)const;
82 // This function finds and return the number of detector types and the
83 // and the number of each type in the TArrayI and their types.
84 Int_t GetNDetTypes(TArrayI &maxs,AliITSDetector *types)const;
85 // This function returns the number of detectors/ladder for a give
86 // layer. In particular it returns fNdet[layer-1].
87 Int_t GetNdetectors(Int_t lay) const {return fNdet[lay-1];}
88 // This function returns the number of ladders for a give layer. In
89 // particular it returns fNlad[layer-1].
90 Int_t GetNladders(Int_t lay) const {return fNlad[lay-1];};
91 // This function returns the number of layers defined in the ITS
92 // geometry. In particular it returns fNlayers.
93 Int_t GetNlayers() const {return fNlayers;}
94 Int_t GetModuleIndex(Int_t lay,Int_t lad,Int_t det)const;
95 // This function returns the module index number given the layer,
96 // ladder and detector numbers put into the array id[3].
97 Int_t GetModuleIndex(const Int_t *id)const{
98 return GetModuleIndex(id[0],id[1],id[2]);}
99 void GetModuleId(Int_t index,Int_t &lay,Int_t &lad,Int_t &det)const;
100 // Returns the detector type
101 //Int_t GetModuleType(Int_t index)const{
102 // return GetGeomMatrix(index)->GetDetectorIndex();}
103 AliITSDetector GetModuleType(Int_t index)const{
104 return (AliITSDetector)(GetGeomMatrix(index)->GetDetectorIndex());}
105 // Returns the detector type as a string
106 const char * GetModuleTypeName(Int_t index)const{
107 return GetDetectorTypeName(GetModuleType(index));}
108 // Returns the detector type as a string
109 const char * GetDetectorTypeName(Int_t index)const{switch(index) {
110 case kSPD : return "kSPD" ; case kSDD : return "kSDD" ;
111 case kSSD : return "kSSD" ; case kSSDp: return "kSSDp";
112 case kSDDp: return "kSDDp"; default : return "Undefined";};}
114 Int_t GetStartDet(Int_t dtype )const;
115 Int_t GetLastDet(Int_t dtype)const;
116 // Returns the starting module index number for SPD detector,
117 // assuming the modules are placed in the "standard" cylindrical
119 Int_t GetStartSPD()const{return GetStartDet(kSPD);}
120 // Returns the ending module index number for SPD detector,
121 // assuming the modules are placed in the "standard" cylindrical
123 Int_t GetLastSPD()const{return GetLastDet(kSPD);}
124 // Returns the starting module index number for SDD detector,
125 // assuming the modules are placed in the "standard" cylindrical
127 Int_t GetStartSDD()const{return GetStartDet(kSDD);}
128 // Returns the ending module index number for SDD detector,
129 // assuming the modules are placed in the "standard" cylindrical
131 Int_t GetLastSDD()const{return GetLastDet(kSDD);}
132 // Returns the starting module index number for SSD detector,
133 // assuming the modules are placed in the "standard" cylindrical
135 Int_t GetStartSSD()const{return GetStartDet(kSSD);}
136 // Returns the ending module index number for SSD detector,
137 // assuming the modules are placed in the "standard" cylindrical
139 Int_t GetLastSSD()const{return GetLastDet(kSSD);}
140 // Returns the last module index number.
141 Int_t GetIndexMax() const {return fNmodules;}
143 // This function returns the rotation angles for a give module
144 // in the Double point array ang[3]. The angles are in radians
145 void GetAngles(Int_t index,Double_t *ang)const{
146 GetGeomMatrix(index)->GetAngles(ang);}
147 // This function returns the rotation angles for a give module
148 // in the three floating point variables provided. rx = frx,
149 // fy = fry, rz = frz. The angles are in radians
150 void GetAngles(Int_t index,Float_t &rx,Float_t &ry,Float_t &rz)const{
151 Double_t a[3];GetAngles(index,a);rx = a[0];ry = a[1];rz = a[2];}
152 // This function returns the rotation angles for a give detector on
153 // a give ladder in a give layer in the three floating point variables
154 // provided. rx = frx, fy = fry, rz = frz. The angles are in radians
155 void GetAngles(Int_t lay,Int_t lad,Int_t det,
156 Float_t &rx,Float_t &ry,Float_t &rz)const{
157 GetAngles(GetModuleIndex(lay,lad,det),rx,ry,rz);}
159 // This function returns the 6 GEANT rotation angles for a give
160 // module in the double point array ang[3]. The angles are in degrees
161 void GetGeantAngles(Int_t index,Double_t *ang)const{
162 GetGeomMatrix(index)->SixAnglesFromMatrix(ang);}
164 // This function returns the Cartesian translation for a give
165 // module in the Double array t[3]. The units are
166 // those of the Monte Carlo, generally cm.
167 void GetTrans(Int_t index,Double_t *t)const{
168 GetGeomMatrix(index)->GetTranslation(t);}
169 // This function returns the Cartesian translation for a give
170 // module index in the three floating point variables provided.
171 // x = fx0, y = fy0, z = fz0. The units are those of the Mont
172 // Carlo, generally cm.
173 void GetTrans(Int_t index,Float_t &x,Float_t &y,Float_t &z)const{
174 Double_t t[3];GetTrans(index,t);x = t[0];y = t[1];z = t[2];}
175 // This function returns the Cartesian translation for a give
176 // detector on a give ladder in a give layer in the three floating
177 // point variables provided. x = fx0, y = fy0, z = fz0. The units are
178 // those of the Monte Carlo, generally cm.
179 void GetTrans(Int_t lay,Int_t lad,Int_t det,
180 Float_t &x,Float_t &y,Float_t &z)const{
181 GetTrans(GetModuleIndex(lay,lad,det),x,y,z);}
183 // This function returns the Cartesian translation for a give
184 // module in the Double array t[3]. The units are
185 // those of the Monte Carlo, generally cm.
186 void GetTransCyln(Int_t index,Double_t *t)const{
187 GetGeomMatrix(index)->GetTranslationCylinderical(t);}
188 // This function returns the Cartesian translation for a give
189 // module index in the three floating point variables provided.
190 // x = fx0, y = fy0, z = fz0. The units are those of the Mont
191 // Carlo, generally cm.
192 void GetTransCyln(Int_t index,Float_t &x,Float_t &y,Float_t &z)const{
193 Double_t t[3];GetTransCyln(index,t);x = t[0];y = t[1];z = t[2];}
194 // This function returns the Cartesian translation for a give
195 // detector on a give ladder in a give layer in the three floating
196 // point variables provided. x = fx0, y = fy0, z = fz0. The units are
197 // those of the Monte Carlo, generally cm.
198 void GetTransCyln(Int_t lay,Int_t lad,Int_t det,
199 Float_t &x,Float_t &y,Float_t &z)const{
200 GetTransCyln(GetModuleIndex(lay,lad,det),x,y,z);}
202 // This function returns the Cartesian translation [cm] and the
203 // 6 GEANT rotation angles [degrees]for a given layer ladder and
204 // detector number, in the TVector x (at least 9 elements large).
205 // This function is required to be in-lined for speed.
206 void GetCenterThetaPhi(Int_t lay,Int_t lad,Int_t det,TVector &x)const{
207 Double_t t[3],a[6];Int_t i=GetModuleIndex(lay,lad,det);GetTrans(i,t);
208 GetGeantAngles(i,a);x(0)=t[0];x(1)=t[1];x(2)=t[2];x(3)=a[0];x(4)=a[1];
209 x(5)=a[2];x(6)=a[3];x(7)=a[4];x(8)=a[5];}
211 // This function returns the rotation matrix in Double
212 // precision for a given module.
213 void GetRotMatrix(Int_t index,Double_t mat[3][3])const{
214 GetGeomMatrix(index)->GetMatrix(mat);}
215 // This function returns the rotation matrix in a Double
216 // precision pointer for a given module. mat[i][j] => mat[3*i+j].
217 void GetRotMatrix(Int_t index,Double_t *mat)const{
218 Double_t rot[3][3];GetRotMatrix(index,rot);
219 for(Int_t i=0;i<3;i++)for(Int_t j=0;j<3;j++) mat[3*i+j] = rot[i][j];}
220 // This function returns the rotation matrix in a floating
221 // precision pointer for a given layer ladder and detector module.
222 // mat[i][j] => mat[3*i+j].
223 void GetRotMatrix(Int_t lay,Int_t lad,Int_t det,Float_t *mat)const{
224 GetRotMatrix(GetModuleIndex(lay,lad,det),mat);}
225 // This function returns the rotation matrix in a Double
226 // precision pointer for a given layer ladder and detector module.
227 // mat[i][j] => mat[3*i+j].
228 void GetRotMatrix(Int_t lay,Int_t lad,Int_t det,Double_t *mat)const{
229 GetRotMatrix(GetModuleIndex(lay,lad,det),mat);}
230 // This function returns the rotation matrix in a floating
231 // precision pointer for a given module. mat[i][j] => mat[3*i+j].
232 void GetRotMatrix(Int_t index,Float_t *mat)const{
234 GetGeomMatrix(index)->GetMatrix(rot);
235 for(Int_t i=0;i<3;i++)for(Int_t j=0;j<3;j++) mat[3*i+j] = rot[i][j];}
236 // This function sets the rotation matrix in a Double
237 // precision pointer for a given module. mat[i][j] => mat[3*i+j].
238 void SetRotMatrix(Int_t index,const Double_t *mat){Double_t rot[3][3];
239 for(Int_t i=0;i<3;i++)for(Int_t j=0;j<3;j++) rot[i][j]=mat[3*i+j];
240 GetGeomMatrix(index)->SetMatrix(rot);}
241 // Return the normal for a specific module
242 void GetGlobalNormal(Int_t index,Double_t n[3]){
243 GetGeomMatrix(index)->GetGlobalNormal(n[0],n[1],n[2]);}
247 // Sets the rotation angles and matrix for a give module index
248 // via the double precision array a[3] [radians].
249 void SetByAngles(Int_t index,const Double_t a[]){
250 GetGeomMatrix(index)->SetAngles(a);}
251 // Sets the rotation angles and matrix for a give module index
252 // via the 3 floating precision variables rx, ry, and rz [radians].
253 void SetByAngles(Int_t index,Float_t rx, Float_t ry, Float_t rz) {
254 Double_t a[3];a[0] = rx;a[1] = ry;a[2] = rz;
255 GetGeomMatrix(index)->SetAngles(a);}
256 // Sets the rotation angles and matrix for a give layer, ladder,
257 // and detector numbers via the 3 floating precision variables rx,
258 // ry, and rz [radians].
259 void SetByAngles(Int_t lay,Int_t lad,Int_t det,
260 Float_t rx, Float_t ry, Float_t rz) {
261 SetByAngles(GetModuleIndex(lay,lad,det),rx,ry,rz);}
263 // Sets the rotation angles and matrix for a give module index
264 // via the Double precision array a[6] [degree]. The angles are those
265 // defined by GEANT 3.12.
266 void SetByGeantAngles(Int_t index,const Double_t *ang){
267 GetGeomMatrix(index)->MatrixFromSixAngles(ang);}
268 // Sets the rotation angles and matrix for a give layer, ladder
269 // and detector, in the array id[3] via the Double precision array
270 // a[6] [degree]. The angles are those defined by GEANT 3.12.
271 void SetByGeantAngles(const Int_t *id,const Double_t *ang){
272 SetByGeantAngles(GetModuleIndex(id),ang);}
273 // Sets the rotation angles and matrix for a give layer, ladder
274 // and detector, via the Double precision array a[6] [degree]. The
275 // angles are those defined by GEANT 3.12.
276 void SetByGeantAngles(Int_t lay,Int_t lad,Int_t det,
277 const Double_t *ang){
278 SetByGeantAngles(GetModuleIndex(lay,lad,det),ang);}
280 // This function sets a new translation vector, given by the
281 // array x[3], for the Cartesian coordinate transformation
282 // for a give module index.
283 void SetTrans(Int_t index,Double_t x[]){
284 GetGeomMatrix(index)->SetTranslation(x);}
285 // This function sets a new translation vector, given by the three
286 // variables x, y, and z, for the Cartesian coordinate transformation
287 // for the detector defined by layer, ladder and detector.
288 void SetTrans(Int_t lay,Int_t lad,Int_t det,
289 Float_t x,Float_t y,Float_t z){Double_t t[3];
290 t[0] = x;t[1] = y;t[2] = z;
291 SetTrans(GetModuleIndex(lay,lad,det),t);}
294 // Transforms from the ALICE Global coordinate system
295 // to the detector local coordinate system for the detector
296 // defined by the layer, ladder, and detector numbers. The
297 // global and local coordinate are given in two floating point
298 // arrays g[3], and l[3].
299 void GtoL(Int_t lay,Int_t lad,Int_t det,
300 const Float_t *g,Float_t *l)const{
301 GtoL(GetModuleIndex(lay,lad,det),g,l);}
302 // Transforms from the ALICE Global coordinate system
303 // to the detector local coordinate system for the detector
304 // defined by the id[0], id[1], and id[2] numbers. The
305 // global and local coordinate are given in two floating point
306 // arrays g[3], and l[3].
307 void GtoL(const Int_t *id,const Float_t *g,Float_t *l)const{
308 GtoL(GetModuleIndex(id),g,l);}
309 // Transforms from the ALICE Global coordinate system
310 // to the detector local coordinate system for the detector
311 // module index number. The global and local coordinate are
312 // given in two floating point arrays g[3], and l[3].
313 void GtoL(Int_t index,const Float_t *g,Float_t *l)const{
314 Double_t dg[3],dl[3];Int_t i;for(i=0;i<3;i++) dg[i] = g[i];
315 GetGeomMatrix(index)->GtoLPosition(dg,dl);
316 for(i=0;i<3;i++) l[i] =dl[i];}
317 // Transforms from the ALICE Global coordinate system
318 // to the detector local coordinate system for the detector
319 // defined by the layer, ladder, and detector numbers. The
320 // global and local coordinate are given in two Double point
321 // arrays g[3], and l[3].
322 void GtoL(Int_t lay,Int_t lad,Int_t det,
323 const Double_t *g,Double_t *l)const{
324 GtoL(GetModuleIndex(lay,lad,det),g,l);}
325 // Transforms from the ALICE Global coordinate system
326 // to the detector local coordinate system for the detector
327 // defined by the id[0], id[1], and id[2] numbers. The
328 // global and local coordinate are given in two Double point
329 // arrays g[3], and l[3].
330 void GtoL(const Int_t *id,const Double_t *g,Double_t *l)const{
331 GtoL(GetModuleIndex(id),g,l);}
332 // Transforms from the ALICE Global coordinate system
333 // to the detector local coordinate system for the detector
334 // module index number. The global and local coordinate are
335 // given in two Double point arrays g[3], and l[3].
336 void GtoL(Int_t index,const Double_t g[3],Double_t l[3])const{
337 GetGeomMatrix(index)->GtoLPosition(g,l);}
339 // Transforms from the ALICE Global coordinate system
340 // to the detector local coordinate system (used for ITS tracking)
341 // for the detector module index number. The global and local
342 // coordinate are given in two Double point arrays g[3], and l[3].
343 void GtoLtracking(Int_t index,const Double_t *g,Double_t *l)const{
344 if(IsGeantToTracking()) GtoL(index,g,l);
345 else GetGeomMatrix(index)->GtoLPositionTracking(g,l);}
346 // Transforms from the ALICE Global coordinate system
347 // to the detector local coordinate system (used for ITS tracking)
348 // for the detector id[3]. The global and local
349 // coordinate are given in two Double point arrays g[3], and l[3].
350 void GtoLtracking(const Int_t *id,const Double_t *g,Double_t *l)const{
351 GtoLtracking(GetModuleIndex(id),g,l);}
352 // Transforms from the ALICE Global coordinate system
353 // to the detector local coordinate system (used for ITS tracking)
354 // for the detector layer ladder and detector numbers. The global
355 // and local coordinate are given in two Double point arrays g[3],
357 void GtoLtracking(Int_t lay,Int_t lad,Int_t det,
358 const Double_t *g,Double_t *l)const{
359 GtoLtracking(GetModuleIndex(lay,lad,det),g,l);}
361 // Transforms of momentum types of quantities from the ALICE
362 // Global coordinate system to the detector local coordinate system
363 // for the detector layer ladder and detector numbers. The global
364 // and local coordinate are given in two float point arrays g[3],
366 void GtoLMomentum(Int_t lay,Int_t lad,Int_t det,
367 const Float_t *g,Float_t *l)const{
368 GtoLMomentum(GetModuleIndex(lay,lad,det),g,l);}
369 // Transforms of momentum types of quantities from the ALICE
370 // Global coordinate system to the detector local coordinate system
371 // for the detector module index number. The global and local
372 // coordinate are given in two float point arrays g[3], and l[3].
373 void GtoLMomentum(Int_t index,const Float_t *g,Float_t *l)const{
374 Double_t dg[3],dl[3];Int_t i;for(i=0;i<3;i++) dg[i] = g[i];
375 GetGeomMatrix(index)->GtoLMomentum(dg,dl);
376 for(i=0;i<3;i++) l[i] =dl[i];}
377 // Transforms of momentum types of quantities from the ALICE
378 // Global coordinate system to the detector local coordinate system
379 // for the detector layer ladder and detector numbers. The global
380 // and local coordinate are given in two Double point arrays g[3],
382 void GtoLMomentum(Int_t lay,Int_t lad,Int_t det,
383 const Double_t *g,Double_t *l)const{
384 GtoLMomentum(GetModuleIndex(lay,lad,det),g,l);}
385 // Transforms of momentum types of quantities from the ALICE
386 // Global coordinate system to the detector local coordinate system
387 // for the detector module index number. The global and local
388 // coordinate are given in two Double point arrays g[3], and l[3].
389 void GtoLMomentum(Int_t index,const Double_t *g,Double_t *l)const{
390 Double_t dg[3],dl[3];Int_t i;for(i=0;i<3;i++) dg[i] = g[i];
391 GetGeomMatrix(index)->GtoLMomentum(dg,dl);
392 for(i=0;i<3;i++) l[i] =dl[i];}
394 // Transforms of momentum types of quantities from the ALICE
395 // Global coordinate system to the detector local coordinate system
396 // (used for ITS tracking) for the detector module index number.
397 // The global and local coordinate are given in two Double point
398 // arrays g[3], and l[3].
399 void GtoLMomentumTracking(Int_t index,const Double_t *g,Double_t *l)const{
400 if(IsGeantToTracking()) GtoLMomentum(index,g,l);
401 else GetGeomMatrix(index)->GtoLMomentumTracking(g,l);}
402 // Transforms of momentum types of quantities from the ALICE
403 // Global coordinate system to the detector local coordinate system
404 // (used for ITS tracking) for the detector id[3].
405 // The global and local coordinate are given in two Double point
406 // arrays g[3], and l[3].
407 void GtoLMomentumTracking(const Int_t *id,
408 const Double_t *g,Double_t *l)const{
409 GtoLMomentumTracking(GetModuleIndex(id),g,l);}
410 // Transforms of momentum types of quantities from the ALICE
411 // Global coordinate system to the detector local coordinate system
412 // (used for ITS tracking) for the detector layer ladder and detector
413 // numbers. The global and local coordinate are given in two Double point
414 // arrays g[3], and l[3].
415 void GtoLMomentumTracking(Int_t lay,Int_t lad,Int_t det,
416 const Double_t *g,Double_t *l)const{
417 GtoLMomentumTracking(GetModuleIndex(lay,lad,det),g,l);}
419 // Transforms from the detector local coordinate system
420 // to the ALICE Global coordinate system for the detector
421 // defined by the layer, ladder, and detector numbers. The
422 // global and local coordinate are given in two floating point
423 // arrays g[3], and l[3].
424 void LtoG(Int_t lay,Int_t lad,Int_t det,
425 const Float_t *l,Float_t *g)const{
426 LtoG(GetModuleIndex(lay,lad,det),l,g);}
427 // Transforms from the detector local coordinate system
428 // to the ALICE Global coordinate system for the detector
429 // defined by the id[0], id[1], and id[2] numbers. The
430 // global and local coordinate are given in two floating point
431 // arrays g[3], and l[3].
432 void LtoG(const Int_t *id,const Float_t *l,Float_t *g)const{
433 LtoG(GetModuleIndex(id),l,g);}
434 // Transforms from the detector local coordinate system
435 // to the ALICE Global coordinate system for the detector
436 // module index number. The global and local coordinate are
437 // given in two floating point arrays g[3], and l[3].
438 void LtoG(Int_t index,const Float_t *l,Float_t *g)const{
439 Double_t dg[3],dl[3];Int_t i;for(i=0;i<3;i++) dl[i] = l[i];
440 GetGeomMatrix(index)->LtoGPosition(dl,dg);
441 for(i=0;i<3;i++) g[i] =dg[i];}
442 // Transforms from the detector local coordinate system
443 // to the ALICE Global coordinate system for the detector
444 // defined by the layer, ladder, and detector numbers. The
445 // global and local coordinate are given in two Double point
446 // arrays g[3], and l[3].
447 void LtoG(Int_t lay,Int_t lad,Int_t det,
448 const Double_t *l,Double_t *g)const{
449 LtoG(GetModuleIndex(lay,lad,det),l,g);}
450 // Transforms from the detector local coordinate system
451 // to the ALICE Global coordinate system for the detector
452 // defined by the id[0], id[1], and id[2] numbers. The
453 // global and local coordinate are given in two Double point
454 // arrays g[3], and l[3].
455 void LtoG(const Int_t *id,const Double_t *l,Double_t *g)const{
456 LtoG(GetModuleIndex(id),l,g);}
457 // Transforms from the detector local coordinate system
458 // to the ALICE Global coordinate system for the detector
459 // module index number. The global and local coordinate are
460 // given in two Double point arrays g[3], and l[3].
461 void LtoG(Int_t index,const Double_t *l,Double_t *g)const{
462 GetGeomMatrix(index)->LtoGPosition(l,g);}
464 // Transforms from the detector local coordinate system (used
465 // for ITS tracking) to the ALICE Global coordinate system
466 // for the detector module index number. The global and local
467 // coordinate are given in two Double point arrays g[3], and l[3].
468 void LtoGtracking(Int_t index,const Double_t *l,Double_t *g)const{
469 if(IsGeantToTracking()) LtoG(index,l,g);
470 else GetGeomMatrix(index)->LtoGPositionTracking(l,g);}
471 // Transforms from the detector local coordinate system (used
472 // for ITS tracking) to the ALICE Global coordinate system
473 // for the detector id[3]. The global and local
474 // coordinate are given in two Double point arrays g[3], and l[3].
475 void LtoGtracking(const Int_t *id,const Double_t *l,Double_t *g)const{
476 LtoGtracking(GetModuleIndex(id),l,g);}
477 // Transforms from the detector local coordinate system (used
478 // for ITS tracking) to the detector local coordinate system
479 // for the detector layer ladder and detector numbers. The global
480 // and local coordinate are given in two Double point arrays g[3],
482 void LtoGtracking(Int_t lay,Int_t lad,Int_t det,
483 const Double_t *l,Double_t *g)const{
484 LtoGtracking(GetModuleIndex(lay,lad,det),l,g);}
486 // Transforms of momentum types of quantities from the detector
487 // local coordinate system to the ALICE Global coordinate system
488 // for the detector layer ladder and detector numbers. The global
489 // and local coordinate are given in two float point arrays g[3],
491 void LtoGMomentum(Int_t lay,Int_t lad,Int_t det,
492 const Float_t *l,Float_t *g)const{
493 LtoGMomentum(GetModuleIndex(lay,lad,det),l,g);}
494 // Transforms of momentum types of quantities from the detector
495 // local coordinate system to the ALICE Global coordinate system
496 // for the detector module index number. The global and local
497 // coordinate are given in two float point arrays g[3], and l[3].
498 void LtoGMomentum(Int_t index,const Float_t *l,Float_t *g)const{
499 Double_t dg[3],dl[3];Int_t i;for(i=0;i<3;i++) dl[i] = l[i];
500 GetGeomMatrix(index)->LtoGMomentum(dl,dg);
501 for(i=0;i<3;i++) g[i] =dg[i];}
502 // Transforms of momentum types of quantities from the detector
503 // local coordinate system to the ALICE Global coordinate system
504 // for the detector layer ladder and detector numbers. The global
505 // and local coordinate are given in two Double point arrays g[3],
507 void LtoGMomentum(Int_t lay,Int_t lad,Int_t det,
508 const Double_t *l,Double_t *g)const{
509 LtoGMomentum(GetModuleIndex(lay,lad,det),l,g);}
510 // Transforms of momentum types of quantities from the detector
511 // local coordinate system to the ALICE Global coordinate system
512 // for the detector module index number. The global and local
513 // coordinate are given in two Double point arrays g[3], and l[3].
514 void LtoGMomentum(Int_t index,const Double_t *l,Double_t *g)const{
515 GetGeomMatrix(index)->LtoGMomentum(l,g);}
517 // Transforms of momentum types of quantities from the detector
518 // local coordinate system (used for ITS tracking) to the detector
519 // system ALICE Global for the detector module index number.
520 // The global and local coordinate are given in two Double point
521 // arrays g[3], and l[3].
522 void LtoGMomentumTracking(Int_t index,const Double_t *l,Double_t *g)const{
523 if(IsGeantToTracking()) LtoGMomentum(index,l,g);
524 else GetGeomMatrix(index)->LtoGMomentumTracking(l,g);}
525 // Transforms of momentum types of quantities from the detector
526 // local coordinate system (used for ITS tracking) to the ALICE
527 // Global coordinate system for the detector id[3].
528 // The global and local coordinate are given in two Double point
529 // arrays g[3], and l[3].
530 void LtoGMomentumTracking(const Int_t *id,const Double_t *l,Double_t *g)
531 const{LtoGMomentumTracking(GetModuleIndex(id),l,g);}
532 // Transforms of momentum types of quantities from the detector
533 // local coordinate system (used for ITS tracking) to the ALICE
534 // Global coordinate system for the detector layer ladder and detector
535 // numbers. The global and local coordinate are given in two Double point
536 // arrays g[3], and l[3].
537 void LtoGMomentumTracking(Int_t lay,Int_t lad,Int_t det,
538 const Double_t *l,Double_t *g)const{
539 LtoGMomentumTracking(GetModuleIndex(lay,lad,det),l,g);}
541 // Transforms from one detector local coordinate system
542 // to another detector local coordinate system for the detector
543 // module index1 number to the detector module index2 number. The
544 // local coordinates are given in two Double point arrays l1[3],
546 void LtoL(Int_t index1,Int_t index2,Double_t *l1,Double_t *l2)const{
547 Double_t g[3]; LtoG(index1,l1,g);GtoL(index2,g,l2);}
548 // Transforms from one detector local coordinate system
549 // to another detector local coordinate system for the detector
550 // id1[3] to the detector id2[3]. The local coordinates are given
551 // in two Double point arrays l1[3], and l2[3].
552 void LtoL(const Int_t *id1,const Int_t *id2,Double_t *l1,Double_t *l2)
553 const{LtoL(GetModuleIndex(id1[0],id1[1],id1[2]),
554 GetModuleIndex(id2[0],id2[1],id2[2]),l1,l2);}
556 // Transforms from one detector local coordinate system (used for
557 // ITS tracking) to another detector local coordinate system (used
558 // for ITS tracking) for the detector module index1 number to the
559 // detector module index2 number. The local coordinates are given
560 // in two Double point arrays l1[3], and l2[3].
561 void LtoLtracking(Int_t index1,Int_t index2,
562 Double_t *l1,Double_t *l2)const{
563 Double_t g[3]; LtoGtracking(index1,l1,g);GtoLtracking(index2,g,l2);}
564 // Transforms from one detector local coordinate system (used for
565 // ITS tracking) to another detector local coordinate system (used
566 // for ITS tracking) for the detector id1[3] to the detector id2[3].
567 // The local coordinates are given in two Double point arrays l1[3],
569 void LtoLtracking(const Int_t *id1,const Int_t *id2,
570 Double_t *l1,Double_t *l2)const{
571 LtoLtracking(GetModuleIndex(id1[0],id1[1],id1[2]),
572 GetModuleIndex(id2[0],id2[1],id2[2]),l1,l2);}
574 // Transforms of momentum types of quantities from one detector
575 // local coordinate system to another detector local coordinate
576 // system for the detector module index1 number to the detector
577 // module index2 number. The local coordinates are given in two
578 // Double point arrays l1[3], and l2[3].
579 void LtoLMomentum(Int_t index1,Int_t index2,
580 const Double_t *l1,Double_t *l2)const{
581 Double_t g[3]; LtoGMomentum(index1,l1,g);GtoLMomentum(index2,g,l2);}
582 // Transforms of momentum types of quantities from one detector
583 // local coordinate system to another detector local coordinate
584 // system for the detector id1[3] to the detector id2[3]. The local
585 // coordinates are given in two Double point arrays l1[3], and l2[3].
586 void LtoLMomentum(const Int_t *id1,const Int_t *id2,
587 const Double_t *l1,Double_t *l2)const{
588 LtoLMomentum(GetModuleIndex(id1[0],id1[1],id1[2]),
589 GetModuleIndex(id2[0],id2[1],id2[2]),l1,l2);}
591 // Transforms of momentum types of quantities from one detector
592 // local coordinate system (used by ITS tracking) to another detector
593 // local coordinate system (used by ITS tracking) for the detector
594 // module index1 number to the detector module index2 number. The
595 // local coordinates are given in two Double point arrays l1[3],
597 void LtoLMomentumTracking(Int_t index1,Int_t index2,
598 Double_t *l1,Double_t *l2)const{
599 Double_t g[3]; LtoGMomentumTracking(index1,l1,g);
600 GtoLMomentumTracking(index2,g,l2);}
601 // Transforms of momentum types of quantities from one detector
602 // local coordinate system (used by ITS tracking) to another detector
603 // local coordinate system (used by ITS tracking) for the detector
604 // id1[3] to the detector id2[3]. The local coordinates are given in
605 // two Double point arrays l1[3], and l2[3].
606 void LtoLMomentumTracking(const Int_t *id1,const Int_t *id2,
607 Double_t *l1,Double_t *l2)const{
608 LtoLMomentumTracking(GetModuleIndex(id1[0],id1[1],id1[2]),
609 GetModuleIndex(id2[0],id2[1],id2[2]),l1,l2);}
611 // Transforms a matrix, like an Uncertainty or Error matrix from
612 // the ALICE Global coordinate system to a detector local coordinate
613 // system. The specific detector is determined by the module index
615 void GtoLErrorMatrix(Int_t index,const Double_t **g,Double_t **l)const{
616 GetGeomMatrix(index)->GtoLPositionError(
617 (Double_t (*)[3])g,(Double_t (*)[3])l);}
619 // Transforms a matrix, like an Uncertainty or Error matrix from
620 // the ALICE Global coordinate system to a detector local coordinate
621 // system (used by ITS tracking). The specific detector is determined
622 // by the module index number.
623 void GtoLErrorMatrixTracking(Int_t index,const Double_t **g,
625 if(IsGeantToTracking()) GetGeomMatrix(index)->GtoLPositionError((
626 Double_t (*)[3])g,(Double_t (*)[3])l);
627 else GetGeomMatrix(index)->GtoLPositionErrorTracking(
628 (Double_t (*)[3])g,(Double_t (*)[3])l);}
630 // Transforms a matrix, like an Uncertainty or Error matrix from
631 // the detector local coordinate system to a ALICE Global coordinate
632 // system. The specific detector is determined by the module index
634 void LtoGErrorMatrix(Int_t index,const Double_t **l,Double_t **g)const{
635 GetGeomMatrix(index)->LtoGPositionError(
636 (Double_t (*)[3])l,(Double_t (*)[3])g);}
638 // Transforms a matrix, like an Uncertainty or Error matrix from
639 // the detector local coordinate system to a ALICE Global coordinate
640 // system. The specific detector is determined by the module index
642 void LtoGErrorMatrix(Int_t index,const Double_t l[3][3],Double_t g[3][3])
644 GetGeomMatrix(index)->LtoGPositionError(
645 (Double_t (*)[3])l,(Double_t (*)[3])g);}
648 // Transforms a matrix, like an Uncertainty or Error matrix from
649 // the detector local coordinate system (used by ITS tracking) to a
650 // ALICE Global coordinate system. The specific detector is determined
651 // by the module index number.
652 void LtoGErrorMatrixTracking(Int_t index,const Double_t **l,
654 if(IsGeantToTracking()) GetGeomMatrix(index)->LtoGPositionError(
655 (Double_t (*)[3])g,(Double_t (*)[3])l);
656 else GetGeomMatrix(index)->LtoGPositionErrorTracking(
657 (Double_t (*)[3])l,(Double_t (*)[3])g);}
659 // Transforms a matrix, like an Uncertainty or Error matrix from
660 // the detector local coordinate system (used by ITS tracking) to a
661 // ALICE Global coordinate system. The specific detector is determined
662 // by the module index number.
663 void LtoGErrorMatrixTracking(Int_t index,const Double_t l[3][3],
664 Double_t g[3][3])const{
665 if(IsGeantToTracking()) GetGeomMatrix(index)->LtoGPositionError(
666 (Double_t (*)[3])g,(Double_t (*)[3])l);
667 else GetGeomMatrix(index)->LtoGPositionErrorTracking(
668 (Double_t (*)[3])l,(Double_t (*)[3])g);}
670 // Transforms a matrix, like an Uncertainty or Error matrix from
671 // one detector local coordinate system to another detector local
672 // coordinate system. The specific detector is determined by the
673 // two module index number index1 and index2.
674 void LtoLErrorMatrix(Int_t index1,Int_t index2,
675 const Double_t **l1,Double_t **l2)const{
677 LtoGErrorMatrix(index1,l1,(Double_t **)g);
678 GtoLErrorMatrix(index2,(const Double_t **)g,l2);}
680 // Transforms a matrix, like an Uncertainty or Error matrix from
681 // one detector local coordinate system (used by ITS tracking) to
682 // another detector local coordinate system (used by ITS tracking).
683 // The specific detector is determined by the two module index number
684 // index1 and index2.
685 void LtoLErrorMatrixTraking(Int_t index1,Int_t index2,
686 const Double_t **l1,Double_t **l2)const{
688 LtoGErrorMatrixTracking(index1,l1,(Double_t **)g);
689 GtoLErrorMatrixTracking(index2,(const Double_t **)g,l2);}
690 // Find Specific Modules
691 // Locate the nearest module to the point g, in ALICE global Cartesian
692 // coordinates [cm] in a give layer. If layer = 0 then it search in
694 Int_t GetNearest(const Double_t g[3],Int_t lay=0)const;
695 // Locates the nearest 27 modules, in nearest order, to the point g, in
696 // ALICE global Cartesian coordinates [cm] in a give layer. If layer = 0
697 // then it searches in all layers. (there are 27 elements in a 3x3x3
699 void GetNearest27(const Double_t g[3],Int_t n[27],Int_t lay=0)const;
700 // Returns the distance [cm] between the point g[3] and the center of
701 // the detector/module specified by the the module index number.
702 Double_t Distance(Int_t index,const Double_t g[3])const{
703 return TMath::Sqrt(GetGeomMatrix(index)->Distance2(g));}
704 // Geometry manipulation
705 // This function performs a Cartesian translation and rotation of
706 // the full ITS from its default position by an amount determined by
707 // the three element arrays tran and rot.
708 void GlobalChange(const Float_t *tran,const Float_t *rot);
709 // This function performs a Cylindrical translation and rotation of
710 // the full ITS from its default position by an amount determined by
711 // the three element arrays tran and rot.
712 void GlobalCylindericalChange(const Float_t *tran,const Float_t *rot);
713 // This function performs a Gaussian random displacement and/or
714 // rotation about the present global position of each active
715 // volume/detector of the ITS with variances given by stran and srot.
716 void RandomChange(const Float_t *stran,const Float_t *srot);
717 // This function performs a Gaussian random displacement and/or
718 // rotation about the present global position of each active
719 // volume/detector of the ITS with variances given by stran and srot.
720 // But in Cylindrical coordinates.
721 void RandomCylindericalChange(const Float_t *stran,const Float_t *srot);
722 // This function converts these transformations from Alice global and
723 // local to Tracking global and local.
725 // This converts the geometry
726 void GeantToTracking(const AliITSgeom &source);
728 // This routine prints, to a file, the contents of this class.
729 void PrintData(FILE *fp,Int_t lay,Int_t lad,Int_t det)const;
730 // This function prints out this class in a single stream. This steam
731 // can be read by ReadGeom.
732 // (Coverity warnings) void PrintGeom(ostream *out)const;
734 //Conversion from det. local coordinates to local ("V2") coordinates
737 void DetLToTrackingV2(Int_t md,Float_t xin,Float_t zin,
738 Float_t &yout, Float_t &zout) const ;
740 void TrackingV2ToDetL(Int_t md,Float_t yin,Float_t zin,
741 Float_t &xout,Float_t &zout) const ;
744 TString fVersion; // Transformation version.
745 Int_t fTrans; // Flag to keep track of which transformation
746 Int_t fNmodules;// The total number of modules
747 Int_t fNlayers; // The number of layers.
748 TArrayI fNlad; // Array of the number of ladders/layer(layer)
749 TArrayI fNdet; // Array of the number of detector/ladder(layer)
750 TObjArray fGm; // Structure of translation. and rotation.
752 ClassDef(AliITSgeom,4) // ITS geometry class
754 // Input and output function for standard C++ input/output.