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