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