Added new base class
[u/mrichter/AliRoot.git] / HLT / hough / AliL3Transform.cxx
CommitLineData
4de874d1 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
27void AliL3Transform::Init(){
28 //sector:
29 fNTimeBins = 512; //?uli
30 fNRowLow = 55;
31 fNRowUp = 119;
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 = 174;
43 fPi = 3.14159265358979323846;
44 for(Int_t i=0;i<36;i++){
45 fCos[i] = cos(fPi/9*i);
46 fSin[i] = sin(fPi/9*i);
47 }
48
49 fX[0] = 88.850006103515625;
50 fX[1] = 89.600006103515625;
51 fX[2] = 90.350006103515625;
52 fX[3] = 91.100006103515625;
53 fX[4] = 91.850006103515625;
54 fX[5] = 92.600006103515625;
55 fX[6] = 93.350006103515625;
56 fX[7] = 94.100006103515625;
57 fX[8] = 94.850006103515625;
58 fX[9] = 95.600006103515625;
59 fX[10] = 96.350006103515625;
60 fX[11] = 97.100006103515625;
61 fX[12] = 97.850006103515625;
62 fX[13] = 98.600006103515625;
63 fX[14] = 99.350006103515625;
64 fX[15] = 100.100006103515625;
65 fX[16] = 100.850006103515625;
66 fX[17] = 101.600006103515625;
67 fX[18] = 102.350006103515625;
68 fX[19] = 103.100006103515625;
69 fX[20] = 103.850006103515625;
70 fX[21] = 104.600006103515625;
71 fX[22] = 105.350006103515625;
72 fX[23] = 106.100006103515625;
73 fX[24] = 106.850006103515625;
74 fX[25] = 107.600006103515625;
75 fX[26] = 108.350006103515625;
76 fX[27] = 109.100006103515625;
77 fX[28] = 109.850006103515625;
78 fX[29] = 110.600006103515625;
79 fX[30] = 111.350006103515625;
80 fX[31] = 112.100006103515625;
81 fX[32] = 112.850006103515625;
82 fX[33] = 113.600006103515625;
83 fX[34] = 114.350006103515625;
84 fX[35] = 115.100006103515625;
85 fX[36] = 115.850006103515625;
86 fX[37] = 116.600006103515625;
87 fX[38] = 117.350006103515625;
88 fX[39] = 118.100006103515625;
89 fX[40] = 118.850006103515625;
90 fX[41] = 119.600006103515625;
91 fX[42] = 120.350006103515625;
92 fX[43] = 121.100006103515625;
93 fX[44] = 121.850006103515625;
94 fX[45] = 122.600006103515625;
95 fX[46] = 123.350006103515625;
96 fX[47] = 124.100006103515625;
97 fX[48] = 124.850006103515625;
98 fX[49] = 125.600006103515625;
99 fX[50] = 126.350006103515625;
100 fX[51] = 127.100006103515625;
101 fX[52] = 127.850006103515625;
102 fX[53] = 128.600006103515625;
103 fX[54] = 129.350006103515625;
104 fX[55] = 132.574996948242188;
105 fX[56] = 133.574996948242188;
106 fX[57] = 134.574996948242188;
107 fX[58] = 135.574996948242188;
108 fX[59] = 136.574996948242188;
109 fX[60] = 137.574996948242188;
110 fX[61] = 138.574996948242188;
111 fX[62] = 139.574996948242188;
112 fX[63] = 140.574996948242188;
113 fX[64] = 141.574996948242188;
114 fX[65] = 142.574996948242188;
115 fX[66] = 143.574996948242188;
116 fX[67] = 144.574996948242188;
117 fX[68] = 145.574996948242188;
118 fX[69] = 146.574996948242188;
119 fX[70] = 147.574996948242188;
120 fX[71] = 148.574996948242188;
121 fX[72] = 149.574996948242188;
122 fX[73] = 150.574996948242188;
123 fX[74] = 151.574996948242188;
124 fX[75] = 152.574996948242188;
125 fX[76] = 153.574996948242188;
126 fX[77] = 154.574996948242188;
127 fX[78] = 155.574996948242188;
128 fX[79] = 156.574996948242188;
129 fX[80] = 157.574996948242188;
130 fX[81] = 158.574996948242188;
131 fX[82] = 159.574996948242188;
132 fX[83] = 160.574996948242188;
133 fX[84] = 161.574996948242188;
134 fX[85] = 162.574996948242188;
135 fX[86] = 163.574996948242188;
136 fX[87] = 164.574996948242188;
137 fX[88] = 165.574996948242188;
138 fX[89] = 166.574996948242188;
139 fX[90] = 167.574996948242188;
140 fX[91] = 168.574996948242188;
141 fX[92] = 169.574996948242188;
142 fX[93] = 170.574996948242188;
143 fX[94] = 171.574996948242188;
144 fX[95] = 172.574996948242188;
145 fX[96] = 173.574996948242188;
146 fX[97] = 174.574996948242188;
147 fX[98] = 175.574996948242188;
148 fX[99] = 176.574996948242188;
149 fX[100] = 177.574996948242188;
150 fX[101] = 178.574996948242188;
151 fX[102] = 179.574996948242188;
152 fX[103] = 180.574996948242188;
153 fX[104] = 181.574996948242188;
154 fX[105] = 182.574996948242188;
155 fX[106] = 183.574996948242188;
156 fX[107] = 184.574996948242188;
157 fX[108] = 185.574996948242188;
158 fX[109] = 186.574996948242188;
159 fX[110] = 187.574996948242188;
160 fX[111] = 188.574996948242188;
161 fX[112] = 189.574996948242188;
162 fX[113] = 190.574996948242188;
163 fX[114] = 191.574996948242188;
164 fX[115] = 192.574996948242188;
165 fX[116] = 193.574996948242188;
166 fX[117] = 194.574996948242188;
167 fX[118] = 195.574996948242188;
168 fX[119] = 196.574996948242188;
169 fX[120] = 197.574996948242188;
170 fX[121] = 198.574996948242188;
171 fX[122] = 199.574996948242188;
172 fX[123] = 200.574996948242188;
173 fX[124] = 201.574996948242188;
174 fX[125] = 202.574996948242188;
175 fX[126] = 203.574996948242188;
176 fX[127] = 204.574996948242188;
177 fX[128] = 205.574996948242188;
178 fX[129] = 206.574996948242188;
179 fX[130] = 207.574996948242188;
180 fX[131] = 208.574996948242188;
181 fX[132] = 209.574996948242188;
182 fX[133] = 210.574996948242188;
183 fX[134] = 211.574996948242188;
184 fX[135] = 212.574996948242188;
185 fX[136] = 213.574996948242188;
186 fX[137] = 214.574996948242188;
187 fX[138] = 215.574996948242188;
188 fX[139] = 216.574996948242188;
189 fX[140] = 217.574996948242188;
190 fX[141] = 218.574996948242188;
191 fX[142] = 219.574996948242188;
192 fX[143] = 220.574996948242188;
193 fX[144] = 221.574996948242188;
194 fX[145] = 222.574996948242188;
195 fX[146] = 223.574996948242188;
196 fX[147] = 224.574996948242188;
197 fX[148] = 225.574996948242188;
198 fX[149] = 226.574996948242188;
199 fX[150] = 227.574996948242188;
200 fX[151] = 228.574996948242188;
201 fX[152] = 229.574996948242188;
202 fX[153] = 230.574996948242188;
203 fX[154] = 231.574996948242188;
204 fX[155] = 232.574996948242188;
205 fX[156] = 233.574996948242188;
206 fX[157] = 234.574996948242188;
207 fX[158] = 235.574996948242188;
208 fX[159] = 236.574996948242188;
209 fX[160] = 237.574996948242188;
210 fX[161] = 238.574996948242188;
211 fX[162] = 239.574996948242188;
212 fX[163] = 240.574996948242188;
213 fX[164] = 241.574996948242188;
214 fX[165] = 242.574996948242188;
215 fX[166] = 243.574996948242188;
216 fX[167] = 244.574996948242188;
217 fX[168] = 245.574996948242188;
218 fX[169] = 246.574996948242188;
219 fX[170] = 247.574996948242188;
220 fX[171] = 248.574996948242188;
221 fX[172] = 249.574996948242188;
222 fX[173] = 250.574996948242188;
223 fNPads[0] = 71;
224 fNPads[1] = 71;
225 fNPads[2] = 71;
226 fNPads[3] = 73;
227 fNPads[4] = 73;
228 fNPads[5] = 73;
229 fNPads[6] = 75;
230 fNPads[7] = 75;
231 fNPads[8] = 75;
232 fNPads[9] = 77;
233 fNPads[10] = 77;
234 fNPads[11] = 77;
235 fNPads[12] = 79;
236 fNPads[13] = 79;
237 fNPads[14] = 79;
238 fNPads[15] = 81;
239 fNPads[16] = 81;
240 fNPads[17] = 81;
241 fNPads[18] = 83;
242 fNPads[19] = 83;
243 fNPads[20] = 83;
244 fNPads[21] = 85;
245 fNPads[22] = 85;
246 fNPads[23] = 85;
247 fNPads[24] = 87;
248 fNPads[25] = 87;
249 fNPads[26] = 87;
250 fNPads[27] = 89;
251 fNPads[28] = 89;
252 fNPads[29] = 89;
253 fNPads[30] = 89;
254 fNPads[31] = 91;
255 fNPads[32] = 91;
256 fNPads[33] = 91;
257 fNPads[34] = 93;
258 fNPads[35] = 93;
259 fNPads[36] = 93;
260 fNPads[37] = 95;
261 fNPads[38] = 95;
262 fNPads[39] = 95;
263 fNPads[40] = 97;
264 fNPads[41] = 97;
265 fNPads[42] = 97;
266 fNPads[43] = 99;
267 fNPads[44] = 99;
268 fNPads[45] = 99;
269 fNPads[46] = 101;
270 fNPads[47] = 101;
271 fNPads[48] = 101;
272 fNPads[49] = 103;
273 fNPads[50] = 103;
274 fNPads[51] = 103;
275 fNPads[52] = 105;
276 fNPads[53] = 105;
277 fNPads[54] = 105;
278 fNPads[55] = 73;
279 fNPads[56] = 73;
280 fNPads[57] = 73;
281 fNPads[58] = 75;
282 fNPads[59] = 75;
283 fNPads[60] = 75;
284 fNPads[61] = 75;
285 fNPads[62] = 77;
286 fNPads[63] = 77;
287 fNPads[64] = 77;
288 fNPads[65] = 79;
289 fNPads[66] = 79;
290 fNPads[67] = 79;
291 fNPads[68] = 81;
292 fNPads[69] = 81;
293 fNPads[70] = 81;
294 fNPads[71] = 81;
295 fNPads[72] = 83;
296 fNPads[73] = 83;
297 fNPads[74] = 83;
298 fNPads[75] = 85;
299 fNPads[76] = 85;
300 fNPads[77] = 85;
301 fNPads[78] = 85;
302 fNPads[79] = 87;
303 fNPads[80] = 87;
304 fNPads[81] = 87;
305 fNPads[82] = 89;
306 fNPads[83] = 89;
307 fNPads[84] = 89;
308 fNPads[85] = 91;
309 fNPads[86] = 91;
310 fNPads[87] = 91;
311 fNPads[88] = 91;
312 fNPads[89] = 93;
313 fNPads[90] = 93;
314 fNPads[91] = 93;
315 fNPads[92] = 95;
316 fNPads[93] = 95;
317 fNPads[94] = 95;
318 fNPads[95] = 95;
319 fNPads[96] = 97;
320 fNPads[97] = 97;
321 fNPads[98] = 97;
322 fNPads[99] = 99;
323 fNPads[100] = 99;
324 fNPads[101] = 99;
325 fNPads[102] = 101;
326 fNPads[103] = 101;
327 fNPads[104] = 101;
328 fNPads[105] = 101;
329 fNPads[106] = 103;
330 fNPads[107] = 103;
331 fNPads[108] = 103;
332 fNPads[109] = 105;
333 fNPads[110] = 105;
334 fNPads[111] = 105;
335 fNPads[112] = 105;
336 fNPads[113] = 107;
337 fNPads[114] = 107;
338 fNPads[115] = 107;
339 fNPads[116] = 109;
340 fNPads[117] = 109;
341 fNPads[118] = 109;
342 fNPads[119] = 111;
343 fNPads[120] = 111;
344 fNPads[121] = 111;
345 fNPads[122] = 111;
346 fNPads[123] = 113;
347 fNPads[124] = 113;
348 fNPads[125] = 113;
349 fNPads[126] = 115;
350 fNPads[127] = 115;
351 fNPads[128] = 115;
352 fNPads[129] = 115;
353 fNPads[130] = 117;
354 fNPads[131] = 117;
355 fNPads[132] = 117;
356 fNPads[133] = 119;
357 fNPads[134] = 119;
358 fNPads[135] = 119;
359 fNPads[136] = 121;
360 fNPads[137] = 121;
361 fNPads[138] = 121;
362 fNPads[139] = 121;
363 fNPads[140] = 123;
364 fNPads[141] = 123;
365 fNPads[142] = 123;
366 fNPads[143] = 125;
367 fNPads[144] = 125;
368 fNPads[145] = 125;
369 fNPads[146] = 125;
370 fNPads[147] = 127;
371 fNPads[148] = 127;
372 fNPads[149] = 127;
373 fNPads[150] = 129;
374 fNPads[151] = 129;
375 fNPads[152] = 129;
376 fNPads[153] = 129;
377 fNPads[154] = 131;
378 fNPads[155] = 131;
379 fNPads[156] = 131;
380 fNPads[157] = 133;
381 fNPads[158] = 133;
382 fNPads[159] = 133;
383 fNPads[160] = 135;
384 fNPads[161] = 135;
385 fNPads[162] = 135;
386 fNPads[163] = 135;
387 fNPads[164] = 137;
388 fNPads[165] = 137;
389 fNPads[166] = 137;
390 fNPads[167] = 139;
391 fNPads[168] = 139;
392 fNPads[169] = 139;
393 fNPads[170] = 139;
394 fNPads[171] = 141;
395 fNPads[172] = 141;
396 fNPads[173] = 141;
397}
398
399
400Double_t AliL3Transform::GetEta(Float_t *xyz)
401{
402 Double_t r3 = sqrt(xyz[0]*xyz[0]+xyz[1]*xyz[1]+xyz[2]*xyz[2]);
403 Double_t eta = 0.5 * log((r3+xyz[2])/(r3-xyz[2]));
404 return eta;
405}
406
407Double_t AliL3Transform::GetPhi(Float_t *xyz)
408{
409
410 Double_t phi = atan2(xyz[1],xyz[0]);
411 //if(phi<0) phi=phi+2*TMath::Pi();
412 return phi;
413}
414
415
416Bool_t AliL3Transform::Slice2Sector(Int_t slice, Int_t slicerow, Int_t & sector, Int_t &row) const{
417 if(slicerow<0&&slicerow>=fNRow) return kFALSE;
418 if(slice<0||slice>=fNSlice) return kFALSE;
419
420 if(slicerow<fNRowLow){
421 sector = slice;
422 row = slicerow;
423 }
424 else {
425 sector = slice+fNSlice;
426 row = slicerow-fNRowLow;
427 }
428 return kTRUE;
429}
430
431Bool_t AliL3Transform::Sector2Slice(Int_t & slice, Int_t sector) const{
432 if(sector<0||sector>=fNSector) return kFALSE;
433 if(sector<fNSectorLow) slice = sector;
434 else slice = sector - fNSectorLow;
435 return kTRUE;
436}
437
438Bool_t AliL3Transform::Sector2Slice(Int_t & slice, Int_t & slicerow,Int_t sector, Int_t row) const{
439 if(sector<0||sector>=fNSector||row<0) return kFALSE;
440 if(sector<fNSectorLow){
441 if(row>=fNRowLow) return kFALSE;
442 slice = sector;
443 slicerow = row;
444 }
445 else{
446 if(row>=fNRowUp) return kFALSE;
447 slice = sector - fNSectorLow;
448 slicerow = row + fNRowLow;
449 }
450 return kTRUE;
451}
452
453Double_t AliL3Transform::Row2X(Int_t slicerow){
454 if(slicerow<0||slicerow>=fNRow) return 0;
455 return fX[slicerow];
456}
457
458void AliL3Transform::Local2Global(Float_t *xyz,Int_t slice)
459{
460 //Transformation to global coordinate system
461 Float_t x0 = xyz[0];
462 Float_t y0 = xyz[1];
463 Float_t cs,sn;
464 cs = fCos[slice];
465 sn = fSin[slice];
466 xyz[0]=x0*cs-y0*sn;
467 xyz[1]=x0*sn+y0*cs;
468 xyz[2]=xyz[2];//global z=local z
469}
470
471void AliL3Transform::Local2GlobalAngle(Float_t *angle,Int_t slice){
472 angle[0] = fmod(angle[0]+slice*fPi/9,2*fPi);
473}
474
475void AliL3Transform::Global2LocalAngle(Float_t *angle,Int_t slice){
476 angle[0] = angle[0]-slice*fPi/9;
477 if(angle[0]<0) angle[0]+=2*fPi;
478}
479
480void AliL3Transform::Raw2Local(Float_t *xyz,Int_t sector,Int_t row,Float_t pad,Float_t time)
481{
482 //Transformation from rawdata to local coordinate system
483
484 Int_t slice,slicerow;
485 Sector2Slice(slice, slicerow, sector, row);
486
487 xyz[0]=Row2X(slicerow);
488 Int_t npads= fNPads[slicerow];
489 if(sector<fNSectorLow)
490 xyz[1]=(pad-0.5*(npads-1))*fPadPitchWidthLow;
491 else
492 xyz[1]=(pad-0.5*(npads-1))*fPadPitchWidthUp;
493 xyz[2]=fZWidth*time-3.*fZSigma;
494 Int_t sign=-1;
495 Int_t nis=fNSectorLow;
496 Int_t nos=fNSectorUp;
497
498 if((sector<nis)/2 || ((sector-nis)<nos/2)) sign=1;
499 xyz[2]=sign*(250.-xyz[2]);
500
501}
502
503void AliL3Transform::Local2Global(Float_t *xyz,Int_t sector,Int_t row)
504{
505 //Transformation to global coordinate system
506 Int_t slice,slicerow;
507 Sector2Slice(slice, slicerow, sector, row);
508 Float_t r=Row2X(slicerow);
509 Float_t cs = fCos[slice];
510 Float_t sn = fSin[slice];
511
512 xyz[0]=r*cs-xyz[1]*sn;
513 xyz[1]=r*sn+xyz[1]*cs;
514 xyz[2]=xyz[2];//global z=local z
515}
516
517Double_t AliL3Transform::GetMaxY(Int_t slicerow)
518{
519
520 if(slicerow < fNRowLow)
521 return fPadPitchWidthLow*fNPads[slicerow]/2;
522
523 else
524 return fPadPitchWidthUp*fNPads[slicerow]/2;
525}
526
527void AliL3Transform::Global2Local(Float_t *xyz,Int_t sector)
528{
529 Int_t slice;
530 Sector2Slice(slice, sector);
531 Float_t cs = fCos[slice];
532 Float_t sn = fSin[slice];
533 Float_t x1 = xyz[0]*cs + xyz[1]*sn;
534 Float_t y1 = -xyz[0]*sn + xyz[1]*cs;
535 xyz[0] = x1;
536 xyz[1] = y1;
537}
538
539void AliL3Transform::Raw2Global(Float_t *xyz,Int_t sector,Int_t row,Float_t pad,Float_t time)
540{
541 //Transformation from raw to global coordinates
542
543 Raw2Local(xyz,sector,row,pad,time);
544 Local2Global(xyz,sector,row);
545}
546
547void AliL3Transform::Local2Raw(Float_t *xyz,Int_t sector,Int_t row)
548{
549 //Transformation from local coordinates to raw
550
551 Int_t slice,slicerow;
552 Sector2Slice(slice, slicerow, sector, row);
553
554 if(sector<fNSectorLow)
555 xyz[1]=xyz[1]/fPadPitchWidthLow+0.5*(fNPads[slicerow]-1);
556 else
557 xyz[1]=xyz[1]/fPadPitchWidthUp+0.5*(fNPads[slicerow]-1);
558 Int_t sign=-1;
559 Int_t nis=fNSectorLow;
560 Int_t nos=fNSectorUp;
561
562 if ((sector<nis/2) || ((sector-nis)<nos/2)) sign=1;
563 xyz[2]=250-sign*xyz[2];
564 xyz[2]=(xyz[2]+3.*fZSigma)/fZWidth;
565}
566
567void AliL3Transform::Global2Raw(Float_t *xyz,Int_t sector,Int_t row)
568{
569 //Transformation from global coordinates to raw.
570
571 Global2Local(xyz,sector);
572 Local2Raw(xyz,sector,row);
573
574}