03ee92a0a56b115fbd6e6c0fca84391c092f3363
[u/mrichter/AliRoot.git] / HLT / src / AliL3Transform.cxx
1 // $Id$
2
3 // Author: Anders Vestbo <mailto:vestbo@fi.uib.no>, Uli Frankenfeld <mailto:franken@fi.uib.no>
4 //*-- Copyright &copy ASV
5 // changes done by Constantin Loizides <mailto:loizides@ikf.physik.uni-frankfurt.de>
6
7 #include "AliL3Logging.h"
8 #include "AliL3Transform.h"
9 #include <math.h>
10 #include <stdlib.h>
11 #include <string.h>
12
13 /** \class AliL3Transform 
14 //<pre>
15 //_____________________________________________________________
16 // AliL3Transform
17 //
18 // Transformation class for ALICE TPC.
19 //
20 // Class which contains all detector specific parameters for the TPC,
21 // and different useful functions for coordinate transforms.
22 //
23 // The class is completely static, which means that no object needs
24 // to be instantiated. Function calls should then be done like:
25 //
26 // AliL3Transform::GetEta(xyz);
27 //
28 // IMPORTANT: If used as is, default detector parameters will be used,
29 //            and you really have to make sure that these correspond to
30 //            the AliROOT version you are currently working on!!
31 //            You should therefore always initialize the parameters by
32 //
33 //            AliL3Transform::Init(path);
34 // 
35 //            where path is a char*, giving the path to where file containing
36 //            the detector parameter is located. This file should be called
37 //            "l3transform.config", and can be created with macro exa/Make_Init.C.
38 //</pre>
39 */
40
41 ClassImp(AliL3Transform)
42
43 const Double_t AliL3Transform::fBFACT = 0.0029980;
44 Double_t AliL3Transform::fBField = 0.2;
45 Int_t AliL3Transform::fBFieldFactor = 1;
46 Int_t AliL3Transform::fVersion = 0;
47 Int_t AliL3Transform::fNTimeBins = 446 ;
48 Int_t AliL3Transform::fNRowLow = 64 ;
49 Int_t AliL3Transform::fNRowUp = 112 ;
50 Int_t AliL3Transform::fNSectorLow = 36 ;
51 Int_t AliL3Transform::fNSectorUp = 36 ;
52 Int_t AliL3Transform::fNSector = 72 ;
53 Double_t AliL3Transform::fPadPitchWidthLow = 0.400000 ;
54 Double_t AliL3Transform::fPadPitchWidthUp = 0.600000 ;
55 Double_t AliL3Transform::fZWidth = 0.56599998474121093750 ;
56 Double_t AliL3Transform::fZSigma = 0.22880849748219134199 ;
57 Double_t AliL3Transform::fZOffset = 0.68642549244657402596;
58 Double_t AliL3Transform::fDiffT = 0.0219999998807907104;
59 Double_t AliL3Transform::fDiffL = 0.0219999998807907104;
60 Double_t AliL3Transform::fAnodeWireSpacing = 0.25;
61 Double_t AliL3Transform::fInnerPadLength = 0.75;
62 Double_t AliL3Transform::fOuterPadLength = 1.;
63 Double_t AliL3Transform::fInnerPRFSigma = 0.203811079263687134;
64 Double_t AliL3Transform::fOuterPRFSigma = 0.299324512481689453;
65 Double_t AliL3Transform::fTimeSigma = 0.228808626532554626;
66 Double_t AliL3Transform::fZLength = 250.;
67 Int_t AliL3Transform::fNSlice = 36 ;
68 Int_t AliL3Transform::fNRow = 176 ;
69 Double_t AliL3Transform::fNRotShift = 0.5 ;
70 Double_t AliL3Transform::fPi = 3.141592653589793 ;
71 Int_t AliL3Transform::fNPatches = 6;
72 Int_t AliL3Transform::fRows[6][2] = {{0,31},{32,63},{64,91},{92,119},{120,143},{144,175}};
73 Int_t AliL3Transform::fNRows[6] = {32,32,28,28,24,32};
74 Double_t AliL3Transform::fX[176] = {84.570007324218750,
75                                     85.320007324218750,
76                                     86.070007324218750,
77                                     86.820007324218750,
78                                     87.570007324218750,
79                                     88.320007324218750,
80                                     89.070007324218750,
81                                     89.820007324218750,
82                                     90.570007324218750,
83                                     91.320007324218750,
84                                     92.070007324218750,
85                                     92.820007324218750,
86                                     93.570007324218750,
87                                     94.320007324218750,
88                                     95.070007324218750,
89                                     95.820007324218750,
90                                     96.570007324218750,
91                                     97.320007324218750,
92                                     98.070007324218750,
93                                     98.820007324218750,
94                                     99.570007324218750,
95                                     100.320007324218750,
96                                     101.070007324218750,
97                                     101.820007324218750,
98                                     102.570007324218750,
99                                     103.320007324218750,
100                                     104.070007324218750,
101                                     104.820007324218750,
102                                     105.570007324218750,
103                                     106.320007324218750,
104                                     107.070007324218750,
105                                     107.820007324218750,
106                                     108.570007324218750,
107                                     109.320007324218750,
108                                     110.070007324218750,
109                                     110.820007324218750,
110                                     111.570007324218750,
111                                     112.320007324218750,
112                                     113.070007324218750,
113                                     113.820007324218750,
114                                     114.570007324218750,
115                                     115.320007324218750,
116                                     116.070007324218750,
117                                     116.820007324218750,
118                                     117.570007324218750,
119                                     118.320007324218750,
120                                     119.070007324218750,
121                                     119.820007324218750,
122                                     120.570007324218750,
123                                     121.320007324218750,
124                                     122.070007324218750,
125                                     122.820007324218750,
126                                     123.570007324218750,
127                                     124.320007324218750,
128                                     125.070007324218750,
129                                     125.820007324218750,
130                                     126.570007324218750,
131                                     127.320007324218750,
132                                     128.070007324218750,
133                                     128.820007324218750,
134                                     129.570007324218750,
135                                     130.320007324218750,
136                                     131.070007324218750,
137                                     131.820007324218750,
138                                     135.054992675781250,
139                                     136.054992675781250,
140                                     137.054992675781250,
141                                     138.054992675781250,
142                                     139.054992675781250,
143                                     140.054992675781250,
144                                     141.054992675781250,
145                                     142.054992675781250,
146                                     143.054992675781250,
147                                     144.054992675781250,
148                                     145.054992675781250,
149                                     146.054992675781250,
150                                     147.054992675781250,
151                                     148.054992675781250,
152                                     149.054992675781250,
153                                     150.054992675781250,
154                                     151.054992675781250,
155                                     152.054992675781250,
156                                     153.054992675781250,
157                                     154.054992675781250,
158                                     155.054992675781250,
159                                     156.054992675781250,
160                                     157.054992675781250,
161                                     158.054992675781250,
162                                     159.054992675781250,
163                                     160.054992675781250,
164                                     161.054992675781250,
165                                     162.054992675781250,
166                                     163.054992675781250,
167                                     164.054992675781250,
168                                     165.054992675781250,
169                                     166.054992675781250,
170                                     167.054992675781250,
171                                     168.054992675781250,
172                                     169.054992675781250,
173                                     170.054992675781250,
174                                     171.054992675781250,
175                                     172.054992675781250,
176                                     173.054992675781250,
177                                     174.054992675781250,
178                                     175.054992675781250,
179                                     176.054992675781250,
180                                     177.054992675781250,
181                                     178.054992675781250,
182                                     179.054992675781250,
183                                     180.054992675781250,
184                                     181.054992675781250,
185                                     182.054992675781250,
186                                     183.054992675781250,
187                                     184.054992675781250,
188                                     185.054992675781250,
189                                     186.054992675781250,
190                                     187.054992675781250,
191                                     188.054992675781250,
192                                     189.054992675781250,
193                                     190.054992675781250,
194                                     191.054992675781250,
195                                     192.054992675781250,
196                                     193.054992675781250,
197                                     194.054992675781250,
198                                     195.054992675781250,
199                                     196.054992675781250,
200                                     197.054992675781250,
201                                     198.054992675781250,
202                                     199.054992675781250,
203                                     200.054992675781250,
204                                     201.054992675781250,
205                                     202.054992675781250,
206                                     203.054992675781250,
207                                     204.054992675781250,
208                                     205.054992675781250,
209                                     206.054992675781250,
210                                     207.054992675781250,
211                                     208.054992675781250,
212                                     209.054992675781250,
213                                     210.054992675781250,
214                                     211.054992675781250,
215                                     212.054992675781250,
216                                     213.054992675781250,
217                                     214.054992675781250,
218                                     215.054992675781250,
219                                     216.054992675781250,
220                                     217.054992675781250,
221                                     218.054992675781250,
222                                     219.054992675781250,
223                                     220.054992675781250,
224                                     221.054992675781250,
225                                     222.054992675781250,
226                                     223.054992675781250,
227                                     224.054992675781250,
228                                     225.054992675781250,
229                                     226.054992675781250,
230                                     227.054992675781250,
231                                     228.054992675781250,
232                                     229.054992675781250,
233                                     230.054992675781250,
234                                     231.054992675781250,
235                                     232.054992675781250,
236                                     233.054992675781250,
237                                     234.054992675781250,
238                                     235.054992675781250,
239                                     236.054992675781250,
240                                     237.054992675781250,
241                                     238.054992675781250,
242                                     239.054992675781250,
243                                     240.054992675781250,
244                                     241.054992675781250,
245                                     242.054992675781250,
246                                     243.054992675781250,
247                                     244.054992675781250,
248                                     245.054992675781250,
249                                     246.054992675781250,
250 };
251
252 Int_t AliL3Transform::fNPads[176] = {67,
253                                      67,
254                                      67,
255                                      69,
256                                      69,
257                                      69,
258                                      71,
259                                      71,
260                                      71,
261                                      73,
262                                      73,
263                                      73,
264                                      75,
265                                      75,
266                                      75,
267                                      77,
268                                      77,
269                                      77,
270                                      79,
271                                      79,
272                                      79,
273                                      81,
274                                      81,
275                                      81,
276                                      83,
277                                      83,
278                                      83,
279                                      85,
280                                      85,
281                                      85,
282                                      87,
283                                      87,
284                                      87,
285                                      89,
286                                      89,
287                                      89,
288                                      91,
289                                      91,
290                                      91,
291                                      93,
292                                      93,
293                                      93,
294                                      95,
295                                      95,
296                                      95,
297                                      97,
298                                      97,
299                                      97,
300                                      99,
301                                      99,
302                                      99,
303                                      101,
304                                      101,
305                                      101,
306                                      103,
307                                      103,
308                                      103,
309                                      105,
310                                      105,
311                                      105,
312                                      107,
313                                      107,
314                                      107,
315                                      109,
316                                      73,
317                                      75,
318                                      75,
319                                      75,
320                                      77,
321                                      77,
322                                      77,
323                                      77,
324                                      79,
325                                      79,
326                                      79,
327                                      81,
328                                      81,
329                                      81,
330                                      83,
331                                      83,
332                                      83,
333                                      83,
334                                      85,
335                                      85,
336                                      85,
337                                      87,
338                                      87,
339                                      87,
340                                      87,
341                                      89,
342                                      89,
343                                      89,
344                                      91,
345                                      91,
346                                      91,
347                                      93,
348                                      93,
349                                      93,
350                                      93,
351                                      95,
352                                      95,
353                                      95,
354                                      97,
355                                      97,
356                                      97,
357                                      97,
358                                      99,
359                                      99,
360                                      99,
361                                      101,
362                                      101,
363                                      101,
364                                      103,
365                                      103,
366                                      103,
367                                      103,
368                                      105,
369                                      105,
370                                      105,
371                                      107,
372                                      107,
373                                      107,
374                                      107,
375                                      109,
376                                      109,
377                                      109,
378                                      111,
379                                      111,
380                                      111,
381                                      113,
382                                      113,
383                                      113,
384                                      113,
385                                      115,
386                                      115,
387                                      115,
388                                      117,
389                                      117,
390                                      117,
391                                      117,
392                                      119,
393                                      119,
394                                      119,
395                                      121,
396                                      121,
397                                      121,
398                                      123,
399                                      123,
400                                      123,
401                                      123,
402                                      125,
403                                      125,
404                                      125,
405                                      127,
406                                      127,
407                                      127,
408                                      127,
409                                      129,
410                                      129,
411                                      129,
412                                      131,
413                                      131,
414                                      131,
415                                      133,
416                                      133,
417                                      133,
418                                      133,
419                                      135,
420                                      135,
421                                      135,
422                                      137,
423                                      137,
424                                      137,
425                                      137,
426                                      139,
427                                      139,
428 };
429
430
431
432 void AliL3Transform::Init(const Char_t* path)
433 {
434   //Overwrite the parameters with values stored in file "l3transform.config" in path.
435   //If file does not exist, old default values will be used.
436   
437   Char_t *pathname=new Char_t[1024];
438   strcpy(pathname,path);
439   strcat(pathname,"/l3transform.config");
440   
441   FILE *fptr=fopen(pathname,"r");
442   if(!fptr){
443     LOG(AliL3Log::kWarning,"AliL3Transform::Init","File Open")
444       <<"Pointer to Config File \""<<pathname<<"\" 0x0!"<<ENDLOG;
445     return;
446   }
447
448   Char_t d1[250], d2[100], d3[100];
449   Int_t dummy=0;
450   Double_t ddummy=0.0;
451
452   while(!feof(fptr)) {
453     fscanf(fptr,"%s",d1);
454
455     if(strcmp(d1,"fBFieldFactor")==0){fscanf(fptr,"%s %d %s",d2,&dummy,d3);fBFieldFactor=(Int_t)dummy;fBField=fBFieldFactor*0.2;}
456     else if(strcmp(d1,"fNTimeBins")==0){fscanf(fptr,"%s %d %s",d2,&dummy,d3);fNTimeBins=(Int_t)dummy;}
457     else if(strcmp(d1,"fNRowLow")==0){fscanf(fptr,"%s %d %s",d2,&dummy,d3);fNRowLow=(Int_t)dummy;}    
458     if(fNRowLow != 64)
459       LOG(AliL3Log::kError,"AliL3Transform::Init","Overflow")
460         <<"Number of inner PadRows should be 64! Check and fgrep the code for 64 to see the consequences of this major change!"<<ENDLOG;
461     else if(strcmp(d1,"fNRowUp")==0){fscanf(fptr,"%s %d %s",d2,&dummy,d3);fNRowUp=(Int_t)dummy;}
462     else if(strcmp(d1,"fNSectorLow")==0){fscanf(fptr,"%s %d %s",d2,&dummy,d3);fNSectorLow=(Int_t)dummy;}
463     else if(strcmp(d1,"fNSectorUp")==0){fscanf(fptr,"%s %d %s",d2,&dummy,d3);fNSectorUp=(Int_t)dummy;}
464     else if(strcmp(d1,"fNSector")==0){fscanf(fptr,"%s %d %s",d2,&dummy,d3);fNSector=(Int_t)dummy;}
465     else if(strcmp(d1,"fPadPitchWidthLow")==0){fscanf(fptr,"%s %lf %s",d2,&ddummy,d3);fPadPitchWidthLow=(Double_t)ddummy;}
466     else if(strcmp(d1,"fPadPitchWidthUp")==0){fscanf(fptr,"%s %lf %s",d2,&ddummy,d3);fPadPitchWidthUp=(Double_t)ddummy;}
467     else if(strcmp(d1,"fZWidth")==0){fscanf(fptr,"%s %lf %s",d2,&ddummy,d3);fZWidth=(Double_t)ddummy;}
468     else if(strcmp(d1,"fZSigma")==0){fscanf(fptr,"%s %lf %s",d2,&ddummy,d3);fZSigma=(Double_t)ddummy;}
469     else if(strcmp(d1,"fZLength")==0){fscanf(fptr,"%s %lf %s",d2,&ddummy,d3);fZLength=(Double_t)ddummy;}
470     else if(strcmp(d1,"fZOffset")==0){fscanf(fptr,"%s %lf %s",d2,&ddummy,d3);fZOffset=(Double_t)ddummy;}
471     else if(strcmp(d1,"fNSlice")==0){fscanf(fptr,"%s %d %s",d2,&dummy,d3);fNSlice=(Int_t)dummy;}
472     else if(strcmp(d1,"fDiffT")==0){fscanf(fptr,"%s %lf %s",d2,&ddummy,d3);fDiffT=(Double_t)ddummy;}
473     else if(strcmp(d1,"fDiffL")==0){fscanf(fptr,"%s %lf %s",d2,&ddummy,d3);fDiffL=(Double_t)ddummy;}
474     else if(strcmp(d1,"fInnerPadLength")==0){fscanf(fptr,"%s %lf %s",d2,&ddummy,d3);fInnerPadLength=(Double_t)ddummy;}
475     else if(strcmp(d1,"fOuterPadLength")==0){fscanf(fptr,"%s %lf %s",d2,&ddummy,d3);fOuterPadLength=(Double_t)ddummy;}
476     else if(strcmp(d1,"fInnerPRFSigma")==0){fscanf(fptr,"%s %lf %s",d2,&ddummy,d3);fInnerPRFSigma=(Double_t)ddummy;}
477     else if(strcmp(d1,"fOuterPRFSigma")==0){fscanf(fptr,"%s %lf %s",d2,&ddummy,d3);fOuterPRFSigma=(Double_t)ddummy;}
478     else if(strcmp(d1,"fTimeSigma")==0){fscanf(fptr,"%s %lf %s",d2,&ddummy,d3);fTimeSigma=(Double_t)ddummy;}
479     else if(strcmp(d1,"fNRow")==0){
480       fscanf(fptr,"%s %d %s",d2,&dummy,d3);fNRow=(Int_t)dummy;
481       if(fNRow!=176){
482         LOG(AliL3Log::kError,"AliL3Transform::Init","Overflow")<<"Number of PadRows should be 176! Check and fgrep the code for 176 to see the consequences of this major change!"<<ENDLOG;
483       }
484     }
485     else if(strcmp(d1,"fNRotShift")==0){fscanf(fptr,"%s %lf %s",d2,&ddummy,d3);fNRotShift=(Double_t)ddummy;}
486     else if(strcmp(d1,"fPi")==0){fscanf(fptr,"%s %lf %s",d2,&ddummy,d3);fPi=(Double_t)ddummy;}
487     else if(strcmp(d1,"fX[0]")==0){
488       fscanf(fptr,"%s %lf %s",d2,&ddummy,d3);fX[0]=(Double_t)ddummy;
489       for(Int_t i=1;i<fNRow;i++){fscanf(fptr,"%s %s %lf %s",d1,d2,&ddummy,d3);fX[i]=(Double_t)ddummy;}
490     }
491     else if(strcmp(d1,"fNPads[0]")==0){
492       fscanf(fptr,"%s %d %s",d2,&dummy,d3);fNPads[0]=(Int_t)dummy;
493       for(Int_t i=1;i<fNRow;i++){fscanf(fptr,"%s %s %d %s",d1,d2,&dummy,d3);fNPads[i]=(Int_t)dummy;}
494     }
495   }
496
497   fclose(fptr);
498   delete pathname;
499   fVersion=1; //new version
500
501 }
502
503 Double_t AliL3Transform::GetEta(Float_t *xyz)
504 {
505   Double_t r3 = sqrt(xyz[0]*xyz[0]+xyz[1]*xyz[1]+xyz[2]*xyz[2]);
506   Double_t eta = 0.5 * log((r3+xyz[2])/(r3-xyz[2]));
507   return eta;
508 }
509
510 void AliL3Transform::XYZtoRPhiEta(Float_t *rpe, Float_t *xyz)
511 {
512   rpe[0] = sqrt(xyz[0]*xyz[0]+xyz[1]*xyz[1]+xyz[2]*xyz[2]);
513   rpe[1] = atan2(xyz[1],xyz[0]);
514   rpe[2] = 0.5 * log((rpe[0]+xyz[2])/(rpe[0]-xyz[2]));
515 }
516
517 Double_t AliL3Transform::GetEta(Int_t padrow,Int_t pad,Int_t time)
518 {
519   Float_t xyz[3];
520   Int_t sector,row;
521   Slice2Sector(0,padrow,sector,row);
522   Raw2Local(xyz,sector,row,pad,time);
523   
524   return GetEta(xyz);
525 }
526
527 Double_t AliL3Transform::GetPhi(Float_t *xyz)
528 {
529   Double_t phi = atan2(xyz[1],xyz[0]);
530   //if(phi<0) phi=phi+2*TMath::Pi();
531   return phi;
532 }
533
534 Bool_t AliL3Transform::Slice2Sector(Int_t slice, Int_t slicerow, Int_t & sector, Int_t &row)
535 {
536   if(slicerow<0&&slicerow>=fNRow) return kFALSE;
537   if(slice<0||slice>=fNSlice) return kFALSE;
538
539   if(slicerow<fNRowLow){
540     sector = slice;
541     row    = slicerow;
542   }
543   else {
544     sector = slice+fNSlice;
545     row    = slicerow-fNRowLow;
546   }
547   return kTRUE;
548 }
549
550 Bool_t AliL3Transform::Sector2Slice(Int_t & slice, Int_t  sector)
551 {
552   if(sector<0||sector>=fNSector) return kFALSE;
553   if(sector<fNSectorLow) slice = sector;
554   else          slice = sector - fNSectorLow;
555   return kTRUE;
556 }
557
558 Bool_t AliL3Transform::Sector2Slice(Int_t & slice, Int_t & slicerow,Int_t  sector, Int_t row)
559 {
560   if(sector<0||sector>=fNSector||row<0) return kFALSE;
561   if(sector<fNSectorLow){
562     if(row>=fNRowLow) return kFALSE;
563     slice = sector;
564     slicerow = row;
565   }
566   else{
567     if(row>=fNRowUp) return kFALSE;
568     slice = sector - fNSectorLow;
569     slicerow = row + fNRowLow;
570   }
571   return kTRUE;
572 }
573
574 Double_t AliL3Transform::Row2X(Int_t slicerow){
575   if(slicerow<0||slicerow>=fNRow) return 0;
576   return fX[slicerow];
577 }
578
579 void AliL3Transform::Local2Global(Float_t *xyz,Int_t slice)
580 {
581   //Transformation to global coordinate system
582   Float_t x0 = xyz[0];
583   Float_t y0 = xyz[1];
584   Float_t cs,sn;
585   cs = cos( (2*fPi/18) * (slice+fNRotShift) );
586   sn = sin( (2*fPi/18) * (slice+fNRotShift) );
587   xyz[0]=x0*cs-y0*sn;
588   xyz[1]=x0*sn+y0*cs;
589   xyz[2]=xyz[2];//global z=local z
590 }
591
592 void AliL3Transform::Local2GlobalAngle(Float_t *angle,Int_t slice){
593   angle[0] = fmod(angle[0]+(slice+fNRotShift)*(2*fPi/18),2*fPi);
594 }
595
596 void AliL3Transform::Global2LocalAngle(Float_t *angle,Int_t slice){
597   angle[0] = angle[0]-(slice+fNRotShift)*(2*fPi/18);
598   if(angle[0]<0) angle[0]+=2*fPi;
599 }
600
601 void AliL3Transform::Raw2Local(Float_t *xyz,Int_t sector,Int_t row,Float_t pad,Float_t time)
602 {
603   //Transformation from rawdata to local coordinate system
604   
605   Int_t slice,slicerow;
606   Sector2Slice(slice, slicerow, sector, row);  
607
608   //X-Value
609   xyz[0]=Row2X(slicerow); 
610
611   //Y-Value
612   Int_t npads= fNPads[slicerow];
613   if(sector<fNSectorLow)
614     xyz[1]=(pad-0.5*(npads-1))*fPadPitchWidthLow;
615   else
616     xyz[1]=(pad-0.5*(npads-1))*fPadPitchWidthUp;
617
618   //Z-Value (remember PULSA Delay)
619   //xyz[2]=fZWidth*time-3.*fZSigma;
620   xyz[2]=fZWidth*time-fZOffset;
621   if(slice < 18)
622     xyz[2]=fZLength-xyz[2];
623   else
624     xyz[2]=xyz[2]-fZLength;
625   
626 }
627
628 void AliL3Transform::Local2Global(Float_t *xyz,Int_t sector,Int_t row)
629 {
630   //Transformation to global coordinate system
631   Int_t slice,slicerow;
632   Sector2Slice(slice, slicerow, sector, row);  
633   Float_t r=Row2X(slicerow);
634   Float_t cs = cos( (2*fPi/18) * (slice+fNRotShift) );
635   Float_t sn = sin( (2*fPi/18) * (slice+fNRotShift) );
636
637   xyz[0]=r*cs-xyz[1]*sn;
638   xyz[1]=r*sn+xyz[1]*cs;
639   xyz[2]=xyz[2];//global z=local z
640 }
641
642 Double_t AliL3Transform::GetMaxY(Int_t slicerow)
643 {
644
645  if(slicerow < fNRowLow)
646      return fPadPitchWidthLow*fNPads[slicerow]/2; 
647  
648  else
649      return fPadPitchWidthUp*fNPads[slicerow]/2;
650
651 }
652
653 void AliL3Transform::Global2Local(Float_t *xyz,Int_t sector,Bool_t isSlice)
654 {
655   
656   Int_t slice;
657   if(!isSlice)
658     Sector2Slice(slice, sector);  
659   else
660     slice = sector;
661   Float_t cs = cos( (2*fPi/18) * (slice+fNRotShift) );
662   Float_t sn = sin( (2*fPi/18) * (slice+fNRotShift) );
663   Float_t x1 = xyz[0]*cs + xyz[1]*sn;
664   Float_t y1 = -xyz[0]*sn + xyz[1]*cs;
665   xyz[0] = x1;
666   xyz[1] = y1;
667 }
668
669 void AliL3Transform::Raw2Global(Float_t *xyz,Int_t sector,Int_t row,Float_t pad,Float_t time)
670 {
671   //Transformation from raw to global coordinates
672   
673   Raw2Local(xyz,sector,row,pad,time);
674   Local2Global(xyz,sector,row);
675 }
676
677 void AliL3Transform::Local2Raw(Float_t *xyz,Int_t sector,Int_t row)
678 {
679   //Transformation from local coordinates to raw
680
681   Int_t slice,slicerow;
682   Sector2Slice(slice, slicerow, sector, row);  
683    
684   if(sector<fNSectorLow)
685     xyz[1]=xyz[1]/fPadPitchWidthLow+0.5*(fNPads[slicerow]-1);
686   else
687     xyz[1]=xyz[1]/fPadPitchWidthUp+0.5*(fNPads[slicerow]-1);
688   Int_t sign=-1;
689   Int_t nis=fNSectorLow;
690   Int_t nos=fNSectorUp;
691  
692   if ((sector<nis/2) || ((sector-nis)<nos/2)) sign=1; 
693   xyz[2]=fZLength-sign*xyz[2];
694   xyz[2]=(xyz[2]+fZOffset)/fZWidth;
695
696 }
697
698 void AliL3Transform::Global2Raw(Float_t *xyz,Int_t sector,Int_t row)
699 {
700   //Transformation from global coordinates to raw. 
701
702   Global2Local(xyz,sector);
703   Local2Raw(xyz,sector,row);
704
705 }