]>
Commit | Line | Data |
---|---|---|
46d29e70 | 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 | $Log$ | |
dd56b762 | 18 | Revision 1.3 2000/10/15 23:40:01 cblume |
19 | Remove AliTRDconst | |
20 | ||
0e9c2ad5 | 21 | Revision 1.2 2000/10/06 16:49:46 cblume |
22 | Made Getters const | |
23 | ||
46d29e70 | 24 | Revision 1.1.2.2 2000/10/04 16:34:58 cblume |
25 | Replace include files by forward declarations | |
26 | ||
27 | Revision 1.1.2.1 2000/09/22 14:47:52 cblume | |
28 | Add the tracking code | |
29 | ||
30 | */ | |
31 | ||
32 | #include <TFile.h> | |
33 | #include <TROOT.h> | |
34 | #include <TBranch.h> | |
35 | #include <TTree.h> | |
36 | ||
37 | #include "AliRun.h" | |
38 | ||
39 | #include "AliTRD.h" | |
46d29e70 | 40 | #include "AliTRDgeometry.h" |
41 | #include "AliTRDrecPoint.h" | |
42 | #include "AliTRDcluster.h" | |
43 | #include "AliTRDtrack.h" | |
44 | #include "AliTRDtrackingSector.h" | |
45 | #include "AliTRDtimeBin.h" | |
46 | ||
47 | #include "AliTRDtracker.h" | |
48 | ||
49 | ClassImp(AliTRDtracker) | |
50 | ||
51 | //____________________________________________________________________ | |
52 | AliTRDtracker::AliTRDtracker() | |
53 | { | |
54 | // | |
55 | // Default constructor | |
56 | // | |
57 | ||
58 | fInputFile = NULL; | |
59 | fEvent = 0; | |
60 | ||
61 | fGeom = NULL; | |
62 | fNclusters = 0; | |
63 | fClusters = NULL; | |
64 | fNseeds = 0; | |
65 | fSeeds = NULL; | |
66 | fNtracks = 0; | |
67 | fTracks = NULL; | |
68 | ||
69 | } | |
70 | ||
71 | //____________________________________________________________________ | |
72 | AliTRDtracker::AliTRDtracker(const Text_t* name, const Text_t* title) | |
73 | :TNamed(name, title) | |
74 | { | |
75 | fInputFile = NULL; | |
76 | fEvent = 0; | |
77 | ||
78 | fGeom = NULL; | |
79 | fNclusters = 0; | |
80 | fClusters = new TObjArray(2000); | |
81 | fNseeds = 0; | |
82 | fSeeds = new TObjArray(20000); | |
83 | fNtracks = 0; | |
84 | fTracks = new TObjArray(10000); | |
85 | ||
86 | } | |
87 | ||
88 | ||
89 | //___________________________________________________________________ | |
90 | AliTRDtracker::~AliTRDtracker() | |
91 | { | |
92 | if (fInputFile) { | |
93 | fInputFile->Close(); | |
94 | delete fInputFile; | |
95 | } | |
96 | delete fClusters; | |
97 | delete fTracks; | |
98 | delete fSeeds; | |
99 | delete fGeom; | |
100 | } | |
101 | ||
102 | ||
103 | //_____________________________________________________________________ | |
104 | static Double_t SigmaY2trd(Double_t r, Double_t tgl, Double_t pt) | |
105 | { | |
106 | // Parametrised "expected" error of the cluster reconstruction in Y | |
107 | ||
108 | Double_t s = 1.; | |
109 | return s; | |
110 | } | |
111 | ||
112 | //_____________________________________________________________________ | |
113 | static Double_t SigmaZ2trd(Double_t r, Double_t tgl) | |
114 | { | |
115 | // Parametrised "expected" error of the cluster reconstruction in Z | |
116 | ||
117 | AliTRD *TRD = (AliTRD*) gAlice->GetDetector("TRD"); | |
118 | AliTRDgeometry *fGeom; | |
119 | fGeom = TRD->GetGeometry(); | |
120 | Double_t s, pad = fGeom->GetRowPadSize(); | |
121 | s = pad * pad /12.; | |
122 | return s; | |
123 | } | |
124 | ||
125 | //_____________________________________________________________________ | |
126 | inline Double_t f1trd(Double_t x1,Double_t y1, | |
127 | Double_t x2,Double_t y2, | |
128 | Double_t x3,Double_t y3) | |
129 | { | |
130 | // Initial approximation of the track curvature | |
131 | // Origin: Iouri Belikov, CERN, Jouri.Belikov@cern.ch | |
132 | ||
133 | Double_t d=(x2-x1)*(y3-y2)-(x3-x2)*(y2-y1); | |
134 | Double_t a=0.5*((y3-y2)*(y2*y2-y1*y1+x2*x2-x1*x1)- | |
135 | (y2-y1)*(y3*y3-y2*y2+x3*x3-x2*x2)); | |
136 | Double_t b=0.5*((x2-x1)*(y3*y3-y2*y2+x3*x3-x2*x2)- | |
137 | (x3-x2)*(y2*y2-y1*y1+x2*x2-x1*x1)); | |
138 | ||
139 | Double_t xr=TMath::Abs(d/(d*x1-a)), yr=d/(d*y1-b); | |
140 | ||
141 | return -xr*yr/sqrt(xr*xr+yr*yr); | |
142 | } | |
143 | ||
144 | //_____________________________________________________________________ | |
145 | inline Double_t f2trd(Double_t x1,Double_t y1, | |
146 | Double_t x2,Double_t y2, | |
147 | Double_t x3,Double_t y3) | |
148 | { | |
149 | // Initial approximation of the track curvature times center of curvature | |
150 | // Origin: Iouri Belikov, CERN, Jouri.Belikov@cern.ch | |
151 | ||
152 | Double_t d=(x2-x1)*(y3-y2)-(x3-x2)*(y2-y1); | |
153 | Double_t a=0.5*((y3-y2)*(y2*y2-y1*y1+x2*x2-x1*x1)- | |
154 | (y2-y1)*(y3*y3-y2*y2+x3*x3-x2*x2)); | |
155 | Double_t b=0.5*((x2-x1)*(y3*y3-y2*y2+x3*x3-x2*x2)- | |
156 | (x3-x2)*(y2*y2-y1*y1+x2*x2-x1*x1)); | |
157 | ||
158 | Double_t xr=TMath::Abs(d/(d*x1-a)), yr=d/(d*y1-b); | |
159 | ||
160 | return -a/(d*y1-b)*xr/sqrt(xr*xr+yr*yr); | |
161 | } | |
162 | ||
163 | //_____________________________________________________________________ | |
164 | inline Double_t f3trd(Double_t x1,Double_t y1, | |
165 | Double_t x2,Double_t y2, | |
166 | Double_t z1,Double_t z2) | |
167 | { | |
168 | // Initial approximation of the tangent of the track dip angle | |
169 | // Origin: Iouri Belikov, CERN, Jouri.Belikov@cern.ch | |
170 | ||
171 | return (z1 - z2)/sqrt((x1-x2)*(x1-x2)+(y1-y2)*(y1-y2)); | |
172 | } | |
173 | ||
174 | ||
175 | //___________________________________________________________________ | |
176 | ||
177 | static Int_t FindProlongation(AliTRDseed& t, AliTRDtrackingSector *sec, | |
178 | Int_t s, Int_t rf=0) | |
179 | { | |
180 | // Starting from current position on track=t this function tries | |
181 | // to extrapolate the track up to timeBin=rf and to confirm prolongation | |
182 | // if a close cluster is found. *sec is a pointer to allocated | |
183 | // array of sectors, in which the initial sector has index=s. | |
184 | ||
185 | const Int_t TIME_BINS_TO_SKIP=Int_t(0.2*sec->GetNtimeBins()); | |
186 | const Double_t MAX_CHI2=12.; | |
187 | Int_t try_again=TIME_BINS_TO_SKIP; | |
188 | ||
0e9c2ad5 | 189 | Double_t alpha=AliTRDgeometry::GetAlpha(); |
46d29e70 | 190 | |
191 | Int_t ns=Int_t(2*TMath::Pi()/alpha+0.5); | |
192 | ||
193 | for (Int_t nr=sec->GetTimeBinNumber(t.GetX())-1; nr>=rf; nr--) { | |
194 | Double_t x=sec->GetX(nr), ymax=sec->GetMaxY(nr); | |
195 | if (!t.PropagateTo(x)) { | |
196 | cerr<<"Can't propagate to x = "<<x<<endl; | |
197 | return 0; | |
198 | } | |
199 | ||
200 | AliTRDcluster *cl=0; | |
201 | UInt_t index=0; | |
202 | ||
203 | Double_t max_chi2=MAX_CHI2; | |
204 | // const AliTRDtimeBin& time_bin=sec[s][nr]; | |
205 | AliTRDtimeBin& time_bin=sec[s][nr]; | |
206 | Double_t sy2=SigmaY2trd(t.GetX(),t.GetTgl(),t.GetPt()); | |
207 | Double_t sz2=SigmaZ2trd(t.GetX(),t.GetTgl()); | |
208 | Double_t road=5.*sqrt(t.GetSigmaY2() + sy2), y=t.GetY(), z=t.GetZ(); | |
209 | ||
210 | if (road>30) { | |
211 | if (t.GetNclusters() > 4) { | |
212 | cerr<<t.GetNclusters()<<" FindProlongation: Road is too wide !\n"; | |
213 | } | |
214 | return 0; | |
215 | } | |
216 | ||
217 | if (time_bin) { | |
218 | for (Int_t i=time_bin.Find(y-road); i<time_bin; i++) { | |
219 | AliTRDcluster* c=(AliTRDcluster*)(time_bin[i]); | |
220 | if (c->GetY() > y+road) break; | |
221 | if (c->IsUsed() > 0) continue; | |
222 | ||
223 | if((c->GetZ()-z)*(c->GetZ()-z) > 25. + sz2) continue; | |
224 | ||
225 | Double_t chi2=t.GetPredictedChi2(c); | |
226 | ||
227 | if (chi2 > max_chi2) continue; | |
228 | max_chi2=chi2; | |
229 | cl=c; | |
230 | index=time_bin.GetIndex(i); | |
231 | } | |
232 | } | |
233 | if (cl) { | |
234 | ||
235 | // Float_t l=sec->GetPitch(); | |
236 | // t.SetSampledEdx(cl->fQ/l,Int_t(t)); | |
237 | ||
238 | t.Update(cl,max_chi2,index); | |
239 | ||
240 | try_again=TIME_BINS_TO_SKIP; | |
241 | } else { | |
242 | if (try_again==0) break; | |
243 | if (y > ymax) { | |
244 | cerr<<"y > ymax: "<<y<<" > "<<ymax<<endl; | |
245 | s = (s+1) % ns; | |
246 | if (!t.Rotate(alpha)) { | |
247 | cerr<<"Failed to rotate, alpha = "<<alpha<<endl; | |
248 | return 0; | |
249 | } | |
250 | } else if (y <-ymax) { | |
251 | cerr<<"y < -ymax: "<<y<<" < "<<-ymax<<endl; | |
252 | s = (s-1+ns) % ns; | |
253 | if (!t.Rotate(-alpha)) { | |
254 | cerr<<"Failed to rotate, alpha = "<<alpha<<endl; | |
255 | return 0; | |
256 | } | |
257 | } | |
258 | try_again--; | |
259 | } | |
260 | } | |
261 | ||
262 | return 1; | |
263 | } | |
264 | ||
265 | ||
266 | ||
267 | //_____________________________________________________________________________ | |
268 | void AliTRDtracker::GetEvent(const Char_t *name, Int_t nEvent) | |
269 | { | |
270 | // Opens a ROOT-file with TRD-clusters and reads in the cluster-tree | |
271 | ||
272 | ||
273 | // Connect the AliRoot file containing Geometry, Kine, and Hits | |
274 | fInputFile = (TFile*) gROOT->GetListOfFiles()->FindObject(name); | |
275 | if (!fInputFile) { | |
276 | printf("AliTRDtracker::Open -- "); | |
277 | printf("Open the ALIROOT-file %s.\n",name); | |
278 | fInputFile = new TFile(name,"UPDATE"); | |
279 | } | |
280 | else { | |
281 | printf("AliTRDtracker::Open -- "); | |
282 | printf("%s is already open.\n",name); | |
283 | } | |
284 | ||
285 | // Get AliRun object from file or create it if not on file | |
286 | //if (!gAlice) { | |
287 | gAlice = (AliRun*) fInputFile->Get("gAlice"); | |
288 | if (gAlice) { | |
289 | printf("AliTRDtracker::GetEvent -- "); | |
290 | printf("AliRun object found on file.\n"); | |
291 | } | |
292 | else { | |
293 | printf("AliTRDtracker::GetEvent -- "); | |
294 | printf("Could not find AliRun object.\n"); | |
295 | } | |
296 | //} | |
297 | ||
298 | fEvent = nEvent; | |
299 | ||
300 | // Import the Trees for the event nEvent in the file | |
301 | Int_t nparticles = gAlice->GetEvent(fEvent); | |
302 | cerr<<"nparticles = "<<nparticles<<endl; | |
303 | ||
304 | if (nparticles <= 0) { | |
305 | printf("AliTRDtracker::GetEvent -- "); | |
306 | printf("No entries in the trees for event %d.\n",fEvent); | |
307 | } | |
308 | ||
309 | AliTRD *TRD = (AliTRD*) gAlice->GetDetector("TRD"); | |
310 | fGeom = TRD->GetGeometry(); | |
311 | ||
312 | Char_t treeName[14]; | |
313 | sprintf(treeName,"TRDrecPoints%d", nEvent); | |
314 | ||
315 | TTree *tree=(TTree*)fInputFile->Get(treeName); | |
316 | TBranch *branch=tree->GetBranch("TRDrecPoints"); | |
317 | Int_t nentr = (Int_t) tree->GetEntries(); | |
318 | printf("found %d entries in %s tree.\n",nentr,treeName); | |
319 | ||
320 | for (Int_t i=0; i<nentr; i++) { | |
321 | TObjArray *ioArray = new TObjArray(400); | |
322 | branch->SetAddress(&ioArray); | |
323 | tree->GetEvent(i); | |
324 | Int_t npoints = ioArray->GetEntriesFast(); | |
325 | printf("Read %d rec. points from entry %d \n", npoints, i); | |
326 | for(Int_t j=0; j<npoints; j++) { | |
327 | AliTRDrecPoint *p=(AliTRDrecPoint*)ioArray->UncheckedAt(j); | |
328 | AliTRDcluster *c = new AliTRDcluster(p); | |
329 | fClusters->AddLast(c); | |
330 | } | |
331 | } | |
332 | ||
333 | } | |
334 | ||
335 | ||
336 | //_____________________________________________________________________________ | |
337 | void AliTRDtracker::SetUpSectors(AliTRDtrackingSector *sec) | |
338 | { | |
339 | // Fills clusters into TRD tracking_sectors | |
340 | // Note that the numbering scheme for the TRD tracking_sectors | |
341 | // differs from that of TRD sectors | |
342 | ||
dd56b762 | 343 | for (Int_t i=0; i<AliTRDgeometry::kNsect; i++) sec[i].SetUp(); |
46d29e70 | 344 | |
345 | // Sort clusters into AliTRDtimeBin's within AliTRDtrackSector's | |
346 | ||
347 | cerr<<"MakeSeeds: sorting clusters"<<endl; | |
348 | ||
349 | Int_t ncl=fClusters->GetEntriesFast(); | |
350 | UInt_t index; | |
351 | while (ncl--) { | |
352 | printf("\r %d left",ncl); | |
353 | AliTRDcluster *c=(AliTRDcluster*)fClusters->UncheckedAt(ncl); | |
354 | Int_t detector=c->GetDetector(), local_time_bin=c->GetLocalTimeBin(); | |
355 | Int_t sector=fGeom->GetSector(detector); | |
356 | ||
357 | Int_t tracking_sector=sector; | |
dd56b762 | 358 | if(sector > 0) tracking_sector = AliTRDgeometry::kNsect - sector; |
46d29e70 | 359 | |
360 | Int_t tb=sec[sector].GetTimeBin(detector,local_time_bin); | |
361 | index=ncl; | |
362 | sec[tracking_sector][tb].InsertCluster(c,index); | |
363 | } | |
364 | printf("\r\n"); | |
365 | } | |
366 | ||
367 | ||
368 | //_____________________________________________________________________________ | |
369 | void AliTRDtracker::MakeSeeds(Int_t inner, Int_t outer) | |
370 | { | |
371 | // Creates track seeds using clusters in timeBins=i1,i2 | |
372 | ||
373 | Int_t i2 = inner, i1=outer; | |
374 | ||
375 | if (!fClusters) return; | |
376 | ||
dd56b762 | 377 | AliTRDtrackingSector fTrSec[AliTRDgeometry::kNsect]; |
46d29e70 | 378 | SetUpSectors(fTrSec); |
379 | ||
380 | // find seeds | |
381 | ||
382 | Double_t x[5], c[15]; | |
dd56b762 | 383 | Int_t max_sec=AliTRDgeometry::kNsect; |
46d29e70 | 384 | |
0e9c2ad5 | 385 | Double_t alpha=AliTRDgeometry::GetAlpha(); |
386 | Double_t shift=AliTRDgeometry::GetAlpha()/2.; | |
46d29e70 | 387 | Double_t cs=cos(alpha), sn=sin(alpha); |
388 | ||
389 | Double_t x1 =fTrSec[0].GetX(i1); | |
390 | Double_t xx2=fTrSec[0].GetX(i2); | |
391 | ||
392 | for (Int_t ns=0; ns<max_sec; ns++) { | |
393 | ||
394 | Int_t nl=fTrSec[(ns-1+max_sec)%max_sec][i2]; | |
395 | Int_t nm=fTrSec[ns][i2]; | |
396 | Int_t nu=fTrSec[(ns+1)%max_sec][i2]; | |
397 | ||
398 | AliTRDtimeBin& r1=fTrSec[ns][i1]; | |
399 | ||
400 | for (Int_t is=0; is < r1; is++) { | |
401 | Double_t y1=r1[is]->GetY(), z1=r1[is]->GetZ(); | |
402 | ||
403 | for (Int_t js=0; js < nl+nm+nu; js++) { | |
404 | const AliTRDcluster *cl; | |
405 | Double_t x2, y2, z2; | |
406 | Double_t x3=0.,y3=0.; | |
407 | ||
408 | if (js<nl) { | |
409 | AliTRDtimeBin& r2=fTrSec[(ns-1+max_sec)%max_sec][i2]; | |
410 | cl=r2[js]; | |
411 | y2=cl->GetY(); z2=cl->GetZ(); | |
412 | ||
413 | x2= xx2*cs+y2*sn; | |
414 | y2=-xx2*sn+y2*cs; | |
415 | ||
416 | } else | |
417 | if (js<nl+nm) { | |
418 | AliTRDtimeBin& r2=fTrSec[ns][i2]; | |
419 | cl=r2[js-nl]; | |
420 | x2=xx2; y2=cl->GetY(); z2=cl->GetZ(); | |
421 | } else { | |
422 | AliTRDtimeBin& r2=fTrSec[(ns+1)%max_sec][i2]; | |
423 | cl=r2[js-nl-nm]; | |
424 | y2=cl->GetY(); z2=cl->GetZ(); | |
425 | ||
426 | x2=xx2*cs-y2*sn; | |
427 | y2=xx2*sn+y2*cs; | |
428 | ||
429 | } | |
430 | ||
431 | Double_t zz=z1 - z1/x1*(x1-x2); | |
432 | ||
433 | if (TMath::Abs(zz-z2)>30.) continue; | |
434 | ||
435 | Double_t d=(x2-x1)*(0.-y2)-(0.-x2)*(y2-y1); | |
436 | if (d==0.) {cerr<<"TRD MakeSeeds: Straight seed !\n"; continue;} | |
437 | ||
438 | x[0]=y1; | |
439 | x[1]=z1; | |
440 | x[2]=f1trd(x1,y1,x2,y2,x3,y3); | |
441 | ||
442 | if (TMath::Abs(x[2]) >= 0.01) continue; | |
443 | ||
444 | x[3]=f2trd(x1,y1,x2,y2,x3,y3); | |
445 | ||
446 | if (TMath::Abs(x[2]*x1-x[3]) >= 0.99999) continue; | |
447 | ||
448 | x[4]=f3trd(x1,y1,x2,y2,z1,z2); | |
449 | ||
450 | if (TMath::Abs(x[4]) > 1.2) continue; | |
451 | ||
452 | Double_t a=asin(x[3]); | |
453 | Double_t zv=z1 - x[4]/x[2]*(a+asin(x[2]*x1-x[3])); | |
454 | if (TMath::Abs(zv)>200.) continue; | |
455 | ||
456 | Double_t sy1=r1[is]->GetSigmaY2(), sz1=r1[is]->GetSigmaZ2()*12; | |
457 | Double_t sy2=cl->GetSigmaY2(), sz2=cl->GetSigmaZ2()*12; | |
458 | Double_t sy3=100*0.025, sy=0.1, sz=0.1; | |
459 | ||
460 | Double_t f20=(f1trd(x1,y1+sy,x2,y2,x3,y3)-x[2])/sy; | |
461 | Double_t f22=(f1trd(x1,y1,x2,y2+sy,x3,y3)-x[2])/sy; | |
462 | Double_t f24=(f1trd(x1,y1,x2,y2,x3,y3+sy)-x[2])/sy; | |
463 | Double_t f30=(f2trd(x1,y1+sy,x2,y2,x3,y3)-x[3])/sy; | |
464 | Double_t f32=(f2trd(x1,y1,x2,y2+sy,x3,y3)-x[3])/sy; | |
465 | Double_t f34=(f2trd(x1,y1,x2,y2,x3,y3+sy)-x[3])/sy; | |
466 | Double_t f40=(f3trd(x1,y1+sy,x2,y2,z1,z2)-x[4])/sy; | |
467 | Double_t f41=(f3trd(x1,y1,x2,y2,z1+sz,z2)-x[4])/sz; | |
468 | Double_t f42=(f3trd(x1,y1,x2,y2+sy,z1,z2)-x[4])/sy; | |
469 | Double_t f43=(f3trd(x1,y1,x2,y2,z1,z2+sz)-x[4])/sz; | |
470 | ||
471 | c[0]=sy1; | |
472 | c[1]=0.; c[2]=sz1; | |
473 | c[3]=f20*sy1; c[4]=0.; c[5]=f20*sy1*f20+f22*sy2*f22+f24*sy3*f24; | |
474 | c[6]=f30*sy1; c[7]=0.; c[8]=f30*sy1*f20+f32*sy2*f22+f34*sy3*f24; | |
475 | c[9]=f30*sy1*f30+f32*sy2*f32+f34*sy3*f34; | |
476 | c[10]=f40*sy1; c[11]=f41*sz1; c[12]=f40*sy1*f20+f42*sy2*f22; | |
477 | c[13]=f40*sy1*f30+f42*sy2*f32; | |
478 | c[14]=f40*sy1*f40+f41*sz1*f41+f42*sy2*f42+f43*sz2*f43; | |
479 | ||
480 | UInt_t index=r1.GetIndex(is); | |
481 | AliTRDseed *track=new AliTRDseed(index, x, c, x1, ns*alpha+shift); | |
482 | ||
483 | // Float_t l=fTrSec->GetPitch(); | |
484 | // track->SetSampledEdx(r1[is]->fQ/l,0); | |
485 | ||
486 | Int_t rc=FindProlongation(*track,fTrSec,ns,i2); | |
487 | ||
488 | if ((rc < 0) || (track->GetNclusters() < (i1-i2)/2) ) delete track; | |
489 | else { | |
490 | fSeeds->AddLast(track); fNseeds++; | |
491 | cerr<<"found seed "<<fNseeds<<endl; | |
492 | } | |
493 | } | |
494 | } | |
495 | } | |
496 | ||
497 | // delete[] fTrSec; | |
498 | ||
499 | fSeeds->Sort(); | |
500 | } | |
501 | ||
502 | //___________________________________________________________________ | |
503 | void AliTRDtracker::FindTracks() | |
504 | { | |
505 | if (!fClusters) return; | |
506 | ||
dd56b762 | 507 | AliTRDtrackingSector fTrSec[AliTRDgeometry::kNsect]; |
46d29e70 | 508 | SetUpSectors(fTrSec); |
509 | ||
510 | // find tracks | |
511 | ||
512 | Int_t num_of_time_bins = fTrSec[0].GetNtimeBins(); | |
513 | Int_t nseed=fSeeds->GetEntriesFast(); | |
514 | ||
515 | Int_t nSeedClusters; | |
516 | for (Int_t i=0; i<nseed; i++) { | |
517 | cerr<<"FindTracks: seed "<<i+1<<" out of "<<nseed<<endl; | |
518 | ||
519 | AliTRDseed& t=*((AliTRDseed*)fSeeds->UncheckedAt(i)); | |
520 | ||
521 | nSeedClusters = t.GetNclusters(); | |
0e9c2ad5 | 522 | Double_t alpha=AliTRDgeometry::GetAlpha(); |
46d29e70 | 523 | |
524 | if (alpha > 2.*TMath::Pi()) alpha -= 2.*TMath::Pi(); | |
525 | if (alpha < 0. ) alpha += 2.*TMath::Pi(); | |
dd56b762 | 526 | Int_t ns=Int_t(alpha/AliTRDgeometry::GetAlpha())%AliTRDgeometry::kNsect; |
46d29e70 | 527 | |
528 | if (FindProlongation(t,fTrSec,ns)) { | |
529 | cerr<<"No of clusters in the track = "<<t.GetNclusters()<<endl; | |
530 | if ((t.GetNclusters() >= Int_t(0.3*num_of_time_bins)) && | |
531 | ((t.GetNclusters()-nSeedClusters)>60)) { | |
532 | t.CookdEdx(); | |
533 | Int_t label = GetTrackLabel(t); | |
534 | t.SetLabel(label); | |
535 | AliTRDtrack* pt=&t; | |
536 | fTracks->AddLast(pt); fNtracks++; | |
537 | UseClusters(t); | |
538 | cerr<<"found track "<<fNtracks<<endl; | |
539 | } | |
540 | } | |
541 | } | |
542 | } | |
543 | ||
544 | //__________________________________________________________________ | |
545 | void AliTRDtracker::UseClusters(AliTRDseed t) { | |
546 | Int_t ncl=t.GetNclusters(); | |
547 | for (Int_t i=0; i<ncl; i++) { | |
548 | Int_t index = t.GetClusterIndex(i); | |
549 | AliTRDcluster *c=(AliTRDcluster*)fClusters->UncheckedAt(index); | |
550 | c->Use(); | |
551 | } | |
552 | } | |
553 | ||
554 | //__________________________________________________________________ | |
555 | Int_t AliTRDtracker::GetTrackLabel(AliTRDseed t) { | |
556 | ||
557 | Int_t label=123456789, index, i, j; | |
558 | Int_t ncl=t.GetNclusters(); | |
559 | const Int_t range=300; | |
560 | Bool_t label_added; | |
561 | ||
562 | Int_t s[range][2]; | |
563 | for (i=0; i<range; i++) { | |
564 | s[i][0]=-1; | |
565 | s[i][1]=0; | |
566 | } | |
567 | ||
568 | Int_t t0,t1,t2; | |
569 | for (i=0; i<ncl; i++) { | |
570 | index=t.GetClusterIndex(i); | |
571 | AliTRDcluster *c=(AliTRDcluster*)fClusters->UncheckedAt(index); | |
572 | t0=c->GetTrackIndex(0); | |
573 | t1=c->GetTrackIndex(1); | |
574 | t2=c->GetTrackIndex(2); | |
575 | } | |
576 | ||
577 | for (i=0; i<ncl; i++) { | |
578 | index=t.GetClusterIndex(i); | |
579 | AliTRDcluster *c=(AliTRDcluster*)fClusters->UncheckedAt(index); | |
580 | for (Int_t k=0; k<3; k++) { | |
581 | label=c->GetTrackIndex(k); | |
582 | label_added=false; j=0; | |
583 | if (label >= 0) { | |
584 | while ( (!label_added) && ( j < range ) ) { | |
585 | if (s[j][0]==label || s[j][1]==0) { | |
586 | s[j][0]=label; | |
587 | s[j][1]=s[j][1]+1; | |
588 | label_added=true; | |
589 | } | |
590 | j++; | |
591 | } | |
592 | } | |
593 | } | |
594 | } | |
595 | ||
596 | ||
597 | Int_t max=0; | |
598 | label = -123456789; | |
599 | ||
600 | for (i=0; i<range; i++) { | |
601 | if (s[i][1]>max) { | |
602 | max=s[i][1]; label=s[i][0]; | |
603 | } | |
604 | } | |
605 | if(max > ncl/2) return label; | |
606 | else return -1; | |
607 | } | |
608 | ||
609 | //___________________________________________________________________ | |
610 | ||
611 | Int_t AliTRDtracker::WriteTracks() { | |
612 | ||
613 | TDirectory *savedir=gDirectory; | |
614 | ||
615 | TFile *out=TFile::Open("AliTRDtracks.root","RECREATE"); | |
616 | ||
617 | TTree tracktree("TreeT","Tree with TRD tracks"); | |
618 | ||
619 | AliTRDtrack *iotrack=0; | |
620 | tracktree.Branch("tracks","AliTRDtrack",&iotrack,32000,0); | |
621 | ||
622 | Int_t ntracks=fTracks->GetEntriesFast(); | |
623 | ||
624 | for (Int_t i=0; i<ntracks; i++) { | |
625 | AliTRDtrack *pt=(AliTRDtrack*)fTracks->UncheckedAt(i); | |
626 | iotrack=pt; | |
627 | tracktree.Fill(); | |
628 | cerr<<"WriteTracks: put track "<<i<<" in the tree"<<endl; | |
629 | } | |
630 | ||
631 | tracktree.Write(); | |
632 | out->Close(); | |
633 | ||
634 | savedir->cd(); | |
635 | ||
636 | cerr<<"WriteTracks: done"<<endl; | |
637 | return 0; | |
638 | } | |
639 | ||
640 | ||
641 | ||
642 | //_____________________________________________________________________________ | |
dd56b762 | 643 | void AliTRDtracker::ReadClusters(TObjArray *array, const Char_t *filename |
644 | , Int_t nEvent, Int_t option) | |
46d29e70 | 645 | { |
646 | // | |
647 | // Reads AliTRDclusters (option >= 0) or AliTRDrecPoints (option < 0) | |
648 | // from the file. The names of the cluster tree and branches | |
649 | // should match the ones used in AliTRDclusterizer::WriteClusters() | |
650 | // | |
651 | ||
652 | TDirectory *savedir=gDirectory; | |
653 | ||
654 | TFile *file = TFile::Open(filename); | |
655 | if (!file->IsOpen()) {printf("Can't open file %s !\n",filename); return;} | |
656 | ||
657 | Char_t treeName[14]; | |
658 | sprintf(treeName,"TRDrecPoints%d", nEvent); | |
659 | ||
660 | TTree *tree=(TTree*)file->Get(treeName); | |
661 | TBranch *branch=tree->GetBranch("TRDrecPoints"); | |
662 | Int_t nentr = (Int_t) tree->GetEntries(); | |
663 | printf("found %d entries in %s tree.\n",nentr,treeName); | |
664 | ||
665 | for (Int_t i=0; i<nentr; i++) { | |
666 | TObjArray *ioArray = new TObjArray(400); | |
667 | branch->SetAddress(&ioArray); | |
668 | tree->GetEvent(i); | |
669 | Int_t npoints = ioArray->GetEntriesFast(); | |
670 | printf("Read %d rec. points from entry %d \n", npoints, i); | |
671 | for(Int_t j=0; j<npoints; j++) { | |
672 | AliTRDrecPoint *p=(AliTRDrecPoint*)ioArray->UncheckedAt(j); | |
673 | AliTRDcluster *c = new AliTRDcluster(p); | |
674 | if( option >= 0) array->AddLast(c); | |
675 | else array->AddLast(p); | |
676 | } | |
677 | } | |
678 | ||
679 | file->Close(); | |
680 | savedir->cd(); | |
681 | ||
682 | } | |
683 | ||
684 | ||
685 | ||
686 |