]> git.uio.no Git - u/mrichter/AliRoot.git/blame_incremental - ITS/AliITSgeomMatrix.cxx
Removed because they have been replaced with AliITS... versions.
[u/mrichter/AliRoot.git] / ITS / AliITSgeomMatrix.cxx
... / ...
CommitLineData
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$
18Revision 1.10 2001/08/24 21:06:37 nilsen
19Added more documentation, fixed up some coding violations, and some
20forward declorations.
21
22Revision 1.9 2001/03/23 15:21:56 nilsen
23Added Cylinderical Coordinates for use with Tracking. Fixed a but in the
24Streamer, It was not setting a value for frot[3] as it should when reading.
25
26Revision 1.8 2001/02/09 00:00:57 nilsen
27Fixed compatibility problem with HP unix {ios::fmtflags -> Int_t}. Fixed
28bugs in iostream based streamers used to read and write .det files. Fixed
29some detector sizes. Fixed bugs in some default-special constructors.
30
31Revision 1.7 2001/02/03 00:00:30 nilsen
32New version of AliITSgeom and related files. Now uses automatic streamers,
33set up for new formatted .det file which includes detector information.
34Additional smaller modifications are still to come.
35
36Revision 1.5 2000/10/02 16:32:35 barbera
37Forward declaration added
38
39Revision 1.1.2.6 2000/10/02 15:52:05 barbera
40Forward declaration added
41
42Revision 1.4 2000/09/07 17:30:45 nilsen
43fixed a bug in SixAnglesFromMatrix.
44
45Revision 1.3 2000/09/05 14:25:50 nilsen
46Made fixes for HP compiler. All function parameter default values placed
47in .h file. Fixed the usual problem with HP comilers and the "for(Int_t i..."
48business. Replaced casting (Double_t [3][3]) to (Double_t (*)[3]) for HP.
49Lastly removed all "const" before function parameters which were 2 dim. arrays,
50because on HP root generates some strange code (?). Thanks Peter for the
51changes.
52
53Revision 1.2 2000/08/29 20:16:50 nilsen
54New class for ITS coordiante transformations used by AliITSgeom nearly
55exclusively.
56
57Revision 1.1.2.1 2000/06/04 16:32:31 Nilsen
58A new class to hold the matrix information needed by AliITSgeom.
59
60*/
61
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////////////////////////////////////////////////////////////////////////
71
72#include <iostream.h>
73#include <iomanip.h>
74#include <TMath.h>
75#include <TBuffer.h>
76#include <TClass.h>
77
78#include "AliITSgeomMatrix.h"
79
80ClassImp(AliITSgeomMatrix)
81//----------------------------------------------------------------------
82AliITSgeomMatrix::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.
93//Begin_Html
94/*
95<img src="picts/ITS/AliISgeomMatrix_L1.gif">
96*/
97//End_Html
98////////////////////////////////////////////////////////////////////////
99 Int_t i,j;
100
101 fDetectorIndex = -1; // a value never defined.
102 for(i=0;i<3;i++){
103 fid[i] = 0;
104 frot[i] = ftran[i] = 0.0;
105 for(j=0;j<3;j++) fm[i][j] = 0.0;
106 fCylR = fCylPhi = 0.0;
107 }// end for i
108 fm[0][0] = fm[1][1] = fm[2][2] = 1.0;
109}
110//----------------------------------------------------------------------
111AliITSgeomMatrix::AliITSgeomMatrix(const AliITSgeomMatrix &sourse){
112////////////////////////////////////////////////////////////////////////
113// The standard copy constructor. This make a full / proper copy of
114// this class.
115////////////////////////////////////////////////////////////////////////
116 Int_t i,j;
117
118 this->fDetectorIndex = sourse.fDetectorIndex;
119 for(i=0;i<3;i++){
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];
126 }// end for i
127}
128//----------------------------------------------------------------------
129void AliITSgeomMatrix::operator=(const AliITSgeomMatrix &sourse){
130////////////////////////////////////////////////////////////////////////
131// The standard = operator. This make a full / proper copy of
132// this class.
133////////////////////////////////////////////////////////////////////////
134 Int_t i,j;
135
136 this->fDetectorIndex = sourse.fDetectorIndex;
137 for(i=0;i<3;i++){
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];
144 }// end for i
145}
146//----------------------------------------------------------------------
147AliITSgeomMatrix::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.
159//Begin_Html
160/*
161<img src="picts/ITS/AliISgeomMatrix_L1.gif">
162*/
163//End_Html
164////////////////////////////////////////////////////////////////////////
165 Int_t i;
166
167 fDetectorIndex = idt; // a value never defined.
168 for(i=0;i<3;i++){
169 fid[i] = id[i];
170 frot[i] = rot[i];
171 ftran[i] = tran[i];
172 }// end for i
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();
177}
178//----------------------------------------------------------------------
179AliITSgeomMatrix::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.
192//Begin_Html
193/*
194<img src="picts/ITS/AliISgeomMatrix_L1.gif">
195*/
196//End_Html
197////////////////////////////////////////////////////////////////////////
198 Int_t i,j;
199
200 fDetectorIndex = idt; // a value never defined.
201 for(i=0;i<3;i++){
202 fid[i] = id[i];
203 ftran[i] = tran[i];
204 for(j=0;j<3;j++) fm[i][j] = matrix[i][j];
205 }// end for i
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();
210}
211//----------------------------------------------------------------------
212void 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();
218
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]);
223
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]);
228
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]);
233
234 for(Int_t i=0;i<6;i++) {ang[i] *= c; if(ang[i]<0.0) ang[i] += 360.;}
235}
236//----------------------------------------------------------------------
237void 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
242// this class.
243////////////////////////////////////////////////////////////////////////
244 Int_t i,j;
245 Double_t si,lr[9],c=TMath::Pi()/180.;
246
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;
257//
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;
268//
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.
281 si = 0.0;
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];
285 } // end for i
286 this->AngleFromMatrix();
287}
288//----------------------------------------------------------------------
289AliITSgeomMatrix::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.
302//Begin_Html
303/*
304<img src="picts/ITS/AliISgeomMatrix_L1.gif">
305*/
306//End_Html
307////////////////////////////////////////////////////////////////////////
308 Int_t i;
309
310 fDetectorIndex = idt; // a value never defined.
311 for(i=0;i<3;i++){
312 fid[i] = id[i];
313 ftran[i] = tran[i];
314 }// end for i
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);
319}
320//----------------------------------------------------------------------
321void AliITSgeomMatrix::AngleFromMatrix(){
322////////////////////////////////////////////////////////////////////////
323// Computes the angles from the rotation matrix up to a phase of 180 degrees.
324////////////////////////////////////////////////////////////////////////
325 Double_t rx,ry,rz;
326 // get angles from matrix up to a phase of 180 degrees.
327
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();
331 frot[0] = rx;
332 frot[1] = ry;
333 frot[2] = rz;
334 return;
335}
336//----------------------------------------------------------------------
337void AliITSgeomMatrix::MatrixFromAngle(){
338////////////////////////////////////////////////////////////////////////
339// Computes the Rotation matrix from the angles [radians] kept in this
340// class.
341////////////////////////////////////////////////////////////////////////
342 Double_t sx,sy,sz,cx,cy,cz;
343
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]
356
357}
358//----------------------------------------------------------------------
359void AliITSgeomMatrix::GtoLPosition(const Double_t g0[3],Double_t l[3]){
360////////////////////////////////////////////////////////////////////////
361// Returns the local coordinates given the global coordinates [cm].
362////////////////////////////////////////////////////////////////////////
363 Int_t i,j;
364 Double_t g[3];
365
366 for(i=0;i<3;i++) g[i] = g0[i] - ftran[i];
367 for(i=0;i<3;i++){
368 l[i] = 0.0;
369 for(j=0;j<3;j++) l[i] += fm[i][j]*g[j];
370 // g = R l + translation
371 } // end for i
372 return;
373}
374//----------------------------------------------------------------------
375void AliITSgeomMatrix::LtoGPosition(const Double_t l[3],Double_t g[3]){
376////////////////////////////////////////////////////////////////////////
377// Returns the global coordinates given the local coordinates [cm].
378////////////////////////////////////////////////////////////////////////
379 Int_t i,j;
380
381 for(i=0;i<3;i++){
382 g[i] = 0.0;
383 for(j=0;j<3;j++) g[i] += fm[j][i]*l[j];
384 g[i] += ftran[i];
385 // g = R^t l + translation
386 } // end for i
387 return;
388}
389//----------------------------------------------------------------------
390void 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////////////////////////////////////////////////////////////////////////
396 Int_t i,j;
397
398 for(i=0;i<3;i++){
399 l[i] = 0.0;
400 for(j=0;j<3;j++) l[i] += fm[i][j]*g[j];
401 // g = R l
402 } // end for i
403 return;
404}
405//----------------------------------------------------------------------
406void 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////////////////////////////////////////////////////////////////////////
412 Int_t i,j;
413
414 for(i=0;i<3;i++){
415 g[i] = 0.0;
416 for(j=0;j<3;j++) g[i] += fm[j][i]*l[j];
417 // g = R^t l
418 } // end for i
419 return;
420}
421//----------------------------------------------------------------------
422void AliITSgeomMatrix::GtoLPositionError( Double_t g[3][3],
423 Double_t l[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////////////////////////////////////////////////////////////////////////
429 Int_t i,j,k,m;
430
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];
433 // g = R^t l R
434 return;
435}
436//----------------------------------------------------------------------
437void AliITSgeomMatrix::LtoGPositionError( Double_t l[3][3],
438 Double_t g[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////////////////////////////////////////////////////////////////////////
444 Int_t i,j,k,m;
445
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];
448 // g = R l R^t
449 return;
450}
451//----------------------------------------------------------------------
452void AliITSgeomMatrix::GtoLPositionTracking(const Double_t g0[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->GtoLPosition(g0,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}
482//----------------------------------------------------------------------
483void AliITSgeomMatrix::LtoGPositionTracking(const Double_t l[3],
484 Double_t g[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).
492//Begin_Html
493/*
494<img src="picts/ITS/AliITSgeomMatrix_T1.gif">
495 */
496//End_Html
497////////////////////////////////////////////////////////////////////////
498 Double_t l0[3];
499
500 if(fid[0]==1){ // for layer 1 the detector are flipped upside down
501 // with respect to the others.
502 l0[0] = -l[1];
503 l0[1] = +l[0];
504 l0[2] = +l[2];
505 }else{
506 l0[0] = +l[1];
507 l0[1] = -l[0];
508 l0[2] = +l[2];
509 } // end if
510 this->LtoGPosition(l0,g);
511 return;
512}
513//----------------------------------------------------------------------
514void AliITSgeomMatrix::GtoLMomentumTracking(const Double_t g[3],
515 Double_t l[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).
523//Begin_Html
524/*
525<img src="picts/ITS/AliITSgeomMatrix_T1.gif">
526 */
527//End_Html
528////////////////////////////////////////////////////////////////////////
529 Double_t l0[3];
530
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.
534 l[0] = +l0[1];
535 l[1] = -l0[0];
536 l[2] = +l0[2];
537 }else{
538 l[0] = -l0[1];
539 l[1] = +l0[0];
540 l[2] = +l0[2];
541 } // end if
542 return;
543 return;
544}
545//----------------------------------------------------------------------
546void AliITSgeomMatrix::LtoGMomentumTracking(const Double_t l[3],
547 Double_t g[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).
555//Begin_Html
556/*
557<img src="picts/ITS/AliITSgeomMatrix_T1.gif">
558 */
559//End_Html
560////////////////////////////////////////////////////////////////////////
561 Double_t l0[3];
562
563 if(fid[0]==1){ // for layer 1 the detector are flipped upside down
564 // with respect to the others.
565 l0[0] = -l[1];
566 l0[1] = +l[0];
567 l0[2] = +l[2];
568 }else{
569 l0[0] = +l[1];
570 l0[1] = -l[0];
571 l0[2] = +l[2];
572 } // end if
573 this->LtoGMomentum(l0,g);
574 return;
575}
576//----------------------------------------------------------------------
577void AliITSgeomMatrix::GtoLPositionErrorTracking( Double_t g[3][3],
578 Double_t l[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).
586//Begin_Html
587/*
588<img src="picts/ITS/AliITSgeomMatrix_T1.gif">
589 */
590//End_Html
591////////////////////////////////////////////////////////////////////////
592 Int_t i,j,k,m;
593 Double_t rt[3][3];
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.}};
596
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];
603 // g = R^t l R
604 return;
605}
606//----------------------------------------------------------------------
607void AliITSgeomMatrix::LtoGPositionErrorTracking( Double_t l[3][3],
608 Double_t g[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).
616//Begin_Html
617/*
618<img src="picts/ITS/AliITSgeomMatrix_T1.gif">
619 */
620//End_Html
621////////////////////////////////////////////////////////////////////////
622 Int_t i,j,k,m;
623 Double_t rt[3][3];
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.}};
626
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];
633 // g = R l R^t
634 return;
635}
636//----------------------------------------------------------------------
637void 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////////////////////////////////////////////////////////////////////////
642 Int_t i,j;
643
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 <<"}{";}
652 *os << "}" << endl;
653 return;
654}
655//----------------------------------------------------------------------
656void 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] ";
663 return;
664}
665//----------------------------------------------------------------------
666void AliITSgeomMatrix::Print(ostream *os){
667////////////////////////////////////////////////////////////////////////
668// Standard output format for this class.
669////////////////////////////////////////////////////////////////////////
670 Int_t i,j;
671 Int_t fmt;
672
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) <<
679 fm[i][j] << " ";
680 *os << endl;
681 os->flags(fmt); // reset back to old formating.
682 return;
683}
684//----------------------------------------------------------------------
685void AliITSgeomMatrix::Read(istream *is){
686////////////////////////////////////////////////////////////////////////
687// Standard input format for this class.
688////////////////////////////////////////////////////////////////////////
689 Int_t i,j;
690
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();
700 return;
701}
702//______________________________________________________________________
703void AliITSgeomMatrix::Streamer(TBuffer &R__b){
704 // Stream an object of class AliITSgeomMatrix.
705
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();
712 } else {
713 AliITSgeomMatrix::Class()->WriteBuffer(R__b, this);
714 }
715}
716//----------------------------------------------------------------------
717ostream &operator<<(ostream &os,AliITSgeomMatrix &p){
718////////////////////////////////////////////////////////////////////////
719// Standard output streaming function.
720////////////////////////////////////////////////////////////////////////
721
722 p.Print(&os);
723 return os;
724}
725//----------------------------------------------------------------------
726istream &operator>>(istream &is,AliITSgeomMatrix &r){
727////////////////////////////////////////////////////////////////////////
728// Standard input streaming function.
729////////////////////////////////////////////////////////////////////////
730
731 r.Read(&is);
732 return is;
733}
734//----------------------------------------------------------------------