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