]> git.uio.no Git - u/mrichter/AliRoot.git/blame - TPC/Rec/AliTPCtrackerSector.cxx
PWGPP-71, ATO-16 Changes for Outlier filtering and Open gating grid analysis
[u/mrichter/AliRoot.git] / TPC / Rec / AliTPCtrackerSector.cxx
CommitLineData
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"
9a836cc2 33//#include "AliTPCcluster.h"
9350f379 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
46ClassImp(AliTPCtrackerRow)
47ClassImp(AliTPCtrackerSector)
48
49
50
51AliTPCtrackerRow::AliTPCtrackerRow():
52 fDeadZone(0.),
53 fClusters1(0),
54 fN1(0),
55 fClusters2(0),
56 fN2(0),
9f98a33d 57 fFastCluster(),
9350f379 58 fN(0),
472f0066 59 fClusters(),
60 fIndex(),
61 fX(0.)
9350f379 62{
63 //
64 // default constructor
65 //
66}
67
68AliTPCtrackerRow::~AliTPCtrackerRow(){
69 //
bfa00fba 70 delete fClusters1;
71 delete fClusters2;
9350f379 72}
73
74
75
76//_________________________________________________________________________
77void
78AliTPCtrackerRow::InsertCluster(const AliTPCclusterMI* c, UInt_t index) {
79 //-----------------------------------------------------------------------
80 // Insert a cluster into this pad row in accordence with its y-coordinate
81 //-----------------------------------------------------------------------
3d34659a 82 if (!c) {
83 AliError("Inserting Zerro cluster pointer");
84 return;
85 }
9350f379 86 if (fN==kMaxClusterPerRow) {
87 //AliInfo("AliTPCtrackerRow::InsertCluster(): Too many clusters");
88 return;
89 }
90 if (fN>=fN1+fN2) {
91 //AliInfo("AliTPCtrackerRow::InsertCluster(): Too many clusters !");
92 }
93
94 if (fN==0) {fIndex[0]=index; fClusters[fN++]=c; return;}
95 Int_t i=Find(c->GetZ());
7528628f 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));
99 }
9350f379 100 fIndex[i]=index; fClusters[i]=c; fN++;
101}
102
103void AliTPCtrackerRow::ResetClusters() {
104 //
105 // reset clusters
106 // MvL: Need to call destructors for AliTPCclusterMI, to delete fInfo
bfa00fba 107 if (fClusters1) fClusters1->Clear("C");
108 if (fClusters2) fClusters2->Clear("C");
9350f379 109
110 fN = 0;
111 fN1 = 0;
112 fN2 = 0;
113 //delete[] fClusterArray;
114
115 //fClusterArray=0;
116}
117
118
119//___________________________________________________________________
120Int_t AliTPCtrackerRow::Find(Double_t z) const {
121 //-----------------------------------------------------------------------
122 // Return the index of the nearest cluster
123 //-----------------------------------------------------------------------
124 if (fN==0) return 0;
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;
130 else e=m;
131 }
132 return m;
133}
134
135
136
137//___________________________________________________________________
138AliTPCclusterMI * 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;
143
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;
38d9d609 148// if ( (c->GetY()-y) > roady ) continue; //JW: Why here not abs???
149 if ( TMath::Abs(c->GetY()-y) > roady ) continue;
9350f379 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
159AliTPCclusterMI * 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
60f94d81 168 Int_t iz1 = Int_t(z-roadz+254.5);
169 if ( iz1>=510) return cl;
170 if (iz1<0 ) iz1 = 0;
9350f379 171 iz1 = TMath::Max(GetFastCluster(iz1)-1,0);
172 Int_t iz2 = Int_t(z+roadz+255.5);
60f94d81 173 if (iz2<0 ) return cl;
174 if ( iz2>=510) iz2 = 509;
9350f379 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;
44ca7282 185 if (c->IsDisabled()) continue;
9350f379 186 Float_t distance = (c->GetZ()-z)*(c->GetZ()-z)+(c->GetY()-y)*(c->GetY()-y);
187 if (maxdistance>distance) {
188 maxdistance = distance;
189 cl=c;
190 index =i;
191 //roady = TMath::Sqrt(maxdistance);
192 }
193 }
194 return cl;
195}
196
197
198void AliTPCtrackerRow::SetFastCluster(Int_t i, Short_t cl){
199 //
200 // Set cluster info for fast navigation
201 //
472f0066 202 if (i>=510|| i<0){
9350f379 203 }else{
204 fFastCluster[i]=cl;
205 }
206}
207
9a836cc2 208Int_t AliTPCtrackerSector::GetNClInSector(Int_t side)
209{
210 // return number of all clusters in one sector; side =0 for A side and 1 for C side
211
212 Int_t nclSector=0;
213 Int_t nrows = GetNRows();
214
215 for (Int_t row=0;row<nrows;row++) {
216 AliTPCtrackerRow& tpcrow = (*this)[row];
217 Int_t ncl = (side==0)?(tpcrow.GetN1()):(tpcrow.GetN2());
218 nclSector+=ncl;
219 }
220
221 return nclSector;
222}
223
224
225
9350f379 226
227Int_t AliTPCtrackerSector::GetRowNumber(Double_t x) const
228{
229 //return pad row number for this x
230 Double_t r;
231 if (fN < 64){
232 r=fRow[fN-1].GetX();
233 if (x > r) return fN;
234 r=fRow[0].GetX();
235 if (x < r) return -1;
236 return Int_t((x-r)/fPadPitchLength + 0.5);}
237 else{
238 r=fRow[fN-1].GetX();
239 if (x > r) return fN;
240 r=fRow[0].GetX();
241 if (x < r) return -1;
242 Double_t r1=fRow[64].GetX();
243 if(x<r1){
244 return Int_t((x-r)/f1PadPitchLength + 0.5);}
245 else{
246 return (Int_t((x-r1)/f2PadPitchLength + 0.5)+64);}
247 }
248}
249
bfa00fba 250
251void AliTPCtrackerRow::SetCluster1(Int_t i, const AliTPCclusterMI &cl)
252{
253 // attach cluster
254 if (!fClusters1) fClusters1 = new TClonesArray("AliTPCclusterMI",1000);
255 if (i<=fClusters1->GetLast() && fClusters1->UncheckedAt(i)) fClusters1->RemoveAt(i);
256 new( (*fClusters1)[fClusters1->GetEntriesFast()] ) AliTPCclusterMI(cl);
257 //
258}
259
260void AliTPCtrackerRow::SetCluster2(Int_t i, const AliTPCclusterMI &cl)
261{
262 // attach cluster
263 if (!fClusters2) fClusters2 = new TClonesArray("AliTPCclusterMI",1000);
264 if (i<=fClusters2->GetLast() && fClusters2->UncheckedAt(i)) fClusters2->RemoveAt(i);
265 new( (*fClusters2)[fClusters2->GetEntriesFast()] ) AliTPCclusterMI(cl);
266 //
267}
268
269
9350f379 270//_________________________________________________________________________
271void AliTPCtrackerSector::Setup(const AliTPCParam *par, Int_t f) {
272 //-----------------------------------------------------------------------
273 // Setup inner sector
274 //-----------------------------------------------------------------------
275 if (f==0) {
276 fAlpha=par->GetInnerAngle();
277 fAlphaShift=par->GetInnerAngleShift();
278 fPadPitchWidth=par->GetInnerPadPitchWidth();
279 fPadPitchLength=par->GetInnerPadPitchLength();
280 fN=par->GetNRowLow();
281 if(fRow)delete [] fRow;fRow = 0;
282 fRow=new AliTPCtrackerRow[fN];
283 for (Int_t i=0; i<fN; i++) {
284 fRow[i].SetX(par->GetPadRowRadiiLow(i));
285 fRow[i].SetDeadZone(1.5); //1.5 cm of dead zone
286 }
287 } else {
288 fAlpha=par->GetOuterAngle();
289 fAlphaShift=par->GetOuterAngleShift();
290 fPadPitchWidth = par->GetOuterPadPitchWidth();
291 fPadPitchLength = par->GetOuter1PadPitchLength();
292 f1PadPitchLength = par->GetOuter1PadPitchLength();
293 f2PadPitchLength = par->GetOuter2PadPitchLength();
294 fN=par->GetNRowUp();
295 if(fRow)delete [] fRow;fRow = 0;
296 fRow=new AliTPCtrackerRow[fN];
297 for (Int_t i=0; i<fN; i++) {
298 fRow[i].SetX(par->GetPadRowRadiiUp(i));
299 fRow[i].SetDeadZone(1.5); // 1.5 cm of dead zone
300 }
301 }
302}
303
aa7f1a5a 304//_________________________________________________________________________
305void AliTPCtrackerSector::InsertCluster(AliTPCclusterMI *cl, Int_t size, const AliTPCParam *par) {
306 //-----------------------------------------------------------------------
307 // Insert cluster to the sector
308 //-----------------------------------------------------------------------
9350f379 309
aa7f1a5a 310 if(!cl) return;
9350f379 311
aa7f1a5a 312 const Int_t fkNIS = par->GetNInnerSector()/2;
313 const Int_t fkNOS = par->GetNOuterSector()/2;
314 Int_t row = cl->GetRow();
315 Int_t sec = cl->GetDetector();
316
317 // add cluster to the corresponding pad row
318 AliTPCtrackerRow *tpcrow = 0x0;
319
320 Int_t left=0;
321 if (sec<fkNIS*2){
322 left = sec/fkNIS;
323 }
324 else{
325 left = (sec-fkNIS*2)/fkNOS;
326 }
327 //
328 if (left ==0){
329 tpcrow = fRow+row;
98ee6d31 330 if(!tpcrow->GetClusters1()) {
98ee6d31 331 tpcrow->SetN1(0);
332 }
aa7f1a5a 333 if(size < kMaxClusterPerRow) {
334 tpcrow->SetCluster1(tpcrow->GetN1(), *cl);
98ee6d31 335 //printf("inner: size %d, tpcrow->GetN1() %d sec %d row %d tpcrow %p cl %p\n", size, tpcrow->GetN1(), sec, row, tpcrow, cl);
aa7f1a5a 336
337 tpcrow->IncrementN1();
338 }
339 }
340 if (left ==1){
341 tpcrow = fRow+row;
98ee6d31 342 if(!tpcrow->GetClusters2()) {
98ee6d31 343 tpcrow->SetN2(0);
344 }
aa7f1a5a 345 if(size < kMaxClusterPerRow) {
346 tpcrow->SetCluster2(tpcrow->GetN2(), *cl);
98ee6d31 347 //printf("outer: size %d, tpcrow->GetN2() %d sec %d row %d tpcrow %p cl %p\n", size, tpcrow->GetN2(), sec, row, tpcrow, cl);
aa7f1a5a 348
349 tpcrow->IncrementN2();
350 }
351 }
352}
9350f379 353
5576d489 354//_________________________________________________________________________
355Int_t AliTPCtrackerSector::GetNClInSector(Int_t side) const
356{
357 //return number of all clusters in one sector; side =0 for A side and 1 for C side
358
359 Int_t nclSector=0;
360 Int_t nrows = GetNRows();
361
362 for (Int_t row=0;row<nrows;row++) {
363 AliTPCtrackerRow& tpcrow = (*this)[row];
364 Int_t ncl = (side==0)?(tpcrow.GetN1()):(tpcrow.GetN2());
365 nclSector+=ncl;
366 }
367
368 return nclSector;
369}
370
371//_________________________________________________________________________
372Int_t AliTPCtrackerSector::GetNClUsedInSector(Int_t side) const
373{
374 //return number of clusters used in tracking in one sector; side =0 for A side and 1 for C side
375
376 Int_t nclSector=0;
377 Int_t nrows = GetNRows();
378
379 for (Int_t row=0;row<nrows;row++) {
380 AliTPCtrackerRow& tpcrow = (*this)[row];
381 Int_t nclusters = (side==0)?tpcrow.GetN1():tpcrow.GetN2();
382 for (Int_t icluster=0; icluster<nclusters; icluster++)
383 {
384 AliTPCclusterMI* cluster = NULL;
385 if (side==0) { cluster=tpcrow.GetCluster1(icluster); }
386 else { cluster=tpcrow.GetCluster2(icluster); }
387 if (!cluster) continue;
388 if (cluster->IsUsed(1)) nclSector++;
389 }
390 }
391
392 return nclSector;
393}
394