]> git.uio.no Git - u/mrichter/AliRoot.git/blob - TOF/AliTOFGeometry.cxx
Adding -Woverloaded-virtual to the CXXFLAGS. Removing temporary -Werror
[u/mrichter/AliRoot.git] / TOF / AliTOFGeometry.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.7  2004/11/05 07:20:08  decaro
19 TOF library splitting and conversion of some printout messages in AliLog schema (T.Kuhr)
20
21 Revision 1.6  2004/06/15 15:27:59  decaro
22 TOF raw data: preliminary implementation and style changes
23
24 Revision 1.5  2004/04/20 14:37:22  hristov
25 Using TMath::Abs instead of fabs, arrays of variable size created/deleted correctly (HP,Sun)
26
27 Revision 1.4  2004/04/13 09:42:51  decaro
28 Track reconstruction code for TOF: updating
29
30 Revision 1.3  2003/12/29 18:40:39  hristov
31 Copy/paste error corrected
32
33 Revision 1.2  2003/12/29 17:26:01  hristov
34 Using enum to initaialize static ints in the header file, the initialization of static floats moved to the implementation file
35
36 Revision 1.1  2003/12/29 15:18:03  decaro
37 TOF geometry updating (addition of AliTOFGeometry)
38
39 Revision 0.05  2004/6/11 A.De Caro
40         Implement Global method NpadXStrip
41         Insert four float constants (originally  in AliTOF class)
42 Revision 0.04  2004/4/05 S.Arcelli
43         Implement Global methods IsInsideThePad 
44                                   DistanceToPad 
45 Revision 0.03  2003/12/14 S.Arcelli
46         Set Phi range [-180,180]->[0,360] 
47 Revision 0.02  2003/12/10 S.Arcelli:
48         Implement Global methods GetPos & GetDetID 
49 Revision 0.01  2003/12/04 S.Arcelli
50 */
51
52 #include <stdlib.h>
53 #include <Riostream.h>
54 ///////////////////////////////////////////////////////////////////////////////
55 //                                                                           //
56 //  TOF Geometry class                                                       //
57 //                                                                           //
58 ///////////////////////////////////////////////////////////////////////////////
59
60 #include "AliLog.h"
61 #include "AliConst.h"
62 #include "AliTOFGeometry.h"
63
64 ClassImp(AliTOFGeometry)
65
66 const Int_t AliTOFGeometry::fgkTimeDiff   = 25000;  // Min signal separation (ps)
67
68 const Float_t AliTOFGeometry::fgkxTOF     = 371.;   // Inner radius of the TOF for Reconstruction (cm)
69 const Float_t AliTOFGeometry::fgkRmin     = 370.;   // Inner radius of the TOF (cm)
70 const Float_t AliTOFGeometry::fgkRmax     = 399;    // Outer radius of the TOF (cm)
71 const Float_t AliTOFGeometry::fgkZlenA    = 106.0;  // length (cm) of the A module
72 const Float_t AliTOFGeometry::fgkZlenB    = 141.0;  // length (cm) of the B module
73 const Float_t AliTOFGeometry::fgkZlenC    = 177.5;  // length (cm) of the C module
74 const Float_t AliTOFGeometry::fgkXPad     = 2.5;    // Pad size in the x direction (cm)
75 const Float_t AliTOFGeometry::fgkZPad     = 3.5;    // Pad size in the z direction (cm)
76 const Float_t AliTOFGeometry::fgkMaxhZtof = 371.5;  // Max half z-size of TOF (cm)
77 const Float_t AliTOFGeometry::fgkStripLength = 122.;// Strip Length (rho X phi direction) (cm)
78 const Float_t AliTOFGeometry::fgkDeadBndX = 1.0;    // Dead Boundaries of a Strip along X direction (length) (cm)
79 const Float_t AliTOFGeometry::fgkDeadBndZ = 1.5;    // Dead Boundaries of a Strip along Z direction (width) (cm)
80 const Float_t AliTOFGeometry::fgkOverSpc = 15.3;    // Space available for sensitive layers in radial direction (cm)
81
82
83 const Float_t AliTOFGeometry::fgkSigmaForTail1= 2.;//Sig1 for simulation of TDC tails 
84 const Float_t AliTOFGeometry::fgkSigmaForTail2= 0.5;//Sig2 for simulation of TDC tails
85 const Float_t AliTOFGeometry::fgkSpeedOfLight = 0.299792458;// c (10^9 m/s)
86 const Float_t AliTOFGeometry::fgkPionMass     = 0.13957;// pion mass (Gev/c^2)
87 const Float_t AliTOFGeometry::fgkKaonMass     = 0.49368;// kaon mass (Gev/c^2)
88 const Float_t AliTOFGeometry::fgkProtonMass   = 0.93827;// proton mass (Gev/c^2)
89 const Float_t AliTOFGeometry::fgkElectronMass = 0.00051;// electron mass (Gev/c^2)
90 const Float_t AliTOFGeometry::fgkMuonMass     = 0.10566;// muon mass (Gev/c^2)
91
92
93 const Float_t AliTOFGeometry::fgkDprecMin = 0.0000075;//num.prec.tolerance on Thmin 
94 const Float_t AliTOFGeometry::fgkDprecMax = 0.0000100;//num.prec.tolerance on Thma 
95 const Float_t AliTOFGeometry::fgkDprecCen = 0.0000005;//num.prec.tolerance on <Theta> 
96
97 const Float_t AliTOFGeometry::fgkTdcBin = 24.4; // time-window for the TDC bins [ps]
98
99 //_____________________________________________________________________________
100 AliTOFGeometry::AliTOFGeometry()
101 {
102   //
103   // AliTOFGeometry default constructor
104   //
105   Init();
106
107 }
108
109 //_____________________________________________________________________________
110 AliTOFGeometry::~AliTOFGeometry()
111 {
112   //
113   // AliTOFGeometry destructor
114   //
115
116 }
117 //_____________________________________________________________________________
118 void AliTOFGeometry::Init()
119 {
120   //
121   // Initialize strip Tilt Angles and Heights
122   //
123   // Strips Tilt Angles
124  
125   Float_t const kangles[kNPlates][kMaxNstrip] ={
126
127  {44.494, 43.725, 42.946, 42.156, 41.357, 40.548, 39.729, 38.899, 
128   38.060, 37.211, 36.353, 35.484, 34.606, 33.719, 32.822, 31.916, 
129   31.001, 30.077, 29.144, 28.202 },
130
131  {26.884, 25.922, 24.952, 23.975, 22.989, 22.320, 21.016, 20.309,
132   19.015, 18.270, 16.989, 16.205, 14.941, 14.117, 12.871, 12.008,
133   10.784, 9.8807, 8.681, 0.0 },
134
135  { 7.5835, 6.4124, 5.4058, 4.2809, 3.2448,  2.1424, 1.078, -0., -1.078, 
136   -2.1424, -3.2448, -4.2809, -5.4058, -6.4124, -7.5835, 0.0, 0.0, 0.0,
137   0.0, 0.0 },
138   
139  {-8.681, -9.8807, -10.784, -12.008, -12.871, -14.117, -14.941, -16.205,
140   -16.989, -18.27, -19.015, -20.309, -21.016, -22.32, -22.989,
141    -23.975, -24.952, -25.922, -26.884, 0. },
142   
143  {-28.202, -29.144, -30.077, -31.001, -31.916, -32.822, -33.719, -34.606,
144   -35.484, -36.353, -37.211, -38.06, -38.899, -39.729, -40.548,
145    -41.357, -42.156, -42.946, -43.725, -44.494 }};
146
147
148   //Strips Heights
149
150    Float_t const kheights[kNPlates][kMaxNstrip]= {
151
152   {-5.5, -5.5, -5.5, -5.5, -5.5, -5.5, -5.5, -5.5, -5.5, -5.5,
153    -5.5, -5.5, -5.5, -5.5, -5.5, -5.5, -5.5, -5.5, -5.5, -5.5 },
154   
155   {-6.3, -7.1, -7.9, -8.7, -9.5, -3, -9.5,   -3, -9.5,   -3, 
156    -9.5, -3.0, -9.5, -3.0, -9.5, -3, -9.5,   -3,   -9 , 0.},
157   
158   {  -3,   -9, -4.5,   -9, -4.5,     -9, -4.5,   -9, -4.5,   -9, 
159      -4.5,   -9, -4.5,   -9,   -3,   0.0, 0.0, 0.0, 0.0, 0.0 },
160   
161   {  -9,   -3, -9.5,   -3, -9.5, -3, -9.5,   -3, -9.5,   -3, -9.5,
162      -3, -9.5,   -3, -9.5,  -8.7, -7.9, -7.1, -6.3, 0. },
163   
164   {-5.5, -5.5, -5.5, -5.5, -5.5, -5.5, -5.5, -5.5, -5.5, -5.5,
165    -5.5, -5.5, -5.5, -5.5, -5.5, -5.5, -5.5, -5.5, -5.5, -5.5 }};
166
167
168    // Deposit in fAngles, fHeights
169
170   for (Int_t iplate = 0; iplate < kNPlates; iplate++) {
171     for (Int_t istrip = 0; istrip < kMaxNstrip; istrip++) {
172       fAngles[iplate][istrip]   = kangles[iplate][istrip];
173       fHeights[iplate][istrip]  = kheights[iplate][istrip];
174     }
175   }
176
177   fPhiSec   = 360./kNSectors;
178 }
179
180 //_____________________________________________________________________________
181 Float_t AliTOFGeometry::DistanceToPad(Int_t *det, Float_t *pos) 
182 {
183 //
184 // Returns distance of  space point with coor pos (x,y,z) (cm) wrt 
185 // pad with Detector Indices idet (iSect,iPlate,iStrip,iPadX,iPadZ) 
186 //
187     
188   //Transform pos into Sector Frame
189
190   Float_t x = pos[0];
191   Float_t y = pos[1];
192   Float_t z = pos[2];
193
194   Float_t radius = TMath::Sqrt(x*x+y*y);
195   Float_t phi=TMath::ATan2(y,x);        
196   if(phi<0) phi=2.*TMath::Pi()+phi;
197   //  Get the local angle in the sector philoc
198   Float_t angle   = phi*kRaddeg-( Int_t (kRaddeg*phi/20.) + 0.5)*fPhiSec;
199   Float_t xs = radius*TMath::Cos(angle/kRaddeg);
200   Float_t ys = radius*TMath::Sin(angle/kRaddeg);
201   Float_t zs = z;
202
203   // Do the same for the selected pad
204
205   Float_t g[3];
206   GetPos(det,g);
207
208   Float_t padRadius = TMath::Sqrt(g[0]*g[0]+g[1]*g[1]);
209   Float_t padPhi=TMath::ATan2(g[1],g[0]);       
210   if(padPhi<0) padPhi=2.*TMath::Pi()+padPhi;
211   //  Get the local angle in the sector philoc
212   Float_t padAngle   = padPhi*kRaddeg-( Int_t (padPhi*kRaddeg/20.)+ 0.5) * fPhiSec; 
213   Float_t padxs = padRadius*TMath::Cos(padAngle/kRaddeg);
214   Float_t padys = padRadius*TMath::Sin(padAngle/kRaddeg);
215   Float_t padzs = g[2];
216   
217   //Now move to local pad coordinate frame. Translate:
218   
219   Float_t xt = xs-padxs;
220   Float_t yt = ys-padys;
221   Float_t zt = zs-padzs;
222   //Now Rotate:
223   
224   Float_t alpha = GetAngles(det[1],det[2]);
225   Float_t xr = xt*TMath::Cos(alpha/kRaddeg)+zt*TMath::Sin(alpha/kRaddeg);
226   Float_t yr = yt;
227   Float_t zr = -xt*TMath::Sin(alpha/kRaddeg)+zt*TMath::Cos(alpha/kRaddeg);
228
229   Float_t dist = TMath::Sqrt(xr*xr+yr*yr+zr*zr);
230   return dist;
231
232 }
233
234
235 //_____________________________________________________________________________
236 Bool_t AliTOFGeometry::IsInsideThePad(Int_t *det, Float_t *pos) 
237 {
238 //
239 // Returns true if space point with coor pos (x,y,z) (cm) falls 
240 // inside pad with Detector Indices idet (iSect,iPlate,iStrip,iPadX,iPadZ) 
241 //
242
243   Bool_t isInside=false; 
244
245     
246   //Transform pos into Sector Frame
247
248   Float_t x = pos[0];
249   Float_t y = pos[1];
250   Float_t z = pos[2];
251
252   Float_t radius = TMath::Sqrt(x*x+y*y);
253   Float_t phi=TMath::ATan2(y,x);        
254   if(phi<0) phi=2.*TMath::Pi()+phi;
255   //  Get the local angle in the sector philoc
256   Float_t angle   = phi*kRaddeg-( Int_t (kRaddeg*phi/20.) + 0.5) *fPhiSec;
257   Float_t xs = radius*TMath::Cos(angle/kRaddeg);
258   Float_t ys = radius*TMath::Sin(angle/kRaddeg);
259   Float_t zs = z;
260
261   // Do the same for the selected pad
262
263   Float_t g[3];
264   GetPos(det,g);
265
266   Float_t padRadius = TMath::Sqrt(g[0]*g[0]+g[1]*g[1]);
267   Float_t padPhi=TMath::ATan2(g[1],g[0]);       
268   if(padPhi<0) padPhi=2.*TMath::Pi()+padPhi;
269   //  Get the local angle in the sector philoc
270   Float_t padAngle   = padPhi*kRaddeg-( Int_t (padPhi*kRaddeg/20.)+ 0.5) * fPhiSec; 
271   Float_t padxs = padRadius*TMath::Cos(padAngle/kRaddeg);
272   Float_t padys = padRadius*TMath::Sin(padAngle/kRaddeg);
273   Float_t padzs = g[2];
274   
275   //Now move to local pad coordinate frame. Translate:
276   
277   Float_t xt = xs-padxs;
278   Float_t yt = ys-padys;
279   Float_t zt = zs-padzs;
280   //Now Rotate:
281   
282   Float_t alpha = GetAngles(det[1],det[2]);
283   Float_t xr = xt*TMath::Cos(alpha/kRaddeg)+zt*TMath::Sin(alpha/kRaddeg);
284   Float_t yr = yt;
285   Float_t zr = -xt*TMath::Sin(alpha/kRaddeg)+zt*TMath::Cos(alpha/kRaddeg);
286
287   if(TMath::Abs(xr)<=0.75 && TMath::Abs(yr)<= (fgkXPad*0.5) && TMath::Abs(zr)<= (fgkZPad*0.5))
288     isInside=true; 
289   return isInside;
290
291 }
292
293 //_____________________________________________________________________________
294 void AliTOFGeometry::GetPos(Int_t *det, Float_t *pos) 
295 {
296 //
297 // Returns space point coor (x,y,z) (cm)  for Detector 
298 // Indices  (iSect,iPlate,iStrip,iPadX,iPadZ) 
299 //
300
301   pos[0]=GetX(det);  
302   pos[1]=GetY(det);  
303   pos[2]=GetZ(det);
304   
305 }
306 //_____________________________________________________________________________
307 void AliTOFGeometry::GetDetID( Float_t *pos, Int_t *det) 
308 {
309  //
310  // Returns Detector Indices (iSect,iPlate,iStrip,iPadX,iPadZ) 
311  // space point coor (x,y,z) (cm)  
312
313
314   det[0]=GetSector(pos);  
315   det[1]=GetPlate(pos);  
316   det[2]=GetStrip(pos);
317   det[3]=GetPadZ(pos);
318   det[4]=GetPadX(pos);
319   
320 }
321 //_____________________________________________________________________________
322 Float_t AliTOFGeometry::GetX(Int_t *det) 
323 {
324   //
325   // Returns X coordinate (cm)
326   //
327
328   Int_t isector = det[0];
329   Int_t iplate  = det[1];
330   Int_t istrip  = det[2];
331   Int_t ipadz   = det[3];
332   Int_t ipadx   = det[4];
333
334   // Find out distance d on the plane wrt median phi:
335   Float_t d = (ipadx+0.5)*fgkXPad-(kNpadX*fgkXPad)*0.5;
336
337   // The radius r in xy plane:
338   Float_t r = (fgkRmin+fgkRmax)/2.+fHeights[iplate][istrip]+
339     (ipadz-0.5)*fgkZPad*TMath::Sin(fAngles[iplate][istrip]/kRaddeg)-0.25;
340
341   // local azimuthal angle in the sector philoc
342   Float_t philoc   = TMath:: ATan(d/r);
343
344   // azimuthal angle in the global frame  phi
345   Float_t phi      = philoc*kRaddeg+(isector+0.5 )*fPhiSec;                    
346
347   Float_t xCoor    = r/TMath::Cos(philoc)*TMath::Cos(phi/kRaddeg);
348   return xCoor;
349
350 }
351 //_____________________________________________________________________________
352 Float_t AliTOFGeometry::GetY(Int_t *det) 
353 {
354   //
355   // Returns Y coordinate (cm)
356   //
357
358   Int_t isector = det[0];
359   Int_t iplate  = det[1];
360   Int_t istrip  = det[2];
361   Int_t ipadz   = det[3];
362   Int_t ipadx   = det[4];
363
364   // Find out distance d on the plane wrt median phi:
365   Float_t d = (ipadx+0.5)*fgkXPad-(kNpadX*fgkXPad)*0.5;
366
367   // The radius r in xy plane:
368   Float_t r = (fgkRmin+fgkRmax)/2.+fHeights[iplate][istrip]+
369     (ipadz-0.5)*fgkZPad*TMath::Sin(fAngles[iplate][istrip]/kRaddeg)-0.25;
370
371   // local azimuthal angle in the sector philoc
372   Float_t philoc   = TMath:: ATan(d/r);
373
374   // azimuthal angle in the global frame  phi
375   Float_t phi      = philoc*kRaddeg+(isector+0.5 )*fPhiSec;                    
376
377   Float_t yCoor    = r/TMath::Cos(philoc)*TMath::Sin(phi/kRaddeg);
378   return yCoor;
379
380 }
381
382 //_____________________________________________________________________________
383 Float_t AliTOFGeometry::GetZ(Int_t *det) 
384 {
385   //
386   // Returns Z coordinate (cm)
387   //
388   
389   Int_t iplate  = det[1];
390   Int_t istrip  = det[2];
391   Int_t ipadz   = det[3];
392   
393   
394   // The radius r in xy plane:
395   Float_t r = (fgkRmin+fgkRmax)/2.+fHeights[iplate][istrip];
396
397   Float_t zCoor = r*TMath::Tan(0.5*TMath::Pi()-GetStripTheta(iplate,istrip))-
398          (ipadz-0.5)*fgkZPad*TMath::Cos(fAngles[iplate][istrip]/kRaddeg);
399   return zCoor;
400
401 }
402 //_____________________________________________________________________________
403 Int_t AliTOFGeometry::GetSector(Float_t *pos) 
404 {
405   //
406   // Returns the Sector index 
407   //
408
409   Int_t   iSect = -1; 
410
411   Float_t x = pos[0];
412   Float_t y = pos[1];
413
414   Float_t phi     =  TMath::ATan2(y,x); 
415   if(phi<0.) phi=2.*TMath::Pi()+phi;
416   iSect  = (Int_t) (phi*kRaddeg/fPhiSec);
417
418   return iSect;
419
420 }
421 //_____________________________________________________________________________
422 Int_t AliTOFGeometry::GetPadX(Float_t *pos) 
423 {
424   //
425   // Returns the Pad index along X 
426   //
427
428   Int_t iPadX  = -1;
429
430   Float_t x = pos[0];
431   Float_t y = pos[1];
432   Float_t z = pos[2];
433
434   Int_t isector = GetSector(pos);
435   if(isector == -1){  
436     AliError("Detector Index could not be determined");
437     return iPadX;}
438   Int_t iplate =  GetPlate(pos);
439   if(iplate == -1){  
440     AliError("Detector Index could not be determined");
441     return iPadX;} 
442   Int_t istrip =  GetStrip(pos);
443   if(istrip == -1){  
444     AliError("Detector Index could not be determined");
445     return iPadX;}
446
447
448   Float_t rho=TMath::Sqrt(x*x+y*y);
449   Float_t phi =  TMath::ATan2(y,x);     
450   if(phi<0.) phi=2.*TMath::Pi()+phi;
451  
452   // Get the local angle in the sector philoc
453   Float_t philoc   = phi*kRaddeg-(isector+0.5)*fPhiSec;
454   philoc*=TMath::Pi()/180.;
455   // theta projected on the median of the sector
456   Float_t theta = TMath::ATan2(rho*TMath::Cos(philoc),z);
457   // The radius r in xy plane:
458   Float_t r   = (fgkRmin+fgkRmax)/2.+fHeights[iplate][istrip]+
459                (theta-GetStripTheta(iplate, istrip))/
460     (GetMaxStripTheta(iplate, istrip)-GetMinStripTheta(iplate, istrip))
461    * 2.*fgkZPad*TMath::Sin(fAngles[iplate][istrip]/kRaddeg)-0.25;
462
463   // Find out distance projected onto the strip plane 
464   Float_t d = (r*TMath::Tan(philoc)+(kNpadX*fgkXPad)*0.5);
465
466   iPadX  =  (Int_t) ( d/fgkXPad);  
467   return iPadX;
468
469 }
470 //_____________________________________________________________________________
471 Int_t AliTOFGeometry::GetPlate(Float_t *pos) 
472 {
473   //
474   // Returns the Plate index 
475   //
476   Int_t iPlate=-1;
477
478   Int_t isector = GetSector(pos);
479   if(isector == -1){  
480     AliError("Detector Index could not be determined");
481     return iPlate;}
482  
483   Float_t x = pos[0];
484   Float_t y = pos[1];
485   Float_t z = pos[2];
486
487   Float_t rho=TMath::Sqrt(x*x+y*y);
488   Float_t phi=TMath::ATan2(y,x);        
489   if(phi<0) phi=2.*TMath::Pi()+phi;
490   // Get the local angle in the sector philoc
491   Float_t philoc   = phi*kRaddeg-(isector+0.5)*fPhiSec;
492   philoc*=TMath::Pi()/180.;
493   // theta projected on the median of the sector
494   Float_t theta=TMath::ATan2(rho*TMath::Cos(philoc),z);
495
496   for (Int_t i=0; i<kNPlates; i++){
497     if ( GetMaxPlateTheta(i) >= theta && 
498          GetMinPlateTheta(i) <= theta)iPlate=i;
499   }
500   
501   return iPlate;
502
503 }
504 //_____________________________________________________________________________
505 Int_t AliTOFGeometry::GetStrip(Float_t *pos) 
506 {
507   //
508   // Returns the Strip index 
509   //
510
511   Int_t iStrip=-1;
512
513
514   Int_t isector = GetSector(pos);
515   if(isector == -1){  
516     AliError("Detector Index could not be determined");
517     return iStrip;}
518   Int_t iplate =  GetPlate(pos);
519   if(iplate == -1){  
520     AliError("Detector Index could not be determined");
521     return iStrip;} 
522
523
524   Float_t x = pos[0];
525   Float_t y = pos[1];
526   Float_t z = pos[2];
527
528   Int_t nstrips=0;
529   if(iplate==0 || iplate == 4)nstrips=kNStripC;
530   if(iplate==1 || iplate == 3)nstrips=kNStripB;
531   if(iplate==2)               nstrips=kNStripA;
532
533   Float_t rho=TMath::Sqrt(x*x+y*y);
534   Float_t phi=TMath::ATan2(y,x);        
535   if(phi<0) phi=2.*TMath::Pi()+phi;
536   // Get the local angle in the sector philoc
537   Float_t philoc   = phi*kRaddeg-(isector+0.5)*fPhiSec;
538   philoc*=TMath::Pi()/180.;
539   // theta projected on the median of the sector
540   Float_t theta=TMath::ATan2(rho*TMath::Cos(philoc),z);
541
542   for (Int_t istrip=0; istrip<nstrips; istrip++){
543
544     if( 
545        GetMaxStripTheta(iplate,istrip) >= theta 
546        &&  
547        GetMinStripTheta(iplate,istrip) <= theta ) iStrip = istrip;
548    
549   }
550
551   return iStrip;
552 }
553 //_____________________________________________________________________________
554 Int_t AliTOFGeometry::GetPadZ(Float_t *pos) 
555 {
556   //
557   // Returns the Pad index along Z 
558   //
559   Int_t iPadZ = -1;
560
561   Int_t isector = GetSector(pos);
562   if(isector == -1){  
563     AliError("Detector Index could not be determined");
564     return iPadZ;}
565   Int_t iplate =  GetPlate(pos);
566   if(iplate == -1){  
567     AliError("Detector Index could not be determined");
568     return iPadZ;} 
569   Int_t istrip =  GetStrip(pos);
570   if(istrip == -1){  
571     AliError("Detector Index could not be determined");
572     return iPadZ;}
573
574
575   Float_t x = pos[0];
576   Float_t y = pos[1];
577   Float_t z = pos[2];
578
579   Float_t rho=TMath::Sqrt(x*x+y*y);
580   Float_t phi=TMath::ATan2(y,x);        
581   if(phi<0) phi=2.*TMath::Pi()+phi;
582   Float_t philoc   = phi*kRaddeg-(isector+0.5)*fPhiSec;
583   philoc*=TMath::Pi()/180.;
584   Float_t theta=TMath::ATan2(rho*TMath::Cos(philoc),z);
585
586   if (theta >= GetStripTheta(iplate, istrip))iPadZ=1;
587   else iPadZ=0;
588
589   return iPadZ;
590 }
591 //_____________________________________________________________________________
592 Float_t AliTOFGeometry::GetMinPlateTheta(Int_t iPlate) 
593 {
594   //
595   // Returns the minimum theta angle of a given plate iPlate (rad)
596   //
597   
598
599   Int_t index=0;
600
601   Float_t delta =0.;
602   if(iPlate==0)delta = -1. ;
603   if(iPlate==1)delta = -0.5;
604   if(iPlate==3)delta = +0.5;
605   if(iPlate==4)delta = +1. ;
606
607   Float_t z=(fgkRmin+2.)*TMath::Tan(fAngles[iPlate][index]/kRaddeg)+delta;
608   Float_t r=(fgkRmin+fgkRmax)/2.+fHeights[iPlate][index];
609   z =z+fgkZPad*TMath::Cos(fAngles[iPlate][index]/kRaddeg);
610   r =r-fgkZPad*TMath::Sin(fAngles[iPlate][index]/kRaddeg);
611
612   Float_t thmin = 0.5*TMath::Pi()-TMath::ATan(z/r)-fgkDprecMin;
613   return thmin;
614
615 }
616 //_____________________________________________________________________________
617 Float_t AliTOFGeometry::GetMaxPlateTheta(Int_t iPlate) 
618 {
619   //
620   // Returns the maximum theta angle of a given plate iPlate (rad)
621   
622   Int_t index=0;
623   if(iPlate==0 ||iPlate == 4)index=kNStripC-1;
624   if(iPlate==1 ||iPlate == 3)index=kNStripB-1;
625   if(iPlate==2)              index=kNStripA-1;
626
627   Float_t delta =0.;
628   if(iPlate==0)delta = -1. ;
629   if(iPlate==1)delta = -0.5;
630   if(iPlate==3)delta = +0.5;
631   if(iPlate==4)delta = +1. ;
632
633   Float_t z=(fgkRmin+2.)*TMath::Tan(fAngles[iPlate][index]/kRaddeg)+delta;
634   Float_t r=(fgkRmin+fgkRmax)/2.+fHeights[iPlate][index];
635   z =z-fgkZPad*TMath::Cos(fAngles[iPlate][index]/kRaddeg);
636   r= r+fgkZPad*TMath::Sin(fAngles[iPlate][index]/kRaddeg);
637
638   Float_t thmax    = 0.5*TMath::Pi()-TMath::ATan(z/r)+fgkDprecMax;
639   return thmax;
640
641 }
642 //_____________________________________________________________________________
643 Float_t  AliTOFGeometry::GetMaxStripTheta(Int_t iPlate, Int_t iStrip) 
644 {
645   //
646   // Returns the maximum theta angle of a given strip iStrip (rad)
647   //
648   
649
650   Float_t delta =0.;
651   if(iPlate==0)delta = -1. ;
652   if(iPlate==1)delta = -0.5;
653   if(iPlate==3)delta = +0.5;
654   if(iPlate==4)delta = +1. ;
655
656   Float_t r =(fgkRmin+fgkRmax)/2.+fHeights[iPlate][iStrip];
657   Float_t z =(fgkRmin+2.)*TMath::Tan(fAngles[iPlate][iStrip]/kRaddeg)+delta;
658   z = z-fgkZPad*TMath::Cos(fAngles[iPlate][iStrip]/kRaddeg);
659   r = r+fgkZPad*TMath::Sin(fAngles[iPlate][iStrip]/kRaddeg);
660   Float_t thmax =0.5*TMath::Pi()-TMath::ATan(z/r)+fgkDprecMax;
661   return thmax;
662
663 }
664
665 //_____________________________________________________________________________
666 Float_t  AliTOFGeometry::GetMinStripTheta(Int_t iPlate, Int_t iStrip) 
667 {
668   //
669   // Returns the minimum theta angle of a given Strip iStrip (rad)
670   //
671   
672
673   Float_t delta =0.;
674   if(iPlate==0)delta = -1. ;
675   if(iPlate==1)delta = -0.5;
676   if(iPlate==3)delta = +0.5;
677   if(iPlate==4)delta = +1. ;
678
679
680   Float_t r =(fgkRmin+fgkRmax)/2.+fHeights[iPlate][iStrip];
681   Float_t z =(fgkRmin+2.)*TMath::Tan(fAngles[iPlate][iStrip]/kRaddeg)+delta;
682   z =z+fgkZPad*TMath::Cos(fAngles[iPlate][iStrip]/kRaddeg);
683   r =r-fgkZPad*TMath::Sin(fAngles[iPlate][iStrip]/kRaddeg);
684   Float_t thmin =0.5*TMath::Pi()-TMath::ATan(z/r)-fgkDprecMin;
685
686   return thmin;
687
688 }
689
690
691 //_____________________________________________________________________________
692 Float_t  AliTOFGeometry::GetStripTheta(Int_t iPlate, Int_t iStrip) 
693 {
694   //
695   // returns the median theta angle of a given strip iStrip (rad)
696   //
697   
698
699   Float_t delta =0.;
700   if(iPlate==0)delta = -1. ;
701   if(iPlate==1)delta = -0.5;
702   if(iPlate==3)delta = +0.5;
703   if(iPlate==4)delta = +1. ;
704
705   Float_t r =(fgkRmin+fgkRmax)/2.+fHeights[iPlate][iStrip];
706   Float_t z =(fgkRmin+2.)*TMath::Tan(fAngles[iPlate][iStrip]/kRaddeg)+delta;
707   Float_t theta =0.5*TMath::Pi()-TMath::ATan(z/r);
708   if(iPlate != 2){
709   if(theta > 0.5*TMath::Pi() )theta+=fgkDprecCen;
710   if(theta < 0.5*TMath::Pi() )theta-=fgkDprecCen;
711   }
712   return theta;
713 }
714
715
716