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