Last cosmetic changes
[u/mrichter/AliRoot.git] / HLT / src / AliL3Transform.cxx
CommitLineData
b661165c 1// Author: Anders Vestbo <mailto:vestbo@fi.uib.no>, Uli Frankenfeld <mailto:franken@fi.uib.no>
2//*-- Copyright &copy ASV
108615fc 3
4#include "AliL3Logging.h"
5#include "AliL3Transform.h"
6//#include <TFile.h>
7#include <math.h>
b661165c 8
9//_____________________________________________________________
108615fc 10// AliL3Transform
11//
12// Transformation class for ALICE TPC.
13
14ClassImp(AliL3Transform);
15
16
17AliL3Transform::AliL3Transform(){
18 //constructor
19 Init();
20}
21
22
23AliL3Transform::~AliL3Transform(){
24}
25
a4982538 26void AliL3Transform::Init(){
27 //sector:
28 fNTimeBins = 446;
29 fNRowLow = 64;
30 fNRowUp = 112;
31 fNSectorLow = 36;
32 fNSectorUp = 36;
33 fNSector = 72;
34 fPadPitchWidthLow = 0.400000;
35 fPadPitchWidthUp = 0.600000;
36 fZWidth = 0.56599998474121093750;
37 fZSigma = 0.22880849748219134199;
38
39 //slices:
40 fNSlice = 36;
41 fNRow = 176;
42 fPi = 3.141592653589793;
40f2887b 43/*
a4982538 44 for(Int_t i=0;i<36;i++){
45 fCos[i] = cos(fPi/9*i);
46 fSin[i] = sin(fPi/9*i);
47 }
40f2887b 48*/
49 for(Int_t i=0;i<36;i++){
50 fCos[i] = cos( (2*fPi/18) * (i+0.5) );
51 fSin[i] = sin( (2*fPi/18) * (i+0.5) );
52 }
a4982538 53
54 fX[0] = 84.570007324218750;
55 fX[1] = 85.320007324218750;
56 fX[2] = 86.070007324218750;
57 fX[3] = 86.820007324218750;
58 fX[4] = 87.570007324218750;
59 fX[5] = 88.320007324218750;
60 fX[6] = 89.070007324218750;
61 fX[7] = 89.820007324218750;
62 fX[8] = 90.570007324218750;
63 fX[9] = 91.320007324218750;
64 fX[10] = 92.070007324218750;
65 fX[11] = 92.820007324218750;
66 fX[12] = 93.570007324218750;
67 fX[13] = 94.320007324218750;
68 fX[14] = 95.070007324218750;
69 fX[15] = 95.820007324218750;
70 fX[16] = 96.570007324218750;
71 fX[17] = 97.320007324218750;
72 fX[18] = 98.070007324218750;
73 fX[19] = 98.820007324218750;
74 fX[20] = 99.570007324218750;
75 fX[21] = 100.320007324218750;
76 fX[22] = 101.070007324218750;
77 fX[23] = 101.820007324218750;
78 fX[24] = 102.570007324218750;
79 fX[25] = 103.320007324218750;
80 fX[26] = 104.070007324218750;
81 fX[27] = 104.820007324218750;
82 fX[28] = 105.570007324218750;
83 fX[29] = 106.320007324218750;
84 fX[30] = 107.070007324218750;
85 fX[31] = 107.820007324218750;
86 fX[32] = 108.570007324218750;
87 fX[33] = 109.320007324218750;
88 fX[34] = 110.070007324218750;
89 fX[35] = 110.820007324218750;
90 fX[36] = 111.570007324218750;
91 fX[37] = 112.320007324218750;
92 fX[38] = 113.070007324218750;
93 fX[39] = 113.820007324218750;
94 fX[40] = 114.570007324218750;
95 fX[41] = 115.320007324218750;
96 fX[42] = 116.070007324218750;
97 fX[43] = 116.820007324218750;
98 fX[44] = 117.570007324218750;
99 fX[45] = 118.320007324218750;
100 fX[46] = 119.070007324218750;
101 fX[47] = 119.820007324218750;
102 fX[48] = 120.570007324218750;
103 fX[49] = 121.320007324218750;
104 fX[50] = 122.070007324218750;
105 fX[51] = 122.820007324218750;
106 fX[52] = 123.570007324218750;
107 fX[53] = 124.320007324218750;
108 fX[54] = 125.070007324218750;
109 fX[55] = 125.820007324218750;
110 fX[56] = 126.570007324218750;
111 fX[57] = 127.320007324218750;
112 fX[58] = 128.070007324218750;
113 fX[59] = 128.820007324218750;
114 fX[60] = 129.570007324218750;
115 fX[61] = 130.320007324218750;
116 fX[62] = 131.070007324218750;
117 fX[63] = 131.820007324218750;
118 fX[64] = 135.054992675781250;
119 fX[65] = 136.054992675781250;
120 fX[66] = 137.054992675781250;
121 fX[67] = 138.054992675781250;
122 fX[68] = 139.054992675781250;
123 fX[69] = 140.054992675781250;
124 fX[70] = 141.054992675781250;
125 fX[71] = 142.054992675781250;
126 fX[72] = 143.054992675781250;
127 fX[73] = 144.054992675781250;
128 fX[74] = 145.054992675781250;
129 fX[75] = 146.054992675781250;
130 fX[76] = 147.054992675781250;
131 fX[77] = 148.054992675781250;
132 fX[78] = 149.054992675781250;
133 fX[79] = 150.054992675781250;
134 fX[80] = 151.054992675781250;
135 fX[81] = 152.054992675781250;
136 fX[82] = 153.054992675781250;
137 fX[83] = 154.054992675781250;
138 fX[84] = 155.054992675781250;
139 fX[85] = 156.054992675781250;
140 fX[86] = 157.054992675781250;
141 fX[87] = 158.054992675781250;
142 fX[88] = 159.054992675781250;
143 fX[89] = 160.054992675781250;
144 fX[90] = 161.054992675781250;
145 fX[91] = 162.054992675781250;
146 fX[92] = 163.054992675781250;
147 fX[93] = 164.054992675781250;
148 fX[94] = 165.054992675781250;
149 fX[95] = 166.054992675781250;
150 fX[96] = 167.054992675781250;
151 fX[97] = 168.054992675781250;
152 fX[98] = 169.054992675781250;
153 fX[99] = 170.054992675781250;
154 fX[100] = 171.054992675781250;
155 fX[101] = 172.054992675781250;
156 fX[102] = 173.054992675781250;
157 fX[103] = 174.054992675781250;
158 fX[104] = 175.054992675781250;
159 fX[105] = 176.054992675781250;
160 fX[106] = 177.054992675781250;
161 fX[107] = 178.054992675781250;
162 fX[108] = 179.054992675781250;
163 fX[109] = 180.054992675781250;
164 fX[110] = 181.054992675781250;
165 fX[111] = 182.054992675781250;
166 fX[112] = 183.054992675781250;
167 fX[113] = 184.054992675781250;
168 fX[114] = 185.054992675781250;
169 fX[115] = 186.054992675781250;
170 fX[116] = 187.054992675781250;
171 fX[117] = 188.054992675781250;
172 fX[118] = 189.054992675781250;
173 fX[119] = 190.054992675781250;
174 fX[120] = 191.054992675781250;
175 fX[121] = 192.054992675781250;
176 fX[122] = 193.054992675781250;
177 fX[123] = 194.054992675781250;
178 fX[124] = 195.054992675781250;
179 fX[125] = 196.054992675781250;
180 fX[126] = 197.054992675781250;
181 fX[127] = 198.054992675781250;
182 fX[128] = 199.054992675781250;
183 fX[129] = 200.054992675781250;
184 fX[130] = 201.054992675781250;
185 fX[131] = 202.054992675781250;
186 fX[132] = 203.054992675781250;
187 fX[133] = 204.054992675781250;
188 fX[134] = 205.054992675781250;
189 fX[135] = 206.054992675781250;
190 fX[136] = 207.054992675781250;
191 fX[137] = 208.054992675781250;
192 fX[138] = 209.054992675781250;
193 fX[139] = 210.054992675781250;
194 fX[140] = 211.054992675781250;
195 fX[141] = 212.054992675781250;
196 fX[142] = 213.054992675781250;
197 fX[143] = 214.054992675781250;
198 fX[144] = 215.054992675781250;
199 fX[145] = 216.054992675781250;
200 fX[146] = 217.054992675781250;
201 fX[147] = 218.054992675781250;
202 fX[148] = 219.054992675781250;
203 fX[149] = 220.054992675781250;
204 fX[150] = 221.054992675781250;
205 fX[151] = 222.054992675781250;
206 fX[152] = 223.054992675781250;
207 fX[153] = 224.054992675781250;
208 fX[154] = 225.054992675781250;
209 fX[155] = 226.054992675781250;
210 fX[156] = 227.054992675781250;
211 fX[157] = 228.054992675781250;
212 fX[158] = 229.054992675781250;
213 fX[159] = 230.054992675781250;
214 fX[160] = 231.054992675781250;
215 fX[161] = 232.054992675781250;
216 fX[162] = 233.054992675781250;
217 fX[163] = 234.054992675781250;
218 fX[164] = 235.054992675781250;
219 fX[165] = 236.054992675781250;
220 fX[166] = 237.054992675781250;
221 fX[167] = 238.054992675781250;
222 fX[168] = 239.054992675781250;
223 fX[169] = 240.054992675781250;
224 fX[170] = 241.054992675781250;
225 fX[171] = 242.054992675781250;
226 fX[172] = 243.054992675781250;
227 fX[173] = 244.054992675781250;
228 fX[174] = 245.054992675781250;
229 fX[175] = 246.054992675781250;
230 fNPads[0] = 67;
231 fNPads[1] = 67;
232 fNPads[2] = 67;
233 fNPads[3] = 69;
234 fNPads[4] = 69;
235 fNPads[5] = 69;
236 fNPads[6] = 71;
237 fNPads[7] = 71;
238 fNPads[8] = 71;
239 fNPads[9] = 73;
240 fNPads[10] = 73;
241 fNPads[11] = 73;
242 fNPads[12] = 75;
243 fNPads[13] = 75;
244 fNPads[14] = 75;
245 fNPads[15] = 77;
246 fNPads[16] = 77;
247 fNPads[17] = 77;
248 fNPads[18] = 79;
249 fNPads[19] = 79;
250 fNPads[20] = 79;
251 fNPads[21] = 81;
252 fNPads[22] = 81;
253 fNPads[23] = 81;
254 fNPads[24] = 83;
255 fNPads[25] = 83;
256 fNPads[26] = 83;
257 fNPads[27] = 85;
258 fNPads[28] = 85;
259 fNPads[29] = 85;
260 fNPads[30] = 87;
261 fNPads[31] = 87;
262 fNPads[32] = 87;
263 fNPads[33] = 89;
264 fNPads[34] = 89;
265 fNPads[35] = 89;
266 fNPads[36] = 91;
267 fNPads[37] = 91;
268 fNPads[38] = 91;
269 fNPads[39] = 93;
270 fNPads[40] = 93;
271 fNPads[41] = 93;
272 fNPads[42] = 95;
273 fNPads[43] = 95;
274 fNPads[44] = 95;
275 fNPads[45] = 97;
276 fNPads[46] = 97;
277 fNPads[47] = 97;
278 fNPads[48] = 99;
279 fNPads[49] = 99;
280 fNPads[50] = 99;
281 fNPads[51] = 101;
282 fNPads[52] = 101;
283 fNPads[53] = 101;
284 fNPads[54] = 103;
285 fNPads[55] = 103;
286 fNPads[56] = 103;
287 fNPads[57] = 105;
288 fNPads[58] = 105;
289 fNPads[59] = 105;
290 fNPads[60] = 107;
291 fNPads[61] = 107;
292 fNPads[62] = 107;
293 fNPads[63] = 109;
294 fNPads[64] = 73;
295 fNPads[65] = 75;
296 fNPads[66] = 75;
297 fNPads[67] = 75;
298 fNPads[68] = 77;
299 fNPads[69] = 77;
300 fNPads[70] = 77;
301 fNPads[71] = 77;
302 fNPads[72] = 79;
303 fNPads[73] = 79;
304 fNPads[74] = 79;
305 fNPads[75] = 81;
306 fNPads[76] = 81;
307 fNPads[77] = 81;
308 fNPads[78] = 83;
309 fNPads[79] = 83;
310 fNPads[80] = 83;
311 fNPads[81] = 83;
312 fNPads[82] = 85;
313 fNPads[83] = 85;
314 fNPads[84] = 85;
315 fNPads[85] = 87;
316 fNPads[86] = 87;
317 fNPads[87] = 87;
318 fNPads[88] = 87;
319 fNPads[89] = 89;
320 fNPads[90] = 89;
321 fNPads[91] = 89;
322 fNPads[92] = 91;
323 fNPads[93] = 91;
324 fNPads[94] = 91;
325 fNPads[95] = 93;
326 fNPads[96] = 93;
327 fNPads[97] = 93;
328 fNPads[98] = 93;
329 fNPads[99] = 95;
330 fNPads[100] = 95;
331 fNPads[101] = 95;
332 fNPads[102] = 97;
333 fNPads[103] = 97;
334 fNPads[104] = 97;
335 fNPads[105] = 97;
336 fNPads[106] = 99;
337 fNPads[107] = 99;
338 fNPads[108] = 99;
339 fNPads[109] = 101;
340 fNPads[110] = 101;
341 fNPads[111] = 101;
342 fNPads[112] = 103;
343 fNPads[113] = 103;
344 fNPads[114] = 103;
345 fNPads[115] = 103;
346 fNPads[116] = 105;
347 fNPads[117] = 105;
348 fNPads[118] = 105;
349 fNPads[119] = 107;
350 fNPads[120] = 107;
351 fNPads[121] = 107;
352 fNPads[122] = 107;
353 fNPads[123] = 109;
354 fNPads[124] = 109;
355 fNPads[125] = 109;
356 fNPads[126] = 111;
357 fNPads[127] = 111;
358 fNPads[128] = 111;
359 fNPads[129] = 113;
360 fNPads[130] = 113;
361 fNPads[131] = 113;
362 fNPads[132] = 113;
363 fNPads[133] = 115;
364 fNPads[134] = 115;
365 fNPads[135] = 115;
366 fNPads[136] = 117;
367 fNPads[137] = 117;
368 fNPads[138] = 117;
369 fNPads[139] = 117;
370 fNPads[140] = 119;
371 fNPads[141] = 119;
372 fNPads[142] = 119;
373 fNPads[143] = 121;
374 fNPads[144] = 121;
375 fNPads[145] = 121;
376 fNPads[146] = 123;
377 fNPads[147] = 123;
378 fNPads[148] = 123;
379 fNPads[149] = 123;
380 fNPads[150] = 125;
381 fNPads[151] = 125;
382 fNPads[152] = 125;
383 fNPads[153] = 127;
384 fNPads[154] = 127;
385 fNPads[155] = 127;
386 fNPads[156] = 127;
387 fNPads[157] = 129;
388 fNPads[158] = 129;
389 fNPads[159] = 129;
390 fNPads[160] = 131;
391 fNPads[161] = 131;
392 fNPads[162] = 131;
393 fNPads[163] = 133;
394 fNPads[164] = 133;
395 fNPads[165] = 133;
396 fNPads[166] = 133;
397 fNPads[167] = 135;
398 fNPads[168] = 135;
399 fNPads[169] = 135;
400 fNPads[170] = 137;
401 fNPads[171] = 137;
402 fNPads[172] = 137;
403 fNPads[173] = 137;
404 fNPads[174] = 139;
405 fNPads[175] = 139;
406}
108615fc 407
408Double_t AliL3Transform::GetEta(Float_t *xyz)
409{
410 Double_t r3 = sqrt(xyz[0]*xyz[0]+xyz[1]*xyz[1]+xyz[2]*xyz[2]);
411 Double_t eta = 0.5 * log((r3+xyz[2])/(r3-xyz[2]));
412 return eta;
413}
414
3a1c3849 415Double_t AliL3Transform::GetEta(Int_t padrow,Int_t pad,Int_t time)
bd7e82e0 416{
417 Float_t xyz[3];
3a1c3849 418 Int_t sector,row;
419 Slice2Sector(0,padrow,sector,row);
420 Raw2Local(xyz,sector,row,pad,time);
bd7e82e0 421
422 return GetEta(xyz);
423}
424
425
108615fc 426Double_t AliL3Transform::GetPhi(Float_t *xyz)
427{
428
429 Double_t phi = atan2(xyz[1],xyz[0]);
430 //if(phi<0) phi=phi+2*TMath::Pi();
431 return phi;
432}
433
434
435Bool_t AliL3Transform::Slice2Sector(Int_t slice, Int_t slicerow, Int_t & sector, Int_t &row) const{
436 if(slicerow<0&&slicerow>=fNRow) return kFALSE;
437 if(slice<0||slice>=fNSlice) return kFALSE;
438
439 if(slicerow<fNRowLow){
440 sector = slice;
441 row = slicerow;
442 }
443 else {
444 sector = slice+fNSlice;
445 row = slicerow-fNRowLow;
446 }
447 return kTRUE;
448}
449
450Bool_t AliL3Transform::Sector2Slice(Int_t & slice, Int_t sector) const{
451 if(sector<0||sector>=fNSector) return kFALSE;
452 if(sector<fNSectorLow) slice = sector;
453 else slice = sector - fNSectorLow;
454 return kTRUE;
455}
456
457Bool_t AliL3Transform::Sector2Slice(Int_t & slice, Int_t & slicerow,Int_t sector, Int_t row) const{
458 if(sector<0||sector>=fNSector||row<0) return kFALSE;
459 if(sector<fNSectorLow){
460 if(row>=fNRowLow) return kFALSE;
461 slice = sector;
462 slicerow = row;
463 }
464 else{
465 if(row>=fNRowUp) return kFALSE;
466 slice = sector - fNSectorLow;
467 slicerow = row + fNRowLow;
468 }
469 return kTRUE;
470}
471
472Double_t AliL3Transform::Row2X(Int_t slicerow){
473 if(slicerow<0||slicerow>=fNRow) return 0;
474 return fX[slicerow];
475}
476
477void AliL3Transform::Local2Global(Float_t *xyz,Int_t slice)
478{
479 //Transformation to global coordinate system
480 Float_t x0 = xyz[0];
481 Float_t y0 = xyz[1];
482 Float_t cs,sn;
483 cs = fCos[slice];
484 sn = fSin[slice];
485 xyz[0]=x0*cs-y0*sn;
486 xyz[1]=x0*sn+y0*cs;
487 xyz[2]=xyz[2];//global z=local z
488}
489
490void AliL3Transform::Local2GlobalAngle(Float_t *angle,Int_t slice){
40f2887b 491 angle[0] = fmod(angle[0]+(slice+0.5)*(2*fPi/18),2*fPi);
108615fc 492}
493
494void AliL3Transform::Global2LocalAngle(Float_t *angle,Int_t slice){
40f2887b 495 angle[0] = angle[0]-(slice+0.5)*(2*fPi/18);
108615fc 496 if(angle[0]<0) angle[0]+=2*fPi;
497}
498
499void AliL3Transform::Raw2Local(Float_t *xyz,Int_t sector,Int_t row,Float_t pad,Float_t time)
500{
501 //Transformation from rawdata to local coordinate system
502
503 Int_t slice,slicerow;
504 Sector2Slice(slice, slicerow, sector, row);
505
506 xyz[0]=Row2X(slicerow);
507 Int_t npads= fNPads[slicerow];
508 if(sector<fNSectorLow)
509 xyz[1]=(pad-0.5*(npads-1))*fPadPitchWidthLow;
510 else
511 xyz[1]=(pad-0.5*(npads-1))*fPadPitchWidthUp;
512 xyz[2]=fZWidth*time-3.*fZSigma;
1c225117 513 Int_t sign=1;
514
515
0e0b1e59 516 if(slice < 18)
517 sign = 1;
518 else
519 sign = -1;
0e0b1e59 520
1c225117 521 xyz[2]=sign*(250.-xyz[2]);
0e0b1e59 522
523 //Int_t nis=fNSectorLow;
524 //Int_t nos=fNSectorUp;
525 //if((sector<nis)/2 || ((sector-nis)<nos/2)) sign=1;
526
108615fc 527}
528
529void AliL3Transform::Local2Global(Float_t *xyz,Int_t sector,Int_t row)
530{
531 //Transformation to global coordinate system
532 Int_t slice,slicerow;
533 Sector2Slice(slice, slicerow, sector, row);
534 Float_t r=Row2X(slicerow);
535 Float_t cs = fCos[slice];
536 Float_t sn = fSin[slice];
537
538 xyz[0]=r*cs-xyz[1]*sn;
539 xyz[1]=r*sn+xyz[1]*cs;
540 xyz[2]=xyz[2];//global z=local z
541}
542
543Double_t AliL3Transform::GetMaxY(Int_t slicerow)
544{
545
546 if(slicerow < fNRowLow)
547 return fPadPitchWidthLow*fNPads[slicerow]/2;
548
549 else
550 return fPadPitchWidthUp*fNPads[slicerow]/2;
551}
552
2342214c 553void AliL3Transform::Global2Local(Float_t *xyz,Int_t sector,Bool_t isSlice)
108615fc 554{
2342214c 555
108615fc 556 Int_t slice;
2342214c 557 if(!isSlice)
558 Sector2Slice(slice, sector);
559 else
560 slice = sector;
108615fc 561 Float_t cs = fCos[slice];
562 Float_t sn = fSin[slice];
563 Float_t x1 = xyz[0]*cs + xyz[1]*sn;
564 Float_t y1 = -xyz[0]*sn + xyz[1]*cs;
565 xyz[0] = x1;
566 xyz[1] = y1;
567}
568
569void AliL3Transform::Raw2Global(Float_t *xyz,Int_t sector,Int_t row,Float_t pad,Float_t time)
570{
571 //Transformation from raw to global coordinates
572
573 Raw2Local(xyz,sector,row,pad,time);
574 Local2Global(xyz,sector,row);
575}
576
577void AliL3Transform::Local2Raw(Float_t *xyz,Int_t sector,Int_t row)
578{
579 //Transformation from local coordinates to raw
580
581 Int_t slice,slicerow;
582 Sector2Slice(slice, slicerow, sector, row);
583
584 if(sector<fNSectorLow)
585 xyz[1]=xyz[1]/fPadPitchWidthLow+0.5*(fNPads[slicerow]-1);
586 else
587 xyz[1]=xyz[1]/fPadPitchWidthUp+0.5*(fNPads[slicerow]-1);
588 Int_t sign=-1;
589 Int_t nis=fNSectorLow;
590 Int_t nos=fNSectorUp;
591
592 if ((sector<nis/2) || ((sector-nis)<nos/2)) sign=1;
593 xyz[2]=250-sign*xyz[2];
594 xyz[2]=(xyz[2]+3.*fZSigma)/fZWidth;
595}
596
597void AliL3Transform::Global2Raw(Float_t *xyz,Int_t sector,Int_t row)
598{
599 //Transformation from global coordinates to raw.
600
601 Global2Local(xyz,sector);
602 Local2Raw(xyz,sector,row);
603
604}