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():
63 // default constructor
67 AliTPCtrackerRow::~AliTPCtrackerRow(){
69 for (Int_t i = 0; i < fN1; i++)
70 fClusters1[i].~AliTPCclusterMI();
72 for (Int_t i = 0; i < fN2; i++)
73 fClusters2[i].~AliTPCclusterMI();
79 //_________________________________________________________________________
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");
90 //AliInfo("AliTPCtrackerRow::InsertCluster(): Too many clusters !");
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++;
100 void AliTPCtrackerRow::ResetClusters() {
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;
114 //delete[] fClusterArray;
120 //___________________________________________________________________
121 Int_t AliTPCtrackerRow::Find(Double_t z) const {
122 //-----------------------------------------------------------------------
123 // Return the index of the nearest cluster
124 //-----------------------------------------------------------------------
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;
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;
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;
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<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;
188 //roady = TMath::Sqrt(maxdistance);
195 void AliTPCtrackerRow::SetFastCluster(Int_t i, Short_t cl){
197 // Set cluster info for fast navigation
206 Int_t AliTPCtrackerSector::GetRowNumber(Double_t x) const
208 //return pad row number for this x
212 if (x > r) return fN;
214 if (x < r) return -1;
215 return Int_t((x-r)/fPadPitchLength + 0.5);}
218 if (x > r) return fN;
220 if (x < r) return -1;
221 Double_t r1=fRow[64].GetX();
223 return Int_t((x-r)/f1PadPitchLength + 0.5);}
225 return (Int_t((x-r1)/f2PadPitchLength + 0.5)+64);}
229 //_________________________________________________________________________
230 void AliTPCtrackerSector::Setup(const AliTPCParam *par, Int_t f) {
231 //-----------------------------------------------------------------------
232 // Setup inner sector
233 //-----------------------------------------------------------------------
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
247 fAlpha=par->GetOuterAngle();
248 fAlphaShift=par->GetOuterAngleShift();
249 fPadPitchWidth = par->GetOuterPadPitchWidth();
250 fPadPitchLength = par->GetOuter1PadPitchLength();
251 f1PadPitchLength = par->GetOuter1PadPitchLength();
252 f2PadPitchLength = par->GetOuter2PadPitchLength();
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
263 //_________________________________________________________________________
264 void AliTPCtrackerSector::InsertCluster(AliTPCclusterMI *cl, Int_t size, const AliTPCParam *par) {
265 //-----------------------------------------------------------------------
266 // Insert cluster to the sector
267 //-----------------------------------------------------------------------
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();
276 // add cluster to the corresponding pad row
277 AliTPCtrackerRow *tpcrow = 0x0;
284 left = (sec-fkNIS*2)/fkNOS;
289 if(!tpcrow->GetClusters1()) {
290 tpcrow->SetClusters1(new AliTPCclusterMI[size]);
293 if(size < kMaxClusterPerRow) {
294 tpcrow->SetCluster1(tpcrow->GetN1(), *cl);
295 //printf("inner: size %d, tpcrow->GetN1() %d sec %d row %d tpcrow %p cl %p\n", size, tpcrow->GetN1(), sec, row, tpcrow, cl);
297 tpcrow->IncrementN1();
302 if(!tpcrow->GetClusters2()) {
303 tpcrow->SetClusters2(new AliTPCclusterMI[size]);
306 if(size < kMaxClusterPerRow) {
307 tpcrow->SetCluster2(tpcrow->GetN2(), *cl);
308 //printf("outer: size %d, tpcrow->GetN2() %d sec %d row %d tpcrow %p cl %p\n", size, tpcrow->GetN2(), sec, row, tpcrow, cl);
310 tpcrow->IncrementN2();