]> git.uio.no Git - u/mrichter/AliRoot.git/blob - TOF/AliTOFGeometryV5.cxx
new lookup table for sim. data with numberof TRMs
[u/mrichter/AliRoot.git] / TOF / AliTOFGeometryV5.cxx
1 /**************************************************************************
2  * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
3  *                                                                        *
4  * Author: The ALICE Off-line Project.                                    *
5  * Contributors are mentioned in the code where appropriate.              *
6  *                                                                        *
7  * Permission to use, copy, modify and distribute this software and its   *
8  * documentation strictly for non-commercial purposes is hereby granted   *
9  * without fee, provided that the above copyright notice appears in all   *
10  * copies and that both the copyright notice and this permission notice   *
11  * appear in the supporting documentation. The authors make no claims     *
12  * about the suitability of this software for any purpose. It is          *
13  * provided "as is" without express or implied warranty.                  *
14  **************************************************************************/
15
16 /*
17 $Log$
18 Revision 1.17.1  2006/12/15
19          Added methods:
20             DetToSectorRF(...) to get pad corners
21           coordinates in its sector reference frame;
22             GetVolumePath(Int_t sector, Char_t *path)
23           to get the volume path for a sector
24             GetVolumePath(Int_t sector, Int_t plate, Int_t strip, Char_t *path)
25           to get the volume path for a strip
26          (A.De Caro, M.Di Stefano)
27 Revision 1.7  2006/07/12 16:03:59  arcelli
28 updates to match the new numbering of the TOF/TRD mother volumes in FRAME (ALICE convention)
29
30 Revision 1.6  2006/05/04 19:41:42  hristov
31 Possibility for partial TOF geometry (S.Arcelli)
32
33 Revision 1.5  2006/04/20 22:30:50  hristov
34 Coding conventions (Annalisa)
35
36 Revision 1.4  2006/04/16 22:29:05  hristov
37 Coding conventions (Annalisa)
38
39 Revision 1.3  2006/03/12 14:38:05  arcelli
40  Changes for TOF Reconstruction using TGeo
41
42 Revision 1.2  2006/02/28 10:38:00  decaro
43 AliTOFGeometry::fAngles, AliTOFGeometry::fHeights, AliTOFGeometry::fDistances arrays: dimension definition in the right location
44
45 Revision 1.1  2005/12/15 08:55:33  decaro
46 New TOF geometry description (V5) -G. Cara Romeo and A. De Caro
47
48 Revision 0.1  2005/07/19 G. Cara Romeo and A. De Caro
49         Modify Global methods IsInsideThePad & DistanceToPad
50                according to the new TOF geometry
51         Implement Global  methods GetPadDx & GetPadDy & GetPadDz
52         Implement Private methods Translation & Rotation & InverseRotation
53         Modify Global methods GetDetID & GetPlate & GetSector &
54                               GetStrip & GetPadX & GetPadZ
55                according to the new TOF geometry
56         Modify Global methods GetPos & GetX & GetY & GetZ
57                according to the new TOF geometry
58 */
59
60 ///////////////////////////////////////////////////////////////////////////////
61 //                                                                           //
62 //  TOF Geometry class (new version)                                         //
63 //                                                                           //
64 ///////////////////////////////////////////////////////////////////////////////
65
66 #include "TGeoManager.h"
67
68 #include "AliConst.h"
69 #include "AliLog.h"
70
71 #include "AliTOFGeometryV5.h"
72
73 extern TGeoManager *gGeoManager;
74
75 ClassImp(AliTOFGeometryV5)
76
77
78 const Float_t AliTOFGeometryV5::fgkZlenA    = 370.6*2.; // length (cm) of the A module
79 const Float_t AliTOFGeometryV5::fgkZlenB    = 146.5;    // length (cm) of the B module
80 const Float_t AliTOFGeometryV5::fgkZlenC    = 170.45;   // length (cm) of the C module
81 const Float_t AliTOFGeometryV5::fgkMaxhZtof = 370.6;    // Max half z-size of TOF (cm)
82
83 const Float_t AliTOFGeometryV5::fgkxTOF     = 371.-0.01;// Inner radius of the TOF for Reconstruction (cm)
84 const Float_t AliTOFGeometryV5::fgkRmin     = 370.-0.01;// Inner radius of the TOF (cm)
85 const Float_t AliTOFGeometryV5::fgkRmax     = 399.-0.01;// Outer radius of the TOF (cm)
86
87 //_____________________________________________________________________________
88 AliTOFGeometryV5::AliTOFGeometryV5()
89   :AliTOFGeometry()
90 {
91   //
92   // AliTOFGeometryV5 default constructor
93   //
94
95   AliTOFGeometry::fNStripC     = kNStripC;       // number of strips in C type module
96
97   AliTOFGeometry::fZlenA       = fgkZlenA;       // length of the TOF supermodule (cm)
98   AliTOFGeometry::fZlenB       = fgkZlenB;       // length of the B module (cm)
99   AliTOFGeometry::fZlenC       = fgkZlenC;       // length of the C module (cm)
100   AliTOFGeometry::fMaxhZtof    = fgkMaxhZtof;    // Max half z-size of TOF supermodule (cm)
101
102   AliTOFGeometry::fxTOF   = fgkxTOF;           // Inner radius of the TOF for Reconstruction (cm)
103   AliTOFGeometry::fRmin   = fgkRmin;           // Inner radius of the TOF (cm)
104   AliTOFGeometry::fRmax   = fgkRmax;           // Outer radius of the TOF (cm)
105
106   Init();
107
108 }
109
110 //_____________________________________________________________________________
111 AliTOFGeometryV5::~AliTOFGeometryV5()
112 {
113   //
114   // AliTOFGeometryV5 destructor
115   //
116
117 }
118 //_____________________________________________________________________________
119 void AliTOFGeometryV5::ImportGeometry(){
120   TGeoManager::Import("geometry.root");
121 }
122 //_____________________________________________________________________________
123 void AliTOFGeometryV5::Init()
124 {
125   //
126   // Initialize strip Tilt Angles, Heights and Distances
127   //
128   // Strips Tilt Angles
129  
130   // For each strip to be positoned in FLTA/FLTB/FLTC,
131   // define 3 arrays containing:
132   //   the angle of the normal with respect to the Y axis of FLTA/FLTB/FLTC
133   //   the Y of the center with respect to the FLTA/FLTB/FLTC reference frame
134   //   the Z of the center with respect to the BT01/BT02/BT03 reference frame
135
136
137   fPhiSec   = 360./kNSectors;
138
139   Float_t const kangles[kNPlates][kMaxNstrip] ={
140     { 43.99,  43.20,  42.40,  41.59,  40.77,  39.94,  39.11,  38.25,  37.40,  36.53,
141       35.65,  34.76,  33.87,  32.96,  32.05,  31.13,  30.19,  29.24,  12.33,  0.00},
142
143     { 27.26,  26.28,  25.30,  24.31,  23.31,  22.31,  21.30,  20.29,  19.26,  18.24,
144       17.20,  16.16,  15.11,  14.05,  13.00,  11.93,  10.87,   9.80,   8.74,  0.00},
145
146     {  0.00,   6.30,   5.31,   4.25,   3.19,   2.12,   1.06,   0.00,  -1.06,  -2.12,
147       -3.19,  -4.25,  -5.31,  -6.30,   0.00,   0.00,   0.00,   0.00,   0.00,  0.00},
148
149     { -8.74,  -9.80, -10.87, -11.93, -13.00, -14.05, -15.11, -16.16, -17.20, -18.24,
150      -19.26, -20.29, -21.30, -22.31, -23.31, -24.31, -25.30, -26.28, -27.26,  0.00},
151     
152     {-12.33, -29.24, -30.19, -31.13, -32.05, -32.96, -33.87, -34.76, -35.65, -36.53,
153      -37.40, -38.25, -39.11, -39.94, -40.77, -41.59, -42.40, -43.20, -43.99,  0.00}
154   };
155
156   Float_t const kheights[kNPlates][kMaxNstrip]= {
157     {-8.2,  -7.5,  -8.2,  -7.7,  -8.1,  -7.6,  -7.7,  -7.7,  -7.7,  -7.7,
158      -7.5,  -7.2,  -7.3,  -7.5,  -7.6,  -7.8,  -8.3,  -9.3,  -3.1,   0.0},
159
160     {-7.9,  -8.1,  -8.5,  -9.0, -10.1,  -3.9,  -5.9,  -7.7, -10.1,  -3.6,
161      -5.8,  -8.0, -10.4,  -4.4,  -7.2, -10.2,  -4.6,  -7.4, -10.4,   0.0},
162
163     {-2.5, -10.4,  -5.0,  -9.9,  -4.8,  -9.9,  -4.7, -10.2,  -4.7,  -9.9,
164      -4.8,  -9.9,  -5.0, -10.4,  -2.5,   0.0,   0.0,   0.0,   0.0,   0.0},
165
166     {-10.4, -7.4,  -4.6, -10.2,  -7.2,  -4.4, -10.4,  -8.0,  -5.8,  -3.6,
167      -10.1,  -7.7, -5.9,  -3.9, -10.1,  -9.0,  -8.5,  -8.1,  -7.9,   0.0},
168
169     { -3.1,  -9.3, -8.3,  -7.8,  -7.6,  -7.5,  -7.3,  -7.2,  -7.5,  -7.7,
170       -7.7,  -7.7, -7.7,  -7.6,  -8.1,  -7.7,  -8.2,  -7.5,  -8.2,   0.0}
171   };
172
173
174   Float_t const kdistances[kNPlates][kMaxNstrip]= {
175     { 364.1,  354.9,  344.5,  335.4,  325.5,  316.6,  307.2,  298.0,  288.9,  280.0,
176       271.3,  262.7,  254.0,  244.8,  236.1,  227.7,  219.1,  210.3,  205.7,    0.0},
177
178     { 194.2,  186.1,  177.9,  169.8,  161.5,  156.3,  147.8,  139.4,  130.9,  125.6,
179       117.3,  109.2,  101.1,   95.3,   87.1,   79.2,   73.0,   65.1,   57.6,    0.0},
180
181     {  49.5,   41.3,   35.3,   27.8,   21.2,   13.9,    7.0,    0.0,   -7.0,  -13.9,
182       -21.2,  -27.8,  -35.3,  -41.3,  -49.5,    0.0,    0.0,    0.0,    0.0,    0.0},
183
184     { -57.6,  -65.1,  -73.0,  -79.2,  -87.1,  -95.3, -101.1, -109.2, -117.3, -125.6,
185      -130.9, -139.4, -147.8, -156.3, -161.5, -169.8, -177.9, -186.1, -194.2,    0.0},
186
187     {-205.7, -210.3, -219.1, -227.7, -236.1, -244.8, -254.0, -262.7, -271.3, -280.0,
188      -288.9, -298.0, -307.2, -316.6, -325.5, -335.4, -344.5, -354.9, -364.1,    0.0}
189   };
190
191
192   for (Int_t iplate = 0; iplate < kNPlates; iplate++) {
193     for (Int_t istrip = 0; istrip < kMaxNstrip; istrip++) {
194       AliTOFGeometry::fAngles[iplate][istrip]   = kangles[iplate][istrip];
195       AliTOFGeometry::fHeights[iplate][istrip]  = kheights[iplate][istrip];
196       AliTOFGeometry::fDistances[iplate][istrip]= kdistances[iplate][istrip];
197     }
198   }
199
200 }
201
202 //_____________________________________________________________________________
203 Float_t AliTOFGeometryV5::DistanceToPadPar(Int_t *det, Float_t *pos, Float_t *dist3d) const
204 {
205 //
206 // Returns distance of  space point with coor pos (x,y,z) (cm) wrt 
207 // pad with Detector Indices idet (iSect,iPlate,iStrip,iPadX,iPadZ) 
208 //
209     
210   //Transform pos into Sector Frame
211
212   Float_t x = pos[0];
213   Float_t y = pos[1];
214   Float_t z = pos[2];
215
216   Float_t radius = TMath::Sqrt(x*x+y*y);
217   //Float_t phi=TMath::ATan(y/x);       
218   //if(phi<0) phi = k2PI+phi; //2.*TMath::Pi()+phi;
219   Float_t phi = TMath::Pi()+TMath::ATan2(-y,-x);        
220   //  Get the local angle in the sector philoc
221   Float_t angle   = phi*kRaddeg-( Int_t (kRaddeg*phi/fPhiSec) + 0.5)*fPhiSec;
222   Float_t xs = radius*TMath::Cos(angle/kRaddeg);
223   Float_t ys = radius*TMath::Sin(angle/kRaddeg);
224   Float_t zs = z;
225
226   // Do the same for the selected pad
227
228   Float_t g[3];
229   GetPosPar(det,g);
230
231   Float_t padRadius = TMath::Sqrt(g[0]*g[0]+g[1]*g[1]);
232   //Float_t padPhi = TMath::ATan(g[1]/g[0]);    
233   //if(padPhi<0) padPhi = k2Pi + padPhi;
234   Float_t padPhi = TMath::Pi()+TMath::ATan2(-g[1],-g[0]);       
235
236   //  Get the local angle in the sector philoc
237   Float_t padAngle = padPhi*kRaddeg-( Int_t (padPhi*kRaddeg/fPhiSec)+ 0.5) * fPhiSec;
238   Float_t padxs = padRadius*TMath::Cos(padAngle/kRaddeg);
239   Float_t padys = padRadius*TMath::Sin(padAngle/kRaddeg);
240   Float_t padzs = g[2];
241   
242   //Now move to local pad coordinate frame. Translate:
243   
244   Float_t xt = xs-padxs;
245   Float_t yt = ys-padys;
246   Float_t zt = zs-padzs;
247   //Now Rotate:
248   
249   Float_t alpha = GetAngles(det[1],det[2]);
250   Float_t xr =  xt*TMath::Cos(alpha/kRaddeg)+zt*TMath::Sin(alpha/kRaddeg);
251   Float_t yr =  yt;
252   Float_t zr = -xt*TMath::Sin(alpha/kRaddeg)+zt*TMath::Cos(alpha/kRaddeg);
253
254   Float_t dist = TMath::Sqrt(xr*xr+yr*yr+zr*zr);
255
256   if (dist3d){
257     dist3d[0] = xr;
258     dist3d[1] = yr;
259     dist3d[2] = zr;
260   }
261
262   return dist;
263
264 }
265
266 //_____________________________________________________________________________
267 Bool_t AliTOFGeometryV5::IsInsideThePadPar(Int_t *det, Float_t *pos) const
268 {
269 //
270 // Returns true if space point with coor pos (x,y,z) (cm) falls 
271 // inside pad with Detector Indices idet (iSect,iPlate,iStrip,iPadX,iPadZ) 
272 //
273
274   Bool_t isInside=false; 
275
276   /*
277   const Float_t khhony    = 1.0          ; // heigth of HONY  Layer
278   const Float_t khpcby    = 0.08         ; // heigth of PCB   Layer
279   const Float_t khrgly    = 0.055        ; // heigth of RED GLASS  Layer
280   const Float_t khglfy    = 0.285        ; // heigth of GLASS+FISHLINE  Layer
281   const Float_t khcpcby   = 0.16         ; // heigth of PCB  Central Layer
282   //const Float_t kwcpcbz   = 12.4         ; // z dimension of PCB  Central Layer
283   const Float_t khstripy = 2.*khhony+2.*khpcby+4.*khrgly+2.*khglfy+khcpcby;//3.11
284   //const Float_t kwstripz = kwcpcbz;
285   //const Float_t klstripx = fgkStripLength;
286   */
287
288   const Float_t khsensmy = 0.5;//0.05;//0.11;//0.16;//          // heigth of Sensitive Layer
289
290   //Transform pos into Sector Frame
291
292   Float_t x = pos[0];
293   Float_t y = pos[1];
294   Float_t z = pos[2];
295
296   Float_t radius = TMath::Sqrt(x*x+y*y);
297   Float_t phi = TMath::Pi()+TMath::ATan2(-y,-x);        
298
299   //  Get the local angle in the sector philoc
300   Float_t angle = phi*kRaddeg-( Int_t (kRaddeg*phi/fPhiSec) + 0.5) *fPhiSec;
301   Float_t xs = radius*TMath::Cos(angle/kRaddeg);
302   Float_t ys = radius*TMath::Sin(angle/kRaddeg);
303   Float_t zs = z;
304
305   // Do the same for the selected pad
306
307   Float_t g[3];
308   GetPosPar(det,g);
309
310   Float_t padRadius = TMath::Sqrt(g[0]*g[0]+g[1]*g[1]);
311   Float_t padPhi = TMath::Pi()+TMath::ATan2(-g[1],-g[0]);       
312
313   //  Get the local angle in the sector philoc
314   Float_t padAngle = padPhi*kRaddeg-( Int_t (padPhi*kRaddeg/fPhiSec)+ 0.5) * fPhiSec; 
315   Float_t padxs = padRadius*TMath::Cos(padAngle/kRaddeg);
316   Float_t padys = padRadius*TMath::Sin(padAngle/kRaddeg);
317   Float_t padzs = g[2];
318
319   //Now move to local pad coordinate frame. Translate:
320
321   Float_t xt = xs-padxs;
322   Float_t yt = ys-padys;
323   Float_t zt = zs-padzs;
324
325   //Now Rotate:
326
327   Float_t alpha = GetAngles(det[1],det[2]);
328   Float_t xr =  xt*TMath::Cos(alpha/kRaddeg)+zt*TMath::Sin(alpha/kRaddeg);
329   Float_t yr =  yt;
330   Float_t zr = -xt*TMath::Sin(alpha/kRaddeg)+zt*TMath::Cos(alpha/kRaddeg);
331
332   if(TMath::Abs(xr)<=khsensmy*0.5 && TMath::Abs(yr)<= (fgkXPad*0.5) && TMath::Abs(zr)<= (fgkZPad*0.5))
333     isInside=true;
334   return isInside;
335
336 }
337
338
339 //_____________________________________________________________________________
340 Float_t AliTOFGeometryV5::DistanceToPad(Int_t *det, TGeoHMatrix mat, Float_t *pos, Float_t *dist3d) const
341 {
342 //
343 // Returns distance of  space point with coor pos (x,y,z) (cm) wrt 
344 // pad with Detector Indices idet (iSect,iPlate,iStrip,iPadX,iPadZ) 
345 //
346   if (!gGeoManager) {
347     printf("ERROR: no TGeo\n");
348     return 0.;
349   }
350   Double_t vecg[3];
351   vecg[0]=pos[0];
352   vecg[1]=pos[1];
353   vecg[2]=pos[2];
354   Double_t veclr[3]={-1.,-1.,-1.};
355   Double_t vecl[3]={-1.,-1.,-1.};
356   mat.MasterToLocal(vecg,veclr);  
357   vecl[0]=veclr[1];
358   vecl[1]=veclr[0];
359   //take into account reflections 
360   if(det[1]>-1)vecl[2]=-veclr[2];
361
362   Float_t dist = TMath::Sqrt(vecl[0]*vecl[0]+vecl[1]*vecl[1]+vecl[2]*vecl[2]);
363
364
365   if (dist3d){
366     dist3d[0] = vecl[0];
367     dist3d[1] = vecl[1];
368     dist3d[2] = vecl[2];
369   }
370
371   return dist;
372
373 }
374
375
376 //_____________________________________________________________________________
377 Bool_t AliTOFGeometryV5::IsInsideThePad( Int_t *det, TGeoHMatrix mat, Float_t *pos) const
378 {
379 //
380 // Returns true if space point with coor pos (x,y,z) (cm) falls 
381 // inside pad with Detector Indices idet (iSect,iPlate,iStrip,iPadX,iPadZ) 
382 //
383
384   const Float_t khsensmy = 0.5;      // heigth of Sensitive Layer
385   Double_t vecg[3];
386   vecg[0]=pos[0];
387   vecg[1]=pos[1];
388   vecg[2]=pos[2];
389   Double_t veclr[3]={-1.,-1.,-1.};
390   Double_t vecl[3]={-1.,-1.,-1.};
391   mat.MasterToLocal(vecg,vecl);  
392   vecl[0]=veclr[1];
393   vecl[1]=veclr[0];
394   //take into account reflections 
395   if(det[1]>-1)vecl[2]=-veclr[2];
396
397   Float_t xr = vecl[0];
398   Float_t yr = vecl[1];
399   Float_t zr = vecl[2];
400
401   Bool_t isInside=false; 
402   if(TMath::Abs(xr)<= khsensmy*0.5 && TMath::Abs(yr)<= (fgkXPad*0.5) && TMath::Abs(zr)<= (fgkZPad*0.5))
403     isInside=true; 
404   return isInside;
405
406 }
407 //_____________________________________________________________________________
408 //_____________________________________________________________________________
409 Float_t AliTOFGeometryV5::GetX(Int_t *det) const
410 {
411   //
412   // Returns X coordinate (cm)
413   //
414
415   Int_t isector = det[0];
416   Int_t iplate  = det[1];
417   Int_t istrip  = det[2];
418   Int_t ipadz   = det[3];
419   Int_t ipadx   = det[4];
420
421   /*
422   // Find out distance d on the plane wrt median phi:
423   Float_t d = (ipadx+0.5-kNpadX*0.5)*fgkXPad;
424
425   // The radius r in xy plane:
426   //Float_t r = (fgkRmin+fgkRmax)*0.5-0.01+GetHeights(iplate,istrip)+
427   //  (ipadz-0.5)*fgkZPad*TMath::Sin(GetAngles(iplate,istrip)/kRaddeg)-0.25; ???
428   Float_t r = (fgkRmin+fgkRmax)*0.5-0.01+GetHeights(iplate,istrip)+
429     (ipadz-0.5)*fgkZPad*TMath::Sin(GetAngles(iplate,istrip)/kRaddeg);
430
431   // local azimuthal angle in the sector philoc
432   Float_t philoc  = TMath::ATan(d/r);
433   //if(philoc<0.) philoc = k2PI + philoc;
434
435   // azimuthal angle in the global frame  phi
436   Float_t phi   = philoc*kRaddeg+(isector+0.5)*fPhiSec;
437
438   Float_t xCoor = r/TMath::Cos(philoc)*TMath::Cos(phi/kRaddeg);
439   */
440
441   // Pad reference frame -> FSTR reference frame
442   //  /*
443   Float_t posLocal[3] = {0., 0., 0.};
444   Float_t step[3] = {-(ipadx+0.5)*fgkXPad, 0., -(ipadz+0.5)*fgkZPad};
445   Translation(posLocal,step);
446
447   step[0] = kNpadX*0.5*fgkXPad;
448   step[1] = 0.;
449   step[2] = kNpadZ*0.5*fgkZPad;
450   //  */
451   /*
452   Float_t posLocal[3] = {(ipadx+0.5)*fgkXPad, 0., (ipadz+0.5)*fgkZPad};
453   Float_t step[3]= {kNpadX*0.5*fgkXPad, 0., kNpadZ*0.5*fgkZPad};
454   */
455   Translation(posLocal,step);
456
457   // FSTR reference frame -> FTOA/B/C = FLTA/B/C reference frame
458   Double_t angles[6];
459   if      (GetAngles(iplate,istrip) >0.) {
460     angles[0] = 90.;
461     angles[1] =  0.;
462     angles[2] = 90.+GetAngles(iplate,istrip);
463     angles[3] = 90.;
464     angles[4] = GetAngles(iplate,istrip);
465     angles[5] = 90.;
466   }
467   else if (GetAngles(iplate,istrip)==0.) {
468     angles[0] = 90.;
469     angles[1] =  0.;
470     angles[2] = 90.;
471     angles[3] = 90.;
472     angles[4] =  0;
473     angles[5] =  0.;
474   }
475   else if (GetAngles(iplate,istrip) <0.) {
476     angles[0] = 90.;
477     angles[1] =  0.;
478     angles[2] = 90.+GetAngles(iplate,istrip);
479     angles[3] = 90.;
480     angles[4] =-GetAngles(iplate,istrip);
481     angles[5] = 270.;
482   }
483
484   InverseRotation(posLocal,angles);
485
486   step[0] = 0.;
487   step[1] = -GetHeights(iplate,istrip);
488   step[2] =  GetDistances(iplate,istrip);
489   Translation(posLocal,step);
490
491   // FTOA = FLTA reference frame -> B071/B074/B075 = BTO1/2/3 reference frame
492   angles[0] = 90.;
493   angles[1] =  0.;
494   angles[2] =  0.;
495   angles[3] =  0.;
496   angles[4] = 90.;
497   angles[5] =270.;
498
499   InverseRotation(posLocal,angles);
500
501   // B071/B074/B075 = BTO1/2/3 reference frame -> ALICE reference frame
502   step[0] = 0.;
503   step[1] = 0.;
504   step[2] = -((fgkRmax+fgkRmin)*0.5);
505   Translation(posLocal,step);
506
507   angles[0] = 90.;
508   angles[1] = 90.+(isector+0.5)*fPhiSec;
509   angles[2] = 0.;
510   angles[3] = 0.;
511   angles[4] = 90.;
512   angles[5] = (isector+0.5)*fPhiSec;
513
514   InverseRotation(posLocal,angles);
515
516   Float_t xCoor = posLocal[0];
517
518   return xCoor;
519
520 }
521 //_____________________________________________________________________________
522 Float_t AliTOFGeometryV5::GetY(Int_t *det) const
523 {
524   //
525   // Returns Y coordinate (cm)
526   //
527
528   Int_t isector = det[0];
529   Int_t iplate  = det[1];
530   Int_t istrip  = det[2];
531   Int_t ipadz   = det[3];
532   Int_t ipadx   = det[4];
533
534   /*
535   // Find out distance d on the plane wrt median phi:
536   Float_t d = (ipadx+0.5-kNpadX*0.5)*fgkXPad;
537
538   // The radius r in xy plane:
539   //Float_t r = (fgkRmin+fgkRmax)*0.5-0.01+GetHeights(iplate,istrip)+
540   //  (ipadz-0.5)*fgkZPad*TMath::Sin(GetAngles(iplate,istrip)/kRaddeg)-0.25; ???
541   Float_t r = (fgkRmin+fgkRmax)*0.5-0.01+GetHeights(iplate,istrip)+
542     (ipadz-0.5)*fgkZPad*TMath::Sin(GetAngles(iplate,istrip)/kRaddeg);
543
544   // local azimuthal angle in the sector philoc
545   Float_t philoc = TMath::ATan(d/r);
546   //if(philoc<0.) philoc = k2PI + philoc;
547
548   // azimuthal angle in the global frame  phi
549   Float_t phi   = philoc*kRaddeg+(isector+0.5)*fPhiSec;
550
551   Float_t yCoor = r/TMath::Cos(philoc)*TMath::Sin(phi/kRaddeg);
552   */
553
554   // Pad reference frame -> FSTR reference frame
555   //  /*
556   Float_t posLocal[3] = {0., 0., 0.};
557   Float_t step[3] = {-(ipadx+0.5)*fgkXPad, 0., -(ipadz+0.5)*fgkZPad};
558   Translation(posLocal,step);
559
560   step[0] = kNpadX*0.5*fgkXPad;
561   step[1] = 0.;
562   step[2] = kNpadZ*0.5*fgkZPad;
563   //  */
564   /*
565   Float_t posLocal[3] = {(ipadx+0.5)*fgkXPad, 0., (ipadz+0.5)*fgkZPad};
566   Float_t step[3]= {kNpadX*0.5*fgkXPad, 0., kNpadZ*0.5*fgkZPad};
567   */
568   Translation(posLocal,step);
569
570   // FSTR reference frame -> FTOA/B/C = FLTA/B/C reference frame
571
572   Double_t angles[6];
573   if      (GetAngles(iplate,istrip) >0.) {
574     angles[0] = 90.;
575     angles[1] =  0.;
576     angles[2] = 90.+GetAngles(iplate,istrip);
577     angles[3] = 90.;
578     angles[4] = GetAngles(iplate,istrip);
579     angles[5] = 90.;
580   }
581   else if (GetAngles(iplate,istrip)==0.) {
582     angles[0] = 90.;
583     angles[1] =  0.;
584     angles[2] = 90.;
585     angles[3] = 90.;
586     angles[4] =  0;
587     angles[5] =  0.;
588   }
589   else if (GetAngles(iplate,istrip) <0.) {
590     angles[0] = 90.;
591     angles[1] =  0.;
592     angles[2] = 90.+GetAngles(iplate,istrip);
593     angles[3] = 90.;
594     angles[4] =-GetAngles(iplate,istrip);
595     angles[5] = 270.;
596   }
597
598   InverseRotation(posLocal,angles);
599
600   step[0] = 0.;
601   step[1] = -GetHeights(iplate,istrip);
602   step[2] =  GetDistances(iplate,istrip);
603   Translation(posLocal,step);
604
605   // FTOA = FLTA reference frame -> B071/B074/B075 = BTO1/2/3 reference frame
606   angles[0] = 90.;
607   angles[1] =  0.;
608   angles[2] =  0.;
609   angles[3] =  0.;
610   angles[4] = 90.;
611   angles[5] =270.;
612
613   InverseRotation(posLocal,angles);
614
615   // B071/B074/B075 = BTO1/2/3 reference frame -> ALICE reference frame
616   step[0] = 0.;
617   step[1] = 0.;
618   step[2] = -((fgkRmax+fgkRmin)*0.5);
619   Translation(posLocal,step);
620
621   angles[0] = 90.;
622   angles[1] = 90.+(isector+0.5)*fPhiSec;
623   angles[2] = 0.;
624   angles[3] = 0.;
625   angles[4] = 90.;
626   angles[5] = (isector+0.5)*fPhiSec;
627
628   InverseRotation(posLocal,angles);
629
630   Float_t yCoor = posLocal[1];
631
632   return yCoor;
633
634 }
635
636 //_____________________________________________________________________________
637 Float_t AliTOFGeometryV5::GetZ(Int_t *det) const
638 {
639   //
640   // Returns Z coordinate (cm)
641   //
642
643   Int_t isector = det[0];
644   Int_t iplate  = det[1];
645   Int_t istrip  = det[2];
646   Int_t ipadz   = det[3];
647   Int_t ipadx   = det[4];
648
649   /*
650   Float_t zCoor = GetDistances(iplate,istrip) +
651     (0.5-ipadz) * fgkZPad * TMath::Cos(GetAngles(iplate,istrip)*kDegrad);
652   */
653
654   // Pad reference frame -> FSTR reference frame
655   //  /*
656   Float_t posLocal[3] = {0., 0., 0.};
657   Float_t step[3] = {-(ipadx+0.5)*fgkXPad, 0., -(ipadz+0.5)*fgkZPad};
658   Translation(posLocal,step);
659
660   step[0] = kNpadX*0.5*fgkXPad;
661   step[1] = 0.;
662   step[2] = kNpadZ*0.5*fgkZPad;
663   //  */
664   /*
665   Float_t posLocal[3] = {(ipadx+0.5)*fgkXPad, 0., (ipadz+0.5)*fgkZPad};
666   Float_t step[3]= {kNpadX*0.5*fgkXPad, 0., kNpadZ*0.5*fgkZPad};
667   */
668   Translation(posLocal,step);
669
670   // FSTR reference frame -> FTOA/B/C = FLTA/B/C reference frame
671   Double_t angles[6];
672   if      (GetAngles(iplate,istrip) >0.) {
673     angles[0] = 90.;
674     angles[1] =  0.;
675     angles[2] = 90.+GetAngles(iplate,istrip);
676     angles[3] = 90.;
677     angles[4] = GetAngles(iplate,istrip);
678     angles[5] = 90.;
679   }
680   else if (GetAngles(iplate,istrip)==0.) {
681     angles[0] = 90.;
682     angles[1] =  0.;
683     angles[2] = 90.;
684     angles[3] = 90.;
685     angles[4] =  0;
686     angles[5] =  0.;
687   }
688   else if (GetAngles(iplate,istrip) <0.) {
689     angles[0] = 90.;
690     angles[1] =  0.;
691     angles[2] = 90.+GetAngles(iplate,istrip);
692     angles[3] = 90.;
693     angles[4] =-GetAngles(iplate,istrip);
694     angles[5] = 270.;
695   }
696
697   InverseRotation(posLocal,angles);
698
699   step[0] = 0.;
700   step[1] = -GetHeights(iplate,istrip);
701   step[2] =  GetDistances(iplate,istrip);
702   Translation(posLocal,step);
703
704   // FTOA = FLTA reference frame -> B071/B074/B075 = BTO1/2/3 reference frame
705   angles[0] = 90.;
706   angles[1] =  0.;
707   angles[2] =  0.;
708   angles[3] =  0.;
709   angles[4] = 90.;
710   angles[5] =270.;
711
712   InverseRotation(posLocal,angles);
713
714   // B071/B074/B075 = BTO1/2/3 reference frame -> ALICE reference frame
715   step[0] = 0.;
716   step[1] = 0.;
717   step[2] = -((fgkRmax+fgkRmin)*0.5);
718   Translation(posLocal,step);
719
720   angles[0] = 90.;
721   angles[1] = 90.+(isector+0.5)*fPhiSec;
722   angles[2] = 0.;
723   angles[3] = 0.;
724   angles[4] = 90.;
725   angles[5] = (isector+0.5)*fPhiSec;
726
727   InverseRotation(posLocal,angles);
728
729   Float_t zCoor = posLocal[2];
730
731   return zCoor;
732
733 }
734
735 //_____________________________________________________________________________
736 Int_t AliTOFGeometryV5::GetSector(Float_t *pos) const
737 {
738   //
739   // Returns the Sector index 
740   //
741
742   //const Float_t khAlWall = 0.1;
743   //const Float_t kModuleWallThickness = 0.3;
744
745   Int_t   iSect = -1; 
746
747   Float_t x = pos[0];
748   Float_t y = pos[1];
749   Float_t z = pos[2];
750
751   Float_t rho = TMath::Sqrt(x*x + y*y);
752
753   //if (!((z>=-fgkMaxhZtof && z<=fgkMaxhZtof) &&
754   if (!((z>=-fgkZlenA*0.5 && z<=fgkZlenA*0.5) &&
755         (rho>=(fgkRmin) && rho<=(fgkRmax)))) {
756     //(rho>=(fgkRmin-0.05)+kModuleWallThickness && rho<=(fgkRmax-0.05)-kModuleWallThickness-khAlWall-kModuleWallThickness))) {
757     //AliError("Detector Index could not be determined");
758     return iSect;
759   }
760
761   Float_t phi = TMath::Pi() + TMath::ATan2(-y,-x);      
762
763   iSect  = (Int_t) (phi*kRaddeg/fPhiSec);
764   
765   return iSect;
766
767 }
768 //_____________________________________________________________________________
769
770 Int_t AliTOFGeometryV5::GetPlate(Float_t *pos) const
771 {
772   //
773   // Returns the Plate index 
774   //
775   const Float_t kInterCentrModBorder1 = 49.5;
776   const Float_t kInterCentrModBorder2 = 57.5;
777   const Float_t kExterInterModBorder1 = 196.0;
778   const Float_t kExterInterModBorder2 = 203.5;
779
780   const Float_t kLengthExInModBorder  = 4.7;
781   const Float_t kLengthInCeModBorder  = 7.0;
782
783   //const Float_t khAlWall = 0.1;
784   const Float_t kModuleWallThickness = 0.3;
785   //const Float_t kHoneycombLayerThickness = 1.5;
786
787   Int_t iPlate=-1;
788
789   Float_t posLocal[3];
790   for (Int_t ii=0; ii<3; ii++) posLocal[ii] = pos[ii];
791
792   Int_t isector = GetSector(posLocal);
793   if(isector == -1){
794     //AliError("Detector Index could not be determined");
795     return iPlate;
796   }
797
798   // ALICE reference frame -> B071/B074/B075 = BTO1/2/3 reference frame
799   Double_t angles[6] = 
800     {90., 90.+(isector+0.5)*fPhiSec,
801       0., 0.,
802      90., (isector+0.5)*fPhiSec
803     };
804   Rotation(posLocal,angles);
805
806   Float_t step[3] = {0., 0., (fgkRmax+fgkRmin)*0.5};
807   Translation(posLocal,step);
808
809   // B071/B074/B075 = BTO1/2/3 reference frame -> FTOA = FLTA reference frame
810   angles[0] = 90.;
811   angles[1] =  0.;
812   angles[2] =  0.;
813   angles[3] =  0.;
814   angles[4] = 90.;
815   angles[5] =270.;
816
817   Rotation(posLocal,angles);
818
819   Float_t yLocal = posLocal[1];
820   Float_t zLocal = posLocal[2];
821
822   Float_t deltaRhoLoc  = (fgkRmax-fgkRmin)*0.5 - kModuleWallThickness + yLocal;
823   Float_t deltaZetaLoc = TMath::Abs(zLocal);
824
825   Float_t deltaRHOmax = 0.;
826
827   if (TMath::Abs(zLocal)>=kExterInterModBorder1 && TMath::Abs(zLocal)<=kExterInterModBorder2) 
828     {
829       deltaRhoLoc -= kLengthExInModBorder;
830       deltaZetaLoc = kExterInterModBorder2-deltaZetaLoc;
831       deltaRHOmax  = (fgkRmax - fgkRmin)*0.5 - kModuleWallThickness - 2.*kLengthExInModBorder; // old 5.35, new 4.8
832
833       if (deltaRhoLoc > deltaZetaLoc*deltaRHOmax/(kInterCentrModBorder2-kInterCentrModBorder1)) {
834         if (zLocal<0) iPlate = 0;
835         else iPlate = 4;
836       }
837       else {
838         if (zLocal<0) iPlate = 1;
839         else iPlate = 3;
840       }
841     }
842   else if (TMath::Abs(zLocal)>=kInterCentrModBorder1 && TMath::Abs(zLocal)<=kInterCentrModBorder2) 
843     {
844       deltaRhoLoc -= kLengthInCeModBorder;
845       deltaZetaLoc = deltaZetaLoc-kInterCentrModBorder1;
846       deltaRHOmax = (fgkRmax - fgkRmin)*0.5 - kModuleWallThickness - 2.*kLengthInCeModBorder; // old 0.39, new 0.2
847
848       if (deltaRhoLoc>deltaZetaLoc*deltaRHOmax/(kInterCentrModBorder2-kInterCentrModBorder1)) iPlate = 2;
849       else {
850         if (zLocal<0) iPlate = 1;
851         else iPlate = 3;
852       }
853     }
854
855   if      (zLocal>-fgkZlenA*0.5/*fgkMaxhZtof*/ && zLocal<-kExterInterModBorder2)       iPlate = 0;
856   else if (zLocal>-kExterInterModBorder1       && zLocal<-kInterCentrModBorder2)       iPlate = 1;
857   else if (zLocal>-kInterCentrModBorder1       && zLocal< kInterCentrModBorder1)       iPlate = 2;
858   else if (zLocal> kInterCentrModBorder2       && zLocal< kExterInterModBorder1)       iPlate = 3;
859   else if (zLocal> kExterInterModBorder2       && zLocal< fgkZlenA*0.5/*fgkMaxhZtof*/) iPlate = 4;
860   
861   return iPlate;
862
863 }
864
865 //_____________________________________________________________________________
866 Int_t AliTOFGeometryV5::GetStrip(Float_t *pos) const
867 {
868   //
869   // Returns the Strip index 
870   //
871   const Float_t khhony    = 1.0          ; // heigth of HONY  Layer
872   const Float_t khpcby    = 0.08         ; // heigth of PCB   Layer
873   const Float_t khrgly    = 0.055        ; // heigth of RED GLASS  Layer
874   const Float_t khglfy    = 0.285        ; // heigth of GLASS+FISHLINE  Layer
875   const Float_t khcpcby   = 0.16         ; // heigth of PCB  Central Layer
876   const Float_t kwcpcbz   = 12.4         ; // z dimension of PCB  Central Layer
877   const Float_t khstripy = 2.*khhony+2.*khpcby+4.*khrgly+2.*khglfy+khcpcby;//3.11
878   const Float_t kwstripz = kwcpcbz;
879   const Float_t klstripx = fgkStripLength;
880   
881   Int_t iStrip=-1;
882    
883   Float_t posLocal[3];
884   for (Int_t ii=0; ii<3; ii++) posLocal[ii] = pos[ii];
885  
886   Int_t isector = GetSector(posLocal);
887   if(isector == -1){
888     //AliError("Detector Index could not be determined");
889     return iStrip;}
890   Int_t iplate =  GetPlate(posLocal);
891   if(iplate == -1){
892     //AliError("Detector Index could not be determined");
893     return iStrip;} 
894
895   Int_t nstrips=0;
896   switch (iplate) {
897   case 0:
898     nstrips=kNStripC;
899     break;
900   case 4:
901     nstrips=kNStripC;
902     break;
903   case 1:
904     nstrips=kNStripB;
905     break;
906   case 3:
907     nstrips=kNStripB;
908     break;
909   case 2:
910     nstrips=kNStripA;
911     break;
912   }
913   
914   // ALICE reference frame -> B071/B074/B075 = BTO1/2/3 reference frame
915   Double_t angles[6] = 
916     {90., 90.+(isector+0.5)*fPhiSec,
917       0., 0.,
918      90., (isector+0.5)*fPhiSec
919     };
920   Rotation(posLocal,angles);
921
922   Float_t step[3] = {0., 0., (fgkRmax+fgkRmin)*0.5};
923   Translation(posLocal,step);
924
925   // B071/B074/B075 = BTO1/2/3 reference frame -> FTOA = FLTA reference frame
926   angles[0] = 90.;
927   angles[1] =  0.;
928   angles[2] =  0.;
929   angles[3] =  0.;
930   angles[4] = 90.;
931   angles[5] =270.;
932
933   Rotation(posLocal,angles);
934
935   // FTOA/B/C = FLTA/B/C reference frame -> FSTR reference frame
936   Int_t totStrip=0;
937   for (Int_t istrip=0; istrip<nstrips; istrip++){
938
939     Float_t posLoc2[3]={posLocal[0],posLocal[1],posLocal[2]};         
940
941     step[0] = 0.;
942     step[1] = GetHeights(iplate,istrip);
943     step[2] = -GetDistances(iplate,istrip);
944     Translation(posLoc2,step);
945
946     if      (GetAngles(iplate,istrip) >0.) {
947       angles[0] = 90.;
948       angles[1] =  0.;
949       angles[2] = 90.+GetAngles(iplate,istrip);
950       angles[3] = 90.;
951       angles[4] = GetAngles(iplate,istrip);
952       angles[5] = 90.;
953     }
954     else if (GetAngles(iplate,istrip)==0.) {
955       angles[0] = 90.;
956       angles[1] =  0.;
957       angles[2] = 90.;
958       angles[3] = 90.;
959       angles[4] =  0;
960       angles[5] =  0.;
961     }
962     else if (GetAngles(iplate,istrip) <0.) {
963       angles[0] = 90.;
964       angles[1] =  0.;
965       angles[2] = 90.+GetAngles(iplate,istrip);
966       angles[3] = 90.;
967       angles[4] =-GetAngles(iplate,istrip);
968       angles[5] = 270.;
969     }
970     Rotation(posLoc2,angles);
971
972     if ((TMath::Abs(posLoc2[0])<=klstripx*0.5) &&
973         (TMath::Abs(posLoc2[1])<=khstripy*0.5) &&
974         (TMath::Abs(posLoc2[2])<=kwstripz*0.5)) {
975       iStrip = istrip;
976       totStrip++;
977       for (Int_t jj=0; jj<3; jj++) posLocal[jj]=posLoc2[jj];
978       //AliInfo(Form(" posLocal[0] = %f, posLocal[1] = %f, posLocal[2] = %f ", posLocal[0],posLocal[1],posLocal[2]));
979
980       //AliInfo(Form(" GetAngles(%1i,%2i) = %f, pos[0] = %f, pos[1] = %f, pos[2] = %f", iplate, istrip, GetAngles(iplate,istrip), pos[0], pos[1], pos[2]));
981       break;
982     }
983
984     if (totStrip>1) AliInfo(Form("total strip number found %2i",totStrip));
985
986   }
987
988   return iStrip;
989   
990 }
991 //_____________________________________________________________________________
992 Int_t AliTOFGeometryV5::GetPadZ(Float_t *pos) const
993 {
994   //
995   // Returns the Pad index along Z 
996   //
997   //const Float_t klsensmx = kNpadX*fgkXPad;  // length of Sensitive Layer
998   //const Float_t khsensmy = 0.05;//0.11;//0.16;// heigth of Sensitive Layer
999   //const Float_t kwsensmz = kNpadZ*fgkZPad;  // width of Sensitive Layer
1000
1001   Int_t iPadZ = -1;
1002
1003   Float_t posLocal[3];
1004   for (Int_t ii=0; ii<3; ii++) posLocal[ii] = pos[ii];
1005  
1006   Int_t isector = GetSector(posLocal);
1007   if(isector == -1){
1008     //AliError("Detector Index could not be determined");
1009     return iPadZ;}
1010   Int_t iplate =  GetPlate(posLocal);
1011   if(iplate == -1){
1012     //AliError("Detector Index could not be determined");
1013     return iPadZ;}
1014   Int_t istrip =  GetStrip(posLocal);
1015   if(istrip == -1){
1016     //AliError("Detector Index could not be determined");
1017     return iPadZ;}
1018
1019   // ALICE reference frame -> B071/B074/B075 = BTO1/2/3 reference frame
1020   Double_t angles[6] = 
1021     {90., 90.+(isector+0.5)*fPhiSec,
1022       0., 0.,
1023      90., (isector+0.5)*fPhiSec
1024     };
1025   Rotation(posLocal,angles);
1026
1027   Float_t step[3] = {0., 0., (fgkRmax+fgkRmin)*0.5};
1028   Translation(posLocal,step);
1029
1030   // B071/B074/B075 = BTO1/2/3 reference frame -> FTOA = FLTA reference frame
1031   angles[0] = 90.;
1032   angles[1] =  0.;
1033   angles[2] =  0.;
1034   angles[3] =  0.;
1035   angles[4] = 90.;
1036   angles[5] =270.;
1037
1038   Rotation(posLocal,angles);
1039
1040   // FTOA/B/C = FLTA/B/C reference frame -> FSTR reference frame
1041   step[0] = 0.;
1042   step[1] = GetHeights(iplate,istrip);
1043   step[2] = -GetDistances(iplate,istrip);
1044   Translation(posLocal,step);
1045
1046   if      (GetAngles(iplate,istrip) >0.) {
1047     angles[0] = 90.;
1048     angles[1] =  0.;
1049     angles[2] = 90.+GetAngles(iplate,istrip);
1050     angles[3] = 90.;
1051     angles[4] = GetAngles(iplate,istrip);
1052     angles[5] = 90.;
1053   }
1054   else if (GetAngles(iplate,istrip)==0.) {
1055     angles[0] = 90.;
1056     angles[1] =  0.;
1057     angles[2] = 90.;
1058     angles[3] = 90.;
1059     angles[4] =  0;
1060     angles[5] =  0.;
1061   }
1062   else if (GetAngles(iplate,istrip) <0.) {
1063     angles[0] = 90.;
1064     angles[1] =  0.;
1065     angles[2] = 90.+GetAngles(iplate,istrip);
1066     angles[3] = 90.;
1067     angles[4] =-GetAngles(iplate,istrip);
1068     angles[5] = 270.;
1069   }
1070   Rotation(posLocal,angles);
1071
1072   //if (TMath::Abs(posLocal[0])<=klsensmx*0.5 && /*TMath::Abs(posLocal[1])<=khsensmy*0.5+0.005 &&*/ TMath::Abs(posLocal[2])<=kwsensmz*0.5) {
1073   //if (TMath::Abs(posLocal[1])<=khsensmy*0.5) {
1074
1075     step[0] =-0.5*kNpadX*fgkXPad;
1076     step[1] = 0.;
1077     step[2] =-0.5*kNpadZ*fgkZPad;
1078     Translation(posLocal,step);
1079
1080     iPadZ = (Int_t)(posLocal[2]/fgkZPad);
1081     if (iPadZ==kNpadZ) iPadZ--;
1082     else if (iPadZ>kNpadZ) iPadZ=-1;
1083
1084   //}
1085   // else AliError("Detector Index could not be determined");
1086
1087   return iPadZ;
1088
1089 }
1090 //_____________________________________________________________________________
1091 Int_t AliTOFGeometryV5::GetPadX(Float_t *pos) const
1092 {
1093   //
1094   // Returns the Pad index along X 
1095   //
1096   //const Float_t klsensmx = kNpadX*fgkXPad;  // length of Sensitive Layer
1097   //const Float_t khsensmy = 0.05;//0.11;//0.16;// heigth of Sensitive Layer
1098   //const Float_t kwsensmz = kNpadZ*fgkZPad;  // width of Sensitive Layer
1099
1100   Int_t iPadX  = -1;
1101
1102   Float_t posLocal[3];
1103   for (Int_t ii=0; ii<3; ii++) posLocal[ii] = pos[ii];
1104  
1105   Int_t isector = GetSector(posLocal);
1106   if(isector == -1){
1107     //AliError("Detector Index could not be determined");
1108     return iPadX;}
1109   Int_t iplate =  GetPlate(posLocal);
1110   if(iplate == -1){
1111     //AliError("Detector Index could not be determined");
1112     return iPadX;} 
1113   Int_t istrip =  GetStrip(posLocal);
1114   if(istrip == -1){  
1115     //AliError("Detector Index could not be determined");
1116     return iPadX;}
1117
1118   // ALICE reference frame -> B071/B074/B075 = BTO1/2/3 reference frame
1119   Double_t angles[6] = 
1120     {90., 90.+(isector+0.5)*fPhiSec,
1121       0.,  0.,
1122      90., (isector+0.5)*fPhiSec
1123     };
1124   Rotation(posLocal,angles);
1125
1126   Float_t step[3] = {0., 0., (fgkRmax+fgkRmin)*0.5};
1127   Translation(posLocal,step);
1128
1129   // B071/B074/B075 = BTO1/2/3 reference frame -> FTOA/B/C = FLTA/B/C reference frame
1130   angles[0] = 90.;
1131   angles[1] =  0.;
1132   angles[2] =  0.;
1133   angles[3] =  0.;
1134   angles[4] = 90.;
1135   angles[5] =270.;
1136
1137   Rotation(posLocal,angles);
1138
1139   // FTOA/B/C = FLTA/B/C reference frame -> FSTR reference frame
1140   step[0] = 0.;
1141   step[1] = GetHeights(iplate,istrip);
1142   step[2] = -GetDistances(iplate,istrip);
1143   Translation(posLocal,step);
1144
1145   if      (GetAngles(iplate,istrip) >0.) {
1146     angles[0] = 90.;
1147     angles[1] =  0.;
1148     angles[2] = 90.+GetAngles(iplate,istrip);
1149     angles[3] = 90.;
1150     angles[4] = GetAngles(iplate,istrip);
1151     angles[5] = 90.;
1152   }
1153   else if (GetAngles(iplate,istrip)==0.) {
1154     angles[0] = 90.;
1155     angles[1] =  0.;
1156     angles[2] = 90.;
1157     angles[3] = 90.;
1158     angles[4] =  0;
1159     angles[5] =  0.;
1160   }
1161   else if (GetAngles(iplate,istrip) <0.) {
1162     angles[0] = 90.;
1163     angles[1] =  0.;
1164     angles[2] = 90.+GetAngles(iplate,istrip);
1165     angles[3] = 90.;
1166     angles[4] =-GetAngles(iplate,istrip);
1167     angles[5] = 270.;
1168   }
1169   Rotation(posLocal,angles);
1170
1171   //if (TMath::Abs(posLocal[0])<=klsensmx*0.5 && /*TMath::Abs(posLocal[1])<=khsensmy*0.5+0.005 &&*/ TMath::Abs(posLocal[2])<=kwsensmz*0.5) {
1172   //if (TMath::Abs(posLocal[1])<=khsensmy*0.5) {
1173
1174     step[0] =-0.5*kNpadX*fgkXPad;
1175     step[1] = 0.;
1176     step[2] =-0.5*kNpadZ*fgkZPad;
1177     Translation(posLocal,step);
1178
1179     iPadX = (Int_t)(posLocal[0]/fgkXPad);
1180     if (iPadX==kNpadX) iPadX--;
1181     else if (iPadX>kNpadX) iPadX=-1;
1182
1183   //}
1184   //else AliError("Detector Index could not be determined");
1185
1186   return iPadX;
1187
1188 }
1189 //_____________________________________________________________________________
1190
1191 Float_t AliTOFGeometryV5::GetPadDx(Float_t *pos)
1192 {
1193   //
1194   // Returns the x coordinate in the Pad reference frame
1195   //
1196
1197   Float_t xpad = -2.;
1198
1199   Float_t posLocal[3];
1200   for (Int_t ii=0; ii<3; ii++) posLocal[ii] = pos[ii];
1201  
1202   Int_t isector = GetSector(posLocal);
1203   if(isector == -1){
1204     //AliError("Detector Index could not be determined");
1205     return xpad;}
1206   Int_t iplate =  GetPlate(posLocal);
1207   if(iplate == -1){
1208     //AliError("Detector Index could not be determined");
1209     return xpad;} 
1210   Int_t istrip =  GetStrip(posLocal);
1211   if(istrip == -1){  
1212     //AliError("Detector Index could not be determined");
1213     return xpad;}
1214   Int_t ipadz =  GetPadZ(posLocal);
1215   if(ipadz == -1){  
1216     //AliError("Detector Index could not be determined");
1217     return xpad;}
1218   Int_t ipadx =  GetPadX(posLocal);
1219   if(ipadx == -1){
1220     //AliError("Detector Index could not be determined");
1221     return xpad;}
1222
1223   // ALICE reference frame -> B071/B074/B075 = BTO1/2/3 reference frame
1224   Double_t angles[6] = 
1225     {90., 90.+(isector+0.5)*fPhiSec,
1226       0.,  0.,
1227      90., (isector+0.5)*fPhiSec
1228     };
1229   Rotation(posLocal,angles);
1230
1231   Float_t step[3] = {0., 0., (fgkRmax+fgkRmin)*0.5};
1232   Translation(posLocal,step);
1233
1234   // B071/B074/B075 = BTO1/2/3 reference frame -> FTOA/B/C = FLTA/B/C reference frame
1235   angles[0] = 90.;
1236   angles[1] =  0.;
1237   angles[2] =  0.;
1238   angles[3] =  0.;
1239   angles[4] = 90.;
1240   angles[5] =270.;
1241
1242   Rotation(posLocal,angles);
1243
1244   // FTOA/B/C = FLTA/B/C reference frame -> FSTR reference frame
1245   step[0] = 0.;
1246   step[1] = GetHeights(iplate,istrip);
1247   step[2] = -GetDistances(iplate,istrip);
1248   Translation(posLocal,step);
1249
1250   if      (GetAngles(iplate,istrip) >0.) {
1251     angles[0] = 90.;
1252     angles[1] =  0.;
1253     angles[2] = 90.+GetAngles(iplate,istrip);
1254     angles[3] = 90.;
1255     angles[4] = GetAngles(iplate,istrip);
1256     angles[5] = 90.;
1257   }
1258   else if (GetAngles(iplate,istrip)==0.) {
1259     angles[0] = 90.;
1260     angles[1] =  0.;
1261     angles[2] = 90.;
1262     angles[3] = 90.;
1263     angles[4] =  0;
1264     angles[5] =  0.;
1265   }
1266   else if (GetAngles(iplate,istrip) <0.) {
1267     angles[0] = 90.;
1268     angles[1] =  0.;
1269     angles[2] = 90.+GetAngles(iplate,istrip);
1270     angles[3] = 90.;
1271     angles[4] =-GetAngles(iplate,istrip);
1272     angles[5] = 270.;
1273   }
1274   Rotation(posLocal,angles);
1275
1276   step[0] =-0.5*kNpadX*fgkXPad;
1277   step[1] = 0.;
1278   step[2] =-0.5*kNpadZ*fgkZPad;
1279   Translation(posLocal,step);
1280
1281   step[0] = (ipadx+0.5)*fgkXPad;
1282   step[1] = 0.;
1283   step[2] = (ipadz+0.5)*fgkZPad;
1284   Translation(posLocal,step);
1285   
1286   xpad=posLocal[0];
1287
1288   return xpad;
1289
1290 }
1291 //_____________________________________________________________________________
1292 Float_t AliTOFGeometryV5::GetPadDy(Float_t *pos)
1293 {
1294   //
1295   // Returns the y coordinate in the Pad reference frame
1296   //
1297
1298   Float_t ypad = -2.;
1299
1300   Float_t posLocal[3];
1301   for (Int_t ii=0; ii<3; ii++) posLocal[ii] = pos[ii];
1302  
1303   Int_t isector = GetSector(posLocal);
1304   if(isector == -1){
1305     //AliError("Detector Index could not be determined");
1306     return ypad;}
1307   Int_t iplate =  GetPlate(posLocal);
1308   if(iplate == -1){
1309     //AliError("Detector Index could not be determined");
1310     return ypad;} 
1311   Int_t istrip =  GetStrip(posLocal);
1312   if(istrip == -1){  
1313     //AliError("Detector Index could not be determined");
1314     return ypad;}
1315   Int_t ipadz =  GetPadZ(posLocal);
1316   if(ipadz == -1){  
1317     //AliError("Detector Index could not be determined");
1318     return ypad;}
1319   Int_t ipadx =  GetPadX(posLocal);
1320   if(ipadx == -1){
1321     //AliError("Detector Index could not be determined");
1322     return ypad;}
1323
1324   // ALICE reference frame -> B071/B074/B075 = BTO1/2/3 reference frame
1325   Double_t angles[6] = 
1326     {90., 90.+(isector+0.5)*fPhiSec,
1327       0.,  0.,
1328      90., (isector+0.5)*fPhiSec
1329     };
1330   Rotation(posLocal,angles);
1331
1332   Float_t step[3] = {0., 0., (fgkRmax+fgkRmin)*0.5};
1333   Translation(posLocal,step);
1334
1335   // B071/B074/B075 = BTO1/2/3 reference frame -> FTOA/B/C = FLTA/B/C reference frame
1336   angles[0] = 90.;
1337   angles[1] =  0.;
1338   angles[2] =  0.;
1339   angles[3] =  0.;
1340   angles[4] = 90.;
1341   angles[5] =270.;
1342
1343   Rotation(posLocal,angles);
1344
1345   // FTOA/B/C = FLTA/B/C reference frame -> FSTR reference frame
1346   step[0] = 0.;
1347   step[1] = GetHeights(iplate,istrip);
1348   step[2] = -GetDistances(iplate,istrip);
1349   Translation(posLocal,step);
1350
1351   if      (GetAngles(iplate,istrip) >0.) {
1352     angles[0] = 90.;
1353     angles[1] =  0.;
1354     angles[2] = 90.+GetAngles(iplate,istrip);
1355     angles[3] = 90.;
1356     angles[4] = GetAngles(iplate,istrip);
1357     angles[5] = 90.;
1358   }
1359   else if (GetAngles(iplate,istrip)==0.) {
1360     angles[0] = 90.;
1361     angles[1] =  0.;
1362     angles[2] = 90.;
1363     angles[3] = 90.;
1364     angles[4] =  0;
1365     angles[5] =  0.;
1366   }
1367   else if (GetAngles(iplate,istrip) <0.) {
1368     angles[0] = 90.;
1369     angles[1] =  0.;
1370     angles[2] = 90.+GetAngles(iplate,istrip);
1371     angles[3] = 90.;
1372     angles[4] =-GetAngles(iplate,istrip);
1373     angles[5] = 270.;
1374   }
1375   Rotation(posLocal,angles);
1376
1377   step[0] =-0.5*kNpadX*fgkXPad;
1378   step[1] = 0.;
1379   step[2] =-0.5*kNpadZ*fgkZPad;
1380   Translation(posLocal,step);
1381   
1382   step[0] = (ipadx+0.5)*fgkXPad;
1383   step[1] = 0.;
1384   step[2] = (ipadz+0.5)*fgkZPad;
1385   Translation(posLocal,step);
1386   
1387   ypad=posLocal[1];
1388   
1389   return ypad;
1390
1391 }
1392 //_____________________________________________________________________________
1393 Float_t AliTOFGeometryV5::GetPadDz(Float_t *pos)
1394 {
1395   //
1396   // Returns the z coordinate in the Pad reference frame
1397   //
1398
1399   Float_t zpad = -2.;
1400
1401   Float_t posLocal[3];
1402   for (Int_t ii=0; ii<3; ii++) posLocal[ii] = pos[ii];
1403  
1404   Int_t isector = GetSector(posLocal);
1405   if(isector == -1){
1406     //AliError("Detector Index could not be determined");
1407     return zpad;}
1408   Int_t iplate =  GetPlate(posLocal);
1409   if(iplate == -1){
1410     //AliError("Detector Index could not be determined");
1411     return zpad;} 
1412   Int_t istrip =  GetStrip(posLocal);
1413   if(istrip == -1){  
1414     //AliError("Detector Index could not be determined");
1415     return zpad;}
1416   Int_t ipadz =  GetPadZ(posLocal);
1417   if(ipadz == -1){  
1418     //AliError("Detector Index could not be determined");
1419     return zpad;}
1420   Int_t ipadx =  GetPadX(posLocal);
1421   if(ipadx == -1){
1422     //AliError("Detector Index could not be determined");
1423     return zpad;}
1424
1425   // ALICE reference frame -> B071/B074/B075 = BTO1/2/3 reference frame
1426   Double_t angles[6] = 
1427     {90., 90.+(isector+0.5)*fPhiSec,
1428       0.,  0.,
1429      90., (isector+0.5)*fPhiSec
1430     };
1431   Rotation(posLocal,angles);
1432
1433   Float_t step[3] = {0., 0., (fgkRmax+fgkRmin)*0.5};
1434   Translation(posLocal,step);
1435
1436   // B071/B074/B075 = BTO1/2/3 reference frame -> FTOA/B/C = FLTA/B/C reference frame
1437   angles[0] = 90.;
1438   angles[1] =  0.;
1439   angles[2] =  0.;
1440   angles[3] =  0.;
1441   angles[4] = 90.;
1442   angles[5] =270.;
1443
1444   Rotation(posLocal,angles);
1445
1446   // FTOA/B/C = FLTA/B/C reference frame -> FSTR reference frame
1447   step[0] = 0.;
1448   step[1] = GetHeights(iplate,istrip);
1449   step[2] = -GetDistances(iplate,istrip);
1450   Translation(posLocal,step);
1451
1452   if      (GetAngles(iplate,istrip) >0.) {
1453     angles[0] = 90.;
1454     angles[1] =  0.;
1455     angles[2] = 90.+GetAngles(iplate,istrip);
1456     angles[3] = 90.;
1457     angles[4] = GetAngles(iplate,istrip);
1458     angles[5] = 90.;
1459   }
1460   else if (GetAngles(iplate,istrip)==0.) {
1461     angles[0] = 90.;
1462     angles[1] =  0.;
1463     angles[2] = 90.;
1464     angles[3] = 90.;
1465     angles[4] =  0;
1466     angles[5] =  0.;
1467   }
1468   else if (GetAngles(iplate,istrip) <0.) {
1469     angles[0] = 90.;
1470     angles[1] =  0.;
1471     angles[2] = 90.+GetAngles(iplate,istrip);
1472     angles[3] = 90.;
1473     angles[4] =-GetAngles(iplate,istrip);
1474     angles[5] = 270.;
1475   }
1476   Rotation(posLocal,angles);
1477
1478   step[0] =-0.5*kNpadX*fgkXPad;
1479   step[1] = 0.;
1480   step[2] =-0.5*kNpadZ*fgkZPad;
1481   Translation(posLocal,step);
1482   
1483   step[0] = (ipadx+0.5)*fgkXPad;
1484   step[1] = 0.;
1485   step[2] = (ipadz+0.5)*fgkZPad;
1486   Translation(posLocal,step);
1487
1488   zpad=posLocal[2];
1489
1490   return zpad;
1491
1492 }
1493 //_____________________________________________________________________________
1494
1495 void AliTOFGeometryV5::Translation(Float_t *xyz, Float_t translationVector[3]) const
1496 {
1497   //
1498   // Return the vector xyz translated by translationVector vector
1499   //
1500
1501   Int_t ii=0;
1502
1503   for (ii=0; ii<3; ii++)
1504     xyz[ii] -= translationVector[ii];
1505
1506   return;
1507
1508 }
1509 //_____________________________________________________________________________
1510
1511 void AliTOFGeometryV5::Rotation(Float_t *xyz, Double_t rotationAngles[6]) const
1512 {
1513   //
1514   // Return the vector xyz rotated according to the rotationAngles angles
1515   //
1516
1517   Int_t ii=0;
1518   /*
1519   TRotMatrix *matrix = new TRotMatrix("matrix","matrix", angles[0], angles[1],
1520                                       angles[2], angles[3],
1521                                       angles[4], angles[5]);
1522   */
1523
1524   for (ii=0; ii<6; ii++) rotationAngles[ii]*=kDegrad;
1525
1526   Float_t xyzDummy[3] = {0., 0., 0.};
1527
1528   for (ii=0; ii<3; ii++) {
1529     xyzDummy[ii] =
1530       xyz[0]*TMath::Sin(rotationAngles[2*ii])*TMath::Cos(rotationAngles[2*ii+1]) +
1531       xyz[1]*TMath::Sin(rotationAngles[2*ii])*TMath::Sin(rotationAngles[2*ii+1]) +
1532       xyz[2]*TMath::Cos(rotationAngles[2*ii]);
1533   }
1534
1535   for (ii=0; ii<3; ii++) xyz[ii]=xyzDummy[ii];
1536
1537   return;
1538
1539 }
1540 //_____________________________________________________________________________
1541 void AliTOFGeometryV5::InverseRotation(Float_t *xyz, Double_t rotationAngles[6]) const
1542 {
1543   //
1544   //
1545   //
1546
1547   Int_t ii=0;
1548
1549   for (ii=0; ii<6; ii++) rotationAngles[ii]*=kDegrad;
1550
1551   Float_t xyzDummy[3] = {0., 0., 0.};
1552
1553   xyzDummy[0] =
1554     xyz[0]*TMath::Sin(rotationAngles[0])*TMath::Cos(rotationAngles[1]) +
1555     xyz[1]*TMath::Sin(rotationAngles[2])*TMath::Cos(rotationAngles[3]) +
1556     xyz[2]*TMath::Sin(rotationAngles[4])*TMath::Cos(rotationAngles[5]);
1557   
1558   xyzDummy[1] =
1559     xyz[0]*TMath::Sin(rotationAngles[0])*TMath::Sin(rotationAngles[1]) +
1560     xyz[1]*TMath::Sin(rotationAngles[2])*TMath::Sin(rotationAngles[3]) +
1561     xyz[2]*TMath::Sin(rotationAngles[4])*TMath::Sin(rotationAngles[5]);
1562   
1563   xyzDummy[2] =
1564     xyz[0]*TMath::Cos(rotationAngles[0]) +
1565     xyz[1]*TMath::Cos(rotationAngles[2]) +
1566     xyz[2]*TMath::Cos(rotationAngles[4]);
1567   
1568   for (ii=0; ii<3; ii++) xyz[ii]=xyzDummy[ii];
1569
1570   return;
1571
1572 }
1573 //_____________________________________________________________________________
1574 void AliTOFGeometryV5::GetVolumePath(Int_t *ind, Char_t *path ) {
1575   //--------------------------------------------------------------------
1576   // This function returns the colume path of a given pad 
1577   //--------------------------------------------------------------------
1578   Int_t sector = ind[0];
1579   Char_t  string1[100];
1580   Char_t  string2[100];
1581   Char_t  string3[100];
1582   
1583   Int_t icopy=-1;
1584   icopy=sector;
1585   // Old 6h convention
1586   // if(sector<13){
1587   //    icopy=sector+5;}  
1588   // else{ icopy=sector-13;}
1589   sprintf(string1,"/ALIC_1/B077_1/BSEGMO%i_1/BTOF%i_1/FTOA_0/FLTA_0",icopy,icopy);
1590   
1591   Int_t iplate=ind[1];
1592   Int_t istrip=ind[2];
1593   if( iplate==0) icopy=istrip; 
1594   if( iplate==1) icopy=istrip+NStripC(); 
1595   if( iplate==2) icopy=istrip+NStripC()+NStripB(); 
1596   if( iplate==3) icopy=istrip+NStripC()+NStripB()+NStripA(); 
1597   if( iplate==4) icopy=istrip+NStripC()+2*NStripB()+NStripA(); 
1598   icopy++;
1599   sprintf(string2,"FSTR_%i",icopy);
1600   if(fHoles && (sector==11 || sector==12)){
1601     if(iplate<2)  sprintf(string2,"FTOB_0/FLTB_0/FSTR_%i",icopy);
1602     if(iplate>2)  sprintf(string2,"FTOC_0/FLTC_0/FSTR_%i",icopy);
1603   }
1604  
1605
1606   Int_t padz = ind[3]+1; 
1607   Int_t padx = ind[4]+1;
1608   sprintf(string3,"FPCB_1/FSEN_1/FSEZ_%i/FPAD_%i",padz,padx);
1609   sprintf(path,"%s/%s/%s",string1,string2,string3); 
1610
1611 }
1612 //_____________________________________________________________________________
1613 void AliTOFGeometryV5::GetVolumePath(Int_t sector, Char_t *path ){
1614   //--------------------------------------------------------------------
1615   // This function returns the colume path of a given sector 
1616   //--------------------------------------------------------------------
1617
1618   Char_t string[100];
1619
1620   Int_t icopy = sector;
1621   // Old 6h convention
1622   // if(sector<13){
1623   //    icopy=sector+5;}  
1624   // else{ icopy=sector-13;}
1625
1626   sprintf(string,"/ALIC_1/B077_1/BSEGMO%i_1/BTOF%i_1",icopy,icopy);
1627   sprintf(path,"%s",string);
1628
1629 }
1630 //_____________________________________________________________________________
1631 void AliTOFGeometryV5::GetVolumePath(Int_t sector, Int_t plate, Int_t strip, Char_t *path ) {
1632   //--------------------------------------------------------------------
1633   // This function returns the colume path of a given strip 
1634   //--------------------------------------------------------------------
1635
1636   Char_t string1[100];
1637   Char_t string2[100];
1638   Char_t string3[100];
1639   
1640   Int_t icopy = sector;
1641   // Old 6h convention
1642   // if(sector<13){
1643   //    icopy=sector+5;}  
1644   // else{ icopy=sector-13;}
1645   sprintf(string1,"/ALIC_1/B077_1/BSEGMO%i_1/BTOF%i_1/FTOA_0/FLTA_0",icopy,icopy);
1646   
1647   if(plate==0) icopy=strip; 
1648   if(plate==1) icopy=strip+NStripC(); 
1649   if(plate==2) icopy=strip+NStripC()+NStripB(); 
1650   if(plate==3) icopy=strip+NStripC()+NStripB()+NStripA(); 
1651   if(plate==4) icopy=strip+NStripC()+2*NStripB()+NStripA(); 
1652   icopy++;
1653   sprintf(string2,"FSTR_%i",icopy);
1654   if(fHoles && (sector==11 || sector==12)) {
1655     if(plate<2)  sprintf(string2,"FTOB_0/FLTB_0/FSTR_%i",icopy);
1656     if(plate>2)  sprintf(string2,"FTOC_0/FLTC_0/FSTR_%i",icopy);
1657   }
1658
1659   sprintf(string3,"FPCB_1/FSEN_1");
1660   sprintf(path,"%s/%s/%s",string1,string2,string3); 
1661
1662 }
1663 //_____________________________________________________________________________
1664 void AliTOFGeometryV5::GetPos(Int_t *det, Float_t *pos) 
1665 {
1666 //
1667 // Returns space point coor (x,y,z) (cm)  for Detector 
1668 // Indices  (iSect,iPlate,iStrip,iPadX,iPadZ) 
1669 //
1670   Char_t path[100];
1671   GetVolumePath(det,path );
1672   if (!gGeoManager) {
1673     printf("ERROR: no TGeo\n");
1674   }
1675   gGeoManager->cd(path);
1676   TGeoHMatrix global;
1677   global = *gGeoManager->GetCurrentMatrix();
1678   const Double_t *tr = global.GetTranslation();
1679
1680   pos[0]=tr[0];  
1681   pos[1]=tr[1];  
1682   pos[2]=tr[2];
1683 }
1684 //_____________________________________________________________________________
1685
1686 void AliTOFGeometryV5::DetToSectorRF(Int_t vol[5], Double_t **coord)
1687 {
1688   //
1689   // Returns the local coordinates (x, y, z) in sector reference frame
1690   // for the 4 corners of each sector pad (vol[1], vol[2], vol[3], vol[4])
1691   //
1692
1693   if (!gGeoManager) printf("ERROR: no TGeo\n");
1694
1695   // ALICE -> TOF Sector
1696   Char_t path1[100]="";
1697   GetVolumePath(vol[0],path1);
1698   gGeoManager->cd(path1);
1699   TGeoHMatrix aliceToSector;
1700   aliceToSector = *gGeoManager->GetCurrentMatrix();
1701
1702   // TOF Sector -> ALICE
1703   //TGeoHMatrix sectorToALICE = aliceToSector.Inverse();
1704
1705   // ALICE -> TOF Pad
1706   Char_t path2[100]="";
1707   GetVolumePath(vol,path2);
1708   gGeoManager->cd(path2);
1709   TGeoHMatrix aliceToPad;
1710   aliceToPad = *gGeoManager->GetCurrentMatrix();
1711
1712   // TOF Pad -> ALICE
1713   TGeoHMatrix padToALICE = aliceToPad.Inverse();
1714
1715   // TOF Pad -> TOF Sector
1716   TGeoHMatrix padToSector = padToALICE*aliceToSector;
1717
1718   // TOF Sector -> TOF Pad
1719   //TGeoHMatrix sectorToPad = sectorToALICE*aliceToPad;
1720
1721   // coordinates of the pad bottom corner
1722   Double_t **cornerPad = new Double_t*[4];
1723   for (Int_t ii=0; ii<4; ii++) cornerPad[ii] = new Double_t[3];
1724
1725   cornerPad[0][0] = -fgkXPad/2.;
1726   cornerPad[0][1] =  0.;
1727   cornerPad[0][2] = -fgkZPad/2.;
1728
1729   cornerPad[1][0] =  fgkXPad/2.;
1730   cornerPad[1][1] =  0.;
1731   cornerPad[1][2] = -fgkZPad/2.;
1732
1733   cornerPad[2][0] =  fgkXPad/2.;
1734   cornerPad[2][1] =  0.;
1735   cornerPad[2][2] =  fgkZPad/2.;
1736
1737   cornerPad[3][0] = -fgkXPad/2.;
1738   cornerPad[3][1] =  0.;
1739   cornerPad[3][2] =  fgkZPad/2.;
1740
1741   for(Int_t aa=0; aa<4; aa++) for(Int_t bb=0; bb<3; bb++) coord[aa][bb]=0.;
1742
1743   for (Int_t jj=0; jj<4; jj++) padToSector.MasterToLocal(&cornerPad[jj][0], &coord[jj][0]);
1744
1745   delete cornerPad;
1746
1747   //sectorToPad.LocalToMaster(cornerPad, coord);
1748
1749 }