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.12 2001/10/12 22:07:20 nilsen
19 A patch for C++ io manipulation functions so that they will work both
20 with GNU gcc 2.96 and GNU gcc 3.01 compilers. Needs to be tested with
23 Revision 1.11 2001/09/04 14:54:31 hristov
24 Const multidimentional arrays cause problems in the CINT dictionary on HP, const removed
26 Revision 1.10 2001/08/24 21:06:37 nilsen
27 Added more documentation, fixed up some coding violations, and some
30 Revision 1.9 2001/03/23 15:21:56 nilsen
31 Added Cylinderical Coordinates for use with Tracking. Fixed a but in the
32 Streamer, It was not setting a value for frot[3] as it should when reading.
34 Revision 1.8 2001/02/09 00:00:57 nilsen
35 Fixed compatibility problem with HP unix {ios::fmtflags -> Int_t}. Fixed
36 bugs in iostream based streamers used to read and write .det files. Fixed
37 some detector sizes. Fixed bugs in some default-special constructors.
39 Revision 1.7 2001/02/03 00:00:30 nilsen
40 New version of AliITSgeom and related files. Now uses automatic streamers,
41 set up for new formatted .det file which includes detector information.
42 Additional smaller modifications are still to come.
44 Revision 1.5 2000/10/02 16:32:35 barbera
45 Forward declaration added
47 Revision 1.1.2.6 2000/10/02 15:52:05 barbera
48 Forward declaration added
50 Revision 1.4 2000/09/07 17:30:45 nilsen
51 fixed a bug in SixAnglesFromMatrix.
53 Revision 1.3 2000/09/05 14:25:50 nilsen
54 Made fixes for HP compiler. All function parameter default values placed
55 in .h file. Fixed the usual problem with HP comilers and the "for(Int_t i..."
56 business. Replaced casting (Double_t [3][3]) to (Double_t (*)[3]) for HP.
57 Lastly removed all "const" before function parameters which were 2 dim. arrays,
58 because on HP root generates some strange code (?). Thanks Peter for the
61 Revision 1.2 2000/08/29 20:16:50 nilsen
62 New class for ITS coordiante transformations used by AliITSgeom nearly
65 Revision 1.1.2.1 2000/06/04 16:32:31 Nilsen
66 A new class to hold the matrix information needed by AliITSgeom.
70 ////////////////////////////////////////////////////////////////////////
71 // This is the implementation file for AliITSgeomMatrix class. It
72 // contains the routines to manipulate, setup, and queary the geometry
73 // of a given ITS module. An ITS module may be one of at least three
74 // ITS detector technologies, Silicon Pixel, Drift, or Strip Detectors,
75 // and variations of these in size and/or layout. These routines let
76 // one go between ALICE global coordiantes (cm) to a given modules
77 // specific local coordinates (cm).
78 ////////////////////////////////////////////////////////////////////////
86 #include "AliITSgeomMatrix.h"
88 ClassImp(AliITSgeomMatrix)
89 //----------------------------------------------------------------------
90 AliITSgeomMatrix::AliITSgeomMatrix(){
91 ////////////////////////////////////////////////////////////////////////
92 // The Default constructor for the AliITSgeomMatrix class. By Default
93 // the angles of rotations are set to zero, meaning that the rotation
94 // matrix is the unit matrix. The translation vector is also set to zero
95 // as are the module id number. The detector type is set to -1 (an undefined
96 // value). The full rotation matrix is kept so that the evaluation
97 // of a coordinate transformation can be done quickly and with a minimum
98 // of CPU overhead. The basic coordinate systems are the ALICE global
99 // coordinate system and the detector local coordinate system. In general
100 // this structure is not limited to just those two coordinate systems.
103 <img src="picts/ITS/AliISgeomMatrix_L1.gif">
106 ////////////////////////////////////////////////////////////////////////
109 fDetectorIndex = -1; // a value never defined.
112 frot[i] = ftran[i] = 0.0;
113 for(j=0;j<3;j++) fm[i][j] = 0.0;
114 fCylR = fCylPhi = 0.0;
116 fm[0][0] = fm[1][1] = fm[2][2] = 1.0;
118 //----------------------------------------------------------------------
119 AliITSgeomMatrix::AliITSgeomMatrix(const AliITSgeomMatrix &sourse){
120 ////////////////////////////////////////////////////////////////////////
121 // The standard copy constructor. This make a full / proper copy of
123 ////////////////////////////////////////////////////////////////////////
126 this->fDetectorIndex = sourse.fDetectorIndex;
128 this->fid[i] = sourse.fid[i];
129 this->frot[i] = sourse.frot[i];
130 this->ftran[i] = sourse.ftran[i];
131 this->fCylR = sourse.fCylR;
132 this->fCylPhi = sourse.fCylPhi;
133 for(j=0;j<3;j++) this->fm[i][j] = sourse.fm[i][j];
136 //----------------------------------------------------------------------
137 void AliITSgeomMatrix::operator=(const AliITSgeomMatrix &sourse){
138 ////////////////////////////////////////////////////////////////////////
139 // The standard = operator. This make a full / proper copy of
141 ////////////////////////////////////////////////////////////////////////
144 this->fDetectorIndex = sourse.fDetectorIndex;
146 this->fid[i] = sourse.fid[i];
147 this->frot[i] = sourse.frot[i];
148 this->ftran[i] = sourse.ftran[i];
149 this->fCylR = sourse.fCylR;
150 this->fCylPhi = sourse.fCylPhi;
151 for(j=0;j<3;j++) this->fm[i][j] = sourse.fm[i][j];
154 //----------------------------------------------------------------------
155 AliITSgeomMatrix::AliITSgeomMatrix(const Int_t idt,const Int_t id[3],
156 const Double_t rot[3],const Double_t tran[3]){
157 ////////////////////////////////////////////////////////////////////////
158 // This is a constructor for the AliITSgeomMatrix class. The matrix is
159 // defined by 3 standard rotation angles [radians], and the translation
160 // vector tran [cm]. In addition the layer, ladder, and detector number
161 // for this particular module and the type of module must be given.
162 // The full rotation matrix is kept so that the evaluation
163 // of a coordinate transformation can be done quickly and with a minimum
164 // of CPU overhead. The basic coordinate systems are the ALICE global
165 // coordinate system and the detector local coordinate system. In general
166 // this structure is not limited to just those two coordinate systems.
169 <img src="picts/ITS/AliISgeomMatrix_L1.gif">
172 ////////////////////////////////////////////////////////////////////////
175 fDetectorIndex = idt; // a value never defined.
181 fCylR = TMath::Sqrt(ftran[0]*ftran[0]+ftran[1]*ftran[1]);
182 fCylPhi = TMath::ATan2(ftran[1],ftran[0]);
183 if(fCylPhi<0.0) fCylPhi += TMath::Pi();
184 this->MatrixFromAngle();
186 //----------------------------------------------------------------------
187 AliITSgeomMatrix::AliITSgeomMatrix(const Int_t idt, const Int_t id[3],
188 Double_t matrix[3][3],
189 const Double_t tran[3]){
190 ////////////////////////////////////////////////////////////////////////
191 // This is a constructor for the AliITSgeomMatrix class. The rotation matrix
192 // is given as one of the inputs, and the translation vector tran [cm]. In
193 // addition the layer, ladder, and detector number for this particular
194 // module and the type of module must be given. The full rotation matrix
195 // is kept so that the evaluation of a coordinate transformation can be
196 // done quickly and with a minimum of CPU overhead. The basic coordinate
197 // systems are the ALICE global coordinate system and the detector local
198 // coordinate system. In general this structure is not limited to just
199 // those two coordinate systems.
202 <img src="picts/ITS/AliISgeomMatrix_L1.gif">
205 ////////////////////////////////////////////////////////////////////////
208 fDetectorIndex = idt; // a value never defined.
212 for(j=0;j<3;j++) fm[i][j] = matrix[i][j];
214 fCylR = TMath::Sqrt(ftran[0]*ftran[0]+ftran[1]*ftran[1]);
215 fCylPhi = TMath::ATan2(ftran[1],ftran[0]);
216 if(fCylPhi<0.0) fCylPhi += TMath::Pi();
217 this->AngleFromMatrix();
219 //----------------------------------------------------------------------
220 void AliITSgeomMatrix::SixAnglesFromMatrix(Double_t *ang){
221 ////////////////////////////////////////////////////////////////////////
222 // This function returns the 6 GEANT 3.21 rotation angles [degrees] in
223 // the array ang which must be at least [6] long.
224 ////////////////////////////////////////////////////////////////////////
225 Double_t si,c=180./TMath::Pi();
227 ang[1] = TMath::ATan2(fm[0][1],fm[0][0]);
228 if(TMath::Cos(ang[1])!=0.0) si = fm[0][0]/TMath::Cos(ang[1]);
229 else si = fm[0][1]/TMath::Sin(ang[1]);
230 ang[0] = TMath::ATan2(si,fm[0][2]);
232 ang[3] = TMath::ATan2(fm[1][1],fm[1][0]);
233 if(TMath::Cos(ang[3])!=0.0) si = fm[1][0]/TMath::Cos(ang[3]);
234 else si = fm[1][1]/TMath::Sin(ang[3]);
235 ang[2] = TMath::ATan2(si,fm[1][2]);
237 ang[5] = TMath::ATan2(fm[2][1],fm[2][0]);
238 if(TMath::Cos(ang[5])!=0.0) si = fm[2][0]/TMath::Cos(ang[5]);
239 else si = fm[2][1]/TMath::Sin(ang[5]);
240 ang[4] = TMath::ATan2(si,fm[2][2]);
242 for(Int_t i=0;i<6;i++) {ang[i] *= c; if(ang[i]<0.0) ang[i] += 360.;}
244 //----------------------------------------------------------------------
245 void AliITSgeomMatrix::MatrixFromSixAngles(const Double_t *ang){
246 ////////////////////////////////////////////////////////////////////////
247 // Given the 6 GEANT 3.21 rotation angles [degree], this will compute and
248 // set the rotations matrix and 3 standard rotation angles [radians].
249 // These angles and rotation matrix are overwrite the existing values in
251 ////////////////////////////////////////////////////////////////////////
253 Double_t si,lr[9],c=TMath::Pi()/180.;
255 si = TMath::Sin(c*ang[0]);
256 if(ang[0]== 90.0) si = +1.0;
257 if(ang[0]==270.0) si = -1.0;
258 if(ang[0]== 0.0||ang[0]==180.) si = 0.0;
259 lr[0] = si * TMath::Cos(c*ang[1]);
260 lr[1] = si * TMath::Sin(c*ang[1]);
261 lr[2] = TMath::Cos(c*ang[0]);
262 if(ang[0]== 90.0||ang[0]==270.) lr[2] = 0.0;
263 if(ang[0]== 0.0) lr[2] = +1.0;
264 if(ang[0]==180.0) lr[2] = -1.0;
266 si = TMath::Sin(c*ang[2]);
267 if(ang[2]== 90.0) si = +1.0;
268 if(ang[2]==270.0) si = -1.0;
269 if(ang[2]== 0.0||ang[2]==180.) si = 0.0;
270 lr[3] = si * TMath::Cos(c*ang[3]);
271 lr[4] = si * TMath::Sin(c*ang[3]);
272 lr[5] = TMath::Cos(c*ang[2]);
273 if(ang[2]== 90.0||ang[2]==270.) lr[5] = 0.0;
274 if(ang[2]== 0.0) lr[5] = +1.0;
275 if(ang[2]==180.0) lr[5] = -1.0;
277 si = TMath::Sin(c*ang[4]);
278 if(ang[4]== 90.0) si = +1.0;
279 if(ang[4]==270.0) si = -1.0;
280 if(ang[4]== 0.0||ang[4]==180.) si = 0.0;
281 lr[6] = si * TMath::Cos(c*ang[5]);
282 lr[7] = si * TMath::Sin(c*ang[5]);
283 lr[8] = TMath::Cos(c*ang[4]);
284 if(ang[4]== 90.0||ang[4]==270.0) lr[8] = 0.0;
285 if(ang[4]== 0.0) lr[8] = +1.0;
286 if(ang[4]==180.0) lr[8] = -1.0;
287 // Normalize these elements and fill matrix fm.
288 for(i=0;i<3;i++){// reuse si.
290 for(j=0;j<3;j++) si += lr[3*i+j]*lr[3*i+j];
291 si = TMath::Sqrt(1./si);
292 for(j=0;j<3;j++) fm[i][j] = si*lr[3*i+j];
294 this->AngleFromMatrix();
296 //----------------------------------------------------------------------
297 AliITSgeomMatrix::AliITSgeomMatrix(const Double_t rotd[6]/*degrees*/,
298 const Int_t idt,const Int_t id[3],
299 const Double_t tran[3]){
300 ////////////////////////////////////////////////////////////////////////
301 // This is a constructor for the AliITSgeomMatrix class. The matrix is
302 // defined by the 6 GEANT 3.21 rotation angles [degrees], and the translation
303 // vector tran [cm]. In addition the layer, ladder, and detector number
304 // for this particular module and the type of module must be given.
305 // The full rotation matrix is kept so that the evaluation
306 // of a coordinate transformation can be done quickly and with a minimum
307 // of CPU overhead. The basic coordinate systems are the ALICE global
308 // coordinate system and the detector local coordinate system. In general
309 // this structure is not limited to just those two coordinate systems.
312 <img src="picts/ITS/AliISgeomMatrix_L1.gif">
315 ////////////////////////////////////////////////////////////////////////
318 fDetectorIndex = idt; // a value never defined.
323 fCylR = TMath::Sqrt(ftran[0]*ftran[0]+ftran[1]*ftran[1]);
324 fCylPhi = TMath::ATan2(ftran[1],ftran[0]);
325 if(fCylPhi<0.0) fCylPhi += TMath::Pi();
326 this->MatrixFromSixAngles(rotd);
328 //----------------------------------------------------------------------
329 void AliITSgeomMatrix::AngleFromMatrix(){
330 ////////////////////////////////////////////////////////////////////////
331 // Computes the angles from the rotation matrix up to a phase of 180 degrees.
332 ////////////////////////////////////////////////////////////////////////
334 // get angles from matrix up to a phase of 180 degrees.
336 rx = TMath::ATan2(fm[2][1],fm[2][2]);if(rx<0.0) rx += 2.0*TMath::Pi();
337 ry = TMath::ASin(fm[0][2]); if(ry<0.0) ry += 2.0*TMath::Pi();
338 rz = TMath::ATan2(fm[1][1],fm[0][0]);if(rz<0.0) rz += 2.0*TMath::Pi();
344 //----------------------------------------------------------------------
345 void AliITSgeomMatrix::MatrixFromAngle(){
346 ////////////////////////////////////////////////////////////////////////
347 // Computes the Rotation matrix from the angles [radians] kept in this
349 ////////////////////////////////////////////////////////////////////////
350 Double_t sx,sy,sz,cx,cy,cz;
352 sx = TMath::Sin(frot[0]); cx = TMath::Cos(frot[0]);
353 sy = TMath::Sin(frot[1]); cy = TMath::Cos(frot[1]);
354 sz = TMath::Sin(frot[2]); cz = TMath::Cos(frot[2]);
355 fm[0][0] = cz*cy; // fr[0]
356 fm[0][1] = -cz*sy*sx - sz*cx; // fr[1]
357 fm[0][2] = -cz*sy*cx + sz*sx; // fr[2]
358 fm[1][0] = sz*cy; // fr[3]
359 fm[1][1] = -sz*sy*sx + cz*cx; // fr[4]
360 fm[1][2] = -sz*sy*cx - cz*sx; // fr[5]
361 fm[2][0] = sy; // fr[6]
362 fm[2][1] = cy*sx; // fr[7]
363 fm[2][2] = cy*cx; // fr[8]
366 //----------------------------------------------------------------------
367 void AliITSgeomMatrix::GtoLPosition(const Double_t g0[3],Double_t l[3]){
368 ////////////////////////////////////////////////////////////////////////
369 // Returns the local coordinates given the global coordinates [cm].
370 ////////////////////////////////////////////////////////////////////////
374 for(i=0;i<3;i++) g[i] = g0[i] - ftran[i];
377 for(j=0;j<3;j++) l[i] += fm[i][j]*g[j];
378 // g = R l + translation
382 //----------------------------------------------------------------------
383 void AliITSgeomMatrix::LtoGPosition(const Double_t l[3],Double_t g[3]){
384 ////////////////////////////////////////////////////////////////////////
385 // Returns the global coordinates given the local coordinates [cm].
386 ////////////////////////////////////////////////////////////////////////
391 for(j=0;j<3;j++) g[i] += fm[j][i]*l[j];
393 // g = R^t l + translation
397 //----------------------------------------------------------------------
398 void AliITSgeomMatrix::GtoLMomentum(const Double_t g[3],Double_t l[3]){
399 ////////////////////////////////////////////////////////////////////////
400 // Returns the local coordinates of the momentum given the global
401 // coordinates of the momentum. It transforms just like GtoLPosition
402 // except that the translation vector is zero.
403 ////////////////////////////////////////////////////////////////////////
408 for(j=0;j<3;j++) l[i] += fm[i][j]*g[j];
413 //----------------------------------------------------------------------
414 void AliITSgeomMatrix::LtoGMomentum(const Double_t l[3],Double_t g[3]){
415 ////////////////////////////////////////////////////////////////////////
416 // Returns the Global coordinates of the momentum given the local
417 // coordinates of the momentum. It transforms just like LtoGPosition
418 // except that the translation vector is zero.
419 ////////////////////////////////////////////////////////////////////////
424 for(j=0;j<3;j++) g[i] += fm[j][i]*l[j];
429 //----------------------------------------------------------------------
430 void AliITSgeomMatrix::GtoLPositionError( Double_t g[3][3],
432 ////////////////////////////////////////////////////////////////////////
433 // Given an Uncertainty matrix in Global coordinates it is rotated so that
434 // its representation in local coordinates can be returned. There is no
435 // effect due to the translation vector or its uncertainty.
436 ////////////////////////////////////////////////////////////////////////
439 for(i=0;i<3;i++)for(m=0;m<3;m++){
441 for(j=0;j<3;j++)for(k=0;k<3;k++)
442 l[i][m] += fm[j][i]*g[j][k]*fm[k][m];
447 //----------------------------------------------------------------------
448 void AliITSgeomMatrix::LtoGPositionError( Double_t l[3][3],
450 ////////////////////////////////////////////////////////////////////////
451 // Given an Uncertainty matrix in Local coordinates it is rotated so that
452 // its representation in global coordinates can be returned. There is no
453 // effect due to the translation vector or its uncertainty.
454 ////////////////////////////////////////////////////////////////////////
457 for(i=0;i<3;i++)for(m=0;m<3;m++){
459 for(j=0;j<3;j++)for(k=0;k<3;k++)
460 g[i][m] += fm[i][j]*l[j][k]*fm[m][k];
465 //----------------------------------------------------------------------
466 void AliITSgeomMatrix::GtoLPositionTracking(const Double_t g0[3],
468 ////////////////////////////////////////////////////////////////////////
469 // A slightly different coordinate system is used when tracking.
470 // This coordinate system is only relevant when the geometry represents
471 // the cylindrical ALICE ITS geometry. For tracking the Z axis is left
472 // alone but X -> -Y and Y -> X such that X always points out of the
473 // ITS Cylinder for every layer including layer 1 (where the detector
474 // are mounted upside down).
477 <img src="picts/ITS/AliITSgeomMatrix_T1.gif">
480 ////////////////////////////////////////////////////////////////////////
483 this->GtoLPosition(g0,l0);
484 if(fid[0]==1){ // for layer 1 the detector are flipped upside down
485 // with respect to the others.
496 //----------------------------------------------------------------------
497 void AliITSgeomMatrix::LtoGPositionTracking(const Double_t l[3],
499 ////////////////////////////////////////////////////////////////////////
500 // A slightly different coordinate system is used when tracking.
501 // This coordinate system is only relevant when the geometry represents
502 // the cylindrical ALICE ITS geometry. For tracking the Z axis is left
503 // alone but X -> -Y and Y -> X such that X always points out of the
504 // ITS Cylinder for every layer including layer 1 (where the detector
505 // are mounted upside down).
508 <img src="picts/ITS/AliITSgeomMatrix_T1.gif">
511 ////////////////////////////////////////////////////////////////////////
514 if(fid[0]==1){ // for layer 1 the detector are flipped upside down
515 // with respect to the others.
524 this->LtoGPosition(l0,g);
527 //----------------------------------------------------------------------
528 void AliITSgeomMatrix::GtoLMomentumTracking(const Double_t g[3],
530 ////////////////////////////////////////////////////////////////////////
531 // A slightly different coordinate system is used when tracking.
532 // This coordinate system is only relevant when the geometry represents
533 // the cylindrical ALICE ITS geometry. For tracking the Z axis is left
534 // alone but X -> -Y and Y -> X such that X always points out of the
535 // ITS Cylinder for every layer including layer 1 (where the detector
536 // are mounted upside down).
539 <img src="picts/ITS/AliITSgeomMatrix_T1.gif">
542 ////////////////////////////////////////////////////////////////////////
545 this->GtoLMomentum(g,l0);
546 if(fid[0]==1){ // for layer 1 the detector are flipped upside down
547 // with respect to the others.
559 //----------------------------------------------------------------------
560 void AliITSgeomMatrix::LtoGMomentumTracking(const Double_t l[3],
562 ////////////////////////////////////////////////////////////////////////
563 // A slightly different coordinate system is used when tracking.
564 // This coordinate system is only relevant when the geometry represents
565 // the cylindrical ALICE ITS geometry. For tracking the Z axis is left
566 // alone but X -> -Y and Y -> X such that X always points out of the
567 // ITS Cylinder for every layer including layer 1 (where the detector
568 // are mounted upside down).
571 <img src="picts/ITS/AliITSgeomMatrix_T1.gif">
574 ////////////////////////////////////////////////////////////////////////
577 if(fid[0]==1){ // for layer 1 the detector are flipped upside down
578 // with respect to the others.
587 this->LtoGMomentum(l0,g);
590 //----------------------------------------------------------------------
591 void AliITSgeomMatrix::GtoLPositionErrorTracking( Double_t g[3][3],
593 ////////////////////////////////////////////////////////////////////////
594 // A slightly different coordinate system is used when tracking.
595 // This coordinate system is only relevant when the geometry represents
596 // the cylindrical ALICE ITS geometry. For tracking the Z axis is left
597 // alone but X -> -Y and Y -> X such that X always points out of the
598 // ITS Cylinder for every layer including layer 1 (where the detector
599 // are mounted upside down).
602 <img src="picts/ITS/AliITSgeomMatrix_T1.gif">
605 ////////////////////////////////////////////////////////////////////////
608 Double_t a0[3][3] = {{0.,+1.,0.},{-1.,0.,0.},{0.,0.,+1.}};
609 Double_t a1[3][3] = {{0.,-1.,0.},{+1.,0.,0.},{0.,0.,+1.}};
611 if(fid[0]==1) for(i=0;i<3;i++)for(j=0;j<3;j++)for(k=0;k<3;k++)
612 rt[i][k] = a0[i][j]*fm[j][k];
613 else for(i=0;i<3;i++)for(j=0;j<3;j++)for(k=0;k<3;k++)
614 rt[i][k] = a1[i][j]*fm[j][k];
615 for(i=0;i<3;i++)for(m=0;m<3;m++){
617 for(j=0;j<3;j++)for(k=0;k<3;k++)
618 l[i][m] += rt[j][i]*g[j][k]*rt[k][m];
623 //----------------------------------------------------------------------
624 void AliITSgeomMatrix::LtoGPositionErrorTracking( Double_t l[3][3],
626 ////////////////////////////////////////////////////////////////////////
627 // A slightly different coordinate system is used when tracking.
628 // This coordinate system is only relevant when the geometry represents
629 // the cylindrical ALICE ITS geometry. For tracking the Z axis is left
630 // alone but X -> -Y and Y -> X such that X always points out of the
631 // ITS Cylinder for every layer including layer 1 (where the detector
632 // are mounted upside down).
635 <img src="picts/ITS/AliITSgeomMatrix_T1.gif">
638 ////////////////////////////////////////////////////////////////////////
641 Double_t a0[3][3] = {{0.,+1.,0.},{-1.,0.,0.},{0.,0.,+1.}};
642 Double_t a1[3][3] = {{0.,-1.,0.},{+1.,0.,0.},{0.,0.,+1.}};
644 if(fid[0]==1) for(i=0;i<3;i++)for(j=0;j<3;j++)for(k=0;k<3;k++)
645 rt[i][k] = a0[i][j]*fm[j][k];
646 else for(i=0;i<3;i++)for(j=0;j<3;j++)for(k=0;k<3;k++)
647 rt[i][k] = a1[i][j]*fm[j][k];
648 for(i=0;i<3;i++)for(m=0;m<3;m++){
650 for(j=0;j<3;j++)for(k=0;k<3;k++)
651 g[i][m] += rt[i][j]*l[j][k]*rt[m][k];
656 //----------------------------------------------------------------------
657 void AliITSgeomMatrix::PrintTitles(ostream *os){
658 ////////////////////////////////////////////////////////////////////////
659 // Standard output format for this class but it includes variable
660 // names and formatting that makes it easer to read.
661 ////////////////////////////////////////////////////////////////////////
664 *os << "fDetectorIndex=" << fDetectorIndex << " fid[3]={";
665 for(i=0;i<3;i++) *os << fid[i] << " ";
666 *os << "} frot[3]={";
667 for(i=0;i<3;i++) *os << frot[i] << " ";
668 *os << "} ftran[3]={";
669 for(i=0;i<3;i++) *os << ftran[i] << " ";
670 *os << "} fm[3][3]={";
671 for(i=0;i<3;i++){for(j=0;j<3;j++){ *os << fm[i][j] << " ";} *os <<"}{";}
675 //----------------------------------------------------------------------
676 void AliITSgeomMatrix::PrintComment(ostream *os){
677 ////////////////////////////////////////////////////////////////////////
678 // output format used by Print..
679 ////////////////////////////////////////////////////////////////////////
680 *os << "fDetectorIndex fid[0] fid[1] fid[2] ftran[0] ftran[1] ftran[2] ";
681 *os << "fm[0][0] fm[0][1] fm[0][2] fm[1][0] fm[1][1] fm[1][2] ";
682 *os << "fm[2][0] fm[2][1] fm[2][2] ";
685 //----------------------------------------------------------------------
686 void AliITSgeomMatrix::Print(ostream *os){
687 ////////////////////////////////////////////////////////////////////////
688 // Standard output format for this class.
689 ////////////////////////////////////////////////////////////////////////
701 fmt = os->setf(ios::scientific); // set scientific floating point output
702 *os << fDetectorIndex << " ";
703 for(i=0;i<3;i++) *os << fid[i] << " ";
704 // for(i=0;i<3;i++) *os << frot[i] << " "; // Redundant with fm[][].
705 for(i=0;i<3;i++) *os << setprecision(16) << ftran[i] << " ";
706 for(i=0;i<3;i++)for(j=0;j<3;j++) *os << setprecision(16) <<
709 os->flags(fmt); // reset back to old formating.
712 //----------------------------------------------------------------------
713 void AliITSgeomMatrix::Read(istream *is){
714 ////////////////////////////////////////////////////////////////////////
715 // Standard input format for this class.
716 ////////////////////////////////////////////////////////////////////////
719 *is >> fDetectorIndex;
720 for(i=0;i<3;i++) *is >> fid[i];
721 // for(i=0;i<3;i++) *is >> frot[i]; // Redundant with fm[][].
722 for(i=0;i<3;i++) *is >> ftran[i];
723 for(i=0;i<3;i++)for(j=0;j<3;j++) *is >> fm[i][j];
724 AngleFromMatrix(); // compute angles frot[].
725 fCylR = TMath::Sqrt(ftran[0]*ftran[0]+ftran[1]*ftran[1]);
726 fCylPhi = TMath::ATan2(ftran[1],ftran[0]);
727 if(fCylPhi<0.0) fCylPhi += TMath::Pi();
730 //______________________________________________________________________
731 void AliITSgeomMatrix::Streamer(TBuffer &R__b){
732 // Stream an object of class AliITSgeomMatrix.
734 if (R__b.IsReading()) {
735 AliITSgeomMatrix::Class()->ReadBuffer(R__b, this);
736 fCylR = TMath::Sqrt(ftran[0]*ftran[0]+ftran[1]*ftran[1]);
737 fCylPhi = TMath::ATan2(ftran[1],ftran[0]);
738 this->AngleFromMatrix();
739 if(fCylPhi<0.0) fCylPhi += TMath::Pi();
741 AliITSgeomMatrix::Class()->WriteBuffer(R__b, this);
744 //----------------------------------------------------------------------
745 ostream &operator<<(ostream &os,AliITSgeomMatrix &p){
746 ////////////////////////////////////////////////////////////////////////
747 // Standard output streaming function.
748 ////////////////////////////////////////////////////////////////////////
753 //----------------------------------------------------------------------
754 istream &operator>>(istream &is,AliITSgeomMatrix &r){
755 ////////////////////////////////////////////////////////////////////////
756 // Standard input streaming function.
757 ////////////////////////////////////////////////////////////////////////
762 //----------------------------------------------------------------------