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 **************************************************************************/
18 Revision 1.13 2002/01/28 21:49:19 nilsen
19 Fixed a logical bug in functions GtoLPositionError, LtoGPositionError,
20 GtoLPositionErrorTracking, and LtoGPositionErrorTracking.
22 Revision 1.12 2001/10/12 22:07:20 nilsen
23 A patch for C++ io manipulation functions so that they will work both
24 with GNU gcc 2.96 and GNU gcc 3.01 compilers. Needs to be tested with
27 Revision 1.11 2001/09/04 14:54:31 hristov
28 Const multidimentional arrays cause problems in the CINT dictionary on HP, const removed
30 Revision 1.10 2001/08/24 21:06:37 nilsen
31 Added more documentation, fixed up some coding violations, and some
34 Revision 1.9 2001/03/23 15:21:56 nilsen
35 Added Cylinderical Coordinates for use with Tracking. Fixed a but in the
36 Streamer, It was not setting a value for frot[3] as it should when reading.
38 Revision 1.8 2001/02/09 00:00:57 nilsen
39 Fixed compatibility problem with HP unix {ios::fmtflags -> Int_t}. Fixed
40 bugs in iostream based streamers used to read and write .det files. Fixed
41 some detector sizes. Fixed bugs in some default-special constructors.
43 Revision 1.7 2001/02/03 00:00:30 nilsen
44 New version of AliITSgeom and related files. Now uses automatic streamers,
45 set up for new formatted .det file which includes detector information.
46 Additional smaller modifications are still to come.
48 Revision 1.5 2000/10/02 16:32:35 barbera
49 Forward declaration added
51 Revision 1.1.2.6 2000/10/02 15:52:05 barbera
52 Forward declaration added
54 Revision 1.4 2000/09/07 17:30:45 nilsen
55 fixed a bug in SixAnglesFromMatrix.
57 Revision 1.3 2000/09/05 14:25:50 nilsen
58 Made fixes for HP compiler. All function parameter default values placed
59 in .h file. Fixed the usual problem with HP comilers and the "for(Int_t i..."
60 business. Replaced casting (Double_t [3][3]) to (Double_t (*)[3]) for HP.
61 Lastly removed all "const" before function parameters which were 2 dim. arrays,
62 because on HP root generates some strange code (?). Thanks Peter for the
65 Revision 1.2 2000/08/29 20:16:50 nilsen
66 New class for ITS coordiante transformations used by AliITSgeom nearly
69 Revision 1.1.2.1 2000/06/04 16:32:31 Nilsen
70 A new class to hold the matrix information needed by AliITSgeom.
74 ////////////////////////////////////////////////////////////////////////
75 // This is the implementation file for AliITSgeomMatrix class. It
76 // contains the routines to manipulate, setup, and queary the geometry
77 // of a given ITS module. An ITS module may be one of at least three
78 // ITS detector technologies, Silicon Pixel, Drift, or Strip Detectors,
79 // and variations of these in size and/or layout. These routines let
80 // one go between ALICE global coordiantes (cm) to a given modules
81 // specific local coordinates (cm).
82 ////////////////////////////////////////////////////////////////////////
90 #include "AliITSgeomMatrix.h"
92 ClassImp(AliITSgeomMatrix)
93 //----------------------------------------------------------------------
94 AliITSgeomMatrix::AliITSgeomMatrix(){
95 ////////////////////////////////////////////////////////////////////////
96 // The Default constructor for the AliITSgeomMatrix class. By Default
97 // the angles of rotations are set to zero, meaning that the rotation
98 // matrix is the unit matrix. The translation vector is also set to zero
99 // as are the module id number. The detector type is set to -1 (an undefined
100 // value). The full rotation matrix is kept so that the evaluation
101 // of a coordinate transformation can be done quickly and with a minimum
102 // of CPU overhead. The basic coordinate systems are the ALICE global
103 // coordinate system and the detector local coordinate system. In general
104 // this structure is not limited to just those two coordinate systems.
107 <img src="picts/ITS/AliISgeomMatrix_L1.gif">
110 ////////////////////////////////////////////////////////////////////////
113 fDetectorIndex = -1; // a value never defined.
116 frot[i] = ftran[i] = 0.0;
117 for(j=0;j<3;j++) fm[i][j] = 0.0;
118 fCylR = fCylPhi = 0.0;
120 fm[0][0] = fm[1][1] = fm[2][2] = 1.0;
122 //----------------------------------------------------------------------
123 AliITSgeomMatrix::AliITSgeomMatrix(const AliITSgeomMatrix &sourse){
124 ////////////////////////////////////////////////////////////////////////
125 // The standard copy constructor. This make a full / proper copy of
127 ////////////////////////////////////////////////////////////////////////
130 this->fDetectorIndex = sourse.fDetectorIndex;
132 this->fid[i] = sourse.fid[i];
133 this->frot[i] = sourse.frot[i];
134 this->ftran[i] = sourse.ftran[i];
135 this->fCylR = sourse.fCylR;
136 this->fCylPhi = sourse.fCylPhi;
137 for(j=0;j<3;j++) this->fm[i][j] = sourse.fm[i][j];
140 //----------------------------------------------------------------------
141 void AliITSgeomMatrix::operator=(const AliITSgeomMatrix &sourse){
142 ////////////////////////////////////////////////////////////////////////
143 // The standard = operator. This make a full / proper copy of
145 ////////////////////////////////////////////////////////////////////////
148 this->fDetectorIndex = sourse.fDetectorIndex;
150 this->fid[i] = sourse.fid[i];
151 this->frot[i] = sourse.frot[i];
152 this->ftran[i] = sourse.ftran[i];
153 this->fCylR = sourse.fCylR;
154 this->fCylPhi = sourse.fCylPhi;
155 for(j=0;j<3;j++) this->fm[i][j] = sourse.fm[i][j];
158 //----------------------------------------------------------------------
159 AliITSgeomMatrix::AliITSgeomMatrix(const Int_t idt,const Int_t id[3],
160 const Double_t rot[3],const Double_t tran[3]){
161 ////////////////////////////////////////////////////////////////////////
162 // This is a constructor for the AliITSgeomMatrix class. The matrix is
163 // defined by 3 standard rotation angles [radians], and the translation
164 // vector tran [cm]. In addition the layer, ladder, and detector number
165 // for this particular module and the type of module must be given.
166 // The full rotation matrix is kept so that the evaluation
167 // of a coordinate transformation can be done quickly and with a minimum
168 // of CPU overhead. The basic coordinate systems are the ALICE global
169 // coordinate system and the detector local coordinate system. In general
170 // this structure is not limited to just those two coordinate systems.
173 <img src="picts/ITS/AliISgeomMatrix_L1.gif">
176 ////////////////////////////////////////////////////////////////////////
179 fDetectorIndex = idt; // a value never defined.
185 fCylR = TMath::Sqrt(ftran[0]*ftran[0]+ftran[1]*ftran[1]);
186 fCylPhi = TMath::ATan2(ftran[1],ftran[0]);
187 if(fCylPhi<0.0) fCylPhi += TMath::Pi();
188 this->MatrixFromAngle();
190 //----------------------------------------------------------------------
191 AliITSgeomMatrix::AliITSgeomMatrix(const Int_t idt, const Int_t id[3],
192 Double_t matrix[3][3],
193 const Double_t tran[3]){
194 ////////////////////////////////////////////////////////////////////////
195 // This is a constructor for the AliITSgeomMatrix class. The rotation matrix
196 // is given as one of the inputs, and the translation vector tran [cm]. In
197 // addition the layer, ladder, and detector number for this particular
198 // module and the type of module must be given. The full rotation matrix
199 // is kept so that the evaluation of a coordinate transformation can be
200 // done quickly and with a minimum of CPU overhead. The basic coordinate
201 // systems are the ALICE global coordinate system and the detector local
202 // coordinate system. In general this structure is not limited to just
203 // those two coordinate systems.
206 <img src="picts/ITS/AliISgeomMatrix_L1.gif">
209 ////////////////////////////////////////////////////////////////////////
212 fDetectorIndex = idt; // a value never defined.
216 for(j=0;j<3;j++) fm[i][j] = matrix[i][j];
218 fCylR = TMath::Sqrt(ftran[0]*ftran[0]+ftran[1]*ftran[1]);
219 fCylPhi = TMath::ATan2(ftran[1],ftran[0]);
220 if(fCylPhi<0.0) fCylPhi += TMath::Pi();
221 this->AngleFromMatrix();
223 //----------------------------------------------------------------------
224 void AliITSgeomMatrix::SixAnglesFromMatrix(Double_t *ang){
225 ////////////////////////////////////////////////////////////////////////
226 // This function returns the 6 GEANT 3.21 rotation angles [degrees] in
227 // the array ang which must be at least [6] long.
228 ////////////////////////////////////////////////////////////////////////
229 Double_t si,c=180./TMath::Pi();
231 ang[1] = TMath::ATan2(fm[0][1],fm[0][0]);
232 if(TMath::Cos(ang[1])!=0.0) si = fm[0][0]/TMath::Cos(ang[1]);
233 else si = fm[0][1]/TMath::Sin(ang[1]);
234 ang[0] = TMath::ATan2(si,fm[0][2]);
236 ang[3] = TMath::ATan2(fm[1][1],fm[1][0]);
237 if(TMath::Cos(ang[3])!=0.0) si = fm[1][0]/TMath::Cos(ang[3]);
238 else si = fm[1][1]/TMath::Sin(ang[3]);
239 ang[2] = TMath::ATan2(si,fm[1][2]);
241 ang[5] = TMath::ATan2(fm[2][1],fm[2][0]);
242 if(TMath::Cos(ang[5])!=0.0) si = fm[2][0]/TMath::Cos(ang[5]);
243 else si = fm[2][1]/TMath::Sin(ang[5]);
244 ang[4] = TMath::ATan2(si,fm[2][2]);
246 for(Int_t i=0;i<6;i++) {ang[i] *= c; if(ang[i]<0.0) ang[i] += 360.;}
248 //----------------------------------------------------------------------
249 void AliITSgeomMatrix::MatrixFromSixAngles(const Double_t *ang){
250 ////////////////////////////////////////////////////////////////////////
251 // Given the 6 GEANT 3.21 rotation angles [degree], this will compute and
252 // set the rotations matrix and 3 standard rotation angles [radians].
253 // These angles and rotation matrix are overwrite the existing values in
255 ////////////////////////////////////////////////////////////////////////
257 Double_t si,lr[9],c=TMath::Pi()/180.;
259 si = TMath::Sin(c*ang[0]);
260 if(ang[0]== 90.0) si = +1.0;
261 if(ang[0]==270.0) si = -1.0;
262 if(ang[0]== 0.0||ang[0]==180.) si = 0.0;
263 lr[0] = si * TMath::Cos(c*ang[1]);
264 lr[1] = si * TMath::Sin(c*ang[1]);
265 lr[2] = TMath::Cos(c*ang[0]);
266 if(ang[0]== 90.0||ang[0]==270.) lr[2] = 0.0;
267 if(ang[0]== 0.0) lr[2] = +1.0;
268 if(ang[0]==180.0) lr[2] = -1.0;
270 si = TMath::Sin(c*ang[2]);
271 if(ang[2]== 90.0) si = +1.0;
272 if(ang[2]==270.0) si = -1.0;
273 if(ang[2]== 0.0||ang[2]==180.) si = 0.0;
274 lr[3] = si * TMath::Cos(c*ang[3]);
275 lr[4] = si * TMath::Sin(c*ang[3]);
276 lr[5] = TMath::Cos(c*ang[2]);
277 if(ang[2]== 90.0||ang[2]==270.) lr[5] = 0.0;
278 if(ang[2]== 0.0) lr[5] = +1.0;
279 if(ang[2]==180.0) lr[5] = -1.0;
281 si = TMath::Sin(c*ang[4]);
282 if(ang[4]== 90.0) si = +1.0;
283 if(ang[4]==270.0) si = -1.0;
284 if(ang[4]== 0.0||ang[4]==180.) si = 0.0;
285 lr[6] = si * TMath::Cos(c*ang[5]);
286 lr[7] = si * TMath::Sin(c*ang[5]);
287 lr[8] = TMath::Cos(c*ang[4]);
288 if(ang[4]== 90.0||ang[4]==270.0) lr[8] = 0.0;
289 if(ang[4]== 0.0) lr[8] = +1.0;
290 if(ang[4]==180.0) lr[8] = -1.0;
291 // Normalize these elements and fill matrix fm.
292 for(i=0;i<3;i++){// reuse si.
294 for(j=0;j<3;j++) si += lr[3*i+j]*lr[3*i+j];
295 si = TMath::Sqrt(1./si);
296 for(j=0;j<3;j++) fm[i][j] = si*lr[3*i+j];
298 this->AngleFromMatrix();
300 //----------------------------------------------------------------------
301 AliITSgeomMatrix::AliITSgeomMatrix(const Double_t rotd[6]/*degrees*/,
302 const Int_t idt,const Int_t id[3],
303 const Double_t tran[3]){
304 ////////////////////////////////////////////////////////////////////////
305 // This is a constructor for the AliITSgeomMatrix class. The matrix is
306 // defined by the 6 GEANT 3.21 rotation angles [degrees], and the translation
307 // vector tran [cm]. In addition the layer, ladder, and detector number
308 // for this particular module and the type of module must be given.
309 // The full rotation matrix is kept so that the evaluation
310 // of a coordinate transformation can be done quickly and with a minimum
311 // of CPU overhead. The basic coordinate systems are the ALICE global
312 // coordinate system and the detector local coordinate system. In general
313 // this structure is not limited to just those two coordinate systems.
316 <img src="picts/ITS/AliISgeomMatrix_L1.gif">
319 ////////////////////////////////////////////////////////////////////////
322 fDetectorIndex = idt; // a value never defined.
327 fCylR = TMath::Sqrt(ftran[0]*ftran[0]+ftran[1]*ftran[1]);
328 fCylPhi = TMath::ATan2(ftran[1],ftran[0]);
329 if(fCylPhi<0.0) fCylPhi += TMath::Pi();
330 this->MatrixFromSixAngles(rotd);
332 //----------------------------------------------------------------------
333 void AliITSgeomMatrix::AngleFromMatrix(){
334 ////////////////////////////////////////////////////////////////////////
335 // Computes the angles from the rotation matrix up to a phase of 180 degrees.
336 ////////////////////////////////////////////////////////////////////////
338 // get angles from matrix up to a phase of 180 degrees.
340 rx = TMath::ATan2(fm[2][1],fm[2][2]);if(rx<0.0) rx += 2.0*TMath::Pi();
341 ry = TMath::ASin(fm[0][2]); if(ry<0.0) ry += 2.0*TMath::Pi();
342 rz = TMath::ATan2(fm[1][1],fm[0][0]);if(rz<0.0) rz += 2.0*TMath::Pi();
348 //----------------------------------------------------------------------
349 void AliITSgeomMatrix::MatrixFromAngle(){
350 ////////////////////////////////////////////////////////////////////////
351 // Computes the Rotation matrix from the angles [radians] kept in this
353 ////////////////////////////////////////////////////////////////////////
354 Double_t sx,sy,sz,cx,cy,cz;
356 sx = TMath::Sin(frot[0]); cx = TMath::Cos(frot[0]);
357 sy = TMath::Sin(frot[1]); cy = TMath::Cos(frot[1]);
358 sz = TMath::Sin(frot[2]); cz = TMath::Cos(frot[2]);
359 fm[0][0] = cz*cy; // fr[0]
360 fm[0][1] = -cz*sy*sx - sz*cx; // fr[1]
361 fm[0][2] = -cz*sy*cx + sz*sx; // fr[2]
362 fm[1][0] = sz*cy; // fr[3]
363 fm[1][1] = -sz*sy*sx + cz*cx; // fr[4]
364 fm[1][2] = -sz*sy*cx - cz*sx; // fr[5]
365 fm[2][0] = sy; // fr[6]
366 fm[2][1] = cy*sx; // fr[7]
367 fm[2][2] = cy*cx; // fr[8]
370 //----------------------------------------------------------------------
371 void AliITSgeomMatrix::GtoLPosition(const Double_t g0[3],Double_t l[3]){
372 ////////////////////////////////////////////////////////////////////////
373 // Returns the local coordinates given the global coordinates [cm].
374 ////////////////////////////////////////////////////////////////////////
378 for(i=0;i<3;i++) g[i] = g0[i] - ftran[i];
381 for(j=0;j<3;j++) l[i] += fm[i][j]*g[j];
382 // g = R l + translation
386 //----------------------------------------------------------------------
387 void AliITSgeomMatrix::LtoGPosition(const Double_t l[3],Double_t g[3]){
388 ////////////////////////////////////////////////////////////////////////
389 // Returns the global coordinates given the local coordinates [cm].
390 ////////////////////////////////////////////////////////////////////////
395 for(j=0;j<3;j++) g[i] += fm[j][i]*l[j];
397 // g = R^t l + translation
401 //----------------------------------------------------------------------
402 void AliITSgeomMatrix::GtoLMomentum(const Double_t g[3],Double_t l[3]){
403 ////////////////////////////////////////////////////////////////////////
404 // Returns the local coordinates of the momentum given the global
405 // coordinates of the momentum. It transforms just like GtoLPosition
406 // except that the translation vector is zero.
407 ////////////////////////////////////////////////////////////////////////
412 for(j=0;j<3;j++) l[i] += fm[i][j]*g[j];
417 //----------------------------------------------------------------------
418 void AliITSgeomMatrix::LtoGMomentum(const Double_t l[3],Double_t g[3]){
419 ////////////////////////////////////////////////////////////////////////
420 // Returns the Global coordinates of the momentum given the local
421 // coordinates of the momentum. It transforms just like LtoGPosition
422 // except that the translation vector is zero.
423 ////////////////////////////////////////////////////////////////////////
428 for(j=0;j<3;j++) g[i] += fm[j][i]*l[j];
433 //----------------------------------------------------------------------
434 void AliITSgeomMatrix::GtoLPositionError( Double_t g[3][3],
436 ////////////////////////////////////////////////////////////////////////
437 // Given an Uncertainty matrix in Global coordinates it is rotated so that
438 // its representation in local coordinates can be returned. There is no
439 // effect due to the translation vector or its uncertainty.
440 ////////////////////////////////////////////////////////////////////////
443 for(i=0;i<3;i++)for(m=0;m<3;m++){
445 for(j=0;j<3;j++)for(k=0;k<3;k++)
446 l[i][m] += fm[j][i]*g[j][k]*fm[k][m];
451 //----------------------------------------------------------------------
452 void AliITSgeomMatrix::LtoGPositionError( Double_t l[3][3],
454 ////////////////////////////////////////////////////////////////////////
455 // Given an Uncertainty matrix in Local coordinates it is rotated so that
456 // its representation in global coordinates can be returned. There is no
457 // effect due to the translation vector or its uncertainty.
458 ////////////////////////////////////////////////////////////////////////
461 for(i=0;i<3;i++)for(m=0;m<3;m++){
463 for(j=0;j<3;j++)for(k=0;k<3;k++)
464 g[i][m] += fm[i][j]*l[j][k]*fm[m][k];
469 //----------------------------------------------------------------------
470 void AliITSgeomMatrix::GtoLPositionTracking(const Double_t g0[3],
472 ////////////////////////////////////////////////////////////////////////
473 // A slightly different coordinate system is used when tracking.
474 // This coordinate system is only relevant when the geometry represents
475 // the cylindrical ALICE ITS geometry. For tracking the Z axis is left
476 // alone but X -> -Y and Y -> X such that X always points out of the
477 // ITS Cylinder for every layer including layer 1 (where the detector
478 // are mounted upside down).
481 <img src="picts/ITS/AliITSgeomMatrix_T1.gif">
484 ////////////////////////////////////////////////////////////////////////
487 this->GtoLPosition(g0,l0);
488 if(fid[0]==1){ // for layer 1 the detector are flipped upside down
489 // with respect to the others.
500 //----------------------------------------------------------------------
501 void AliITSgeomMatrix::LtoGPositionTracking(const Double_t l[3],
503 ////////////////////////////////////////////////////////////////////////
504 // A slightly different coordinate system is used when tracking.
505 // This coordinate system is only relevant when the geometry represents
506 // the cylindrical ALICE ITS geometry. For tracking the Z axis is left
507 // alone but X -> -Y and Y -> X such that X always points out of the
508 // ITS Cylinder for every layer including layer 1 (where the detector
509 // are mounted upside down).
512 <img src="picts/ITS/AliITSgeomMatrix_T1.gif">
515 ////////////////////////////////////////////////////////////////////////
518 if(fid[0]==1){ // for layer 1 the detector are flipped upside down
519 // with respect to the others.
528 this->LtoGPosition(l0,g);
531 //----------------------------------------------------------------------
532 void AliITSgeomMatrix::GtoLMomentumTracking(const Double_t g[3],
534 ////////////////////////////////////////////////////////////////////////
535 // A slightly different coordinate system is used when tracking.
536 // This coordinate system is only relevant when the geometry represents
537 // the cylindrical ALICE ITS geometry. For tracking the Z axis is left
538 // alone but X -> -Y and Y -> X such that X always points out of the
539 // ITS Cylinder for every layer including layer 1 (where the detector
540 // are mounted upside down).
543 <img src="picts/ITS/AliITSgeomMatrix_T1.gif">
546 ////////////////////////////////////////////////////////////////////////
549 this->GtoLMomentum(g,l0);
550 if(fid[0]==1){ // for layer 1 the detector are flipped upside down
551 // with respect to the others.
563 //----------------------------------------------------------------------
564 void AliITSgeomMatrix::LtoGMomentumTracking(const Double_t l[3],
566 ////////////////////////////////////////////////////////////////////////
567 // A slightly different coordinate system is used when tracking.
568 // This coordinate system is only relevant when the geometry represents
569 // the cylindrical ALICE ITS geometry. For tracking the Z axis is left
570 // alone but X -> -Y and Y -> X such that X always points out of the
571 // ITS Cylinder for every layer including layer 1 (where the detector
572 // are mounted upside down).
575 <img src="picts/ITS/AliITSgeomMatrix_T1.gif">
578 ////////////////////////////////////////////////////////////////////////
581 if(fid[0]==1){ // for layer 1 the detector are flipped upside down
582 // with respect to the others.
591 this->LtoGMomentum(l0,g);
594 //----------------------------------------------------------------------
595 void AliITSgeomMatrix::GtoLPositionErrorTracking( Double_t g[3][3],
597 ////////////////////////////////////////////////////////////////////////
598 // A slightly different coordinate system is used when tracking.
599 // This coordinate system is only relevant when the geometry represents
600 // the cylindrical ALICE ITS geometry. For tracking the Z axis is left
601 // alone but X -> -Y and Y -> X such that X always points out of the
602 // ITS Cylinder for every layer including layer 1 (where the detector
603 // are mounted upside down).
606 <img src="picts/ITS/AliITSgeomMatrix_T1.gif">
609 ////////////////////////////////////////////////////////////////////////
612 Double_t a0[3][3] = {{0.,+1.,0.},{-1.,0.,0.},{0.,0.,+1.}};
613 Double_t a1[3][3] = {{0.,-1.,0.},{+1.,0.,0.},{0.,0.,+1.}};
615 if(fid[0]==1) for(i=0;i<3;i++)for(j=0;j<3;j++)for(k=0;k<3;k++)
616 rt[i][k] = a0[i][j]*fm[j][k];
617 else for(i=0;i<3;i++)for(j=0;j<3;j++)for(k=0;k<3;k++)
618 rt[i][k] = a1[i][j]*fm[j][k];
619 for(i=0;i<3;i++)for(m=0;m<3;m++){
621 for(j=0;j<3;j++)for(k=0;k<3;k++)
622 l[i][m] += rt[j][i]*g[j][k]*rt[k][m];
627 //----------------------------------------------------------------------
628 void AliITSgeomMatrix::LtoGPositionErrorTracking( Double_t l[3][3],
630 ////////////////////////////////////////////////////////////////////////
631 // A slightly different coordinate system is used when tracking.
632 // This coordinate system is only relevant when the geometry represents
633 // the cylindrical ALICE ITS geometry. For tracking the Z axis is left
634 // alone but X -> -Y and Y -> X such that X always points out of the
635 // ITS Cylinder for every layer including layer 1 (where the detector
636 // are mounted upside down).
639 <img src="picts/ITS/AliITSgeomMatrix_T1.gif">
642 ////////////////////////////////////////////////////////////////////////
645 Double_t a0[3][3] = {{0.,+1.,0.},{-1.,0.,0.},{0.,0.,+1.}};
646 Double_t a1[3][3] = {{0.,-1.,0.},{+1.,0.,0.},{0.,0.,+1.}};
648 if(fid[0]==1) for(i=0;i<3;i++)for(j=0;j<3;j++)for(k=0;k<3;k++)
649 rt[i][k] = a0[i][j]*fm[j][k];
650 else for(i=0;i<3;i++)for(j=0;j<3;j++)for(k=0;k<3;k++)
651 rt[i][k] = a1[i][j]*fm[j][k];
652 for(i=0;i<3;i++)for(m=0;m<3;m++){
654 for(j=0;j<3;j++)for(k=0;k<3;k++)
655 g[i][m] += rt[i][j]*l[j][k]*rt[m][k];
660 //----------------------------------------------------------------------
661 void AliITSgeomMatrix::PrintTitles(ostream *os){
662 ////////////////////////////////////////////////////////////////////////
663 // Standard output format for this class but it includes variable
664 // names and formatting that makes it easer to read.
665 ////////////////////////////////////////////////////////////////////////
668 *os << "fDetectorIndex=" << fDetectorIndex << " fid[3]={";
669 for(i=0;i<3;i++) *os << fid[i] << " ";
670 *os << "} frot[3]={";
671 for(i=0;i<3;i++) *os << frot[i] << " ";
672 *os << "} ftran[3]={";
673 for(i=0;i<3;i++) *os << ftran[i] << " ";
674 *os << "} fm[3][3]={";
675 for(i=0;i<3;i++){for(j=0;j<3;j++){ *os << fm[i][j] << " ";} *os <<"}{";}
679 //----------------------------------------------------------------------
680 void AliITSgeomMatrix::PrintComment(ostream *os){
681 ////////////////////////////////////////////////////////////////////////
682 // output format used by Print..
683 ////////////////////////////////////////////////////////////////////////
684 *os << "fDetectorIndex fid[0] fid[1] fid[2] ftran[0] ftran[1] ftran[2] ";
685 *os << "fm[0][0] fm[0][1] fm[0][2] fm[1][0] fm[1][1] fm[1][2] ";
686 *os << "fm[2][0] fm[2][1] fm[2][2] ";
689 //----------------------------------------------------------------------
690 void AliITSgeomMatrix::Print(ostream *os){
691 ////////////////////////////////////////////////////////////////////////
692 // Standard output format for this class.
693 ////////////////////////////////////////////////////////////////////////
709 fmt = os->setf(ios::scientific); // set scientific floating point output
710 *os << fDetectorIndex << " ";
711 for(i=0;i<3;i++) *os << fid[i] << " ";
712 // for(i=0;i<3;i++) *os << frot[i] << " "; // Redundant with fm[][].
713 for(i=0;i<3;i++) *os << setprecision(16) << ftran[i] << " ";
714 for(i=0;i<3;i++)for(j=0;j<3;j++) *os << setprecision(16) <<
717 os->flags(fmt); // reset back to old formating.
720 //----------------------------------------------------------------------
721 void AliITSgeomMatrix::Read(istream *is){
722 ////////////////////////////////////////////////////////////////////////
723 // Standard input format for this class.
724 ////////////////////////////////////////////////////////////////////////
727 *is >> fDetectorIndex;
728 for(i=0;i<3;i++) *is >> fid[i];
729 // for(i=0;i<3;i++) *is >> frot[i]; // Redundant with fm[][].
730 for(i=0;i<3;i++) *is >> ftran[i];
731 for(i=0;i<3;i++)for(j=0;j<3;j++) *is >> fm[i][j];
732 AngleFromMatrix(); // compute angles frot[].
733 fCylR = TMath::Sqrt(ftran[0]*ftran[0]+ftran[1]*ftran[1]);
734 fCylPhi = TMath::ATan2(ftran[1],ftran[0]);
735 if(fCylPhi<0.0) fCylPhi += TMath::Pi();
738 //______________________________________________________________________
739 void AliITSgeomMatrix::Streamer(TBuffer &R__b){
740 // Stream an object of class AliITSgeomMatrix.
742 if (R__b.IsReading()) {
743 AliITSgeomMatrix::Class()->ReadBuffer(R__b, this);
744 fCylR = TMath::Sqrt(ftran[0]*ftran[0]+ftran[1]*ftran[1]);
745 fCylPhi = TMath::ATan2(ftran[1],ftran[0]);
746 this->AngleFromMatrix();
747 if(fCylPhi<0.0) fCylPhi += TMath::Pi();
749 AliITSgeomMatrix::Class()->WriteBuffer(R__b, this);
752 //----------------------------------------------------------------------
753 ostream &operator<<(ostream &os,AliITSgeomMatrix &p){
754 ////////////////////////////////////////////////////////////////////////
755 // Standard output streaming function.
756 ////////////////////////////////////////////////////////////////////////
761 //----------------------------------------------------------------------
762 istream &operator>>(istream &is,AliITSgeomMatrix &r){
763 ////////////////////////////////////////////////////////////////////////
764 // Standard input streaming function.
765 ////////////////////////////////////////////////////////////////////////
770 //----------------------------------------------------------------------