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