Parameterization of the gas properties - Usage in the MC
[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"
9350f379 33#include "AliTPCclusterMI.h"
34#include "AliTPCClustersRow.h"
35#include "AliTPCParam.h"
36#include "AliTPCReconstructor.h"
37#include "AliTPCreco.h"
38//
39#include "AliTPCtrackerSector.h"
40#include "TStopwatch.h"
41#include "TTreeStream.h"
42
43//
44
45ClassImp(AliTPCtrackerRow)
46ClassImp(AliTPCtrackerSector)
47
48
49
50AliTPCtrackerRow::AliTPCtrackerRow():
51 fDeadZone(0.),
52 fClusters1(0),
53 fN1(0),
54 fClusters2(0),
55 fN2(0),
9f98a33d 56 fFastCluster(),
9350f379 57 fN(0),
472f0066 58 fClusters(),
59 fIndex(),
60 fX(0.)
9350f379 61{
62 //
63 // default constructor
64 //
65}
66
67AliTPCtrackerRow::~AliTPCtrackerRow(){
68 //
bfa00fba 69 delete fClusters1;
70 delete fClusters2;
9350f379 71}
72
73
74
75//_________________________________________________________________________
76void
77AliTPCtrackerRow::InsertCluster(const AliTPCclusterMI* c, UInt_t index) {
78 //-----------------------------------------------------------------------
79 // Insert a cluster into this pad row in accordence with its y-coordinate
80 //-----------------------------------------------------------------------
3d34659a 81 if (!c) {
82 AliError("Inserting Zerro cluster pointer");
83 return;
84 }
9350f379 85 if (fN==kMaxClusterPerRow) {
86 //AliInfo("AliTPCtrackerRow::InsertCluster(): Too many clusters");
87 return;
88 }
89 if (fN>=fN1+fN2) {
90 //AliInfo("AliTPCtrackerRow::InsertCluster(): Too many clusters !");
91 }
92
93 if (fN==0) {fIndex[0]=index; fClusters[fN++]=c; return;}
94 Int_t i=Find(c->GetZ());
7528628f 95 if (i>=0 && i<=kMaxClusterPerRow-2) {
96 memmove(fClusters+i+1 ,fClusters+i,(fN-i)*sizeof(AliTPCclusterMI*));
97 memmove(fIndex +i+1 ,fIndex +i,(fN-i)*sizeof(UInt_t));
98 }
9350f379 99 fIndex[i]=index; fClusters[i]=c; fN++;
100}
101
102void AliTPCtrackerRow::ResetClusters() {
103 //
104 // reset clusters
105 // MvL: Need to call destructors for AliTPCclusterMI, to delete fInfo
bfa00fba 106 if (fClusters1) fClusters1->Clear("C");
107 if (fClusters2) fClusters2->Clear("C");
9350f379 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;
38d9d609 147// if ( (c->GetY()-y) > roady ) continue; //JW: Why here not abs???
148 if ( TMath::Abs(c->GetY()-y) > roady ) continue;
9350f379 149 Float_t distance = (c->GetZ()-z)*(c->GetZ()-z)+(c->GetY()-y)*(c->GetY()-y);
150 if (maxdistance>distance) {
151 maxdistance = distance;
152 cl=c;
153 }
154 }
155 return cl;
156}
157
158AliTPCclusterMI * AliTPCtrackerRow::FindNearest2(Double_t y, Double_t z, Double_t roady, Double_t roadz,UInt_t & index) const
159{
160 //-----------------------------------------------------------------------
161 // Return the index of the nearest cluster in z y
162 //-----------------------------------------------------------------------
163 Float_t maxdistance = roady*roady + roadz*roadz;
164 AliTPCclusterMI *cl =0;
165
166 //PH Check boundaries. 510 is the size of fFastCluster
60f94d81 167 Int_t iz1 = Int_t(z-roadz+254.5);
168 if ( iz1>=510) return cl;
169 if (iz1<0 ) iz1 = 0;
9350f379 170 iz1 = TMath::Max(GetFastCluster(iz1)-1,0);
171 Int_t iz2 = Int_t(z+roadz+255.5);
60f94d81 172 if (iz2<0 ) return cl;
173 if ( iz2>=510) iz2 = 509;
9350f379 174 iz2 = TMath::Min(GetFastCluster(iz2)+1,fN);
175 Bool_t skipUsed = !(AliTPCReconstructor::GetRecoParam()->GetClusterSharing());
176 //FindNearest3(y,z,roady,roadz,index);
177 // for (Int_t i=Find(z-roadz); i<fN; i++) {
178 for (Int_t i=iz1; i<iz2; i++) {
179 AliTPCclusterMI *c=(AliTPCclusterMI*)(fClusters[i]);
180 if (c->GetZ() > z+roadz) break;
181 if ( c->GetY()-y > roady ) continue;
182 if ( y-c->GetY() > roady ) continue;
183 if (skipUsed && c->IsUsed(11)) continue;
184 Float_t distance = (c->GetZ()-z)*(c->GetZ()-z)+(c->GetY()-y)*(c->GetY()-y);
185 if (maxdistance>distance) {
186 maxdistance = distance;
187 cl=c;
188 index =i;
189 //roady = TMath::Sqrt(maxdistance);
190 }
191 }
192 return cl;
193}
194
195
196void AliTPCtrackerRow::SetFastCluster(Int_t i, Short_t cl){
197 //
198 // Set cluster info for fast navigation
199 //
472f0066 200 if (i>=510|| i<0){
9350f379 201 }else{
202 fFastCluster[i]=cl;
203 }
204}
205
206
207Int_t AliTPCtrackerSector::GetRowNumber(Double_t x) const
208{
209 //return pad row number for this x
210 Double_t r;
211 if (fN < 64){
212 r=fRow[fN-1].GetX();
213 if (x > r) return fN;
214 r=fRow[0].GetX();
215 if (x < r) return -1;
216 return Int_t((x-r)/fPadPitchLength + 0.5);}
217 else{
218 r=fRow[fN-1].GetX();
219 if (x > r) return fN;
220 r=fRow[0].GetX();
221 if (x < r) return -1;
222 Double_t r1=fRow[64].GetX();
223 if(x<r1){
224 return Int_t((x-r)/f1PadPitchLength + 0.5);}
225 else{
226 return (Int_t((x-r1)/f2PadPitchLength + 0.5)+64);}
227 }
228}
229
bfa00fba 230
231void AliTPCtrackerRow::SetCluster1(Int_t i, const AliTPCclusterMI &cl)
232{
233 // attach cluster
234 if (!fClusters1) fClusters1 = new TClonesArray("AliTPCclusterMI",1000);
235 if (i<=fClusters1->GetLast() && fClusters1->UncheckedAt(i)) fClusters1->RemoveAt(i);
236 new( (*fClusters1)[fClusters1->GetEntriesFast()] ) AliTPCclusterMI(cl);
237 //
238}
239
240void AliTPCtrackerRow::SetCluster2(Int_t i, const AliTPCclusterMI &cl)
241{
242 // attach cluster
243 if (!fClusters2) fClusters2 = new TClonesArray("AliTPCclusterMI",1000);
244 if (i<=fClusters2->GetLast() && fClusters2->UncheckedAt(i)) fClusters2->RemoveAt(i);
245 new( (*fClusters2)[fClusters2->GetEntriesFast()] ) AliTPCclusterMI(cl);
246 //
247}
248
249
9350f379 250//_________________________________________________________________________
251void AliTPCtrackerSector::Setup(const AliTPCParam *par, Int_t f) {
252 //-----------------------------------------------------------------------
253 // Setup inner sector
254 //-----------------------------------------------------------------------
255 if (f==0) {
256 fAlpha=par->GetInnerAngle();
257 fAlphaShift=par->GetInnerAngleShift();
258 fPadPitchWidth=par->GetInnerPadPitchWidth();
259 fPadPitchLength=par->GetInnerPadPitchLength();
260 fN=par->GetNRowLow();
261 if(fRow)delete [] fRow;fRow = 0;
262 fRow=new AliTPCtrackerRow[fN];
263 for (Int_t i=0; i<fN; i++) {
264 fRow[i].SetX(par->GetPadRowRadiiLow(i));
265 fRow[i].SetDeadZone(1.5); //1.5 cm of dead zone
266 }
267 } else {
268 fAlpha=par->GetOuterAngle();
269 fAlphaShift=par->GetOuterAngleShift();
270 fPadPitchWidth = par->GetOuterPadPitchWidth();
271 fPadPitchLength = par->GetOuter1PadPitchLength();
272 f1PadPitchLength = par->GetOuter1PadPitchLength();
273 f2PadPitchLength = par->GetOuter2PadPitchLength();
274 fN=par->GetNRowUp();
275 if(fRow)delete [] fRow;fRow = 0;
276 fRow=new AliTPCtrackerRow[fN];
277 for (Int_t i=0; i<fN; i++) {
278 fRow[i].SetX(par->GetPadRowRadiiUp(i));
279 fRow[i].SetDeadZone(1.5); // 1.5 cm of dead zone
280 }
281 }
282}
283
aa7f1a5a 284//_________________________________________________________________________
285void AliTPCtrackerSector::InsertCluster(AliTPCclusterMI *cl, Int_t size, const AliTPCParam *par) {
286 //-----------------------------------------------------------------------
287 // Insert cluster to the sector
288 //-----------------------------------------------------------------------
9350f379 289
aa7f1a5a 290 if(!cl) return;
9350f379 291
aa7f1a5a 292 const Int_t fkNIS = par->GetNInnerSector()/2;
293 const Int_t fkNOS = par->GetNOuterSector()/2;
294 Int_t row = cl->GetRow();
295 Int_t sec = cl->GetDetector();
296
297 // add cluster to the corresponding pad row
298 AliTPCtrackerRow *tpcrow = 0x0;
299
300 Int_t left=0;
301 if (sec<fkNIS*2){
302 left = sec/fkNIS;
303 }
304 else{
305 left = (sec-fkNIS*2)/fkNOS;
306 }
307 //
308 if (left ==0){
309 tpcrow = fRow+row;
98ee6d31 310 if(!tpcrow->GetClusters1()) {
98ee6d31 311 tpcrow->SetN1(0);
312 }
aa7f1a5a 313 if(size < kMaxClusterPerRow) {
314 tpcrow->SetCluster1(tpcrow->GetN1(), *cl);
98ee6d31 315 //printf("inner: size %d, tpcrow->GetN1() %d sec %d row %d tpcrow %p cl %p\n", size, tpcrow->GetN1(), sec, row, tpcrow, cl);
aa7f1a5a 316
317 tpcrow->IncrementN1();
318 }
319 }
320 if (left ==1){
321 tpcrow = fRow+row;
98ee6d31 322 if(!tpcrow->GetClusters2()) {
98ee6d31 323 tpcrow->SetN2(0);
324 }
aa7f1a5a 325 if(size < kMaxClusterPerRow) {
326 tpcrow->SetCluster2(tpcrow->GetN2(), *cl);
98ee6d31 327 //printf("outer: size %d, tpcrow->GetN2() %d sec %d row %d tpcrow %p cl %p\n", size, tpcrow->GetN2(), sec, row, tpcrow, cl);
aa7f1a5a 328
329 tpcrow->IncrementN2();
330 }
331 }
332}
9350f379 333