Line data Source code
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 16 : ClassImp(AliTPCtrackerRow)
47 16 : ClassImp(AliTPCtrackerSector)
48 :
49 :
50 :
51 5724 : AliTPCtrackerRow::AliTPCtrackerRow():
52 5724 : fDeadZone(0.),
53 5724 : fClusters1(0),
54 5724 : fN1(0),
55 5724 : fClusters2(0),
56 5724 : fN2(0),
57 5724 : fFastCluster(),
58 5724 : fN(0),
59 5724 : fClusters(),
60 5724 : fIndex(),
61 5724 : fX(0.)
62 28620 : {
63 : //
64 : // default constructor
65 : //
66 11448 : }
67 :
68 22896 : AliTPCtrackerRow::~AliTPCtrackerRow(){
69 : //
70 8752 : delete fClusters1;
71 9422 : delete fClusters2;
72 11448 : }
73 :
74 :
75 :
76 : //_________________________________________________________________________
77 : void
78 : AliTPCtrackerRow::InsertCluster(const AliTPCclusterMI* c, UInt_t index) {
79 : //-----------------------------------------------------------------------
80 : // Insert a cluster into this pad row in accordence with its y-coordinate
81 : //-----------------------------------------------------------------------
82 129896 : if (!c) {
83 0 : AliError("Inserting Zerro cluster pointer");
84 0 : return;
85 : }
86 64948 : if (fN==kMaxClusterPerRow) {
87 : //AliInfo("AliTPCtrackerRow::InsertCluster(): Too many clusters");
88 : return;
89 : }
90 64948 : if (fN>=fN1+fN2) {
91 : //AliInfo("AliTPCtrackerRow::InsertCluster(): Too many clusters !");
92 : }
93 :
94 76110 : if (fN==0) {fIndex[0]=index; fClusters[fN++]=c; return;}
95 53786 : Int_t i=Find(c->GetZ());
96 53786 : if (i>=0 && i<=kMaxClusterPerRow-2) {
97 53786 : memmove(fClusters+i+1 ,fClusters+i,(fN-i)*sizeof(AliTPCclusterMI*));
98 53786 : memmove(fIndex +i+1 ,fIndex +i,(fN-i)*sizeof(UInt_t));
99 53786 : }
100 53786 : fIndex[i]=index; fClusters[i]=c; fN++;
101 118734 : }
102 :
103 : void AliTPCtrackerRow::ResetClusters() {
104 : //
105 : // reset clusters
106 : // MvL: Need to call destructors for AliTPCclusterMI, to delete fInfo
107 : // if (fClusters1) fClusters1->Clear("C");
108 : // if (fClusters2) fClusters2->Clear("C");
109 55558 : if (fClusters1) fClusters1->Clear(); // RS AliTPCclusterMI does not allocate memory
110 36140 : if (fClusters2) fClusters2->Clear();
111 :
112 22896 : fN = 0;
113 22896 : fN1 = 0;
114 22896 : fN2 = 0;
115 : //delete[] fClusterArray;
116 :
117 : //fClusterArray=0;
118 22896 : }
119 :
120 :
121 : //___________________________________________________________________
122 : Int_t AliTPCtrackerRow::Find(Double_t z) const {
123 : //-----------------------------------------------------------------------
124 : // Return the index of the nearest cluster
125 : //-----------------------------------------------------------------------
126 167660 : if (fN==0) return 0;
127 92478 : if (z <= fClusters[0]->GetZ()) return 0;
128 67958 : if (z > fClusters[fN-1]->GetZ()) return fN;
129 38774 : Int_t b=0, e=fN-1, m=(b+e)/2;
130 479340 : for (; b<e; m=(b+e)/2) {
131 299189 : if (z > fClusters[m]->GetZ()) b=m+1;
132 : else e=m;
133 : }
134 : return m;
135 80194 : }
136 :
137 :
138 :
139 : //___________________________________________________________________
140 : AliTPCclusterMI * AliTPCtrackerRow::FindNearest(Double_t y, Double_t z, Double_t roady, Double_t roadz) const {
141 : //-----------------------------------------------------------------------
142 : // Return the index of the nearest cluster in z y
143 : //-----------------------------------------------------------------------
144 0 : Float_t maxdistance = roady*roady + roadz*roadz;
145 :
146 : AliTPCclusterMI *cl =0;
147 0 : for (Int_t i=Find(z-roadz); i<fN; i++) {
148 0 : AliTPCclusterMI *c=(AliTPCclusterMI*)(fClusters[i]);
149 0 : if (c->GetZ() > z+roadz) break;
150 : // if ( (c->GetY()-y) > roady ) continue; //JW: Why here not abs???
151 0 : if ( TMath::Abs(c->GetY()-y) > roady ) continue;
152 0 : Float_t distance = (c->GetZ()-z)*(c->GetZ()-z)+(c->GetY()-y)*(c->GetY()-y);
153 0 : if (maxdistance>distance) {
154 : maxdistance = distance;
155 : cl=c;
156 0 : }
157 0 : }
158 0 : return cl;
159 : }
160 :
161 : AliTPCclusterMI * AliTPCtrackerRow::FindNearest2(Double_t y, Double_t z, Double_t roady, Double_t roadz,UInt_t & index) const
162 : {
163 : //-----------------------------------------------------------------------
164 : // Return the index of the nearest cluster in z y
165 : //-----------------------------------------------------------------------
166 168920 : Float_t maxdistance = roady*roady + roadz*roadz;
167 : AliTPCclusterMI *cl =0;
168 :
169 : //PH Check boundaries. 510 is the size of fFastCluster
170 84460 : Int_t iz1 = Int_t(z-roadz+254.5);
171 84460 : if ( iz1>=510) return cl;
172 84460 : if (iz1<0 ) iz1 = 0;
173 84460 : iz1 = TMath::Max(GetFastCluster(iz1)-1,0);
174 84460 : Int_t iz2 = Int_t(z+roadz+255.5);
175 84460 : if (iz2<0 ) return cl;
176 84460 : if ( iz2>=510) iz2 = 509;
177 84460 : iz2 = TMath::Min(GetFastCluster(iz2)+1,fN);
178 84460 : Bool_t skipUsed = !(AliTPCReconstructor::GetRecoParam()->GetClusterSharing());
179 : //FindNearest3(y,z,roady,roadz,index);
180 : // for (Int_t i=Find(z-roadz); i<fN; i++) {
181 536244 : for (Int_t i=iz1; i<iz2; i++) {
182 150300 : AliTPCclusterMI *c=(AliTPCclusterMI*)(fClusters[i]);
183 156212 : if (c->GetZ() > z+roadz) break;
184 171394 : if ( c->GetY()-y > roady ) continue;
185 151630 : if ( y-c->GetY() > roady ) continue;
186 83134 : if (skipUsed && c->IsUsed(11)) continue;
187 83134 : if (c->IsDisabled()) continue;
188 83134 : Float_t distance = (c->GetZ()-z)*(c->GetZ()-z)+(c->GetY()-y)*(c->GetY()-y);
189 83134 : if (maxdistance>distance) {
190 : maxdistance = distance;
191 : cl=c;
192 76838 : index =i;
193 : //roady = TMath::Sqrt(maxdistance);
194 76838 : }
195 83134 : }
196 : return cl;
197 84460 : }
198 :
199 :
200 : void AliTPCtrackerRow::SetFastCluster(Int_t i, Short_t cl){
201 : //
202 : // Set cluster info for fast navigation
203 : //
204 46724028 : if (i>=510|| i<0){
205 : }else{
206 23362014 : fFastCluster[i]=cl;
207 : }
208 23362014 : }
209 :
210 : Int_t AliTPCtrackerSector::GetNClInSector(Int_t side)
211 : {
212 : // return number of all clusters in one sector; side =0 for A side and 1 for C side
213 :
214 : Int_t nclSector=0;
215 1152 : Int_t nrows = GetNRows();
216 :
217 92736 : for (Int_t row=0;row<nrows;row++) {
218 45792 : AliTPCtrackerRow& tpcrow = (*this)[row];
219 137376 : Int_t ncl = (side==0)?(tpcrow.GetN1()):(tpcrow.GetN2());
220 45792 : nclSector+=ncl;
221 : }
222 :
223 576 : return nclSector;
224 : }
225 :
226 :
227 :
228 :
229 : Int_t AliTPCtrackerSector::GetRowNumber(Double_t x) const
230 : {
231 : //return pad row number for this x
232 : Double_t r;
233 148920 : if (fN < 64){
234 49640 : r=fRow[fN-1].GetX();
235 : // if (x > r) return fN;
236 72346 : if (x > r) return fN-1; // RS
237 22702 : r=fRow[0].GetX();
238 : // if (x < r) return -1;
239 22832 : if (x < r) return 0; // RS
240 22572 : return Int_t((x-r)/fPadPitchLength + 0.5);}
241 : else{
242 : r=fRow[fN-1].GetX();
243 : // if (x > r) return fN;
244 26936 : if (x > r) return fN-1;
245 26936 : r=fRow[0].GetX();
246 : // if (x < r) return -1;
247 26936 : if (x < r) return 0;
248 26936 : Double_t r1=fRow[64].GetX();
249 26936 : if(x<r1){
250 19120 : return Int_t((x-r)/f1PadPitchLength + 0.5);}
251 : else{
252 7816 : return (Int_t((x-r1)/f2PadPitchLength + 0.5)+64);}
253 : }
254 49640 : }
255 :
256 :
257 : void AliTPCtrackerRow::SetCluster1(Int_t i, const AliTPCclusterMI &cl)
258 : {
259 : // attach cluster
260 73396 : if (!fClusters1) fClusters1 = new TClonesArray("AliTPCclusterMI",1000);
261 33670 : if (i<=fClusters1->GetLast() && fClusters1->UncheckedAt(i)) fClusters1->RemoveAt(i);
262 33670 : new( (*fClusters1)[fClusters1->GetEntriesFast()] ) AliTPCclusterMI(cl);
263 : //
264 33670 : }
265 :
266 : void AliTPCtrackerRow::SetCluster2(Int_t i, const AliTPCclusterMI &cl)
267 : {
268 : // attach cluster
269 69952 : if (!fClusters2) fClusters2 = new TClonesArray("AliTPCclusterMI",1000);
270 31278 : if (i<=fClusters2->GetLast() && fClusters2->UncheckedAt(i)) fClusters2->RemoveAt(i);
271 31278 : new( (*fClusters2)[fClusters2->GetEntriesFast()] ) AliTPCclusterMI(cl);
272 : //
273 31278 : }
274 :
275 :
276 : //_________________________________________________________________________
277 : void AliTPCtrackerSector::Setup(const AliTPCParam *par, Int_t f) {
278 : //-----------------------------------------------------------------------
279 : // Setup inner sector
280 : //-----------------------------------------------------------------------
281 144 : if (f==0) {
282 36 : fAlpha=par->GetInnerAngle();
283 36 : fAlphaShift=par->GetInnerAngleShift();
284 36 : fPadPitchWidth=par->GetInnerPadPitchWidth();
285 36 : fPadPitchLength=par->GetInnerPadPitchLength();
286 36 : fN=par->GetNRowLow();
287 72 : if(fRow)delete [] fRow;fRow = 0;
288 4644 : fRow=new AliTPCtrackerRow[fN];
289 4608 : for (Int_t i=0; i<fN; i++) {
290 2268 : fRow[i].SetX(par->GetPadRowRadiiLow(i));
291 2268 : fRow[i].SetDeadZone(1.5); //1.5 cm of dead zone
292 : }
293 36 : } else {
294 36 : fAlpha=par->GetOuterAngle();
295 36 : fAlphaShift=par->GetOuterAngleShift();
296 36 : fPadPitchWidth = par->GetOuterPadPitchWidth();
297 36 : fPadPitchLength = par->GetOuter1PadPitchLength();
298 36 : f1PadPitchLength = par->GetOuter1PadPitchLength();
299 36 : f2PadPitchLength = par->GetOuter2PadPitchLength();
300 36 : fN=par->GetNRowUp();
301 72 : if(fRow)delete [] fRow;fRow = 0;
302 7020 : fRow=new AliTPCtrackerRow[fN];
303 6984 : for (Int_t i=0; i<fN; i++) {
304 3456 : fRow[i].SetX(par->GetPadRowRadiiUp(i));
305 3456 : fRow[i].SetDeadZone(1.5); // 1.5 cm of dead zone
306 : }
307 : }
308 72 : }
309 :
310 : //_________________________________________________________________________
311 : void AliTPCtrackerSector::InsertCluster(AliTPCclusterMI *cl, Int_t size, const AliTPCParam *par) {
312 : //-----------------------------------------------------------------------
313 : // Insert cluster to the sector
314 : //-----------------------------------------------------------------------
315 :
316 0 : if(!cl) return;
317 :
318 0 : const Int_t fkNIS = par->GetNInnerSector()/2;
319 0 : const Int_t fkNOS = par->GetNOuterSector()/2;
320 0 : Int_t row = cl->GetRow();
321 0 : Int_t sec = cl->GetDetector();
322 :
323 : // add cluster to the corresponding pad row
324 : AliTPCtrackerRow *tpcrow = 0x0;
325 :
326 : Int_t left=0;
327 0 : if (sec<fkNIS*2){
328 0 : left = sec/fkNIS;
329 0 : }
330 : else{
331 0 : left = (sec-fkNIS*2)/fkNOS;
332 : }
333 : //
334 0 : if (left ==0){
335 0 : tpcrow = fRow+row;
336 0 : if(!tpcrow->GetClusters1()) {
337 0 : tpcrow->SetN1(0);
338 0 : }
339 0 : if(size < kMaxClusterPerRow) {
340 0 : tpcrow->SetCluster1(tpcrow->GetN1(), *cl);
341 : //printf("inner: size %d, tpcrow->GetN1() %d sec %d row %d tpcrow %p cl %p\n", size, tpcrow->GetN1(), sec, row, tpcrow, cl);
342 :
343 0 : tpcrow->IncrementN1();
344 0 : }
345 : }
346 0 : if (left ==1){
347 0 : tpcrow = fRow+row;
348 0 : if(!tpcrow->GetClusters2()) {
349 0 : tpcrow->SetN2(0);
350 0 : }
351 0 : if(size < kMaxClusterPerRow) {
352 0 : tpcrow->SetCluster2(tpcrow->GetN2(), *cl);
353 : //printf("outer: size %d, tpcrow->GetN2() %d sec %d row %d tpcrow %p cl %p\n", size, tpcrow->GetN2(), sec, row, tpcrow, cl);
354 :
355 0 : tpcrow->IncrementN2();
356 0 : }
357 : }
358 0 : }
359 :
360 : //_________________________________________________________________________
361 : Int_t AliTPCtrackerSector::GetNClInSector(Int_t side) const
362 : {
363 : //return number of all clusters in one sector; side =0 for A side and 1 for C side
364 :
365 : Int_t nclSector=0;
366 0 : Int_t nrows = GetNRows();
367 :
368 0 : for (Int_t row=0;row<nrows;row++) {
369 0 : AliTPCtrackerRow& tpcrow = (*this)[row];
370 0 : Int_t ncl = (side==0)?(tpcrow.GetN1()):(tpcrow.GetN2());
371 0 : nclSector+=ncl;
372 : }
373 :
374 0 : return nclSector;
375 : }
376 :
377 : //_________________________________________________________________________
378 : Int_t AliTPCtrackerSector::GetNClUsedInSector(Int_t side) const
379 : {
380 : //return number of clusters used in tracking in one sector; side =0 for A side and 1 for C side
381 :
382 : Int_t nclSector=0;
383 1152 : Int_t nrows = GetNRows();
384 :
385 92736 : for (Int_t row=0;row<nrows;row++) {
386 45792 : AliTPCtrackerRow& tpcrow = (*this)[row];
387 137376 : Int_t nclusters = (side==0)?tpcrow.GetN1():tpcrow.GetN2();
388 221480 : for (Int_t icluster=0; icluster<nclusters; icluster++)
389 : {
390 : AliTPCclusterMI* cluster = NULL;
391 98618 : if (side==0) { cluster=tpcrow.GetCluster1(icluster); }
392 31278 : else { cluster=tpcrow.GetCluster2(icluster); }
393 64948 : if (!cluster) continue;
394 78840 : if (cluster->IsUsed(1)) nclSector++;
395 64948 : }
396 : }
397 :
398 576 : return nclSector;
399 : }
400 :
|