1 /**************************************************************************
2 * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
4 * Author: The ALICE Off-line Project. *
5 * Contributors are mentioned in the code where appropriate. *
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 **************************************************************************/
18 ///////////////////////////////////////////////////////////////////////////////
20 // The standard TRD tracker //
22 ///////////////////////////////////////////////////////////////////////////////
24 #include <Riostream.h>
28 #include <TObjArray.h>
30 #include "AliTRDgeometry.h"
31 #include "AliTRDparameter.h"
32 #include "AliTRDgeometryDetail.h"
33 #include "AliTRDgeometryHole.h"
34 #include "AliTRDcluster.h"
35 #include "AliTRDtrack.h"
36 #include "AliTRDPartID.h"
37 #include "../TPC/AliTPCtrack.h"
39 #include "AliTRDtracker.h"
41 ClassImp(AliTRDtracker)
43 const Float_t AliTRDtracker::fgkSeedDepth = 0.5;
44 const Float_t AliTRDtracker::fgkSeedStep = 0.10;
45 const Float_t AliTRDtracker::fgkSeedGap = 0.25;
47 const Float_t AliTRDtracker::fgkMaxSeedDeltaZ12 = 40.;
48 const Float_t AliTRDtracker::fgkMaxSeedDeltaZ = 25.;
49 const Float_t AliTRDtracker::fgkMaxSeedC = 0.0052;
50 const Float_t AliTRDtracker::fgkMaxSeedTan = 1.2;
51 const Float_t AliTRDtracker::fgkMaxSeedVertexZ = 150.;
53 const Double_t AliTRDtracker::fgkSeedErrorSY = 0.2;
54 const Double_t AliTRDtracker::fgkSeedErrorSY3 = 2.5;
55 const Double_t AliTRDtracker::fgkSeedErrorSZ = 0.1;
57 const Float_t AliTRDtracker::fgkMinClustersInSeed = 0.7;
59 const Float_t AliTRDtracker::fgkMinClustersInTrack = 0.5;
60 const Float_t AliTRDtracker::fgkMinFractionOfFoundClusters = 0.8;
62 const Float_t AliTRDtracker::fgkSkipDepth = 0.3;
63 const Float_t AliTRDtracker::fgkLabelFraction = 0.8;
64 const Float_t AliTRDtracker::fgkWideRoad = 20.;
66 const Double_t AliTRDtracker::fgkMaxChi2 = 12.;
68 const Int_t AliTRDtracker::fgkFirstPlane = 5;
69 const Int_t AliTRDtracker::fgkLastPlane = 17;
72 //____________________________________________________________________
73 AliTRDtracker::AliTRDtracker():AliTracker(),
90 for(Int_t i=0;i<kTrackingSectors;i++) fTrSec[i]=0;
91 for(Int_t j=0;j<5;j++)
92 for(Int_t k=0;k<18;k++) fHoles[j][k]=kFALSE;
94 //____________________________________________________________________
95 AliTRDtracker::AliTRDtracker(const TFile *geomfile):AliTracker()
101 //Float_t fTzero = 0;
103 fAddTRDseeds = kFALSE;
107 TDirectory *savedir=gDirectory;
108 TFile *in=(TFile*)geomfile;
110 printf("AliTRDtracker::AliTRDtracker(): geometry file is not open!\n");
111 printf(" DETAIL TRD geometry and DEFAULT TRD parameter will be used\n");
116 fGeom = (AliTRDgeometry*) in->Get("TRDgeometry");
117 fPar = (AliTRDparameter*) in->Get("TRDparameter");
122 // fTzero = geo->GetT0();
123 printf("Found geometry version %d on file \n", fGeom->IsVersion());
126 printf("AliTRDtracker::AliTRDtracker(): can't find TRD geometry!\n");
127 //printf("The DETAIL TRD geometry will be used\n");
128 //fGeom = new AliTRDgeometryDetail();
129 fGeom = new AliTRDgeometryHole();
130 fGeom->SetPHOShole();
131 fGeom->SetRICHhole();
135 printf("AliTRDtracker::AliTRDtracker(): can't find TRD parameter!\n");
136 printf("The DEFAULT TRD parameter will be used\n");
137 fPar = new AliTRDparameter();
144 // fGeom->SetT0(fTzero);
147 fClusters = new TObjArray(2000);
149 fSeeds = new TObjArray(2000);
151 fTracks = new TObjArray(1000);
153 for(Int_t geomS = 0; geomS < kTrackingSectors; geomS++) {
154 Int_t trS = CookSectorIndex(geomS);
155 fTrSec[trS] = new AliTRDtrackingSector(fGeom, geomS, fPar);
156 for (Int_t icham=0;icham<AliTRDgeometry::kNcham; icham++){
157 fHoles[icham][trS]=fGeom->IsHole(0,icham,geomS);
161 Float_t tiltAngle = TMath::Abs(fPar->GetTiltingAngle());
162 if(tiltAngle < 0.1) {
169 if(fNoTilt && (tiltAngle > 0.1)) fSY2corr = fSY2corr + tiltAngle * 0.05;
172 // calculate max gap on track
174 Double_t dxAmp = (Double_t) fGeom->CamHght(); // Amplification region
175 Double_t dxDrift = (Double_t) fGeom->CdrHght(); // Drift region
177 Double_t dx = (Double_t) fPar->GetTimeBinSize();
178 Int_t tbAmp = fPar->GetTimeBefore();
179 Int_t maxAmp = (Int_t) ((dxAmp+0.000001)/dx);
180 if(kTRUE) maxAmp = 0; // intentional until we change the parameter class
181 Int_t tbDrift = fPar->GetTimeMax();
182 Int_t maxDrift = (Int_t) ((dxDrift+0.000001)/dx);
184 tbDrift = TMath::Min(tbDrift,maxDrift);
185 tbAmp = TMath::Min(tbAmp,maxAmp);
187 fTimeBinsPerPlane = tbAmp + tbDrift;
188 fMaxGap = (Int_t) (fTimeBinsPerPlane * fGeom->Nplan() * fgkSkipDepth);
193 // Barrel Tracks [SR, 03.04.2003]
203 //___________________________________________________________________
204 AliTRDtracker::~AliTRDtracker()
207 // Destructor of AliTRDtracker
225 for(Int_t geomS = 0; geomS < kTrackingSectors; geomS++) {
226 delete fTrSec[geomS];
230 //_____________________________________________________________________
232 void AliTRDtracker::SetBarrelTree(const char *mode) {
237 if (!IsStoringBarrel()) return;
239 TDirectory *sav = gDirectory;
240 if (!fBarrelFile) fBarrelFile = new TFile("AliBarrelTracks.root", "UPDATE");
243 sprintf(buff, "BarrelTRD_%d_%s", GetEventNumber(), mode);
246 fBarrelTree = new TTree(buff, "Barrel TPC tracks");
248 Int_t nRefs = fgkLastPlane - fgkFirstPlane + 1;
250 if (!fBarrelArray) fBarrelArray = new TClonesArray("AliBarrelTrack", nRefs);
251 for(Int_t i=0; i<nRefs; i++) new((*fBarrelArray)[i]) AliBarrelTrack();
253 fBarrelTree->Branch("tracks", &fBarrelArray);
257 //_____________________________________________________________________
259 void AliTRDtracker::StoreBarrelTrack(AliTRDtrack *ps, Int_t refPlane, Int_t isIn) {
264 if (!IsStoringBarrel()) return;
266 static Int_t nClusters;
268 static Double_t chi2;
270 static Bool_t wasLast = kTRUE;
272 Int_t newClusters, newWrong;
277 fBarrelArray->Clear();
278 nClusters = nWrong = 0;
284 fBarrelTrack = (AliBarrelTrack*)(*fBarrelArray)[index++];
285 ps->GetBarrelTrack(fBarrelTrack);
287 newClusters = ps->GetNumberOfClusters() - nClusters;
288 newWrong = ps->GetNWrong() - nWrong;
289 newChi2 = ps->GetChi2() - chi2;
291 nClusters = ps->GetNumberOfClusters();
292 nWrong = ps->GetNWrong();
293 chi2 = ps->GetChi2();
295 if (refPlane != fgkLastPlane) {
296 fBarrelTrack->SetNClusters(newClusters, newChi2);
297 fBarrelTrack->SetNWrongClusters(newWrong);
302 fBarrelTrack->SetRefPlane(refPlane, isIn);
305 //_____________________________________________________________________
307 Bool_t AliTRDtracker::AdjustSector(AliTRDtrack *track) {
309 // Rotates the track when necessary
312 Double_t alpha = AliTRDgeometry::GetAlpha();
313 Double_t y = track->GetY();
314 Double_t ymax = track->GetX()*TMath::Tan(0.5*alpha);
316 //Int_t ns = AliTRDgeometry::kNsect;
317 //Int_t s=Int_t(track->GetAlpha()/alpha)%ns;
321 if (!track->Rotate(alpha)) return kFALSE;
322 } else if (y <-ymax) {
324 if (!track->Rotate(-alpha)) return kFALSE;
330 //_____________________________________________________________________
331 inline Double_t f1trd(Double_t x1,Double_t y1,
332 Double_t x2,Double_t y2,
333 Double_t x3,Double_t y3)
336 // Initial approximation of the track curvature
338 Double_t d=(x2-x1)*(y3-y2)-(x3-x2)*(y2-y1);
339 Double_t a=0.5*((y3-y2)*(y2*y2-y1*y1+x2*x2-x1*x1)-
340 (y2-y1)*(y3*y3-y2*y2+x3*x3-x2*x2));
341 Double_t b=0.5*((x2-x1)*(y3*y3-y2*y2+x3*x3-x2*x2)-
342 (x3-x2)*(y2*y2-y1*y1+x2*x2-x1*x1));
344 Double_t xr=TMath::Abs(d/(d*x1-a)), yr=d/(d*y1-b);
346 return -xr*yr/sqrt(xr*xr+yr*yr);
349 //_____________________________________________________________________
350 inline Double_t f2trd(Double_t x1,Double_t y1,
351 Double_t x2,Double_t y2,
352 Double_t x3,Double_t y3)
355 // Initial approximation of the track curvature times X coordinate
356 // of the center of curvature
359 Double_t d=(x2-x1)*(y3-y2)-(x3-x2)*(y2-y1);
360 Double_t a=0.5*((y3-y2)*(y2*y2-y1*y1+x2*x2-x1*x1)-
361 (y2-y1)*(y3*y3-y2*y2+x3*x3-x2*x2));
362 Double_t b=0.5*((x2-x1)*(y3*y3-y2*y2+x3*x3-x2*x2)-
363 (x3-x2)*(y2*y2-y1*y1+x2*x2-x1*x1));
365 Double_t xr=TMath::Abs(d/(d*x1-a)), yr=d/(d*y1-b);
367 return -a/(d*y1-b)*xr/sqrt(xr*xr+yr*yr);
370 //_____________________________________________________________________
371 inline Double_t f3trd(Double_t x1,Double_t y1,
372 Double_t x2,Double_t y2,
373 Double_t z1,Double_t z2)
376 // Initial approximation of the tangent of the track dip angle
379 return (z1 - z2)/sqrt((x1-x2)*(x1-x2)+(y1-y2)*(y1-y2));
383 AliTRDcluster * AliTRDtracker::GetCluster(AliTRDtrack * track, Int_t plane, Int_t timebin){
385 //try to find cluster in the backup list
387 AliTRDcluster * cl =0;
388 UInt_t *indexes = track->GetBackupIndexes();
389 for (UInt_t i=0;i<kMaxTimeBinIndex;i++){
390 if (indexes[i]==0) break;
391 AliTRDcluster * cli = (AliTRDcluster*)fClusters->UncheckedAt(indexes[i]);
393 if (cli->GetLocalTimeBin()!=timebin) continue;
394 Int_t iplane = fGeom->GetPlane(cli->GetDetector());
404 Int_t AliTRDtracker::GetLastPlane(AliTRDtrack * track){
406 //return last updated plane
408 UInt_t *indexes = track->GetBackupIndexes();
409 for (UInt_t i=0;i<kMaxTimeBinIndex;i++){
410 AliTRDcluster * cli = (AliTRDcluster*)fClusters->UncheckedAt(indexes[i]);
412 Int_t iplane = fGeom->GetPlane(cli->GetDetector());
413 if (iplane>lastplane) {
419 //___________________________________________________________________
420 Int_t AliTRDtracker::Clusters2Tracks(const TFile *inp, TFile *out)
423 // Finds tracks within the TRD. File <inp> is expected to contain seeds
424 // at the outer part of the TRD. If <inp> is NULL, the seeds
425 // are found within the TRD if fAddTRDseeds is TRUE.
426 // The tracks are propagated to the innermost time bin
427 // of the TRD and stored in file <out>.
432 TDirectory *savedir=gDirectory;
436 if (!out->IsOpen()) {
437 cerr<<"AliTRDtracker::Clusters2Tracks(): output file is not open !\n";
441 sprintf(tname,"seedTRDtoTPC_%d",GetEventNumber());
442 TTree tpcTree(tname,"Tree with seeds from TRD at outer TPC pad row");
443 AliTPCtrack *iotrack=0;
444 tpcTree.Branch("tracks","AliTPCtrack",&iotrack,32000,0);
446 sprintf(tname,"TreeT%d_TRD",GetEventNumber());
447 TTree trdTree(tname,"TRD tracks at inner TRD time bin");
448 AliTRDtrack *iotrackTRD=0;
449 trdTree.Branch("tracks","AliTRDtrack",&iotrackTRD,32000,0);
451 Int_t timeBins = fTrSec[0]->GetNumberOfTimeBins();
452 Float_t foundMin = fgkMinClustersInTrack * timeBins;
455 TFile *in=(TFile*)inp;
458 "AliTRDtracker::Clusters2Tracks(): file with seeds is not open !\n";
459 cerr<<" ... going for seeds finding inside the TRD\n";
463 sprintf(tname,"TRDb_%d",GetEventNumber());
464 TTree *seedTree=(TTree*)in->Get(tname);
466 cerr<<"AliTRDtracker::Clusters2Tracks(): ";
467 cerr<<"can't get a tree with track seeds !\n";
470 AliTRDtrack *seed=new AliTRDtrack;
471 seedTree->SetBranchAddress("tracks",&seed);
473 Int_t n=(Int_t)seedTree->GetEntries();
474 for (Int_t i=0; i<n; i++) {
475 seedTree->GetEvent(i);
476 seed->ResetCovariance();
477 AliTRDtrack *tr = new AliTRDtrack(*seed,seed->GetAlpha());
489 // find tracks from loaded seeds
491 Int_t nseed=fSeeds->GetEntriesFast();
493 Int_t innerTB = fTrSec[0]->GetInnerTimeBin();
495 for (i=0; i<nseed; i++) {
496 AliTRDtrack *pt=(AliTRDtrack*)fSeeds->UncheckedAt(i), &t=*pt;
497 FollowProlongation(t, innerTB);
498 if (t.GetNumberOfClusters() >= foundMin) {
500 CookLabel(pt, 1-fgkLabelFraction);
506 // cout<<found<<'\r';
508 if(PropagateToTPC(t)) {
509 AliTPCtrack *tpc = new AliTPCtrack(*pt,pt->GetAlpha());
514 delete fSeeds->RemoveAt(i);
518 cout<<"Number of loaded seeds: "<<nseed<<endl;
519 cout<<"Number of found tracks from loaded seeds: "<<found<<endl;
521 // after tracks from loaded seeds are found and the corresponding
522 // clusters are used, look for additional seeds from TRD
525 // Find tracks for the seeds in the TRD
526 Int_t timeBins = fTrSec[0]->GetNumberOfTimeBins();
528 Int_t nSteps = (Int_t) (fgkSeedDepth / fgkSeedStep);
529 Int_t gap = (Int_t) (timeBins * fgkSeedGap);
530 Int_t step = (Int_t) (timeBins * fgkSeedStep);
532 // make a first turn with tight cut on initial curvature
533 for(Int_t turn = 1; turn <= 2; turn++) {
535 nSteps = (Int_t) (fgkSeedDepth / (3*fgkSeedStep));
536 step = (Int_t) (timeBins * (3*fgkSeedStep));
538 for(Int_t i=0; i<nSteps; i++) {
539 Int_t outer=timeBins-1-i*step;
540 Int_t inner=outer-gap;
542 nseed=fSeeds->GetEntriesFast();
544 MakeSeeds(inner, outer, turn);
546 nseed=fSeeds->GetEntriesFast();
547 printf("\n turn %d, step %d: number of seeds for TRD inward %d\n",
550 for (Int_t i=0; i<nseed; i++) {
551 AliTRDtrack *pt=(AliTRDtrack*)fSeeds->UncheckedAt(i), &t=*pt;
552 FollowProlongation(t,innerTB);
553 if (t.GetNumberOfClusters() >= foundMin) {
555 CookLabel(pt, 1-fgkLabelFraction);
558 // cout<<found<<'\r';
561 if(PropagateToTPC(t)) {
562 AliTPCtrack *tpc = new AliTPCtrack(*pt,pt->GetAlpha());
568 delete fSeeds->RemoveAt(i);
577 cout<<"Total number of found tracks: "<<found<<endl;
586 //___________________________________________________________________
587 Int_t AliTRDtracker::Clusters2Tracks(AliESD* event)
590 // Finds tracks within the TRD. The ESD event is expected to contain seeds
591 // at the outer part of the TRD. The seeds
592 // are found within the TRD if fAddTRDseeds is TRUE.
593 // The tracks are propagated to the innermost time bin
594 // of the TRD and the ESD event is updated
597 Int_t timeBins = fTrSec[0]->GetNumberOfTimeBins();
598 Float_t foundMin = fgkMinClustersInTrack * timeBins;
601 Int_t innerTB = fTrSec[0]->GetInnerTimeBin();
603 Int_t n = event->GetNumberOfTracks();
604 for (Int_t i=0; i<n; i++) {
605 AliESDtrack* seed=event->GetTrack(i);
606 ULong_t status=seed->GetStatus();
607 if ( (status & AliESDtrack::kTRDout ) == 0 ) continue;
608 if ( (status & AliESDtrack::kTRDin) != 0 ) continue;
611 AliTRDtrack* seed2 = new AliTRDtrack(*seed);
612 //seed2->ResetCovariance();
613 AliTRDtrack *pt = new AliTRDtrack(*seed2,seed2->GetAlpha());
615 FollowProlongation(t, innerTB);
616 if (t.GetNumberOfClusters() >= foundMin) {
618 CookLabel(pt, 1-fgkLabelFraction);
622 // cout<<found<<'\r';
624 if(PropagateToTPC(t)) {
625 seed->UpdateTrackParams(pt, AliESDtrack::kTRDin);
631 cout<<"Number of loaded seeds: "<<nseed<<endl;
632 cout<<"Number of found tracks from loaded seeds: "<<found<<endl;
634 // after tracks from loaded seeds are found and the corresponding
635 // clusters are used, look for additional seeds from TRD
638 // Find tracks for the seeds in the TRD
639 Int_t timeBins = fTrSec[0]->GetNumberOfTimeBins();
641 Int_t nSteps = (Int_t) (fgkSeedDepth / fgkSeedStep);
642 Int_t gap = (Int_t) (timeBins * fgkSeedGap);
643 Int_t step = (Int_t) (timeBins * fgkSeedStep);
645 // make a first turn with tight cut on initial curvature
646 for(Int_t turn = 1; turn <= 2; turn++) {
648 nSteps = (Int_t) (fgkSeedDepth / (3*fgkSeedStep));
649 step = (Int_t) (timeBins * (3*fgkSeedStep));
651 for(Int_t i=0; i<nSteps; i++) {
652 Int_t outer=timeBins-1-i*step;
653 Int_t inner=outer-gap;
655 nseed=fSeeds->GetEntriesFast();
657 MakeSeeds(inner, outer, turn);
659 nseed=fSeeds->GetEntriesFast();
660 printf("\n turn %d, step %d: number of seeds for TRD inward %d\n",
663 for (Int_t i=0; i<nseed; i++) {
664 AliTRDtrack *pt=(AliTRDtrack*)fSeeds->UncheckedAt(i), &t=*pt;
665 FollowProlongation(t,innerTB);
666 if (t.GetNumberOfClusters() >= foundMin) {
668 CookLabel(pt, 1-fgkLabelFraction);
671 // cout<<found<<'\r';
672 if(PropagateToTPC(t)) {
674 track.UpdateTrackParams(pt,AliESDtrack::kTRDin);
675 event->AddTrack(&track);
678 delete fSeeds->RemoveAt(i);
685 cout<<"Total number of found tracks: "<<found<<endl;
692 //_____________________________________________________________________________
693 Int_t AliTRDtracker::PropagateBack(const TFile *inp, TFile *out) {
695 // Reads seeds from file <inp>. The seeds are AliTPCtrack's found and
696 // backpropagated by the TPC tracker. Each seed is first propagated
697 // to the TRD, and then its prolongation is searched in the TRD.
698 // If sufficiently long continuation of the track is found in the TRD
699 // the track is updated, otherwise it's stored as originaly defined
700 // by the TPC tracker.
705 TDirectory *savedir=gDirectory;
707 TFile *in=(TFile*)inp;
710 cerr<<"AliTRDtracker::PropagateBack(): ";
711 cerr<<"file with back propagated TPC tracks is not open !\n";
715 if (!out->IsOpen()) {
716 cerr<<"AliTRDtracker::PropagateBack(): ";
717 cerr<<"file for back propagated TRD tracks is not open !\n";
723 sprintf(tname,"seedsTPCtoTRD_%d",GetEventNumber());
724 TTree *seedTree=(TTree*)in->Get(tname);
726 cerr<<"AliTRDtracker::PropagateBack(): ";
727 cerr<<"can't get a tree with seeds from TPC !\n";
728 cerr<<"check if your version of TPC tracker creates tree "<<tname<<"\n";
732 AliTPCtrack *seed=new AliTPCtrack;
733 seedTree->SetBranchAddress("tracks",&seed);
735 Int_t n=(Int_t)seedTree->GetEntries();
736 for (Int_t i=0; i<n; i++) {
737 seedTree->GetEvent(i);
738 Int_t lbl = seed->GetLabel();
739 AliTRDtrack *tr = new AliTRDtrack(*seed,seed->GetAlpha());
740 tr->SetSeedLabel(lbl);
750 AliTPCtrack *otrack=0;
752 sprintf(tname,"seedsTRDtoTOF1_%d",GetEventNumber());
753 TTree tofTree1(tname,"Tracks back propagated through TPC and TRD");
754 tofTree1.Branch("tracks","AliTPCtrack",&otrack,32000,0);
756 sprintf(tname,"seedsTRDtoTOF2_%d",GetEventNumber());
757 TTree tofTree2(tname,"Tracks back propagated through TPC and TRD");
758 tofTree2.Branch("tracks","AliTPCtrack",&otrack,32000,0);
760 sprintf(tname,"seedsTRDtoPHOS_%d",GetEventNumber());
761 TTree phosTree(tname,"Tracks back propagated through TPC and TRD");
762 phosTree.Branch("tracks","AliTPCtrack",&otrack,32000,0);
764 sprintf(tname,"seedsTRDtoRICH_%d",GetEventNumber());
765 TTree richTree(tname,"Tracks back propagated through TPC and TRD");
766 richTree.Branch("tracks","AliTPCtrack",&otrack,32000,0);
768 sprintf(tname,"TRDb_%d",GetEventNumber());
769 TTree trdTree(tname,"Back propagated TRD tracks at outer TRD time bin");
770 AliTRDtrack *otrackTRD=0;
771 trdTree.Branch("tracks","AliTRDtrack",&otrackTRD,32000,0);
773 if (IsStoringBarrel()) SetBarrelTree("back");
777 Int_t nseed=fSeeds->GetEntriesFast();
779 // Float_t foundMin = fgkMinClustersInTrack * fTimeBinsPerPlane * fGeom->Nplan();
780 Float_t foundMin = 40;
782 Int_t outermostTB = fTrSec[0]->GetOuterTimeBin();
784 for (Int_t i=0; i<nseed; i++) {
786 AliTRDtrack *ps=(AliTRDtrack*)fSeeds->UncheckedAt(i), &s=*ps;
787 Int_t expectedClr = FollowBackProlongation(s);
789 if (IsStoringBarrel()) {
790 StoreBarrelTrack(ps, fgkLastPlane, kTrackBack);
794 Int_t foundClr = s.GetNumberOfClusters();
795 Int_t lastTB = fTrSec[0]->GetLayerNumber(s.GetX());
797 // printf("seed %d: found %d out of %d expected clusters, Min is %f\n",
798 // i, foundClr, expectedClr, foundMin);
800 if (foundClr >= foundMin) {
803 CookLabel(ps, 1-fgkLabelFraction);
807 // Propagate to outer reference plane [SR, GSI, 18.02.2003]
808 ps->PropagateTo(364.8);
812 // cout<<found<<'\r';
815 if(((expectedClr < 10) && (lastTB == outermostTB)) ||
816 ((expectedClr >= 10) &&
817 (((Float_t) foundClr) / ((Float_t) expectedClr) >=
818 fgkMinFractionOfFoundClusters) && (lastTB == outermostTB))) {
820 Double_t xTOF = 375.5;
822 if(PropagateToOuterPlane(s,xTOF)) {
823 AliTPCtrack *pt = new AliTPCtrack(*ps,ps->GetAlpha());
830 if(PropagateToOuterPlane(s,xTOF)) {
831 AliTPCtrack *pt = new AliTPCtrack(*ps,ps->GetAlpha());
836 Double_t xPHOS = 460.;
838 if(PropagateToOuterPlane(s,xPHOS)) {
839 AliTPCtrack *pt = new AliTPCtrack(*ps,ps->GetAlpha());
844 Double_t xRICH = 490+1.267;
846 if(PropagateToOuterPlane(s,xRICH)) {
847 AliTPCtrack *pt = new AliTPCtrack(*ps,ps->GetAlpha());
866 if (IsStoringBarrel()) { // [SR, 03.04.2003]
868 fBarrelTree->Write();
869 fBarrelFile->Flush();
873 cerr<<"Number of seeds: "<<nseed<<endl;
874 cerr<<"Number of back propagated TRD tracks: "<<found<<endl;
882 //_____________________________________________________________________________
883 Int_t AliTRDtracker::PropagateBack(AliESD* event) {
885 // Gets seeds from ESD event. The seeds are AliTPCtrack's found and
886 // backpropagated by the TPC tracker. Each seed is first propagated
887 // to the TRD, and then its prolongation is searched in the TRD.
888 // If sufficiently long continuation of the track is found in the TRD
889 // the track is updated, otherwise it's stored as originaly defined
890 // by the TPC tracker.
894 Float_t foundMin = 40;
896 Int_t n = event->GetNumberOfTracks();
897 for (Int_t i=0; i<n; i++) {
898 AliESDtrack* seed=event->GetTrack(i);
899 ULong_t status=seed->GetStatus();
900 if ( (status & AliESDtrack::kTPCout ) == 0 ) continue;
901 if ( (status & AliESDtrack::kTRDout) != 0 ) continue;
903 Int_t lbl = seed->GetLabel();
904 AliTRDtrack *track = new AliTRDtrack(*seed);
905 track->SetSeedLabel(lbl);
908 Int_t expectedClr = FollowBackProlongation(*track);
909 if (track->GetNumberOfClusters()<expectedClr/3){
910 AliTRDtrack *track1 = new AliTRDtrack(*seed);
911 track1->SetSeedLabel(lbl);
912 FollowBackProlongation(*track1);
913 AliTRDtrack *track2= new AliTRDtrack(*seed);
914 track->SetSeedLabel(lbl);
915 FollowBackProlongation(*track2);
920 Int_t foundClr = track->GetNumberOfClusters();
921 if (foundClr >= foundMin) {
924 // CookLabel(track, 1-fgkLabelFraction);
928 // Propagate to outer reference plane [SR, GSI, 18.02.2003]
929 // track->PropagateTo(364.8); why?
931 //seed->UpdateTrackParams(track, AliESDtrack::kTRDout);
935 //Propagation to the TOF (I.Belikov)
937 if (track->GetStop()==kFALSE){
938 Double_t xTOF = 375.5;
939 PropagateToOuterPlane(*track,xTOF);
942 Double_t c2=track->GetC()*xtof - track->GetEta();
943 if (TMath::Abs(c2)>=0.9999999){
948 Double_t ymax=xtof*TMath::Tan(0.5*AliTRDgeometry::GetAlpha());
949 Double_t y=track->GetYat(xtof);
951 if (!track->Rotate(AliTRDgeometry::GetAlpha())) {
955 } else if (y <-ymax) {
956 if (!track->Rotate(-AliTRDgeometry::GetAlpha())) {
962 if (track->PropagateTo(xtof)) {
963 seed->UpdateTrackParams(track, AliESDtrack::kTRDout);
964 if (track->GetNumberOfClusters()>foundMin) found++;
967 if (track->GetNumberOfClusters()>15&&track->GetNumberOfClusters()>0.5*expectedClr){
968 seed->UpdateTrackParams(track, AliESDtrack::kTRDout);
969 seed->UpdateTrackParams(track, AliESDtrack::kTRDStop);
976 //End of propagation to the TOF
977 //if (foundClr>foundMin)
978 // seed->UpdateTrackParams(track, AliESDtrack::kTRDout);
983 cerr<<"Number of seeds: "<<fNseeds<<endl;
984 cerr<<"Number of back propagated TRD tracks: "<<found<<endl;
986 fSeeds->Clear(); fNseeds=0;
992 //_____________________________________________________________________________
993 Int_t AliTRDtracker::RefitInward(AliESD* event)
996 // Refits tracks within the TRD. The ESD event is expected to contain seeds
997 // at the outer part of the TRD.
998 // The tracks are propagated to the innermost time bin
999 // of the TRD and the ESD event is updated
1000 // Origin: Thomas KUHR (Thomas.Kuhr@cern.ch)
1003 Int_t timeBins = fTrSec[0]->GetNumberOfTimeBins();
1004 Float_t foundMin = fgkMinClustersInTrack * timeBins;
1007 Int_t innerTB = fTrSec[0]->GetInnerTimeBin();
1009 Int_t n = event->GetNumberOfTracks();
1010 for (Int_t i=0; i<n; i++) {
1011 AliESDtrack* seed=event->GetTrack(i);
1012 ULong_t status=seed->GetStatus();
1013 if ( (status & AliESDtrack::kTRDout ) == 0 ) continue;
1014 if ( (status & AliESDtrack::kTRDin) != 0 ) continue;
1017 AliTRDtrack* seed2 = new AliTRDtrack(*seed);
1018 seed2->ResetCovariance(5.);
1019 AliTRDtrack *pt = new AliTRDtrack(*seed2,seed2->GetAlpha());
1020 UInt_t * indexes2 = seed2->GetIndexes();
1021 UInt_t * indexes3 = pt->GetBackupIndexes();
1022 for (Int_t i=0;i<200;i++) {
1023 if (indexes2[i]==0) break;
1024 indexes3[i] = indexes2[i];
1026 //AliTRDtrack *pt = seed2;
1028 FollowProlongation(t, innerTB);
1030 if (t.GetNumberOfClusters()<seed->GetTRDclusters(indexes3)*0.5){
1031 // debug - why we dont go back?
1032 AliTRDtrack *pt2 = new AliTRDtrack(*seed2,seed2->GetAlpha());
1033 UInt_t * indexes2 = seed2->GetIndexes();
1034 UInt_t * indexes3 = pt2->GetBackupIndexes();
1035 for (Int_t i=0;i<200;i++) {
1036 if (indexes2[i]==0) break;
1037 indexes3[i] = indexes2[i];
1039 FollowProlongation(*pt2, innerTB);
1043 if (t.GetNumberOfClusters() >= foundMin) {
1045 //CookLabel(pt, 1-fgkLabelFraction);
1049 // cout<<found<<'\r';
1051 if(PropagateToTPC(t)) {
1052 seed->UpdateTrackParams(pt, AliESDtrack::kTRDrefit);
1058 cout<<"Number of loaded seeds: "<<nseed<<endl;
1059 cout<<"Number of found tracks from loaded seeds: "<<found<<endl;
1066 //---------------------------------------------------------------------------
1067 Int_t AliTRDtracker::FollowProlongation(AliTRDtrack& t, Int_t rf)
1069 // Starting from current position on track=t this function tries
1070 // to extrapolate the track up to timeBin=0 and to confirm prolongation
1071 // if a close cluster is found. Returns the number of clusters
1072 // expected to be found in sensitive layers
1074 Float_t wIndex, wTB, wChi2;
1075 Float_t wYrt, wYclosest, wYcorrect, wYwindow;
1076 Float_t wZrt, wZclosest, wZcorrect, wZwindow;
1077 Float_t wPx, wPy, wPz, wC;
1078 Double_t px, py, pz;
1079 Float_t wSigmaC2, wSigmaTgl2, wSigmaY2, wSigmaZ2;
1080 Int_t lastplane = GetLastPlane(&t);
1082 Int_t trackIndex = t.GetLabel();
1084 Int_t ns=Int_t(2*TMath::Pi()/AliTRDgeometry::GetAlpha()+0.5);
1086 Int_t tryAgain=fMaxGap;
1088 Double_t alpha=t.GetAlpha();
1089 alpha = TVector2::Phi_0_2pi(alpha);
1091 Int_t s=Int_t(alpha/AliTRDgeometry::GetAlpha())%AliTRDgeometry::kNsect;
1092 Double_t radLength, rho, x, dx, y, ymax, z;
1094 Int_t expectedNumberOfClusters = 0;
1095 Bool_t lookForCluster;
1097 alpha=AliTRDgeometry::GetAlpha(); // note: change in meaning
1100 for (Int_t nr=fTrSec[0]->GetLayerNumber(t.GetX()); nr>rf; nr--) {
1102 y = t.GetY(); z = t.GetZ();
1104 // first propagate to the inner surface of the current time bin
1105 fTrSec[s]->GetLayer(nr)->GetPropagationParameters(y,z,dx,rho,radLength,lookForCluster);
1106 x = fTrSec[s]->GetLayer(nr)->GetX()-dx/2; y = t.GetY(); z = t.GetZ();
1107 if(!t.PropagateTo(x,radLength,rho)) break;
1109 ymax = x*TMath::Tan(0.5*alpha);
1112 if (!t.Rotate(alpha)) break;
1113 if(!t.PropagateTo(x,radLength,rho)) break;
1114 } else if (y <-ymax) {
1116 if (!t.Rotate(-alpha)) break;
1117 if(!t.PropagateTo(x,radLength,rho)) break;
1120 y = t.GetY(); z = t.GetZ();
1122 // now propagate to the middle plane of the next time bin
1123 fTrSec[s]->GetLayer(nr-1)->GetPropagationParameters(y,z,dx,rho,radLength,lookForCluster);
1124 x = fTrSec[s]->GetLayer(nr-1)->GetX(); y = t.GetY(); z = t.GetZ();
1125 if(!t.PropagateTo(x,radLength,rho)) break;
1127 ymax = x*TMath::Tan(0.5*alpha);
1130 if (!t.Rotate(alpha)) break;
1131 if(!t.PropagateTo(x,radLength,rho)) break;
1132 } else if (y <-ymax) {
1134 if (!t.Rotate(-alpha)) break;
1135 if(!t.PropagateTo(x,radLength,rho)) break;
1139 if(lookForCluster) {
1141 expectedNumberOfClusters++;
1142 wIndex = (Float_t) t.GetLabel();
1145 AliTRDpropagationLayer& timeBin=*(fTrSec[s]->GetLayer(nr-1));
1147 Double_t sy2=ExpectedSigmaY2(x,t.GetTgl(),t.GetPt());
1148 Double_t sz2=ExpectedSigmaZ2(x,t.GetTgl());
1151 if((t.GetSigmaY2() + sy2) > 0) road=10.*sqrt(t.GetSigmaY2() + sy2);
1152 else return expectedNumberOfClusters;
1156 wYwindow = (Float_t) road;
1157 t.GetPxPyPz(px,py,pz);
1161 wC = (Float_t) t.GetC();
1162 wSigmaC2 = (Float_t) t.GetSigmaC2();
1163 wSigmaTgl2 = (Float_t) t.GetSigmaTgl2();
1164 wSigmaY2 = (Float_t) t.GetSigmaY2();
1165 wSigmaZ2 = (Float_t) t.GetSigmaZ2();
1169 AliTRDcluster *cl=0;
1172 Double_t maxChi2=fgkMaxChi2;
1174 wYclosest = 12345678;
1175 wYcorrect = 12345678;
1176 wZclosest = 12345678;
1177 wZcorrect = 12345678;
1178 wZwindow = TMath::Sqrt(2.25 * 12 * sz2);
1180 // Find the closest correct cluster for debugging purposes
1182 Float_t minDY = 1000000;
1183 for (Int_t i=0; i<timeBin; i++) {
1184 AliTRDcluster* c=(AliTRDcluster*)(timeBin[i]);
1185 if((c->GetLabel(0) != trackIndex) &&
1186 (c->GetLabel(1) != trackIndex) &&
1187 (c->GetLabel(2) != trackIndex)) continue;
1188 if(TMath::Abs(c->GetY() - y) > minDY) continue;
1189 minDY = TMath::Abs(c->GetY() - y);
1190 wYcorrect = c->GetY();
1191 wZcorrect = c->GetZ();
1193 Double_t h01 = GetTiltFactor(c);
1194 wChi2 = t.GetPredictedChi2(c, h01);
1198 // Now go for the real cluster search
1202 //find cluster in history
1205 AliTRDcluster * cl0 = timeBin[0];
1209 Int_t plane = fGeom->GetPlane(cl0->GetDetector());
1210 if (plane>lastplane) continue;
1211 Int_t timebin = cl0->GetLocalTimeBin();
1212 AliTRDcluster * cl2= GetCluster(&t,plane, timebin);
1215 Double_t h01 = GetTiltFactor(cl);
1216 maxChi2=t.GetPredictedChi2(cl,h01);
1218 if ((!cl) && road>fgkWideRoad) {
1219 //if (t.GetNumberOfClusters()>4)
1220 // cerr<<t.GetNumberOfClusters()
1221 // <<"FindProlongation warning: Too broad road !\n";
1228 for (Int_t i=timeBin.Find(y-road); i<timeBin; i++) {
1229 AliTRDcluster* c=(AliTRDcluster*)(timeBin[i]);
1230 if (c->GetY() > y+road) break;
1231 if (c->IsUsed() > 0) continue;
1232 if((c->GetZ()-z)*(c->GetZ()-z) > 3 * sz2) continue;
1234 Double_t h01 = GetTiltFactor(c);
1235 Double_t chi2=t.GetPredictedChi2(c,h01);
1237 if (chi2 > maxChi2) continue;
1240 index=timeBin.GetIndex(i);
1246 for (Int_t i=timeBin.Find(y-road); i<timeBin; i++) {
1247 AliTRDcluster* c=(AliTRDcluster*)(timeBin[i]);
1249 if (c->GetY() > y+road) break;
1250 if (c->IsUsed() > 0) continue;
1251 if((c->GetZ()-z)*(c->GetZ()-z) > 12 * sz2) continue;
1253 Double_t h01 = GetTiltFactor(c);
1254 Double_t chi2=t.GetPredictedChi2(c, h01);
1256 if (chi2 > maxChi2) continue;
1259 index=timeBin.GetIndex(i);
1263 wYclosest = cl->GetY();
1264 wZclosest = cl->GetZ();
1265 Double_t h01 = GetTiltFactor(cl);
1267 t.SetSampledEdx(cl->GetQ()/dx,t.GetNumberOfClusters());
1268 //printf("Track position\t%f\t%f\t%f\n",t.GetX(),t.GetY(),t.GetZ());
1269 //printf("Cluster position\t%d\t%f\t%f\n",cl->GetLocalTimeBin(),cl->GetY(),cl->GetZ());
1270 Int_t det = cl->GetDetector();
1271 Int_t plane = fGeom->GetPlane(det);
1273 if(!t.UpdateMI(cl,maxChi2,index,h01,plane)) {
1274 //if(!t.Update(cl,maxChi2,index,h01)) {
1275 //if(!tryAgain--) return 0;
1277 else tryAgain=fMaxGap;
1280 //if (tryAgain==0) break;
1285 if((((Int_t) wTB)%15 == 0) || (((Int_t) wTB)%15 == 14)) {
1287 printf(" %f", wIndex); //1
1288 printf(" %f", wTB); //2
1289 printf(" %f", wYrt); //3
1290 printf(" %f", wYclosest); //4
1291 printf(" %f", wYcorrect); //5
1292 printf(" %f", wYwindow); //6
1293 printf(" %f", wZrt); //7
1294 printf(" %f", wZclosest); //8
1295 printf(" %f", wZcorrect); //9
1296 printf(" %f", wZwindow); //10
1297 printf(" %f", wPx); //11
1298 printf(" %f", wPy); //12
1299 printf(" %f", wPz); //13
1300 printf(" %f", wSigmaC2*1000000); //14
1301 printf(" %f", wSigmaTgl2*1000); //15
1302 printf(" %f", wSigmaY2); //16
1303 // printf(" %f", wSigmaZ2); //17
1304 printf(" %f", wChi2); //17
1305 printf(" %f", wC); //18
1312 return expectedNumberOfClusters;
1317 //___________________________________________________________________
1319 Int_t AliTRDtracker::FollowBackProlongation(AliTRDtrack& t)
1321 // Starting from current radial position of track <t> this function
1322 // extrapolates the track up to outer timebin and in the sensitive
1323 // layers confirms prolongation if a close cluster is found.
1324 // Returns the number of clusters expected to be found in sensitive layers
1326 Float_t wIndex, wTB, wChi2;
1327 Float_t wYrt, wYclosest, wYcorrect, wYwindow;
1328 Float_t wZrt, wZclosest, wZcorrect, wZwindow;
1329 Float_t wPx, wPy, wPz, wC;
1330 Double_t px, py, pz;
1331 Float_t wSigmaC2, wSigmaTgl2, wSigmaY2, wSigmaZ2;
1333 Int_t trackIndex = t.GetLabel();
1334 Int_t tryAgain=fMaxGap;
1336 Double_t alpha=t.GetAlpha();
1337 TVector2::Phi_0_2pi(alpha);
1341 Int_t outerTB = fTrSec[0]->GetOuterTimeBin();
1342 Double_t radLength, rho, x, dx, y, ymax = 0, z;
1343 Bool_t lookForCluster;
1345 Int_t expectedNumberOfClusters = 0;
1348 alpha=AliTRDgeometry::GetAlpha(); // note: change in meaning
1350 Int_t nRefPlane = fgkFirstPlane;
1351 Bool_t isNewLayer = kFALSE;
1357 for (nr=fTrSec[0]->GetLayerNumber(t.GetX()); nr<outerTB+1; nr++) {
1362 // first propagate to the outer surface of the current time bin
1365 fTrSec[s]->GetLayer(nr)->GetPropagationParameters(y,z,dx,rho,radLength,lookForCluster);
1366 x = fTrSec[s]->GetLayer(nr)->GetX()+dx/2;
1370 if(!t.PropagateTo(x,radLength,rho)) break;
1371 // if (!AdjustSector(&t)) break;
1373 // MI -fix untill correct material desription will be implemented
1375 Float_t angle = t.GetAlpha(); // MI - if rotation - we go through the material -
1376 if (!AdjustSector(&t)) break;
1377 if (TMath::Abs(angle - t.GetAlpha())>0.000001) break; //better to stop track
1378 Int_t currentzone = fTrSec[s]->GetLayer(nr)->GetZone(z);
1379 if (currentzone==-10) break; // we are in the frame
1380 if (currentzone>-10){ // layer knows where we are
1381 if (zone==-10) zone = currentzone;
1382 if (zone!=currentzone) break;
1387 if (!t.PropagateTo(x,radLength,rho)) break;
1392 // Barrel Tracks [SR, 04.04.2003]
1395 if (fTrSec[s]->GetLayer(nr)->IsSensitive() !=
1396 fTrSec[s]->GetLayer(nr+1)->IsSensitive() ) {
1398 // if (IsStoringBarrel()) StoreBarrelTrack(&t, nRefPlane++, kTrackBack);
1401 if (fTrSec[s]->GetLayer(nr-1)->IsSensitive() &&
1402 ! fTrSec[s]->GetLayer(nr)->IsSensitive()) {
1404 } else {isNewLayer = kFALSE;}
1409 // now propagate to the middle plane of the next time bin
1410 fTrSec[s]->GetLayer(nr+1)->GetPropagationParameters(y,z,dx,rho,radLength,lookForCluster);
1412 x = fTrSec[s]->GetLayer(nr+1)->GetX();
1413 if(!t.PropagateTo(x,radLength,rho)) break;
1414 if (!AdjustSector(&t)) break;
1416 if(!t.PropagateTo(x,radLength,rho)) break;
1421 if(fVocal) printf("nr+1=%d, x %f, z %f, y %f, ymax %f\n",nr+1,x,z,y,ymax);
1422 // printf("label %d, pl %d, lookForCluster %d \n",
1423 // trackIndex, nr+1, lookForCluster);
1425 if(lookForCluster) {
1426 expectedNumberOfClusters++;
1428 wIndex = (Float_t) t.GetLabel();
1429 wTB = fTrSec[s]->GetLayer(nr+1)->GetTimeBinIndex();
1431 AliTRDpropagationLayer& timeBin=*(fTrSec[s]->GetLayer(nr+1));
1432 Double_t sy2=ExpectedSigmaY2(t.GetX(),t.GetTgl(),t.GetPt());
1433 Double_t sz2=ExpectedSigmaZ2(t.GetX(),t.GetTgl());
1434 if((t.GetSigmaY2() + sy2) < 0) break;
1435 Double_t road = 10.*sqrt(t.GetSigmaY2() + sy2);
1436 Double_t y=t.GetY(), z=t.GetZ();
1440 wYwindow = (Float_t) road;
1441 t.GetPxPyPz(px,py,pz);
1445 wC = (Float_t) t.GetC();
1446 wSigmaC2 = (Float_t) t.GetSigmaC2();
1447 wSigmaTgl2 = (Float_t) t.GetSigmaTgl2();
1448 wSigmaY2 = (Float_t) t.GetSigmaY2();
1449 wSigmaZ2 = (Float_t) t.GetSigmaZ2();
1452 if (road>fgkWideRoad) {
1453 if (t.GetNumberOfClusters()>4)
1454 cerr<<t.GetNumberOfClusters()
1455 <<"FindProlongation warning: Too broad road !\n";
1459 AliTRDcluster *cl=0;
1462 Double_t maxChi2=fgkMaxChi2;
1467 maxChi2 = 10 * fgkMaxChi2;
1470 if (nRefPlane == fgkFirstPlane) maxChi2 = 20 * fgkMaxChi2;
1471 if (nRefPlane == fgkFirstPlane+2) maxChi2 = 15 * fgkMaxChi2;
1472 if (t.GetNRotate() > 0) maxChi2 = 3 * maxChi2;
1475 wYclosest = 12345678;
1476 wYcorrect = 12345678;
1477 wZclosest = 12345678;
1478 wZcorrect = 12345678;
1479 wZwindow = TMath::Sqrt(2.25 * 12 * sz2);
1481 // Find the closest correct cluster for debugging purposes
1484 for (Int_t i=0; i<timeBin; i++) {
1485 AliTRDcluster* c=(AliTRDcluster*)(timeBin[i]);
1486 if((c->GetLabel(0) != trackIndex) &&
1487 (c->GetLabel(1) != trackIndex) &&
1488 (c->GetLabel(2) != trackIndex)) continue;
1489 if(TMath::Abs(c->GetY() - y) > minDY) continue;
1490 //minDY = TMath::Abs(c->GetY() - y);
1491 minDY = c->GetY() - y;
1492 wYcorrect = c->GetY();
1493 wZcorrect = c->GetZ();
1495 Double_t h01 = GetTiltFactor(c);
1496 wChi2 = t.GetPredictedChi2(c, h01);
1500 // Now go for the real cluster search
1504 for (Int_t i=timeBin.Find(y-road); i<timeBin; i++) {
1505 AliTRDcluster* c=(AliTRDcluster*)(timeBin[i]);
1506 if (c->GetY() > y+road) break;
1507 if (c->IsUsed() > 0) continue;
1508 if((c->GetZ()-z)*(c->GetZ()-z) > 3 * sz2) continue;
1510 Double_t h01 = GetTiltFactor(c);
1511 chi2=t.GetPredictedChi2(c,h01);
1513 if (chi2 > maxChi2) continue;
1516 index=timeBin.GetIndex(i);
1519 if((c->GetLabel(0) != trackIndex) &&
1520 (c->GetLabel(1) != trackIndex) &&
1521 (c->GetLabel(2) != trackIndex)) t.AddNWrong();
1526 for (Int_t i=timeBin.Find(y-road); i<timeBin; i++) {
1527 AliTRDcluster* c=(AliTRDcluster*)(timeBin[i]);
1529 if (c->GetY() > y+road) break;
1530 if (c->IsUsed() > 0) continue;
1531 if((c->GetZ()-z)*(c->GetZ()-z) > 2.25 * 12 * sz2) continue;
1533 Double_t h01 = GetTiltFactor(c);
1534 chi2=t.GetPredictedChi2(c,h01);
1536 if (chi2 > maxChi2) continue;
1539 index=timeBin.GetIndex(i);
1544 wYclosest = cl->GetY();
1545 wZclosest = cl->GetZ();
1547 t.SetSampledEdx(cl->GetQ()/dx,t.GetNumberOfClusters());
1548 Double_t h01 = GetTiltFactor(cl);
1549 Int_t det = cl->GetDetector();
1550 Int_t plane = fGeom->GetPlane(det);
1552 if(!t.UpdateMI(cl,maxChi2,index,h01,plane)) {
1553 //if(!t.Update(cl,maxChi2,index,h01)) {
1554 if(!tryAgain--) return 0;
1556 else tryAgain=fMaxGap;
1559 if (tryAgain==0) break;
1562 //if (minDY < 1000000 && isNewLayer)
1563 //cout << "\t" << nRefPlane << "\t" << "\t" << t.GetNRotate() << "\t" <<
1564 // road << "\t" << minDY << "\t" << chi2 << "\t" << wChi2 << "\t" << maxChi2 << endl;
1568 isNewLayer = kFALSE;
1571 if((((Int_t) wTB)%15 == 0) || (((Int_t) wTB)%15 == 14)) {
1573 printf(" %f", wIndex); //1
1574 printf(" %f", wTB); //2
1575 printf(" %f", wYrt); //3
1576 printf(" %f", wYclosest); //4
1577 printf(" %f", wYcorrect); //5
1578 printf(" %f", wYwindow); //6
1579 printf(" %f", wZrt); //7
1580 printf(" %f", wZclosest); //8
1581 printf(" %f", wZcorrect); //9
1582 printf(" %f", wZwindow); //10
1583 printf(" %f", wPx); //11
1584 printf(" %f", wPy); //12
1585 printf(" %f", wPz); //13
1586 printf(" %f", wSigmaC2*1000000); //14
1587 printf(" %f", wSigmaTgl2*1000); //15
1588 printf(" %f", wSigmaY2); //16
1589 // printf(" %f", wSigmaZ2); //17
1590 printf(" %f", wChi2); //17
1591 printf(" %f", wC); //18
1602 return expectedNumberOfClusters;
1607 //---------------------------------------------------------------------------
1608 Int_t AliTRDtracker::Refit(AliTRDtrack& t, Int_t rf)
1610 // Starting from current position on track=t this function tries
1611 // to extrapolate the track up to timeBin=0 and to reuse already
1612 // assigned clusters. Returns the number of clusters
1613 // expected to be found in sensitive layers
1614 // get indices of assigned clusters for each layer
1615 // Origin: Thomas KUHR (Thomas.Kuhr@cern.ch)
1618 for (Int_t i = 0; i < 90; i++) iCluster[i] = 0;
1619 for (Int_t i = 0; i < t.GetNumberOfClusters(); i++) {
1620 Int_t index = t.GetClusterIndex(i);
1621 AliTRDcluster *cl=(AliTRDcluster*) GetCluster(index);
1623 Int_t detector=cl->GetDetector();
1624 Int_t localTimeBin=cl->GetLocalTimeBin();
1625 Int_t sector=fGeom->GetSector(detector);
1626 Int_t plane=fGeom->GetPlane(detector);
1628 Int_t trackingSector = CookSectorIndex(sector);
1630 Int_t gtb = fTrSec[trackingSector]->CookTimeBinIndex(plane,localTimeBin);
1631 if(gtb < 0) continue;
1632 Int_t layer = fTrSec[trackingSector]->GetLayerNumber(gtb);
1633 iCluster[layer] = index;
1637 Int_t ns=Int_t(2*TMath::Pi()/AliTRDgeometry::GetAlpha()+0.5);
1639 Double_t alpha=t.GetAlpha();
1640 alpha = TVector2::Phi_0_2pi(alpha);
1642 Int_t s=Int_t(alpha/AliTRDgeometry::GetAlpha())%AliTRDgeometry::kNsect;
1643 Double_t radLength, rho, x, dx, y, ymax, z;
1645 Int_t expectedNumberOfClusters = 0;
1646 Bool_t lookForCluster;
1648 alpha=AliTRDgeometry::GetAlpha(); // note: change in meaning
1651 for (Int_t nr=fTrSec[0]->GetLayerNumber(t.GetX()); nr>rf; nr--) {
1653 y = t.GetY(); z = t.GetZ();
1655 // first propagate to the inner surface of the current time bin
1656 fTrSec[s]->GetLayer(nr)->GetPropagationParameters(y,z,dx,rho,radLength,lookForCluster);
1657 x = fTrSec[s]->GetLayer(nr)->GetX()-dx/2; y = t.GetY(); z = t.GetZ();
1658 if(!t.PropagateTo(x,radLength,rho)) break;
1660 ymax = x*TMath::Tan(0.5*alpha);
1663 if (!t.Rotate(alpha)) break;
1664 if(!t.PropagateTo(x,radLength,rho)) break;
1665 } else if (y <-ymax) {
1667 if (!t.Rotate(-alpha)) break;
1668 if(!t.PropagateTo(x,radLength,rho)) break;
1671 y = t.GetY(); z = t.GetZ();
1673 // now propagate to the middle plane of the next time bin
1674 fTrSec[s]->GetLayer(nr-1)->GetPropagationParameters(y,z,dx,rho,radLength,lookForCluster);
1675 x = fTrSec[s]->GetLayer(nr-1)->GetX(); y = t.GetY(); z = t.GetZ();
1676 if(!t.PropagateTo(x,radLength,rho)) break;
1678 ymax = x*TMath::Tan(0.5*alpha);
1681 if (!t.Rotate(alpha)) break;
1682 if(!t.PropagateTo(x,radLength,rho)) break;
1683 } else if (y <-ymax) {
1685 if (!t.Rotate(-alpha)) break;
1686 if(!t.PropagateTo(x,radLength,rho)) break;
1689 if(lookForCluster) expectedNumberOfClusters++;
1691 // use assigned cluster
1692 if (!iCluster[nr-1]) continue;
1693 AliTRDcluster *cl=(AliTRDcluster*)GetCluster(iCluster[nr-1]);
1694 Double_t h01 = GetTiltFactor(cl);
1695 Double_t chi2=t.GetPredictedChi2(cl, h01);
1696 t.SetSampledEdx(cl->GetQ()/dx,t.GetNumberOfClusters());
1697 t.Update(cl,chi2,iCluster[nr-1],h01);
1700 return expectedNumberOfClusters;
1703 //___________________________________________________________________
1705 Int_t AliTRDtracker::PropagateToOuterPlane(AliTRDtrack& t, Double_t xToGo)
1707 // Starting from current radial position of track <t> this function
1708 // extrapolates the track up to radial position <xToGo>.
1709 // Returns 1 if track reaches the plane, and 0 otherwise
1711 Int_t ns=Int_t(2*TMath::Pi()/AliTRDgeometry::GetAlpha()+0.5);
1713 Double_t alpha=t.GetAlpha();
1715 if (alpha > 2.*TMath::Pi()) alpha -= 2.*TMath::Pi();
1716 if (alpha < 0. ) alpha += 2.*TMath::Pi();
1718 Int_t s=Int_t(alpha/AliTRDgeometry::GetAlpha())%AliTRDgeometry::kNsect;
1720 Bool_t lookForCluster;
1721 Double_t radLength, rho, x, dx, y, ymax, z;
1725 alpha=AliTRDgeometry::GetAlpha(); // note: change in meaning
1727 Int_t plToGo = fTrSec[0]->GetLayerNumber(xToGo);
1729 for (Int_t nr=fTrSec[0]->GetLayerNumber(x); nr<plToGo; nr++) {
1731 y = t.GetY(); z = t.GetZ();
1733 // first propagate to the outer surface of the current time bin
1734 fTrSec[s]->GetLayer(nr)->GetPropagationParameters(y,z,dx,rho,radLength,lookForCluster);
1735 x = fTrSec[s]->GetLayer(nr)->GetX()+dx/2; y = t.GetY(); z = t.GetZ();
1736 if(!t.PropagateTo(x,radLength,rho)) return 0;
1738 ymax = x*TMath::Tan(0.5*alpha);
1741 if (!t.Rotate(alpha)) return 0;
1742 } else if (y <-ymax) {
1744 if (!t.Rotate(-alpha)) return 0;
1746 if(!t.PropagateTo(x,radLength,rho)) return 0;
1748 y = t.GetY(); z = t.GetZ();
1750 // now propagate to the middle plane of the next time bin
1751 fTrSec[s]->GetLayer(nr+1)->GetPropagationParameters(y,z,dx,rho,radLength,lookForCluster);
1752 x = fTrSec[s]->GetLayer(nr+1)->GetX(); y = t.GetY(); z = t.GetZ();
1753 if(!t.PropagateTo(x,radLength,rho)) return 0;
1755 ymax = x*TMath::Tan(0.5*alpha);
1758 if (!t.Rotate(alpha)) return 0;
1759 } else if (y <-ymax) {
1761 if (!t.Rotate(-alpha)) return 0;
1763 if(!t.PropagateTo(x,radLength,rho)) return 0;
1768 //___________________________________________________________________
1770 Int_t AliTRDtracker::PropagateToTPC(AliTRDtrack& t)
1772 // Starting from current radial position of track <t> this function
1773 // extrapolates the track up to radial position of the outermost
1774 // padrow of the TPC.
1775 // Returns 1 if track reaches the TPC, and 0 otherwise
1777 //Int_t ns=Int_t(2*TMath::Pi()/AliTRDgeometry::GetAlpha()+0.5);
1779 Double_t alpha=t.GetAlpha();
1780 alpha = TVector2::Phi_0_2pi(alpha);
1782 Int_t s=Int_t(alpha/AliTRDgeometry::GetAlpha())%AliTRDgeometry::kNsect;
1784 Bool_t lookForCluster;
1785 Double_t radLength, rho, x, dx, y, /*ymax,*/ z;
1789 alpha=AliTRDgeometry::GetAlpha(); // note: change in meaning
1790 Int_t plTPC = fTrSec[0]->GetLayerNumber(246.055);
1792 for (Int_t nr=fTrSec[0]->GetLayerNumber(x); nr>plTPC; nr--) {
1797 // first propagate to the outer surface of the current time bin
1798 fTrSec[s]->GetLayer(nr)->GetPropagationParameters(y,z,dx,rho,radLength,lookForCluster);
1799 x = fTrSec[s]->GetLayer(nr)->GetX()-dx/2;
1801 if(!t.PropagateTo(x,radLength,rho)) return 0;
1803 if(!t.PropagateTo(x,radLength,rho)) return 0;
1808 // now propagate to the middle plane of the next time bin
1809 fTrSec[s]->GetLayer(nr-1)->GetPropagationParameters(y,z,dx,rho,radLength,lookForCluster);
1810 x = fTrSec[s]->GetLayer(nr-1)->GetX();
1812 if(!t.PropagateTo(x,radLength,rho)) return 0;
1814 if(!t.PropagateTo(x,radLength,rho)) return 0;
1819 void AliTRDtracker::LoadEvent()
1821 // Fills clusters into TRD tracking_sectors
1822 // Note that the numbering scheme for the TRD tracking_sectors
1823 // differs from that of TRD sectors
1825 ReadClusters(fClusters);
1826 Int_t ncl=fClusters->GetEntriesFast();
1827 cout<<"LoadSectors: sorting "<<ncl<<" clusters"<<endl;
1831 // printf("\r %d left ",ncl);
1832 AliTRDcluster *c=(AliTRDcluster*)fClusters->UncheckedAt(ncl);
1833 Int_t detector=c->GetDetector();
1834 Int_t localTimeBin=c->GetLocalTimeBin();
1835 Int_t sector=fGeom->GetSector(detector);
1836 Int_t plane=fGeom->GetPlane(detector);
1838 Int_t trackingSector = CookSectorIndex(sector);
1840 Int_t gtb = fTrSec[trackingSector]->CookTimeBinIndex(plane,localTimeBin);
1841 if(gtb < 0) continue;
1842 Int_t layer = fTrSec[trackingSector]->GetLayerNumber(gtb);
1845 fTrSec[trackingSector]->GetLayer(layer)->InsertCluster(c,index);
1851 //_____________________________________________________________________________
1852 Int_t AliTRDtracker::LoadClusters(TTree *cTree)
1854 // Fills clusters into TRD tracking_sectors
1855 // Note that the numbering scheme for the TRD tracking_sectors
1856 // differs from that of TRD sectors
1858 if (ReadClusters(fClusters,cTree)) {
1859 Error("LoadClusters","Problem with reading the clusters !");
1862 Int_t ncl=fClusters->GetEntriesFast();
1863 cout<<"\n LoadSectors: sorting "<<ncl<<" clusters"<<endl;
1866 for (Int_t ichamber=0;ichamber<5;ichamber++)
1867 for (Int_t isector=0;isector<18;isector++){
1868 fHoles[ichamber][isector]=kTRUE;
1873 // printf("\r %d left ",ncl);
1874 AliTRDcluster *c=(AliTRDcluster*)fClusters->UncheckedAt(ncl);
1875 Int_t detector=c->GetDetector();
1876 Int_t localTimeBin=c->GetLocalTimeBin();
1877 Int_t sector=fGeom->GetSector(detector);
1878 Int_t plane=fGeom->GetPlane(detector);
1880 Int_t trackingSector = CookSectorIndex(sector);
1881 if (c->GetLabel(0)>0){
1882 Int_t chamber = fGeom->GetChamber(detector);
1883 fHoles[chamber][trackingSector]=kFALSE;
1886 Int_t gtb = fTrSec[trackingSector]->CookTimeBinIndex(plane,localTimeBin);
1887 if(gtb < 0) continue;
1888 Int_t layer = fTrSec[trackingSector]->GetLayerNumber(gtb);
1891 fTrSec[trackingSector]->GetLayer(layer)->InsertCluster(c,index);
1897 for (Int_t isector=0;isector<18;isector++){
1898 for (Int_t ichamber=0;ichamber<5;ichamber++)
1899 if (fHoles[ichamber][isector]!=fGeom->IsHole(0,ichamber,17-isector))
1900 printf("Problem \t%d\t%d\t%d\t%d\n",isector,ichamber,fHoles[ichamber][isector],
1901 fGeom->IsHole(0,ichamber,17-isector));
1907 //_____________________________________________________________________________
1908 void AliTRDtracker::UnloadEvent()
1911 // Clears the arrays of clusters and tracks. Resets sectors and timebins
1916 nentr = fClusters->GetEntriesFast();
1917 for (i = 0; i < nentr; i++) delete fClusters->RemoveAt(i);
1919 nentr = fSeeds->GetEntriesFast();
1920 for (i = 0; i < nentr; i++) delete fSeeds->RemoveAt(i);
1922 nentr = fTracks->GetEntriesFast();
1923 for (i = 0; i < nentr; i++) delete fTracks->RemoveAt(i);
1925 Int_t nsec = AliTRDgeometry::kNsect;
1927 for (i = 0; i < nsec; i++) {
1928 for(Int_t pl = 0; pl < fTrSec[i]->GetNumberOfLayers(); pl++) {
1929 fTrSec[i]->GetLayer(pl)->Clear();
1935 //__________________________________________________________________________
1936 void AliTRDtracker::MakeSeeds(Int_t inner, Int_t outer, Int_t turn)
1938 // Creates track seeds using clusters in timeBins=i1,i2
1941 cerr<<"MakeSeeds: turn "<<turn<<" exceeds the limit of 2"<<endl;
1945 Double_t x[5], c[15];
1946 Int_t maxSec=AliTRDgeometry::kNsect;
1948 Double_t alpha=AliTRDgeometry::GetAlpha();
1949 Double_t shift=AliTRDgeometry::GetAlpha()/2.;
1950 Double_t cs=cos(alpha), sn=sin(alpha);
1951 Double_t cs2=cos(2.*alpha), sn2=sin(2.*alpha);
1954 Int_t i2 = fTrSec[0]->GetLayerNumber(inner);
1955 Int_t i1 = fTrSec[0]->GetLayerNumber(outer);
1957 Double_t x1 =fTrSec[0]->GetX(i1);
1958 Double_t xx2=fTrSec[0]->GetX(i2);
1960 for (Int_t ns=0; ns<maxSec; ns++) {
1962 Int_t nl2 = *(fTrSec[(ns-2+maxSec)%maxSec]->GetLayer(i2));
1963 Int_t nl=(*fTrSec[(ns-1+maxSec)%maxSec]->GetLayer(i2));
1964 Int_t nm=(*fTrSec[ns]->GetLayer(i2));
1965 Int_t nu=(*fTrSec[(ns+1)%maxSec]->GetLayer(i2));
1966 Int_t nu2=(*fTrSec[(ns+2)%maxSec]->GetLayer(i2));
1968 AliTRDpropagationLayer& r1=*(fTrSec[ns]->GetLayer(i1));
1970 for (Int_t is=0; is < r1; is++) {
1971 Double_t y1=r1[is]->GetY(), z1=r1[is]->GetZ();
1973 for (Int_t js=0; js < nl2+nl+nm+nu+nu2; js++) {
1975 const AliTRDcluster *cl;
1976 Double_t x2, y2, z2;
1977 Double_t x3=0., y3=0.;
1980 if(turn != 2) continue;
1981 AliTRDpropagationLayer& r2=*(fTrSec[(ns-2+maxSec)%maxSec]->GetLayer(i2));
1983 y2=cl->GetY(); z2=cl->GetZ();
1988 else if (js<nl2+nl) {
1989 if(turn != 1) continue;
1990 AliTRDpropagationLayer& r2=*(fTrSec[(ns-1+maxSec)%maxSec]->GetLayer(i2));
1992 y2=cl->GetY(); z2=cl->GetZ();
1997 else if (js<nl2+nl+nm) {
1998 if(turn != 1) continue;
1999 AliTRDpropagationLayer& r2=*(fTrSec[ns]->GetLayer(i2));
2001 x2=xx2; y2=cl->GetY(); z2=cl->GetZ();
2003 else if (js<nl2+nl+nm+nu) {
2004 if(turn != 1) continue;
2005 AliTRDpropagationLayer& r2=*(fTrSec[(ns+1)%maxSec]->GetLayer(i2));
2006 cl=r2[js-nl2-nl-nm];
2007 y2=cl->GetY(); z2=cl->GetZ();
2013 if(turn != 2) continue;
2014 AliTRDpropagationLayer& r2=*(fTrSec[(ns+2)%maxSec]->GetLayer(i2));
2015 cl=r2[js-nl2-nl-nm-nu];
2016 y2=cl->GetY(); z2=cl->GetZ();
2022 if(TMath::Abs(z1-z2) > fgkMaxSeedDeltaZ12) continue;
2024 Double_t zz=z1 - z1/x1*(x1-x2);
2026 if (TMath::Abs(zz-z2)>fgkMaxSeedDeltaZ) continue;
2028 Double_t d=(x2-x1)*(0.-y2)-(0.-x2)*(y2-y1);
2029 if (d==0.) {cerr<<"TRD MakeSeeds: Straight seed !\n"; continue;}
2033 x[4]=f1trd(x1,y1,x2,y2,x3,y3);
2035 if (TMath::Abs(x[4]) > fgkMaxSeedC) continue;
2037 x[2]=f2trd(x1,y1,x2,y2,x3,y3);
2039 if (TMath::Abs(x[4]*x1-x[2]) >= 0.99999) continue;
2041 x[3]=f3trd(x1,y1,x2,y2,z1,z2);
2043 if (TMath::Abs(x[3]) > fgkMaxSeedTan) continue;
2045 Double_t a=asin(x[2]);
2046 Double_t zv=z1 - x[3]/x[4]*(a+asin(x[4]*x1-x[2]));
2048 if (TMath::Abs(zv)>fgkMaxSeedVertexZ) continue;
2050 Double_t sy1=r1[is]->GetSigmaY2(), sz1=r1[is]->GetSigmaZ2();
2051 Double_t sy2=cl->GetSigmaY2(), sz2=cl->GetSigmaZ2();
2052 Double_t sy3=fgkSeedErrorSY3, sy=fgkSeedErrorSY, sz=fgkSeedErrorSZ;
2055 Double_t h01 = GetTiltFactor(r1[is]);
2056 Double_t xuFactor = 100.;
2062 sy1=sy1+sz1*h01*h01;
2063 Double_t syz=sz1*(-h01);
2064 // end of tilt changes
2066 Double_t f40=(f1trd(x1,y1+sy,x2,y2,x3,y3)-x[4])/sy;
2067 Double_t f42=(f1trd(x1,y1,x2,y2+sy,x3,y3)-x[4])/sy;
2068 Double_t f43=(f1trd(x1,y1,x2,y2,x3,y3+sy)-x[4])/sy;
2069 Double_t f20=(f2trd(x1,y1+sy,x2,y2,x3,y3)-x[2])/sy;
2070 Double_t f22=(f2trd(x1,y1,x2,y2+sy,x3,y3)-x[2])/sy;
2071 Double_t f23=(f2trd(x1,y1,x2,y2,x3,y3+sy)-x[2])/sy;
2072 Double_t f30=(f3trd(x1,y1+sy,x2,y2,z1,z2)-x[3])/sy;
2073 Double_t f31=(f3trd(x1,y1,x2,y2,z1+sz,z2)-x[3])/sz;
2074 Double_t f32=(f3trd(x1,y1,x2,y2+sy,z1,z2)-x[3])/sy;
2075 Double_t f34=(f3trd(x1,y1,x2,y2,z1,z2+sz)-x[3])/sz;
2079 // c[1]=0.; c[2]=sz1;
2080 c[1]=syz; c[2]=sz1*xuFactor;
2081 c[3]=f20*sy1; c[4]=0.; c[5]=f20*sy1*f20+f22*sy2*f22+f23*sy3*f23;
2082 c[6]=f30*sy1; c[7]=f31*sz1; c[8]=f30*sy1*f20+f32*sy2*f22;
2083 c[9]=f30*sy1*f30+f31*sz1*f31+f32*sy2*f32+f34*sz2*f34;
2084 c[10]=f40*sy1; c[11]=0.; c[12]=f40*sy1*f20+f42*sy2*f22+f43*sy3*f23;
2085 c[13]=f30*sy1*f40+f32*sy2*f42;
2086 c[14]=f40*sy1*f40+f42*sy2*f42+f43*sy3*f43;
2088 UInt_t index=r1.GetIndex(is);
2090 AliTRDtrack *track=new AliTRDtrack(r1[is],index,x,c,x1,ns*alpha+shift);
2092 Int_t rc=FollowProlongation(*track, i2);
2095 (track->GetNumberOfClusters() <
2096 (outer-inner)*fgkMinClustersInSeed)) delete track;
2098 fSeeds->AddLast(track); fNseeds++;
2099 // cerr<<"\r found seed "<<fNseeds;
2106 //_____________________________________________________________________________
2107 Int_t AliTRDtracker::ReadClusters(TObjArray *array, TTree *ClusterTree)
2110 // Reads AliTRDclusters (option >= 0) or AliTRDrecPoints (option < 0)
2111 // from the file. The names of the cluster tree and branches
2112 // should match the ones used in AliTRDclusterizer::WriteClusters()
2114 TObjArray *clusterArray = new TObjArray(400);
2116 TBranch *branch=ClusterTree->GetBranch("TRDcluster");
2118 Error("ReadClusters","Can't get the branch !");
2121 branch->SetAddress(&clusterArray);
2123 Int_t nEntries = (Int_t) ClusterTree->GetEntries();
2124 // printf("found %d entries in %s.\n",nEntries,ClusterTree->GetName());
2126 // Loop through all entries in the tree
2128 AliTRDcluster *c = 0;
2131 for (Int_t iEntry = 0; iEntry < nEntries; iEntry++) {
2134 nbytes += ClusterTree->GetEvent(iEntry);
2136 // Get the number of points in the detector
2137 Int_t nCluster = clusterArray->GetEntriesFast();
2138 // printf("\r Read %d clusters from entry %d", nCluster, iEntry);
2140 // Loop through all TRD digits
2141 for (Int_t iCluster = 0; iCluster < nCluster; iCluster++) {
2142 c = (AliTRDcluster*)clusterArray->UncheckedAt(iCluster);
2143 AliTRDcluster *co = new AliTRDcluster(*c);
2144 co->SetSigmaY2(c->GetSigmaY2() * fSY2corr);
2145 Int_t ltb = co->GetLocalTimeBin();
2146 if(ltb == 19) co->SetSigmaZ2(c->GetSigmaZ2());
2147 else if(fNoTilt) co->SetSigmaZ2(c->GetSigmaZ2() * fSZ2corr);
2149 delete clusterArray->RemoveAt(iCluster);
2153 delete clusterArray;
2158 //______________________________________________________________________
2159 void AliTRDtracker::ReadClusters(TObjArray *array, const Char_t *filename)
2162 // Reads AliTRDclusters from file <filename>. The names of the cluster
2163 // tree and branches should match the ones used in
2164 // AliTRDclusterizer::WriteClusters()
2165 // if <array> == 0, clusters are added into AliTRDtracker fCluster array
2168 TDirectory *savedir=gDirectory;
2170 TFile *file = TFile::Open(filename);
2171 if (!file->IsOpen()) {
2172 cerr<<"Can't open file with TRD clusters"<<endl;
2176 Char_t treeName[12];
2177 sprintf(treeName,"TreeR%d_TRD",GetEventNumber());
2178 TTree *clusterTree = (TTree*) gDirectory->Get(treeName);
2181 cerr<<"AliTRDtracker::ReadClusters(): ";
2182 cerr<<"can't get a tree with clusters !\n";
2186 TObjArray *clusterArray = new TObjArray(400);
2188 clusterTree->GetBranch("TRDcluster")->SetAddress(&clusterArray);
2190 Int_t nEntries = (Int_t) clusterTree->GetEntries();
2191 cout<<"found "<<nEntries<<" in clusterTree"<<endl;
2193 // Loop through all entries in the tree
2195 AliTRDcluster *c = 0;
2199 for (Int_t iEntry = 0; iEntry < nEntries; iEntry++) {
2202 nbytes += clusterTree->GetEvent(iEntry);
2204 // Get the number of points in the detector
2205 Int_t nCluster = clusterArray->GetEntriesFast();
2206 printf("\n Read %d clusters from entry %d", nCluster, iEntry);
2208 // Loop through all TRD digits
2209 for (Int_t iCluster = 0; iCluster < nCluster; iCluster++) {
2210 c = (AliTRDcluster*)clusterArray->UncheckedAt(iCluster);
2211 AliTRDcluster *co = new AliTRDcluster(*c);
2212 co->SetSigmaY2(c->GetSigmaY2() * fSY2corr);
2213 Int_t ltb = co->GetLocalTimeBin();
2214 if(ltb == 19) co->SetSigmaZ2(c->GetSigmaZ2());
2215 else if(fNoTilt) co->SetSigmaZ2(c->GetSigmaZ2() * fSZ2corr);
2217 delete clusterArray->RemoveAt(iCluster);
2222 delete clusterArray;
2227 void AliTRDtracker::ReadClusters(TObjArray *array, const TFile *inp)
2230 // Reads AliTRDclusters (option >= 0) or AliTRDrecPoints (option < 0)
2231 // from the file. The names of the cluster tree and branches
2232 // should match the ones used in AliTRDclusterizer::WriteClusters()
2235 TDirectory *savedir=gDirectory;
2238 TFile *in=(TFile*)inp;
2239 if (!in->IsOpen()) {
2240 cerr<<"AliTRDtracker::ReadClusters(): input file is not open !\n";
2248 Char_t treeName[12];
2249 sprintf(treeName,"TreeR%d_TRD",GetEventNumber());
2250 TTree *clusterTree = (TTree*) gDirectory->Get(treeName);
2252 TObjArray *clusterArray = new TObjArray(400);
2254 clusterTree->GetBranch("TRDcluster")->SetAddress(&clusterArray);
2256 Int_t nEntries = (Int_t) clusterTree->GetEntries();
2257 printf("found %d entries in %s.\n",nEntries,clusterTree->GetName());
2259 // Loop through all entries in the tree
2261 AliTRDcluster *c = 0;
2264 for (Int_t iEntry = 0; iEntry < nEntries; iEntry++) {
2267 nbytes += clusterTree->GetEvent(iEntry);
2269 // Get the number of points in the detector
2270 Int_t nCluster = clusterArray->GetEntriesFast();
2271 // printf("\r Read %d clusters from entry %d", nCluster, iEntry);
2273 // Loop through all TRD digits
2274 for (Int_t iCluster = 0; iCluster < nCluster; iCluster++) {
2275 c = (AliTRDcluster*)clusterArray->UncheckedAt(iCluster);
2276 AliTRDcluster *co = new AliTRDcluster(*c);
2277 co->SetSigmaY2(c->GetSigmaY2() * fSY2corr);
2278 Int_t ltb = co->GetLocalTimeBin();
2279 if(ltb == 19) co->SetSigmaZ2(c->GetSigmaZ2());
2280 else if(fNoTilt) co->SetSigmaZ2(c->GetSigmaZ2() * fSZ2corr);
2282 delete clusterArray->RemoveAt(iCluster);
2286 delete clusterArray;
2291 //__________________________________________________________________
2292 void AliTRDtracker::CookLabel(AliKalmanTrack* pt, Float_t wrong) const
2295 // This cooks a label. Mmmmh, smells good...
2298 Int_t label=123456789, index, i, j;
2299 Int_t ncl=pt->GetNumberOfClusters();
2300 const Int_t kRange = fTrSec[0]->GetOuterTimeBin()+1;
2304 // Int_t s[kRange][2];
2305 Int_t **s = new Int_t* [kRange];
2306 for (i=0; i<kRange; i++) {
2307 s[i] = new Int_t[2];
2309 for (i=0; i<kRange; i++) {
2315 for (i=0; i<ncl; i++) {
2316 index=pt->GetClusterIndex(i);
2317 AliTRDcluster *c=(AliTRDcluster*)fClusters->UncheckedAt(index);
2323 for (i=0; i<ncl; i++) {
2324 index=pt->GetClusterIndex(i);
2325 AliTRDcluster *c=(AliTRDcluster*)fClusters->UncheckedAt(index);
2326 for (Int_t k=0; k<3; k++) {
2327 label=c->GetLabel(k);
2328 labelAdded=kFALSE; j=0;
2330 while ( (!labelAdded) && ( j < kRange ) ) {
2331 if (s[j][0]==label || s[j][1]==0) {
2345 for (i=0; i<kRange; i++) {
2347 max=s[i][1]; label=s[i][0];
2351 for (i=0; i<kRange; i++) {
2357 if ((1.- Float_t(max)/ncl) > wrong) label=-label;
2359 pt->SetLabel(label);
2364 //__________________________________________________________________
2365 void AliTRDtracker::UseClusters(const AliKalmanTrack* t, Int_t from) const
2368 // Use clusters, but don't abuse them!
2371 Int_t ncl=t->GetNumberOfClusters();
2372 for (Int_t i=from; i<ncl; i++) {
2373 Int_t index = t->GetClusterIndex(i);
2374 AliTRDcluster *c=(AliTRDcluster*)fClusters->UncheckedAt(index);
2380 //_____________________________________________________________________
2381 Double_t AliTRDtracker::ExpectedSigmaY2(Double_t , Double_t , Double_t ) const
2383 // Parametrised "expected" error of the cluster reconstruction in Y
2385 Double_t s = 0.08 * 0.08;
2389 //_____________________________________________________________________
2390 Double_t AliTRDtracker::ExpectedSigmaZ2(Double_t , Double_t ) const
2392 // Parametrised "expected" error of the cluster reconstruction in Z
2394 Double_t s = 9 * 9 /12.;
2398 //_____________________________________________________________________
2399 Double_t AliTRDtracker::GetX(Int_t sector, Int_t plane, Int_t localTB) const
2402 // Returns radial position which corresponds to time bin <localTB>
2403 // in tracking sector <sector> and plane <plane>
2406 Int_t index = fTrSec[sector]->CookTimeBinIndex(plane, localTB);
2407 Int_t pl = fTrSec[sector]->GetLayerNumber(index);
2408 return fTrSec[sector]->GetLayer(pl)->GetX();
2413 //_______________________________________________________
2414 AliTRDtracker::AliTRDpropagationLayer::AliTRDpropagationLayer(Double_t x,
2415 Double_t dx, Double_t rho, Double_t radLength, Int_t tbIndex)
2418 // AliTRDpropagationLayer constructor
2421 fN = 0; fX = x; fdX = dx; fRho = rho; fX0 = radLength;
2422 fClusters = NULL; fIndex = NULL; fTimeBinIndex = tbIndex;
2425 for(Int_t i=0; i < (Int_t) kZones; i++) {
2426 fZc[i]=0; fZmax[i] = 0;
2431 if(fTimeBinIndex >= 0) {
2432 fClusters = new AliTRDcluster*[kMaxClusterPerTimeBin];
2433 fIndex = new UInt_t[kMaxClusterPerTimeBin];
2436 for (Int_t i=0;i<5;i++) fIsHole[i] = kFALSE;
2447 //_______________________________________________________
2448 void AliTRDtracker::AliTRDpropagationLayer::SetHole(
2449 Double_t Zmax, Double_t Ymax, Double_t rho,
2450 Double_t radLength, Double_t Yc, Double_t Zc)
2453 // Sets hole in the layer
2461 fHoleX0 = radLength;
2465 //_______________________________________________________
2466 AliTRDtracker::AliTRDtrackingSector::AliTRDtrackingSector(AliTRDgeometry* geo, Int_t gs, AliTRDparameter* par)
2469 // AliTRDtrackingSector Constructor
2478 // get holes description from geometry
2479 Bool_t holes[AliTRDgeometry::kNcham];
2480 //printf("sector\t%d\t",gs);
2481 for (Int_t icham=0; icham<AliTRDgeometry::kNcham;icham++){
2482 holes[icham] = fGeom->IsHole(0,icham,gs);
2483 //printf("%d",holes[icham]);
2487 for(UInt_t i=0; i < kMaxTimeBinIndex; i++) fTimeBinIndex[i] = -1;
2490 AliTRDpropagationLayer* ppl;
2492 Double_t x, xin, xout, dx, rho, radLength;
2495 // set time bins in the gas of the TPC
2497 xin = 246.055; xout = 254.055; steps = 20; dx = (xout-xin)/steps;
2498 rho = 0.9e-3; radLength = 28.94;
2500 for(Int_t i=0; i<steps; i++) {
2501 x = xin + i*dx + dx/2;
2502 ppl = new AliTRDpropagationLayer(x,dx,rho,radLength,-1);
2506 // set time bins in the outer field cage vessel
2508 dx = 50e-4; xin = xout; xout = xin + dx; rho = 1.71; radLength = 44.77; // Tedlar
2509 ppl = new AliTRDpropagationLayer(xin+dx/2,dx,rho,radLength,-1);
2512 dx = 0.02; xin = xout; xout = xin + dx; rho = 1.45; radLength = 44.86; // prepreg
2513 ppl = new AliTRDpropagationLayer(xin+dx/2,dx,rho,radLength,-1);
2516 dx = 2.; xin = xout; xout = xin + dx; rho = 1.45*0.02; radLength = 41.28; // Nomex
2517 steps = 5; dx = (xout - xin)/steps;
2518 for(Int_t i=0; i<steps; i++) {
2519 x = xin + i*dx + dx/2;
2520 ppl = new AliTRDpropagationLayer(x,dx,rho,radLength,-1);
2524 dx = 0.02; xin = xout; xout = xin + dx; rho = 1.45; radLength = 44.86; // prepreg
2525 ppl = new AliTRDpropagationLayer(xin+dx/2,dx,rho,radLength,-1);
2528 dx = 50e-4; xin = xout; xout = xin + dx; rho = 1.71; radLength = 44.77; // Tedlar
2529 ppl = new AliTRDpropagationLayer(xin+dx/2,dx,rho,radLength,-1);
2533 // set time bins in CO2
2535 xin = xout; xout = 275.0;
2536 steps = 50; dx = (xout - xin)/steps;
2537 rho = 1.977e-3; radLength = 36.2;
2539 for(Int_t i=0; i<steps; i++) {
2540 x = xin + i*dx + dx/2;
2541 ppl = new AliTRDpropagationLayer(x,dx,rho,radLength,-1);
2545 // set time bins in the outer containment vessel
2547 dx = 50e-4; xin = xout; xout = xin + dx; rho = 2.7; radLength = 24.01; // Al
2548 ppl = new AliTRDpropagationLayer(xin+dx/2,dx,rho,radLength,-1);
2551 dx = 50e-4; xin = xout; xout = xin + dx; rho = 1.71; radLength = 44.77; // Tedlar
2552 ppl = new AliTRDpropagationLayer(xin+dx/2,dx,rho,radLength,-1);
2555 dx = 0.06; xin = xout; xout = xin + dx; rho = 1.45; radLength = 44.86; // prepreg
2556 ppl = new AliTRDpropagationLayer(xin+dx/2,dx,rho,radLength,-1);
2559 dx = 3.; xin = xout; xout = xin + dx; rho = 1.45*0.02; radLength = 41.28; // Nomex
2560 steps = 10; dx = (xout - xin)/steps;
2561 for(Int_t i=0; i<steps; i++) {
2562 x = xin + i*dx + dx/2;
2563 ppl = new AliTRDpropagationLayer(x,dx,rho,radLength,-1);
2567 dx = 0.06; xin = xout; xout = xin + dx; rho = 1.45; radLength = 44.86; // prepreg
2568 ppl = new AliTRDpropagationLayer(xin+dx/2,dx,rho,radLength,-1);
2571 dx = 50e-4; xin = xout; xout = xin + dx; rho = 1.71; radLength = 44.77; // Tedlar
2572 ppl = new AliTRDpropagationLayer(xin+dx/2,dx,rho,radLength,-1);
2575 dx = 50e-4; xin = xout; xout = xin + dx; rho = 2.7; radLength = 24.01; // Al
2576 ppl = new AliTRDpropagationLayer(xin+dx/2,dx,rho,radLength,-1);
2579 Double_t xtrd = (Double_t) fGeom->Rmin();
2581 // add layers between TPC and TRD (Air temporarily)
2582 xin = xout; xout = xtrd;
2583 steps = 50; dx = (xout - xin)/steps;
2584 rho = 1.2e-3; radLength = 36.66;
2586 for(Int_t i=0; i<steps; i++) {
2587 x = xin + i*dx + dx/2;
2588 ppl = new AliTRDpropagationLayer(x,dx,rho,radLength,-1);
2593 // Double_t alpha=AliTRDgeometry::GetAlpha();
2595 // add layers for each of the planes
2597 Double_t dxRo = (Double_t) fGeom->CroHght(); // Rohacell
2598 Double_t dxSpace = (Double_t) fGeom->Cspace(); // Spacing between planes
2599 Double_t dxAmp = (Double_t) fGeom->CamHght(); // Amplification region
2600 Double_t dxDrift = (Double_t) fGeom->CdrHght(); // Drift region
2601 Double_t dxRad = (Double_t) fGeom->CraHght(); // Radiator
2602 Double_t dxTEC = dxRad + dxDrift + dxAmp + dxRo;
2603 Double_t dxPlane = dxTEC + dxSpace;
2606 const Int_t kNchambers = AliTRDgeometry::Ncham();
2609 Double_t ymaxsensitive=0;
2610 Double_t *zc = new Double_t[kNchambers];
2611 Double_t *zmax = new Double_t[kNchambers];
2612 Double_t *zmaxsensitive = new Double_t[kNchambers];
2613 // Double_t holeZmax = 1000.; // the whole sector is missing
2615 for(Int_t plane = 0; plane < AliTRDgeometry::Nplan(); plane++) {
2618 xin = xtrd + plane * dxPlane; xout = xin + dxRad;
2619 steps = 12; dx = (xout - xin)/steps; rho = 0.074; radLength = 40.6;
2620 for(Int_t i=0; i<steps; i++) {
2621 x = xin + i*dx + dx/2;
2622 ppl = new AliTRDpropagationLayer(x,dx,rho,radLength,-1);
2626 ymax = fGeom->GetChamberWidth(plane)/2.;
2627 ymaxsensitive = (fPar->GetColPadSize(plane)*fPar->GetColMax(plane)-4)/2.;
2629 for(Int_t ch = 0; ch < kNchambers; ch++) {
2630 zmax[ch] = fGeom->GetChamberLength(plane,ch)/2;
2631 Float_t pad = fPar->GetRowPadSize(plane,ch,0);
2632 Float_t row0 = fPar->GetRow0(plane,ch,0);
2633 Int_t nPads = fPar->GetRowMax(plane,ch,0);
2634 zmaxsensitive[ch] = Float_t(nPads)*pad/2.;
2635 // zc[ch] = (pad * nPads)/2 + row0 - pad/2;
2636 zc[ch] = (pad * nPads)/2 + row0;
2637 //zc[ch] = row0+zmax[ch]-AliTRDgeometry::RpadW();
2641 dx = fPar->GetTimeBinSize();
2642 rho = 0.00295 * 0.85; radLength = 11.0;
2644 Double_t x0 = (Double_t) fPar->GetTime0(plane);
2645 Double_t xbottom = x0 - dxDrift;
2646 Double_t xtop = x0 + dxAmp;
2648 // Amplification region
2649 steps = (Int_t) (dxAmp/dx);
2651 for(tb = 0; tb < steps; tb++) {
2652 x = x0 + tb * dx + dx/2;
2653 tbIndex = CookTimeBinIndex(plane, -tb-1);
2654 ppl = new AliTRDpropagationLayer(x,dx,rho,radLength,tbIndex);
2655 ppl->SetYmax(ymax,ymaxsensitive);
2656 ppl->SetZ(zc, zmax, zmaxsensitive);
2657 ppl->SetHoles(holes);
2660 tbIndex = CookTimeBinIndex(plane, -steps);
2661 x = (x + dx/2 + xtop)/2;
2663 ppl = new AliTRDpropagationLayer(x,dx,rho,radLength,tbIndex);
2664 ppl->SetYmax(ymax,ymaxsensitive);
2665 ppl->SetZ(zc, zmax,zmaxsensitive);
2666 ppl->SetHoles(holes);
2670 dx = fPar->GetTimeBinSize();
2671 steps = (Int_t) (dxDrift/dx);
2673 for(tb = 0; tb < steps; tb++) {
2674 x = x0 - tb * dx - dx/2;
2675 tbIndex = CookTimeBinIndex(plane, tb);
2677 ppl = new AliTRDpropagationLayer(x,dx,rho,radLength,tbIndex);
2678 ppl->SetYmax(ymax,ymaxsensitive);
2679 ppl->SetZ(zc, zmax, zmaxsensitive);
2680 ppl->SetHoles(holes);
2683 tbIndex = CookTimeBinIndex(plane, steps);
2684 x = (x - dx/2 + xbottom)/2;
2686 ppl = new AliTRDpropagationLayer(x,dx,rho,radLength,tbIndex);
2687 ppl->SetYmax(ymax,ymaxsensitive);
2688 ppl->SetZ(zc, zmax, zmaxsensitive);
2689 ppl->SetHoles(holes);
2693 xin = xtop; dx = 0.025; xout = xin + dx; rho = 1.7; radLength = 33.0;
2694 ppl = new AliTRDpropagationLayer(xin+dx/2,dx,rho,radLength,-1);
2695 ppl->SetYmax(ymax,ymaxsensitive);
2696 ppl->SetZ(zc, zmax,zmax);
2697 ppl->SetHoles(holes);
2701 xin = xout; xout = xtrd + (plane + 1) * dxPlane - dxSpace;
2702 steps = 5; dx = (xout - xin)/steps; rho = 0.074; radLength = 40.6;
2703 for(Int_t i=0; i<steps; i++) {
2704 x = xin + i*dx + dx/2;
2705 ppl = new AliTRDpropagationLayer(x,dx,rho,radLength,-1);
2706 ppl->SetYmax(ymax,ymaxsensitive);
2707 ppl->SetZ(zc, zmax,zmax);
2708 ppl->SetHoles(holes);
2712 // Space between the chambers, air
2713 xin = xout; xout = xtrd + (plane + 1) * dxPlane;
2714 steps = 5; dx = (xout - xin)/steps; rho = 1.29e-3; radLength = 36.66;
2715 for(Int_t i=0; i<steps; i++) {
2716 x = xin + i*dx + dx/2;
2717 ppl = new AliTRDpropagationLayer(x,dx,rho,radLength,-1);
2722 // Space between the TRD and RICH
2723 Double_t xRICH = 500.;
2724 xin = xout; xout = xRICH;
2725 steps = 200; dx = (xout - xin)/steps; rho = 1.29e-3; radLength = 36.66;
2726 for(Int_t i=0; i<steps; i++) {
2727 x = xin + i*dx + dx/2;
2728 ppl = new AliTRDpropagationLayer(x,dx,rho,radLength,-1);
2738 //______________________________________________________
2740 Int_t AliTRDtracker::AliTRDtrackingSector::CookTimeBinIndex(Int_t plane, Int_t localTB) const
2743 // depending on the digitization parameters calculates "global"
2744 // time bin index for timebin <localTB> in plane <plane>
2747 Double_t dxAmp = (Double_t) fGeom->CamHght(); // Amplification region
2748 Double_t dxDrift = (Double_t) fGeom->CdrHght(); // Drift region
2749 Double_t dx = (Double_t) fPar->GetTimeBinSize();
2751 Int_t tbAmp = fPar->GetTimeBefore();
2752 Int_t maxAmp = (Int_t) ((dxAmp+0.000001)/dx);
2753 if(kTRUE) maxAmp = 0; // intentional until we change parameter class
2754 Int_t tbDrift = fPar->GetTimeMax();
2755 Int_t maxDrift = (Int_t) ((dxDrift+0.000001)/dx);
2757 Int_t tbPerPlane = TMath::Min(tbAmp,maxAmp) + TMath::Min(tbDrift,maxDrift);
2759 Int_t gtb = (plane+1) * tbPerPlane - localTB - 1 - TMath::Min(tbAmp,maxAmp);
2762 (TMath::Abs(localTB) > TMath::Min(tbAmp,maxAmp))) return -1;
2763 if(localTB >= TMath::Min(tbDrift,maxDrift)) return -1;
2770 //______________________________________________________
2772 void AliTRDtracker::AliTRDtrackingSector::MapTimeBinLayers()
2775 // For all sensitive time bins sets corresponding layer index
2776 // in the array fTimeBins
2781 for(Int_t i = 0; i < fN; i++) {
2782 index = fLayers[i]->GetTimeBinIndex();
2784 // printf("gtb %d -> pl %d -> x %f \n", index, i, fLayers[i]->GetX());
2786 if(index < 0) continue;
2787 if(index >= (Int_t) kMaxTimeBinIndex) {
2788 printf("*** AliTRDtracker::MapTimeBinLayers: \n");
2789 printf(" index %d exceeds allowed maximum of %d!\n",
2790 index, kMaxTimeBinIndex-1);
2793 fTimeBinIndex[index] = i;
2796 Double_t x1, dx1, x2, dx2, gap;
2798 for(Int_t i = 0; i < fN-1; i++) {
2799 x1 = fLayers[i]->GetX();
2800 dx1 = fLayers[i]->GetdX();
2801 x2 = fLayers[i+1]->GetX();
2802 dx2 = fLayers[i+1]->GetdX();
2803 gap = (x2 - dx2/2) - (x1 + dx1/2);
2805 printf("*** warning: layers %d and %d are overlayed:\n",i,i+1);
2806 printf(" %f + %f + %f > %f\n", x1, dx1/2, dx2/2, x2);
2809 printf("*** warning: layers %d and %d have a large gap:\n",i,i+1);
2810 printf(" (%f - %f) - (%f + %f) = %f\n",
2811 x2, dx2/2, x1, dx1, gap);
2817 //______________________________________________________
2820 Int_t AliTRDtracker::AliTRDtrackingSector::GetLayerNumber(Double_t x) const
2823 // Returns the number of time bin which in radial position is closest to <x>
2826 if(x >= fLayers[fN-1]->GetX()) return fN-1;
2827 if(x <= fLayers[0]->GetX()) return 0;
2829 Int_t b=0, e=fN-1, m=(b+e)/2;
2830 for (; b<e; m=(b+e)/2) {
2831 if (x > fLayers[m]->GetX()) b=m+1;
2834 if(TMath::Abs(x - fLayers[m]->GetX()) >
2835 TMath::Abs(x - fLayers[m+1]->GetX())) return m+1;
2840 //______________________________________________________
2842 Int_t AliTRDtracker::AliTRDtrackingSector::GetInnerTimeBin() const
2845 // Returns number of the innermost SENSITIVE propagation layer
2848 return GetLayerNumber(0);
2851 //______________________________________________________
2853 Int_t AliTRDtracker::AliTRDtrackingSector::GetOuterTimeBin() const
2856 // Returns number of the outermost SENSITIVE time bin
2859 return GetLayerNumber(GetNumberOfTimeBins() - 1);
2862 //______________________________________________________
2864 Int_t AliTRDtracker::AliTRDtrackingSector::GetNumberOfTimeBins() const
2867 // Returns number of SENSITIVE time bins
2871 for(tb = kMaxTimeBinIndex-1; tb >=0; tb--) {
2872 layer = GetLayerNumber(tb);
2878 //______________________________________________________
2880 void AliTRDtracker::AliTRDtrackingSector::InsertLayer(AliTRDpropagationLayer* pl)
2883 // Insert layer <pl> in fLayers array.
2884 // Layers are sorted according to X coordinate.
2886 if ( fN == ((Int_t) kMaxLayersPerSector)) {
2887 printf("AliTRDtrackingSector::InsertLayer(): Too many layers !\n");
2890 if (fN==0) {fLayers[fN++] = pl; return;}
2891 Int_t i=Find(pl->GetX());
2893 memmove(fLayers+i+1 ,fLayers+i,(fN-i)*sizeof(AliTRDpropagationLayer*));
2894 fLayers[i]=pl; fN++;
2898 //______________________________________________________
2900 Int_t AliTRDtracker::AliTRDtrackingSector::Find(Double_t x) const
2903 // Returns index of the propagation layer nearest to X
2906 if (x <= fLayers[0]->GetX()) return 0;
2907 if (x > fLayers[fN-1]->GetX()) return fN;
2908 Int_t b=0, e=fN-1, m=(b+e)/2;
2909 for (; b<e; m=(b+e)/2) {
2910 if (x > fLayers[m]->GetX()) b=m+1;
2916 //______________________________________________________
2917 void AliTRDtracker::AliTRDpropagationLayer::SetZ(Double_t* center, Double_t *w, Double_t *wsensitive )
2920 // set centers and the width of sectors
2921 for (Int_t icham=0;icham< AliTRDgeometry::kNcham;icham++){
2922 fZc[icham] = center[icham];
2923 fZmax[icham] = w[icham];
2924 fZmaxSensitive[icham] = wsensitive[icham];
2925 // printf("chamber\t%d\tzc\t%f\tzmax\t%f\tzsens\t%f\n",icham,fZc[icham],fZmax[icham],fZmaxSensitive[icham]);
2928 //______________________________________________________
2930 void AliTRDtracker::AliTRDpropagationLayer::SetHoles(Bool_t *holes)
2933 // set centers and the width of sectors
2935 for (Int_t icham=0;icham< AliTRDgeometry::kNcham;icham++){
2936 fIsHole[icham] = holes[icham];
2937 if (holes[icham]) fHole = kTRUE;
2943 void AliTRDtracker::AliTRDpropagationLayer::GetPropagationParameters(
2944 Double_t y, Double_t z, Double_t &dx, Double_t &rho, Double_t &radLength,
2945 Bool_t &lookForCluster) const
2948 // Returns radial step <dx>, density <rho>, rad. length <radLength>,
2949 // and sensitivity <lookForCluster> in point <y,z>
2955 lookForCluster = kFALSE;
2957 // check dead regions in sensitive volume
2958 if(fTimeBinIndex >= 0) {
2961 for(Int_t ch = 0; ch < (Int_t) kZones; ch++) {
2962 if (TMath::Abs(z - fZc[ch]) < fZmaxSensitive[ch]){
2964 lookForCluster = !(fIsHole[zone]);
2965 if(TMath::Abs(y) > fYmaxSensitive){
2966 lookForCluster = kFALSE;
2968 if (fIsHole[zone]) {
2980 if (fHole==kFALSE) return;
2982 for(Int_t ch = 0; ch < (Int_t) kZones; ch++) {
2983 if (TMath::Abs(z - fZc[ch]) < fZmax[ch]){
2994 Int_t AliTRDtracker::AliTRDpropagationLayer::GetZone( Double_t z) const
2998 if (fTimeBinIndex < 0) return -20; //unknown
2999 Int_t zone=-10; // dead zone
3000 for(Int_t ch = 0; ch < (Int_t) kZones; ch++) {
3001 if(TMath::Abs(z - fZc[ch]) < fZmax[ch])
3008 //______________________________________________________
3010 void AliTRDtracker::AliTRDpropagationLayer::InsertCluster(AliTRDcluster* c,
3013 // Insert cluster in cluster array.
3014 // Clusters are sorted according to Y coordinate.
3016 if(fTimeBinIndex < 0) {
3017 printf("*** attempt to insert cluster into non-sensitive time bin!\n");
3021 if (fN== (Int_t) kMaxClusterPerTimeBin) {
3022 printf("AliTRDpropagationLayer::InsertCluster(): Too many clusters !\n");
3025 if (fN==0) {fIndex[0]=index; fClusters[fN++]=c; return;}
3026 Int_t i=Find(c->GetY());
3027 memmove(fClusters+i+1 ,fClusters+i,(fN-i)*sizeof(AliTRDcluster*));
3028 memmove(fIndex +i+1 ,fIndex +i,(fN-i)*sizeof(UInt_t));
3029 fIndex[i]=index; fClusters[i]=c; fN++;
3032 //______________________________________________________
3034 Int_t AliTRDtracker::AliTRDpropagationLayer::Find(Double_t y) const {
3036 // Returns index of the cluster nearest in Y
3038 if (y <= fClusters[0]->GetY()) return 0;
3039 if (y > fClusters[fN-1]->GetY()) return fN;
3040 Int_t b=0, e=fN-1, m=(b+e)/2;
3041 for (; b<e; m=(b+e)/2) {
3042 if (y > fClusters[m]->GetY()) b=m+1;
3048 //---------------------------------------------------------
3050 Double_t AliTRDtracker::GetTiltFactor(const AliTRDcluster* c) {
3052 // Returns correction factor for tilted pads geometry
3055 Double_t h01 = sin(TMath::Pi() / 180.0 * fPar->GetTiltingAngle());
3056 Int_t det = c->GetDetector();
3057 Int_t plane = fGeom->GetPlane(det);
3059 if((plane == 1) || (plane == 3) || (plane == 5)) h01=-h01;
3061 if(fNoTilt) h01 = 0;