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.10 2001/08/24 21:06:37 nilsen
19 Added more documentation, fixed up some coding violations, and some
22 Revision 1.9 2001/03/23 15:21:56 nilsen
23 Added Cylinderical Coordinates for use with Tracking. Fixed a but in the
24 Streamer, It was not setting a value for frot[3] as it should when reading.
26 Revision 1.8 2001/02/09 00:00:57 nilsen
27 Fixed compatibility problem with HP unix {ios::fmtflags -> Int_t}. Fixed
28 bugs in iostream based streamers used to read and write .det files. Fixed
29 some detector sizes. Fixed bugs in some default-special constructors.
31 Revision 1.7 2001/02/03 00:00:30 nilsen
32 New version of AliITSgeom and related files. Now uses automatic streamers,
33 set up for new formatted .det file which includes detector information.
34 Additional smaller modifications are still to come.
36 Revision 1.5 2000/10/02 16:32:35 barbera
37 Forward declaration added
39 Revision 1.1.2.6 2000/10/02 15:52:05 barbera
40 Forward declaration added
42 Revision 1.4 2000/09/07 17:30:45 nilsen
43 fixed a bug in SixAnglesFromMatrix.
45 Revision 1.3 2000/09/05 14:25:50 nilsen
46 Made fixes for HP compiler. All function parameter default values placed
47 in .h file. Fixed the usual problem with HP comilers and the "for(Int_t i..."
48 business. Replaced casting (Double_t [3][3]) to (Double_t (*)[3]) for HP.
49 Lastly removed all "const" before function parameters which were 2 dim. arrays,
50 because on HP root generates some strange code (?). Thanks Peter for the
53 Revision 1.2 2000/08/29 20:16:50 nilsen
54 New class for ITS coordiante transformations used by AliITSgeom nearly
57 Revision 1.1.2.1 2000/06/04 16:32:31 Nilsen
58 A new class to hold the matrix information needed by AliITSgeom.
62 ////////////////////////////////////////////////////////////////////////
63 // This is the implementation file for AliITSgeomMatrix class. It
64 // contains the routines to manipulate, setup, and queary the geometry
65 // of a given ITS module. An ITS module may be one of at least three
66 // ITS detector technologies, Silicon Pixel, Drift, or Strip Detectors,
67 // and variations of these in size and/or layout. These routines let
68 // one go between ALICE global coordiantes (cm) to a given modules
69 // specific local coordinates (cm).
70 ////////////////////////////////////////////////////////////////////////
78 #include "AliITSgeomMatrix.h"
80 ClassImp(AliITSgeomMatrix)
81 //----------------------------------------------------------------------
82 AliITSgeomMatrix::AliITSgeomMatrix(){
83 ////////////////////////////////////////////////////////////////////////
84 // The Default constructor for the AliITSgeomMatrix class. By Default
85 // the angles of rotations are set to zero, meaning that the rotation
86 // matrix is the unit matrix. The translation vector is also set to zero
87 // as are the module id number. The detector type is set to -1 (an undefined
88 // value). The full rotation matrix is kept so that the evaluation
89 // of a coordinate transformation can be done quickly and with a minimum
90 // of CPU overhead. The basic coordinate systems are the ALICE global
91 // coordinate system and the detector local coordinate system. In general
92 // this structure is not limited to just those two coordinate systems.
95 <img src="picts/ITS/AliISgeomMatrix_L1.gif">
98 ////////////////////////////////////////////////////////////////////////
101 fDetectorIndex = -1; // a value never defined.
104 frot[i] = ftran[i] = 0.0;
105 for(j=0;j<3;j++) fm[i][j] = 0.0;
106 fCylR = fCylPhi = 0.0;
108 fm[0][0] = fm[1][1] = fm[2][2] = 1.0;
110 //----------------------------------------------------------------------
111 AliITSgeomMatrix::AliITSgeomMatrix(const AliITSgeomMatrix &sourse){
112 ////////////////////////////////////////////////////////////////////////
113 // The standard copy constructor. This make a full / proper copy of
115 ////////////////////////////////////////////////////////////////////////
118 this->fDetectorIndex = sourse.fDetectorIndex;
120 this->fid[i] = sourse.fid[i];
121 this->frot[i] = sourse.frot[i];
122 this->ftran[i] = sourse.ftran[i];
123 this->fCylR = sourse.fCylR;
124 this->fCylPhi = sourse.fCylPhi;
125 for(j=0;j<3;j++) this->fm[i][j] = sourse.fm[i][j];
128 //----------------------------------------------------------------------
129 void AliITSgeomMatrix::operator=(const AliITSgeomMatrix &sourse){
130 ////////////////////////////////////////////////////////////////////////
131 // The standard = operator. This make a full / proper copy of
133 ////////////////////////////////////////////////////////////////////////
136 this->fDetectorIndex = sourse.fDetectorIndex;
138 this->fid[i] = sourse.fid[i];
139 this->frot[i] = sourse.frot[i];
140 this->ftran[i] = sourse.ftran[i];
141 this->fCylR = sourse.fCylR;
142 this->fCylPhi = sourse.fCylPhi;
143 for(j=0;j<3;j++) this->fm[i][j] = sourse.fm[i][j];
146 //----------------------------------------------------------------------
147 AliITSgeomMatrix::AliITSgeomMatrix(const Int_t idt,const Int_t id[3],
148 const Double_t rot[3],const Double_t tran[3]){
149 ////////////////////////////////////////////////////////////////////////
150 // This is a constructor for the AliITSgeomMatrix class. The matrix is
151 // defined by 3 standard rotation angles [radians], and the translation
152 // vector tran [cm]. In addition the layer, ladder, and detector number
153 // for this particular module and the type of module must be given.
154 // The full rotation matrix is kept so that the evaluation
155 // of a coordinate transformation can be done quickly and with a minimum
156 // of CPU overhead. The basic coordinate systems are the ALICE global
157 // coordinate system and the detector local coordinate system. In general
158 // this structure is not limited to just those two coordinate systems.
161 <img src="picts/ITS/AliISgeomMatrix_L1.gif">
164 ////////////////////////////////////////////////////////////////////////
167 fDetectorIndex = idt; // a value never defined.
173 fCylR = TMath::Sqrt(ftran[0]*ftran[0]+ftran[1]*ftran[1]);
174 fCylPhi = TMath::ATan2(ftran[1],ftran[0]);
175 if(fCylPhi<0.0) fCylPhi += TMath::Pi();
176 this->MatrixFromAngle();
178 //----------------------------------------------------------------------
179 AliITSgeomMatrix::AliITSgeomMatrix(const Int_t idt, const Int_t id[3],
180 Double_t matrix[3][3],
181 const Double_t tran[3]){
182 ////////////////////////////////////////////////////////////////////////
183 // This is a constructor for the AliITSgeomMatrix class. The rotation matrix
184 // is given as one of the inputs, and the translation vector tran [cm]. In
185 // addition the layer, ladder, and detector number for this particular
186 // module and the type of module must be given. The full rotation matrix
187 // is kept so that the evaluation of a coordinate transformation can be
188 // done quickly and with a minimum of CPU overhead. The basic coordinate
189 // systems are the ALICE global coordinate system and the detector local
190 // coordinate system. In general this structure is not limited to just
191 // those two coordinate systems.
194 <img src="picts/ITS/AliISgeomMatrix_L1.gif">
197 ////////////////////////////////////////////////////////////////////////
200 fDetectorIndex = idt; // a value never defined.
204 for(j=0;j<3;j++) fm[i][j] = matrix[i][j];
206 fCylR = TMath::Sqrt(ftran[0]*ftran[0]+ftran[1]*ftran[1]);
207 fCylPhi = TMath::ATan2(ftran[1],ftran[0]);
208 if(fCylPhi<0.0) fCylPhi += TMath::Pi();
209 this->AngleFromMatrix();
211 //----------------------------------------------------------------------
212 void AliITSgeomMatrix::SixAnglesFromMatrix(Double_t *ang){
213 ////////////////////////////////////////////////////////////////////////
214 // This function returns the 6 GEANT 3.21 rotation angles [degrees] in
215 // the array ang which must be at least [6] long.
216 ////////////////////////////////////////////////////////////////////////
217 Double_t si,c=180./TMath::Pi();
219 ang[1] = TMath::ATan2(fm[0][1],fm[0][0]);
220 if(TMath::Cos(ang[1])!=0.0) si = fm[0][0]/TMath::Cos(ang[1]);
221 else si = fm[0][1]/TMath::Sin(ang[1]);
222 ang[0] = TMath::ATan2(si,fm[0][2]);
224 ang[3] = TMath::ATan2(fm[1][1],fm[1][0]);
225 if(TMath::Cos(ang[3])!=0.0) si = fm[1][0]/TMath::Cos(ang[3]);
226 else si = fm[1][1]/TMath::Sin(ang[3]);
227 ang[2] = TMath::ATan2(si,fm[1][2]);
229 ang[5] = TMath::ATan2(fm[2][1],fm[2][0]);
230 if(TMath::Cos(ang[5])!=0.0) si = fm[2][0]/TMath::Cos(ang[5]);
231 else si = fm[2][1]/TMath::Sin(ang[5]);
232 ang[4] = TMath::ATan2(si,fm[2][2]);
234 for(Int_t i=0;i<6;i++) {ang[i] *= c; if(ang[i]<0.0) ang[i] += 360.;}
236 //----------------------------------------------------------------------
237 void AliITSgeomMatrix::MatrixFromSixAngles(const Double_t *ang){
238 ////////////////////////////////////////////////////////////////////////
239 // Given the 6 GEANT 3.21 rotation angles [degree], this will compute and
240 // set the rotations matrix and 3 standard rotation angles [radians].
241 // These angles and rotation matrix are overwrite the existing values in
243 ////////////////////////////////////////////////////////////////////////
245 Double_t si,lr[9],c=TMath::Pi()/180.;
247 si = TMath::Sin(c*ang[0]);
248 if(ang[0]== 90.0) si = +1.0;
249 if(ang[0]==270.0) si = -1.0;
250 if(ang[0]== 0.0||ang[0]==180.) si = 0.0;
251 lr[0] = si * TMath::Cos(c*ang[1]);
252 lr[1] = si * TMath::Sin(c*ang[1]);
253 lr[2] = TMath::Cos(c*ang[0]);
254 if(ang[0]== 90.0||ang[0]==270.) lr[2] = 0.0;
255 if(ang[0]== 0.0) lr[2] = +1.0;
256 if(ang[0]==180.0) lr[2] = -1.0;
258 si = TMath::Sin(c*ang[2]);
259 if(ang[2]== 90.0) si = +1.0;
260 if(ang[2]==270.0) si = -1.0;
261 if(ang[2]== 0.0||ang[2]==180.) si = 0.0;
262 lr[3] = si * TMath::Cos(c*ang[3]);
263 lr[4] = si * TMath::Sin(c*ang[3]);
264 lr[5] = TMath::Cos(c*ang[2]);
265 if(ang[2]== 90.0||ang[2]==270.) lr[5] = 0.0;
266 if(ang[2]== 0.0) lr[5] = +1.0;
267 if(ang[2]==180.0) lr[5] = -1.0;
269 si = TMath::Sin(c*ang[4]);
270 if(ang[4]== 90.0) si = +1.0;
271 if(ang[4]==270.0) si = -1.0;
272 if(ang[4]== 0.0||ang[4]==180.) si = 0.0;
273 lr[6] = si * TMath::Cos(c*ang[5]);
274 lr[7] = si * TMath::Sin(c*ang[5]);
275 lr[8] = TMath::Cos(c*ang[4]);
276 if(ang[4]== 90.0||ang[4]==270.0) lr[8] = 0.0;
277 if(ang[4]== 0.0) lr[8] = +1.0;
278 if(ang[4]==180.0) lr[8] = -1.0;
279 // Normalize these elements and fill matrix fm.
280 for(i=0;i<3;i++){// reuse si.
282 for(j=0;j<3;j++) si += lr[3*i+j]*lr[3*i+j];
283 si = TMath::Sqrt(1./si);
284 for(j=0;j<3;j++) fm[i][j] = si*lr[3*i+j];
286 this->AngleFromMatrix();
288 //----------------------------------------------------------------------
289 AliITSgeomMatrix::AliITSgeomMatrix(const Double_t rotd[6]/*degrees*/,
290 const Int_t idt,const Int_t id[3],
291 const Double_t tran[3]){
292 ////////////////////////////////////////////////////////////////////////
293 // This is a constructor for the AliITSgeomMatrix class. The matrix is
294 // defined by the 6 GEANT 3.21 rotation angles [degrees], and the translation
295 // vector tran [cm]. In addition the layer, ladder, and detector number
296 // for this particular module and the type of module must be given.
297 // The full rotation matrix is kept so that the evaluation
298 // of a coordinate transformation can be done quickly and with a minimum
299 // of CPU overhead. The basic coordinate systems are the ALICE global
300 // coordinate system and the detector local coordinate system. In general
301 // this structure is not limited to just those two coordinate systems.
304 <img src="picts/ITS/AliISgeomMatrix_L1.gif">
307 ////////////////////////////////////////////////////////////////////////
310 fDetectorIndex = idt; // a value never defined.
315 fCylR = TMath::Sqrt(ftran[0]*ftran[0]+ftran[1]*ftran[1]);
316 fCylPhi = TMath::ATan2(ftran[1],ftran[0]);
317 if(fCylPhi<0.0) fCylPhi += TMath::Pi();
318 this->MatrixFromSixAngles(rotd);
320 //----------------------------------------------------------------------
321 void AliITSgeomMatrix::AngleFromMatrix(){
322 ////////////////////////////////////////////////////////////////////////
323 // Computes the angles from the rotation matrix up to a phase of 180 degrees.
324 ////////////////////////////////////////////////////////////////////////
326 // get angles from matrix up to a phase of 180 degrees.
328 rx = TMath::ATan2(fm[2][1],fm[2][2]);if(rx<0.0) rx += 2.0*TMath::Pi();
329 ry = TMath::ASin(fm[0][2]); if(ry<0.0) ry += 2.0*TMath::Pi();
330 rz = TMath::ATan2(fm[1][1],fm[0][0]);if(rz<0.0) rz += 2.0*TMath::Pi();
336 //----------------------------------------------------------------------
337 void AliITSgeomMatrix::MatrixFromAngle(){
338 ////////////////////////////////////////////////////////////////////////
339 // Computes the Rotation matrix from the angles [radians] kept in this
341 ////////////////////////////////////////////////////////////////////////
342 Double_t sx,sy,sz,cx,cy,cz;
344 sx = TMath::Sin(frot[0]); cx = TMath::Cos(frot[0]);
345 sy = TMath::Sin(frot[1]); cy = TMath::Cos(frot[1]);
346 sz = TMath::Sin(frot[2]); cz = TMath::Cos(frot[2]);
347 fm[0][0] = cz*cy; // fr[0]
348 fm[0][1] = -cz*sy*sx - sz*cx; // fr[1]
349 fm[0][2] = -cz*sy*cx + sz*sx; // fr[2]
350 fm[1][0] = sz*cy; // fr[3]
351 fm[1][1] = -sz*sy*sx + cz*cx; // fr[4]
352 fm[1][2] = -sz*sy*cx - cz*sx; // fr[5]
353 fm[2][0] = sy; // fr[6]
354 fm[2][1] = cy*sx; // fr[7]
355 fm[2][2] = cy*cx; // fr[8]
358 //----------------------------------------------------------------------
359 void AliITSgeomMatrix::GtoLPosition(const Double_t g0[3],Double_t l[3]){
360 ////////////////////////////////////////////////////////////////////////
361 // Returns the local coordinates given the global coordinates [cm].
362 ////////////////////////////////////////////////////////////////////////
366 for(i=0;i<3;i++) g[i] = g0[i] - ftran[i];
369 for(j=0;j<3;j++) l[i] += fm[i][j]*g[j];
370 // g = R l + translation
374 //----------------------------------------------------------------------
375 void AliITSgeomMatrix::LtoGPosition(const Double_t l[3],Double_t g[3]){
376 ////////////////////////////////////////////////////////////////////////
377 // Returns the global coordinates given the local coordinates [cm].
378 ////////////////////////////////////////////////////////////////////////
383 for(j=0;j<3;j++) g[i] += fm[j][i]*l[j];
385 // g = R^t l + translation
389 //----------------------------------------------------------------------
390 void AliITSgeomMatrix::GtoLMomentum(const Double_t g[3],Double_t l[3]){
391 ////////////////////////////////////////////////////////////////////////
392 // Returns the local coordinates of the momentum given the global
393 // coordinates of the momentum. It transforms just like GtoLPosition
394 // except that the translation vector is zero.
395 ////////////////////////////////////////////////////////////////////////
400 for(j=0;j<3;j++) l[i] += fm[i][j]*g[j];
405 //----------------------------------------------------------------------
406 void AliITSgeomMatrix::LtoGMomentum(const Double_t l[3],Double_t g[3]){
407 ////////////////////////////////////////////////////////////////////////
408 // Returns the Global coordinates of the momentum given the local
409 // coordinates of the momentum. It transforms just like LtoGPosition
410 // except that the translation vector is zero.
411 ////////////////////////////////////////////////////////////////////////
416 for(j=0;j<3;j++) g[i] += fm[j][i]*l[j];
421 //----------------------------------------------------------------------
422 void AliITSgeomMatrix::GtoLPositionError( Double_t g[3][3],
424 ////////////////////////////////////////////////////////////////////////
425 // Given an Uncertainty matrix in Global coordinates it is rotated so that
426 // its representation in local coordinates can be returned. There is no
427 // effect due to the translation vector or its uncertainty.
428 ////////////////////////////////////////////////////////////////////////
431 for(i=0;i<3;i++)for(j=0;j<3;j++)for(k=0;k<3;k++)for(m=0;m<3;m++)
432 l[i][m] = fm[j][i]*g[j][k]*fm[k][m];
436 //----------------------------------------------------------------------
437 void AliITSgeomMatrix::LtoGPositionError( Double_t l[3][3],
439 ////////////////////////////////////////////////////////////////////////
440 // Given an Uncertainty matrix in Local coordinates it is rotated so that
441 // its representation in global coordinates can be returned. There is no
442 // effect due to the translation vector or its uncertainty.
443 ////////////////////////////////////////////////////////////////////////
446 for(i=0;i<3;i++)for(j=0;j<3;j++)for(k=0;k<3;k++)for(m=0;m<3;m++)
447 g[i][m] = fm[i][j]*l[j][k]*fm[m][k];
451 //----------------------------------------------------------------------
452 void AliITSgeomMatrix::GtoLPositionTracking(const Double_t g0[3],
454 ////////////////////////////////////////////////////////////////////////
455 // A slightly different coordinate system is used when tracking.
456 // This coordinate system is only relevant when the geometry represents
457 // the cylindrical ALICE ITS geometry. For tracking the Z axis is left
458 // alone but X -> -Y and Y -> X such that X always points out of the
459 // ITS Cylinder for every layer including layer 1 (where the detector
460 // are mounted upside down).
463 <img src="picts/ITS/AliITSgeomMatrix_T1.gif">
466 ////////////////////////////////////////////////////////////////////////
469 this->GtoLPosition(g0,l0);
470 if(fid[0]==1){ // for layer 1 the detector are flipped upside down
471 // with respect to the others.
482 //----------------------------------------------------------------------
483 void AliITSgeomMatrix::LtoGPositionTracking(const Double_t l[3],
485 ////////////////////////////////////////////////////////////////////////
486 // A slightly different coordinate system is used when tracking.
487 // This coordinate system is only relevant when the geometry represents
488 // the cylindrical ALICE ITS geometry. For tracking the Z axis is left
489 // alone but X -> -Y and Y -> X such that X always points out of the
490 // ITS Cylinder for every layer including layer 1 (where the detector
491 // are mounted upside down).
494 <img src="picts/ITS/AliITSgeomMatrix_T1.gif">
497 ////////////////////////////////////////////////////////////////////////
500 if(fid[0]==1){ // for layer 1 the detector are flipped upside down
501 // with respect to the others.
510 this->LtoGPosition(l0,g);
513 //----------------------------------------------------------------------
514 void AliITSgeomMatrix::GtoLMomentumTracking(const Double_t g[3],
516 ////////////////////////////////////////////////////////////////////////
517 // A slightly different coordinate system is used when tracking.
518 // This coordinate system is only relevant when the geometry represents
519 // the cylindrical ALICE ITS geometry. For tracking the Z axis is left
520 // alone but X -> -Y and Y -> X such that X always points out of the
521 // ITS Cylinder for every layer including layer 1 (where the detector
522 // are mounted upside down).
525 <img src="picts/ITS/AliITSgeomMatrix_T1.gif">
528 ////////////////////////////////////////////////////////////////////////
531 this->GtoLMomentum(g,l0);
532 if(fid[0]==1){ // for layer 1 the detector are flipped upside down
533 // with respect to the others.
545 //----------------------------------------------------------------------
546 void AliITSgeomMatrix::LtoGMomentumTracking(const Double_t l[3],
548 ////////////////////////////////////////////////////////////////////////
549 // A slightly different coordinate system is used when tracking.
550 // This coordinate system is only relevant when the geometry represents
551 // the cylindrical ALICE ITS geometry. For tracking the Z axis is left
552 // alone but X -> -Y and Y -> X such that X always points out of the
553 // ITS Cylinder for every layer including layer 1 (where the detector
554 // are mounted upside down).
557 <img src="picts/ITS/AliITSgeomMatrix_T1.gif">
560 ////////////////////////////////////////////////////////////////////////
563 if(fid[0]==1){ // for layer 1 the detector are flipped upside down
564 // with respect to the others.
573 this->LtoGMomentum(l0,g);
576 //----------------------------------------------------------------------
577 void AliITSgeomMatrix::GtoLPositionErrorTracking( Double_t g[3][3],
579 ////////////////////////////////////////////////////////////////////////
580 // A slightly different coordinate system is used when tracking.
581 // This coordinate system is only relevant when the geometry represents
582 // the cylindrical ALICE ITS geometry. For tracking the Z axis is left
583 // alone but X -> -Y and Y -> X such that X always points out of the
584 // ITS Cylinder for every layer including layer 1 (where the detector
585 // are mounted upside down).
588 <img src="picts/ITS/AliITSgeomMatrix_T1.gif">
591 ////////////////////////////////////////////////////////////////////////
594 Double_t a0[3][3] = {{0.,+1.,0.},{-1.,0.,0.},{0.,0.,+1.}};
595 Double_t a1[3][3] = {{0.,-1.,0.},{+1.,0.,0.},{0.,0.,+1.}};
597 if(fid[0]==1) for(i=0;i<3;i++)for(j=0;j<3;j++)for(k=0;k<3;k++)
598 rt[i][k] = a0[i][j]*fm[j][k];
599 else for(i=0;i<3;i++)for(j=0;j<3;j++)for(k=0;k<3;k++)
600 rt[i][k] = a1[i][j]*fm[j][k];
601 for(i=0;i<3;i++)for(j=0;j<3;j++)for(k=0;k<3;k++)for(m=0;m<3;m++)
602 l[i][m] = rt[j][i]*g[j][k]*rt[k][m];
606 //----------------------------------------------------------------------
607 void AliITSgeomMatrix::LtoGPositionErrorTracking( Double_t l[3][3],
609 ////////////////////////////////////////////////////////////////////////
610 // A slightly different coordinate system is used when tracking.
611 // This coordinate system is only relevant when the geometry represents
612 // the cylindrical ALICE ITS geometry. For tracking the Z axis is left
613 // alone but X -> -Y and Y -> X such that X always points out of the
614 // ITS Cylinder for every layer including layer 1 (where the detector
615 // are mounted upside down).
618 <img src="picts/ITS/AliITSgeomMatrix_T1.gif">
621 ////////////////////////////////////////////////////////////////////////
624 Double_t a0[3][3] = {{0.,+1.,0.},{-1.,0.,0.},{0.,0.,+1.}};
625 Double_t a1[3][3] = {{0.,-1.,0.},{+1.,0.,0.},{0.,0.,+1.}};
627 if(fid[0]==1) for(i=0;i<3;i++)for(j=0;j<3;j++)for(k=0;k<3;k++)
628 rt[i][k] = a0[i][j]*fm[j][k];
629 else for(i=0;i<3;i++)for(j=0;j<3;j++)for(k=0;k<3;k++)
630 rt[i][k] = a1[i][j]*fm[j][k];
631 for(i=0;i<3;i++)for(j=0;j<3;j++)for(k=0;k<3;k++)for(m=0;m<3;m++)
632 g[i][m] = rt[i][j]*l[j][k]*rt[m][k];
636 //----------------------------------------------------------------------
637 void AliITSgeomMatrix::PrintTitles(ostream *os){
638 ////////////////////////////////////////////////////////////////////////
639 // Standard output format for this class but it includes variable
640 // names and formatting that makes it easer to read.
641 ////////////////////////////////////////////////////////////////////////
644 *os << "fDetectorIndex=" << fDetectorIndex << " fid[3]={";
645 for(i=0;i<3;i++) *os << fid[i] << " ";
646 *os << "} frot[3]={";
647 for(i=0;i<3;i++) *os << frot[i] << " ";
648 *os << "} ftran[3]={";
649 for(i=0;i<3;i++) *os << ftran[i] << " ";
650 *os << "} fm[3][3]={";
651 for(i=0;i<3;i++){for(j=0;j<3;j++){ *os << fm[i][j] << " ";} *os <<"}{";}
655 //----------------------------------------------------------------------
656 void AliITSgeomMatrix::PrintComment(ostream *os){
657 ////////////////////////////////////////////////////////////////////////
658 // output format used by Print..
659 ////////////////////////////////////////////////////////////////////////
660 *os << "fDetectorIndex fid[0] fid[1] fid[2] ftran[0] ftran[1] ftran[2] ";
661 *os << "fm[0][0] fm[0][1] fm[0][2] fm[1][0] fm[1][1] fm[1][2] ";
662 *os << "fm[2][0] fm[2][1] fm[2][2] ";
665 //----------------------------------------------------------------------
666 void AliITSgeomMatrix::Print(ostream *os){
667 ////////////////////////////////////////////////////////////////////////
668 // Standard output format for this class.
669 ////////////////////////////////////////////////////////////////////////
673 fmt = os->setf(ios::scientific); // set scientific floating point output
674 *os << fDetectorIndex << " ";
675 for(i=0;i<3;i++) *os << fid[i] << " ";
676 // for(i=0;i<3;i++) *os << frot[i] << " "; // Redundant with fm[][].
677 for(i=0;i<3;i++) *os << setprecision(16) << ftran[i] << " ";
678 for(i=0;i<3;i++)for(j=0;j<3;j++) *os << setprecision(16) <<
681 os->flags(fmt); // reset back to old formating.
684 //----------------------------------------------------------------------
685 void AliITSgeomMatrix::Read(istream *is){
686 ////////////////////////////////////////////////////////////////////////
687 // Standard input format for this class.
688 ////////////////////////////////////////////////////////////////////////
691 *is >> fDetectorIndex;
692 for(i=0;i<3;i++) *is >> fid[i];
693 // for(i=0;i<3;i++) *is >> frot[i]; // Redundant with fm[][].
694 for(i=0;i<3;i++) *is >> ftran[i];
695 for(i=0;i<3;i++)for(j=0;j<3;j++) *is >> fm[i][j];
696 AngleFromMatrix(); // compute angles frot[].
697 fCylR = TMath::Sqrt(ftran[0]*ftran[0]+ftran[1]*ftran[1]);
698 fCylPhi = TMath::ATan2(ftran[1],ftran[0]);
699 if(fCylPhi<0.0) fCylPhi += TMath::Pi();
702 //______________________________________________________________________
703 void AliITSgeomMatrix::Streamer(TBuffer &R__b){
704 // Stream an object of class AliITSgeomMatrix.
706 if (R__b.IsReading()) {
707 AliITSgeomMatrix::Class()->ReadBuffer(R__b, this);
708 fCylR = TMath::Sqrt(ftran[0]*ftran[0]+ftran[1]*ftran[1]);
709 fCylPhi = TMath::ATan2(ftran[1],ftran[0]);
710 this->AngleFromMatrix();
711 if(fCylPhi<0.0) fCylPhi += TMath::Pi();
713 AliITSgeomMatrix::Class()->WriteBuffer(R__b, this);
716 //----------------------------------------------------------------------
717 ostream &operator<<(ostream &os,AliITSgeomMatrix &p){
718 ////////////////////////////////////////////////////////////////////////
719 // Standard output streaming function.
720 ////////////////////////////////////////////////////////////////////////
725 //----------------------------------------------------------------------
726 istream &operator>>(istream &is,AliITSgeomMatrix &r){
727 ////////////////////////////////////////////////////////////////////////
728 // Standard input streaming function.
729 ////////////////////////////////////////////////////////////////////////
734 //----------------------------------------------------------------------