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