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