]>
Commit | Line | Data |
---|---|---|
9350f379 | 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 | //------------------------------------------------------- | |
18 | // Implementation of the TPC tracker helper clasess | |
19 | // AliTPCtrackerRow | |
20 | // AliTPCtrackerSector | |
21 | // | |
22 | // Origin: Marian Ivanov Marian.Ivanov@cern.ch | |
23 | // | |
24 | // AliTPCtrakerMI - parallel tracker helper clases | |
25 | // | |
26 | ||
27 | /* $Id: AliTPCtrackerSector.cxx 25837 2008-05-16 16:39:00Z marian $ */ | |
28 | ||
29 | #include "Riostream.h" | |
30 | #include <TClonesArray.h> | |
31 | #include "AliLog.h" | |
32 | #include "AliComplexCluster.h" | |
33 | #include "AliTPCcluster.h" | |
34 | #include "AliTPCclusterMI.h" | |
35 | #include "AliTPCClustersRow.h" | |
36 | #include "AliTPCParam.h" | |
37 | #include "AliTPCReconstructor.h" | |
38 | #include "AliTPCreco.h" | |
39 | // | |
40 | #include "AliTPCtrackerSector.h" | |
41 | #include "TStopwatch.h" | |
42 | #include "TTreeStream.h" | |
43 | ||
44 | // | |
45 | ||
46 | ClassImp(AliTPCtrackerRow) | |
47 | ClassImp(AliTPCtrackerSector) | |
48 | ||
49 | ||
50 | ||
51 | AliTPCtrackerRow::AliTPCtrackerRow(): | |
52 | fDeadZone(0.), | |
53 | fClusters1(0), | |
54 | fN1(0), | |
55 | fClusters2(0), | |
56 | fN2(0), | |
9f98a33d | 57 | fFastCluster(), |
9350f379 | 58 | fN(0), |
472f0066 | 59 | fClusters(), |
60 | fIndex(), | |
61 | fX(0.) | |
9350f379 | 62 | { |
63 | // | |
64 | // default constructor | |
65 | // | |
66 | } | |
67 | ||
68 | AliTPCtrackerRow::~AliTPCtrackerRow(){ | |
69 | // | |
70 | for (Int_t i = 0; i < fN1; i++) | |
71 | fClusters1[i].~AliTPCclusterMI(); | |
72 | delete [] fClusters1; | |
73 | for (Int_t i = 0; i < fN2; i++) | |
74 | fClusters2[i].~AliTPCclusterMI(); | |
75 | delete [] fClusters2; | |
76 | } | |
77 | ||
78 | ||
79 | ||
80 | //_________________________________________________________________________ | |
81 | void | |
82 | AliTPCtrackerRow::InsertCluster(const AliTPCclusterMI* c, UInt_t index) { | |
83 | //----------------------------------------------------------------------- | |
84 | // Insert a cluster into this pad row in accordence with its y-coordinate | |
85 | //----------------------------------------------------------------------- | |
86 | if (fN==kMaxClusterPerRow) { | |
87 | //AliInfo("AliTPCtrackerRow::InsertCluster(): Too many clusters"); | |
88 | return; | |
89 | } | |
90 | if (fN>=fN1+fN2) { | |
91 | //AliInfo("AliTPCtrackerRow::InsertCluster(): Too many clusters !"); | |
92 | } | |
93 | ||
94 | if (fN==0) {fIndex[0]=index; fClusters[fN++]=c; return;} | |
95 | Int_t i=Find(c->GetZ()); | |
7528628f | 96 | if (i>=0 && i<=kMaxClusterPerRow-2) { |
97 | memmove(fClusters+i+1 ,fClusters+i,(fN-i)*sizeof(AliTPCclusterMI*)); | |
98 | memmove(fIndex +i+1 ,fIndex +i,(fN-i)*sizeof(UInt_t)); | |
99 | } | |
9350f379 | 100 | fIndex[i]=index; fClusters[i]=c; fN++; |
101 | } | |
102 | ||
103 | void AliTPCtrackerRow::ResetClusters() { | |
104 | // | |
105 | // reset clusters | |
106 | // MvL: Need to call destructors for AliTPCclusterMI, to delete fInfo | |
107 | for (Int_t i = 0; i < fN1; i++) | |
108 | fClusters1[i].~AliTPCclusterMI(); | |
109 | delete [] fClusters1; fClusters1=0; | |
110 | for (Int_t i = 0; i < fN2; i++) | |
111 | fClusters2[i].~AliTPCclusterMI(); | |
112 | delete [] fClusters2; fClusters2=0; | |
113 | ||
114 | fN = 0; | |
115 | fN1 = 0; | |
116 | fN2 = 0; | |
117 | //delete[] fClusterArray; | |
118 | ||
119 | //fClusterArray=0; | |
120 | } | |
121 | ||
122 | ||
123 | //___________________________________________________________________ | |
124 | Int_t AliTPCtrackerRow::Find(Double_t z) const { | |
125 | //----------------------------------------------------------------------- | |
126 | // Return the index of the nearest cluster | |
127 | //----------------------------------------------------------------------- | |
128 | if (fN==0) return 0; | |
129 | if (z <= fClusters[0]->GetZ()) return 0; | |
130 | if (z > fClusters[fN-1]->GetZ()) return fN; | |
131 | Int_t b=0, e=fN-1, m=(b+e)/2; | |
132 | for (; b<e; m=(b+e)/2) { | |
133 | if (z > fClusters[m]->GetZ()) b=m+1; | |
134 | else e=m; | |
135 | } | |
136 | return m; | |
137 | } | |
138 | ||
139 | ||
140 | ||
141 | //___________________________________________________________________ | |
142 | AliTPCclusterMI * AliTPCtrackerRow::FindNearest(Double_t y, Double_t z, Double_t roady, Double_t roadz) const { | |
143 | //----------------------------------------------------------------------- | |
144 | // Return the index of the nearest cluster in z y | |
145 | //----------------------------------------------------------------------- | |
146 | Float_t maxdistance = roady*roady + roadz*roadz; | |
147 | ||
148 | AliTPCclusterMI *cl =0; | |
149 | for (Int_t i=Find(z-roadz); i<fN; i++) { | |
150 | AliTPCclusterMI *c=(AliTPCclusterMI*)(fClusters[i]); | |
151 | if (c->GetZ() > z+roadz) break; | |
152 | if ( (c->GetY()-y) > roady ) continue; | |
153 | Float_t distance = (c->GetZ()-z)*(c->GetZ()-z)+(c->GetY()-y)*(c->GetY()-y); | |
154 | if (maxdistance>distance) { | |
155 | maxdistance = distance; | |
156 | cl=c; | |
157 | } | |
158 | } | |
159 | return cl; | |
160 | } | |
161 | ||
162 | AliTPCclusterMI * AliTPCtrackerRow::FindNearest2(Double_t y, Double_t z, Double_t roady, Double_t roadz,UInt_t & index) const | |
163 | { | |
164 | //----------------------------------------------------------------------- | |
165 | // Return the index of the nearest cluster in z y | |
166 | //----------------------------------------------------------------------- | |
167 | Float_t maxdistance = roady*roady + roadz*roadz; | |
168 | AliTPCclusterMI *cl =0; | |
169 | ||
170 | //PH Check boundaries. 510 is the size of fFastCluster | |
171 | Int_t iz1 = Int_t(z-roadz+254.5); | |
172 | if (iz1<0 || iz1>=510) return cl; | |
173 | iz1 = TMath::Max(GetFastCluster(iz1)-1,0); | |
174 | Int_t iz2 = Int_t(z+roadz+255.5); | |
175 | if (iz2<0 || iz2>=510) return cl; | |
176 | iz2 = TMath::Min(GetFastCluster(iz2)+1,fN); | |
177 | Bool_t skipUsed = !(AliTPCReconstructor::GetRecoParam()->GetClusterSharing()); | |
178 | //FindNearest3(y,z,roady,roadz,index); | |
179 | // for (Int_t i=Find(z-roadz); i<fN; i++) { | |
180 | for (Int_t i=iz1; i<iz2; i++) { | |
181 | AliTPCclusterMI *c=(AliTPCclusterMI*)(fClusters[i]); | |
182 | if (c->GetZ() > z+roadz) break; | |
183 | if ( c->GetY()-y > roady ) continue; | |
184 | if ( y-c->GetY() > roady ) continue; | |
185 | if (skipUsed && c->IsUsed(11)) continue; | |
186 | Float_t distance = (c->GetZ()-z)*(c->GetZ()-z)+(c->GetY()-y)*(c->GetY()-y); | |
187 | if (maxdistance>distance) { | |
188 | maxdistance = distance; | |
189 | cl=c; | |
190 | index =i; | |
191 | //roady = TMath::Sqrt(maxdistance); | |
192 | } | |
193 | } | |
194 | return cl; | |
195 | } | |
196 | ||
197 | ||
198 | void AliTPCtrackerRow::SetFastCluster(Int_t i, Short_t cl){ | |
199 | // | |
200 | // Set cluster info for fast navigation | |
201 | // | |
472f0066 | 202 | if (i>=510|| i<0){ |
9350f379 | 203 | }else{ |
204 | fFastCluster[i]=cl; | |
205 | } | |
206 | } | |
207 | ||
208 | ||
209 | Int_t AliTPCtrackerSector::GetRowNumber(Double_t x) const | |
210 | { | |
211 | //return pad row number for this x | |
212 | Double_t r; | |
213 | if (fN < 64){ | |
214 | r=fRow[fN-1].GetX(); | |
215 | if (x > r) return fN; | |
216 | r=fRow[0].GetX(); | |
217 | if (x < r) return -1; | |
218 | return Int_t((x-r)/fPadPitchLength + 0.5);} | |
219 | else{ | |
220 | r=fRow[fN-1].GetX(); | |
221 | if (x > r) return fN; | |
222 | r=fRow[0].GetX(); | |
223 | if (x < r) return -1; | |
224 | Double_t r1=fRow[64].GetX(); | |
225 | if(x<r1){ | |
226 | return Int_t((x-r)/f1PadPitchLength + 0.5);} | |
227 | else{ | |
228 | return (Int_t((x-r1)/f2PadPitchLength + 0.5)+64);} | |
229 | } | |
230 | } | |
231 | ||
232 | //_________________________________________________________________________ | |
233 | void AliTPCtrackerSector::Setup(const AliTPCParam *par, Int_t f) { | |
234 | //----------------------------------------------------------------------- | |
235 | // Setup inner sector | |
236 | //----------------------------------------------------------------------- | |
237 | if (f==0) { | |
238 | fAlpha=par->GetInnerAngle(); | |
239 | fAlphaShift=par->GetInnerAngleShift(); | |
240 | fPadPitchWidth=par->GetInnerPadPitchWidth(); | |
241 | fPadPitchLength=par->GetInnerPadPitchLength(); | |
242 | fN=par->GetNRowLow(); | |
243 | if(fRow)delete [] fRow;fRow = 0; | |
244 | fRow=new AliTPCtrackerRow[fN]; | |
245 | for (Int_t i=0; i<fN; i++) { | |
246 | fRow[i].SetX(par->GetPadRowRadiiLow(i)); | |
247 | fRow[i].SetDeadZone(1.5); //1.5 cm of dead zone | |
248 | } | |
249 | } else { | |
250 | fAlpha=par->GetOuterAngle(); | |
251 | fAlphaShift=par->GetOuterAngleShift(); | |
252 | fPadPitchWidth = par->GetOuterPadPitchWidth(); | |
253 | fPadPitchLength = par->GetOuter1PadPitchLength(); | |
254 | f1PadPitchLength = par->GetOuter1PadPitchLength(); | |
255 | f2PadPitchLength = par->GetOuter2PadPitchLength(); | |
256 | fN=par->GetNRowUp(); | |
257 | if(fRow)delete [] fRow;fRow = 0; | |
258 | fRow=new AliTPCtrackerRow[fN]; | |
259 | for (Int_t i=0; i<fN; i++) { | |
260 | fRow[i].SetX(par->GetPadRowRadiiUp(i)); | |
261 | fRow[i].SetDeadZone(1.5); // 1.5 cm of dead zone | |
262 | } | |
263 | } | |
264 | } | |
265 | ||
aa7f1a5a | 266 | //_________________________________________________________________________ |
267 | void AliTPCtrackerSector::InsertCluster(AliTPCclusterMI *cl, Int_t size, const AliTPCParam *par) { | |
268 | //----------------------------------------------------------------------- | |
269 | // Insert cluster to the sector | |
270 | //----------------------------------------------------------------------- | |
9350f379 | 271 | |
aa7f1a5a | 272 | if(!cl) return; |
9350f379 | 273 | |
aa7f1a5a | 274 | const Int_t fkNIS = par->GetNInnerSector()/2; |
275 | const Int_t fkNOS = par->GetNOuterSector()/2; | |
276 | Int_t row = cl->GetRow(); | |
277 | Int_t sec = cl->GetDetector(); | |
278 | ||
279 | // add cluster to the corresponding pad row | |
280 | AliTPCtrackerRow *tpcrow = 0x0; | |
281 | ||
282 | Int_t left=0; | |
283 | if (sec<fkNIS*2){ | |
284 | left = sec/fkNIS; | |
285 | } | |
286 | else{ | |
287 | left = (sec-fkNIS*2)/fkNOS; | |
288 | } | |
289 | // | |
290 | if (left ==0){ | |
291 | tpcrow = fRow+row; | |
98ee6d31 | 292 | if(!tpcrow->GetClusters1()) { |
293 | tpcrow->SetClusters1(new AliTPCclusterMI[size]); | |
294 | tpcrow->SetN1(0); | |
295 | } | |
aa7f1a5a | 296 | if(size < kMaxClusterPerRow) { |
297 | tpcrow->SetCluster1(tpcrow->GetN1(), *cl); | |
98ee6d31 | 298 | //printf("inner: size %d, tpcrow->GetN1() %d sec %d row %d tpcrow %p cl %p\n", size, tpcrow->GetN1(), sec, row, tpcrow, cl); |
aa7f1a5a | 299 | |
300 | tpcrow->IncrementN1(); | |
301 | } | |
302 | } | |
303 | if (left ==1){ | |
304 | tpcrow = fRow+row; | |
98ee6d31 | 305 | if(!tpcrow->GetClusters2()) { |
306 | tpcrow->SetClusters2(new AliTPCclusterMI[size]); | |
307 | tpcrow->SetN2(0); | |
308 | } | |
aa7f1a5a | 309 | if(size < kMaxClusterPerRow) { |
310 | tpcrow->SetCluster2(tpcrow->GetN2(), *cl); | |
98ee6d31 | 311 | //printf("outer: size %d, tpcrow->GetN2() %d sec %d row %d tpcrow %p cl %p\n", size, tpcrow->GetN2(), sec, row, tpcrow, cl); |
aa7f1a5a | 312 | |
313 | tpcrow->IncrementN2(); | |
314 | } | |
315 | } | |
316 | } | |
9350f379 | 317 | |
318 | ||
319 |