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():
61 // default constructor
65 AliTPCtrackerRow::~AliTPCtrackerRow(){
67 for (Int_t i = 0; i < fN1; i++)
68 fClusters1[i].~AliTPCclusterMI();
70 for (Int_t i = 0; i < fN2; i++)
71 fClusters2[i].~AliTPCclusterMI();
77 //_________________________________________________________________________
79 AliTPCtrackerRow::InsertCluster(const AliTPCclusterMI* c, UInt_t index) {
80 //-----------------------------------------------------------------------
81 // Insert a cluster into this pad row in accordence with its y-coordinate
82 //-----------------------------------------------------------------------
83 if (fN==kMaxClusterPerRow) {
84 //AliInfo("AliTPCtrackerRow::InsertCluster(): Too many clusters");
88 //AliInfo("AliTPCtrackerRow::InsertCluster(): Too many clusters !");
91 if (fN==0) {fIndex[0]=index; fClusters[fN++]=c; return;}
92 Int_t i=Find(c->GetZ());
93 memmove(fClusters+i+1 ,fClusters+i,(fN-i)*sizeof(AliTPCclusterMI*));
94 memmove(fIndex +i+1 ,fIndex +i,(fN-i)*sizeof(UInt_t));
95 fIndex[i]=index; fClusters[i]=c; fN++;
98 void AliTPCtrackerRow::ResetClusters() {
101 // MvL: Need to call destructors for AliTPCclusterMI, to delete fInfo
102 for (Int_t i = 0; i < fN1; i++)
103 fClusters1[i].~AliTPCclusterMI();
104 delete [] fClusters1; fClusters1=0;
105 for (Int_t i = 0; i < fN2; i++)
106 fClusters2[i].~AliTPCclusterMI();
107 delete [] fClusters2; fClusters2=0;
112 //delete[] fClusterArray;
118 //___________________________________________________________________
119 Int_t AliTPCtrackerRow::Find(Double_t z) const {
120 //-----------------------------------------------------------------------
121 // Return the index of the nearest cluster
122 //-----------------------------------------------------------------------
124 if (z <= fClusters[0]->GetZ()) return 0;
125 if (z > fClusters[fN-1]->GetZ()) return fN;
126 Int_t b=0, e=fN-1, m=(b+e)/2;
127 for (; b<e; m=(b+e)/2) {
128 if (z > fClusters[m]->GetZ()) b=m+1;
136 //___________________________________________________________________
137 AliTPCclusterMI * AliTPCtrackerRow::FindNearest(Double_t y, Double_t z, Double_t roady, Double_t roadz) const {
138 //-----------------------------------------------------------------------
139 // Return the index of the nearest cluster in z y
140 //-----------------------------------------------------------------------
141 Float_t maxdistance = roady*roady + roadz*roadz;
143 AliTPCclusterMI *cl =0;
144 for (Int_t i=Find(z-roadz); i<fN; i++) {
145 AliTPCclusterMI *c=(AliTPCclusterMI*)(fClusters[i]);
146 if (c->GetZ() > z+roadz) break;
147 if ( (c->GetY()-y) > roady ) continue;
148 Float_t distance = (c->GetZ()-z)*(c->GetZ()-z)+(c->GetY()-y)*(c->GetY()-y);
149 if (maxdistance>distance) {
150 maxdistance = distance;
157 AliTPCclusterMI * AliTPCtrackerRow::FindNearest2(Double_t y, Double_t z, Double_t roady, Double_t roadz,UInt_t & index) const
159 //-----------------------------------------------------------------------
160 // Return the index of the nearest cluster in z y
161 //-----------------------------------------------------------------------
162 Float_t maxdistance = roady*roady + roadz*roadz;
163 AliTPCclusterMI *cl =0;
165 //PH Check boundaries. 510 is the size of fFastCluster
166 Int_t iz1 = Int_t(z-roadz+254.5);
167 if (iz1<0 || iz1>=510) return cl;
168 iz1 = TMath::Max(GetFastCluster(iz1)-1,0);
169 Int_t iz2 = Int_t(z+roadz+255.5);
170 if (iz2<0 || iz2>=510) return cl;
171 iz2 = TMath::Min(GetFastCluster(iz2)+1,fN);
172 Bool_t skipUsed = !(AliTPCReconstructor::GetRecoParam()->GetClusterSharing());
173 //FindNearest3(y,z,roady,roadz,index);
174 // for (Int_t i=Find(z-roadz); i<fN; i++) {
175 for (Int_t i=iz1; i<iz2; i++) {
176 AliTPCclusterMI *c=(AliTPCclusterMI*)(fClusters[i]);
177 if (c->GetZ() > z+roadz) break;
178 if ( c->GetY()-y > roady ) continue;
179 if ( y-c->GetY() > roady ) continue;
180 if (skipUsed && c->IsUsed(11)) continue;
181 Float_t distance = (c->GetZ()-z)*(c->GetZ()-z)+(c->GetY()-y)*(c->GetY()-y);
182 if (maxdistance>distance) {
183 maxdistance = distance;
186 //roady = TMath::Sqrt(maxdistance);
193 void AliTPCtrackerRow::SetFastCluster(Int_t i, Short_t cl){
195 // Set cluster info for fast navigation
204 Int_t AliTPCtrackerSector::GetRowNumber(Double_t x) const
206 //return pad row number for this x
210 if (x > r) return fN;
212 if (x < r) return -1;
213 return Int_t((x-r)/fPadPitchLength + 0.5);}
216 if (x > r) return fN;
218 if (x < r) return -1;
219 Double_t r1=fRow[64].GetX();
221 return Int_t((x-r)/f1PadPitchLength + 0.5);}
223 return (Int_t((x-r1)/f2PadPitchLength + 0.5)+64);}
227 //_________________________________________________________________________
228 void AliTPCtrackerSector::Setup(const AliTPCParam *par, Int_t f) {
229 //-----------------------------------------------------------------------
230 // Setup inner sector
231 //-----------------------------------------------------------------------
233 fAlpha=par->GetInnerAngle();
234 fAlphaShift=par->GetInnerAngleShift();
235 fPadPitchWidth=par->GetInnerPadPitchWidth();
236 fPadPitchLength=par->GetInnerPadPitchLength();
237 fN=par->GetNRowLow();
238 if(fRow)delete [] fRow;fRow = 0;
239 fRow=new AliTPCtrackerRow[fN];
240 for (Int_t i=0; i<fN; i++) {
241 fRow[i].SetX(par->GetPadRowRadiiLow(i));
242 fRow[i].SetDeadZone(1.5); //1.5 cm of dead zone
245 fAlpha=par->GetOuterAngle();
246 fAlphaShift=par->GetOuterAngleShift();
247 fPadPitchWidth = par->GetOuterPadPitchWidth();
248 fPadPitchLength = par->GetOuter1PadPitchLength();
249 f1PadPitchLength = par->GetOuter1PadPitchLength();
250 f2PadPitchLength = par->GetOuter2PadPitchLength();
252 if(fRow)delete [] fRow;fRow = 0;
253 fRow=new AliTPCtrackerRow[fN];
254 for (Int_t i=0; i<fN; i++) {
255 fRow[i].SetX(par->GetPadRowRadiiUp(i));
256 fRow[i].SetDeadZone(1.5); // 1.5 cm of dead zone
261 //_________________________________________________________________________
262 void AliTPCtrackerSector::InsertCluster(AliTPCclusterMI *cl, Int_t size, const AliTPCParam *par) {
263 //-----------------------------------------------------------------------
264 // Insert cluster to the sector
265 //-----------------------------------------------------------------------
269 const Int_t fkNIS = par->GetNInnerSector()/2;
270 const Int_t fkNOS = par->GetNOuterSector()/2;
271 Int_t row = cl->GetRow();
272 Int_t sec = cl->GetDetector();
274 // add cluster to the corresponding pad row
275 AliTPCtrackerRow *tpcrow = 0x0;
282 left = (sec-fkNIS*2)/fkNOS;
287 if(!tpcrow->GetClusters1()) {
288 tpcrow->SetClusters1(new AliTPCclusterMI[size]);
291 if(size < kMaxClusterPerRow) {
292 tpcrow->SetCluster1(tpcrow->GetN1(), *cl);
293 //printf("inner: size %d, tpcrow->GetN1() %d sec %d row %d tpcrow %p cl %p\n", size, tpcrow->GetN1(), sec, row, tpcrow, cl);
295 tpcrow->IncrementN1();
300 if(!tpcrow->GetClusters2()) {
301 tpcrow->SetClusters2(new AliTPCclusterMI[size]);
304 if(size < kMaxClusterPerRow) {
305 tpcrow->SetCluster2(tpcrow->GetN2(), *cl);
306 //printf("outer: size %d, tpcrow->GetN2() %d sec %d row %d tpcrow %p cl %p\n", size, tpcrow->GetN2(), sec, row, tpcrow, cl);
308 tpcrow->IncrementN2();