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 Revision 1.29 2003/07/22 15:56:14 hristov
19 Implementing ESD functionality in the NewIO (Yu.Belikov)
21 Revision 1.27.2.2 2003/07/14 09:19:33 hristov
22 TOF included in the combined PID (Yu.Belikov)
24 Revision 1.27.2.1 2003/07/11 10:53:01 hristov
25 Inward refit for TPC and TRD in the ESD schema (T.Kuhr)
27 Revision 1.27 2003/05/27 17:46:13 hristov
28 TRD PID included in the ESD schema (T.Kuhr)
30 Revision 1.26 2003/04/10 10:36:54 hristov
31 Code for unified TPC/TRD tracking (S.Radomski)
33 Revision 1.25 2003/03/19 17:14:11 hristov
34 Load/UnloadClusters added to the base class and the derived classes changed correspondingly. Possibility to give 2 input files for ITS and TPC tracks in PropagateBack. TRD tracker uses fEventN from the base class (T.Kuhr)
36 Revision 1.24 2003/02/19 09:02:28 hristov
37 Track time measurement (S.Radomski)
39 Revision 1.23 2003/02/10 14:06:10 cblume
40 Add tracking without tilted pads as option
42 Revision 1.22 2003/01/30 15:19:58 cblume
45 Revision 1.21 2003/01/27 16:34:49 cblume
46 Update of tracking by Sergei and Chuncheng
48 Revision 1.20 2002/11/07 15:52:09 cblume
49 Update of tracking code for tilted pads
51 Revision 1.19 2002/10/22 15:53:08 alibrary
52 Introducing Riostream.h
54 Revision 1.18 2002/10/14 14:57:44 hristov
55 Merging the VirtualMC branch to the main development branch (HEAD)
57 Revision 1.14.6.2 2002/07/24 10:09:31 alibrary
60 Revision 1.17 2002/06/13 12:09:58 hristov
63 Revision 1.16 2002/06/12 09:54:36 cblume
64 Update of tracking code provided by Sergei
66 Revision 1.14 2001/11/14 10:50:46 cblume
67 Changes in digits IO. Add merging of summable digits
69 Revision 1.13 2001/05/30 12:17:47 hristov
70 Loop variables declared once
72 Revision 1.12 2001/05/28 17:07:58 hristov
73 Last minute changes; ExB correction in AliTRDclusterizerV1; taking into account of material in G10 TEC frames and material between TEC planes (C.Blume,S.Sedykh)
75 Revision 1.8 2000/12/20 13:00:44 cblume
76 Modifications for the HP-compiler
78 Revision 1.7 2000/12/08 16:07:02 cblume
79 Update of the tracking by Sergei
81 Revision 1.6 2000/11/30 17:38:08 cblume
82 Changes to get in line with new STEER and EVGEN
84 Revision 1.5 2000/11/14 14:40:27 cblume
85 Correction for the Sun compiler (kTRUE and kFALSE)
87 Revision 1.4 2000/11/10 14:57:52 cblume
88 Changes in the geometry constants for the DEC compiler
90 Revision 1.3 2000/10/15 23:40:01 cblume
93 Revision 1.2 2000/10/06 16:49:46 cblume
96 Revision 1.1.2.2 2000/10/04 16:34:58 cblume
97 Replace include files by forward declarations
99 Revision 1.1.2.1 2000/09/22 14:47:52 cblume
100 Add the tracking code
104 #include <Riostream.h>
109 #include <TObjArray.h>
111 #include "AliTRDgeometry.h"
112 #include "AliTRDparameter.h"
113 #include "AliTRDgeometryDetail.h"
114 #include "AliTRDcluster.h"
115 #include "AliTRDtrack.h"
116 #include "AliTRDPartID.h"
117 #include "../TPC/AliTPCtrack.h"
119 #include "AliTRDtracker.h"
121 ClassImp(AliTRDtracker)
123 const Float_t AliTRDtracker::fSeedDepth = 0.5;
124 const Float_t AliTRDtracker::fSeedStep = 0.10;
125 const Float_t AliTRDtracker::fSeedGap = 0.25;
127 const Float_t AliTRDtracker::fMaxSeedDeltaZ12 = 40.;
128 const Float_t AliTRDtracker::fMaxSeedDeltaZ = 25.;
129 const Float_t AliTRDtracker::fMaxSeedC = 0.0052;
130 const Float_t AliTRDtracker::fMaxSeedTan = 1.2;
131 const Float_t AliTRDtracker::fMaxSeedVertexZ = 150.;
133 const Double_t AliTRDtracker::fSeedErrorSY = 0.2;
134 const Double_t AliTRDtracker::fSeedErrorSY3 = 2.5;
135 const Double_t AliTRDtracker::fSeedErrorSZ = 0.1;
137 const Float_t AliTRDtracker::fMinClustersInSeed = 0.7;
139 const Float_t AliTRDtracker::fMinClustersInTrack = 0.5;
140 const Float_t AliTRDtracker::fMinFractionOfFoundClusters = 0.8;
142 const Float_t AliTRDtracker::fSkipDepth = 0.3;
143 const Float_t AliTRDtracker::fLabelFraction = 0.8;
144 const Float_t AliTRDtracker::fWideRoad = 20.;
146 const Double_t AliTRDtracker::fMaxChi2 = 12.;
148 const Int_t AliTRDtracker::kFirstPlane = 5;
149 const Int_t AliTRDtracker::kLastPlane = 17;
152 //____________________________________________________________________
153 AliTRDtracker::AliTRDtracker(const TFile *geomfile):AliTracker()
159 //Float_t fTzero = 0;
161 fAddTRDseeds = kFALSE;
165 TDirectory *savedir=gDirectory;
166 TFile *in=(TFile*)geomfile;
168 printf("AliTRDtracker::AliTRDtracker(): geometry file is not open!\n");
169 printf(" DETAIL TRD geometry and DEFAULT TRD parameter will be used\n");
174 fGeom = (AliTRDgeometry*) in->Get("TRDgeometry");
175 fPar = (AliTRDparameter*) in->Get("TRDparameter");
180 // fTzero = geo->GetT0();
181 printf("Found geometry version %d on file \n", fGeom->IsVersion());
184 printf("AliTRDtracker::AliTRDtracker(): can't find TRD geometry!\n");
185 printf("The DETAIL TRD geometry will be used\n");
186 fGeom = new AliTRDgeometryDetail();
190 printf("AliTRDtracker::AliTRDtracker(): can't find TRD parameter!\n");
191 printf("The DEFAULT TRD parameter will be used\n");
192 fPar = new AliTRDparameter();
199 // fGeom->SetT0(fTzero);
202 fClusters = new TObjArray(2000);
204 fSeeds = new TObjArray(2000);
206 fTracks = new TObjArray(1000);
208 for(Int_t geom_s = 0; geom_s < kTRACKING_SECTORS; geom_s++) {
209 Int_t tr_s = CookSectorIndex(geom_s);
210 fTrSec[tr_s] = new AliTRDtrackingSector(fGeom, geom_s, fPar);
213 Float_t tilt_angle = TMath::Abs(fPar->GetTiltingAngle());
214 if(tilt_angle < 0.1) {
221 if(fNoTilt && (tilt_angle > 0.1)) fSY2corr = fSY2corr + tilt_angle * 0.05;
224 // calculate max gap on track
226 Double_t dxAmp = (Double_t) fGeom->CamHght(); // Amplification region
227 Double_t dxDrift = (Double_t) fGeom->CdrHght(); // Drift region
229 Double_t dx = (Double_t) fPar->GetTimeBinSize();
230 Int_t tbAmp = fPar->GetTimeBefore();
231 Int_t maxAmp = (Int_t) ((dxAmp+0.000001)/dx);
232 if(kTRUE) maxAmp = 0; // intentional until we change the parameter class
233 Int_t tbDrift = fPar->GetTimeMax();
234 Int_t maxDrift = (Int_t) ((dxDrift+0.000001)/dx);
236 tbDrift = TMath::Min(tbDrift,maxDrift);
237 tbAmp = TMath::Min(tbAmp,maxAmp);
239 fTimeBinsPerPlane = tbAmp + tbDrift;
240 fMaxGap = (Int_t) (fTimeBinsPerPlane * fGeom->Nplan() * fSkipDepth);
245 // Barrel Tracks [SR, 03.04.2003]
255 //___________________________________________________________________
256 AliTRDtracker::~AliTRDtracker()
264 for(Int_t geom_s = 0; geom_s < kTRACKING_SECTORS; geom_s++) {
265 delete fTrSec[geom_s];
269 //_____________________________________________________________________
271 void AliTRDtracker::SetBarrelTree(const char *mode) {
276 if (!IsStoringBarrel()) return;
278 TDirectory *sav = gDirectory;
279 if (!fBarrelFile) fBarrelFile = new TFile("AliBarrelTracks.root", "UPDATE");
282 sprintf(buff, "BarrelTRD_%d_%s", GetEventNumber(), mode);
285 fBarrelTree = new TTree(buff, "Barrel TPC tracks");
287 Int_t nRefs = kLastPlane - kFirstPlane + 1;
289 if (!fBarrelArray) fBarrelArray = new TClonesArray("AliBarrelTrack", nRefs);
290 for(Int_t i=0; i<nRefs; i++) new((*fBarrelArray)[i]) AliBarrelTrack();
292 fBarrelTree->Branch("tracks", &fBarrelArray);
296 //_____________________________________________________________________
298 void AliTRDtracker::StoreBarrelTrack(AliTRDtrack *ps, Int_t refPlane, Int_t isIn) {
303 if (!IsStoringBarrel()) return;
305 static Int_t nClusters;
307 static Double_t chi2;
309 static Bool_t wasLast = kTRUE;
311 Int_t newClusters, newWrong;
316 fBarrelArray->Clear();
317 nClusters = nWrong = 0;
323 fBarrelTrack = (AliBarrelTrack*)(*fBarrelArray)[index++];
324 ps->GetBarrelTrack(fBarrelTrack);
326 newClusters = ps->GetNumberOfClusters() - nClusters;
327 newWrong = ps->GetNWrong() - nWrong;
328 newChi2 = ps->GetChi2() - chi2;
330 nClusters = ps->GetNumberOfClusters();
331 nWrong = ps->GetNWrong();
332 chi2 = ps->GetChi2();
334 if (refPlane != kLastPlane) {
335 fBarrelTrack->SetNClusters(newClusters, newChi2);
336 fBarrelTrack->SetNWrongClusters(newWrong);
341 fBarrelTrack->SetRefPlane(refPlane, isIn);
344 //_____________________________________________________________________
346 Bool_t AliTRDtracker::AdjustSector(AliTRDtrack *track) {
348 // Rotates the track when necessary
351 Double_t alpha = AliTRDgeometry::GetAlpha();
352 Double_t y = track->GetY();
353 Double_t ymax = track->GetX()*TMath::Tan(0.5*alpha);
355 //Int_t ns = AliTRDgeometry::kNsect;
356 //Int_t s=Int_t(track->GetAlpha()/alpha)%ns;
360 if (!track->Rotate(alpha)) return kFALSE;
361 } else if (y <-ymax) {
363 if (!track->Rotate(-alpha)) return kFALSE;
369 //_____________________________________________________________________
370 inline Double_t f1trd(Double_t x1,Double_t y1,
371 Double_t x2,Double_t y2,
372 Double_t x3,Double_t y3)
375 // Initial approximation of the track curvature
377 Double_t d=(x2-x1)*(y3-y2)-(x3-x2)*(y2-y1);
378 Double_t a=0.5*((y3-y2)*(y2*y2-y1*y1+x2*x2-x1*x1)-
379 (y2-y1)*(y3*y3-y2*y2+x3*x3-x2*x2));
380 Double_t b=0.5*((x2-x1)*(y3*y3-y2*y2+x3*x3-x2*x2)-
381 (x3-x2)*(y2*y2-y1*y1+x2*x2-x1*x1));
383 Double_t xr=TMath::Abs(d/(d*x1-a)), yr=d/(d*y1-b);
385 return -xr*yr/sqrt(xr*xr+yr*yr);
388 //_____________________________________________________________________
389 inline Double_t f2trd(Double_t x1,Double_t y1,
390 Double_t x2,Double_t y2,
391 Double_t x3,Double_t y3)
394 // Initial approximation of the track curvature times X coordinate
395 // of the center of curvature
398 Double_t d=(x2-x1)*(y3-y2)-(x3-x2)*(y2-y1);
399 Double_t a=0.5*((y3-y2)*(y2*y2-y1*y1+x2*x2-x1*x1)-
400 (y2-y1)*(y3*y3-y2*y2+x3*x3-x2*x2));
401 Double_t b=0.5*((x2-x1)*(y3*y3-y2*y2+x3*x3-x2*x2)-
402 (x3-x2)*(y2*y2-y1*y1+x2*x2-x1*x1));
404 Double_t xr=TMath::Abs(d/(d*x1-a)), yr=d/(d*y1-b);
406 return -a/(d*y1-b)*xr/sqrt(xr*xr+yr*yr);
409 //_____________________________________________________________________
410 inline Double_t f3trd(Double_t x1,Double_t y1,
411 Double_t x2,Double_t y2,
412 Double_t z1,Double_t z2)
415 // Initial approximation of the tangent of the track dip angle
418 return (z1 - z2)/sqrt((x1-x2)*(x1-x2)+(y1-y2)*(y1-y2));
421 //___________________________________________________________________
422 Int_t AliTRDtracker::Clusters2Tracks(const TFile *inp, TFile *out)
425 // Finds tracks within the TRD. File <inp> is expected to contain seeds
426 // at the outer part of the TRD. If <inp> is NULL, the seeds
427 // are found within the TRD if fAddTRDseeds is TRUE.
428 // The tracks are propagated to the innermost time bin
429 // of the TRD and stored in file <out>.
434 TDirectory *savedir=gDirectory;
438 if (!out->IsOpen()) {
439 cerr<<"AliTRDtracker::Clusters2Tracks(): output file is not open !\n";
443 sprintf(tname,"seedTRDtoTPC_%d",GetEventNumber());
444 TTree tpc_tree(tname,"Tree with seeds from TRD at outer TPC pad row");
445 AliTPCtrack *iotrack=0;
446 tpc_tree.Branch("tracks","AliTPCtrack",&iotrack,32000,0);
448 sprintf(tname,"TreeT%d_TRD",GetEventNumber());
449 TTree trd_tree(tname,"TRD tracks at inner TRD time bin");
450 AliTRDtrack *iotrack_trd=0;
451 trd_tree.Branch("tracks","AliTRDtrack",&iotrack_trd,32000,0);
453 Int_t timeBins = fTrSec[0]->GetNumberOfTimeBins();
454 Float_t foundMin = fMinClustersInTrack * timeBins;
457 TFile *in=(TFile*)inp;
460 "AliTRDtracker::Clusters2Tracks(): file with seeds is not open !\n";
461 cerr<<" ... going for seeds finding inside the TRD\n";
465 sprintf(tname,"TRDb_%d",GetEventNumber());
466 TTree *seedTree=(TTree*)in->Get(tname);
468 cerr<<"AliTRDtracker::Clusters2Tracks(): ";
469 cerr<<"can't get a tree with track seeds !\n";
472 AliTRDtrack *seed=new AliTRDtrack;
473 seedTree->SetBranchAddress("tracks",&seed);
475 Int_t n=(Int_t)seedTree->GetEntries();
476 for (Int_t i=0; i<n; i++) {
477 seedTree->GetEvent(i);
478 seed->ResetCovariance();
479 AliTRDtrack *tr = new AliTRDtrack(*seed,seed->GetAlpha());
491 // find tracks from loaded seeds
493 Int_t nseed=fSeeds->GetEntriesFast();
495 Int_t innerTB = fTrSec[0]->GetInnerTimeBin();
497 for (i=0; i<nseed; i++) {
498 AliTRDtrack *pt=(AliTRDtrack*)fSeeds->UncheckedAt(i), &t=*pt;
499 FollowProlongation(t, innerTB);
500 if (t.GetNumberOfClusters() >= foundMin) {
502 CookLabel(pt, 1-fLabelFraction);
508 // cout<<found<<'\r';
510 if(PropagateToTPC(t)) {
511 AliTPCtrack *tpc = new AliTPCtrack(*pt,pt->GetAlpha());
516 delete fSeeds->RemoveAt(i);
520 cout<<"Number of loaded seeds: "<<nseed<<endl;
521 cout<<"Number of found tracks from loaded seeds: "<<found<<endl;
523 // after tracks from loaded seeds are found and the corresponding
524 // clusters are used, look for additional seeds from TRD
527 // Find tracks for the seeds in the TRD
528 Int_t timeBins = fTrSec[0]->GetNumberOfTimeBins();
530 Int_t nSteps = (Int_t) (fSeedDepth / fSeedStep);
531 Int_t gap = (Int_t) (timeBins * fSeedGap);
532 Int_t step = (Int_t) (timeBins * fSeedStep);
534 // make a first turn with tight cut on initial curvature
535 for(Int_t turn = 1; turn <= 2; turn++) {
537 nSteps = (Int_t) (fSeedDepth / (3*fSeedStep));
538 step = (Int_t) (timeBins * (3*fSeedStep));
540 for(Int_t i=0; i<nSteps; i++) {
541 Int_t outer=timeBins-1-i*step;
542 Int_t inner=outer-gap;
544 nseed=fSeeds->GetEntriesFast();
546 MakeSeeds(inner, outer, turn);
548 nseed=fSeeds->GetEntriesFast();
549 printf("\n turn %d, step %d: number of seeds for TRD inward %d\n",
552 for (Int_t i=0; i<nseed; i++) {
553 AliTRDtrack *pt=(AliTRDtrack*)fSeeds->UncheckedAt(i), &t=*pt;
554 FollowProlongation(t,innerTB);
555 if (t.GetNumberOfClusters() >= foundMin) {
557 CookLabel(pt, 1-fLabelFraction);
560 // cout<<found<<'\r';
563 if(PropagateToTPC(t)) {
564 AliTPCtrack *tpc = new AliTPCtrack(*pt,pt->GetAlpha());
570 delete fSeeds->RemoveAt(i);
579 cout<<"Total number of found tracks: "<<found<<endl;
588 //___________________________________________________________________
589 Int_t AliTRDtracker::Clusters2Tracks(AliESD* event)
592 // Finds tracks within the TRD. The ESD event is expected to contain seeds
593 // at the outer part of the TRD. The seeds
594 // are found within the TRD if fAddTRDseeds is TRUE.
595 // The tracks are propagated to the innermost time bin
596 // of the TRD and the ESD event is updated
599 Int_t timeBins = fTrSec[0]->GetNumberOfTimeBins();
600 Float_t foundMin = fMinClustersInTrack * timeBins;
603 Int_t innerTB = fTrSec[0]->GetInnerTimeBin();
605 Int_t n = event->GetNumberOfTracks();
606 for (Int_t i=0; i<n; i++) {
607 AliESDtrack* seed=event->GetTrack(i);
608 ULong_t status=seed->GetStatus();
609 if ( (status & AliESDtrack::kTRDout ) == 0 ) continue;
610 if ( (status & AliESDtrack::kTRDin) != 0 ) continue;
613 AliTRDtrack* seed2 = new AliTRDtrack(*seed);
614 seed2->ResetCovariance();
615 AliTRDtrack *pt = new AliTRDtrack(*seed2,seed2->GetAlpha());
617 FollowProlongation(t, innerTB);
618 if (t.GetNumberOfClusters() >= foundMin) {
620 CookLabel(pt, 1-fLabelFraction);
624 // cout<<found<<'\r';
626 if(PropagateToTPC(t)) {
627 seed->UpdateTrackParams(pt, AliESDtrack::kTRDin);
633 cout<<"Number of loaded seeds: "<<nseed<<endl;
634 cout<<"Number of found tracks from loaded seeds: "<<found<<endl;
636 // after tracks from loaded seeds are found and the corresponding
637 // clusters are used, look for additional seeds from TRD
640 // Find tracks for the seeds in the TRD
641 Int_t timeBins = fTrSec[0]->GetNumberOfTimeBins();
643 Int_t nSteps = (Int_t) (fSeedDepth / fSeedStep);
644 Int_t gap = (Int_t) (timeBins * fSeedGap);
645 Int_t step = (Int_t) (timeBins * fSeedStep);
647 // make a first turn with tight cut on initial curvature
648 for(Int_t turn = 1; turn <= 2; turn++) {
650 nSteps = (Int_t) (fSeedDepth / (3*fSeedStep));
651 step = (Int_t) (timeBins * (3*fSeedStep));
653 for(Int_t i=0; i<nSteps; i++) {
654 Int_t outer=timeBins-1-i*step;
655 Int_t inner=outer-gap;
657 nseed=fSeeds->GetEntriesFast();
659 MakeSeeds(inner, outer, turn);
661 nseed=fSeeds->GetEntriesFast();
662 printf("\n turn %d, step %d: number of seeds for TRD inward %d\n",
665 for (Int_t i=0; i<nseed; i++) {
666 AliTRDtrack *pt=(AliTRDtrack*)fSeeds->UncheckedAt(i), &t=*pt;
667 FollowProlongation(t,innerTB);
668 if (t.GetNumberOfClusters() >= foundMin) {
670 CookLabel(pt, 1-fLabelFraction);
673 // cout<<found<<'\r';
674 if(PropagateToTPC(t)) {
676 track.UpdateTrackParams(pt,AliESDtrack::kTRDin);
677 event->AddTrack(&track);
680 delete fSeeds->RemoveAt(i);
687 cout<<"Total number of found tracks: "<<found<<endl;
694 //_____________________________________________________________________________
695 Int_t AliTRDtracker::PropagateBack(const TFile *inp, TFile *out) {
697 // Reads seeds from file <inp>. The seeds are AliTPCtrack's found and
698 // backpropagated by the TPC tracker. Each seed is first propagated
699 // to the TRD, and then its prolongation is searched in the TRD.
700 // If sufficiently long continuation of the track is found in the TRD
701 // the track is updated, otherwise it's stored as originaly defined
702 // by the TPC tracker.
707 TDirectory *savedir=gDirectory;
709 TFile *in=(TFile*)inp;
712 cerr<<"AliTRDtracker::PropagateBack(): ";
713 cerr<<"file with back propagated TPC tracks is not open !\n";
717 if (!out->IsOpen()) {
718 cerr<<"AliTRDtracker::PropagateBack(): ";
719 cerr<<"file for back propagated TRD tracks is not open !\n";
725 sprintf(tname,"seedsTPCtoTRD_%d",GetEventNumber());
726 TTree *seedTree=(TTree*)in->Get(tname);
728 cerr<<"AliTRDtracker::PropagateBack(): ";
729 cerr<<"can't get a tree with seeds from TPC !\n";
730 cerr<<"check if your version of TPC tracker creates tree "<<tname<<"\n";
734 AliTPCtrack *seed=new AliTPCtrack;
735 seedTree->SetBranchAddress("tracks",&seed);
737 Int_t n=(Int_t)seedTree->GetEntries();
738 for (Int_t i=0; i<n; i++) {
739 seedTree->GetEvent(i);
740 Int_t lbl = seed->GetLabel();
741 AliTRDtrack *tr = new AliTRDtrack(*seed,seed->GetAlpha());
742 tr->SetSeedLabel(lbl);
752 AliTPCtrack *otrack=0;
754 sprintf(tname,"seedsTRDtoTOF1_%d",GetEventNumber());
755 TTree tofTree1(tname,"Tracks back propagated through TPC and TRD");
756 tofTree1.Branch("tracks","AliTPCtrack",&otrack,32000,0);
758 sprintf(tname,"seedsTRDtoTOF2_%d",GetEventNumber());
759 TTree tofTree2(tname,"Tracks back propagated through TPC and TRD");
760 tofTree2.Branch("tracks","AliTPCtrack",&otrack,32000,0);
762 sprintf(tname,"seedsTRDtoPHOS_%d",GetEventNumber());
763 TTree phosTree(tname,"Tracks back propagated through TPC and TRD");
764 phosTree.Branch("tracks","AliTPCtrack",&otrack,32000,0);
766 sprintf(tname,"seedsTRDtoRICH_%d",GetEventNumber());
767 TTree richTree(tname,"Tracks back propagated through TPC and TRD");
768 richTree.Branch("tracks","AliTPCtrack",&otrack,32000,0);
770 sprintf(tname,"TRDb_%d",GetEventNumber());
771 TTree trdTree(tname,"Back propagated TRD tracks at outer TRD time bin");
772 AliTRDtrack *otrack_trd=0;
773 trdTree.Branch("tracks","AliTRDtrack",&otrack_trd,32000,0);
775 if (IsStoringBarrel()) SetBarrelTree("back");
779 Int_t nseed=fSeeds->GetEntriesFast();
781 // Float_t foundMin = fMinClustersInTrack * fTimeBinsPerPlane * fGeom->Nplan();
782 Float_t foundMin = 40;
784 Int_t outermost_tb = fTrSec[0]->GetOuterTimeBin();
786 for (Int_t i=0; i<nseed; i++) {
788 AliTRDtrack *ps=(AliTRDtrack*)fSeeds->UncheckedAt(i), &s=*ps;
789 Int_t expectedClr = FollowBackProlongation(s);
791 if (IsStoringBarrel()) {
792 StoreBarrelTrack(ps, kLastPlane, kTrackBack);
796 Int_t foundClr = s.GetNumberOfClusters();
797 Int_t last_tb = fTrSec[0]->GetLayerNumber(s.GetX());
799 // printf("seed %d: found %d out of %d expected clusters, Min is %f\n",
800 // i, foundClr, expectedClr, foundMin);
802 if (foundClr >= foundMin) {
805 CookLabel(ps, 1-fLabelFraction);
809 // Propagate to outer reference plane [SR, GSI, 18.02.2003]
810 ps->PropagateTo(364.8);
814 // cout<<found<<'\r';
817 if(((expectedClr < 10) && (last_tb == outermost_tb)) ||
818 ((expectedClr >= 10) &&
819 (((Float_t) foundClr) / ((Float_t) expectedClr) >=
820 fMinFractionOfFoundClusters) && (last_tb == outermost_tb))) {
822 Double_t x_tof = 375.5;
824 if(PropagateToOuterPlane(s,x_tof)) {
825 AliTPCtrack *pt = new AliTPCtrack(*ps,ps->GetAlpha());
832 if(PropagateToOuterPlane(s,x_tof)) {
833 AliTPCtrack *pt = new AliTPCtrack(*ps,ps->GetAlpha());
838 Double_t x_phos = 460.;
840 if(PropagateToOuterPlane(s,x_phos)) {
841 AliTPCtrack *pt = new AliTPCtrack(*ps,ps->GetAlpha());
846 Double_t x_rich = 490+1.267;
848 if(PropagateToOuterPlane(s,x_rich)) {
849 AliTPCtrack *pt = new AliTPCtrack(*ps,ps->GetAlpha());
868 if (IsStoringBarrel()) { // [SR, 03.04.2003]
870 fBarrelTree->Write();
871 fBarrelFile->Flush();
875 cerr<<"Number of seeds: "<<nseed<<endl;
876 cerr<<"Number of back propagated TRD tracks: "<<found<<endl;
884 //_____________________________________________________________________________
885 Int_t AliTRDtracker::PropagateBack(AliESD* event) {
887 // Gets seeds from ESD event. The seeds are AliTPCtrack's found and
888 // backpropagated by the TPC tracker. Each seed is first propagated
889 // to the TRD, and then its prolongation is searched in the TRD.
890 // If sufficiently long continuation of the track is found in the TRD
891 // the track is updated, otherwise it's stored as originaly defined
892 // by the TPC tracker.
896 Float_t foundMin = 40;
898 Int_t n = event->GetNumberOfTracks();
899 for (Int_t i=0; i<n; i++) {
900 AliESDtrack* seed=event->GetTrack(i);
901 ULong_t status=seed->GetStatus();
902 if ( (status & AliESDtrack::kTPCout ) == 0 ) continue;
903 if ( (status & AliESDtrack::kTRDout) != 0 ) continue;
905 Int_t lbl = seed->GetLabel();
906 AliTRDtrack *track = new AliTRDtrack(*seed);
907 track->SetSeedLabel(lbl);
910 /*Int_t expectedClr = */FollowBackProlongation(*track);
912 Int_t foundClr = track->GetNumberOfClusters();
913 if (foundClr >= foundMin) {
916 // CookLabel(track, 1-fLabelFraction);
920 // Propagate to outer reference plane [SR, GSI, 18.02.2003]
921 // track->PropagateTo(364.8); why?
923 //seed->UpdateTrackParams(track, AliESDtrack::kTRDout);
927 if (track->PropagateTo(376.)) { //Propagation to the TOF (I.Belikov)
928 seed->UpdateTrackParams(track, AliESDtrack::kTRDout);
934 cerr<<"Number of seeds: "<<fNseeds<<endl;
935 cerr<<"Number of back propagated TRD tracks: "<<found<<endl;
942 //---------------------------------------------------------------------------
943 Int_t AliTRDtracker::FollowProlongation(AliTRDtrack& t, Int_t rf)
945 // Starting from current position on track=t this function tries
946 // to extrapolate the track up to timeBin=0 and to confirm prolongation
947 // if a close cluster is found. Returns the number of clusters
948 // expected to be found in sensitive layers
950 Float_t wIndex, wTB, wChi2;
951 Float_t wYrt, wYclosest, wYcorrect, wYwindow;
952 Float_t wZrt, wZclosest, wZcorrect, wZwindow;
953 Float_t wPx, wPy, wPz, wC;
955 Float_t wSigmaC2, wSigmaTgl2, wSigmaY2, wSigmaZ2;
957 Int_t trackIndex = t.GetLabel();
959 Int_t ns=Int_t(2*TMath::Pi()/AliTRDgeometry::GetAlpha()+0.5);
961 Int_t try_again=fMaxGap;
963 Double_t alpha=t.GetAlpha();
964 alpha = TVector2::Phi_0_2pi(alpha);
966 Int_t s=Int_t(alpha/AliTRDgeometry::GetAlpha())%AliTRDgeometry::kNsect;
967 Double_t rad_length, rho, x, dx, y, ymax, z;
969 Int_t expectedNumberOfClusters = 0;
970 Bool_t lookForCluster;
972 alpha=AliTRDgeometry::GetAlpha(); // note: change in meaning
975 for (Int_t nr=fTrSec[0]->GetLayerNumber(t.GetX()); nr>rf; nr--) {
977 y = t.GetY(); z = t.GetZ();
979 // first propagate to the inner surface of the current time bin
980 fTrSec[s]->GetLayer(nr)->GetPropagationParameters(y,z,dx,rho,rad_length,lookForCluster);
981 x = fTrSec[s]->GetLayer(nr)->GetX()-dx/2; y = t.GetY(); z = t.GetZ();
982 if(!t.PropagateTo(x,rad_length,rho)) break;
984 ymax = x*TMath::Tan(0.5*alpha);
987 if (!t.Rotate(alpha)) break;
988 if(!t.PropagateTo(x,rad_length,rho)) break;
989 } else if (y <-ymax) {
991 if (!t.Rotate(-alpha)) break;
992 if(!t.PropagateTo(x,rad_length,rho)) break;
995 y = t.GetY(); z = t.GetZ();
997 // now propagate to the middle plane of the next time bin
998 fTrSec[s]->GetLayer(nr-1)->GetPropagationParameters(y,z,dx,rho,rad_length,lookForCluster);
999 x = fTrSec[s]->GetLayer(nr-1)->GetX(); y = t.GetY(); z = t.GetZ();
1000 if(!t.PropagateTo(x,rad_length,rho)) break;
1002 ymax = x*TMath::Tan(0.5*alpha);
1005 if (!t.Rotate(alpha)) break;
1006 if(!t.PropagateTo(x,rad_length,rho)) break;
1007 } else if (y <-ymax) {
1009 if (!t.Rotate(-alpha)) break;
1010 if(!t.PropagateTo(x,rad_length,rho)) break;
1014 if(lookForCluster) {
1016 expectedNumberOfClusters++;
1017 wIndex = (Float_t) t.GetLabel();
1020 AliTRDpropagationLayer& time_bin=*(fTrSec[s]->GetLayer(nr-1));
1022 Double_t sy2=ExpectedSigmaY2(x,t.GetTgl(),t.GetPt());
1023 Double_t sz2=ExpectedSigmaZ2(x,t.GetTgl());
1026 if((t.GetSigmaY2() + sy2) > 0) road=10.*sqrt(t.GetSigmaY2() + sy2);
1027 else return expectedNumberOfClusters;
1031 wYwindow = (Float_t) road;
1032 t.GetPxPyPz(Px,Py,Pz);
1036 wC = (Float_t) t.GetC();
1037 wSigmaC2 = (Float_t) t.GetSigmaC2();
1038 wSigmaTgl2 = (Float_t) t.GetSigmaTgl2();
1039 wSigmaY2 = (Float_t) t.GetSigmaY2();
1040 wSigmaZ2 = (Float_t) t.GetSigmaZ2();
1043 if (road>fWideRoad) {
1044 if (t.GetNumberOfClusters()>4)
1045 cerr<<t.GetNumberOfClusters()
1046 <<"FindProlongation warning: Too broad road !\n";
1050 AliTRDcluster *cl=0;
1053 Double_t max_chi2=fMaxChi2;
1055 wYclosest = 12345678;
1056 wYcorrect = 12345678;
1057 wZclosest = 12345678;
1058 wZcorrect = 12345678;
1059 wZwindow = TMath::Sqrt(2.25 * 12 * sz2);
1061 // Find the closest correct cluster for debugging purposes
1063 Float_t minDY = 1000000;
1064 for (Int_t i=0; i<time_bin; i++) {
1065 AliTRDcluster* c=(AliTRDcluster*)(time_bin[i]);
1066 if((c->GetLabel(0) != trackIndex) &&
1067 (c->GetLabel(1) != trackIndex) &&
1068 (c->GetLabel(2) != trackIndex)) continue;
1069 if(TMath::Abs(c->GetY() - y) > minDY) continue;
1070 minDY = TMath::Abs(c->GetY() - y);
1071 wYcorrect = c->GetY();
1072 wZcorrect = c->GetZ();
1074 Double_t h01 = GetTiltFactor(c);
1075 wChi2 = t.GetPredictedChi2(c, h01);
1079 // Now go for the real cluster search
1083 for (Int_t i=time_bin.Find(y-road); i<time_bin; i++) {
1084 AliTRDcluster* c=(AliTRDcluster*)(time_bin[i]);
1085 if (c->GetY() > y+road) break;
1086 if (c->IsUsed() > 0) continue;
1087 if((c->GetZ()-z)*(c->GetZ()-z) > 3 * sz2) continue;
1089 Double_t h01 = GetTiltFactor(c);
1090 Double_t chi2=t.GetPredictedChi2(c,h01);
1092 if (chi2 > max_chi2) continue;
1095 index=time_bin.GetIndex(i);
1100 for (Int_t i=time_bin.Find(y-road); i<time_bin; i++) {
1101 AliTRDcluster* c=(AliTRDcluster*)(time_bin[i]);
1103 if (c->GetY() > y+road) break;
1104 if (c->IsUsed() > 0) continue;
1105 if((c->GetZ()-z)*(c->GetZ()-z) > 12 * sz2) continue;
1107 Double_t h01 = GetTiltFactor(c);
1108 Double_t chi2=t.GetPredictedChi2(c, h01);
1110 if (chi2 > max_chi2) continue;
1113 index=time_bin.GetIndex(i);
1119 wYclosest = cl->GetY();
1120 wZclosest = cl->GetZ();
1121 Double_t h01 = GetTiltFactor(cl);
1123 t.SetSampledEdx(cl->GetQ()/dx,t.GetNumberOfClusters());
1124 if(!t.Update(cl,max_chi2,index,h01)) {
1125 if(!try_again--) return 0;
1127 else try_again=fMaxGap;
1130 if (try_again==0) break;
1135 if((((Int_t) wTB)%15 == 0) || (((Int_t) wTB)%15 == 14)) {
1137 printf(" %f", wIndex); //1
1138 printf(" %f", wTB); //2
1139 printf(" %f", wYrt); //3
1140 printf(" %f", wYclosest); //4
1141 printf(" %f", wYcorrect); //5
1142 printf(" %f", wYwindow); //6
1143 printf(" %f", wZrt); //7
1144 printf(" %f", wZclosest); //8
1145 printf(" %f", wZcorrect); //9
1146 printf(" %f", wZwindow); //10
1147 printf(" %f", wPx); //11
1148 printf(" %f", wPy); //12
1149 printf(" %f", wPz); //13
1150 printf(" %f", wSigmaC2*1000000); //14
1151 printf(" %f", wSigmaTgl2*1000); //15
1152 printf(" %f", wSigmaY2); //16
1153 // printf(" %f", wSigmaZ2); //17
1154 printf(" %f", wChi2); //17
1155 printf(" %f", wC); //18
1162 return expectedNumberOfClusters;
1167 //___________________________________________________________________
1169 Int_t AliTRDtracker::FollowBackProlongation(AliTRDtrack& t)
1171 // Starting from current radial position of track <t> this function
1172 // extrapolates the track up to outer timebin and in the sensitive
1173 // layers confirms prolongation if a close cluster is found.
1174 // Returns the number of clusters expected to be found in sensitive layers
1176 Float_t wIndex, wTB, wChi2;
1177 Float_t wYrt, wYclosest, wYcorrect, wYwindow;
1178 Float_t wZrt, wZclosest, wZcorrect, wZwindow;
1179 Float_t wPx, wPy, wPz, wC;
1180 Double_t Px, Py, Pz;
1181 Float_t wSigmaC2, wSigmaTgl2, wSigmaY2, wSigmaZ2;
1183 Int_t trackIndex = t.GetLabel();
1184 Int_t try_again=fMaxGap;
1186 Double_t alpha=t.GetAlpha();
1187 TVector2::Phi_0_2pi(alpha);
1191 Int_t outerTB = fTrSec[0]->GetOuterTimeBin();
1192 Double_t rad_length, rho, x, dx, y, ymax = 0, z;
1193 Bool_t lookForCluster;
1195 Int_t expectedNumberOfClusters = 0;
1198 alpha=AliTRDgeometry::GetAlpha(); // note: change in meaning
1200 Int_t nRefPlane = kFirstPlane;
1201 Bool_t isNewLayer = kFALSE;
1206 for (Int_t nr=fTrSec[0]->GetLayerNumber(t.GetX()); nr<outerTB+1; nr++) {
1211 // first propagate to the outer surface of the current time bin
1214 fTrSec[s]->GetLayer(nr)->GetPropagationParameters(y,z,dx,rho,rad_length,lookForCluster);
1215 x = fTrSec[s]->GetLayer(nr)->GetX()+dx/2;
1219 if(!t.PropagateTo(x,rad_length,rho)) break;
1220 if (!AdjustSector(&t)) break;
1222 if (!t.PropagateTo(x,rad_length,rho)) break;
1227 // Barrel Tracks [SR, 04.04.2003]
1230 if (fTrSec[s]->GetLayer(nr)->IsSensitive() !=
1231 fTrSec[s]->GetLayer(nr+1)->IsSensitive() ) {
1233 // if (IsStoringBarrel()) StoreBarrelTrack(&t, nRefPlane++, kTrackBack);
1236 if (fTrSec[s]->GetLayer(nr-1)->IsSensitive() &&
1237 ! fTrSec[s]->GetLayer(nr)->IsSensitive()) {
1239 } else {isNewLayer = kFALSE;}
1244 // now propagate to the middle plane of the next time bin
1245 fTrSec[s]->GetLayer(nr+1)->GetPropagationParameters(y,z,dx,rho,rad_length,lookForCluster);
1247 x = fTrSec[s]->GetLayer(nr+1)->GetX();
1248 if(!t.PropagateTo(x,rad_length,rho)) break;
1249 if (!AdjustSector(&t)) break;
1251 if(!t.PropagateTo(x,rad_length,rho)) break;
1256 if(fVocal) printf("nr+1=%d, x %f, z %f, y %f, ymax %f\n",nr+1,x,z,y,ymax);
1257 // printf("label %d, pl %d, lookForCluster %d \n",
1258 // trackIndex, nr+1, lookForCluster);
1260 if(lookForCluster) {
1261 expectedNumberOfClusters++;
1263 wIndex = (Float_t) t.GetLabel();
1264 wTB = fTrSec[s]->GetLayer(nr+1)->GetTimeBinIndex();
1266 AliTRDpropagationLayer& time_bin=*(fTrSec[s]->GetLayer(nr+1));
1267 Double_t sy2=ExpectedSigmaY2(t.GetX(),t.GetTgl(),t.GetPt());
1268 Double_t sz2=ExpectedSigmaZ2(t.GetX(),t.GetTgl());
1269 if((t.GetSigmaY2() + sy2) < 0) break;
1270 Double_t road = 10.*sqrt(t.GetSigmaY2() + sy2);
1271 Double_t y=t.GetY(), z=t.GetZ();
1275 wYwindow = (Float_t) road;
1276 t.GetPxPyPz(Px,Py,Pz);
1280 wC = (Float_t) t.GetC();
1281 wSigmaC2 = (Float_t) t.GetSigmaC2();
1282 wSigmaTgl2 = (Float_t) t.GetSigmaTgl2();
1283 wSigmaY2 = (Float_t) t.GetSigmaY2();
1284 wSigmaZ2 = (Float_t) t.GetSigmaZ2();
1287 if (road>fWideRoad) {
1288 if (t.GetNumberOfClusters()>4)
1289 cerr<<t.GetNumberOfClusters()
1290 <<"FindProlongation warning: Too broad road !\n";
1294 AliTRDcluster *cl=0;
1297 Double_t max_chi2=fMaxChi2;
1302 max_chi2 = 10 * fMaxChi2;
1305 if (nRefPlane == kFirstPlane) max_chi2 = 20 * fMaxChi2;
1306 if (nRefPlane == kFirstPlane+2) max_chi2 = 15 * fMaxChi2;
1307 if (t.GetNRotate() > 0) max_chi2 = 3 * max_chi2;
1310 wYclosest = 12345678;
1311 wYcorrect = 12345678;
1312 wZclosest = 12345678;
1313 wZcorrect = 12345678;
1314 wZwindow = TMath::Sqrt(2.25 * 12 * sz2);
1316 // Find the closest correct cluster for debugging purposes
1319 for (Int_t i=0; i<time_bin; i++) {
1320 AliTRDcluster* c=(AliTRDcluster*)(time_bin[i]);
1321 if((c->GetLabel(0) != trackIndex) &&
1322 (c->GetLabel(1) != trackIndex) &&
1323 (c->GetLabel(2) != trackIndex)) continue;
1324 if(TMath::Abs(c->GetY() - y) > minDY) continue;
1325 //minDY = TMath::Abs(c->GetY() - y);
1326 minDY = c->GetY() - y;
1327 wYcorrect = c->GetY();
1328 wZcorrect = c->GetZ();
1330 Double_t h01 = GetTiltFactor(c);
1331 wChi2 = t.GetPredictedChi2(c, h01);
1335 // Now go for the real cluster search
1339 for (Int_t i=time_bin.Find(y-road); i<time_bin; i++) {
1340 AliTRDcluster* c=(AliTRDcluster*)(time_bin[i]);
1341 if (c->GetY() > y+road) break;
1342 if (c->IsUsed() > 0) continue;
1343 if((c->GetZ()-z)*(c->GetZ()-z) > 3 * sz2) continue;
1345 Double_t h01 = GetTiltFactor(c);
1346 chi2=t.GetPredictedChi2(c,h01);
1348 if (chi2 > max_chi2) continue;
1351 index=time_bin.GetIndex(i);
1354 if((c->GetLabel(0) != trackIndex) &&
1355 (c->GetLabel(1) != trackIndex) &&
1356 (c->GetLabel(2) != trackIndex)) t.AddNWrong();
1361 for (Int_t i=time_bin.Find(y-road); i<time_bin; i++) {
1362 AliTRDcluster* c=(AliTRDcluster*)(time_bin[i]);
1364 if (c->GetY() > y+road) break;
1365 if (c->IsUsed() > 0) continue;
1366 if((c->GetZ()-z)*(c->GetZ()-z) > 2.25 * 12 * sz2) continue;
1368 Double_t h01 = GetTiltFactor(c);
1369 chi2=t.GetPredictedChi2(c,h01);
1371 if (chi2 > max_chi2) continue;
1374 index=time_bin.GetIndex(i);
1379 wYclosest = cl->GetY();
1380 wZclosest = cl->GetZ();
1382 t.SetSampledEdx(cl->GetQ()/dx,t.GetNumberOfClusters());
1383 Double_t h01 = GetTiltFactor(cl);
1384 if(!t.Update(cl,max_chi2,index,h01)) {
1385 if(!try_again--) return 0;
1387 else try_again=fMaxGap;
1390 if (try_again==0) break;
1393 //if (minDY < 1000000 && isNewLayer)
1394 //cout << "\t" << nRefPlane << "\t" << "\t" << t.GetNRotate() << "\t" <<
1395 // road << "\t" << minDY << "\t" << chi2 << "\t" << wChi2 << "\t" << max_chi2 << endl;
1399 isNewLayer = kFALSE;
1402 if((((Int_t) wTB)%15 == 0) || (((Int_t) wTB)%15 == 14)) {
1404 printf(" %f", wIndex); //1
1405 printf(" %f", wTB); //2
1406 printf(" %f", wYrt); //3
1407 printf(" %f", wYclosest); //4
1408 printf(" %f", wYcorrect); //5
1409 printf(" %f", wYwindow); //6
1410 printf(" %f", wZrt); //7
1411 printf(" %f", wZclosest); //8
1412 printf(" %f", wZcorrect); //9
1413 printf(" %f", wZwindow); //10
1414 printf(" %f", wPx); //11
1415 printf(" %f", wPy); //12
1416 printf(" %f", wPz); //13
1417 printf(" %f", wSigmaC2*1000000); //14
1418 printf(" %f", wSigmaTgl2*1000); //15
1419 printf(" %f", wSigmaY2); //16
1420 // printf(" %f", wSigmaZ2); //17
1421 printf(" %f", wChi2); //17
1422 printf(" %f", wC); //18
1429 return expectedNumberOfClusters;
1434 //___________________________________________________________________
1436 Int_t AliTRDtracker::PropagateToOuterPlane(AliTRDtrack& t, Double_t xToGo)
1438 // Starting from current radial position of track <t> this function
1439 // extrapolates the track up to radial position <xToGo>.
1440 // Returns 1 if track reaches the plane, and 0 otherwise
1442 Int_t ns=Int_t(2*TMath::Pi()/AliTRDgeometry::GetAlpha()+0.5);
1444 Double_t alpha=t.GetAlpha();
1446 if (alpha > 2.*TMath::Pi()) alpha -= 2.*TMath::Pi();
1447 if (alpha < 0. ) alpha += 2.*TMath::Pi();
1449 Int_t s=Int_t(alpha/AliTRDgeometry::GetAlpha())%AliTRDgeometry::kNsect;
1451 Bool_t lookForCluster;
1452 Double_t rad_length, rho, x, dx, y, ymax, z;
1456 alpha=AliTRDgeometry::GetAlpha(); // note: change in meaning
1458 Int_t plToGo = fTrSec[0]->GetLayerNumber(xToGo);
1460 for (Int_t nr=fTrSec[0]->GetLayerNumber(x); nr<plToGo; nr++) {
1462 y = t.GetY(); z = t.GetZ();
1464 // first propagate to the outer surface of the current time bin
1465 fTrSec[s]->GetLayer(nr)->GetPropagationParameters(y,z,dx,rho,rad_length,lookForCluster);
1466 x = fTrSec[s]->GetLayer(nr)->GetX()+dx/2; y = t.GetY(); z = t.GetZ();
1467 if(!t.PropagateTo(x,rad_length,rho)) return 0;
1469 ymax = x*TMath::Tan(0.5*alpha);
1472 if (!t.Rotate(alpha)) return 0;
1473 } else if (y <-ymax) {
1475 if (!t.Rotate(-alpha)) return 0;
1477 if(!t.PropagateTo(x,rad_length,rho)) return 0;
1479 y = t.GetY(); z = t.GetZ();
1481 // now propagate to the middle plane of the next time bin
1482 fTrSec[s]->GetLayer(nr+1)->GetPropagationParameters(y,z,dx,rho,rad_length,lookForCluster);
1483 x = fTrSec[s]->GetLayer(nr+1)->GetX(); y = t.GetY(); z = t.GetZ();
1484 if(!t.PropagateTo(x,rad_length,rho)) return 0;
1486 ymax = x*TMath::Tan(0.5*alpha);
1489 if (!t.Rotate(alpha)) return 0;
1490 } else if (y <-ymax) {
1492 if (!t.Rotate(-alpha)) return 0;
1494 if(!t.PropagateTo(x,rad_length,rho)) return 0;
1499 //___________________________________________________________________
1501 Int_t AliTRDtracker::PropagateToTPC(AliTRDtrack& t)
1503 // Starting from current radial position of track <t> this function
1504 // extrapolates the track up to radial position of the outermost
1505 // padrow of the TPC.
1506 // Returns 1 if track reaches the TPC, and 0 otherwise
1508 //Int_t ns=Int_t(2*TMath::Pi()/AliTRDgeometry::GetAlpha()+0.5);
1510 Double_t alpha=t.GetAlpha();
1511 alpha = TVector2::Phi_0_2pi(alpha);
1513 Int_t s=Int_t(alpha/AliTRDgeometry::GetAlpha())%AliTRDgeometry::kNsect;
1515 Bool_t lookForCluster;
1516 Double_t rad_length, rho, x, dx, y, /*ymax,*/ z;
1520 alpha=AliTRDgeometry::GetAlpha(); // note: change in meaning
1521 Int_t plTPC = fTrSec[0]->GetLayerNumber(246.055);
1523 for (Int_t nr=fTrSec[0]->GetLayerNumber(x); nr>plTPC; nr--) {
1528 // first propagate to the outer surface of the current time bin
1529 fTrSec[s]->GetLayer(nr)->GetPropagationParameters(y,z,dx,rho,rad_length,lookForCluster);
1530 x = fTrSec[s]->GetLayer(nr)->GetX()-dx/2;
1532 if(!t.PropagateTo(x,rad_length,rho)) return 0;
1534 if(!t.PropagateTo(x,rad_length,rho)) return 0;
1539 // now propagate to the middle plane of the next time bin
1540 fTrSec[s]->GetLayer(nr-1)->GetPropagationParameters(y,z,dx,rho,rad_length,lookForCluster);
1541 x = fTrSec[s]->GetLayer(nr-1)->GetX();
1543 if(!t.PropagateTo(x,rad_length,rho)) return 0;
1545 if(!t.PropagateTo(x,rad_length,rho)) return 0;
1550 void AliTRDtracker::LoadEvent()
1552 // Fills clusters into TRD tracking_sectors
1553 // Note that the numbering scheme for the TRD tracking_sectors
1554 // differs from that of TRD sectors
1556 ReadClusters(fClusters);
1557 Int_t ncl=fClusters->GetEntriesFast();
1558 cout<<"\n LoadSectors: sorting "<<ncl<<" clusters"<<endl;
1562 // printf("\r %d left ",ncl);
1563 AliTRDcluster *c=(AliTRDcluster*)fClusters->UncheckedAt(ncl);
1564 Int_t detector=c->GetDetector(), local_time_bin=c->GetLocalTimeBin();
1565 Int_t sector=fGeom->GetSector(detector);
1566 Int_t plane=fGeom->GetPlane(detector);
1568 Int_t tracking_sector = CookSectorIndex(sector);
1570 Int_t gtb = fTrSec[tracking_sector]->CookTimeBinIndex(plane,local_time_bin);
1571 if(gtb < 0) continue;
1572 Int_t layer = fTrSec[tracking_sector]->GetLayerNumber(gtb);
1575 fTrSec[tracking_sector]->GetLayer(layer)->InsertCluster(c,index);
1581 //_____________________________________________________________________________
1582 Int_t AliTRDtracker::LoadClusters(TTree *cTree)
1584 // Fills clusters into TRD tracking_sectors
1585 // Note that the numbering scheme for the TRD tracking_sectors
1586 // differs from that of TRD sectors
1588 if (ReadClusters(fClusters,cTree)) {
1589 Error("LoadClusters","Problem with reading the clusters !");
1592 Int_t ncl=fClusters->GetEntriesFast();
1593 cout<<"\n LoadSectors: sorting "<<ncl<<" clusters"<<endl;
1597 // printf("\r %d left ",ncl);
1598 AliTRDcluster *c=(AliTRDcluster*)fClusters->UncheckedAt(ncl);
1599 Int_t detector=c->GetDetector(), local_time_bin=c->GetLocalTimeBin();
1600 Int_t sector=fGeom->GetSector(detector);
1601 Int_t plane=fGeom->GetPlane(detector);
1603 Int_t tracking_sector = CookSectorIndex(sector);
1605 Int_t gtb = fTrSec[tracking_sector]->CookTimeBinIndex(plane,local_time_bin);
1606 if(gtb < 0) continue;
1607 Int_t layer = fTrSec[tracking_sector]->GetLayerNumber(gtb);
1610 fTrSec[tracking_sector]->GetLayer(layer)->InsertCluster(c,index);
1617 //_____________________________________________________________________________
1618 void AliTRDtracker::UnloadEvent()
1621 // Clears the arrays of clusters and tracks. Resets sectors and timebins
1626 nentr = fClusters->GetEntriesFast();
1627 for (i = 0; i < nentr; i++) delete fClusters->RemoveAt(i);
1629 nentr = fSeeds->GetEntriesFast();
1630 for (i = 0; i < nentr; i++) delete fSeeds->RemoveAt(i);
1632 nentr = fTracks->GetEntriesFast();
1633 for (i = 0; i < nentr; i++) delete fTracks->RemoveAt(i);
1635 Int_t nsec = AliTRDgeometry::kNsect;
1637 for (i = 0; i < nsec; i++) {
1638 for(Int_t pl = 0; pl < fTrSec[i]->GetNumberOfLayers(); pl++) {
1639 fTrSec[i]->GetLayer(pl)->Clear();
1645 //__________________________________________________________________________
1646 void AliTRDtracker::MakeSeeds(Int_t inner, Int_t outer, Int_t turn)
1648 // Creates track seeds using clusters in timeBins=i1,i2
1651 cerr<<"MakeSeeds: turn "<<turn<<" exceeds the limit of 2"<<endl;
1655 Double_t x[5], c[15];
1656 Int_t max_sec=AliTRDgeometry::kNsect;
1658 Double_t alpha=AliTRDgeometry::GetAlpha();
1659 Double_t shift=AliTRDgeometry::GetAlpha()/2.;
1660 Double_t cs=cos(alpha), sn=sin(alpha);
1661 Double_t cs2=cos(2.*alpha), sn2=sin(2.*alpha);
1664 Int_t i2 = fTrSec[0]->GetLayerNumber(inner);
1665 Int_t i1 = fTrSec[0]->GetLayerNumber(outer);
1667 Double_t x1 =fTrSec[0]->GetX(i1);
1668 Double_t xx2=fTrSec[0]->GetX(i2);
1670 for (Int_t ns=0; ns<max_sec; ns++) {
1672 Int_t nl2 = *(fTrSec[(ns-2+max_sec)%max_sec]->GetLayer(i2));
1673 Int_t nl=(*fTrSec[(ns-1+max_sec)%max_sec]->GetLayer(i2));
1674 Int_t nm=(*fTrSec[ns]->GetLayer(i2));
1675 Int_t nu=(*fTrSec[(ns+1)%max_sec]->GetLayer(i2));
1676 Int_t nu2=(*fTrSec[(ns+2)%max_sec]->GetLayer(i2));
1678 AliTRDpropagationLayer& r1=*(fTrSec[ns]->GetLayer(i1));
1680 for (Int_t is=0; is < r1; is++) {
1681 Double_t y1=r1[is]->GetY(), z1=r1[is]->GetZ();
1683 for (Int_t js=0; js < nl2+nl+nm+nu+nu2; js++) {
1685 const AliTRDcluster *cl;
1686 Double_t x2, y2, z2;
1687 Double_t x3=0., y3=0.;
1690 if(turn != 2) continue;
1691 AliTRDpropagationLayer& r2=*(fTrSec[(ns-2+max_sec)%max_sec]->GetLayer(i2));
1693 y2=cl->GetY(); z2=cl->GetZ();
1698 else if (js<nl2+nl) {
1699 if(turn != 1) continue;
1700 AliTRDpropagationLayer& r2=*(fTrSec[(ns-1+max_sec)%max_sec]->GetLayer(i2));
1702 y2=cl->GetY(); z2=cl->GetZ();
1707 else if (js<nl2+nl+nm) {
1708 if(turn != 1) continue;
1709 AliTRDpropagationLayer& r2=*(fTrSec[ns]->GetLayer(i2));
1711 x2=xx2; y2=cl->GetY(); z2=cl->GetZ();
1713 else if (js<nl2+nl+nm+nu) {
1714 if(turn != 1) continue;
1715 AliTRDpropagationLayer& r2=*(fTrSec[(ns+1)%max_sec]->GetLayer(i2));
1716 cl=r2[js-nl2-nl-nm];
1717 y2=cl->GetY(); z2=cl->GetZ();
1723 if(turn != 2) continue;
1724 AliTRDpropagationLayer& r2=*(fTrSec[(ns+2)%max_sec]->GetLayer(i2));
1725 cl=r2[js-nl2-nl-nm-nu];
1726 y2=cl->GetY(); z2=cl->GetZ();
1732 if(TMath::Abs(z1-z2) > fMaxSeedDeltaZ12) continue;
1734 Double_t zz=z1 - z1/x1*(x1-x2);
1736 if (TMath::Abs(zz-z2)>fMaxSeedDeltaZ) continue;
1738 Double_t d=(x2-x1)*(0.-y2)-(0.-x2)*(y2-y1);
1739 if (d==0.) {cerr<<"TRD MakeSeeds: Straight seed !\n"; continue;}
1743 x[4]=f1trd(x1,y1,x2,y2,x3,y3);
1745 if (TMath::Abs(x[4]) > fMaxSeedC) continue;
1747 x[2]=f2trd(x1,y1,x2,y2,x3,y3);
1749 if (TMath::Abs(x[4]*x1-x[2]) >= 0.99999) continue;
1751 x[3]=f3trd(x1,y1,x2,y2,z1,z2);
1753 if (TMath::Abs(x[3]) > fMaxSeedTan) continue;
1755 Double_t a=asin(x[2]);
1756 Double_t zv=z1 - x[3]/x[4]*(a+asin(x[4]*x1-x[2]));
1758 if (TMath::Abs(zv)>fMaxSeedVertexZ) continue;
1760 Double_t sy1=r1[is]->GetSigmaY2(), sz1=r1[is]->GetSigmaZ2();
1761 Double_t sy2=cl->GetSigmaY2(), sz2=cl->GetSigmaZ2();
1762 Double_t sy3=fSeedErrorSY3, sy=fSeedErrorSY, sz=fSeedErrorSZ;
1765 Double_t h01 = GetTiltFactor(r1[is]);
1766 Double_t xu_factor = 100.;
1772 sy1=sy1+sz1*h01*h01;
1773 Double_t syz=sz1*(-h01);
1774 // end of tilt changes
1776 Double_t f40=(f1trd(x1,y1+sy,x2,y2,x3,y3)-x[4])/sy;
1777 Double_t f42=(f1trd(x1,y1,x2,y2+sy,x3,y3)-x[4])/sy;
1778 Double_t f43=(f1trd(x1,y1,x2,y2,x3,y3+sy)-x[4])/sy;
1779 Double_t f20=(f2trd(x1,y1+sy,x2,y2,x3,y3)-x[2])/sy;
1780 Double_t f22=(f2trd(x1,y1,x2,y2+sy,x3,y3)-x[2])/sy;
1781 Double_t f23=(f2trd(x1,y1,x2,y2,x3,y3+sy)-x[2])/sy;
1782 Double_t f30=(f3trd(x1,y1+sy,x2,y2,z1,z2)-x[3])/sy;
1783 Double_t f31=(f3trd(x1,y1,x2,y2,z1+sz,z2)-x[3])/sz;
1784 Double_t f32=(f3trd(x1,y1,x2,y2+sy,z1,z2)-x[3])/sy;
1785 Double_t f34=(f3trd(x1,y1,x2,y2,z1,z2+sz)-x[3])/sz;
1789 // c[1]=0.; c[2]=sz1;
1790 c[1]=syz; c[2]=sz1*xu_factor;
1791 c[3]=f20*sy1; c[4]=0.; c[5]=f20*sy1*f20+f22*sy2*f22+f23*sy3*f23;
1792 c[6]=f30*sy1; c[7]=f31*sz1; c[8]=f30*sy1*f20+f32*sy2*f22;
1793 c[9]=f30*sy1*f30+f31*sz1*f31+f32*sy2*f32+f34*sz2*f34;
1794 c[10]=f40*sy1; c[11]=0.; c[12]=f40*sy1*f20+f42*sy2*f22+f43*sy3*f23;
1795 c[13]=f30*sy1*f40+f32*sy2*f42;
1796 c[14]=f40*sy1*f40+f42*sy2*f42+f43*sy3*f43;
1798 UInt_t index=r1.GetIndex(is);
1800 AliTRDtrack *track=new AliTRDtrack(r1[is],index,x,c,x1,ns*alpha+shift);
1802 Int_t rc=FollowProlongation(*track, i2);
1805 (track->GetNumberOfClusters() <
1806 (outer-inner)*fMinClustersInSeed)) delete track;
1808 fSeeds->AddLast(track); fNseeds++;
1809 // cerr<<"\r found seed "<<fNseeds;
1816 //_____________________________________________________________________________
1817 Int_t AliTRDtracker::ReadClusters(TObjArray *array, TTree *ClusterTree)
1820 // Reads AliTRDclusters (option >= 0) or AliTRDrecPoints (option < 0)
1821 // from the file. The names of the cluster tree and branches
1822 // should match the ones used in AliTRDclusterizer::WriteClusters()
1824 TObjArray *ClusterArray = new TObjArray(400);
1826 TBranch *branch=ClusterTree->GetBranch("TRDcluster");
1828 Error("ReadClusters","Can't get the branch !");
1831 branch->SetAddress(&ClusterArray);
1833 Int_t nEntries = (Int_t) ClusterTree->GetEntries();
1834 printf("found %d entries in %s.\n",nEntries,ClusterTree->GetName());
1836 // Loop through all entries in the tree
1838 AliTRDcluster *c = 0;
1841 for (Int_t iEntry = 0; iEntry < nEntries; iEntry++) {
1844 nbytes += ClusterTree->GetEvent(iEntry);
1846 // Get the number of points in the detector
1847 Int_t nCluster = ClusterArray->GetEntriesFast();
1848 // printf("\r Read %d clusters from entry %d", nCluster, iEntry);
1850 // Loop through all TRD digits
1851 for (Int_t iCluster = 0; iCluster < nCluster; iCluster++) {
1852 c = (AliTRDcluster*)ClusterArray->UncheckedAt(iCluster);
1853 AliTRDcluster *co = new AliTRDcluster(*c);
1854 co->SetSigmaY2(c->GetSigmaY2() * fSY2corr);
1855 Int_t ltb = co->GetLocalTimeBin();
1856 if(ltb == 19) co->SetSigmaZ2(c->GetSigmaZ2());
1857 else if(fNoTilt) co->SetSigmaZ2(c->GetSigmaZ2() * fSZ2corr);
1859 delete ClusterArray->RemoveAt(iCluster);
1863 delete ClusterArray;
1868 //______________________________________________________________________
1869 void AliTRDtracker::ReadClusters(TObjArray *array, const Char_t *filename)
1872 // Reads AliTRDclusters from file <filename>. The names of the cluster
1873 // tree and branches should match the ones used in
1874 // AliTRDclusterizer::WriteClusters()
1875 // if <array> == 0, clusters are added into AliTRDtracker fCluster array
1878 TDirectory *savedir=gDirectory;
1880 TFile *file = TFile::Open(filename);
1881 if (!file->IsOpen()) {
1882 cerr<<"Can't open file with TRD clusters"<<endl;
1886 Char_t treeName[12];
1887 sprintf(treeName,"TreeR%d_TRD",GetEventNumber());
1888 TTree *ClusterTree = (TTree*) gDirectory->Get(treeName);
1891 cerr<<"AliTRDtracker::ReadClusters(): ";
1892 cerr<<"can't get a tree with clusters !\n";
1896 TObjArray *ClusterArray = new TObjArray(400);
1898 ClusterTree->GetBranch("TRDcluster")->SetAddress(&ClusterArray);
1900 Int_t nEntries = (Int_t) ClusterTree->GetEntries();
1901 cout<<"found "<<nEntries<<" in ClusterTree"<<endl;
1903 // Loop through all entries in the tree
1905 AliTRDcluster *c = 0;
1909 for (Int_t iEntry = 0; iEntry < nEntries; iEntry++) {
1912 nbytes += ClusterTree->GetEvent(iEntry);
1914 // Get the number of points in the detector
1915 Int_t nCluster = ClusterArray->GetEntriesFast();
1916 printf("\n Read %d clusters from entry %d", nCluster, iEntry);
1918 // Loop through all TRD digits
1919 for (Int_t iCluster = 0; iCluster < nCluster; iCluster++) {
1920 c = (AliTRDcluster*)ClusterArray->UncheckedAt(iCluster);
1921 AliTRDcluster *co = new AliTRDcluster(*c);
1922 co->SetSigmaY2(c->GetSigmaY2() * fSY2corr);
1923 Int_t ltb = co->GetLocalTimeBin();
1924 if(ltb == 19) co->SetSigmaZ2(c->GetSigmaZ2());
1925 else if(fNoTilt) co->SetSigmaZ2(c->GetSigmaZ2() * fSZ2corr);
1927 delete ClusterArray->RemoveAt(iCluster);
1932 delete ClusterArray;
1937 void AliTRDtracker::ReadClusters(TObjArray *array, const TFile *inp)
1940 // Reads AliTRDclusters (option >= 0) or AliTRDrecPoints (option < 0)
1941 // from the file. The names of the cluster tree and branches
1942 // should match the ones used in AliTRDclusterizer::WriteClusters()
1945 TDirectory *savedir=gDirectory;
1948 TFile *in=(TFile*)inp;
1949 if (!in->IsOpen()) {
1950 cerr<<"AliTRDtracker::ReadClusters(): input file is not open !\n";
1958 Char_t treeName[12];
1959 sprintf(treeName,"TreeR%d_TRD",GetEventNumber());
1960 TTree *ClusterTree = (TTree*) gDirectory->Get(treeName);
1962 TObjArray *ClusterArray = new TObjArray(400);
1964 ClusterTree->GetBranch("TRDcluster")->SetAddress(&ClusterArray);
1966 Int_t nEntries = (Int_t) ClusterTree->GetEntries();
1967 printf("found %d entries in %s.\n",nEntries,ClusterTree->GetName());
1969 // Loop through all entries in the tree
1971 AliTRDcluster *c = 0;
1974 for (Int_t iEntry = 0; iEntry < nEntries; iEntry++) {
1977 nbytes += ClusterTree->GetEvent(iEntry);
1979 // Get the number of points in the detector
1980 Int_t nCluster = ClusterArray->GetEntriesFast();
1981 // printf("\r Read %d clusters from entry %d", nCluster, iEntry);
1983 // Loop through all TRD digits
1984 for (Int_t iCluster = 0; iCluster < nCluster; iCluster++) {
1985 c = (AliTRDcluster*)ClusterArray->UncheckedAt(iCluster);
1986 AliTRDcluster *co = new AliTRDcluster(*c);
1987 co->SetSigmaY2(c->GetSigmaY2() * fSY2corr);
1988 Int_t ltb = co->GetLocalTimeBin();
1989 if(ltb == 19) co->SetSigmaZ2(c->GetSigmaZ2());
1990 else if(fNoTilt) co->SetSigmaZ2(c->GetSigmaZ2() * fSZ2corr);
1992 delete ClusterArray->RemoveAt(iCluster);
1996 delete ClusterArray;
2001 //__________________________________________________________________
2002 void AliTRDtracker::CookLabel(AliKalmanTrack* pt, Float_t wrong) const {
2004 Int_t label=123456789, index, i, j;
2005 Int_t ncl=pt->GetNumberOfClusters();
2006 const Int_t range = fTrSec[0]->GetOuterTimeBin()+1;
2010 // Int_t s[range][2];
2011 Int_t **s = new Int_t* [range];
2012 for (i=0; i<range; i++) {
2013 s[i] = new Int_t[2];
2015 for (i=0; i<range; i++) {
2021 for (i=0; i<ncl; i++) {
2022 index=pt->GetClusterIndex(i);
2023 AliTRDcluster *c=(AliTRDcluster*)fClusters->UncheckedAt(index);
2029 for (i=0; i<ncl; i++) {
2030 index=pt->GetClusterIndex(i);
2031 AliTRDcluster *c=(AliTRDcluster*)fClusters->UncheckedAt(index);
2032 for (Int_t k=0; k<3; k++) {
2033 label=c->GetLabel(k);
2034 label_added=kFALSE; j=0;
2036 while ( (!label_added) && ( j < range ) ) {
2037 if (s[j][0]==label || s[j][1]==0) {
2051 for (i=0; i<range; i++) {
2053 max=s[i][1]; label=s[i][0];
2057 for (i=0; i<range; i++) {
2063 if ((1.- Float_t(max)/ncl) > wrong) label=-label;
2065 pt->SetLabel(label);
2070 //__________________________________________________________________
2071 void AliTRDtracker::UseClusters(const AliKalmanTrack* t, Int_t from) const {
2072 Int_t ncl=t->GetNumberOfClusters();
2073 for (Int_t i=from; i<ncl; i++) {
2074 Int_t index = t->GetClusterIndex(i);
2075 AliTRDcluster *c=(AliTRDcluster*)fClusters->UncheckedAt(index);
2081 //_____________________________________________________________________
2082 Double_t AliTRDtracker::ExpectedSigmaY2(Double_t , Double_t , Double_t )
2084 // Parametrised "expected" error of the cluster reconstruction in Y
2086 Double_t s = 0.08 * 0.08;
2090 //_____________________________________________________________________
2091 Double_t AliTRDtracker::ExpectedSigmaZ2(Double_t , Double_t )
2093 // Parametrised "expected" error of the cluster reconstruction in Z
2095 Double_t s = 9 * 9 /12.;
2100 //_____________________________________________________________________
2101 Double_t AliTRDtracker::GetX(Int_t sector, Int_t plane, Int_t local_tb) const
2104 // Returns radial position which corresponds to time bin <local_tb>
2105 // in tracking sector <sector> and plane <plane>
2108 Int_t index = fTrSec[sector]->CookTimeBinIndex(plane, local_tb);
2109 Int_t pl = fTrSec[sector]->GetLayerNumber(index);
2110 return fTrSec[sector]->GetLayer(pl)->GetX();
2115 //_______________________________________________________
2116 AliTRDtracker::AliTRDpropagationLayer::AliTRDpropagationLayer(Double_t x,
2117 Double_t dx, Double_t rho, Double_t rad_length, Int_t tb_index)
2120 // AliTRDpropagationLayer constructor
2123 fN = 0; fX = x; fdX = dx; fRho = rho; fX0 = rad_length;
2124 fClusters = NULL; fIndex = NULL; fTimeBinIndex = tb_index;
2127 for(Int_t i=0; i < (Int_t) kZONES; i++) {
2128 fZc[i]=0; fZmax[i] = 0;
2133 if(fTimeBinIndex >= 0) {
2134 fClusters = new AliTRDcluster*[kMAX_CLUSTER_PER_TIME_BIN];
2135 fIndex = new UInt_t[kMAX_CLUSTER_PER_TIME_BIN];
2148 //_______________________________________________________
2149 void AliTRDtracker::AliTRDpropagationLayer::SetHole(
2150 Double_t Zmax, Double_t Ymax, Double_t rho,
2151 Double_t rad_length, Double_t Yc, Double_t Zc)
2154 // Sets hole in the layer
2163 fHoleX0 = rad_length;
2167 //_______________________________________________________
2168 AliTRDtracker::AliTRDtrackingSector::AliTRDtrackingSector(AliTRDgeometry* geo, Int_t gs, AliTRDparameter* par)
2171 // AliTRDtrackingSector Constructor
2180 for(UInt_t i=0; i < kMAX_TIME_BIN_INDEX; i++) fTimeBinIndex[i] = -1;
2183 AliTRDpropagationLayer* ppl;
2185 Double_t x, xin, xout, dx, rho, rad_length;
2188 // set time bins in the gas of the TPC
2190 xin = 246.055; xout = 254.055; steps = 20; dx = (xout-xin)/steps;
2191 rho = 0.9e-3; rad_length = 28.94;
2193 for(Int_t i=0; i<steps; i++) {
2194 x = xin + i*dx + dx/2;
2195 ppl = new AliTRDpropagationLayer(x,dx,rho,rad_length,-1);
2199 // set time bins in the outer field cage vessel
2201 dx = 50e-4; xin = xout; xout = xin + dx; rho = 1.71; rad_length = 44.77; // Tedlar
2202 ppl = new AliTRDpropagationLayer(xin+dx/2,dx,rho,rad_length,-1);
2205 dx = 0.02; xin = xout; xout = xin + dx; rho = 1.45; rad_length = 44.86; // prepreg
2206 ppl = new AliTRDpropagationLayer(xin+dx/2,dx,rho,rad_length,-1);
2209 dx = 2.; xin = xout; xout = xin + dx; rho = 1.45*0.02; rad_length = 41.28; // Nomex
2210 steps = 5; dx = (xout - xin)/steps;
2211 for(Int_t i=0; i<steps; i++) {
2212 x = xin + i*dx + dx/2;
2213 ppl = new AliTRDpropagationLayer(x,dx,rho,rad_length,-1);
2217 dx = 0.02; xin = xout; xout = xin + dx; rho = 1.45; rad_length = 44.86; // prepreg
2218 ppl = new AliTRDpropagationLayer(xin+dx/2,dx,rho,rad_length,-1);
2221 dx = 50e-4; xin = xout; xout = xin + dx; rho = 1.71; rad_length = 44.77; // Tedlar
2222 ppl = new AliTRDpropagationLayer(xin+dx/2,dx,rho,rad_length,-1);
2226 // set time bins in CO2
2228 xin = xout; xout = 275.0;
2229 steps = 50; dx = (xout - xin)/steps;
2230 rho = 1.977e-3; rad_length = 36.2;
2232 for(Int_t i=0; i<steps; i++) {
2233 x = xin + i*dx + dx/2;
2234 ppl = new AliTRDpropagationLayer(x,dx,rho,rad_length,-1);
2238 // set time bins in the outer containment vessel
2240 dx = 50e-4; xin = xout; xout = xin + dx; rho = 2.7; rad_length = 24.01; // Al
2241 ppl = new AliTRDpropagationLayer(xin+dx/2,dx,rho,rad_length,-1);
2244 dx = 50e-4; xin = xout; xout = xin + dx; rho = 1.71; rad_length = 44.77; // Tedlar
2245 ppl = new AliTRDpropagationLayer(xin+dx/2,dx,rho,rad_length,-1);
2248 dx = 0.06; xin = xout; xout = xin + dx; rho = 1.45; rad_length = 44.86; // prepreg
2249 ppl = new AliTRDpropagationLayer(xin+dx/2,dx,rho,rad_length,-1);
2252 dx = 3.; xin = xout; xout = xin + dx; rho = 1.45*0.02; rad_length = 41.28; // Nomex
2253 steps = 10; dx = (xout - xin)/steps;
2254 for(Int_t i=0; i<steps; i++) {
2255 x = xin + i*dx + dx/2;
2256 ppl = new AliTRDpropagationLayer(x,dx,rho,rad_length,-1);
2260 dx = 0.06; xin = xout; xout = xin + dx; rho = 1.45; rad_length = 44.86; // prepreg
2261 ppl = new AliTRDpropagationLayer(xin+dx/2,dx,rho,rad_length,-1);
2264 dx = 50e-4; xin = xout; xout = xin + dx; rho = 1.71; rad_length = 44.77; // Tedlar
2265 ppl = new AliTRDpropagationLayer(xin+dx/2,dx,rho,rad_length,-1);
2268 dx = 50e-4; xin = xout; xout = xin + dx; rho = 2.7; rad_length = 24.01; // Al
2269 ppl = new AliTRDpropagationLayer(xin+dx/2,dx,rho,rad_length,-1);
2272 Double_t xtrd = (Double_t) fGeom->Rmin();
2274 // add layers between TPC and TRD (Air temporarily)
2275 xin = xout; xout = xtrd;
2276 steps = 50; dx = (xout - xin)/steps;
2277 rho = 1.2e-3; rad_length = 36.66;
2279 for(Int_t i=0; i<steps; i++) {
2280 x = xin + i*dx + dx/2;
2281 ppl = new AliTRDpropagationLayer(x,dx,rho,rad_length,-1);
2286 Double_t alpha=AliTRDgeometry::GetAlpha();
2288 // add layers for each of the planes
2290 Double_t dxRo = (Double_t) fGeom->CroHght(); // Rohacell
2291 Double_t dxSpace = (Double_t) fGeom->Cspace(); // Spacing between planes
2292 Double_t dxAmp = (Double_t) fGeom->CamHght(); // Amplification region
2293 Double_t dxDrift = (Double_t) fGeom->CdrHght(); // Drift region
2294 Double_t dxRad = (Double_t) fGeom->CraHght(); // Radiator
2295 Double_t dxTEC = dxRad + dxDrift + dxAmp + dxRo;
2296 Double_t dxPlane = dxTEC + dxSpace;
2299 const Int_t nChambers = AliTRDgeometry::Ncham();
2300 Double_t Ymax = 0, holeYmax = 0;
2301 Double_t * Zc = new Double_t[nChambers];
2302 Double_t * Zmax = new Double_t[nChambers];
2303 Double_t holeZmax = 1000.; // the whole sector is missing
2305 for(Int_t plane = 0; plane < AliTRDgeometry::Nplan(); plane++) {
2308 xin = xtrd + plane * dxPlane; xout = xin + dxRad;
2309 steps = 12; dx = (xout - xin)/steps; rho = 0.074; rad_length = 40.6;
2310 for(Int_t i=0; i<steps; i++) {
2311 x = xin + i*dx + dx/2;
2312 ppl = new AliTRDpropagationLayer(x,dx,rho,rad_length,-1);
2313 if((fGeom->GetPHOShole()) && (fGeomSector >= 2) && (fGeomSector <= 6)) {
2314 holeYmax = x*TMath::Tan(0.5*alpha);
2315 ppl->SetHole(holeYmax, holeZmax);
2317 if((fGeom->GetRICHhole()) && (fGeomSector >= 12) && (fGeomSector <= 14)) {
2318 holeYmax = x*TMath::Tan(0.5*alpha);
2319 ppl->SetHole(holeYmax, holeZmax);
2324 Ymax = fGeom->GetChamberWidth(plane)/2;
2325 for(Int_t ch = 0; ch < nChambers; ch++) {
2326 Zmax[ch] = fGeom->GetChamberLength(plane,ch)/2;
2327 Float_t pad = fPar->GetRowPadSize(plane,ch,0);
2328 Float_t row0 = fPar->GetRow0(plane,ch,0);
2329 Int_t nPads = fPar->GetRowMax(plane,ch,0);
2330 Zc[ch] = (pad * nPads)/2 + row0 - pad/2;
2333 dx = fPar->GetTimeBinSize();
2334 rho = 0.00295 * 0.85; rad_length = 11.0;
2336 Double_t x0 = (Double_t) fPar->GetTime0(plane);
2337 Double_t xbottom = x0 - dxDrift;
2338 Double_t xtop = x0 + dxAmp;
2340 // Amplification region
2342 steps = (Int_t) (dxAmp/dx);
2344 for(tb = 0; tb < steps; tb++) {
2345 x = x0 + tb * dx + dx/2;
2346 tb_index = CookTimeBinIndex(plane, -tb-1);
2347 ppl = new AliTRDpropagationLayer(x,dx,rho,rad_length,tb_index);
2349 for(Int_t ch = 0; ch < nChambers; ch++) {
2350 ppl->SetZmax(ch, Zc[ch], Zmax[ch]);
2352 if((fGeom->GetPHOShole()) && (fGeomSector >= 2) && (fGeomSector <= 6)) {
2353 holeYmax = x*TMath::Tan(0.5*alpha);
2354 ppl->SetHole(holeYmax, holeZmax);
2356 if((fGeom->GetRICHhole()) && (fGeomSector >= 12) && (fGeomSector <= 14)) {
2357 holeYmax = x*TMath::Tan(0.5*alpha);
2358 ppl->SetHole(holeYmax, holeZmax);
2362 tb_index = CookTimeBinIndex(plane, -steps);
2363 x = (x + dx/2 + xtop)/2;
2365 ppl = new AliTRDpropagationLayer(x,dx,rho,rad_length,tb_index);
2367 for(Int_t ch = 0; ch < nChambers; ch++) {
2368 ppl->SetZmax(ch, Zc[ch], Zmax[ch]);
2370 if((fGeom->GetPHOShole()) && (fGeomSector >= 2) && (fGeomSector <= 6)) {
2371 holeYmax = x*TMath::Tan(0.5*alpha);
2372 ppl->SetHole(holeYmax, holeZmax);
2374 if((fGeom->GetRICHhole()) && (fGeomSector >= 12) && (fGeomSector <= 14)) {
2375 holeYmax = x*TMath::Tan(0.5*alpha);
2376 ppl->SetHole(holeYmax, holeZmax);
2381 dx = fPar->GetTimeBinSize();
2382 steps = (Int_t) (dxDrift/dx);
2384 for(tb = 0; tb < steps; tb++) {
2385 x = x0 - tb * dx - dx/2;
2386 tb_index = CookTimeBinIndex(plane, tb);
2388 ppl = new AliTRDpropagationLayer(x,dx,rho,rad_length,tb_index);
2390 for(Int_t ch = 0; ch < nChambers; ch++) {
2391 ppl->SetZmax(ch, Zc[ch], Zmax[ch]);
2393 if((fGeom->GetPHOShole()) && (fGeomSector >= 2) && (fGeomSector <= 6)) {
2394 holeYmax = x*TMath::Tan(0.5*alpha);
2395 ppl->SetHole(holeYmax, holeZmax);
2397 if((fGeom->GetRICHhole()) && (fGeomSector >= 12) && (fGeomSector <= 14)) {
2398 holeYmax = x*TMath::Tan(0.5*alpha);
2399 ppl->SetHole(holeYmax, holeZmax);
2403 tb_index = CookTimeBinIndex(plane, steps);
2404 x = (x - dx/2 + xbottom)/2;
2406 ppl = new AliTRDpropagationLayer(x,dx,rho,rad_length,tb_index);
2408 for(Int_t ch = 0; ch < nChambers; ch++) {
2409 ppl->SetZmax(ch, Zc[ch], Zmax[ch]);
2411 if((fGeom->GetPHOShole()) && (fGeomSector >= 2) && (fGeomSector <= 6)) {
2412 holeYmax = x*TMath::Tan(0.5*alpha);
2413 ppl->SetHole(holeYmax, holeZmax);
2415 if((fGeom->GetRICHhole()) && (fGeomSector >= 12) && (fGeomSector <= 14)) {
2416 holeYmax = x*TMath::Tan(0.5*alpha);
2417 ppl->SetHole(holeYmax, holeZmax);
2422 xin = xtop; dx = 0.025; xout = xin + dx; rho = 1.7; rad_length = 33.0;
2423 ppl = new AliTRDpropagationLayer(xin+dx/2,dx,rho,rad_length,-1);
2424 if((fGeom->GetPHOShole()) && (fGeomSector >= 2) && (fGeomSector <= 6)) {
2425 holeYmax = (xin+dx/2)*TMath::Tan(0.5*alpha);
2426 ppl->SetHole(holeYmax, holeZmax);
2428 if((fGeom->GetRICHhole()) && (fGeomSector >= 12) && (fGeomSector <= 14)) {
2429 holeYmax = (xin+dx/2)*TMath::Tan(0.5*alpha);
2430 ppl->SetHole(holeYmax, holeZmax);
2435 xin = xout; xout = xtrd + (plane + 1) * dxPlane - dxSpace;
2436 steps = 5; dx = (xout - xin)/steps; rho = 0.074; rad_length = 40.6;
2437 for(Int_t i=0; i<steps; i++) {
2438 x = xin + i*dx + dx/2;
2439 ppl = new AliTRDpropagationLayer(x,dx,rho,rad_length,-1);
2440 if((fGeom->GetPHOShole()) && (fGeomSector >= 2) && (fGeomSector <= 6)) {
2441 holeYmax = x*TMath::Tan(0.5*alpha);
2442 ppl->SetHole(holeYmax, holeZmax);
2444 if((fGeom->GetRICHhole()) && (fGeomSector >= 12) && (fGeomSector <= 14)) {
2445 holeYmax = x*TMath::Tan(0.5*alpha);
2446 ppl->SetHole(holeYmax, holeZmax);
2451 // Space between the chambers, air
2452 xin = xout; xout = xtrd + (plane + 1) * dxPlane;
2453 steps = 5; dx = (xout - xin)/steps; rho = 1.29e-3; rad_length = 36.66;
2454 for(Int_t i=0; i<steps; i++) {
2455 x = xin + i*dx + dx/2;
2456 ppl = new AliTRDpropagationLayer(x,dx,rho,rad_length,-1);
2457 if((fGeom->GetPHOShole()) && (fGeomSector >= 2) && (fGeomSector <= 6)) {
2458 holeYmax = x*TMath::Tan(0.5*alpha);
2459 ppl->SetHole(holeYmax, holeZmax);
2461 if((fGeom->GetRICHhole()) && (fGeomSector >= 12) && (fGeomSector <= 14)) {
2462 holeYmax = x*TMath::Tan(0.5*alpha);
2463 ppl->SetHole(holeYmax, holeZmax);
2469 // Space between the TRD and RICH
2470 Double_t xRICH = 500.;
2471 xin = xout; xout = xRICH;
2472 steps = 200; dx = (xout - xin)/steps; rho = 1.29e-3; rad_length = 36.66;
2473 for(Int_t i=0; i<steps; i++) {
2474 x = xin + i*dx + dx/2;
2475 ppl = new AliTRDpropagationLayer(x,dx,rho,rad_length,-1);
2485 //______________________________________________________
2487 Int_t AliTRDtracker::AliTRDtrackingSector::CookTimeBinIndex(Int_t plane, Int_t local_tb) const
2490 // depending on the digitization parameters calculates "global"
2491 // time bin index for timebin <local_tb> in plane <plane>
2494 Double_t dxAmp = (Double_t) fGeom->CamHght(); // Amplification region
2495 Double_t dxDrift = (Double_t) fGeom->CdrHght(); // Drift region
2496 Double_t dx = (Double_t) fPar->GetTimeBinSize();
2498 Int_t tbAmp = fPar->GetTimeBefore();
2499 Int_t maxAmp = (Int_t) ((dxAmp+0.000001)/dx);
2500 if(kTRUE) maxAmp = 0; // intentional until we change parameter class
2501 Int_t tbDrift = fPar->GetTimeMax();
2502 Int_t maxDrift = (Int_t) ((dxDrift+0.000001)/dx);
2504 Int_t tb_per_plane = TMath::Min(tbAmp,maxAmp) + TMath::Min(tbDrift,maxDrift);
2506 Int_t gtb = (plane+1) * tb_per_plane - local_tb - 1 - TMath::Min(tbAmp,maxAmp);
2508 if((local_tb < 0) &&
2509 (TMath::Abs(local_tb) > TMath::Min(tbAmp,maxAmp))) return -1;
2510 if(local_tb >= TMath::Min(tbDrift,maxDrift)) return -1;
2517 //______________________________________________________
2519 void AliTRDtracker::AliTRDtrackingSector::MapTimeBinLayers()
2522 // For all sensitive time bins sets corresponding layer index
2523 // in the array fTimeBins
2528 for(Int_t i = 0; i < fN; i++) {
2529 index = fLayers[i]->GetTimeBinIndex();
2531 // printf("gtb %d -> pl %d -> x %f \n", index, i, fLayers[i]->GetX());
2533 if(index < 0) continue;
2534 if(index >= (Int_t) kMAX_TIME_BIN_INDEX) {
2535 printf("*** AliTRDtracker::MapTimeBinLayers: \n");
2536 printf(" index %d exceeds allowed maximum of %d!\n",
2537 index, kMAX_TIME_BIN_INDEX-1);
2540 fTimeBinIndex[index] = i;
2543 Double_t x1, dx1, x2, dx2, gap;
2545 for(Int_t i = 0; i < fN-1; i++) {
2546 x1 = fLayers[i]->GetX();
2547 dx1 = fLayers[i]->GetdX();
2548 x2 = fLayers[i+1]->GetX();
2549 dx2 = fLayers[i+1]->GetdX();
2550 gap = (x2 - dx2/2) - (x1 + dx1/2);
2552 printf("*** warning: layers %d and %d are overlayed:\n",i,i+1);
2553 printf(" %f + %f + %f > %f\n", x1, dx1/2, dx2/2, x2);
2556 printf("*** warning: layers %d and %d have a large gap:\n",i,i+1);
2557 printf(" (%f - %f) - (%f + %f) = %f\n",
2558 x2, dx2/2, x1, dx1, gap);
2564 //______________________________________________________
2567 Int_t AliTRDtracker::AliTRDtrackingSector::GetLayerNumber(Double_t x) const
2570 // Returns the number of time bin which in radial position is closest to <x>
2573 if(x >= fLayers[fN-1]->GetX()) return fN-1;
2574 if(x <= fLayers[0]->GetX()) return 0;
2576 Int_t b=0, e=fN-1, m=(b+e)/2;
2577 for (; b<e; m=(b+e)/2) {
2578 if (x > fLayers[m]->GetX()) b=m+1;
2581 if(TMath::Abs(x - fLayers[m]->GetX()) >
2582 TMath::Abs(x - fLayers[m+1]->GetX())) return m+1;
2587 //______________________________________________________
2589 Int_t AliTRDtracker::AliTRDtrackingSector::GetInnerTimeBin() const
2592 // Returns number of the innermost SENSITIVE propagation layer
2595 return GetLayerNumber(0);
2598 //______________________________________________________
2600 Int_t AliTRDtracker::AliTRDtrackingSector::GetOuterTimeBin() const
2603 // Returns number of the outermost SENSITIVE time bin
2606 return GetLayerNumber(GetNumberOfTimeBins() - 1);
2609 //______________________________________________________
2611 Int_t AliTRDtracker::AliTRDtrackingSector::GetNumberOfTimeBins() const
2614 // Returns number of SENSITIVE time bins
2618 for(tb = kMAX_TIME_BIN_INDEX-1; tb >=0; tb--) {
2619 layer = GetLayerNumber(tb);
2625 //______________________________________________________
2627 void AliTRDtracker::AliTRDtrackingSector::InsertLayer(AliTRDpropagationLayer* pl)
2630 // Insert layer <pl> in fLayers array.
2631 // Layers are sorted according to X coordinate.
2633 if ( fN == ((Int_t) kMAX_LAYERS_PER_SECTOR)) {
2634 printf("AliTRDtrackingSector::InsertLayer(): Too many layers !\n");
2637 if (fN==0) {fLayers[fN++] = pl; return;}
2638 Int_t i=Find(pl->GetX());
2640 memmove(fLayers+i+1 ,fLayers+i,(fN-i)*sizeof(AliTRDpropagationLayer*));
2641 fLayers[i]=pl; fN++;
2645 //______________________________________________________
2647 Int_t AliTRDtracker::AliTRDtrackingSector::Find(Double_t x) const
2650 // Returns index of the propagation layer nearest to X
2653 if (x <= fLayers[0]->GetX()) return 0;
2654 if (x > fLayers[fN-1]->GetX()) return fN;
2655 Int_t b=0, e=fN-1, m=(b+e)/2;
2656 for (; b<e; m=(b+e)/2) {
2657 if (x > fLayers[m]->GetX()) b=m+1;
2663 //______________________________________________________
2665 void AliTRDtracker::AliTRDpropagationLayer::GetPropagationParameters(
2666 Double_t y, Double_t z, Double_t &dx, Double_t &rho, Double_t &rad_length,
2667 Bool_t &lookForCluster) const
2670 // Returns radial step <dx>, density <rho>, rad. length <rad_length>,
2671 // and sensitivity <lookForCluster> in point <y,z>
2677 lookForCluster = kFALSE;
2679 // check dead regions
2680 if(fTimeBinIndex >= 0) {
2681 for(Int_t ch = 0; ch < (Int_t) kZONES; ch++) {
2682 if(TMath::Abs(z - fZc[ch]) < fZmax[ch])
2683 lookForCluster = kTRUE;
2684 // else { rho = 1.7; rad_length = 33.0; } // G10
2686 if(TMath::Abs(y) > fYmax) lookForCluster = kFALSE;
2687 if(!lookForCluster) {
2688 // rho = 1.7; rad_length = 33.0; // G10
2693 if(fHole && (TMath::Abs(y - fHoleYc) < fHoleYmax) &&
2694 (TMath::Abs(z - fHoleZc) < fHoleZmax)) {
2695 lookForCluster = kFALSE;
2697 rad_length = fHoleX0;
2703 //______________________________________________________
2705 void AliTRDtracker::AliTRDpropagationLayer::InsertCluster(AliTRDcluster* c,
2708 // Insert cluster in cluster array.
2709 // Clusters are sorted according to Y coordinate.
2711 if(fTimeBinIndex < 0) {
2712 printf("*** attempt to insert cluster into non-sensitive time bin!\n");
2716 if (fN== (Int_t) kMAX_CLUSTER_PER_TIME_BIN) {
2717 printf("AliTRDpropagationLayer::InsertCluster(): Too many clusters !\n");
2720 if (fN==0) {fIndex[0]=index; fClusters[fN++]=c; return;}
2721 Int_t i=Find(c->GetY());
2722 memmove(fClusters+i+1 ,fClusters+i,(fN-i)*sizeof(AliTRDcluster*));
2723 memmove(fIndex +i+1 ,fIndex +i,(fN-i)*sizeof(UInt_t));
2724 fIndex[i]=index; fClusters[i]=c; fN++;
2727 //______________________________________________________
2729 Int_t AliTRDtracker::AliTRDpropagationLayer::Find(Double_t y) const {
2731 // Returns index of the cluster nearest in Y
2733 if (y <= fClusters[0]->GetY()) return 0;
2734 if (y > fClusters[fN-1]->GetY()) return fN;
2735 Int_t b=0, e=fN-1, m=(b+e)/2;
2736 for (; b<e; m=(b+e)/2) {
2737 if (y > fClusters[m]->GetY()) b=m+1;
2743 //---------------------------------------------------------
2745 Double_t AliTRDtracker::GetTiltFactor(const AliTRDcluster* c) {
2747 // Returns correction factor for tilted pads geometry
2750 Double_t h01 = sin(TMath::Pi() / 180.0 * fPar->GetTiltingAngle());
2751 Int_t det = c->GetDetector();
2752 Int_t plane = fGeom->GetPlane(det);
2754 if((plane == 1) || (plane == 3) || (plane == 5)) h01=-h01;
2756 if(fNoTilt) h01 = 0;