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