1 /**************************************************************************
2 * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
4 * Author: The ALICE Off-line Project. *
5 * Contributors are mentioned in the code where appropriate. *
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 **************************************************************************/
17 //-------------------------------------------------------
18 // Implementation of the TPC tracker helper clasess
20 // AliTPCtrackerSector
22 // Origin: Marian Ivanov Marian.Ivanov@cern.ch
24 // AliTPCtrakerMI - parallel tracker helper clases
27 /* $Id: AliTPCtrackerSector.cxx 25837 2008-05-16 16:39:00Z marian $ */
29 #include "Riostream.h"
30 #include <TClonesArray.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"
40 #include "AliTPCtrackerSector.h"
41 #include "TStopwatch.h"
42 #include "TTreeStream.h"
46 ClassImp(AliTPCtrackerRow)
47 ClassImp(AliTPCtrackerSector)
51 AliTPCtrackerRow::AliTPCtrackerRow():
64 // default constructor
68 AliTPCtrackerRow::~AliTPCtrackerRow(){
76 //_________________________________________________________________________
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 //-----------------------------------------------------------------------
83 AliError("Inserting Zerro cluster pointer");
86 if (fN==kMaxClusterPerRow) {
87 //AliInfo("AliTPCtrackerRow::InsertCluster(): Too many clusters");
91 //AliInfo("AliTPCtrackerRow::InsertCluster(): Too many clusters !");
94 if (fN==0) {fIndex[0]=index; fClusters[fN++]=c; return;}
95 Int_t i=Find(c->GetZ());
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));
100 fIndex[i]=index; fClusters[i]=c; fN++;
103 void AliTPCtrackerRow::ResetClusters() {
106 // MvL: Need to call destructors for AliTPCclusterMI, to delete fInfo
107 if (fClusters1) fClusters1->Clear("C");
108 if (fClusters2) fClusters2->Clear("C");
113 //delete[] fClusterArray;
119 //___________________________________________________________________
120 Int_t AliTPCtrackerRow::Find(Double_t z) const {
121 //-----------------------------------------------------------------------
122 // Return the index of the nearest cluster
123 //-----------------------------------------------------------------------
125 if (z <= fClusters[0]->GetZ()) return 0;
126 if (z > fClusters[fN-1]->GetZ()) return fN;
127 Int_t b=0, e=fN-1, m=(b+e)/2;
128 for (; b<e; m=(b+e)/2) {
129 if (z > fClusters[m]->GetZ()) b=m+1;
137 //___________________________________________________________________
138 AliTPCclusterMI * AliTPCtrackerRow::FindNearest(Double_t y, Double_t z, Double_t roady, Double_t roadz) const {
139 //-----------------------------------------------------------------------
140 // Return the index of the nearest cluster in z y
141 //-----------------------------------------------------------------------
142 Float_t maxdistance = roady*roady + roadz*roadz;
144 AliTPCclusterMI *cl =0;
145 for (Int_t i=Find(z-roadz); i<fN; i++) {
146 AliTPCclusterMI *c=(AliTPCclusterMI*)(fClusters[i]);
147 if (c->GetZ() > z+roadz) break;
148 // if ( (c->GetY()-y) > roady ) continue; //JW: Why here not abs???
149 if ( TMath::Abs(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;
159 AliTPCclusterMI * AliTPCtrackerRow::FindNearest2(Double_t y, Double_t z, Double_t roady, Double_t roadz,UInt_t & index) const
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;
167 //PH Check boundaries. 510 is the size of fFastCluster
168 Int_t iz1 = Int_t(z-roadz+254.5);
169 if ( iz1>=510) return cl;
171 iz1 = TMath::Max(GetFastCluster(iz1)-1,0);
172 Int_t iz2 = Int_t(z+roadz+255.5);
173 if (iz2<0 ) return cl;
174 if ( iz2>=510) iz2 = 509;
175 iz2 = TMath::Min(GetFastCluster(iz2)+1,fN);
176 Bool_t skipUsed = !(AliTPCReconstructor::GetRecoParam()->GetClusterSharing());
177 //FindNearest3(y,z,roady,roadz,index);
178 // for (Int_t i=Find(z-roadz); i<fN; i++) {
179 for (Int_t i=iz1; i<iz2; i++) {
180 AliTPCclusterMI *c=(AliTPCclusterMI*)(fClusters[i]);
181 if (c->GetZ() > z+roadz) break;
182 if ( c->GetY()-y > roady ) continue;
183 if ( y-c->GetY() > roady ) continue;
184 if (skipUsed && c->IsUsed(11)) continue;
185 Float_t distance = (c->GetZ()-z)*(c->GetZ()-z)+(c->GetY()-y)*(c->GetY()-y);
186 if (maxdistance>distance) {
187 maxdistance = distance;
190 //roady = TMath::Sqrt(maxdistance);
197 void AliTPCtrackerRow::SetFastCluster(Int_t i, Short_t cl){
199 // Set cluster info for fast navigation
207 Int_t AliTPCtrackerSector::GetNClInSector(Int_t side)
209 // return number of all clusters in one sector; side =0 for A side and 1 for C side
212 Int_t nrows = GetNRows();
214 for (Int_t row=0;row<nrows;row++) {
215 AliTPCtrackerRow& tpcrow = (*this)[row];
216 Int_t ncl = (side==0)?(tpcrow.GetN1()):(tpcrow.GetN2());
226 Int_t AliTPCtrackerSector::GetRowNumber(Double_t x) const
228 //return pad row number for this x
232 if (x > r) return fN;
234 if (x < r) return -1;
235 return Int_t((x-r)/fPadPitchLength + 0.5);}
238 if (x > r) return fN;
240 if (x < r) return -1;
241 Double_t r1=fRow[64].GetX();
243 return Int_t((x-r)/f1PadPitchLength + 0.5);}
245 return (Int_t((x-r1)/f2PadPitchLength + 0.5)+64);}
250 void AliTPCtrackerRow::SetCluster1(Int_t i, const AliTPCclusterMI &cl)
253 if (!fClusters1) fClusters1 = new TClonesArray("AliTPCclusterMI",1000);
254 if (i<=fClusters1->GetLast() && fClusters1->UncheckedAt(i)) fClusters1->RemoveAt(i);
255 new( (*fClusters1)[fClusters1->GetEntriesFast()] ) AliTPCclusterMI(cl);
259 void AliTPCtrackerRow::SetCluster2(Int_t i, const AliTPCclusterMI &cl)
262 if (!fClusters2) fClusters2 = new TClonesArray("AliTPCclusterMI",1000);
263 if (i<=fClusters2->GetLast() && fClusters2->UncheckedAt(i)) fClusters2->RemoveAt(i);
264 new( (*fClusters2)[fClusters2->GetEntriesFast()] ) AliTPCclusterMI(cl);
269 //_________________________________________________________________________
270 void AliTPCtrackerSector::Setup(const AliTPCParam *par, Int_t f) {
271 //-----------------------------------------------------------------------
272 // Setup inner sector
273 //-----------------------------------------------------------------------
275 fAlpha=par->GetInnerAngle();
276 fAlphaShift=par->GetInnerAngleShift();
277 fPadPitchWidth=par->GetInnerPadPitchWidth();
278 fPadPitchLength=par->GetInnerPadPitchLength();
279 fN=par->GetNRowLow();
280 if(fRow)delete [] fRow;fRow = 0;
281 fRow=new AliTPCtrackerRow[fN];
282 for (Int_t i=0; i<fN; i++) {
283 fRow[i].SetX(par->GetPadRowRadiiLow(i));
284 fRow[i].SetDeadZone(1.5); //1.5 cm of dead zone
287 fAlpha=par->GetOuterAngle();
288 fAlphaShift=par->GetOuterAngleShift();
289 fPadPitchWidth = par->GetOuterPadPitchWidth();
290 fPadPitchLength = par->GetOuter1PadPitchLength();
291 f1PadPitchLength = par->GetOuter1PadPitchLength();
292 f2PadPitchLength = par->GetOuter2PadPitchLength();
294 if(fRow)delete [] fRow;fRow = 0;
295 fRow=new AliTPCtrackerRow[fN];
296 for (Int_t i=0; i<fN; i++) {
297 fRow[i].SetX(par->GetPadRowRadiiUp(i));
298 fRow[i].SetDeadZone(1.5); // 1.5 cm of dead zone
303 //_________________________________________________________________________
304 void AliTPCtrackerSector::InsertCluster(AliTPCclusterMI *cl, Int_t size, const AliTPCParam *par) {
305 //-----------------------------------------------------------------------
306 // Insert cluster to the sector
307 //-----------------------------------------------------------------------
311 const Int_t fkNIS = par->GetNInnerSector()/2;
312 const Int_t fkNOS = par->GetNOuterSector()/2;
313 Int_t row = cl->GetRow();
314 Int_t sec = cl->GetDetector();
316 // add cluster to the corresponding pad row
317 AliTPCtrackerRow *tpcrow = 0x0;
324 left = (sec-fkNIS*2)/fkNOS;
329 if(!tpcrow->GetClusters1()) {
332 if(size < kMaxClusterPerRow) {
333 tpcrow->SetCluster1(tpcrow->GetN1(), *cl);
334 //printf("inner: size %d, tpcrow->GetN1() %d sec %d row %d tpcrow %p cl %p\n", size, tpcrow->GetN1(), sec, row, tpcrow, cl);
336 tpcrow->IncrementN1();
341 if(!tpcrow->GetClusters2()) {
344 if(size < kMaxClusterPerRow) {
345 tpcrow->SetCluster2(tpcrow->GetN2(), *cl);
346 //printf("outer: size %d, tpcrow->GetN2() %d sec %d row %d tpcrow %p cl %p\n", size, tpcrow->GetN2(), sec, row, tpcrow, cl);
348 tpcrow->IncrementN2();
353 //_________________________________________________________________________
354 Int_t AliTPCtrackerSector::GetNClInSector(Int_t side) const
356 //return number of all clusters in one sector; side =0 for A side and 1 for C side
359 Int_t nrows = GetNRows();
361 for (Int_t row=0;row<nrows;row++) {
362 AliTPCtrackerRow& tpcrow = (*this)[row];
363 Int_t ncl = (side==0)?(tpcrow.GetN1()):(tpcrow.GetN2());
370 //_________________________________________________________________________
371 Int_t AliTPCtrackerSector::GetNClUsedInSector(Int_t side) const
373 //return number of clusters used in tracking in one sector; side =0 for A side and 1 for C side
376 Int_t nrows = GetNRows();
378 for (Int_t row=0;row<nrows;row++) {
379 AliTPCtrackerRow& tpcrow = (*this)[row];
380 Int_t nclusters = (side==0)?tpcrow.GetN1():tpcrow.GetN2();
381 for (Int_t icluster=0; icluster<nclusters; icluster++)
383 AliTPCclusterMI* cluster = NULL;
384 if (side==0) { cluster=tpcrow.GetCluster1(icluster); }
385 else { cluster=tpcrow.GetCluster2(icluster); }
386 if (!cluster) continue;
387 if (cluster->IsUsed(1)) nclSector++;