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