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