]> git.uio.no Git - u/mrichter/AliRoot.git/blame - ITS/AliITSgeomMatrix.cxx
In Streamer: TIter() after R__b << fEntries (Dmitri Yurevitch Peressounko)
[u/mrichter/AliRoot.git] / ITS / AliITSgeomMatrix.cxx
CommitLineData
df5240ea 1/**************************************************************************
2 * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
3 * *
4 * Author: The ALICE Off-line Project. *
5 * Contributors are mentioned in the code where appropriate. *
6 * *
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 **************************************************************************/
15
16/*
17$Log$
d962cab4 18Revision 1.2 2000/08/29 20:16:50 nilsen
19New class for ITS coordiante transformations used by AliITSgeom nearly
20exclusively.
21
df5240ea 22Revision 1.1.2.1 2000/06/04 16:32:31 Nilsen
23A new class to hold the matrix information needed by AliITSgeom.
24
25*/
26#include <iostream.h>
27#include <TMath.h>
28#include <TBuffer.h>
29
30#include "AliITSgeomMatrix.h"
31
32ClassImp(AliITSgeomMatrix)
33//----------------------------------------------------------------------
34AliITSgeomMatrix::AliITSgeomMatrix(){
35////////////////////////////////////////////////////////////////////////
36// The Default constructor for the AliITSgeomMatrix class. By Default
37// the angles of rotations are set to zero, meaning that the rotation
38// matrix is the unit matrix. The translation vector is also set to zero
39// as are the module id number. The detector type is set to -1 (an undefined
40// value). The full rotation matrix is kept so that the evaluation
41// of a coordinate transformation can be done quickly and with a minimum
42// of CPU overhead. The basic coordinate systems are the ALICE global
43// coordinate system and the detector local coordinate system. In general
44// this structure is not limited to just those two coordinate systems.
45//Begin_Html
46/*
47<img src="picts/ITS/AliISgeomMatrix_L1.gif">
48*/
49//End_Html
50////////////////////////////////////////////////////////////////////////
51 Int_t i,j;
52
53 fDetectorIndex = -1; // a value never defined.
54 for(i=0;i<3;i++){
55 fid[i] = 0;
56 frot[i] = ftran[i] = 0.0;
57 for(j=0;j<3;j++) fm[i][j] = 0.0;
58 }// end for i
59 fm[0][0] = fm[1][1] = fm[2][2] = 1.0;
60}
61//----------------------------------------------------------------------
62AliITSgeomMatrix::AliITSgeomMatrix(const AliITSgeomMatrix &sourse){
63////////////////////////////////////////////////////////////////////////
64// The standard copy constructor. This make a full / proper copy of
65// this class.
66////////////////////////////////////////////////////////////////////////
67 Int_t i,j;
68
69 this->fDetectorIndex = sourse.fDetectorIndex;
70 for(i=0;i<3;i++){
71 this->fid[i] = sourse.fid[i];
72 this->frot[i] = sourse.frot[i];
73 this->ftran[i] = sourse.ftran[i];
74 for(j=0;j<3;j++) this->fm[i][j] = sourse.fm[i][j];
75 }// end for i
76}
77//----------------------------------------------------------------------
78void AliITSgeomMatrix::operator=(const AliITSgeomMatrix &sourse){
79////////////////////////////////////////////////////////////////////////
80// The standard = operator. This make a full / proper copy of
81// this class.
82////////////////////////////////////////////////////////////////////////
83 Int_t i,j;
84
85 this->fDetectorIndex = sourse.fDetectorIndex;
86 for(i=0;i<3;i++){
87 this->fid[i] = sourse.fid[i];
88 this->frot[i] = sourse.frot[i];
89 this->ftran[i] = sourse.ftran[i];
90 for(j=0;j<3;j++) this->fm[i][j] = sourse.fm[i][j];
91 }// end for i
92}
93//----------------------------------------------------------------------
94AliITSgeomMatrix::AliITSgeomMatrix(const Int_t idt,const Int_t id[3],
95 const Double_t rot[3],const Double_t tran[3]){
96////////////////////////////////////////////////////////////////////////
97// This is a constructor for the AliITSgeomMatrix class. The matrix is
98// defined by 3 standard rotation angles [radians], and the translation
99// vector tran [cm]. In addition the layer, ladder, and detector number
100// for this particular module and the type of module must be given.
101// The full rotation matrix is kept so that the evaluation
102// of a coordinate transformation can be done quickly and with a minimum
103// of CPU overhead. The basic coordinate systems are the ALICE global
104// coordinate system and the detector local coordinate system. In general
105// this structure is not limited to just those two coordinate systems.
106//Begin_Html
107/*
108<img src="picts/ITS/AliISgeomMatrix_L1.gif">
109*/
110//End_Html
111////////////////////////////////////////////////////////////////////////
112 Int_t i;
113
114 fDetectorIndex = idt; // a value never defined.
115 for(i=0;i<3;i++){
116 fid[i] = id[i];
117 frot[i] = rot[i];
118 ftran[i] = tran[i];
119 }// end for i
120 this->MatrixFromAngle();
121}
122//----------------------------------------------------------------------
123AliITSgeomMatrix::AliITSgeomMatrix(const Int_t idt, const Int_t id[3],
d962cab4 124 Double_t matrix[3][3],
df5240ea 125 const Double_t tran[3]){
126////////////////////////////////////////////////////////////////////////
127// This is a constructor for the AliITSgeomMatrix class. The rotation matrix
128// is given as one of the inputs, and the translation vector tran [cm]. In
129// addition the layer, ladder, and detector number for this particular
130// module and the type of module must be given. The full rotation matrix
131// is kept so that the evaluation of a coordinate transformation can be
132// done quickly and with a minimum of CPU overhead. The basic coordinate
133// systems are the ALICE global coordinate system and the detector local
134// coordinate system. In general this structure is not limited to just
135// those two coordinate systems.
136//Begin_Html
137/*
138<img src="picts/ITS/AliISgeomMatrix_L1.gif">
139*/
140//End_Html
141////////////////////////////////////////////////////////////////////////
142 Int_t i,j;
143
144 fDetectorIndex = idt; // a value never defined.
145 for(i=0;i<3;i++){
146 fid[i] = id[i];
147 ftran[i] = tran[i];
148 for(j=0;j<3;j++) fm[i][j] = matrix[i][j];
149 }// end for i
150 this->AngleFromMatrix();
151}
152//----------------------------------------------------------------------
153void AliITSgeomMatrix::SixAnglesFromMatrix(Double_t *ang){
154////////////////////////////////////////////////////////////////////////
155// This function returns the 6 GEANT 3.21 rotation angles [degrees] in
156// the array ang which must be at least [6] long.
157////////////////////////////////////////////////////////////////////////
158 Double_t si,c=180./TMath::Pi();
159
160 ang[1] = TMath::ATan2(fm[0][1],fm[0][0]);
161 if(TMath::Cos(ang[1])!=0.0) si = fm[0][0]/TMath::Cos(ang[1]);
162 else si = fm[0][1]/TMath::Sin(ang[1]);
163 ang[0] = TMath::ATan2(si,fm[0][2]);
164
165 ang[3] = TMath::ATan2(fm[1][1],fm[1][0]);
166 if(TMath::Cos(ang[3])!=0.0) si = fm[1][0]/TMath::Cos(ang[3]);
167 else si = fm[1][1]/TMath::Sin(ang[3]);
168 ang[4] = TMath::ATan2(si,fm[1][2]);
169
170 ang[6] = TMath::ATan2(fm[2][1],fm[2][0]);
171 if(TMath::Cos(ang[6])!=0.0) si = fm[2][0]/TMath::Cos(ang[6]);
172 else si = fm[2][1]/TMath::Sin(ang[6]);
173 ang[5] = TMath::ATan2(si,fm[2][2]);
174
175 for(Int_t i=0;i<6;i++) {ang[i] *= c; if(ang[i]<0.0) ang[i] += 360.;}
176}
177//----------------------------------------------------------------------
178void AliITSgeomMatrix::MatrixFromSixAngles(const Double_t *ang){
179////////////////////////////////////////////////////////////////////////
180// Given the 6 GEANT 3.21 rotation angles [degree], this will compute and
181// set the rotations matrix and 3 standard rotation angles [radians].
182// These angles and rotation matrix are overwrite the existing values in
183// this class.
184////////////////////////////////////////////////////////////////////////
185 Int_t i,j;
186 Double_t si,lr[9],c=TMath::Pi()/180.;
187
188 si = TMath::Sin(c*ang[0]);
189 if(ang[0]== 90.0) si = +1.0;
190 if(ang[0]==270.0) si = -1.0;
191 if(ang[0]== 0.0||ang[0]==180.) si = 0.0;
192 lr[0] = si * TMath::Cos(c*ang[1]);
193 lr[1] = si * TMath::Sin(c*ang[1]);
194 lr[2] = TMath::Cos(c*ang[0]);
195 if(ang[0]== 90.0||ang[0]==270.) lr[2] = 0.0;
196 if(ang[0]== 0.0) lr[2] = +1.0;
197 if(ang[0]==180.0) lr[2] = -1.0;
198//
199 si = TMath::Sin(c*ang[2]);
200 if(ang[2]== 90.0) si = +1.0;
201 if(ang[2]==270.0) si = -1.0;
202 if(ang[2]== 0.0||ang[2]==180.) si = 0.0;
203 lr[3] = si * TMath::Cos(c*ang[3]);
204 lr[4] = si * TMath::Sin(c*ang[3]);
205 lr[5] = TMath::Cos(c*ang[2]);
206 if(ang[2]== 90.0||ang[2]==270.) lr[5] = 0.0;
207 if(ang[2]== 0.0) lr[5] = +1.0;
208 if(ang[2]==180.0) lr[5] = -1.0;
209//
210 si = TMath::Sin(c*ang[4]);
211 if(ang[4]== 90.0) si = +1.0;
212 if(ang[4]==270.0) si = -1.0;
213 if(ang[4]== 0.0||ang[4]==180.) si = 0.0;
214 lr[6] = si * TMath::Cos(c*ang[5]);
215 lr[7] = si * TMath::Sin(c*ang[5]);
216 lr[8] = TMath::Cos(c*ang[4]);
217 if(ang[4]== 90.0||ang[4]==270.0) lr[8] = 0.0;
218 if(ang[4]== 0.0) lr[8] = +1.0;
219 if(ang[4]==180.0) lr[8] = -1.0;
220 // Normalize these elements and fill matrix fm.
221 for(i=0;i<3;i++){// reuse si.
222 si = 0.0;
223 for(j=0;j<3;j++) si += lr[3*i+j]*lr[3*i+j];
224 si = TMath::Sqrt(1./si);
225 for(j=0;j<3;j++) fm[i][j] = si*lr[3*i+j];
226 } // end for i
227 this->AngleFromMatrix();
228}
229//----------------------------------------------------------------------
230AliITSgeomMatrix::AliITSgeomMatrix(const Double_t rotd[6]/*degrees*/,
231 const Int_t idt,const Int_t id[3],
232 const Double_t tran[3]){
233////////////////////////////////////////////////////////////////////////
234// This is a constructor for the AliITSgeomMatrix class. The matrix is
235// defined by the 6 GEANT 3.21 rotation angles [degrees], and the translation
236// vector tran [cm]. In addition the layer, ladder, and detector number
237// for this particular module and the type of module must be given.
238// The full rotation matrix is kept so that the evaluation
239// of a coordinate transformation can be done quickly and with a minimum
240// of CPU overhead. The basic coordinate systems are the ALICE global
241// coordinate system and the detector local coordinate system. In general
242// this structure is not limited to just those two coordinate systems.
243//Begin_Html
244/*
245<img src="picts/ITS/AliISgeomMatrix_L1.gif">
246*/
247//End_Html
248////////////////////////////////////////////////////////////////////////
249 Int_t i;
250
251 fDetectorIndex = idt; // a value never defined.
252 for(i=0;i<3;i++){
253 fid[i] = id[i];
254 ftran[i] = tran[i];
255 }// end for i
256 this->MatrixFromSixAngles(rotd);
257}
258//----------------------------------------------------------------------
259void AliITSgeomMatrix::AngleFromMatrix(){
260////////////////////////////////////////////////////////////////////////
261// Computes the angles from the rotation matrix up to a phase of 180 degrees.
262////////////////////////////////////////////////////////////////////////
263 Double_t rx,ry,rz;
264 // get angles from matrix up to a phase of 180 degrees.
265
266 rx = TMath::ATan2(fm[2][1],fm[2][2]);if(rx<0.0) rx += 2.0*TMath::Pi();
267 ry = TMath::ASin(fm[0][2]); if(ry<0.0) ry += 2.0*TMath::Pi();
268 rz = TMath::ATan2(fm[1][1],fm[0][0]);if(rz<0.0) rz += 2.0*TMath::Pi();
269 frot[0] = rx;
270 frot[1] = ry;
271 frot[2] = rz;
272 return;
273}
274//----------------------------------------------------------------------
275void AliITSgeomMatrix::MatrixFromAngle(){
276////////////////////////////////////////////////////////////////////////
277// Computes the Rotation matrix from the angles [radians] kept in this
278// class.
279////////////////////////////////////////////////////////////////////////
280 Double_t sx,sy,sz,cx,cy,cz;
281
282 sx = TMath::Sin(frot[0]); cx = TMath::Cos(frot[0]);
283 sy = TMath::Sin(frot[1]); cy = TMath::Cos(frot[1]);
284 sz = TMath::Sin(frot[2]); cz = TMath::Cos(frot[2]);
285 fm[0][0] = cz*cy; // fr[0]
286 fm[0][1] = -cz*sy*sx - sz*cx; // fr[1]
287 fm[0][2] = -cz*sy*cx + sz*sx; // fr[2]
288 fm[1][0] = sz*cy; // fr[3]
289 fm[1][1] = -sz*sy*sx + cz*cx; // fr[4]
290 fm[1][2] = -sz*sy*cx - cz*sx; // fr[5]
291 fm[2][0] = sy; // fr[6]
292 fm[2][1] = cy*sx; // fr[7]
293 fm[2][2] = cy*cx; // fr[8]
294
295}
296//----------------------------------------------------------------------
297void AliITSgeomMatrix::GtoLPosition(const Double_t g0[3],Double_t l[3]){
298////////////////////////////////////////////////////////////////////////
299// Returns the local coordinates given the global coordinates [cm].
300////////////////////////////////////////////////////////////////////////
301 Int_t i,j;
302 Double_t g[3];
303
304 for(i=0;i<3;i++) g[i] = g0[i] - ftran[i];
305 for(i=0;i<3;i++){
306 l[i] = 0.0;
307 for(j=0;j<3;j++) l[i] += fm[i][j]*g[j];
308 // g = R l + translation
309 } // end for i
310 return;
311}
312//----------------------------------------------------------------------
313void AliITSgeomMatrix::LtoGPosition(const Double_t l[3],Double_t g[3]){
314////////////////////////////////////////////////////////////////////////
315// Returns the global coordinates given the local coordinates [cm].
316////////////////////////////////////////////////////////////////////////
317 Int_t i,j;
318
319 for(i=0;i<3;i++){
320 g[i] = 0.0;
321 for(j=0;j<3;j++) g[i] += fm[j][i]*l[j];
322 g[i] += ftran[i];
323 // g = R^t l + translation
324 } // end for i
325 return;
326}
327//----------------------------------------------------------------------
328void AliITSgeomMatrix::GtoLMomentum(const Double_t g[3],Double_t l[3]){
329////////////////////////////////////////////////////////////////////////
330// Returns the local coordinates of the momentum given the global
331// coordinates of the momentum. It transforms just like GtoLPosition
332// except that the translation vector is zero.
333////////////////////////////////////////////////////////////////////////
334 Int_t i,j;
335
336 for(i=0;i<3;i++){
337 l[i] = 0.0;
338 for(j=0;j<3;j++) l[i] += fm[i][j]*g[j];
339 // g = R l
340 } // end for i
341 return;
342}
343//----------------------------------------------------------------------
344void AliITSgeomMatrix::LtoGMomentum(const Double_t l[3],Double_t g[3]){
345////////////////////////////////////////////////////////////////////////
346// Returns the Global coordinates of the momentum given the local
347// coordinates of the momentum. It transforms just like LtoGPosition
348// except that the translation vector is zero.
349////////////////////////////////////////////////////////////////////////
350 Int_t i,j;
351
352 for(i=0;i<3;i++){
353 g[i] = 0.0;
354 for(j=0;j<3;j++) g[i] += fm[j][i]*l[j];
355 // g = R^t l
356 } // end for i
357 return;
358}
359//----------------------------------------------------------------------
d962cab4 360void AliITSgeomMatrix::GtoLPositionError(Double_t g[3][3],
df5240ea 361 Double_t l[3][3]){
362////////////////////////////////////////////////////////////////////////
363// Given an Uncertainty matrix in Global coordinates it is rotated so that
364// its representation in local coordinates can be returned. There is no
365// effect due to the translation vector or its uncertainty.
366////////////////////////////////////////////////////////////////////////
367 Int_t i,j,k,m;
368
369 for(i=0;i<3;i++)for(j=0;j<3;j++)for(k=0;k<3;k++)for(m=0;m<3;m++)
370 l[i][m] = fm[j][i]*g[j][k]*fm[k][m];
371 // g = R^t l R
372 return;
373}
374//----------------------------------------------------------------------
d962cab4 375void AliITSgeomMatrix::LtoGPositionError(Double_t l[3][3],
df5240ea 376 Double_t g[3][3]){
377////////////////////////////////////////////////////////////////////////
378// Given an Uncertainty matrix in Local coordinates it is rotated so that
379// its representation in global coordinates can be returned. There is no
380// effect due to the translation vector or its uncertainty.
381////////////////////////////////////////////////////////////////////////
382 Int_t i,j,k,m;
383
384 for(i=0;i<3;i++)for(j=0;j<3;j++)for(k=0;k<3;k++)for(m=0;m<3;m++)
385 g[i][m] = fm[i][j]*l[j][k]*fm[m][k];
386 // g = R l R^t
387 return;
388}
389//----------------------------------------------------------------------
390void AliITSgeomMatrix::GtoLPositionTracking(const Double_t g0[3],
391 Double_t l[3]){
392////////////////////////////////////////////////////////////////////////
393// A slightly different coordinate system is used when tracking.
394// This coordinate system is only relevant when the geometry represents
395// the cylindrical ALICE ITS geometry. For tracking the Z axis is left
396// alone but X -> -Y and Y -> X such that X always points out of the
397// ITS Cylinder for every layer including layer 1 (where the detector
398// are mounted upside down).
399//Begin_Html
400/*
401<img src="picts/ITS/AliITSgeomMatrix_T1.gif">
402 */
403//End_Html
404////////////////////////////////////////////////////////////////////////
405 Double_t l0[3];
406
407 this->GtoLPosition(g0,l0);
408 if(fid[0]==1){ // for layer 1 the detector are flipped upside down
409 // with respect to the others.
410 l[0] = +l0[1];
411 l[1] = -l0[0];
412 l[2] = +l0[2];
413 }else{
414 l[0] = -l0[1];
415 l[1] = +l0[0];
416 l[2] = +l0[2];
417 } // end if
418 return;
419}
420//----------------------------------------------------------------------
421void AliITSgeomMatrix::LtoGPositionTracking(const Double_t l[3],
422 Double_t g[3]){
423////////////////////////////////////////////////////////////////////////
424// A slightly different coordinate system is used when tracking.
425// This coordinate system is only relevant when the geometry represents
426// the cylindrical ALICE ITS geometry. For tracking the Z axis is left
427// alone but X -> -Y and Y -> X such that X always points out of the
428// ITS Cylinder for every layer including layer 1 (where the detector
429// are mounted upside down).
430//Begin_Html
431/*
432<img src="picts/ITS/AliITSgeomMatrix_T1.gif">
433 */
434//End_Html
435////////////////////////////////////////////////////////////////////////
436 Double_t l0[3];
437
438 if(fid[0]==1){ // for layer 1 the detector are flipped upside down
439 // with respect to the others.
440 l0[0] = -l[1];
441 l0[1] = +l[0];
442 l0[2] = +l[2];
443 }else{
444 l0[0] = +l[1];
445 l0[1] = -l[0];
446 l0[2] = +l[2];
447 } // end if
448 this->LtoGPosition(l0,g);
449 return;
450}
451//----------------------------------------------------------------------
452void AliITSgeomMatrix::GtoLMomentumTracking(const Double_t g[3],
453 Double_t l[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).
461//Begin_Html
462/*
463<img src="picts/ITS/AliITSgeomMatrix_T1.gif">
464 */
465//End_Html
466////////////////////////////////////////////////////////////////////////
467 Double_t l0[3];
468
469 this->GtoLMomentum(g,l0);
470 if(fid[0]==1){ // for layer 1 the detector are flipped upside down
471 // with respect to the others.
472 l[0] = +l0[1];
473 l[1] = -l0[0];
474 l[2] = +l0[2];
475 }else{
476 l[0] = -l0[1];
477 l[1] = +l0[0];
478 l[2] = +l0[2];
479 } // end if
480 return;
481 return;
482}
483//----------------------------------------------------------------------
484void AliITSgeomMatrix::LtoGMomentumTracking(const Double_t l[3],
485 Double_t g[3]){
486////////////////////////////////////////////////////////////////////////
487// A slightly different coordinate system is used when tracking.
488// This coordinate system is only relevant when the geometry represents
489// the cylindrical ALICE ITS geometry. For tracking the Z axis is left
490// alone but X -> -Y and Y -> X such that X always points out of the
491// ITS Cylinder for every layer including layer 1 (where the detector
492// are mounted upside down).
493//Begin_Html
494/*
495<img src="picts/ITS/AliITSgeomMatrix_T1.gif">
496 */
497//End_Html
498////////////////////////////////////////////////////////////////////////
499 Double_t l0[3];
500
501 if(fid[0]==1){ // for layer 1 the detector are flipped upside down
502 // with respect to the others.
503 l0[0] = -l[1];
504 l0[1] = +l[0];
505 l0[2] = +l[2];
506 }else{
507 l0[0] = +l[1];
508 l0[1] = -l[0];
509 l0[2] = +l[2];
510 } // end if
511 this->LtoGMomentum(l0,g);
512 return;
513}
514//----------------------------------------------------------------------
d962cab4 515void AliITSgeomMatrix::GtoLPositionErrorTracking(Double_t g[3][3],
df5240ea 516 Double_t l[3][3]){
517////////////////////////////////////////////////////////////////////////
518// A slightly different coordinate system is used when tracking.
519// This coordinate system is only relevant when the geometry represents
520// the cylindrical ALICE ITS geometry. For tracking the Z axis is left
521// alone but X -> -Y and Y -> X such that X always points out of the
522// ITS Cylinder for every layer including layer 1 (where the detector
523// are mounted upside down).
524//Begin_Html
525/*
526<img src="picts/ITS/AliITSgeomMatrix_T1.gif">
527 */
528//End_Html
529////////////////////////////////////////////////////////////////////////
530 Int_t i,j,k,m;
531 Double_t Rt[3][3];
532 Double_t A0[3][3] = {{0.,+1.,0.},{-1.,0.,0.},{0.,0.,+1.}};
533 Double_t A1[3][3] = {{0.,-1.,0.},{+1.,0.,0.},{0.,0.,+1.}};
534
535 if(fid[0]==1) for(i=0;i<3;i++)for(j=0;j<3;j++)for(k=0;k<3;k++)
536 Rt[i][k] = A0[i][j]*fm[j][k];
537 else for(i=0;i<3;i++)for(j=0;j<3;j++)for(k=0;k<3;k++)
538 Rt[i][k] = A1[i][j]*fm[j][k];
539 for(i=0;i<3;i++)for(j=0;j<3;j++)for(k=0;k<3;k++)for(m=0;m<3;m++)
540 l[i][m] = Rt[j][i]*g[j][k]*Rt[k][m];
541 // g = R^t l R
542 return;
543}
544//----------------------------------------------------------------------
d962cab4 545void AliITSgeomMatrix::LtoGPositionErrorTracking(Double_t l[3][3],
df5240ea 546 Double_t g[3][3]){
547////////////////////////////////////////////////////////////////////////
548// A slightly different coordinate system is used when tracking.
549// This coordinate system is only relevant when the geometry represents
550// the cylindrical ALICE ITS geometry. For tracking the Z axis is left
551// alone but X -> -Y and Y -> X such that X always points out of the
552// ITS Cylinder for every layer including layer 1 (where the detector
553// are mounted upside down).
554//Begin_Html
555/*
556<img src="picts/ITS/AliITSgeomMatrix_T1.gif">
557 */
558//End_Html
559////////////////////////////////////////////////////////////////////////
560 Int_t i,j,k,m;
561 Double_t Rt[3][3];
562 Double_t A0[3][3] = {{0.,+1.,0.},{-1.,0.,0.},{0.,0.,+1.}};
563 Double_t A1[3][3] = {{0.,-1.,0.},{+1.,0.,0.},{0.,0.,+1.}};
564
565 if(fid[0]==1) for(i=0;i<3;i++)for(j=0;j<3;j++)for(k=0;k<3;k++)
566 Rt[i][k] = A0[i][j]*fm[j][k];
567 else for(i=0;i<3;i++)for(j=0;j<3;j++)for(k=0;k<3;k++)
568 Rt[i][k] = A1[i][j]*fm[j][k];
569 for(i=0;i<3;i++)for(j=0;j<3;j++)for(k=0;k<3;k++)for(m=0;m<3;m++)
570 g[i][m] = Rt[i][j]*l[j][k]*Rt[m][k];
571 // g = R l R^t
572 return;
573}
574//----------------------------------------------------------------------
575void AliITSgeomMatrix::PrintTitles(ostream *os){
576////////////////////////////////////////////////////////////////////////
577// Standard output format for this class but it includes variable
578// names and formatting that makes it easer to read.
579////////////////////////////////////////////////////////////////////////
580 Int_t i,j;
581
582 *os << "fDetectorIndex=" << fDetectorIndex << " fid[3]={";
583 for(i=0;i<3;i++) *os << fid[i] << " ";
584 *os << "} frot[3]={";
585 for(i=0;i<3;i++) *os << frot[i] << " ";
586 *os << "} ftran[3]={";
587 for(i=0;i<3;i++) *os << ftran[i] << " ";
588 *os << "} fm[3][3]={";
589 for(i=0;i<3;i++){for(j=0;j<3;j++){ *os << fm[i][j] << " ";} *os <<"}{";}
590 *os << "}" << endl;
591 return;
592}
593//----------------------------------------------------------------------
594void AliITSgeomMatrix::print(ostream *os){
595////////////////////////////////////////////////////////////////////////
596// Standard output format for this class.
597////////////////////////////////////////////////////////////////////////
598 Int_t i,j;
599
600 *os << fDetectorIndex << " ";
601 for(i=0;i<3;i++) *os << fid[i] << " ";
602 for(i=0;i<3;i++) *os << frot[i] << " ";
603 for(i=0;i<3;i++) *os << ftran[i] << " ";
604 for(i=0;i<3;i++)for(j=0;j<3;j++) *os << fm[i][j] << " ";
605 *os << endl;
606 return;
607}
608//----------------------------------------------------------------------
609void AliITSgeomMatrix::read(istream *is){
610////////////////////////////////////////////////////////////////////////
611// Standard input format for this class.
612////////////////////////////////////////////////////////////////////////
613 Int_t i,j;
614
615 *is >> fDetectorIndex;
616 for(i=0;i<3;i++) *is >> fid[i];
617 for(i=0;i<3;i++) *is >> frot[i];
618 for(i=0;i<3;i++) *is >> ftran[i];
619 for(i=0;i<3;i++)for(j=0;j<3;j++) *is >> fm[i][j];
620 return;
621}
622//----------------------------------------------------------------------
623ostream &operator<<(ostream &os,AliITSgeomMatrix &p){
624////////////////////////////////////////////////////////////////////////
625// Standard output streaming function.
626////////////////////////////////////////////////////////////////////////
627
628 p.print(&os);
629 return os;
630}
631//----------------------------------------------------------------------
632istream &operator>>(istream &is,AliITSgeomMatrix &r){
633////////////////////////////////////////////////////////////////////////
634// Standard input streaming function.
635////////////////////////////////////////////////////////////////////////
636
637 r.read(&is);
638 return is;
639}
640//----------------------------------------------------------------------
641void AliITSgeomMatrix::Streamer(TBuffer &R__b){
642////////////////////////////////////////////////////////////////////////
643// Stream an object of class AliITSgeomMatrix.
644////////////////////////////////////////////////////////////////////////
645
646 UInt_t R__s, R__c;
647 if (R__b.IsReading()) {
648 Version_t R__v = R__b.ReadVersion(&R__s, &R__c);
649 if (R__v==1) {
650 R__b >> fDetectorIndex;
651 R__b.ReadStaticArray(fid);
652 R__b.ReadStaticArray(frot);
653 R__b.ReadStaticArray(ftran);
654 R__b.ReadStaticArray((double*)fm);
655 R__b.CheckByteCount(R__s, R__c, AliITSgeomMatrix::IsA());
656 } // end if R__v
657 } else { // R__b.IsWriting()
658 R__c = R__b.WriteVersion(AliITSgeomMatrix::IsA(), kTRUE);
659 R__b << fDetectorIndex;
660 R__b.WriteArray(fid, 3);
661 R__b.WriteArray(frot, 3);
662 R__b.WriteArray(ftran, 3);
663 R__b.WriteArray((double*)fm, 9);
664 R__b.SetByteCount(R__c, kTRUE);
665 } // end if R__b.IsReading()||IsWriting()
666}
667//______________________________________________________________________