]> git.uio.no Git - u/mrichter/AliRoot.git/blob - ITS/AliITSgeomMatrix.cxx
This commit was generated by cvs2svn to compensate for changes in r15977,
[u/mrichter/AliRoot.git] / ITS / AliITSgeomMatrix.cxx
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 $Id$ 
18 */
19 ////////////////////////////////////////////////////////////////////////
20 // This is the implementation file for AliITSgeomMatrix class. It 
21 // contains the routines to manipulate, setup, and queary the geometry 
22 // of a given ITS module. An ITS module may be one of at least three
23 // ITS detector technologies, Silicon Pixel, Drift, or Strip Detectors,
24 // and variations of these in size and/or layout. These routines let
25 // one go between ALICE global coordiantes (cm) to a given modules 
26 // specific local coordinates (cm).
27 ////////////////////////////////////////////////////////////////////////
28
29 #include <Riostream.h>
30 #include <TMath.h>
31 #include <TBuffer.h>
32 #include <TCanvas.h>
33 #include <TView.h>
34 #include <TPolyLine3D.h>
35 #include <TNode.h>
36 #include <TPCON.h>
37 #include <TBRIK.h>
38 #include <TXTRU.h>
39
40 #include "AliITSgeomMatrix.h"
41
42 ClassImp(AliITSgeomMatrix)
43 //----------------------------------------------------------------------
44 AliITSgeomMatrix::AliITSgeomMatrix():
45 TObject(),
46 fDetectorIndex(0), // Detector type index (like fShapeIndex was)
47 fid(),       // layer, ladder, detector numbers.
48 frot(),      //! vector of rotations about x,y,z [radians].
49 ftran(),     // Translation vector of module x,y,z.
50 fCylR(0.0),  //! R Translation in Cylinderical coordinates
51 fCylPhi(0.0),//! Phi Translation vector in Cylindrical coord.
52 fm(),        // Rotation matrix based on frot.
53 fPath(){     // Path in geometry to this module
54     // The Default constructor for the AliITSgeomMatrix class. By Default
55     // the angles of rotations are set to zero, meaning that the rotation
56     // matrix is the unit matrix. The translation vector is also set to 
57     // zero as are the module id number. The detector type is set to -1 
58     // (an undefined value). The full rotation matrix is kept so that 
59     // the evaluation  of a coordinate transformation can be done 
60     // quickly and with a minimum of CPU overhead. The basic coordinate 
61     // systems are the ALICE global coordinate system and the detector 
62     // local coordinate system. In general this structure is not limited 
63     // to just those two coordinate systems.
64     //Begin_Html
65     /*
66       <img src="picts/ITS/AliITSgeomMatrix_L1.gif">
67     */
68     //End_Html
69     // Inputs:
70     //    none.
71     // Outputs:
72     //    none.
73     // Return:
74     //    A default constructes AliITSgeomMatrix class.
75     Int_t i,j;
76
77     fDetectorIndex = -1; // a value never defined.
78     for(i=0;i<3;i++){
79         fid[i] = 0;
80         frot[i] = ftran[i] = 0.0;
81         for(j=0;j<3;j++) fm[i][j] = 0.0;
82         fCylR = fCylPhi = 0.0;
83     }// end for i
84     fm[0][0] = fm[1][1] = fm[2][2] = 1.0;
85 }
86
87 //----------------------------------------------------------------------
88 AliITSgeomMatrix::AliITSgeomMatrix(const AliITSgeomMatrix &source) : 
89 TObject(source),
90 fDetectorIndex(source.fDetectorIndex),
91 fCylR(source.fCylR),
92 fCylPhi(source.fCylPhi),
93 fPath(source.fPath){
94     // The standard Copy constructor. This make a full / proper copy of
95     // this class.
96     // Inputs:
97     //    AliITSgeomMatrix &source   The source of this copy
98     // Outputs:
99     //    none.
100     // Return:
101     //    A copy constructes AliITSgeomMatrix class.
102         Int_t i,j;
103         for(i=0;i<3;i++){
104                 this->fid[i]     = source.fid[i];
105                 this->frot[i]    = source.frot[i];
106                 this->ftran[i]   = source.ftran[i];
107                 for(j=0;j<3;j++) this->fm[i][j] = source.fm[i][j];
108         }// end for i
109 }
110 //----------------------------------------------------------------------
111 AliITSgeomMatrix& AliITSgeomMatrix::operator=(const AliITSgeomMatrix &source){
112     // The standard = operator. This make a full / proper copy of
113     // this class.
114     // The standard Copy constructor. This make a full / proper copy of
115     // this class.
116     // Inputs:
117     //    AliITSgeomMatrix &source   The source of this copy
118     // Outputs:
119     //    none.
120     // Return:
121     //    A copy of the source AliITSgeomMatrix class.
122   if(this == &source)return *this;
123   Int_t i,j;
124
125   this->fDetectorIndex = source.fDetectorIndex;
126   this->fCylR      = source.fCylR;
127   this->fCylPhi    = source.fCylPhi;
128   for(i=0;i<3;i++){
129     this->fid[i]     = source.fid[i];
130     this->frot[i]    = source.frot[i];
131     this->ftran[i]   = source.ftran[i];
132
133     for(j=0;j<3;j++) this->fm[i][j] = source.fm[i][j];
134   }
135   this->fPath   = source.fPath;
136   return *this;
137 }
138
139 //----------------------------------------------------------------------
140 AliITSgeomMatrix::AliITSgeomMatrix(Int_t idt,const Int_t id[3],
141                         const Double_t rot[3],const Double_t tran[3]):
142 TObject(),
143 fDetectorIndex(idt), // Detector type index (like fShapeIndex was)
144 fid(),       // layer, ladder, detector numbers.
145 frot(),      //! vector of rotations about x,y,z [radians].
146 ftran(),     // Translation vector of module x,y,z.
147 fCylR(0.0),  //! R Translation in Cylinderical coordinates
148 fCylPhi(0.0),//! Phi Translation vector in Cylindrical coord.
149 fm(),        // Rotation matrix based on frot.
150 fPath(){     // Path in geometry to this moduel
151     // This is a constructor for the AliITSgeomMatrix class. The matrix is
152     // defined by 3 standard rotation angles [radians], and the translation
153     // vector tran [cm]. In addition the layer, ladder, and detector number
154     // for this particular module and the type of module must be given.
155     // The full rotation matrix is kept so that the evaluation 
156     // of a coordinate transformation can be done quickly and with a minimum
157     // of CPU overhead. The basic coordinate systems are the ALICE global
158     // coordinate system and the detector local coordinate system. In general
159     // this structure is not limited to just those two coordinate systems.
160     //Begin_Html
161     /*
162       <img src="picts/ITS/AliITSgeomMatrix_L1.gif">
163     */
164     //End_Html
165     // Inputs:
166     //    Int_t idt        The detector index value
167     //    Int_t id[3]      The layer, ladder, and detector numbers
168     //    Double_t rot[3]  The 3 Cartician rotaion angles [radians]
169     //    Double_t tran[3] The 3 Cartician translation distnaces
170     // Outputs:
171     //    none.
172     // Return:
173     //    A properly inilized AliITSgeomMatrix class.
174     Int_t i;
175
176     for(i=0;i<3;i++){
177         fid[i]   = id[i];
178         frot[i]  = rot[i];
179         ftran[i] = tran[i];
180     }// end for i
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();
185 }
186 //----------------------------------------------------------------------
187 AliITSgeomMatrix::AliITSgeomMatrix(Int_t idt, const Int_t id[3],
188                                    Double_t matrix[3][3],
189                                    const Double_t tran[3]):
190 TObject(),
191 fDetectorIndex(idt), // Detector type index (like fShapeIndex was)
192 fid(),       // layer, ladder, detector numbers.
193 frot(),      //! vector of rotations about x,y,z [radians].
194 ftran(),     // Translation vector of module x,y,z.
195 fCylR(0.0),  //! R Translation in Cylinderical coordinates
196 fCylPhi(0.0),//! Phi Translation vector in Cylindrical coord.
197 fm(),        // Rotation matrix based on frot.
198 fPath(){     // Path in geometry to this module
199     // This is a constructor for the AliITSgeomMatrix class. The 
200     // rotation matrix is given as one of the inputs, and the 
201     // translation vector tran [cm]. In  addition the layer, ladder, 
202     // and detector number for this particular module and the type of 
203     // module must be given. The full rotation matrix is kept so that 
204     // the evaluation of a coordinate transformation can be done quickly 
205     // and with a minimum of CPU overhead. The basic coordinate systems 
206     // are the ALICE global coordinate system and the detector local
207     // coordinate system. In general this structure is not limited to just
208     // those two coordinate systems.
209     //Begin_Html
210     /*
211       <img src="picts/ITS/AliITSgeomMatrix_L1.gif">
212     */
213     //End_Html
214     // Inputs:
215     //    Int_t idt          The detector index value
216     //    Int_t id[3]        The layer, ladder, and detector numbers
217     //    Double_t rot[3][3] The 3x3 Cartician rotaion matrix
218     //    Double_t tran[3]   The 3 Cartician translation distnaces
219     // Outputs:
220     //    none.
221     // Return:
222     //    A properly inilized AliITSgeomMatrix class.
223     Int_t i,j;
224
225     for(i=0;i<3;i++){
226         fid[i]   = id[i];
227         ftran[i] = tran[i];
228         for(j=0;j<3;j++) fm[i][j] = matrix[i][j];
229     }// end for i
230     fCylR   = TMath::Sqrt(ftran[0]*ftran[0]+ftran[1]*ftran[1]);
231     fCylPhi = TMath::ATan2(ftran[1],ftran[0]);
232     if(fCylPhi<0.0) fCylPhi += TMath::Pi();
233     this->AngleFromMatrix();
234 }
235 //----------------------------------------------------------------------
236 void AliITSgeomMatrix::SixAnglesFromMatrix(Double_t *ang)const{
237     // This function returns the 6 GEANT 3.21 rotation angles [degrees] in
238     // the array ang which must be at least [6] long.
239     // Inputs:
240     //   none.
241     // Outputs:
242     //   Double_t ang[6]  The 6 Geant3.21 rotation angles. [degrees]
243     // Return:
244     //   noting
245     Double_t si,c=180./TMath::Pi();
246
247     ang[1] = TMath::ATan2(fm[0][1],fm[0][0]);
248     if(TMath::Cos(ang[1])!=0.0) si = fm[0][0]/TMath::Cos(ang[1]);
249     else si = fm[0][1]/TMath::Sin(ang[1]);
250     ang[0] = TMath::ATan2(si,fm[0][2]);
251
252     ang[3] = TMath::ATan2(fm[1][1],fm[1][0]);
253     if(TMath::Cos(ang[3])!=0.0) si = fm[1][0]/TMath::Cos(ang[3]);
254     else si = fm[1][1]/TMath::Sin(ang[3]);
255     ang[2] = TMath::ATan2(si,fm[1][2]);
256
257     ang[5] = TMath::ATan2(fm[2][1],fm[2][0]);
258     if(TMath::Cos(ang[5])!=0.0) si = fm[2][0]/TMath::Cos(ang[5]);
259     else si = fm[2][1]/TMath::Sin(ang[5]);
260     ang[4] = TMath::ATan2(si,fm[2][2]);
261
262     for(Int_t i=0;i<6;i++) {ang[i] *= c; if(ang[i]<0.0) ang[i] += 360.;}
263 }
264 //----------------------------------------------------------------------
265 void AliITSgeomMatrix::MatrixFromSixAngles(const Double_t *ang){
266     // Given the 6 GEANT 3.21 rotation angles [degree], this will compute and
267     // set the rotations matrix and 3 standard rotation angles [radians].
268     // These angles and rotation matrix are overwrite the existing values in
269     // this class.
270     // Inputs:
271     //   Double_t ang[6]  The 6 Geant3.21 rotation angles. [degrees]
272     // Outputs:
273     //   none.
274     // Return:
275     //   noting
276     Int_t    i,j;
277     Double_t si,lr[9],c=TMath::Pi()/180.;
278
279     si    = TMath::Sin(c*ang[0]);
280     if(ang[0]== 90.0)                 si = +1.0;
281     if(ang[0]==270.0)                 si = -1.0;
282     if(ang[0]==  0.0||ang[0]==180.) si =  0.0;
283     lr[0] = si * TMath::Cos(c*ang[1]);
284     lr[1] = si * TMath::Sin(c*ang[1]);
285     lr[2] = TMath::Cos(c*ang[0]);
286     if(ang[0]== 90.0||ang[0]==270.) lr[2] =  0.0;
287     if(ang[0]== 0.0)                  lr[2] = +1.0;
288     if(ang[0]==180.0)                 lr[2] = -1.0;
289 //
290     si    =  TMath::Sin(c*ang[2]);
291     if(ang[2]== 90.0)                 si = +1.0; 
292     if(ang[2]==270.0)                 si = -1.0;
293     if(ang[2]==  0.0||ang[2]==180.) si =  0.0;
294     lr[3] = si * TMath::Cos(c*ang[3]);
295     lr[4] = si * TMath::Sin(c*ang[3]);
296     lr[5] = TMath::Cos(c*ang[2]);
297     if(ang[2]== 90.0||ang[2]==270.) lr[5] =  0.0;
298     if(ang[2]==  0.0)                 lr[5] = +1.0;
299     if(ang[2]==180.0)                 lr[5] = -1.0;
300 //
301     si    = TMath::Sin(c*ang[4]);
302     if(ang[4]== 90.0)                 si = +1.0;
303     if(ang[4]==270.0)                 si = -1.0;
304     if(ang[4]==  0.0||ang[4]==180.) si =  0.0;
305     lr[6] = si * TMath::Cos(c*ang[5]);
306     lr[7] = si * TMath::Sin(c*ang[5]);
307     lr[8] = TMath::Cos(c*ang[4]);
308     if(ang[4]== 90.0||ang[4]==270.0) lr[8] =  0.0;
309     if(ang[4]==  0.0)                  lr[8] = +1.0;
310     if(ang[4]==180.0)                  lr[8] = -1.0;
311     // Normalize these elements and fill matrix fm.
312     for(i=0;i<3;i++){// reuse si.
313         si = 0.0;
314         for(j=0;j<3;j++) si += lr[3*i+j]*lr[3*i+j];
315         si = TMath::Sqrt(1./si);
316         for(j=0;j<3;j++) fm[i][j] = si*lr[3*i+j];
317     } // end for i
318     this->AngleFromMatrix();
319 }
320 //----------------------------------------------------------------------
321 AliITSgeomMatrix::AliITSgeomMatrix(const Double_t rotd[6]/*degrees*/,
322                                    Int_t idt,const Int_t id[3],
323                                    const Double_t tran[3]):
324 TObject(),
325 fDetectorIndex(idt),
326 fCylR(0.),
327 fCylPhi(0.),
328 fPath(){
329     // This is a constructor for the AliITSgeomMatrix class. The matrix 
330     // is defined by the 6 GEANT 3.21 rotation angles [degrees], and 
331     // the translation vector tran [cm]. In addition the layer, ladder, 
332     // and detector number for this particular module and the type of 
333     // module must be given. The full rotation matrix is kept so that 
334     // the evaluation  of a coordinate transformation can be done 
335     // quickly and with a minimum of CPU overhead. The basic coordinate 
336     // systems are the ALICE global coordinate system and the detector 
337     // local coordinate system. In general this structure is not limited 
338     // to just those two coordinate systems.
339     //Begin_Html
340     /*
341       <img src="picts/ITS/AliITSgeomMatrix_L1.gif">
342     */
343     //End_Html
344     // Inputs:
345     //    Double_t rotd[6]  The 6 Geant 3.21 rotation angles [degrees]
346     //    Int_t idt         The module Id number
347     //    Int_t id[3]       The layer, ladder and detector number
348     //    Double_t tran[3]  The translation vector
349     Int_t i;
350
351     for(i=0;i<3;i++){
352         fid[i]   = id[i];
353         ftran[i] = tran[i];
354     }// end for i
355     fCylR   = TMath::Sqrt(ftran[0]*ftran[0]+ftran[1]*ftran[1]);
356     fCylPhi = TMath::ATan2(ftran[1],ftran[0]);
357     if(fCylPhi<0.0) fCylPhi += TMath::Pi();
358     this->MatrixFromSixAngles(rotd);
359 }
360
361 //----------------------------------------------------------------------
362 void AliITSgeomMatrix::AngleFromMatrix(){
363     // Computes the angles from the rotation matrix up to a phase of 
364     // 180 degrees. The matrix used in AliITSgeomMatrix::MatrixFromAngle()
365     // and  its inverse AliITSgeomMatrix::AngleFromMatrix() are defined in 
366     // the following ways, R = Rz*Ry*Rx (M=R*L+T) where
367     //     1   0   0       Cy  0 +Sy       Cz -Sz  0
368     // Rx= 0   Cx -Sx  Ry=  0  1   0   Rz=+Sz  Cz  0
369     //     0  +Sx  Cx     -Sy  0  Cy        0   0  1
370     // The choice of the since of S, comes from the choice between 
371     // the rotation of the object or the coordinate system (view). I think
372     // that this choice is the first, the rotation of the object.
373     // Inputs:
374     //   none
375     // Outputs:
376     //   none
377     // Return:
378     //   none
379     Double_t rx,ry,rz;
380     // get angles from matrix up to a phase of 180 degrees.
381
382     rx = TMath::ATan2(fm[2][1],fm[2][2]);if(rx<0.0) rx += 2.0*TMath::Pi();
383     ry = TMath::ASin(-fm[0][2]);         if(ry<0.0) ry += 2.0*TMath::Pi();
384     rz = TMath::ATan2(fm[1][0],fm[0][0]);if(rz<0.0) rz += 2.0*TMath::Pi();
385     frot[0] = rx;
386     frot[1] = ry;
387     frot[2] = rz;
388     return;
389 }
390
391 //----------------------------------------------------------------------
392 void AliITSgeomMatrix::MatrixFromAngle(){
393     // Computes the Rotation matrix from the angles [radians] kept in this
394     // class. The matrix used in AliITSgeomMatrix::MatrixFromAngle() and 
395     // its inverse AliITSgeomMatrix::AngleFromMatrix() are defined in 
396     // the following ways, R = Rz*Ry*Rx (M=R*L+T) where
397     //     1   0   0       Cy  0 +Sy       Cz -Sz  0
398     // Rx= 0   Cx -Sx  Ry=  0  1   0   Rz=+Sz  Cz  0
399     //     0  +Sx  Cx     -Sy  0  Cy        0   0  1
400     // The choice of the since of S, comes from the choice between 
401     // the rotation of the object or the coordinate system (view). I think
402     // that this choice is the first, the rotation of the object.
403     // Inputs:
404     //   none
405     // Outputs:
406     //   none
407     // Return:
408     //   none
409    Double_t sx,sy,sz,cx,cy,cz;
410
411    sx = TMath::Sin(frot[0]); cx = TMath::Cos(frot[0]);
412    sy = TMath::Sin(frot[1]); cy = TMath::Cos(frot[1]);
413    sz = TMath::Sin(frot[2]); cz = TMath::Cos(frot[2]);
414    fm[0][0] = +cz*cy;             // fr[0]
415    fm[0][1] = +cz*sy*sx - sz*cx;  // fr[1]
416    fm[0][2] = +cz*sy*cx + sz*sx;  // fr[2]
417    fm[1][0] = +sz*cy;             // fr[3]
418    fm[1][1] = +sz*sy*sx + cz*cx;  // fr[4]
419    fm[1][2] = +sz*sy*cx - cz*sx;  // fr[5]
420    fm[2][0] = -sy;                // fr[6]
421    fm[2][1] = +cy*sx;             // fr[7]
422    fm[2][2] = +cy*cx;             // fr[8]
423
424 }
425
426 //----------------------------------------------------------------------
427 void AliITSgeomMatrix::GtoLPosition(const Double_t g0[3],Double_t l[3]) const {
428     // Returns the local coordinates given the global coordinates [cm].
429     // Inputs:
430     //   Double_t g[3]   The position represented in the ALICE 
431     //                   global coordinate system
432     // Outputs:
433     //   Double_t l[3]  The poistion represented in the local
434     //                  detector coordiante system
435     // Return:
436     //   none
437         Int_t    i,j;
438         Double_t g[3];
439
440         for(i=0;i<3;i++) g[i] = g0[i] - ftran[i];
441         for(i=0;i<3;i++){
442                 l[i] = 0.0;
443                 for(j=0;j<3;j++) l[i] += fm[i][j]*g[j];
444                 // g = R l + translation
445         } // end for i
446         return;
447 }
448 //----------------------------------------------------------------------
449 void AliITSgeomMatrix::LtoGPosition(const Double_t l[3],Double_t g[3]) const {
450     // Returns the global coordinates given the local coordinates [cm].
451     // Inputs:
452     //   Double_t l[3]   The poistion represented in the detector 
453     //                   local coordinate system
454     // Outputs:
455     //   Double_t g[3]   The poistion represented in the ALICE
456     //                   Global coordinate system
457     // Return:
458     //   none.
459         Int_t    i,j;
460
461         for(i=0;i<3;i++){
462                 g[i] = 0.0;
463                 for(j=0;j<3;j++) g[i] += fm[j][i]*l[j];
464                 g[i] += ftran[i];
465                 // g = R^t l + translation
466         } // end for i
467         return;
468 }
469 //----------------------------------------------------------------------
470 void AliITSgeomMatrix::GtoLMomentum(const Double_t g[3],Double_t l[3]) const{
471     // Returns the local coordinates of the momentum given the global
472     // coordinates of the momentum. It transforms just like GtoLPosition
473     // except that the translation vector is zero.
474     // Inputs:
475     //   Double_t g[3] The momentum represented in the ALICE global 
476     //                 coordinate system
477     // Outputs:
478     //   Double_t l[3] the momentum represented in the detector 
479     //                 local coordinate system
480     // Return:
481     //   none.
482         Int_t    i,j;
483
484         for(i=0;i<3;i++){
485                 l[i] = 0.0;
486                 for(j=0;j<3;j++) l[i] += fm[i][j]*g[j];
487                 // g = R l
488         } // end for i
489         return;
490 }
491 //----------------------------------------------------------------------
492 void AliITSgeomMatrix::LtoGMomentum(const Double_t l[3],Double_t g[3]) const {
493     // Returns the Global coordinates of the momentum given the local
494     // coordinates of the momentum. It transforms just like LtoGPosition
495     // except that the translation vector is zero.
496     // Inputs:
497     //   Double_t l[3] the momentum represented in the detector 
498     //                 local coordinate system
499     // Outputs:
500     //   Double_t g[3] The momentum represented in the ALICE global 
501     //                 coordinate system
502     // Return:
503     //   none.
504         Int_t    i,j;
505
506         for(i=0;i<3;i++){
507                 g[i] = 0.0;
508                 for(j=0;j<3;j++) g[i] += fm[j][i]*l[j];
509                 // g = R^t l
510         } // end for i
511         return;
512 }
513 //----------------------------------------------------------------------
514 void AliITSgeomMatrix::GtoLPositionError(const Double_t g[3][3],
515                                          Double_t l[3][3]) const {
516     // Given an Uncertainty matrix in Global coordinates it is 
517     // rotated so that  its representation in local coordinates can 
518     // be returned. There is no effect due to the translation vector 
519     // or its uncertainty.
520     // Inputs:
521     //   Double_t g[3][3] The error matrix represented in the ALICE global 
522     //                    coordinate system
523     // Outputs:
524     //   Double_t l[3][3] the error matrix represented in the detector 
525     //                    local coordinate system
526     // Return:
527     //   none.
528         Int_t    i,j,k,m;
529
530         for(i=0;i<3;i++)for(m=0;m<3;m++){
531             l[i][m] = 0.0;
532             for(j=0;j<3;j++)for(k=0;k<3;k++)
533                 l[i][m] += fm[j][i]*g[j][k]*fm[k][m];
534         } // end for i,m
535             // g = R^t l R
536         return;
537 }
538 //----------------------------------------------------------------------
539 void AliITSgeomMatrix::LtoGPositionError(const Double_t l[3][3],
540                                                Double_t g[3][3]) const {
541     // Given an Uncertainty matrix in Local coordinates it is rotated so that 
542     // its representation in global coordinates can be returned. There is no
543     // effect due to the translation vector or its uncertainty.
544     // Inputs:
545     //   Double_t l[3][3] the error matrix represented in the detector 
546     //                    local coordinate system
547     // Outputs:
548     //   Double_t g[3][3] The error matrix represented in the ALICE global 
549     //                    coordinate system
550     // Return:
551     //   none.
552         Int_t    i,j,k,m;
553
554         for(i=0;i<3;i++)for(m=0;m<3;m++){
555             g[i][m] = 0.0;
556             for(j=0;j<3;j++)for(k=0;k<3;k++)
557                 g[i][m] += fm[i][j]*l[j][k]*fm[m][k];
558         } // end for i,m
559             // g = R l R^t
560         return;
561 }
562 //----------------------------------------------------------------------
563 void AliITSgeomMatrix::GtoLPositionTracking(const Double_t g[3],
564                                             Double_t l[3]) const {
565     // A slightly different coordinate system is used when tracking.
566     // This coordinate system is only relevant when the geometry represents
567     // the cylindrical ALICE ITS geometry. For tracking the Z axis is left
568     // alone but X -> -Y and Y -> X such that X always points out of the
569     // ITS Cylinder for every layer including layer 1 (where the detector 
570     // are mounted upside down).
571     //Begin_Html
572     /*
573       <img src="picts/ITS/AliITSgeomMatrix_T1.gif">
574     */
575     //End_Html
576     // Inputs:
577     //   Double_t g[3]   The position represented in the ALICE 
578     //                   global coordinate system
579     // Outputs:
580     //   Double_t l[3]  The poistion represented in the local
581     //                  detector coordiante system
582     // Return:
583     //   none
584     Double_t l0[3];
585
586     this->GtoLPosition(g,l0);
587     if(fid[0]==1){ // for layer 1 the detector are flipped upside down
588                    // with respect to the others.
589         l[0] = +l0[1];
590         l[1] = -l0[0];
591         l[2] = +l0[2];
592     }else{
593         l[0] = -l0[1];
594         l[1] = +l0[0];
595         l[2] = +l0[2];
596     } // end if
597     return;
598 }
599 //----------------------------------------------------------------------
600 void AliITSgeomMatrix::LtoGPositionTracking(const Double_t l[3],
601                                             Double_t g[3]) const {
602     // A slightly different coordinate system is used when tracking.
603     // This coordinate system is only relevant when the geometry represents
604     // the cylindrical ALICE ITS geometry. For tracking the Z axis is left
605     // alone but X -> -Y and Y -> X such that X always points out of the
606     // ITS Cylinder for every layer including layer 1 (where the detector 
607     // are mounted upside down).
608     //Begin_Html
609     /*
610       <img src="picts/ITS/AliITSgeomMatrix_T1.gif">
611     */
612     //End_Html
613     // Inputs:
614     //   Double_t l[3]   The poistion represented in the detector 
615     //                   local coordinate system
616     // Outputs:
617     //   Double_t g[3]   The poistion represented in the ALICE
618     //                   Global coordinate system
619     // Return:
620     //   none.
621     Double_t l0[3];
622
623     if(fid[0]==1){ // for layer 1 the detector are flipped upside down
624                    // with respect to the others.
625         l0[0] = -l[1];
626         l0[1] = +l[0];
627         l0[2] = +l[2];
628     }else{
629         l0[0] = +l[1];
630         l0[1] = -l[0];
631         l0[2] = +l[2];
632     } // end if
633     this->LtoGPosition(l0,g);
634     return;
635 }
636 //----------------------------------------------------------------------
637 void AliITSgeomMatrix::GtoLMomentumTracking(const Double_t g[3],
638                                             Double_t l[3]) const {
639     // A slightly different coordinate system is used when tracking.
640     // This coordinate system is only relevant when the geometry represents
641     // the cylindrical ALICE ITS geometry. For tracking the Z axis is left
642     // alone but X -> -Y and Y -> X such that X always points out of the
643     // ITS Cylinder for every layer including layer 1 (where the detector 
644     // are mounted upside down).
645     //Begin_Html
646     /*
647       <img src="picts/ITS/AliITSgeomMatrix_T1.gif">
648     */
649     //End_Html
650     // Inputs:
651     //   Double_t g[3] The momentum represented in the ALICE global 
652     //                 coordinate system
653     // Outputs:
654     //   Double_t l[3] the momentum represented in the detector 
655     //                 local coordinate system
656     // Return:
657     //   none.
658     Double_t l0[3];
659
660     this->GtoLMomentum(g,l0);
661     if(fid[0]==1){ // for layer 1 the detector are flipped upside down
662                    // with respect to the others.
663         l[0] = +l0[1];
664         l[1] = -l0[0];
665         l[2] = +l0[2];
666     }else{
667         l[0] = -l0[1];
668         l[1] = +l0[0];
669         l[2] = +l0[2];
670     } // end if
671     return;
672 }
673 //----------------------------------------------------------------------
674 void AliITSgeomMatrix::LtoGMomentumTracking(const Double_t l[3],
675                                             Double_t g[3]) const {
676     // A slightly different coordinate system is used when tracking.
677     // This coordinate system is only relevant when the geometry represents
678     // the cylindrical ALICE ITS geometry. For tracking the Z axis is left
679     // alone but X -> -Y and Y -> X such that X always points out of the
680     // ITS Cylinder for every layer including layer 1 (where the detector 
681     // are mounted upside down).
682     //Begin_Html
683     /*
684       <img src="picts/ITS/AliITSgeomMatrix_T1.gif">
685     */
686     //End_Html
687     // Inputs:
688     //   Double_t l[3] the momentum represented in the detector 
689     //                 local coordinate system
690     // Outputs:
691     //   Double_t g[3] The momentum represented in the ALICE global 
692     //                 coordinate system
693     // Return:
694     //   none.
695     Double_t l0[3];
696
697     if(fid[0]==1){ // for layer 1 the detector are flipped upside down
698                    // with respect to the others.
699         l0[0] = -l[1];
700         l0[1] = +l[0];
701         l0[2] = +l[2];
702     }else{
703         l0[0] = +l[1];
704         l0[1] = -l[0];
705         l0[2] = +l[2];
706     } // end if
707     this->LtoGMomentum(l0,g);
708         return;
709 }
710 //----------------------------------------------------------------------
711 void AliITSgeomMatrix::GtoLPositionErrorTracking(const Double_t g[3][3],
712                                                  Double_t l[3][3]) const {
713     // A slightly different coordinate system is used when tracking.
714     // This coordinate system is only relevant when the geometry represents
715     // the cylindrical ALICE ITS geometry. For tracking the Z axis is left
716     // alone but X -> -Y and Y -> X such that X always points out of the
717     // ITS Cylinder for every layer including layer 1 (where the detector 
718     // are mounted upside down).
719     //Begin_Html
720     /*
721       <img src="picts/ITS/AliITSgeomMatrix_TE1.gif">
722     */
723     //End_Html
724     // Inputs:
725     //   Double_t g[3][3] The error matrix represented in the ALICE global 
726     //                    coordinate system
727     // Outputs:
728     //   Double_t l[3][3] the error matrix represented in the detector 
729     //                    local coordinate system
730     // Return:
731         Int_t    i,j,k,m;
732         Double_t rt[3][3];
733         Double_t a0[3][3] = {{0.,+1.,0.},{-1.,0.,0.},{0.,0.,+1.}};
734         Double_t a1[3][3] = {{0.,-1.,0.},{+1.,0.,0.},{0.,0.,+1.}};
735
736         if(fid[0]==1) for(i=0;i<3;i++)for(j=0;j<3;j++)for(k=0;k<3;k++)
737             rt[i][k] = a0[i][j]*fm[j][k];
738         else for(i=0;i<3;i++)for(j=0;j<3;j++)for(k=0;k<3;k++)
739             rt[i][k] = a1[i][j]*fm[j][k];
740         for(i=0;i<3;i++)for(m=0;m<3;m++){
741             l[i][m] = 0.0;
742             for(j=0;j<3;j++)for(k=0;k<3;k++)
743                 l[i][m] += rt[j][i]*g[j][k]*rt[k][m];
744         } // end for i,m
745             // g = R^t l R
746         return;
747 }
748 //----------------------------------------------------------------------
749 void AliITSgeomMatrix::LtoGPositionErrorTracking(const Double_t l[3][3],
750                                                  Double_t g[3][3]) const {
751     // A slightly different coordinate system is used when tracking.
752     // This coordinate system is only relevant when the geometry represents
753     // the cylindrical ALICE ITS geometry. For tracking the Z axis is left
754     // alone but X -> -Y and Y -> X such that X always points out of the
755     // ITS Cylinder for every layer including layer 1 (where the detector 
756     // are mounted upside down).
757     //Begin_Html
758     /*
759       <img src="picts/ITS/AliITSgeomMatrix_TE1.gif">
760     */
761     //End_Html
762     // Inputs:
763     //   Double_t l[3][3] the error matrix represented in the detector 
764     //                    local coordinate system
765     // Outputs:
766     //   Double_t g[3][3] The error matrix represented in the ALICE global 
767     //                    coordinate system
768     // Return:
769     //   none.
770         Int_t    i,j,k,m;
771         Double_t rt[3][3];
772         Double_t a0[3][3] = {{0.,+1.,0.},{-1.,0.,0.},{0.,0.,+1.}};
773         Double_t a1[3][3] = {{0.,-1.,0.},{+1.,0.,0.},{0.,0.,+1.}};
774
775         if(fid[0]==1) for(i=0;i<3;i++)for(j=0;j<3;j++)for(k=0;k<3;k++)
776             rt[i][k] = a0[i][j]*fm[j][k];
777         else for(i=0;i<3;i++)for(j=0;j<3;j++)for(k=0;k<3;k++)
778             rt[i][k] = a1[i][j]*fm[j][k];
779         for(i=0;i<3;i++)for(m=0;m<3;m++){
780             g[i][m] = 0.0;
781             for(j=0;j<3;j++)for(k=0;k<3;k++)
782                 g[i][m] += rt[i][j]*l[j][k]*rt[m][k];
783         } // end for i,m
784             // g = R l R^t
785         return;
786 }
787 //----------------------------------------------------------------------
788 void AliITSgeomMatrix::PrintTitles(ostream *os) const {
789     // Standard output format for this class but it includes variable
790     // names and formatting that makes it easer to read.
791     // Inputs:
792     //    ostream *os   The output stream to print the title on
793     // Outputs:
794     //    none.
795     // Return:
796     //    none.
797     Int_t i,j;
798
799     *os << "fDetectorIndex=" << fDetectorIndex << " fid[3]={";
800     for(i=0;i<3;i++) *os << fid[i]   << " ";
801     *os << "} frot[3]={";
802     for(i=0;i<3;i++) *os << frot[i]  << " ";
803     *os << "} ftran[3]={";
804     for(i=0;i<3;i++) *os << ftran[i] << " ";
805     *os << "} fm[3][3]={";
806     for(i=0;i<3;i++){for(j=0;j<3;j++){  *os << fm[i][j] << " ";} *os <<"}{";}
807     *os << "}" << endl;
808     return;
809 }
810 //----------------------------------------------------------------------
811 void AliITSgeomMatrix::PrintComment(ostream *os) const {
812     //  output format used by Print.
813     // Inputs:
814     //    ostream *os   The output stream to print the comments on
815     // Outputs:
816     //    none.
817     // Return:
818     //    none.
819     *os << "fDetectorIndex fid[0] fid[1] fid[2] ftran[0] ftran[1] ftran[2] ";
820     *os << "fm[0][0]  fm[0][1]  fm[0][2]  fm[1][0]  fm[1][1]  fm[1][2]  ";
821     *os << "fm[2][0]  fm[2][1]  fm[2][2] ";
822     return;
823 }
824 //----------------------------------------------------------------------
825 void AliITSgeomMatrix::Print(ostream *os)const{
826     // Standard output format for this class.
827     // Inputs:
828     //    ostream *os   The output stream to print the class data on
829     // Outputs:
830     //    none.
831     // Return:
832     //    none.
833     Int_t i,j;
834 #if defined __GNUC__
835 #if __GNUC__ > 2
836     ios::fmtflags fmt;
837 #else
838     Int_t fmt;
839 #endif
840 #else
841 #if defined __ICC || defined __ECC || defined __xlC__
842     ios::fmtflags fmt;
843 #else
844     Int_t fmt;
845 #endif
846 #endif
847
848     fmt = os->setf(ios::scientific);  // set scientific floating point output
849     *os << fDetectorIndex << " ";
850     for(i=0;i<3;i++) *os << fid[i]   << " ";
851 //    for(i=0;i<3;i++) *os << frot[i]  << " ";  // Redundant with fm[][].
852     for(i=0;i<3;i++) *os << setprecision(16) << ftran[i] << " ";
853     for(i=0;i<3;i++)for(j=0;j<3;j++)  *os << setprecision(16) << 
854                                           fm[i][j] << " ";
855     *os << fPath.Length()<< " ";
856     for(i=0;i<fPath.Length();i++) *os << fPath[i];
857     *os << endl;
858     os->flags(fmt); // reset back to old formating.
859     return;
860 }
861 //----------------------------------------------------------------------
862 void AliITSgeomMatrix::Read(istream *is){
863     // Standard input format for this class.
864     // Inputs:
865     //    istream *is   The input stream to read on
866     // Outputs:
867     //    none.
868     // Return:
869     //    none.
870     Int_t i,j;
871
872     *is >> fDetectorIndex;
873     for(i=0;i<3;i++) *is >> fid[i];
874 //    for(i=0;i<3;i++) *is >> frot[i]; // Redundant with fm[][].
875     for(i=0;i<3;i++) *is >> ftran[i];
876     for(i=0;i<3;i++)for(j=0;j<3;j++)  *is >> fm[i][j];
877     while(is->peek()==' ')is->get(); // skip white spaces
878     if(isprint(is->peek())){ // old format did not have path.
879         *is >> j; // string length
880         fPath.Resize(j);
881         for(i=0;i<j;i++) {*is >> fPath[i];}
882     } // end if
883     AngleFromMatrix(); // compute angles frot[].
884     fCylR   = TMath::Sqrt(ftran[0]*ftran[0]+ftran[1]*ftran[1]);
885     fCylPhi = TMath::ATan2(ftran[1],ftran[0]);
886     if(fCylPhi<0.0) fCylPhi += TMath::Pi();
887     return;
888 }
889 //______________________________________________________________________
890 void AliITSgeomMatrix::Streamer(TBuffer &R__b){
891    // Stream an object of class AliITSgeomMatrix.
892     // Inputs:
893     //     TBuffer &R__b   The output buffer to stream data on.
894     // Outputs:
895     //    none.
896     // Return:
897     //    none.
898
899     if (R__b.IsReading()) {
900         AliITSgeomMatrix::Class()->ReadBuffer(R__b, this);
901         fCylR   = TMath::Sqrt(ftran[0]*ftran[0]+ftran[1]*ftran[1]);
902         fCylPhi = TMath::ATan2(ftran[1],ftran[0]);
903         this->AngleFromMatrix();
904         if(fCylPhi<0.0) fCylPhi += TMath::Pi();
905     } else {
906         AliITSgeomMatrix::Class()->WriteBuffer(R__b, this);
907     } // end if
908 }
909 //______________________________________________________________________
910 void AliITSgeomMatrix::SetTranslation(const Double_t tran[3]){
911     // Sets the translation vector and computes fCylR and fCylPhi.
912     // Inputs:
913     //   Double_t trans[3]   The translation vector to be used
914     // Outputs:
915     //   none.
916     // Return:
917     //   none.
918     for(Int_t i=0;i<3;i++) ftran[i] = tran[i];
919     fCylR   = TMath::Sqrt(ftran[0]*ftran[0]+ftran[1]*ftran[1]);
920     fCylPhi = TMath::ATan2(ftran[1],ftran[0]);
921     if(fCylPhi<0.0) fCylPhi += TMath::Pi();
922 }
923 //----------------------------------------------------------------------
924 TPolyLine3D* AliITSgeomMatrix::CreateLocalAxis() const {
925     // This class is used as part of the documentation of this class
926     // Inputs:
927     //   none.
928     // Outputs:
929     //   none.
930     // Return:
931     //   A pointer to a new TPolyLine3D object showing the 3 line
932     //   segments that make up the this local axis in the global
933     //   reference system.
934     Float_t  gf[15];
935     Double_t g[5][3];
936     Double_t l[5][3]={{1.0,0.0,0.0},{0.0,0.0,0.0},{0.0,1.0,0.0},{0.0,0.0,0.0},
937                       {0.0,0.0,1.0}};
938     Int_t i;
939
940     for(i=0;i<5;i++) {
941         LtoGPosition(l[i],g[i]);
942         gf[3*i]=(Float_t)g[i][0];
943         gf[3*i+1]=(Float_t)g[i][1];
944         gf[3*i+2]=(Float_t)g[i][2];
945     } // end for i
946     return new TPolyLine3D(5,gf);
947 }
948 //----------------------------------------------------------------------
949 TPolyLine3D* AliITSgeomMatrix::CreateLocalAxisTracking() const {
950     // This class is used as part of the documentation of this class
951     // Inputs:
952     //   none.
953     // Outputs:
954     //   none.
955     // Return:
956     //   A pointer to a new TPolyLine3D object showing the 3 line
957     //   segments that make up the this local axis in the global
958     //   reference system.
959     Float_t gf[15];
960     Double_t g[5][3];
961     Double_t l[5][3]={{1.0,0.0,0.0},{0.0,0.0,0.0},{0.0,1.0,0.0},{0.0,0.0,0.0},
962                       {0.0,0.0,1.0}};
963     Int_t i;
964
965     for(i=0;i<5;i++) {
966         LtoGPositionTracking(l[i],g[i]);
967         gf[3*i]=(Float_t)g[i][0];
968         gf[3*i+1]=(Float_t)g[i][1];
969         gf[3*i+2]=(Float_t)g[i][2];
970     } // end for i
971     return new TPolyLine3D(5,gf);
972 }
973 //----------------------------------------------------------------------
974 TNode* AliITSgeomMatrix::CreateNode(const Char_t *nodeName,
975                                     const Char_t *nodeTitle,TNode *mother,
976                                     TShape *shape,Bool_t axis) const {
977     // Creates a node inside of the node mother out of the shape shape
978     // in the position, with respect to mother, indecated by "this". If axis
979     // is ture, it will insert an axis within this node/shape.
980     // Inputs:
981     //   Char_t *nodeName  This name of this node
982     //   Char_t *nodeTitle This node title
983     //   TNode  *mother    The node this node will be inside of/with respect to
984     //   TShape *shape     The shape of this node
985     //   Bool_t axis       If ture, a set of x,y,z axis will be included
986     // Outputs:
987     //   none.
988     // Return:
989     //   A pointer to "this" node.
990     Double_t trans[3],matrix[3][3],*matr;
991     TRotMatrix *rot = new TRotMatrix();
992     TString name,title;
993
994     matr = &(matrix[0][0]);
995     this->GetTranslation(trans);
996     this->GetMatrix(matrix);
997     rot->SetMatrix(matr);
998     //
999     name = nodeName;
1000     title = nodeTitle;
1001     //
1002     mother->cd();
1003     TNode *node1 = new TNode(name.Data(),title.Data(),shape,trans[0],trans[1],trans[2],rot);
1004     if(axis){
1005         Int_t i,j;
1006         const Float_t kScale=0.5,kLw=0.2;
1007         Float_t xchar[13][2]={{0.5*kLw,1.},{0.,0.5*kLw},{0.5-0.5*kLw,0.5},
1008                               {0.,0.5*kLw},{0.5*kLw,0.},{0.5,0.5-0.5*kLw},
1009                               {1-0.5*kLw,0.},{1.,0.5*kLw},{0.5+0.5*kLw,0.5},
1010                               {1.,1.-0.5*kLw},{1.-0.5*kLw,1.},{0.5,0.5+0.5*kLw},
1011                               {0.5*kLw,1.}};
1012         Float_t ychar[10][2]={{.5-0.5*kLw,0.},{.5+0.5*kLw,0.},{.5+0.5*kLw,0.5-0.5*kLw},
1013                               {1.,1.-0.5*kLw},{1.-0.5*kLw,1.},{0.5+0.5*kLw,0.5},
1014                               {0.5*kLw,1.}   ,{0.,1-0.5*kLw} ,{0.5-0.5*kLw,0.5},
1015                               {.5-0.5*kLw,0.}};
1016         Float_t zchar[11][2]={{0.,1.},{0,1.-kLw},{1.-kLw,1.-kLw},{0.,kLw}   ,{0.,0.},
1017                               {1.,0.},{1.,kLw}  ,{kLw,kLw}      ,{1.,1.-kLw},{1.,1.},
1018                               {0.,1.}};
1019         for(i=0;i<13;i++)for(j=0;j<2;j++){
1020             if(i<13) xchar[i][j] = kScale*xchar[i][j];
1021             if(i<10) ychar[i][j] = kScale*ychar[i][j];
1022             if(i<11) zchar[i][j] = kScale*zchar[i][j];
1023         } // end for i,j
1024         TXTRU *axisxl = new TXTRU("x","x","text",12,2);
1025         for(i=0;i<12;i++) axisxl->DefineVertex(i,xchar[i][0],xchar[i][1]);
1026         axisxl->DefineSection(0,-0.5*kLw);axisxl->DefineSection(1,0.5*kLw);
1027         TXTRU *axisyl = new TXTRU("y","y","text",9,2);
1028         for(i=0;i<9;i++) axisyl->DefineVertex(i,ychar[i][0],ychar[i][1]);
1029         axisyl->DefineSection(0,-0.5*kLw);axisyl->DefineSection(1,0.5*kLw);
1030         TXTRU *axiszl = new TXTRU("z","z","text",10,2);
1031         for(i=0;i<10;i++) axiszl->DefineVertex(i,zchar[i][0],zchar[i][1]);
1032         axiszl->DefineSection(0,-0.5*kLw);axiszl->DefineSection(1,0.5*kLw);
1033         Float_t lxy[13][2]={{-0.5*kLw,-0.5*kLw},{0.8,-0.5*kLw},{0.8,-0.1},{1.0,0.0},
1034                             {0.8,0.1},{0.8,0.5*kLw},{0.5*kLw,0.5*kLw},{0.5*kLw,0.8},
1035                             {0.1,0.8},{0.0,1.0},{-0.1,0.8},{-0.5*kLw,0.8},
1036                             {-0.5*kLw,-0.5*kLw}};
1037         TXTRU *axisxy = new TXTRU("axisxy","axisxy","text",13,2);
1038         for(i=0;i<13;i++) axisxy->DefineVertex(i,lxy[i][0],lxy[i][1]);
1039         axisxy->DefineSection(0,-0.5*kLw);axisxy->DefineSection(1,0.5*kLw);
1040         Float_t lz[8][2]={{0.5*kLw,-0.5*kLw},{0.8,-0.5*kLw},{0.8,-0.1},{1.0,0.0},
1041                            {0.8,0.1},{0.8,0.5*kLw},{0.5*kLw,0.5*kLw},
1042                            {0.5*kLw,-0.5*kLw}};
1043         TXTRU *axisz = new TXTRU("axisz","axisz","text",8,2);
1044         for(i=0;i<8;i++) axisz->DefineVertex(i,lz[i][0],lz[i][1]);
1045         axisz->DefineSection(0,-0.5*kLw);axisz->DefineSection(1,0.5*kLw);
1046         //TRotMatrix *xaxis90= new TRotMatrix("xaixis90","",90.0, 0.0, 0.0);
1047         TRotMatrix *yaxis90= new TRotMatrix("yaixis90","", 0.0,90.0, 0.0);
1048         TRotMatrix *zaxis90= new TRotMatrix("zaixis90","", 0.0, 0.0,90.0);
1049         //
1050         node1->cd();
1051         title = name.Append("axisxy");
1052         TNode *nodeaxy = new TNode(title.Data(),title.Data(),axisxy);
1053         title = name.Append("axisz");
1054         TNode *nodeaz = new TNode(title.Data(),title.Data(),axisz,0.,0.,0.,yaxis90);
1055         TNode *textboxX0 = new TNode("textboxX0","textboxX0",axisxl,
1056                                     lxy[3][0],lxy[3][1],0.0);
1057         TNode *textboxX1 = new TNode("textboxX1","textboxX1",axisxl,
1058                                     lxy[3][0],lxy[3][1],0.0,yaxis90);
1059         TNode *textboxX2 = new TNode("textboxX2","textboxX2",axisxl,
1060                                     lxy[3][0],lxy[3][1],0.0,zaxis90);
1061         TNode *textboxY0 = new TNode("textboxY0","textboxY0",axisyl,
1062                                     lxy[9][0],lxy[9][1],0.0);
1063         TNode *textboxY1 = new TNode("textboxY1","textboxY1",axisyl,
1064                                     lxy[9][0],lxy[9][1],0.0,yaxis90);
1065         TNode *textboxY2 = new TNode("textboxY2","textboxY2",axisyl,
1066                                     lxy[9][0],lxy[9][1],0.0,zaxis90);
1067         TNode *textboxZ0 = new TNode("textboxZ0","textboxZ0",axiszl,
1068                                     0.0,0.0,lz[3][0]);
1069         TNode *textboxZ1 = new TNode("textboxZ1","textboxZ1",axiszl,
1070                                     0.0,0.0,lz[3][0],yaxis90);
1071         TNode *textboxZ2 = new TNode("textboxZ2","textboxZ2",axiszl,
1072                                     0.0,0.0,lz[3][0],zaxis90);
1073         nodeaxy->Draw();
1074         nodeaz->Draw();
1075         textboxX0->Draw();
1076         textboxX1->Draw();
1077         textboxX2->Draw();
1078         textboxY0->Draw();
1079         textboxY1->Draw();
1080         textboxY2->Draw();
1081         textboxZ0->Draw();
1082         textboxZ1->Draw();
1083         textboxZ2->Draw();
1084     } // end if
1085     mother->cd();
1086     return node1;
1087 }
1088 //----------------------------------------------------------------------
1089 void AliITSgeomMatrix::MakeFigures() const {
1090     // make figures to help document this class
1091     // Inputs:
1092     //   none.
1093     // Outputs:
1094     //   none.
1095     // Return:
1096     //   none.
1097     const Double_t kDx0=550.,kDy0=550.,kDz0=550.; // cm
1098     const Double_t kDx=1.0,kDy=0.300,kDz=3.0,kRmax=0.1; // cm
1099     Float_t l[5][3]={{1.0,0.0,0.0},{0.0,0.0,0.0},{0.0,1.0,0.0},{0.0,0.0,0.0},
1100                       {0.0,0.0,1.0}};
1101     TCanvas *c = new TCanvas(kFALSE);// create a batch mode canvas.
1102     TView   *view = new TView(1); // Create Cartesian coordiante view
1103     TBRIK   *mother  = new TBRIK("Mother","Mother","void",kDx0,kDy0,kDz0);
1104     TBRIK   *det  = new TBRIK("Detector","","Si",kDx,kDy,kDz);
1105     TPolyLine3D *axis = new TPolyLine3D(5,&(l[0][0]));
1106     TPCON *arrow      = new TPCON("arrow","","air",0.0,360.,2);
1107     TRotMatrix *xarrow= new TRotMatrix("xarrow","",90.,0.0,0.0);
1108     TRotMatrix *yarrow= new TRotMatrix("yarrow","",0.0,90.,0.0);
1109
1110     det->SetLineColor(0); // black
1111     det->SetLineStyle(1); // solid line
1112     det->SetLineWidth(2); // pixel units
1113     det->SetFillColor(1); // black
1114     det->SetFillStyle(4010); // window is 90% transparent
1115     arrow->SetLineColor(det->GetLineColor());
1116     arrow->SetLineWidth(det->GetLineWidth());
1117     arrow->SetLineStyle(det->GetLineStyle());
1118     arrow->SetFillColor(1); // black
1119     arrow->SetFillStyle(4100); // window is 100% opaque
1120     arrow->DefineSection(0,0.0,0.0,kRmax);
1121     arrow->DefineSection(1,2.*kRmax,0.0,0.0);
1122     view->SetRange(-kDx0,-kDy0,-kDz0,kDx0,kDy0,kDz0);
1123     //
1124     TNode *node0 = new TNode("NODE0","NODE0",mother);
1125     node0->cd();
1126     TNode *node1 = new TNode("NODE1","NODE1",det);
1127     node1->cd();
1128     TNode *nodex = new TNode("NODEx","NODEx",arrow,l[0][0],l[0][1],l[0][2],xarrow);
1129     TNode *nodey = new TNode("NODEy","NODEy",arrow,l[2][0],l[2][1],l[2][2],yarrow);
1130     TNode *nodez = new TNode("NODEz","NODEz",arrow,l[4][0],l[4][1],l[4][2]);
1131     //
1132     axis->Draw();
1133     nodex->Draw();
1134     nodey->Draw();
1135     nodez->Draw();
1136     
1137     //
1138     node0->cd();
1139     node0->Draw();
1140     c->Update();
1141     c->SaveAs("AliITSgeomMatrix_L1.gif");
1142 }
1143 //----------------------------------------------------------------------
1144 ostream &operator<<(ostream &os,AliITSgeomMatrix &p){
1145     // Standard output streaming function.
1146     // Inputs:
1147     //    ostream &os          The output stream to print the class data on
1148     //    AliITSgeomMatrix &p  This class
1149     // Outputs:
1150     //    none.
1151     // Return:
1152     //    none.
1153
1154     p.Print(&os);
1155     return os;
1156 }
1157 //----------------------------------------------------------------------
1158 istream &operator>>(istream &is,AliITSgeomMatrix &r){
1159     // Standard input streaming function.
1160     // Inputs:
1161     //    ostream &os          The input stream to print the class data on
1162     //    AliITSgeomMatrix &p  This class
1163     // Outputs:
1164     //    none.
1165     // Return:
1166     //    none.
1167
1168     r.Read(&is);
1169     return is;
1170 }
1171 //----------------------------------------------------------------------