1 /**************************************************************************
2 * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
4 * Author: The ALICE Off-line Project. *
5 * Contributors are mentioned in the code where appropriate. *
7 * Permission to use, copy, modify and distribute this software and its *
8 * documentation strictly for non-commercial purposes is hereby granted *
9 * without fee, provided that the above copyright notice appears in all *
10 * copies and that both the copyright notice and this permission notice *
11 * appear in the supporting documentation. The authors make no claims *
12 * about the suitability of this software for any purpose. It is *
13 * provided "as is" without express or implied warranty. *
14 **************************************************************************/
19 ////////////////////////////////////////////////////////////////////////
20 // This is the implementation file for AliITSgeomMatrix class. It
21 // contains the routines to manipulate, setup, and queary the geometry
22 // of a given ITS module. An ITS module may be one of at least three
23 // ITS detector technologies, Silicon Pixel, Drift, or Strip Detectors,
24 // and variations of these in size and/or layout. These routines let
25 // one go between ALICE global coordiantes (cm) to a given modules
26 // specific local coordinates (cm).
27 ////////////////////////////////////////////////////////////////////////
29 #include <Riostream.h>
34 #include <TPolyLine3D.h>
40 #include "AliITSgeomMatrix.h"
42 ClassImp(AliITSgeomMatrix)
43 //----------------------------------------------------------------------
44 AliITSgeomMatrix::AliITSgeomMatrix():
46 fDetectorIndex(0), // Detector type index (like fShapeIndex was)
47 fid(), // layer, ladder, detector numbers.
48 frot(), //! vector of rotations about x,y,z [radians].
49 ftran(), // Translation vector of module x,y,z.
50 fCylR(0.0), //! R Translation in Cylinderical coordinates
51 fCylPhi(0.0),//! Phi Translation vector in Cylindrical coord.
52 fm(), // Rotation matrix based on frot.
53 fPath(){ // Path in geometry to this module
54 // The Default constructor for the AliITSgeomMatrix class. By Default
55 // the angles of rotations are set to zero, meaning that the rotation
56 // matrix is the unit matrix. The translation vector is also set to
57 // zero as are the module id number. The detector type is set to -1
58 // (an undefined value). The full rotation matrix is kept so that
59 // the evaluation of a coordinate transformation can be done
60 // quickly and with a minimum of CPU overhead. The basic coordinate
61 // systems are the ALICE global coordinate system and the detector
62 // local coordinate system. In general this structure is not limited
63 // to just those two coordinate systems.
66 <img src="picts/ITS/AliITSgeomMatrix_L1.gif">
74 // A default constructes AliITSgeomMatrix class.
77 fDetectorIndex = -1; // a value never defined.
80 frot[i] = ftran[i] = 0.0;
81 for(j=0;j<3;j++) fm[i][j] = 0.0;
82 fCylR = fCylPhi = 0.0;
84 fm[0][0] = fm[1][1] = fm[2][2] = 1.0;
87 //----------------------------------------------------------------------
88 AliITSgeomMatrix::AliITSgeomMatrix(const AliITSgeomMatrix &sourse) :
90 // The standard Copy constructor. This make a full / proper copy of
93 // AliITSgeomMatrix &source The source of this copy
97 // A copy constructes AliITSgeomMatrix class.
100 this->fDetectorIndex = sourse.fDetectorIndex;
102 this->fid[i] = sourse.fid[i];
103 this->frot[i] = sourse.frot[i];
104 this->ftran[i] = sourse.ftran[i];
105 this->fCylR = sourse.fCylR;
106 this->fCylPhi = sourse.fCylPhi;
107 for(j=0;j<3;j++) this->fm[i][j] = sourse.fm[i][j];
109 this->fPath = sourse.fPath;
111 //----------------------------------------------------------------------
112 void AliITSgeomMatrix::operator=(const AliITSgeomMatrix &sourse){
113 // The standard = operator. This make a full / proper copy of
115 // The standard Copy constructor. This make a full / proper copy of
118 // AliITSgeomMatrix &source The source of this copy
122 // A copy of the source AliITSgeomMatrix class.
125 this->fDetectorIndex = sourse.fDetectorIndex;
127 this->fid[i] = sourse.fid[i];
128 this->frot[i] = sourse.frot[i];
129 this->ftran[i] = sourse.ftran[i];
130 this->fCylR = sourse.fCylR;
131 this->fCylPhi = sourse.fCylPhi;
132 for(j=0;j<3;j++) this->fm[i][j] = sourse.fm[i][j];
134 this->fPath = sourse.fPath;
137 //----------------------------------------------------------------------
138 AliITSgeomMatrix::AliITSgeomMatrix(Int_t idt,const Int_t id[3],
139 const Double_t rot[3],const Double_t tran[3]):
141 fDetectorIndex(idt), // Detector type index (like fShapeIndex was)
142 fid(), // layer, ladder, detector numbers.
143 frot(), //! vector of rotations about x,y,z [radians].
144 ftran(), // Translation vector of module x,y,z.
145 fCylR(0.0), //! R Translation in Cylinderical coordinates
146 fCylPhi(0.0),//! Phi Translation vector in Cylindrical coord.
147 fm(), // Rotation matrix based on frot.
148 fPath(){ // Path in geometry to this moduel
149 // This is a constructor for the AliITSgeomMatrix class. The matrix is
150 // defined by 3 standard rotation angles [radians], and the translation
151 // vector tran [cm]. In addition the layer, ladder, and detector number
152 // for this particular module and the type of module must be given.
153 // The full rotation matrix is kept so that the evaluation
154 // of a coordinate transformation can be done quickly and with a minimum
155 // of CPU overhead. The basic coordinate systems are the ALICE global
156 // coordinate system and the detector local coordinate system. In general
157 // this structure is not limited to just those two coordinate systems.
160 <img src="picts/ITS/AliITSgeomMatrix_L1.gif">
164 // Int_t idt The detector index value
165 // Int_t id[3] The layer, ladder, and detector numbers
166 // Double_t rot[3] The 3 Cartician rotaion angles [radians]
167 // Double_t tran[3] The 3 Cartician translation distnaces
171 // A properly inilized AliITSgeomMatrix class.
179 fCylR = TMath::Sqrt(ftran[0]*ftran[0]+ftran[1]*ftran[1]);
180 fCylPhi = TMath::ATan2(ftran[1],ftran[0]);
181 if(fCylPhi<0.0) fCylPhi += TMath::Pi();
182 this->MatrixFromAngle();
184 //----------------------------------------------------------------------
185 AliITSgeomMatrix::AliITSgeomMatrix(Int_t idt, const Int_t id[3],
186 Double_t matrix[3][3],
187 const Double_t tran[3]):
189 fDetectorIndex(idt), // Detector type index (like fShapeIndex was)
190 fid(), // layer, ladder, detector numbers.
191 frot(), //! vector of rotations about x,y,z [radians].
192 ftran(), // Translation vector of module x,y,z.
193 fCylR(0.0), //! R Translation in Cylinderical coordinates
194 fCylPhi(0.0),//! Phi Translation vector in Cylindrical coord.
195 fm(), // Rotation matrix based on frot.
196 fPath(){ // Path in geometry to this module
197 // This is a constructor for the AliITSgeomMatrix class. The
198 // rotation matrix is given as one of the inputs, and the
199 // translation vector tran [cm]. In addition the layer, ladder,
200 // and detector number for this particular module and the type of
201 // module must be given. The full rotation matrix is kept so that
202 // the evaluation of a coordinate transformation can be done quickly
203 // and with a minimum of CPU overhead. The basic coordinate systems
204 // are the ALICE global coordinate system and the detector local
205 // coordinate system. In general this structure is not limited to just
206 // those two coordinate systems.
209 <img src="picts/ITS/AliITSgeomMatrix_L1.gif">
213 // Int_t idt The detector index value
214 // Int_t id[3] The layer, ladder, and detector numbers
215 // Double_t rot[3][3] The 3x3 Cartician rotaion matrix
216 // Double_t tran[3] The 3 Cartician translation distnaces
220 // A properly inilized AliITSgeomMatrix class.
226 for(j=0;j<3;j++) fm[i][j] = matrix[i][j];
228 fCylR = TMath::Sqrt(ftran[0]*ftran[0]+ftran[1]*ftran[1]);
229 fCylPhi = TMath::ATan2(ftran[1],ftran[0]);
230 if(fCylPhi<0.0) fCylPhi += TMath::Pi();
231 this->AngleFromMatrix();
233 //----------------------------------------------------------------------
234 void AliITSgeomMatrix::SixAnglesFromMatrix(Double_t *ang)const{
235 // This function returns the 6 GEANT 3.21 rotation angles [degrees] in
236 // the array ang which must be at least [6] long.
240 // Double_t ang[6] The 6 Geant3.21 rotation angles. [degrees]
243 Double_t si,c=180./TMath::Pi();
245 ang[1] = TMath::ATan2(fm[0][1],fm[0][0]);
246 if(TMath::Cos(ang[1])!=0.0) si = fm[0][0]/TMath::Cos(ang[1]);
247 else si = fm[0][1]/TMath::Sin(ang[1]);
248 ang[0] = TMath::ATan2(si,fm[0][2]);
250 ang[3] = TMath::ATan2(fm[1][1],fm[1][0]);
251 if(TMath::Cos(ang[3])!=0.0) si = fm[1][0]/TMath::Cos(ang[3]);
252 else si = fm[1][1]/TMath::Sin(ang[3]);
253 ang[2] = TMath::ATan2(si,fm[1][2]);
255 ang[5] = TMath::ATan2(fm[2][1],fm[2][0]);
256 if(TMath::Cos(ang[5])!=0.0) si = fm[2][0]/TMath::Cos(ang[5]);
257 else si = fm[2][1]/TMath::Sin(ang[5]);
258 ang[4] = TMath::ATan2(si,fm[2][2]);
260 for(Int_t i=0;i<6;i++) {ang[i] *= c; if(ang[i]<0.0) ang[i] += 360.;}
262 //----------------------------------------------------------------------
263 void AliITSgeomMatrix::MatrixFromSixAngles(const Double_t *ang){
264 // Given the 6 GEANT 3.21 rotation angles [degree], this will compute and
265 // set the rotations matrix and 3 standard rotation angles [radians].
266 // These angles and rotation matrix are overwrite the existing values in
269 // Double_t ang[6] The 6 Geant3.21 rotation angles. [degrees]
275 Double_t si,lr[9],c=TMath::Pi()/180.;
277 si = TMath::Sin(c*ang[0]);
278 if(ang[0]== 90.0) si = +1.0;
279 if(ang[0]==270.0) si = -1.0;
280 if(ang[0]== 0.0||ang[0]==180.) si = 0.0;
281 lr[0] = si * TMath::Cos(c*ang[1]);
282 lr[1] = si * TMath::Sin(c*ang[1]);
283 lr[2] = TMath::Cos(c*ang[0]);
284 if(ang[0]== 90.0||ang[0]==270.) lr[2] = 0.0;
285 if(ang[0]== 0.0) lr[2] = +1.0;
286 if(ang[0]==180.0) lr[2] = -1.0;
288 si = TMath::Sin(c*ang[2]);
289 if(ang[2]== 90.0) si = +1.0;
290 if(ang[2]==270.0) si = -1.0;
291 if(ang[2]== 0.0||ang[2]==180.) si = 0.0;
292 lr[3] = si * TMath::Cos(c*ang[3]);
293 lr[4] = si * TMath::Sin(c*ang[3]);
294 lr[5] = TMath::Cos(c*ang[2]);
295 if(ang[2]== 90.0||ang[2]==270.) lr[5] = 0.0;
296 if(ang[2]== 0.0) lr[5] = +1.0;
297 if(ang[2]==180.0) lr[5] = -1.0;
299 si = TMath::Sin(c*ang[4]);
300 if(ang[4]== 90.0) si = +1.0;
301 if(ang[4]==270.0) si = -1.0;
302 if(ang[4]== 0.0||ang[4]==180.) si = 0.0;
303 lr[6] = si * TMath::Cos(c*ang[5]);
304 lr[7] = si * TMath::Sin(c*ang[5]);
305 lr[8] = TMath::Cos(c*ang[4]);
306 if(ang[4]== 90.0||ang[4]==270.0) lr[8] = 0.0;
307 if(ang[4]== 0.0) lr[8] = +1.0;
308 if(ang[4]==180.0) lr[8] = -1.0;
309 // Normalize these elements and fill matrix fm.
310 for(i=0;i<3;i++){// reuse si.
312 for(j=0;j<3;j++) si += lr[3*i+j]*lr[3*i+j];
313 si = TMath::Sqrt(1./si);
314 for(j=0;j<3;j++) fm[i][j] = si*lr[3*i+j];
316 this->AngleFromMatrix();
318 //----------------------------------------------------------------------
319 AliITSgeomMatrix::AliITSgeomMatrix(const Double_t rotd[6]/*degrees*/,
320 Int_t idt,const Int_t id[3],
321 const Double_t tran[3]):
327 // This is a constructor for the AliITSgeomMatrix class. The matrix
328 // is defined by the 6 GEANT 3.21 rotation angles [degrees], and
329 // the translation vector tran [cm]. In addition the layer, ladder,
330 // and detector number for this particular module and the type of
331 // module must be given. The full rotation matrix is kept so that
332 // the evaluation of a coordinate transformation can be done
333 // quickly and with a minimum of CPU overhead. The basic coordinate
334 // systems are the ALICE global coordinate system and the detector
335 // local coordinate system. In general this structure is not limited
336 // to just those two coordinate systems.
339 <img src="picts/ITS/AliITSgeomMatrix_L1.gif">
343 // Double_t rotd[6] The 6 Geant 3.21 rotation angles [degrees]
344 // Int_t idt The module Id number
345 // Int_t id[3] The layer, ladder and detector number
346 // Double_t tran[3] The translation vector
353 fCylR = TMath::Sqrt(ftran[0]*ftran[0]+ftran[1]*ftran[1]);
354 fCylPhi = TMath::ATan2(ftran[1],ftran[0]);
355 if(fCylPhi<0.0) fCylPhi += TMath::Pi();
356 this->MatrixFromSixAngles(rotd);
358 //----------------------------------------------------------------------
359 void AliITSgeomMatrix::AngleFromMatrix(){
360 // Computes the angles from the rotation matrix up to a phase of
369 // get angles from matrix up to a phase of 180 degrees.
371 rx = TMath::ATan2(fm[2][1],fm[2][2]);if(rx<0.0) rx += 2.0*TMath::Pi();
372 ry = TMath::ASin(fm[0][2]); if(ry<0.0) ry += 2.0*TMath::Pi();
373 rz = TMath::ATan2(fm[1][1],fm[0][0]);if(rz<0.0) rz += 2.0*TMath::Pi();
379 //----------------------------------------------------------------------
380 void AliITSgeomMatrix::MatrixFromAngle(){
381 // Computes the Rotation matrix from the angles [radians] kept in this
389 Double_t sx,sy,sz,cx,cy,cz;
391 sx = TMath::Sin(frot[0]); cx = TMath::Cos(frot[0]);
392 sy = TMath::Sin(frot[1]); cy = TMath::Cos(frot[1]);
393 sz = TMath::Sin(frot[2]); cz = TMath::Cos(frot[2]);
394 fm[0][0] = cz*cy; // fr[0]
395 fm[0][1] = -cz*sy*sx - sz*cx; // fr[1]
396 fm[0][2] = -cz*sy*cx + sz*sx; // fr[2]
397 fm[1][0] = sz*cy; // fr[3]
398 fm[1][1] = -sz*sy*sx + cz*cx; // fr[4]
399 fm[1][2] = -sz*sy*cx - cz*sx; // fr[5]
400 fm[2][0] = sy; // fr[6]
401 fm[2][1] = cy*sx; // fr[7]
402 fm[2][2] = cy*cx; // fr[8]
405 //----------------------------------------------------------------------
406 void AliITSgeomMatrix::GtoLPosition(const Double_t g0[3],Double_t l[3]) const {
407 // Returns the local coordinates given the global coordinates [cm].
409 // Double_t g[3] The position represented in the ALICE
410 // global coordinate system
412 // Double_t l[3] The poistion represented in the local
413 // detector coordiante system
419 for(i=0;i<3;i++) g[i] = g0[i] - ftran[i];
422 for(j=0;j<3;j++) l[i] += fm[i][j]*g[j];
423 // g = R l + translation
427 //----------------------------------------------------------------------
428 void AliITSgeomMatrix::LtoGPosition(const Double_t l[3],Double_t g[3]) const {
429 // Returns the global coordinates given the local coordinates [cm].
431 // Double_t l[3] The poistion represented in the detector
432 // local coordinate system
434 // Double_t g[3] The poistion represented in the ALICE
435 // Global coordinate system
442 for(j=0;j<3;j++) g[i] += fm[j][i]*l[j];
444 // g = R^t l + translation
448 //----------------------------------------------------------------------
449 void AliITSgeomMatrix::GtoLMomentum(const Double_t g[3],Double_t l[3]) const{
450 // Returns the local coordinates of the momentum given the global
451 // coordinates of the momentum. It transforms just like GtoLPosition
452 // except that the translation vector is zero.
454 // Double_t g[3] The momentum represented in the ALICE global
457 // Double_t l[3] the momentum represented in the detector
458 // local coordinate system
465 for(j=0;j<3;j++) l[i] += fm[i][j]*g[j];
470 //----------------------------------------------------------------------
471 void AliITSgeomMatrix::LtoGMomentum(const Double_t l[3],Double_t g[3]) const {
472 // Returns the Global coordinates of the momentum given the local
473 // coordinates of the momentum. It transforms just like LtoGPosition
474 // except that the translation vector is zero.
476 // Double_t l[3] the momentum represented in the detector
477 // local coordinate system
479 // Double_t g[3] The momentum represented in the ALICE global
487 for(j=0;j<3;j++) g[i] += fm[j][i]*l[j];
492 //----------------------------------------------------------------------
493 void AliITSgeomMatrix::GtoLPositionError(const Double_t g[3][3],
494 Double_t l[3][3]) const {
495 // Given an Uncertainty matrix in Global coordinates it is
496 // rotated so that its representation in local coordinates can
497 // be returned. There is no effect due to the translation vector
498 // or its uncertainty.
500 // Double_t g[3][3] The error matrix represented in the ALICE global
503 // Double_t l[3][3] the error matrix represented in the detector
504 // local coordinate system
509 for(i=0;i<3;i++)for(m=0;m<3;m++){
511 for(j=0;j<3;j++)for(k=0;k<3;k++)
512 l[i][m] += fm[j][i]*g[j][k]*fm[k][m];
517 //----------------------------------------------------------------------
518 void AliITSgeomMatrix::LtoGPositionError(const Double_t l[3][3],
519 Double_t g[3][3]) const {
520 // Given an Uncertainty matrix in Local coordinates it is rotated so that
521 // its representation in global coordinates can be returned. There is no
522 // effect due to the translation vector or its uncertainty.
524 // Double_t l[3][3] the error matrix represented in the detector
525 // local coordinate system
527 // Double_t g[3][3] The error matrix represented in the ALICE global
533 for(i=0;i<3;i++)for(m=0;m<3;m++){
535 for(j=0;j<3;j++)for(k=0;k<3;k++)
536 g[i][m] += fm[i][j]*l[j][k]*fm[m][k];
541 //----------------------------------------------------------------------
542 void AliITSgeomMatrix::GtoLPositionTracking(const Double_t g[3],
543 Double_t l[3]) const {
544 // A slightly different coordinate system is used when tracking.
545 // This coordinate system is only relevant when the geometry represents
546 // the cylindrical ALICE ITS geometry. For tracking the Z axis is left
547 // alone but X -> -Y and Y -> X such that X always points out of the
548 // ITS Cylinder for every layer including layer 1 (where the detector
549 // are mounted upside down).
552 <img src="picts/ITS/AliITSgeomMatrix_T1.gif">
556 // Double_t g[3] The position represented in the ALICE
557 // global coordinate system
559 // Double_t l[3] The poistion represented in the local
560 // detector coordiante system
565 this->GtoLPosition(g,l0);
566 if(fid[0]==1){ // for layer 1 the detector are flipped upside down
567 // with respect to the others.
578 //----------------------------------------------------------------------
579 void AliITSgeomMatrix::LtoGPositionTracking(const Double_t l[3],
580 Double_t g[3]) const {
581 // A slightly different coordinate system is used when tracking.
582 // This coordinate system is only relevant when the geometry represents
583 // the cylindrical ALICE ITS geometry. For tracking the Z axis is left
584 // alone but X -> -Y and Y -> X such that X always points out of the
585 // ITS Cylinder for every layer including layer 1 (where the detector
586 // are mounted upside down).
589 <img src="picts/ITS/AliITSgeomMatrix_T1.gif">
593 // Double_t l[3] The poistion represented in the detector
594 // local coordinate system
596 // Double_t g[3] The poistion represented in the ALICE
597 // Global coordinate system
602 if(fid[0]==1){ // for layer 1 the detector are flipped upside down
603 // with respect to the others.
612 this->LtoGPosition(l0,g);
615 //----------------------------------------------------------------------
616 void AliITSgeomMatrix::GtoLMomentumTracking(const Double_t g[3],
617 Double_t l[3]) const {
618 // A slightly different coordinate system is used when tracking.
619 // This coordinate system is only relevant when the geometry represents
620 // the cylindrical ALICE ITS geometry. For tracking the Z axis is left
621 // alone but X -> -Y and Y -> X such that X always points out of the
622 // ITS Cylinder for every layer including layer 1 (where the detector
623 // are mounted upside down).
626 <img src="picts/ITS/AliITSgeomMatrix_T1.gif">
630 // Double_t g[3] The momentum represented in the ALICE global
633 // Double_t l[3] the momentum represented in the detector
634 // local coordinate system
639 this->GtoLMomentum(g,l0);
640 if(fid[0]==1){ // for layer 1 the detector are flipped upside down
641 // with respect to the others.
652 //----------------------------------------------------------------------
653 void AliITSgeomMatrix::LtoGMomentumTracking(const Double_t l[3],
654 Double_t g[3]) const {
655 // A slightly different coordinate system is used when tracking.
656 // This coordinate system is only relevant when the geometry represents
657 // the cylindrical ALICE ITS geometry. For tracking the Z axis is left
658 // alone but X -> -Y and Y -> X such that X always points out of the
659 // ITS Cylinder for every layer including layer 1 (where the detector
660 // are mounted upside down).
663 <img src="picts/ITS/AliITSgeomMatrix_T1.gif">
667 // Double_t l[3] the momentum represented in the detector
668 // local coordinate system
670 // Double_t g[3] The momentum represented in the ALICE global
676 if(fid[0]==1){ // for layer 1 the detector are flipped upside down
677 // with respect to the others.
686 this->LtoGMomentum(l0,g);
689 //----------------------------------------------------------------------
690 void AliITSgeomMatrix::GtoLPositionErrorTracking(const Double_t g[3][3],
691 Double_t l[3][3]) const {
692 // A slightly different coordinate system is used when tracking.
693 // This coordinate system is only relevant when the geometry represents
694 // the cylindrical ALICE ITS geometry. For tracking the Z axis is left
695 // alone but X -> -Y and Y -> X such that X always points out of the
696 // ITS Cylinder for every layer including layer 1 (where the detector
697 // are mounted upside down).
700 <img src="picts/ITS/AliITSgeomMatrix_TE1.gif">
704 // Double_t g[3][3] The error matrix represented in the ALICE global
707 // Double_t l[3][3] the error matrix represented in the detector
708 // local coordinate system
712 Double_t a0[3][3] = {{0.,+1.,0.},{-1.,0.,0.},{0.,0.,+1.}};
713 Double_t a1[3][3] = {{0.,-1.,0.},{+1.,0.,0.},{0.,0.,+1.}};
715 if(fid[0]==1) for(i=0;i<3;i++)for(j=0;j<3;j++)for(k=0;k<3;k++)
716 rt[i][k] = a0[i][j]*fm[j][k];
717 else for(i=0;i<3;i++)for(j=0;j<3;j++)for(k=0;k<3;k++)
718 rt[i][k] = a1[i][j]*fm[j][k];
719 for(i=0;i<3;i++)for(m=0;m<3;m++){
721 for(j=0;j<3;j++)for(k=0;k<3;k++)
722 l[i][m] += rt[j][i]*g[j][k]*rt[k][m];
727 //----------------------------------------------------------------------
728 void AliITSgeomMatrix::LtoGPositionErrorTracking(const Double_t l[3][3],
729 Double_t g[3][3]) const {
730 // A slightly different coordinate system is used when tracking.
731 // This coordinate system is only relevant when the geometry represents
732 // the cylindrical ALICE ITS geometry. For tracking the Z axis is left
733 // alone but X -> -Y and Y -> X such that X always points out of the
734 // ITS Cylinder for every layer including layer 1 (where the detector
735 // are mounted upside down).
738 <img src="picts/ITS/AliITSgeomMatrix_TE1.gif">
742 // Double_t l[3][3] the error matrix represented in the detector
743 // local coordinate system
745 // Double_t g[3][3] The error matrix represented in the ALICE global
751 Double_t a0[3][3] = {{0.,+1.,0.},{-1.,0.,0.},{0.,0.,+1.}};
752 Double_t a1[3][3] = {{0.,-1.,0.},{+1.,0.,0.},{0.,0.,+1.}};
754 if(fid[0]==1) for(i=0;i<3;i++)for(j=0;j<3;j++)for(k=0;k<3;k++)
755 rt[i][k] = a0[i][j]*fm[j][k];
756 else for(i=0;i<3;i++)for(j=0;j<3;j++)for(k=0;k<3;k++)
757 rt[i][k] = a1[i][j]*fm[j][k];
758 for(i=0;i<3;i++)for(m=0;m<3;m++){
760 for(j=0;j<3;j++)for(k=0;k<3;k++)
761 g[i][m] += rt[i][j]*l[j][k]*rt[m][k];
766 //----------------------------------------------------------------------
767 void AliITSgeomMatrix::PrintTitles(ostream *os) const {
768 // Standard output format for this class but it includes variable
769 // names and formatting that makes it easer to read.
771 // ostream *os The output stream to print the title on
778 *os << "fDetectorIndex=" << fDetectorIndex << " fid[3]={";
779 for(i=0;i<3;i++) *os << fid[i] << " ";
780 *os << "} frot[3]={";
781 for(i=0;i<3;i++) *os << frot[i] << " ";
782 *os << "} ftran[3]={";
783 for(i=0;i<3;i++) *os << ftran[i] << " ";
784 *os << "} fm[3][3]={";
785 for(i=0;i<3;i++){for(j=0;j<3;j++){ *os << fm[i][j] << " ";} *os <<"}{";}
789 //----------------------------------------------------------------------
790 void AliITSgeomMatrix::PrintComment(ostream *os) const {
791 // output format used by Print.
793 // ostream *os The output stream to print the comments on
798 *os << "fDetectorIndex fid[0] fid[1] fid[2] ftran[0] ftran[1] ftran[2] ";
799 *os << "fm[0][0] fm[0][1] fm[0][2] fm[1][0] fm[1][1] fm[1][2] ";
800 *os << "fm[2][0] fm[2][1] fm[2][2] ";
803 //----------------------------------------------------------------------
804 void AliITSgeomMatrix::Print(ostream *os)const{
805 // Standard output format for this class.
807 // ostream *os The output stream to print the class data on
820 #if defined __ICC || defined __ECC || defined __xlC__
827 fmt = os->setf(ios::scientific); // set scientific floating point output
828 *os << fDetectorIndex << " ";
829 for(i=0;i<3;i++) *os << fid[i] << " ";
830 // for(i=0;i<3;i++) *os << frot[i] << " "; // Redundant with fm[][].
831 for(i=0;i<3;i++) *os << setprecision(16) << ftran[i] << " ";
832 for(i=0;i<3;i++)for(j=0;j<3;j++) *os << setprecision(16) <<
834 *os << fPath.Length()<< " ";
835 for(i=0;i<fPath.Length();i++) *os << fPath[i];
837 os->flags(fmt); // reset back to old formating.
840 //----------------------------------------------------------------------
841 void AliITSgeomMatrix::Read(istream *is){
842 // Standard input format for this class.
844 // istream *is The input stream to read on
851 *is >> fDetectorIndex;
852 for(i=0;i<3;i++) *is >> fid[i];
853 // for(i=0;i<3;i++) *is >> frot[i]; // Redundant with fm[][].
854 for(i=0;i<3;i++) *is >> ftran[i];
855 for(i=0;i<3;i++)for(j=0;j<3;j++) *is >> fm[i][j];
856 while(is->peek()==' ')is->get(); // skip white spaces
857 if(isprint(is->peek())){ // old format did not have path.
858 *is >> j; // string length
860 for(i=0;i<j;i++) {*is >> fPath[i];}
862 AngleFromMatrix(); // compute angles frot[].
863 fCylR = TMath::Sqrt(ftran[0]*ftran[0]+ftran[1]*ftran[1]);
864 fCylPhi = TMath::ATan2(ftran[1],ftran[0]);
865 if(fCylPhi<0.0) fCylPhi += TMath::Pi();
868 //______________________________________________________________________
869 void AliITSgeomMatrix::Streamer(TBuffer &R__b){
870 // Stream an object of class AliITSgeomMatrix.
872 // TBuffer &R__b The output buffer to stream data on.
878 if (R__b.IsReading()) {
879 AliITSgeomMatrix::Class()->ReadBuffer(R__b, this);
880 fCylR = TMath::Sqrt(ftran[0]*ftran[0]+ftran[1]*ftran[1]);
881 fCylPhi = TMath::ATan2(ftran[1],ftran[0]);
882 this->AngleFromMatrix();
883 if(fCylPhi<0.0) fCylPhi += TMath::Pi();
885 AliITSgeomMatrix::Class()->WriteBuffer(R__b, this);
888 //______________________________________________________________________
889 void AliITSgeomMatrix::SetTranslation(const Double_t tran[3]){
890 // Sets the translation vector and computes fCylR and fCylPhi.
892 // Double_t trans[3] The translation vector to be used
897 for(Int_t i=0;i<3;i++) ftran[i] = tran[i];
898 fCylR = TMath::Sqrt(ftran[0]*ftran[0]+ftran[1]*ftran[1]);
899 fCylPhi = TMath::ATan2(ftran[1],ftran[0]);
900 if(fCylPhi<0.0) fCylPhi += TMath::Pi();
902 //----------------------------------------------------------------------
903 TPolyLine3D* AliITSgeomMatrix::CreateLocalAxis() const {
904 // This class is used as part of the documentation of this class
910 // A pointer to a new TPolyLine3D object showing the 3 line
911 // segments that make up the this local axis in the global
915 Double_t l[5][3]={{1.0,0.0,0.0},{0.0,0.0,0.0},{0.0,1.0,0.0},{0.0,0.0,0.0},
920 LtoGPosition(l[i],g[i]);
921 gf[3*i]=(Float_t)g[i][0];
922 gf[3*i+1]=(Float_t)g[i][1];
923 gf[3*i+2]=(Float_t)g[i][2];
925 return new TPolyLine3D(5,gf);
927 //----------------------------------------------------------------------
928 TPolyLine3D* AliITSgeomMatrix::CreateLocalAxisTracking() const {
929 // This class is used as part of the documentation of this class
935 // A pointer to a new TPolyLine3D object showing the 3 line
936 // segments that make up the this local axis in the global
940 Double_t l[5][3]={{1.0,0.0,0.0},{0.0,0.0,0.0},{0.0,1.0,0.0},{0.0,0.0,0.0},
945 LtoGPositionTracking(l[i],g[i]);
946 gf[3*i]=(Float_t)g[i][0];
947 gf[3*i+1]=(Float_t)g[i][1];
948 gf[3*i+2]=(Float_t)g[i][2];
950 return new TPolyLine3D(5,gf);
952 //----------------------------------------------------------------------
953 TNode* AliITSgeomMatrix::CreateNode(const Char_t *nodeName,
954 const Char_t *nodeTitle,TNode *mother,
955 TShape *shape,Bool_t axis) const {
956 // Creates a node inside of the node mother out of the shape shape
957 // in the position, with respect to mother, indecated by "this". If axis
958 // is ture, it will insert an axis within this node/shape.
960 // Char_t *nodeName This name of this node
961 // Char_t *nodeTitle This node title
962 // TNode *mother The node this node will be inside of/with respect to
963 // TShape *shape The shape of this node
964 // Bool_t axis If ture, a set of x,y,z axis will be included
968 // A pointer to "this" node.
969 Double_t trans[3],matrix[3][3],*matr;
970 TRotMatrix *rot = new TRotMatrix();
973 matr = &(matrix[0][0]);
974 this->GetTranslation(trans);
975 this->GetMatrix(matrix);
976 rot->SetMatrix(matr);
982 TNode *node1 = new TNode(name.Data(),title.Data(),shape,trans[0],trans[1],trans[2],rot);
985 const Float_t kScale=0.5,kLw=0.2;
986 Float_t xchar[13][2]={{0.5*kLw,1.},{0.,0.5*kLw},{0.5-0.5*kLw,0.5},
987 {0.,0.5*kLw},{0.5*kLw,0.},{0.5,0.5-0.5*kLw},
988 {1-0.5*kLw,0.},{1.,0.5*kLw},{0.5+0.5*kLw,0.5},
989 {1.,1.-0.5*kLw},{1.-0.5*kLw,1.},{0.5,0.5+0.5*kLw},
991 Float_t ychar[10][2]={{.5-0.5*kLw,0.},{.5+0.5*kLw,0.},{.5+0.5*kLw,0.5-0.5*kLw},
992 {1.,1.-0.5*kLw},{1.-0.5*kLw,1.},{0.5+0.5*kLw,0.5},
993 {0.5*kLw,1.} ,{0.,1-0.5*kLw} ,{0.5-0.5*kLw,0.5},
995 Float_t zchar[11][2]={{0.,1.},{0,1.-kLw},{1.-kLw,1.-kLw},{0.,kLw} ,{0.,0.},
996 {1.,0.},{1.,kLw} ,{kLw,kLw} ,{1.,1.-kLw},{1.,1.},
998 for(i=0;i<13;i++)for(j=0;j<2;j++){
999 if(i<13) xchar[i][j] = kScale*xchar[i][j];
1000 if(i<10) ychar[i][j] = kScale*ychar[i][j];
1001 if(i<11) zchar[i][j] = kScale*zchar[i][j];
1003 TXTRU *axisxl = new TXTRU("x","x","text",12,2);
1004 for(i=0;i<12;i++) axisxl->DefineVertex(i,xchar[i][0],xchar[i][1]);
1005 axisxl->DefineSection(0,-0.5*kLw);axisxl->DefineSection(1,0.5*kLw);
1006 TXTRU *axisyl = new TXTRU("y","y","text",9,2);
1007 for(i=0;i<9;i++) axisyl->DefineVertex(i,ychar[i][0],ychar[i][1]);
1008 axisyl->DefineSection(0,-0.5*kLw);axisyl->DefineSection(1,0.5*kLw);
1009 TXTRU *axiszl = new TXTRU("z","z","text",10,2);
1010 for(i=0;i<10;i++) axiszl->DefineVertex(i,zchar[i][0],zchar[i][1]);
1011 axiszl->DefineSection(0,-0.5*kLw);axiszl->DefineSection(1,0.5*kLw);
1012 Float_t lxy[13][2]={{-0.5*kLw,-0.5*kLw},{0.8,-0.5*kLw},{0.8,-0.1},{1.0,0.0},
1013 {0.8,0.1},{0.8,0.5*kLw},{0.5*kLw,0.5*kLw},{0.5*kLw,0.8},
1014 {0.1,0.8},{0.0,1.0},{-0.1,0.8},{-0.5*kLw,0.8},
1015 {-0.5*kLw,-0.5*kLw}};
1016 TXTRU *axisxy = new TXTRU("axisxy","axisxy","text",13,2);
1017 for(i=0;i<13;i++) axisxy->DefineVertex(i,lxy[i][0],lxy[i][1]);
1018 axisxy->DefineSection(0,-0.5*kLw);axisxy->DefineSection(1,0.5*kLw);
1019 Float_t lz[8][2]={{0.5*kLw,-0.5*kLw},{0.8,-0.5*kLw},{0.8,-0.1},{1.0,0.0},
1020 {0.8,0.1},{0.8,0.5*kLw},{0.5*kLw,0.5*kLw},
1021 {0.5*kLw,-0.5*kLw}};
1022 TXTRU *axisz = new TXTRU("axisz","axisz","text",8,2);
1023 for(i=0;i<8;i++) axisz->DefineVertex(i,lz[i][0],lz[i][1]);
1024 axisz->DefineSection(0,-0.5*kLw);axisz->DefineSection(1,0.5*kLw);
1025 //TRotMatrix *xaxis90= new TRotMatrix("xaixis90","",90.0, 0.0, 0.0);
1026 TRotMatrix *yaxis90= new TRotMatrix("yaixis90","", 0.0,90.0, 0.0);
1027 TRotMatrix *zaxis90= new TRotMatrix("zaixis90","", 0.0, 0.0,90.0);
1030 title = name.Append("axisxy");
1031 TNode *nodeaxy = new TNode(title.Data(),title.Data(),axisxy);
1032 title = name.Append("axisz");
1033 TNode *nodeaz = new TNode(title.Data(),title.Data(),axisz,0.,0.,0.,yaxis90);
1034 TNode *textboxX0 = new TNode("textboxX0","textboxX0",axisxl,
1035 lxy[3][0],lxy[3][1],0.0);
1036 TNode *textboxX1 = new TNode("textboxX1","textboxX1",axisxl,
1037 lxy[3][0],lxy[3][1],0.0,yaxis90);
1038 TNode *textboxX2 = new TNode("textboxX2","textboxX2",axisxl,
1039 lxy[3][0],lxy[3][1],0.0,zaxis90);
1040 TNode *textboxY0 = new TNode("textboxY0","textboxY0",axisyl,
1041 lxy[9][0],lxy[9][1],0.0);
1042 TNode *textboxY1 = new TNode("textboxY1","textboxY1",axisyl,
1043 lxy[9][0],lxy[9][1],0.0,yaxis90);
1044 TNode *textboxY2 = new TNode("textboxY2","textboxY2",axisyl,
1045 lxy[9][0],lxy[9][1],0.0,zaxis90);
1046 TNode *textboxZ0 = new TNode("textboxZ0","textboxZ0",axiszl,
1048 TNode *textboxZ1 = new TNode("textboxZ1","textboxZ1",axiszl,
1049 0.0,0.0,lz[3][0],yaxis90);
1050 TNode *textboxZ2 = new TNode("textboxZ2","textboxZ2",axiszl,
1051 0.0,0.0,lz[3][0],zaxis90);
1067 //----------------------------------------------------------------------
1068 void AliITSgeomMatrix::MakeFigures() const {
1069 // make figures to help document this class
1076 const Double_t kDx0=550.,kDy0=550.,kDz0=550.; // cm
1077 const Double_t kDx=1.0,kDy=0.300,kDz=3.0,kRmax=0.1; // cm
1078 Float_t l[5][3]={{1.0,0.0,0.0},{0.0,0.0,0.0},{0.0,1.0,0.0},{0.0,0.0,0.0},
1080 TCanvas *c = new TCanvas(kFALSE);// create a batch mode canvas.
1081 TView *view = new TView(1); // Create Cartesian coordiante view
1082 TBRIK *mother = new TBRIK("Mother","Mother","void",kDx0,kDy0,kDz0);
1083 TBRIK *det = new TBRIK("Detector","","Si",kDx,kDy,kDz);
1084 TPolyLine3D *axis = new TPolyLine3D(5,&(l[0][0]));
1085 TPCON *arrow = new TPCON("arrow","","air",0.0,360.,2);
1086 TRotMatrix *xarrow= new TRotMatrix("xarrow","",90.,0.0,0.0);
1087 TRotMatrix *yarrow= new TRotMatrix("yarrow","",0.0,90.,0.0);
1089 det->SetLineColor(0); // black
1090 det->SetLineStyle(1); // solid line
1091 det->SetLineWidth(2); // pixel units
1092 det->SetFillColor(1); // black
1093 det->SetFillStyle(4010); // window is 90% transparent
1094 arrow->SetLineColor(det->GetLineColor());
1095 arrow->SetLineWidth(det->GetLineWidth());
1096 arrow->SetLineStyle(det->GetLineStyle());
1097 arrow->SetFillColor(1); // black
1098 arrow->SetFillStyle(4100); // window is 100% opaque
1099 arrow->DefineSection(0,0.0,0.0,kRmax);
1100 arrow->DefineSection(1,2.*kRmax,0.0,0.0);
1101 view->SetRange(-kDx0,-kDy0,-kDz0,kDx0,kDy0,kDz0);
1103 TNode *node0 = new TNode("NODE0","NODE0",mother);
1105 TNode *node1 = new TNode("NODE1","NODE1",det);
1107 TNode *nodex = new TNode("NODEx","NODEx",arrow,l[0][0],l[0][1],l[0][2],xarrow);
1108 TNode *nodey = new TNode("NODEy","NODEy",arrow,l[2][0],l[2][1],l[2][2],yarrow);
1109 TNode *nodez = new TNode("NODEz","NODEz",arrow,l[4][0],l[4][1],l[4][2]);
1120 c->SaveAs("AliITSgeomMatrix_L1.gif");
1122 //----------------------------------------------------------------------
1123 ostream &operator<<(ostream &os,AliITSgeomMatrix &p){
1124 // Standard output streaming function.
1126 // ostream &os The output stream to print the class data on
1127 // AliITSgeomMatrix &p This class
1136 //----------------------------------------------------------------------
1137 istream &operator>>(istream &is,AliITSgeomMatrix &r){
1138 // Standard input streaming function.
1140 // ostream &os The input stream to print the class data on
1141 // AliITSgeomMatrix &p This class
1150 //----------------------------------------------------------------------