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