Little changes to make g++ version 3.2 compile the src library. Problems remaining...
[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 "AliL3StandardIncludes.h"
8
9 #include "AliL3Logging.h"
10 #include "AliL3Transform.h"
11
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 Double_t AliL3Transform::GetEta(Float_t *xyz)
503 {
504   Double_t r3 = sqrt(xyz[0]*xyz[0]+xyz[1]*xyz[1]+xyz[2]*xyz[2]);
505   Double_t eta = 0.5 * log((r3+xyz[2])/(r3-xyz[2]));
506   return eta;
507 }
508
509 void AliL3Transform::XYZtoRPhiEta(Float_t *rpe, Float_t *xyz)
510 {
511   rpe[0] = sqrt(xyz[0]*xyz[0]+xyz[1]*xyz[1]+xyz[2]*xyz[2]);
512   rpe[1] = atan2(xyz[1],xyz[0]);
513   rpe[2] = 0.5 * log((rpe[0]+xyz[2])/(rpe[0]-xyz[2]));
514 }
515
516 Double_t AliL3Transform::GetEta(Int_t padrow,Int_t pad,Int_t time)
517 {
518   Float_t xyz[3];
519   Int_t sector,row;
520   Slice2Sector(0,padrow,sector,row);
521   Raw2Local(xyz,sector,row,pad,time);
522   
523   return GetEta(xyz);
524 }
525
526 Double_t AliL3Transform::GetPhi(Float_t *xyz)
527 {
528   Double_t phi = atan2(xyz[1],xyz[0]);
529   //if(phi<0) phi=phi+2*TMath::Pi();
530   return phi;
531 }
532
533 Bool_t AliL3Transform::Slice2Sector(Int_t slice, Int_t slicerow, Int_t & sector, Int_t &row)
534 {
535   if(slicerow<0&&slicerow>=fNRow) return kFALSE;
536   if(slice<0||slice>=fNSlice) return kFALSE;
537
538   if(slicerow<fNRowLow){
539     sector = slice;
540     row    = slicerow;
541   }
542   else {
543     sector = slice+fNSlice;
544     row    = slicerow-fNRowLow;
545   }
546   return kTRUE;
547 }
548
549 Bool_t AliL3Transform::Sector2Slice(Int_t & slice, Int_t  sector)
550 {
551   if(sector<0||sector>=fNSector) return kFALSE;
552   if(sector<fNSectorLow) slice = sector;
553   else          slice = sector - fNSectorLow;
554   return kTRUE;
555 }
556
557 Bool_t AliL3Transform::Sector2Slice(Int_t & slice, Int_t & slicerow,Int_t  sector, Int_t row)
558 {
559   if(sector<0||sector>=fNSector||row<0) return kFALSE;
560   if(sector<fNSectorLow){
561     if(row>=fNRowLow) return kFALSE;
562     slice = sector;
563     slicerow = row;
564   }
565   else{
566     if(row>=fNRowUp) return kFALSE;
567     slice = sector - fNSectorLow;
568     slicerow = row + fNRowLow;
569   }
570   return kTRUE;
571 }
572
573 Double_t AliL3Transform::Row2X(Int_t slicerow){
574   if(slicerow<0||slicerow>=fNRow) return 0;
575   return fX[slicerow];
576 }
577
578 void AliL3Transform::Local2Global(Float_t *xyz,Int_t slice)
579 {
580   //Transformation to global coordinate system
581   Float_t x0 = xyz[0];
582   Float_t y0 = xyz[1];
583   Float_t cs,sn;
584   cs = cos( (2*fPi/18) * (slice+fNRotShift) );
585   sn = sin( (2*fPi/18) * (slice+fNRotShift) );
586   xyz[0]=x0*cs-y0*sn;
587   xyz[1]=x0*sn+y0*cs;
588   xyz[2]=xyz[2];//global z=local z
589 }
590
591 void AliL3Transform::Local2GlobalAngle(Float_t *angle,Int_t slice){
592   angle[0] = fmod(angle[0]+(slice+fNRotShift)*(2*fPi/18),2*fPi);
593 }
594
595 void AliL3Transform::Global2LocalAngle(Float_t *angle,Int_t slice){
596   angle[0] = angle[0]-(slice+fNRotShift)*(2*fPi/18);
597   if(angle[0]<0) angle[0]+=2*fPi;
598 }
599
600 void AliL3Transform::Raw2Local(Float_t *xyz,Int_t sector,Int_t row,Float_t pad,Float_t time)
601 {
602   //Transformation from rawdata to local coordinate system
603   
604   Int_t slice,slicerow;
605   Sector2Slice(slice, slicerow, sector, row);  
606
607   //X-Value
608   xyz[0]=Row2X(slicerow); 
609
610   //Y-Value
611   Int_t npads= fNPads[slicerow];
612   if(sector<fNSectorLow)
613     xyz[1]=(pad-0.5*(npads-1))*fPadPitchWidthLow;
614   else
615     xyz[1]=(pad-0.5*(npads-1))*fPadPitchWidthUp;
616
617   //Z-Value (remember PULSA Delay)
618   //xyz[2]=fZWidth*time-3.*fZSigma;
619   xyz[2]=fZWidth*time-fZOffset;
620   if(slice < 18)
621     xyz[2]=fZLength-xyz[2];
622   else
623     xyz[2]=xyz[2]-fZLength;
624   
625 }
626
627 void AliL3Transform::Local2Global(Float_t *xyz,Int_t sector,Int_t row)
628 {
629   //Transformation to global coordinate system
630   Int_t slice,slicerow;
631   Sector2Slice(slice, slicerow, sector, row);  
632   Float_t r=Row2X(slicerow);
633   Float_t cs = cos( (2*fPi/18) * (slice+fNRotShift) );
634   Float_t sn = sin( (2*fPi/18) * (slice+fNRotShift) );
635
636   xyz[0]=r*cs-xyz[1]*sn;
637   xyz[1]=r*sn+xyz[1]*cs;
638   xyz[2]=xyz[2];//global z=local z
639 }
640
641 Double_t AliL3Transform::GetMaxY(Int_t slicerow)
642 {
643
644  if(slicerow < fNRowLow)
645      return fPadPitchWidthLow*fNPads[slicerow]/2; 
646  
647  else
648      return fPadPitchWidthUp*fNPads[slicerow]/2;
649
650 }
651
652 void AliL3Transform::Global2Local(Float_t *xyz,Int_t sector,Bool_t isSlice)
653 {
654   
655   Int_t slice;
656   if(!isSlice)
657     Sector2Slice(slice, sector);  
658   else
659     slice = sector;
660   Float_t cs = cos( (2*fPi/18) * (slice+fNRotShift) );
661   Float_t sn = sin( (2*fPi/18) * (slice+fNRotShift) );
662   Float_t x1 = xyz[0]*cs + xyz[1]*sn;
663   Float_t y1 = -xyz[0]*sn + xyz[1]*cs;
664   xyz[0] = x1;
665   xyz[1] = y1;
666 }
667
668 void AliL3Transform::Raw2Global(Float_t *xyz,Int_t sector,Int_t row,Float_t pad,Float_t time)
669 {
670   //Transformation from raw to global coordinates
671   
672   Raw2Local(xyz,sector,row,pad,time);
673   Local2Global(xyz,sector,row);
674 }
675
676 void AliL3Transform::Local2Raw(Float_t *xyz,Int_t sector,Int_t row)
677 {
678   //Transformation from local coordinates to raw
679
680   Int_t slice,slicerow;
681   Sector2Slice(slice, slicerow, sector, row);  
682    
683   if(sector<fNSectorLow)
684     xyz[1]=xyz[1]/fPadPitchWidthLow+0.5*(fNPads[slicerow]-1);
685   else
686     xyz[1]=xyz[1]/fPadPitchWidthUp+0.5*(fNPads[slicerow]-1);
687   Int_t sign=-1;
688   Int_t nis=fNSectorLow;
689   Int_t nos=fNSectorUp;
690  
691   if ((sector<nis/2) || ((sector-nis)<nos/2)) sign=1; 
692   xyz[2]=fZLength-sign*xyz[2];
693   xyz[2]=(xyz[2]+fZOffset)/fZWidth;
694
695 }
696
697 void AliL3Transform::Global2Raw(Float_t *xyz,Int_t sector,Int_t row)
698 {
699   //Transformation from global coordinates to raw. 
700
701   Global2Local(xyz,sector);
702   Local2Raw(xyz,sector,row);
703
704 }