]> git.uio.no Git - u/mrichter/AliRoot.git/blame - TPC/AliTPCtrackerSector.cxx
Make OCDB Entry
[u/mrichter/AliRoot.git] / TPC / 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"
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
46ClassImp(AliTPCtrackerRow)
47ClassImp(AliTPCtrackerSector)
48
49
50
51AliTPCtrackerRow::AliTPCtrackerRow():
52 fDeadZone(0.),
53 fClusters1(0),
54 fN1(0),
55 fClusters2(0),
56 fN2(0),
57 fN(0),
58 fX(0.)
59{
60 //
61 // default constructor
62 //
63}
64
65AliTPCtrackerRow::~AliTPCtrackerRow(){
66 //
67 for (Int_t i = 0; i < fN1; i++)
68 fClusters1[i].~AliTPCclusterMI();
69 delete [] fClusters1;
70 for (Int_t i = 0; i < fN2; i++)
71 fClusters2[i].~AliTPCclusterMI();
72 delete [] fClusters2;
73}
74
75
76
77//_________________________________________________________________________
78void
79AliTPCtrackerRow::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");
85 return;
86 }
87 if (fN>=fN1+fN2) {
88 //AliInfo("AliTPCtrackerRow::InsertCluster(): Too many clusters !");
89 }
90
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++;
96}
97
98void AliTPCtrackerRow::ResetClusters() {
99 //
100 // reset clusters
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;
108
109 fN = 0;
110 fN1 = 0;
111 fN2 = 0;
112 //delete[] fClusterArray;
113
114 //fClusterArray=0;
115}
116
117
118//___________________________________________________________________
119Int_t AliTPCtrackerRow::Find(Double_t z) const {
120 //-----------------------------------------------------------------------
121 // Return the index of the nearest cluster
122 //-----------------------------------------------------------------------
123 if (fN==0) return 0;
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;
129 else e=m;
130 }
131 return m;
132}
133
134
135
136//___________________________________________________________________
137AliTPCclusterMI * 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;
142
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;
151 cl=c;
152 }
153 }
154 return cl;
155}
156
157AliTPCclusterMI * AliTPCtrackerRow::FindNearest2(Double_t y, Double_t z, Double_t roady, Double_t roadz,UInt_t & index) const
158{
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;
164
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;
184 cl=c;
185 index =i;
186 //roady = TMath::Sqrt(maxdistance);
187 }
188 }
189 return cl;
190}
191
192
193void AliTPCtrackerRow::SetFastCluster(Int_t i, Short_t cl){
194 //
195 // Set cluster info for fast navigation
196 //
197 if (i>510|| i<0){
198 }else{
199 fFastCluster[i]=cl;
200 }
201}
202
203
204Int_t AliTPCtrackerSector::GetRowNumber(Double_t x) const
205{
206 //return pad row number for this x
207 Double_t r;
208 if (fN < 64){
209 r=fRow[fN-1].GetX();
210 if (x > r) return fN;
211 r=fRow[0].GetX();
212 if (x < r) return -1;
213 return Int_t((x-r)/fPadPitchLength + 0.5);}
214 else{
215 r=fRow[fN-1].GetX();
216 if (x > r) return fN;
217 r=fRow[0].GetX();
218 if (x < r) return -1;
219 Double_t r1=fRow[64].GetX();
220 if(x<r1){
221 return Int_t((x-r)/f1PadPitchLength + 0.5);}
222 else{
223 return (Int_t((x-r1)/f2PadPitchLength + 0.5)+64);}
224 }
225}
226
227//_________________________________________________________________________
228void AliTPCtrackerSector::Setup(const AliTPCParam *par, Int_t f) {
229 //-----------------------------------------------------------------------
230 // Setup inner sector
231 //-----------------------------------------------------------------------
232 if (f==0) {
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
243 }
244 } else {
245 fAlpha=par->GetOuterAngle();
246 fAlphaShift=par->GetOuterAngleShift();
247 fPadPitchWidth = par->GetOuterPadPitchWidth();
248 fPadPitchLength = par->GetOuter1PadPitchLength();
249 f1PadPitchLength = par->GetOuter1PadPitchLength();
250 f2PadPitchLength = par->GetOuter2PadPitchLength();
251 fN=par->GetNRowUp();
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
257 }
258 }
259}
260
aa7f1a5a 261//_________________________________________________________________________
262void AliTPCtrackerSector::InsertCluster(AliTPCclusterMI *cl, Int_t size, const AliTPCParam *par) {
263 //-----------------------------------------------------------------------
264 // Insert cluster to the sector
265 //-----------------------------------------------------------------------
9350f379 266
aa7f1a5a 267 if(!cl) return;
9350f379 268
aa7f1a5a 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();
273
274 // add cluster to the corresponding pad row
275 AliTPCtrackerRow *tpcrow = 0x0;
276
277 Int_t left=0;
278 if (sec<fkNIS*2){
279 left = sec/fkNIS;
280 }
281 else{
282 left = (sec-fkNIS*2)/fkNOS;
283 }
284 //
285 if (left ==0){
286 tpcrow = fRow+row;
98ee6d31 287 if(!tpcrow->GetClusters1()) {
288 tpcrow->SetClusters1(new AliTPCclusterMI[size]);
289 tpcrow->SetN1(0);
290 }
aa7f1a5a 291 if(size < kMaxClusterPerRow) {
292 tpcrow->SetCluster1(tpcrow->GetN1(), *cl);
98ee6d31 293 //printf("inner: size %d, tpcrow->GetN1() %d sec %d row %d tpcrow %p cl %p\n", size, tpcrow->GetN1(), sec, row, tpcrow, cl);
aa7f1a5a 294
295 tpcrow->IncrementN1();
296 }
297 }
298 if (left ==1){
299 tpcrow = fRow+row;
98ee6d31 300 if(!tpcrow->GetClusters2()) {
301 tpcrow->SetClusters2(new AliTPCclusterMI[size]);
302 tpcrow->SetN2(0);
303 }
aa7f1a5a 304 if(size < kMaxClusterPerRow) {
305 tpcrow->SetCluster2(tpcrow->GetN2(), *cl);
98ee6d31 306 //printf("outer: size %d, tpcrow->GetN2() %d sec %d row %d tpcrow %p cl %p\n", size, tpcrow->GetN2(), sec, row, tpcrow, cl);
aa7f1a5a 307
308 tpcrow->IncrementN2();
309 }
310 }
311}
9350f379 312
313
314