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