]> git.uio.no Git - u/mrichter/AliRoot.git/blob - TRD/AliTRDtrackingSector.cxx
fWSN->Eval(0.001) to avoid fpe.
[u/mrichter/AliRoot.git] / TRD / AliTRDtrackingSector.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 /* $Id$ */
17
18 /////////////////////////////////////////////////////////////////////////
19 //                                                                     //
20 //  Tracking sector                                                    //
21 //                                                                     //
22 /////////////////////////////////////////////////////////////////////////                       
23                                 
24 #include <TObject.h>
25
26 #include "AliRun.h"
27
28 #include "AliTRD.h" 
29 #include "AliTRDgeometry.h" 
30 #include "AliTRDcluster.h" 
31 #include "AliTRDtimeBin.h" 
32 #include "AliTRDtrackingSector.h" 
33 #include "AliTRDparameter.h"
34
35 ClassImp(AliTRDtrackingSector) 
36
37 //_______________________________________________________
38 AliTRDtrackingSector::~AliTRDtrackingSector()
39 {
40   //
41   // Destructor
42   //
43
44   delete fTimeBin;
45
46 }
47
48 //_______________________________________________________
49 AliTRDtimeBin &AliTRDtrackingSector::operator[](Int_t i)
50 {
51   //
52   // Index operator 
53   //
54
55   return *(fTimeBin+i);
56
57 }
58
59 //_______________________________________________________
60 void AliTRDtrackingSector::SetUp()
61
62   //
63   // Initialization
64   //
65
66   AliTRD *trd = (AliTRD*) gAlice->GetDetector("TRD");
67   fGeom = trd->GetGeometry();
68
69   fTimeBinSize = fGeom->GetTimeBinSize();
70
71   fN = AliTRDgeometry::Nplan() * (Int_t(AliTRDgeometry::DrThick()
72                                        /fTimeBinSize) + 1);
73
74   fTimeBin = new AliTRDtimeBin[fN]; 
75
76   if (!fPar) {
77     fPar = new AliTRDparameter("TRDparameter","Standard TRD parameter");
78   }
79
80   fTimeBinSize = fPar->GetTimeBinSize();
81
82 }
83
84 //______________________________________________________
85 Double_t AliTRDtrackingSector::GetX(Int_t tb) const
86 {
87   //
88   // Get global x coordinate
89   //
90
91   if( (tb<0) || (tb>fN-1)) {
92     fprintf(stderr,"AliTRDtrackingSector::GetX: TimeBin index is out of range !\n");
93     return -99999.;
94   }
95   else { 
96     
97     Int_t tbPerPlane = fN/AliTRDgeometry::Nplan();
98     Int_t localTb = tbPerPlane - tb%tbPerPlane - 1;
99
100     Int_t plane = tb/tbPerPlane;
101     Float_t t0 = fPar->GetTime0(plane);
102     Double_t x = t0 - (localTb + 0.5) * fTimeBinSize;
103
104     return x;
105
106   }
107
108 }
109
110 //______________________________________________________
111 Int_t AliTRDtrackingSector::GetTimeBinNumber(Double_t x) const
112 {
113   //
114   // Returns the time bin number
115   //
116
117   Float_t rOut = fPar->GetTime0(AliTRDgeometry::Nplan()-1); 
118   Float_t rIn  = fPar->GetTime0(0) - AliTRDgeometry::DrThick();
119
120
121   if(x >= rOut) return fN-1;
122   if(x <= rIn)  return 0;
123
124   Int_t plane;
125   for (plane = AliTRDgeometry::Nplan()-1; plane >= 0; plane--) {
126     if(x > (fPar->GetTime0(plane) - AliTRDgeometry::DrThick())) break;
127   }  
128  
129   Int_t tbPerPlane = fN/AliTRDgeometry::Nplan();
130   Int_t localTb = Int_t((fPar->GetTime0(plane)-x)/fTimeBinSize);
131
132   if((localTb < 0) || (localTb >= tbPerPlane)) {
133     printf("AliTRDtrackingSector::GetTimeBinNumber: \n");
134     printf("local time bin %d is out of bounds [0..%d]: x = %f \n",
135            localTb,tbPerPlane-1,x);
136     return -1;
137   }
138       
139   Int_t timeBin = (plane + 1) * tbPerPlane - 1 - localTb;
140
141   return timeBin;
142 }
143
144 //______________________________________________________
145 Int_t AliTRDtrackingSector::GetTimeBin(Int_t det, Int_t localTb) const 
146 {
147   //
148   // Time bin
149   //
150
151   Int_t plane = fGeom->GetPlane(det);
152
153   Int_t tbPerPlane = fN/AliTRDgeometry::Nplan();
154
155   Int_t timeBin = (plane + 1) * tbPerPlane - 1 - localTb;
156
157   return timeBin;
158
159 }
160
161
162 //______________________________________________________
163
164 Bool_t AliTRDtrackingSector::TECframe(Int_t tb, Double_t y, Double_t z) const
165 {
166   //  
167   // Returns <true> if point defined by <x(tb),y,z> is within 
168   // the TEC G10 frame, otherwise returns <false>  
169   //  
170
171   if((tb > (fN-1)) || (tb < 0)) return kFALSE; 
172
173   Int_t tbPerPlane = fN/AliTRDgeometry::Nplan();
174   Int_t plane = tb/tbPerPlane;
175   
176   Double_t x = GetX(tb);
177   y = TMath::Abs(y);
178
179   if((y > fGeom->GetChamberWidth(plane)/2.) &&
180      (y < x*TMath::Tan(0.5*AliTRDgeometry::GetAlpha()))) return kTRUE; 
181
182   Double_t zmin, zmax;
183   Float_t  fRowPadSize, fRow0;
184   Int_t    nPadRows;
185
186   for(Int_t iCha = 1; iCha < AliTRDgeometry::Ncham(); iCha++) {
187
188     fRow0 = fPar->GetRow0(plane,iCha-1,0);
189     fRowPadSize = fPar->GetRowPadSize(plane,iCha-1,0);
190     nPadRows = fPar->GetRowMax(plane,iCha-1,0);
191     zmin = fRow0 - fRowPadSize/2 + fRowPadSize * nPadRows;
192
193     fRow0 = fPar->GetRow0(plane,iCha,0);
194     fRowPadSize = fPar->GetRowPadSize(plane,iCha,0);
195     zmax = fRow0 - fRowPadSize/2;
196
197     if((z > zmin) && (z < zmax)) return kTRUE;     
198   }
199
200   return kFALSE;
201
202 }