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.27.2.2 2003/07/14 09:19:33 hristov
19 TOF included in the combined PID (Yu.Belikov)
21 Revision 1.27.2.1 2003/07/11 10:53:01 hristov
22 Inward refit for TPC and TRD in the ESD schema (T.Kuhr)
24 Revision 1.27 2003/05/27 17:46:13 hristov
25 TRD PID included in the ESD schema (T.Kuhr)
27 Revision 1.26 2003/04/10 10:36:54 hristov
28 Code for unified TPC/TRD tracking (S.Radomski)
30 Revision 1.25 2003/03/19 17:14:11 hristov
31 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)
33 Revision 1.24 2003/02/19 09:02:28 hristov
34 Track time measurement (S.Radomski)
36 Revision 1.23 2003/02/10 14:06:10 cblume
37 Add tracking without tilted pads as option
39 Revision 1.22 2003/01/30 15:19:58 cblume
42 Revision 1.21 2003/01/27 16:34:49 cblume
43 Update of tracking by Sergei and Chuncheng
45 Revision 1.20 2002/11/07 15:52:09 cblume
46 Update of tracking code for tilted pads
48 Revision 1.19 2002/10/22 15:53:08 alibrary
49 Introducing Riostream.h
51 Revision 1.18 2002/10/14 14:57:44 hristov
52 Merging the VirtualMC branch to the main development branch (HEAD)
54 Revision 1.14.6.2 2002/07/24 10:09:31 alibrary
57 Revision 1.17 2002/06/13 12:09:58 hristov
60 Revision 1.16 2002/06/12 09:54:36 cblume
61 Update of tracking code provided by Sergei
63 Revision 1.14 2001/11/14 10:50:46 cblume
64 Changes in digits IO. Add merging of summable digits
66 Revision 1.13 2001/05/30 12:17:47 hristov
67 Loop variables declared once
69 Revision 1.12 2001/05/28 17:07:58 hristov
70 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)
72 Revision 1.8 2000/12/20 13:00:44 cblume
73 Modifications for the HP-compiler
75 Revision 1.7 2000/12/08 16:07:02 cblume
76 Update of the tracking by Sergei
78 Revision 1.6 2000/11/30 17:38:08 cblume
79 Changes to get in line with new STEER and EVGEN
81 Revision 1.5 2000/11/14 14:40:27 cblume
82 Correction for the Sun compiler (kTRUE and kFALSE)
84 Revision 1.4 2000/11/10 14:57:52 cblume
85 Changes in the geometry constants for the DEC compiler
87 Revision 1.3 2000/10/15 23:40:01 cblume
90 Revision 1.2 2000/10/06 16:49:46 cblume
93 Revision 1.1.2.2 2000/10/04 16:34:58 cblume
94 Replace include files by forward declarations
96 Revision 1.1.2.1 2000/09/22 14:47:52 cblume
101 #include <Riostream.h>
106 #include <TObjArray.h>
108 #include "AliTRDgeometry.h"
109 #include "AliTRDparameter.h"
110 #include "AliTRDgeometryDetail.h"
111 #include "AliTRDcluster.h"
112 #include "AliTRDtrack.h"
113 #include "AliTRDPartID.h"
114 #include "../TPC/AliTPCtrack.h"
116 #include "AliTRDtracker.h"
118 ClassImp(AliTRDtracker)
120 const Float_t AliTRDtracker::fSeedDepth = 0.5;
121 const Float_t AliTRDtracker::fSeedStep = 0.10;
122 const Float_t AliTRDtracker::fSeedGap = 0.25;
124 const Float_t AliTRDtracker::fMaxSeedDeltaZ12 = 40.;
125 const Float_t AliTRDtracker::fMaxSeedDeltaZ = 25.;
126 const Float_t AliTRDtracker::fMaxSeedC = 0.0052;
127 const Float_t AliTRDtracker::fMaxSeedTan = 1.2;
128 const Float_t AliTRDtracker::fMaxSeedVertexZ = 150.;
130 const Double_t AliTRDtracker::fSeedErrorSY = 0.2;
131 const Double_t AliTRDtracker::fSeedErrorSY3 = 2.5;
132 const Double_t AliTRDtracker::fSeedErrorSZ = 0.1;
134 const Float_t AliTRDtracker::fMinClustersInSeed = 0.7;
136 const Float_t AliTRDtracker::fMinClustersInTrack = 0.5;
137 const Float_t AliTRDtracker::fMinFractionOfFoundClusters = 0.8;
139 const Float_t AliTRDtracker::fSkipDepth = 0.3;
140 const Float_t AliTRDtracker::fLabelFraction = 0.8;
141 const Float_t AliTRDtracker::fWideRoad = 20.;
143 const Double_t AliTRDtracker::fMaxChi2 = 12.;
145 const Int_t AliTRDtracker::kFirstPlane = 5;
146 const Int_t AliTRDtracker::kLastPlane = 17;
149 //____________________________________________________________________
150 AliTRDtracker::AliTRDtracker(const TFile *geomfile):AliTracker()
156 //Float_t fTzero = 0;
158 fAddTRDseeds = kFALSE;
162 TDirectory *savedir=gDirectory;
163 TFile *in=(TFile*)geomfile;
165 printf("AliTRDtracker::AliTRDtracker(): geometry file is not open!\n");
166 printf(" DETAIL TRD geometry and DEFAULT TRD parameter will be used\n");
171 fGeom = (AliTRDgeometry*) in->Get("TRDgeometry");
172 fPar = (AliTRDparameter*) in->Get("TRDparameter");
177 // fTzero = geo->GetT0();
178 printf("Found geometry version %d on file \n", fGeom->IsVersion());
181 printf("AliTRDtracker::AliTRDtracker(): can't find TRD geometry!\n");
182 printf("The DETAIL TRD geometry will be used\n");
183 fGeom = new AliTRDgeometryDetail();
187 printf("AliTRDtracker::AliTRDtracker(): can't find TRD parameter!\n");
188 printf("The DEFAULT TRD parameter will be used\n");
189 fPar = new AliTRDparameter();
196 // fGeom->SetT0(fTzero);
199 fClusters = new TObjArray(2000);
201 fSeeds = new TObjArray(2000);
203 fTracks = new TObjArray(1000);
205 for(Int_t geom_s = 0; geom_s < kTRACKING_SECTORS; geom_s++) {
206 Int_t tr_s = CookSectorIndex(geom_s);
207 fTrSec[tr_s] = new AliTRDtrackingSector(fGeom, geom_s, fPar);
210 Float_t tilt_angle = TMath::Abs(fPar->GetTiltingAngle());
211 if(tilt_angle < 0.1) {
218 if(fNoTilt && (tilt_angle > 0.1)) fSY2corr = fSY2corr + tilt_angle * 0.05;
221 // calculate max gap on track
223 Double_t dxAmp = (Double_t) fGeom->CamHght(); // Amplification region
224 Double_t dxDrift = (Double_t) fGeom->CdrHght(); // Drift region
226 Double_t dx = (Double_t) fPar->GetTimeBinSize();
227 Int_t tbAmp = fPar->GetTimeBefore();
228 Int_t maxAmp = (Int_t) ((dxAmp+0.000001)/dx);
229 if(kTRUE) maxAmp = 0; // intentional until we change the parameter class
230 Int_t tbDrift = fPar->GetTimeMax();
231 Int_t maxDrift = (Int_t) ((dxDrift+0.000001)/dx);
233 tbDrift = TMath::Min(tbDrift,maxDrift);
234 tbAmp = TMath::Min(tbAmp,maxAmp);
236 fTimeBinsPerPlane = tbAmp + tbDrift;
237 fMaxGap = (Int_t) (fTimeBinsPerPlane * fGeom->Nplan() * fSkipDepth);
242 // Barrel Tracks [SR, 03.04.2003]
252 //___________________________________________________________________
253 AliTRDtracker::~AliTRDtracker()
261 for(Int_t geom_s = 0; geom_s < kTRACKING_SECTORS; geom_s++) {
262 delete fTrSec[geom_s];
266 //_____________________________________________________________________
268 void AliTRDtracker::SetBarrelTree(const char *mode) {
273 if (!IsStoringBarrel()) return;
275 TDirectory *sav = gDirectory;
276 if (!fBarrelFile) fBarrelFile = new TFile("AliBarrelTracks.root", "UPDATE");
279 sprintf(buff, "BarrelTRD_%d_%s", GetEventNumber(), mode);
282 fBarrelTree = new TTree(buff, "Barrel TPC tracks");
284 Int_t nRefs = kLastPlane - kFirstPlane + 1;
286 if (!fBarrelArray) fBarrelArray = new TClonesArray("AliBarrelTrack", nRefs);
287 for(Int_t i=0; i<nRefs; i++) new((*fBarrelArray)[i]) AliBarrelTrack();
289 fBarrelTree->Branch("tracks", &fBarrelArray);
293 //_____________________________________________________________________
295 void AliTRDtracker::StoreBarrelTrack(AliTRDtrack *ps, Int_t refPlane, Int_t isIn) {
300 if (!IsStoringBarrel()) return;
302 static Int_t nClusters;
304 static Double_t chi2;
306 static Bool_t wasLast = kTRUE;
308 Int_t newClusters, newWrong;
313 fBarrelArray->Clear();
314 nClusters = nWrong = 0;
320 fBarrelTrack = (AliBarrelTrack*)(*fBarrelArray)[index++];
321 ps->GetBarrelTrack(fBarrelTrack);
323 newClusters = ps->GetNumberOfClusters() - nClusters;
324 newWrong = ps->GetNWrong() - nWrong;
325 newChi2 = ps->GetChi2() - chi2;
327 nClusters = ps->GetNumberOfClusters();
328 nWrong = ps->GetNWrong();
329 chi2 = ps->GetChi2();
331 if (refPlane != kLastPlane) {
332 fBarrelTrack->SetNClusters(newClusters, newChi2);
333 fBarrelTrack->SetNWrongClusters(newWrong);
338 fBarrelTrack->SetRefPlane(refPlane, isIn);
341 //_____________________________________________________________________
343 Bool_t AliTRDtracker::AdjustSector(AliTRDtrack *track) {
345 // Rotates the track when necessary
348 Double_t alpha = AliTRDgeometry::GetAlpha();
349 Double_t y = track->GetY();
350 Double_t ymax = track->GetX()*TMath::Tan(0.5*alpha);
352 //Int_t ns = AliTRDgeometry::kNsect;
353 //Int_t s=Int_t(track->GetAlpha()/alpha)%ns;
357 if (!track->Rotate(alpha)) return kFALSE;
358 } else if (y <-ymax) {
360 if (!track->Rotate(-alpha)) return kFALSE;
366 //_____________________________________________________________________
367 inline Double_t f1trd(Double_t x1,Double_t y1,
368 Double_t x2,Double_t y2,
369 Double_t x3,Double_t y3)
372 // Initial approximation of the track curvature
374 Double_t d=(x2-x1)*(y3-y2)-(x3-x2)*(y2-y1);
375 Double_t a=0.5*((y3-y2)*(y2*y2-y1*y1+x2*x2-x1*x1)-
376 (y2-y1)*(y3*y3-y2*y2+x3*x3-x2*x2));
377 Double_t b=0.5*((x2-x1)*(y3*y3-y2*y2+x3*x3-x2*x2)-
378 (x3-x2)*(y2*y2-y1*y1+x2*x2-x1*x1));
380 Double_t xr=TMath::Abs(d/(d*x1-a)), yr=d/(d*y1-b);
382 return -xr*yr/sqrt(xr*xr+yr*yr);
385 //_____________________________________________________________________
386 inline Double_t f2trd(Double_t x1,Double_t y1,
387 Double_t x2,Double_t y2,
388 Double_t x3,Double_t y3)
391 // Initial approximation of the track curvature times X coordinate
392 // of the center of curvature
395 Double_t d=(x2-x1)*(y3-y2)-(x3-x2)*(y2-y1);
396 Double_t a=0.5*((y3-y2)*(y2*y2-y1*y1+x2*x2-x1*x1)-
397 (y2-y1)*(y3*y3-y2*y2+x3*x3-x2*x2));
398 Double_t b=0.5*((x2-x1)*(y3*y3-y2*y2+x3*x3-x2*x2)-
399 (x3-x2)*(y2*y2-y1*y1+x2*x2-x1*x1));
401 Double_t xr=TMath::Abs(d/(d*x1-a)), yr=d/(d*y1-b);
403 return -a/(d*y1-b)*xr/sqrt(xr*xr+yr*yr);
406 //_____________________________________________________________________
407 inline Double_t f3trd(Double_t x1,Double_t y1,
408 Double_t x2,Double_t y2,
409 Double_t z1,Double_t z2)
412 // Initial approximation of the tangent of the track dip angle
415 return (z1 - z2)/sqrt((x1-x2)*(x1-x2)+(y1-y2)*(y1-y2));
418 //___________________________________________________________________
419 Int_t AliTRDtracker::Clusters2Tracks(const TFile *inp, TFile *out)
422 // Finds tracks within the TRD. File <inp> is expected to contain seeds
423 // at the outer part of the TRD. If <inp> is NULL, the seeds
424 // are found within the TRD if fAddTRDseeds is TRUE.
425 // The tracks are propagated to the innermost time bin
426 // of the TRD and stored in file <out>.
431 TDirectory *savedir=gDirectory;
435 if (!out->IsOpen()) {
436 cerr<<"AliTRDtracker::Clusters2Tracks(): output file is not open !\n";
440 sprintf(tname,"seedTRDtoTPC_%d",GetEventNumber());
441 TTree tpc_tree(tname,"Tree with seeds from TRD at outer TPC pad row");
442 AliTPCtrack *iotrack=0;
443 tpc_tree.Branch("tracks","AliTPCtrack",&iotrack,32000,0);
445 sprintf(tname,"TreeT%d_TRD",GetEventNumber());
446 TTree trd_tree(tname,"TRD tracks at inner TRD time bin");
447 AliTRDtrack *iotrack_trd=0;
448 trd_tree.Branch("tracks","AliTRDtrack",&iotrack_trd,32000,0);
450 Int_t timeBins = fTrSec[0]->GetNumberOfTimeBins();
451 Float_t foundMin = fMinClustersInTrack * timeBins;
454 TFile *in=(TFile*)inp;
457 "AliTRDtracker::Clusters2Tracks(): file with seeds is not open !\n";
458 cerr<<" ... going for seeds finding inside the TRD\n";
462 sprintf(tname,"TRDb_%d",GetEventNumber());
463 TTree *seedTree=(TTree*)in->Get(tname);
465 cerr<<"AliTRDtracker::Clusters2Tracks(): ";
466 cerr<<"can't get a tree with track seeds !\n";
469 AliTRDtrack *seed=new AliTRDtrack;
470 seedTree->SetBranchAddress("tracks",&seed);
472 Int_t n=(Int_t)seedTree->GetEntries();
473 for (Int_t i=0; i<n; i++) {
474 seedTree->GetEvent(i);
475 seed->ResetCovariance();
476 AliTRDtrack *tr = new AliTRDtrack(*seed,seed->GetAlpha());
488 // find tracks from loaded seeds
490 Int_t nseed=fSeeds->GetEntriesFast();
492 Int_t innerTB = fTrSec[0]->GetInnerTimeBin();
494 for (i=0; i<nseed; i++) {
495 AliTRDtrack *pt=(AliTRDtrack*)fSeeds->UncheckedAt(i), &t=*pt;
496 FollowProlongation(t, innerTB);
497 if (t.GetNumberOfClusters() >= foundMin) {
499 CookLabel(pt, 1-fLabelFraction);
505 // cout<<found<<'\r';
507 if(PropagateToTPC(t)) {
508 AliTPCtrack *tpc = new AliTPCtrack(*pt,pt->GetAlpha());
513 delete fSeeds->RemoveAt(i);
517 cout<<"Number of loaded seeds: "<<nseed<<endl;
518 cout<<"Number of found tracks from loaded seeds: "<<found<<endl;
520 // after tracks from loaded seeds are found and the corresponding
521 // clusters are used, look for additional seeds from TRD
524 // Find tracks for the seeds in the TRD
525 Int_t timeBins = fTrSec[0]->GetNumberOfTimeBins();
527 Int_t nSteps = (Int_t) (fSeedDepth / fSeedStep);
528 Int_t gap = (Int_t) (timeBins * fSeedGap);
529 Int_t step = (Int_t) (timeBins * fSeedStep);
531 // make a first turn with tight cut on initial curvature
532 for(Int_t turn = 1; turn <= 2; turn++) {
534 nSteps = (Int_t) (fSeedDepth / (3*fSeedStep));
535 step = (Int_t) (timeBins * (3*fSeedStep));
537 for(Int_t i=0; i<nSteps; i++) {
538 Int_t outer=timeBins-1-i*step;
539 Int_t inner=outer-gap;
541 nseed=fSeeds->GetEntriesFast();
543 MakeSeeds(inner, outer, turn);
545 nseed=fSeeds->GetEntriesFast();
546 printf("\n turn %d, step %d: number of seeds for TRD inward %d\n",
549 for (Int_t i=0; i<nseed; i++) {
550 AliTRDtrack *pt=(AliTRDtrack*)fSeeds->UncheckedAt(i), &t=*pt;
551 FollowProlongation(t,innerTB);
552 if (t.GetNumberOfClusters() >= foundMin) {
554 CookLabel(pt, 1-fLabelFraction);
557 // cout<<found<<'\r';
560 if(PropagateToTPC(t)) {
561 AliTPCtrack *tpc = new AliTPCtrack(*pt,pt->GetAlpha());
567 delete fSeeds->RemoveAt(i);
576 cout<<"Total number of found tracks: "<<found<<endl;
585 //___________________________________________________________________
586 Int_t AliTRDtracker::Clusters2Tracks(AliESD* event)
589 // Finds tracks within the TRD. The ESD event is expected to contain seeds
590 // at the outer part of the TRD. The seeds
591 // are found within the TRD if fAddTRDseeds is TRUE.
592 // The tracks are propagated to the innermost time bin
593 // of the TRD and the ESD event is updated
596 Int_t timeBins = fTrSec[0]->GetNumberOfTimeBins();
597 Float_t foundMin = fMinClustersInTrack * timeBins;
600 Int_t innerTB = fTrSec[0]->GetInnerTimeBin();
602 Int_t n = event->GetNumberOfTracks();
603 for (Int_t i=0; i<n; i++) {
604 AliESDtrack* seed=event->GetTrack(i);
605 ULong_t status=seed->GetStatus();
606 if ( (status & AliESDtrack::kTRDout ) == 0 ) continue;
607 if ( (status & AliESDtrack::kTRDin) != 0 ) continue;
610 AliTRDtrack* seed2 = new AliTRDtrack(*seed);
611 seed2->ResetCovariance();
612 AliTRDtrack *pt = new AliTRDtrack(*seed2,seed2->GetAlpha());
614 FollowProlongation(t, innerTB);
615 if (t.GetNumberOfClusters() >= foundMin) {
617 CookLabel(pt, 1-fLabelFraction);
621 // cout<<found<<'\r';
623 if(PropagateToTPC(t)) {
624 seed->UpdateTrackParams(pt, AliESDtrack::kTRDin);
630 cout<<"Number of loaded seeds: "<<nseed<<endl;
631 cout<<"Number of found tracks from loaded seeds: "<<found<<endl;
633 // after tracks from loaded seeds are found and the corresponding
634 // clusters are used, look for additional seeds from TRD
637 // Find tracks for the seeds in the TRD
638 Int_t timeBins = fTrSec[0]->GetNumberOfTimeBins();
640 Int_t nSteps = (Int_t) (fSeedDepth / fSeedStep);
641 Int_t gap = (Int_t) (timeBins * fSeedGap);
642 Int_t step = (Int_t) (timeBins * fSeedStep);
644 // make a first turn with tight cut on initial curvature
645 for(Int_t turn = 1; turn <= 2; turn++) {
647 nSteps = (Int_t) (fSeedDepth / (3*fSeedStep));
648 step = (Int_t) (timeBins * (3*fSeedStep));
650 for(Int_t i=0; i<nSteps; i++) {
651 Int_t outer=timeBins-1-i*step;
652 Int_t inner=outer-gap;
654 nseed=fSeeds->GetEntriesFast();
656 MakeSeeds(inner, outer, turn);
658 nseed=fSeeds->GetEntriesFast();
659 printf("\n turn %d, step %d: number of seeds for TRD inward %d\n",
662 for (Int_t i=0; i<nseed; i++) {
663 AliTRDtrack *pt=(AliTRDtrack*)fSeeds->UncheckedAt(i), &t=*pt;
664 FollowProlongation(t,innerTB);
665 if (t.GetNumberOfClusters() >= foundMin) {
667 CookLabel(pt, 1-fLabelFraction);
670 // cout<<found<<'\r';
671 if(PropagateToTPC(t)) {
673 track.UpdateTrackParams(pt,AliESDtrack::kTRDin);
674 event->AddTrack(&track);
677 delete fSeeds->RemoveAt(i);
684 cout<<"Total number of found tracks: "<<found<<endl;
691 //_____________________________________________________________________________
692 Int_t AliTRDtracker::PropagateBack(const TFile *inp, TFile *out) {
694 // Reads seeds from file <inp>. The seeds are AliTPCtrack's found and
695 // backpropagated by the TPC tracker. Each seed is first propagated
696 // to the TRD, and then its prolongation is searched in the TRD.
697 // If sufficiently long continuation of the track is found in the TRD
698 // the track is updated, otherwise it's stored as originaly defined
699 // by the TPC tracker.
704 TDirectory *savedir=gDirectory;
706 TFile *in=(TFile*)inp;
709 cerr<<"AliTRDtracker::PropagateBack(): ";
710 cerr<<"file with back propagated TPC tracks is not open !\n";
714 if (!out->IsOpen()) {
715 cerr<<"AliTRDtracker::PropagateBack(): ";
716 cerr<<"file for back propagated TRD tracks is not open !\n";
722 sprintf(tname,"seedsTPCtoTRD_%d",GetEventNumber());
723 TTree *seedTree=(TTree*)in->Get(tname);
725 cerr<<"AliTRDtracker::PropagateBack(): ";
726 cerr<<"can't get a tree with seeds from TPC !\n";
727 cerr<<"check if your version of TPC tracker creates tree "<<tname<<"\n";
731 AliTPCtrack *seed=new AliTPCtrack;
732 seedTree->SetBranchAddress("tracks",&seed);
734 Int_t n=(Int_t)seedTree->GetEntries();
735 for (Int_t i=0; i<n; i++) {
736 seedTree->GetEvent(i);
737 Int_t lbl = seed->GetLabel();
738 AliTRDtrack *tr = new AliTRDtrack(*seed,seed->GetAlpha());
739 tr->SetSeedLabel(lbl);
749 AliTPCtrack *otrack=0;
751 sprintf(tname,"seedsTRDtoTOF1_%d",GetEventNumber());
752 TTree tofTree1(tname,"Tracks back propagated through TPC and TRD");
753 tofTree1.Branch("tracks","AliTPCtrack",&otrack,32000,0);
755 sprintf(tname,"seedsTRDtoTOF2_%d",GetEventNumber());
756 TTree tofTree2(tname,"Tracks back propagated through TPC and TRD");
757 tofTree2.Branch("tracks","AliTPCtrack",&otrack,32000,0);
759 sprintf(tname,"seedsTRDtoPHOS_%d",GetEventNumber());
760 TTree phosTree(tname,"Tracks back propagated through TPC and TRD");
761 phosTree.Branch("tracks","AliTPCtrack",&otrack,32000,0);
763 sprintf(tname,"seedsTRDtoRICH_%d",GetEventNumber());
764 TTree richTree(tname,"Tracks back propagated through TPC and TRD");
765 richTree.Branch("tracks","AliTPCtrack",&otrack,32000,0);
767 sprintf(tname,"TRDb_%d",GetEventNumber());
768 TTree trdTree(tname,"Back propagated TRD tracks at outer TRD time bin");
769 AliTRDtrack *otrack_trd=0;
770 trdTree.Branch("tracks","AliTRDtrack",&otrack_trd,32000,0);
772 if (IsStoringBarrel()) SetBarrelTree("back");
776 Int_t nseed=fSeeds->GetEntriesFast();
778 // Float_t foundMin = fMinClustersInTrack * fTimeBinsPerPlane * fGeom->Nplan();
779 Float_t foundMin = 40;
781 Int_t outermost_tb = fTrSec[0]->GetOuterTimeBin();
783 for (Int_t i=0; i<nseed; i++) {
785 AliTRDtrack *ps=(AliTRDtrack*)fSeeds->UncheckedAt(i), &s=*ps;
786 Int_t expectedClr = FollowBackProlongation(s);
788 if (IsStoringBarrel()) {
789 StoreBarrelTrack(ps, kLastPlane, kTrackBack);
793 Int_t foundClr = s.GetNumberOfClusters();
794 Int_t last_tb = fTrSec[0]->GetLayerNumber(s.GetX());
796 // printf("seed %d: found %d out of %d expected clusters, Min is %f\n",
797 // i, foundClr, expectedClr, foundMin);
799 if (foundClr >= foundMin) {
802 CookLabel(ps, 1-fLabelFraction);
806 // Propagate to outer reference plane [SR, GSI, 18.02.2003]
807 ps->PropagateTo(364.8);
811 // cout<<found<<'\r';
814 if(((expectedClr < 10) && (last_tb == outermost_tb)) ||
815 ((expectedClr >= 10) &&
816 (((Float_t) foundClr) / ((Float_t) expectedClr) >=
817 fMinFractionOfFoundClusters) && (last_tb == outermost_tb))) {
819 Double_t x_tof = 375.5;
821 if(PropagateToOuterPlane(s,x_tof)) {
822 AliTPCtrack *pt = new AliTPCtrack(*ps,ps->GetAlpha());
829 if(PropagateToOuterPlane(s,x_tof)) {
830 AliTPCtrack *pt = new AliTPCtrack(*ps,ps->GetAlpha());
835 Double_t x_phos = 460.;
837 if(PropagateToOuterPlane(s,x_phos)) {
838 AliTPCtrack *pt = new AliTPCtrack(*ps,ps->GetAlpha());
843 Double_t x_rich = 490+1.267;
845 if(PropagateToOuterPlane(s,x_rich)) {
846 AliTPCtrack *pt = new AliTPCtrack(*ps,ps->GetAlpha());
865 if (IsStoringBarrel()) { // [SR, 03.04.2003]
867 fBarrelTree->Write();
868 fBarrelFile->Flush();
872 cerr<<"Number of seeds: "<<nseed<<endl;
873 cerr<<"Number of back propagated TRD tracks: "<<found<<endl;
881 //_____________________________________________________________________________
882 Int_t AliTRDtracker::PropagateBack(AliESD* event) {
884 // Gets seeds from ESD event. The seeds are AliTPCtrack's found and
885 // backpropagated by the TPC tracker. Each seed is first propagated
886 // to the TRD, and then its prolongation is searched in the TRD.
887 // If sufficiently long continuation of the track is found in the TRD
888 // the track is updated, otherwise it's stored as originaly defined
889 // by the TPC tracker.
893 Float_t foundMin = 40;
895 Int_t n = event->GetNumberOfTracks();
896 for (Int_t i=0; i<n; i++) {
897 AliESDtrack* seed=event->GetTrack(i);
898 ULong_t status=seed->GetStatus();
899 if ( (status & AliESDtrack::kTPCout ) == 0 ) continue;
900 if ( (status & AliESDtrack::kTRDout) != 0 ) continue;
902 Int_t lbl = seed->GetLabel();
903 AliTRDtrack *track = new AliTRDtrack(*seed);
904 track->SetSeedLabel(lbl);
907 /*Int_t expectedClr = */FollowBackProlongation(*track);
909 Int_t foundClr = track->GetNumberOfClusters();
910 if (foundClr >= foundMin) {
913 // CookLabel(track, 1-fLabelFraction);
917 // Propagate to outer reference plane [SR, GSI, 18.02.2003]
918 // track->PropagateTo(364.8); why?
920 //seed->UpdateTrackParams(track, AliESDtrack::kTRDout);
924 if (track->PropagateTo(376.)) { //Propagation to the TOF (I.Belikov)
925 seed->UpdateTrackParams(track, AliESDtrack::kTRDout);
931 cerr<<"Number of seeds: "<<fNseeds<<endl;
932 cerr<<"Number of back propagated TRD tracks: "<<found<<endl;
939 //---------------------------------------------------------------------------
940 Int_t AliTRDtracker::FollowProlongation(AliTRDtrack& t, Int_t rf)
942 // Starting from current position on track=t this function tries
943 // to extrapolate the track up to timeBin=0 and to confirm prolongation
944 // if a close cluster is found. Returns the number of clusters
945 // expected to be found in sensitive layers
947 Float_t wIndex, wTB, wChi2;
948 Float_t wYrt, wYclosest, wYcorrect, wYwindow;
949 Float_t wZrt, wZclosest, wZcorrect, wZwindow;
950 Float_t wPx, wPy, wPz, wC;
952 Float_t wSigmaC2, wSigmaTgl2, wSigmaY2, wSigmaZ2;
954 Int_t trackIndex = t.GetLabel();
956 Int_t ns=Int_t(2*TMath::Pi()/AliTRDgeometry::GetAlpha()+0.5);
958 Int_t try_again=fMaxGap;
960 Double_t alpha=t.GetAlpha();
961 alpha = TVector2::Phi_0_2pi(alpha);
963 Int_t s=Int_t(alpha/AliTRDgeometry::GetAlpha())%AliTRDgeometry::kNsect;
964 Double_t rad_length, rho, x, dx, y, ymax, z;
966 Int_t expectedNumberOfClusters = 0;
967 Bool_t lookForCluster;
969 alpha=AliTRDgeometry::GetAlpha(); // note: change in meaning
972 for (Int_t nr=fTrSec[0]->GetLayerNumber(t.GetX()); nr>rf; nr--) {
974 y = t.GetY(); z = t.GetZ();
976 // first propagate to the inner surface of the current time bin
977 fTrSec[s]->GetLayer(nr)->GetPropagationParameters(y,z,dx,rho,rad_length,lookForCluster);
978 x = fTrSec[s]->GetLayer(nr)->GetX()-dx/2; y = t.GetY(); z = t.GetZ();
979 if(!t.PropagateTo(x,rad_length,rho)) break;
981 ymax = x*TMath::Tan(0.5*alpha);
984 if (!t.Rotate(alpha)) break;
985 if(!t.PropagateTo(x,rad_length,rho)) break;
986 } else if (y <-ymax) {
988 if (!t.Rotate(-alpha)) break;
989 if(!t.PropagateTo(x,rad_length,rho)) break;
992 y = t.GetY(); z = t.GetZ();
994 // now propagate to the middle plane of the next time bin
995 fTrSec[s]->GetLayer(nr-1)->GetPropagationParameters(y,z,dx,rho,rad_length,lookForCluster);
996 x = fTrSec[s]->GetLayer(nr-1)->GetX(); y = t.GetY(); z = t.GetZ();
997 if(!t.PropagateTo(x,rad_length,rho)) break;
999 ymax = x*TMath::Tan(0.5*alpha);
1002 if (!t.Rotate(alpha)) break;
1003 if(!t.PropagateTo(x,rad_length,rho)) break;
1004 } else if (y <-ymax) {
1006 if (!t.Rotate(-alpha)) break;
1007 if(!t.PropagateTo(x,rad_length,rho)) break;
1011 if(lookForCluster) {
1013 expectedNumberOfClusters++;
1014 wIndex = (Float_t) t.GetLabel();
1017 AliTRDpropagationLayer& time_bin=*(fTrSec[s]->GetLayer(nr-1));
1019 Double_t sy2=ExpectedSigmaY2(x,t.GetTgl(),t.GetPt());
1020 Double_t sz2=ExpectedSigmaZ2(x,t.GetTgl());
1023 if((t.GetSigmaY2() + sy2) > 0) road=10.*sqrt(t.GetSigmaY2() + sy2);
1024 else return expectedNumberOfClusters;
1028 wYwindow = (Float_t) road;
1029 t.GetPxPyPz(Px,Py,Pz);
1033 wC = (Float_t) t.GetC();
1034 wSigmaC2 = (Float_t) t.GetSigmaC2();
1035 wSigmaTgl2 = (Float_t) t.GetSigmaTgl2();
1036 wSigmaY2 = (Float_t) t.GetSigmaY2();
1037 wSigmaZ2 = (Float_t) t.GetSigmaZ2();
1040 if (road>fWideRoad) {
1041 if (t.GetNumberOfClusters()>4)
1042 cerr<<t.GetNumberOfClusters()
1043 <<"FindProlongation warning: Too broad road !\n";
1047 AliTRDcluster *cl=0;
1050 Double_t max_chi2=fMaxChi2;
1052 wYclosest = 12345678;
1053 wYcorrect = 12345678;
1054 wZclosest = 12345678;
1055 wZcorrect = 12345678;
1056 wZwindow = TMath::Sqrt(2.25 * 12 * sz2);
1058 // Find the closest correct cluster for debugging purposes
1060 Float_t minDY = 1000000;
1061 for (Int_t i=0; i<time_bin; i++) {
1062 AliTRDcluster* c=(AliTRDcluster*)(time_bin[i]);
1063 if((c->GetLabel(0) != trackIndex) &&
1064 (c->GetLabel(1) != trackIndex) &&
1065 (c->GetLabel(2) != trackIndex)) continue;
1066 if(TMath::Abs(c->GetY() - y) > minDY) continue;
1067 minDY = TMath::Abs(c->GetY() - y);
1068 wYcorrect = c->GetY();
1069 wZcorrect = c->GetZ();
1071 Double_t h01 = GetTiltFactor(c);
1072 wChi2 = t.GetPredictedChi2(c, h01);
1076 // Now go for the real cluster search
1080 for (Int_t i=time_bin.Find(y-road); i<time_bin; i++) {
1081 AliTRDcluster* c=(AliTRDcluster*)(time_bin[i]);
1082 if (c->GetY() > y+road) break;
1083 if (c->IsUsed() > 0) continue;
1084 if((c->GetZ()-z)*(c->GetZ()-z) > 3 * sz2) continue;
1086 Double_t h01 = GetTiltFactor(c);
1087 Double_t chi2=t.GetPredictedChi2(c,h01);
1089 if (chi2 > max_chi2) continue;
1092 index=time_bin.GetIndex(i);
1097 for (Int_t i=time_bin.Find(y-road); i<time_bin; i++) {
1098 AliTRDcluster* c=(AliTRDcluster*)(time_bin[i]);
1100 if (c->GetY() > y+road) break;
1101 if (c->IsUsed() > 0) continue;
1102 if((c->GetZ()-z)*(c->GetZ()-z) > 12 * sz2) continue;
1104 Double_t h01 = GetTiltFactor(c);
1105 Double_t chi2=t.GetPredictedChi2(c, h01);
1107 if (chi2 > max_chi2) continue;
1110 index=time_bin.GetIndex(i);
1116 wYclosest = cl->GetY();
1117 wZclosest = cl->GetZ();
1118 Double_t h01 = GetTiltFactor(cl);
1120 t.SetSampledEdx(cl->GetQ()/dx,t.GetNumberOfClusters());
1121 if(!t.Update(cl,max_chi2,index,h01)) {
1122 if(!try_again--) return 0;
1124 else try_again=fMaxGap;
1127 if (try_again==0) break;
1132 if((((Int_t) wTB)%15 == 0) || (((Int_t) wTB)%15 == 14)) {
1134 printf(" %f", wIndex); //1
1135 printf(" %f", wTB); //2
1136 printf(" %f", wYrt); //3
1137 printf(" %f", wYclosest); //4
1138 printf(" %f", wYcorrect); //5
1139 printf(" %f", wYwindow); //6
1140 printf(" %f", wZrt); //7
1141 printf(" %f", wZclosest); //8
1142 printf(" %f", wZcorrect); //9
1143 printf(" %f", wZwindow); //10
1144 printf(" %f", wPx); //11
1145 printf(" %f", wPy); //12
1146 printf(" %f", wPz); //13
1147 printf(" %f", wSigmaC2*1000000); //14
1148 printf(" %f", wSigmaTgl2*1000); //15
1149 printf(" %f", wSigmaY2); //16
1150 // printf(" %f", wSigmaZ2); //17
1151 printf(" %f", wChi2); //17
1152 printf(" %f", wC); //18
1159 return expectedNumberOfClusters;
1164 //___________________________________________________________________
1166 Int_t AliTRDtracker::FollowBackProlongation(AliTRDtrack& t)
1168 // Starting from current radial position of track <t> this function
1169 // extrapolates the track up to outer timebin and in the sensitive
1170 // layers confirms prolongation if a close cluster is found.
1171 // Returns the number of clusters expected to be found in sensitive layers
1173 Float_t wIndex, wTB, wChi2;
1174 Float_t wYrt, wYclosest, wYcorrect, wYwindow;
1175 Float_t wZrt, wZclosest, wZcorrect, wZwindow;
1176 Float_t wPx, wPy, wPz, wC;
1177 Double_t Px, Py, Pz;
1178 Float_t wSigmaC2, wSigmaTgl2, wSigmaY2, wSigmaZ2;
1180 Int_t trackIndex = t.GetLabel();
1181 Int_t try_again=fMaxGap;
1183 Double_t alpha=t.GetAlpha();
1184 TVector2::Phi_0_2pi(alpha);
1188 Int_t outerTB = fTrSec[0]->GetOuterTimeBin();
1189 Double_t rad_length, rho, x, dx, y, ymax = 0, z;
1190 Bool_t lookForCluster;
1192 Int_t expectedNumberOfClusters = 0;
1195 alpha=AliTRDgeometry::GetAlpha(); // note: change in meaning
1197 Int_t nRefPlane = kFirstPlane;
1198 Bool_t isNewLayer = kFALSE;
1203 for (Int_t nr=fTrSec[0]->GetLayerNumber(t.GetX()); nr<outerTB+1; nr++) {
1208 // first propagate to the outer surface of the current time bin
1211 fTrSec[s]->GetLayer(nr)->GetPropagationParameters(y,z,dx,rho,rad_length,lookForCluster);
1212 x = fTrSec[s]->GetLayer(nr)->GetX()+dx/2;
1216 if(!t.PropagateTo(x,rad_length,rho)) break;
1217 if (!AdjustSector(&t)) break;
1219 if (!t.PropagateTo(x,rad_length,rho)) break;
1224 // Barrel Tracks [SR, 04.04.2003]
1227 if (fTrSec[s]->GetLayer(nr)->IsSensitive() !=
1228 fTrSec[s]->GetLayer(nr+1)->IsSensitive() ) {
1230 // if (IsStoringBarrel()) StoreBarrelTrack(&t, nRefPlane++, kTrackBack);
1233 if (fTrSec[s]->GetLayer(nr-1)->IsSensitive() &&
1234 ! fTrSec[s]->GetLayer(nr)->IsSensitive()) {
1236 } else {isNewLayer = kFALSE;}
1241 // now propagate to the middle plane of the next time bin
1242 fTrSec[s]->GetLayer(nr+1)->GetPropagationParameters(y,z,dx,rho,rad_length,lookForCluster);
1244 x = fTrSec[s]->GetLayer(nr+1)->GetX();
1245 if(!t.PropagateTo(x,rad_length,rho)) break;
1246 if (!AdjustSector(&t)) break;
1248 if(!t.PropagateTo(x,rad_length,rho)) break;
1253 if(fVocal) printf("nr+1=%d, x %f, z %f, y %f, ymax %f\n",nr+1,x,z,y,ymax);
1254 // printf("label %d, pl %d, lookForCluster %d \n",
1255 // trackIndex, nr+1, lookForCluster);
1257 if(lookForCluster) {
1258 expectedNumberOfClusters++;
1260 wIndex = (Float_t) t.GetLabel();
1261 wTB = fTrSec[s]->GetLayer(nr+1)->GetTimeBinIndex();
1263 AliTRDpropagationLayer& time_bin=*(fTrSec[s]->GetLayer(nr+1));
1264 Double_t sy2=ExpectedSigmaY2(t.GetX(),t.GetTgl(),t.GetPt());
1265 Double_t sz2=ExpectedSigmaZ2(t.GetX(),t.GetTgl());
1266 if((t.GetSigmaY2() + sy2) < 0) break;
1267 Double_t road = 10.*sqrt(t.GetSigmaY2() + sy2);
1268 Double_t y=t.GetY(), z=t.GetZ();
1272 wYwindow = (Float_t) road;
1273 t.GetPxPyPz(Px,Py,Pz);
1277 wC = (Float_t) t.GetC();
1278 wSigmaC2 = (Float_t) t.GetSigmaC2();
1279 wSigmaTgl2 = (Float_t) t.GetSigmaTgl2();
1280 wSigmaY2 = (Float_t) t.GetSigmaY2();
1281 wSigmaZ2 = (Float_t) t.GetSigmaZ2();
1284 if (road>fWideRoad) {
1285 if (t.GetNumberOfClusters()>4)
1286 cerr<<t.GetNumberOfClusters()
1287 <<"FindProlongation warning: Too broad road !\n";
1291 AliTRDcluster *cl=0;
1294 Double_t max_chi2=fMaxChi2;
1299 max_chi2 = 10 * fMaxChi2;
1302 if (nRefPlane == kFirstPlane) max_chi2 = 20 * fMaxChi2;
1303 if (nRefPlane == kFirstPlane+2) max_chi2 = 15 * fMaxChi2;
1304 if (t.GetNRotate() > 0) max_chi2 = 3 * max_chi2;
1307 wYclosest = 12345678;
1308 wYcorrect = 12345678;
1309 wZclosest = 12345678;
1310 wZcorrect = 12345678;
1311 wZwindow = TMath::Sqrt(2.25 * 12 * sz2);
1313 // Find the closest correct cluster for debugging purposes
1316 for (Int_t i=0; i<time_bin; i++) {
1317 AliTRDcluster* c=(AliTRDcluster*)(time_bin[i]);
1318 if((c->GetLabel(0) != trackIndex) &&
1319 (c->GetLabel(1) != trackIndex) &&
1320 (c->GetLabel(2) != trackIndex)) continue;
1321 if(TMath::Abs(c->GetY() - y) > minDY) continue;
1322 //minDY = TMath::Abs(c->GetY() - y);
1323 minDY = c->GetY() - y;
1324 wYcorrect = c->GetY();
1325 wZcorrect = c->GetZ();
1327 Double_t h01 = GetTiltFactor(c);
1328 wChi2 = t.GetPredictedChi2(c, h01);
1332 // Now go for the real cluster search
1336 for (Int_t i=time_bin.Find(y-road); i<time_bin; i++) {
1337 AliTRDcluster* c=(AliTRDcluster*)(time_bin[i]);
1338 if (c->GetY() > y+road) break;
1339 if (c->IsUsed() > 0) continue;
1340 if((c->GetZ()-z)*(c->GetZ()-z) > 3 * sz2) continue;
1342 Double_t h01 = GetTiltFactor(c);
1343 chi2=t.GetPredictedChi2(c,h01);
1345 if (chi2 > max_chi2) continue;
1348 index=time_bin.GetIndex(i);
1351 if((c->GetLabel(0) != trackIndex) &&
1352 (c->GetLabel(1) != trackIndex) &&
1353 (c->GetLabel(2) != trackIndex)) t.AddNWrong();
1358 for (Int_t i=time_bin.Find(y-road); i<time_bin; i++) {
1359 AliTRDcluster* c=(AliTRDcluster*)(time_bin[i]);
1361 if (c->GetY() > y+road) break;
1362 if (c->IsUsed() > 0) continue;
1363 if((c->GetZ()-z)*(c->GetZ()-z) > 2.25 * 12 * sz2) continue;
1365 Double_t h01 = GetTiltFactor(c);
1366 chi2=t.GetPredictedChi2(c,h01);
1368 if (chi2 > max_chi2) continue;
1371 index=time_bin.GetIndex(i);
1376 wYclosest = cl->GetY();
1377 wZclosest = cl->GetZ();
1379 t.SetSampledEdx(cl->GetQ()/dx,t.GetNumberOfClusters());
1380 Double_t h01 = GetTiltFactor(cl);
1381 if(!t.Update(cl,max_chi2,index,h01)) {
1382 if(!try_again--) return 0;
1384 else try_again=fMaxGap;
1387 if (try_again==0) break;
1390 //if (minDY < 1000000 && isNewLayer)
1391 //cout << "\t" << nRefPlane << "\t" << "\t" << t.GetNRotate() << "\t" <<
1392 // road << "\t" << minDY << "\t" << chi2 << "\t" << wChi2 << "\t" << max_chi2 << endl;
1396 isNewLayer = kFALSE;
1399 if((((Int_t) wTB)%15 == 0) || (((Int_t) wTB)%15 == 14)) {
1401 printf(" %f", wIndex); //1
1402 printf(" %f", wTB); //2
1403 printf(" %f", wYrt); //3
1404 printf(" %f", wYclosest); //4
1405 printf(" %f", wYcorrect); //5
1406 printf(" %f", wYwindow); //6
1407 printf(" %f", wZrt); //7
1408 printf(" %f", wZclosest); //8
1409 printf(" %f", wZcorrect); //9
1410 printf(" %f", wZwindow); //10
1411 printf(" %f", wPx); //11
1412 printf(" %f", wPy); //12
1413 printf(" %f", wPz); //13
1414 printf(" %f", wSigmaC2*1000000); //14
1415 printf(" %f", wSigmaTgl2*1000); //15
1416 printf(" %f", wSigmaY2); //16
1417 // printf(" %f", wSigmaZ2); //17
1418 printf(" %f", wChi2); //17
1419 printf(" %f", wC); //18
1426 return expectedNumberOfClusters;
1431 //___________________________________________________________________
1433 Int_t AliTRDtracker::PropagateToOuterPlane(AliTRDtrack& t, Double_t xToGo)
1435 // Starting from current radial position of track <t> this function
1436 // extrapolates the track up to radial position <xToGo>.
1437 // Returns 1 if track reaches the plane, and 0 otherwise
1439 Int_t ns=Int_t(2*TMath::Pi()/AliTRDgeometry::GetAlpha()+0.5);
1441 Double_t alpha=t.GetAlpha();
1443 if (alpha > 2.*TMath::Pi()) alpha -= 2.*TMath::Pi();
1444 if (alpha < 0. ) alpha += 2.*TMath::Pi();
1446 Int_t s=Int_t(alpha/AliTRDgeometry::GetAlpha())%AliTRDgeometry::kNsect;
1448 Bool_t lookForCluster;
1449 Double_t rad_length, rho, x, dx, y, ymax, z;
1453 alpha=AliTRDgeometry::GetAlpha(); // note: change in meaning
1455 Int_t plToGo = fTrSec[0]->GetLayerNumber(xToGo);
1457 for (Int_t nr=fTrSec[0]->GetLayerNumber(x); nr<plToGo; nr++) {
1459 y = t.GetY(); z = t.GetZ();
1461 // first propagate to the outer surface of the current time bin
1462 fTrSec[s]->GetLayer(nr)->GetPropagationParameters(y,z,dx,rho,rad_length,lookForCluster);
1463 x = fTrSec[s]->GetLayer(nr)->GetX()+dx/2; y = t.GetY(); z = t.GetZ();
1464 if(!t.PropagateTo(x,rad_length,rho)) return 0;
1466 ymax = x*TMath::Tan(0.5*alpha);
1469 if (!t.Rotate(alpha)) return 0;
1470 } else if (y <-ymax) {
1472 if (!t.Rotate(-alpha)) return 0;
1474 if(!t.PropagateTo(x,rad_length,rho)) return 0;
1476 y = t.GetY(); z = t.GetZ();
1478 // now propagate to the middle plane of the next time bin
1479 fTrSec[s]->GetLayer(nr+1)->GetPropagationParameters(y,z,dx,rho,rad_length,lookForCluster);
1480 x = fTrSec[s]->GetLayer(nr+1)->GetX(); y = t.GetY(); z = t.GetZ();
1481 if(!t.PropagateTo(x,rad_length,rho)) return 0;
1483 ymax = x*TMath::Tan(0.5*alpha);
1486 if (!t.Rotate(alpha)) return 0;
1487 } else if (y <-ymax) {
1489 if (!t.Rotate(-alpha)) return 0;
1491 if(!t.PropagateTo(x,rad_length,rho)) return 0;
1496 //___________________________________________________________________
1498 Int_t AliTRDtracker::PropagateToTPC(AliTRDtrack& t)
1500 // Starting from current radial position of track <t> this function
1501 // extrapolates the track up to radial position of the outermost
1502 // padrow of the TPC.
1503 // Returns 1 if track reaches the TPC, and 0 otherwise
1505 //Int_t ns=Int_t(2*TMath::Pi()/AliTRDgeometry::GetAlpha()+0.5);
1507 Double_t alpha=t.GetAlpha();
1508 alpha = TVector2::Phi_0_2pi(alpha);
1510 Int_t s=Int_t(alpha/AliTRDgeometry::GetAlpha())%AliTRDgeometry::kNsect;
1512 Bool_t lookForCluster;
1513 Double_t rad_length, rho, x, dx, y, /*ymax,*/ z;
1517 alpha=AliTRDgeometry::GetAlpha(); // note: change in meaning
1518 Int_t plTPC = fTrSec[0]->GetLayerNumber(246.055);
1520 for (Int_t nr=fTrSec[0]->GetLayerNumber(x); nr>plTPC; nr--) {
1525 // first propagate to the outer surface of the current time bin
1526 fTrSec[s]->GetLayer(nr)->GetPropagationParameters(y,z,dx,rho,rad_length,lookForCluster);
1527 x = fTrSec[s]->GetLayer(nr)->GetX()-dx/2;
1529 if(!t.PropagateTo(x,rad_length,rho)) return 0;
1531 if(!t.PropagateTo(x,rad_length,rho)) return 0;
1536 // now propagate to the middle plane of the next time bin
1537 fTrSec[s]->GetLayer(nr-1)->GetPropagationParameters(y,z,dx,rho,rad_length,lookForCluster);
1538 x = fTrSec[s]->GetLayer(nr-1)->GetX();
1540 if(!t.PropagateTo(x,rad_length,rho)) return 0;
1542 if(!t.PropagateTo(x,rad_length,rho)) return 0;
1547 void AliTRDtracker::LoadEvent()
1549 // Fills clusters into TRD tracking_sectors
1550 // Note that the numbering scheme for the TRD tracking_sectors
1551 // differs from that of TRD sectors
1553 ReadClusters(fClusters);
1554 Int_t ncl=fClusters->GetEntriesFast();
1555 cout<<"\n LoadSectors: sorting "<<ncl<<" clusters"<<endl;
1559 // printf("\r %d left ",ncl);
1560 AliTRDcluster *c=(AliTRDcluster*)fClusters->UncheckedAt(ncl);
1561 Int_t detector=c->GetDetector(), local_time_bin=c->GetLocalTimeBin();
1562 Int_t sector=fGeom->GetSector(detector);
1563 Int_t plane=fGeom->GetPlane(detector);
1565 Int_t tracking_sector = CookSectorIndex(sector);
1567 Int_t gtb = fTrSec[tracking_sector]->CookTimeBinIndex(plane,local_time_bin);
1568 if(gtb < 0) continue;
1569 Int_t layer = fTrSec[tracking_sector]->GetLayerNumber(gtb);
1572 fTrSec[tracking_sector]->GetLayer(layer)->InsertCluster(c,index);
1578 //_____________________________________________________________________________
1579 Int_t AliTRDtracker::LoadClusters(TTree *cTree)
1581 // Fills clusters into TRD tracking_sectors
1582 // Note that the numbering scheme for the TRD tracking_sectors
1583 // differs from that of TRD sectors
1585 if (ReadClusters(fClusters,cTree)) {
1586 Error("LoadClusters","Problem with reading the clusters !");
1589 Int_t ncl=fClusters->GetEntriesFast();
1590 cout<<"\n LoadSectors: sorting "<<ncl<<" clusters"<<endl;
1594 // printf("\r %d left ",ncl);
1595 AliTRDcluster *c=(AliTRDcluster*)fClusters->UncheckedAt(ncl);
1596 Int_t detector=c->GetDetector(), local_time_bin=c->GetLocalTimeBin();
1597 Int_t sector=fGeom->GetSector(detector);
1598 Int_t plane=fGeom->GetPlane(detector);
1600 Int_t tracking_sector = CookSectorIndex(sector);
1602 Int_t gtb = fTrSec[tracking_sector]->CookTimeBinIndex(plane,local_time_bin);
1603 if(gtb < 0) continue;
1604 Int_t layer = fTrSec[tracking_sector]->GetLayerNumber(gtb);
1607 fTrSec[tracking_sector]->GetLayer(layer)->InsertCluster(c,index);
1614 //_____________________________________________________________________________
1615 void AliTRDtracker::UnloadEvent()
1618 // Clears the arrays of clusters and tracks. Resets sectors and timebins
1623 nentr = fClusters->GetEntriesFast();
1624 for (i = 0; i < nentr; i++) delete fClusters->RemoveAt(i);
1626 nentr = fSeeds->GetEntriesFast();
1627 for (i = 0; i < nentr; i++) delete fSeeds->RemoveAt(i);
1629 nentr = fTracks->GetEntriesFast();
1630 for (i = 0; i < nentr; i++) delete fTracks->RemoveAt(i);
1632 Int_t nsec = AliTRDgeometry::kNsect;
1634 for (i = 0; i < nsec; i++) {
1635 for(Int_t pl = 0; pl < fTrSec[i]->GetNumberOfLayers(); pl++) {
1636 fTrSec[i]->GetLayer(pl)->Clear();
1642 //__________________________________________________________________________
1643 void AliTRDtracker::MakeSeeds(Int_t inner, Int_t outer, Int_t turn)
1645 // Creates track seeds using clusters in timeBins=i1,i2
1648 cerr<<"MakeSeeds: turn "<<turn<<" exceeds the limit of 2"<<endl;
1652 Double_t x[5], c[15];
1653 Int_t max_sec=AliTRDgeometry::kNsect;
1655 Double_t alpha=AliTRDgeometry::GetAlpha();
1656 Double_t shift=AliTRDgeometry::GetAlpha()/2.;
1657 Double_t cs=cos(alpha), sn=sin(alpha);
1658 Double_t cs2=cos(2.*alpha), sn2=sin(2.*alpha);
1661 Int_t i2 = fTrSec[0]->GetLayerNumber(inner);
1662 Int_t i1 = fTrSec[0]->GetLayerNumber(outer);
1664 Double_t x1 =fTrSec[0]->GetX(i1);
1665 Double_t xx2=fTrSec[0]->GetX(i2);
1667 for (Int_t ns=0; ns<max_sec; ns++) {
1669 Int_t nl2 = *(fTrSec[(ns-2+max_sec)%max_sec]->GetLayer(i2));
1670 Int_t nl=(*fTrSec[(ns-1+max_sec)%max_sec]->GetLayer(i2));
1671 Int_t nm=(*fTrSec[ns]->GetLayer(i2));
1672 Int_t nu=(*fTrSec[(ns+1)%max_sec]->GetLayer(i2));
1673 Int_t nu2=(*fTrSec[(ns+2)%max_sec]->GetLayer(i2));
1675 AliTRDpropagationLayer& r1=*(fTrSec[ns]->GetLayer(i1));
1677 for (Int_t is=0; is < r1; is++) {
1678 Double_t y1=r1[is]->GetY(), z1=r1[is]->GetZ();
1680 for (Int_t js=0; js < nl2+nl+nm+nu+nu2; js++) {
1682 const AliTRDcluster *cl;
1683 Double_t x2, y2, z2;
1684 Double_t x3=0., y3=0.;
1687 if(turn != 2) continue;
1688 AliTRDpropagationLayer& r2=*(fTrSec[(ns-2+max_sec)%max_sec]->GetLayer(i2));
1690 y2=cl->GetY(); z2=cl->GetZ();
1695 else if (js<nl2+nl) {
1696 if(turn != 1) continue;
1697 AliTRDpropagationLayer& r2=*(fTrSec[(ns-1+max_sec)%max_sec]->GetLayer(i2));
1699 y2=cl->GetY(); z2=cl->GetZ();
1704 else if (js<nl2+nl+nm) {
1705 if(turn != 1) continue;
1706 AliTRDpropagationLayer& r2=*(fTrSec[ns]->GetLayer(i2));
1708 x2=xx2; y2=cl->GetY(); z2=cl->GetZ();
1710 else if (js<nl2+nl+nm+nu) {
1711 if(turn != 1) continue;
1712 AliTRDpropagationLayer& r2=*(fTrSec[(ns+1)%max_sec]->GetLayer(i2));
1713 cl=r2[js-nl2-nl-nm];
1714 y2=cl->GetY(); z2=cl->GetZ();
1720 if(turn != 2) continue;
1721 AliTRDpropagationLayer& r2=*(fTrSec[(ns+2)%max_sec]->GetLayer(i2));
1722 cl=r2[js-nl2-nl-nm-nu];
1723 y2=cl->GetY(); z2=cl->GetZ();
1729 if(TMath::Abs(z1-z2) > fMaxSeedDeltaZ12) continue;
1731 Double_t zz=z1 - z1/x1*(x1-x2);
1733 if (TMath::Abs(zz-z2)>fMaxSeedDeltaZ) continue;
1735 Double_t d=(x2-x1)*(0.-y2)-(0.-x2)*(y2-y1);
1736 if (d==0.) {cerr<<"TRD MakeSeeds: Straight seed !\n"; continue;}
1740 x[4]=f1trd(x1,y1,x2,y2,x3,y3);
1742 if (TMath::Abs(x[4]) > fMaxSeedC) continue;
1744 x[2]=f2trd(x1,y1,x2,y2,x3,y3);
1746 if (TMath::Abs(x[4]*x1-x[2]) >= 0.99999) continue;
1748 x[3]=f3trd(x1,y1,x2,y2,z1,z2);
1750 if (TMath::Abs(x[3]) > fMaxSeedTan) continue;
1752 Double_t a=asin(x[2]);
1753 Double_t zv=z1 - x[3]/x[4]*(a+asin(x[4]*x1-x[2]));
1755 if (TMath::Abs(zv)>fMaxSeedVertexZ) continue;
1757 Double_t sy1=r1[is]->GetSigmaY2(), sz1=r1[is]->GetSigmaZ2();
1758 Double_t sy2=cl->GetSigmaY2(), sz2=cl->GetSigmaZ2();
1759 Double_t sy3=fSeedErrorSY3, sy=fSeedErrorSY, sz=fSeedErrorSZ;
1762 Double_t h01 = GetTiltFactor(r1[is]);
1763 Double_t xu_factor = 100.;
1769 sy1=sy1+sz1*h01*h01;
1770 Double_t syz=sz1*(-h01);
1771 // end of tilt changes
1773 Double_t f40=(f1trd(x1,y1+sy,x2,y2,x3,y3)-x[4])/sy;
1774 Double_t f42=(f1trd(x1,y1,x2,y2+sy,x3,y3)-x[4])/sy;
1775 Double_t f43=(f1trd(x1,y1,x2,y2,x3,y3+sy)-x[4])/sy;
1776 Double_t f20=(f2trd(x1,y1+sy,x2,y2,x3,y3)-x[2])/sy;
1777 Double_t f22=(f2trd(x1,y1,x2,y2+sy,x3,y3)-x[2])/sy;
1778 Double_t f23=(f2trd(x1,y1,x2,y2,x3,y3+sy)-x[2])/sy;
1779 Double_t f30=(f3trd(x1,y1+sy,x2,y2,z1,z2)-x[3])/sy;
1780 Double_t f31=(f3trd(x1,y1,x2,y2,z1+sz,z2)-x[3])/sz;
1781 Double_t f32=(f3trd(x1,y1,x2,y2+sy,z1,z2)-x[3])/sy;
1782 Double_t f34=(f3trd(x1,y1,x2,y2,z1,z2+sz)-x[3])/sz;
1786 // c[1]=0.; c[2]=sz1;
1787 c[1]=syz; c[2]=sz1*xu_factor;
1788 c[3]=f20*sy1; c[4]=0.; c[5]=f20*sy1*f20+f22*sy2*f22+f23*sy3*f23;
1789 c[6]=f30*sy1; c[7]=f31*sz1; c[8]=f30*sy1*f20+f32*sy2*f22;
1790 c[9]=f30*sy1*f30+f31*sz1*f31+f32*sy2*f32+f34*sz2*f34;
1791 c[10]=f40*sy1; c[11]=0.; c[12]=f40*sy1*f20+f42*sy2*f22+f43*sy3*f23;
1792 c[13]=f30*sy1*f40+f32*sy2*f42;
1793 c[14]=f40*sy1*f40+f42*sy2*f42+f43*sy3*f43;
1795 UInt_t index=r1.GetIndex(is);
1797 AliTRDtrack *track=new AliTRDtrack(r1[is],index,x,c,x1,ns*alpha+shift);
1799 Int_t rc=FollowProlongation(*track, i2);
1802 (track->GetNumberOfClusters() <
1803 (outer-inner)*fMinClustersInSeed)) delete track;
1805 fSeeds->AddLast(track); fNseeds++;
1806 // cerr<<"\r found seed "<<fNseeds;
1813 //_____________________________________________________________________________
1814 Int_t AliTRDtracker::ReadClusters(TObjArray *array, TTree *ClusterTree)
1817 // Reads AliTRDclusters (option >= 0) or AliTRDrecPoints (option < 0)
1818 // from the file. The names of the cluster tree and branches
1819 // should match the ones used in AliTRDclusterizer::WriteClusters()
1821 TObjArray *ClusterArray = new TObjArray(400);
1823 TBranch *branch=ClusterTree->GetBranch("TRDcluster");
1825 Error("ReadClusters","Can't get the branch !");
1828 branch->SetAddress(&ClusterArray);
1830 Int_t nEntries = (Int_t) ClusterTree->GetEntries();
1831 printf("found %d entries in %s.\n",nEntries,ClusterTree->GetName());
1833 // Loop through all entries in the tree
1835 AliTRDcluster *c = 0;
1838 for (Int_t iEntry = 0; iEntry < nEntries; iEntry++) {
1841 nbytes += ClusterTree->GetEvent(iEntry);
1843 // Get the number of points in the detector
1844 Int_t nCluster = ClusterArray->GetEntriesFast();
1845 // printf("\r Read %d clusters from entry %d", nCluster, iEntry);
1847 // Loop through all TRD digits
1848 for (Int_t iCluster = 0; iCluster < nCluster; iCluster++) {
1849 c = (AliTRDcluster*)ClusterArray->UncheckedAt(iCluster);
1850 AliTRDcluster *co = new AliTRDcluster(*c);
1851 co->SetSigmaY2(c->GetSigmaY2() * fSY2corr);
1852 Int_t ltb = co->GetLocalTimeBin();
1853 if(ltb == 19) co->SetSigmaZ2(c->GetSigmaZ2());
1854 else if(fNoTilt) co->SetSigmaZ2(c->GetSigmaZ2() * fSZ2corr);
1856 delete ClusterArray->RemoveAt(iCluster);
1860 delete ClusterArray;
1865 //______________________________________________________________________
1866 void AliTRDtracker::ReadClusters(TObjArray *array, const Char_t *filename)
1869 // Reads AliTRDclusters from file <filename>. The names of the cluster
1870 // tree and branches should match the ones used in
1871 // AliTRDclusterizer::WriteClusters()
1872 // if <array> == 0, clusters are added into AliTRDtracker fCluster array
1875 TDirectory *savedir=gDirectory;
1877 TFile *file = TFile::Open(filename);
1878 if (!file->IsOpen()) {
1879 cerr<<"Can't open file with TRD clusters"<<endl;
1883 Char_t treeName[12];
1884 sprintf(treeName,"TreeR%d_TRD",GetEventNumber());
1885 TTree *ClusterTree = (TTree*) gDirectory->Get(treeName);
1888 cerr<<"AliTRDtracker::ReadClusters(): ";
1889 cerr<<"can't get a tree with clusters !\n";
1893 TObjArray *ClusterArray = new TObjArray(400);
1895 ClusterTree->GetBranch("TRDcluster")->SetAddress(&ClusterArray);
1897 Int_t nEntries = (Int_t) ClusterTree->GetEntries();
1898 cout<<"found "<<nEntries<<" in ClusterTree"<<endl;
1900 // Loop through all entries in the tree
1902 AliTRDcluster *c = 0;
1906 for (Int_t iEntry = 0; iEntry < nEntries; iEntry++) {
1909 nbytes += ClusterTree->GetEvent(iEntry);
1911 // Get the number of points in the detector
1912 Int_t nCluster = ClusterArray->GetEntriesFast();
1913 printf("\n Read %d clusters from entry %d", nCluster, iEntry);
1915 // Loop through all TRD digits
1916 for (Int_t iCluster = 0; iCluster < nCluster; iCluster++) {
1917 c = (AliTRDcluster*)ClusterArray->UncheckedAt(iCluster);
1918 AliTRDcluster *co = new AliTRDcluster(*c);
1919 co->SetSigmaY2(c->GetSigmaY2() * fSY2corr);
1920 Int_t ltb = co->GetLocalTimeBin();
1921 if(ltb == 19) co->SetSigmaZ2(c->GetSigmaZ2());
1922 else if(fNoTilt) co->SetSigmaZ2(c->GetSigmaZ2() * fSZ2corr);
1924 delete ClusterArray->RemoveAt(iCluster);
1929 delete ClusterArray;
1934 void AliTRDtracker::ReadClusters(TObjArray *array, const TFile *inp)
1937 // Reads AliTRDclusters (option >= 0) or AliTRDrecPoints (option < 0)
1938 // from the file. The names of the cluster tree and branches
1939 // should match the ones used in AliTRDclusterizer::WriteClusters()
1942 TDirectory *savedir=gDirectory;
1945 TFile *in=(TFile*)inp;
1946 if (!in->IsOpen()) {
1947 cerr<<"AliTRDtracker::ReadClusters(): input file is not open !\n";
1955 Char_t treeName[12];
1956 sprintf(treeName,"TreeR%d_TRD",GetEventNumber());
1957 TTree *ClusterTree = (TTree*) gDirectory->Get(treeName);
1959 TObjArray *ClusterArray = new TObjArray(400);
1961 ClusterTree->GetBranch("TRDcluster")->SetAddress(&ClusterArray);
1963 Int_t nEntries = (Int_t) ClusterTree->GetEntries();
1964 printf("found %d entries in %s.\n",nEntries,ClusterTree->GetName());
1966 // Loop through all entries in the tree
1968 AliTRDcluster *c = 0;
1971 for (Int_t iEntry = 0; iEntry < nEntries; iEntry++) {
1974 nbytes += ClusterTree->GetEvent(iEntry);
1976 // Get the number of points in the detector
1977 Int_t nCluster = ClusterArray->GetEntriesFast();
1978 // printf("\r Read %d clusters from entry %d", nCluster, iEntry);
1980 // Loop through all TRD digits
1981 for (Int_t iCluster = 0; iCluster < nCluster; iCluster++) {
1982 c = (AliTRDcluster*)ClusterArray->UncheckedAt(iCluster);
1983 AliTRDcluster *co = new AliTRDcluster(*c);
1984 co->SetSigmaY2(c->GetSigmaY2() * fSY2corr);
1985 Int_t ltb = co->GetLocalTimeBin();
1986 if(ltb == 19) co->SetSigmaZ2(c->GetSigmaZ2());
1987 else if(fNoTilt) co->SetSigmaZ2(c->GetSigmaZ2() * fSZ2corr);
1989 delete ClusterArray->RemoveAt(iCluster);
1993 delete ClusterArray;
1998 //__________________________________________________________________
1999 void AliTRDtracker::CookLabel(AliKalmanTrack* pt, Float_t wrong) const {
2001 Int_t label=123456789, index, i, j;
2002 Int_t ncl=pt->GetNumberOfClusters();
2003 const Int_t range = fTrSec[0]->GetOuterTimeBin()+1;
2007 // Int_t s[range][2];
2008 Int_t **s = new Int_t* [range];
2009 for (i=0; i<range; i++) {
2010 s[i] = new Int_t[2];
2012 for (i=0; i<range; i++) {
2018 for (i=0; i<ncl; i++) {
2019 index=pt->GetClusterIndex(i);
2020 AliTRDcluster *c=(AliTRDcluster*)fClusters->UncheckedAt(index);
2026 for (i=0; i<ncl; i++) {
2027 index=pt->GetClusterIndex(i);
2028 AliTRDcluster *c=(AliTRDcluster*)fClusters->UncheckedAt(index);
2029 for (Int_t k=0; k<3; k++) {
2030 label=c->GetLabel(k);
2031 label_added=kFALSE; j=0;
2033 while ( (!label_added) && ( j < range ) ) {
2034 if (s[j][0]==label || s[j][1]==0) {
2048 for (i=0; i<range; i++) {
2050 max=s[i][1]; label=s[i][0];
2054 for (i=0; i<range; i++) {
2060 if ((1.- Float_t(max)/ncl) > wrong) label=-label;
2062 pt->SetLabel(label);
2067 //__________________________________________________________________
2068 void AliTRDtracker::UseClusters(const AliKalmanTrack* t, Int_t from) const {
2069 Int_t ncl=t->GetNumberOfClusters();
2070 for (Int_t i=from; i<ncl; i++) {
2071 Int_t index = t->GetClusterIndex(i);
2072 AliTRDcluster *c=(AliTRDcluster*)fClusters->UncheckedAt(index);
2078 //_____________________________________________________________________
2079 Double_t AliTRDtracker::ExpectedSigmaY2(Double_t r, Double_t tgl, Double_t pt)
2081 // Parametrised "expected" error of the cluster reconstruction in Y
2083 Double_t s = 0.08 * 0.08;
2087 //_____________________________________________________________________
2088 Double_t AliTRDtracker::ExpectedSigmaZ2(Double_t r, Double_t tgl)
2090 // Parametrised "expected" error of the cluster reconstruction in Z
2092 Double_t s = 9 * 9 /12.;
2097 //_____________________________________________________________________
2098 Double_t AliTRDtracker::GetX(Int_t sector, Int_t plane, Int_t local_tb) const
2101 // Returns radial position which corresponds to time bin <local_tb>
2102 // in tracking sector <sector> and plane <plane>
2105 Int_t index = fTrSec[sector]->CookTimeBinIndex(plane, local_tb);
2106 Int_t pl = fTrSec[sector]->GetLayerNumber(index);
2107 return fTrSec[sector]->GetLayer(pl)->GetX();
2112 //_______________________________________________________
2113 AliTRDtracker::AliTRDpropagationLayer::AliTRDpropagationLayer(Double_t x,
2114 Double_t dx, Double_t rho, Double_t rad_length, Int_t tb_index)
2117 // AliTRDpropagationLayer constructor
2120 fN = 0; fX = x; fdX = dx; fRho = rho; fX0 = rad_length;
2121 fClusters = NULL; fIndex = NULL; fTimeBinIndex = tb_index;
2124 for(Int_t i=0; i < (Int_t) kZONES; i++) {
2125 fZc[i]=0; fZmax[i] = 0;
2130 if(fTimeBinIndex >= 0) {
2131 fClusters = new AliTRDcluster*[kMAX_CLUSTER_PER_TIME_BIN];
2132 fIndex = new UInt_t[kMAX_CLUSTER_PER_TIME_BIN];
2145 //_______________________________________________________
2146 void AliTRDtracker::AliTRDpropagationLayer::SetHole(
2147 Double_t Zmax, Double_t Ymax, Double_t rho,
2148 Double_t rad_length, Double_t Yc, Double_t Zc)
2151 // Sets hole in the layer
2160 fHoleX0 = rad_length;
2164 //_______________________________________________________
2165 AliTRDtracker::AliTRDtrackingSector::AliTRDtrackingSector(AliTRDgeometry* geo, Int_t gs, AliTRDparameter* par)
2168 // AliTRDtrackingSector Constructor
2177 for(UInt_t i=0; i < kMAX_TIME_BIN_INDEX; i++) fTimeBinIndex[i] = -1;
2180 AliTRDpropagationLayer* ppl;
2182 Double_t x, xin, xout, dx, rho, rad_length;
2185 // set time bins in the gas of the TPC
2187 xin = 246.055; xout = 254.055; steps = 20; dx = (xout-xin)/steps;
2188 rho = 0.9e-3; rad_length = 28.94;
2190 for(Int_t i=0; i<steps; i++) {
2191 x = xin + i*dx + dx/2;
2192 ppl = new AliTRDpropagationLayer(x,dx,rho,rad_length,-1);
2196 // set time bins in the outer field cage vessel
2198 dx = 50e-4; xin = xout; xout = xin + dx; rho = 1.71; rad_length = 44.77; // Tedlar
2199 ppl = new AliTRDpropagationLayer(xin+dx/2,dx,rho,rad_length,-1);
2202 dx = 0.02; xin = xout; xout = xin + dx; rho = 1.45; rad_length = 44.86; // prepreg
2203 ppl = new AliTRDpropagationLayer(xin+dx/2,dx,rho,rad_length,-1);
2206 dx = 2.; xin = xout; xout = xin + dx; rho = 1.45*0.02; rad_length = 41.28; // Nomex
2207 steps = 5; dx = (xout - xin)/steps;
2208 for(Int_t i=0; i<steps; i++) {
2209 x = xin + i*dx + dx/2;
2210 ppl = new AliTRDpropagationLayer(x,dx,rho,rad_length,-1);
2214 dx = 0.02; xin = xout; xout = xin + dx; rho = 1.45; rad_length = 44.86; // prepreg
2215 ppl = new AliTRDpropagationLayer(xin+dx/2,dx,rho,rad_length,-1);
2218 dx = 50e-4; xin = xout; xout = xin + dx; rho = 1.71; rad_length = 44.77; // Tedlar
2219 ppl = new AliTRDpropagationLayer(xin+dx/2,dx,rho,rad_length,-1);
2223 // set time bins in CO2
2225 xin = xout; xout = 275.0;
2226 steps = 50; dx = (xout - xin)/steps;
2227 rho = 1.977e-3; rad_length = 36.2;
2229 for(Int_t i=0; i<steps; i++) {
2230 x = xin + i*dx + dx/2;
2231 ppl = new AliTRDpropagationLayer(x,dx,rho,rad_length,-1);
2235 // set time bins in the outer containment vessel
2237 dx = 50e-4; xin = xout; xout = xin + dx; rho = 2.7; rad_length = 24.01; // Al
2238 ppl = new AliTRDpropagationLayer(xin+dx/2,dx,rho,rad_length,-1);
2241 dx = 50e-4; xin = xout; xout = xin + dx; rho = 1.71; rad_length = 44.77; // Tedlar
2242 ppl = new AliTRDpropagationLayer(xin+dx/2,dx,rho,rad_length,-1);
2245 dx = 0.06; xin = xout; xout = xin + dx; rho = 1.45; rad_length = 44.86; // prepreg
2246 ppl = new AliTRDpropagationLayer(xin+dx/2,dx,rho,rad_length,-1);
2249 dx = 3.; xin = xout; xout = xin + dx; rho = 1.45*0.02; rad_length = 41.28; // Nomex
2250 steps = 10; dx = (xout - xin)/steps;
2251 for(Int_t i=0; i<steps; i++) {
2252 x = xin + i*dx + dx/2;
2253 ppl = new AliTRDpropagationLayer(x,dx,rho,rad_length,-1);
2257 dx = 0.06; xin = xout; xout = xin + dx; rho = 1.45; rad_length = 44.86; // prepreg
2258 ppl = new AliTRDpropagationLayer(xin+dx/2,dx,rho,rad_length,-1);
2261 dx = 50e-4; xin = xout; xout = xin + dx; rho = 1.71; rad_length = 44.77; // Tedlar
2262 ppl = new AliTRDpropagationLayer(xin+dx/2,dx,rho,rad_length,-1);
2265 dx = 50e-4; xin = xout; xout = xin + dx; rho = 2.7; rad_length = 24.01; // Al
2266 ppl = new AliTRDpropagationLayer(xin+dx/2,dx,rho,rad_length,-1);
2269 Double_t xtrd = (Double_t) fGeom->Rmin();
2271 // add layers between TPC and TRD (Air temporarily)
2272 xin = xout; xout = xtrd;
2273 steps = 50; dx = (xout - xin)/steps;
2274 rho = 1.2e-3; rad_length = 36.66;
2276 for(Int_t i=0; i<steps; i++) {
2277 x = xin + i*dx + dx/2;
2278 ppl = new AliTRDpropagationLayer(x,dx,rho,rad_length,-1);
2283 Double_t alpha=AliTRDgeometry::GetAlpha();
2285 // add layers for each of the planes
2287 Double_t dxRo = (Double_t) fGeom->CroHght(); // Rohacell
2288 Double_t dxSpace = (Double_t) fGeom->Cspace(); // Spacing between planes
2289 Double_t dxAmp = (Double_t) fGeom->CamHght(); // Amplification region
2290 Double_t dxDrift = (Double_t) fGeom->CdrHght(); // Drift region
2291 Double_t dxRad = (Double_t) fGeom->CraHght(); // Radiator
2292 Double_t dxTEC = dxRad + dxDrift + dxAmp + dxRo;
2293 Double_t dxPlane = dxTEC + dxSpace;
2296 const Int_t nChambers = AliTRDgeometry::Ncham();
2297 Double_t Ymax = 0, holeYmax = 0;
2298 Double_t * Zc = new Double_t[nChambers];
2299 Double_t * Zmax = new Double_t[nChambers];
2300 Double_t holeZmax = 1000.; // the whole sector is missing
2302 for(Int_t plane = 0; plane < AliTRDgeometry::Nplan(); plane++) {
2305 xin = xtrd + plane * dxPlane; xout = xin + dxRad;
2306 steps = 12; dx = (xout - xin)/steps; rho = 0.074; rad_length = 40.6;
2307 for(Int_t i=0; i<steps; i++) {
2308 x = xin + i*dx + dx/2;
2309 ppl = new AliTRDpropagationLayer(x,dx,rho,rad_length,-1);
2310 if((fGeom->GetPHOShole()) && (fGeomSector >= 2) && (fGeomSector <= 6)) {
2311 holeYmax = x*TMath::Tan(0.5*alpha);
2312 ppl->SetHole(holeYmax, holeZmax);
2314 if((fGeom->GetRICHhole()) && (fGeomSector >= 12) && (fGeomSector <= 14)) {
2315 holeYmax = x*TMath::Tan(0.5*alpha);
2316 ppl->SetHole(holeYmax, holeZmax);
2321 Ymax = fGeom->GetChamberWidth(plane)/2;
2322 for(Int_t ch = 0; ch < nChambers; ch++) {
2323 Zmax[ch] = fGeom->GetChamberLength(plane,ch)/2;
2324 Float_t pad = fPar->GetRowPadSize(plane,ch,0);
2325 Float_t row0 = fPar->GetRow0(plane,ch,0);
2326 Int_t nPads = fPar->GetRowMax(plane,ch,0);
2327 Zc[ch] = (pad * nPads)/2 + row0 - pad/2;
2330 dx = fPar->GetTimeBinSize();
2331 rho = 0.00295 * 0.85; rad_length = 11.0;
2333 Double_t x0 = (Double_t) fPar->GetTime0(plane);
2334 Double_t xbottom = x0 - dxDrift;
2335 Double_t xtop = x0 + dxAmp;
2337 // Amplification region
2339 steps = (Int_t) (dxAmp/dx);
2341 for(tb = 0; tb < steps; tb++) {
2342 x = x0 + tb * dx + dx/2;
2343 tb_index = CookTimeBinIndex(plane, -tb-1);
2344 ppl = new AliTRDpropagationLayer(x,dx,rho,rad_length,tb_index);
2346 for(Int_t ch = 0; ch < nChambers; ch++) {
2347 ppl->SetZmax(ch, Zc[ch], Zmax[ch]);
2349 if((fGeom->GetPHOShole()) && (fGeomSector >= 2) && (fGeomSector <= 6)) {
2350 holeYmax = x*TMath::Tan(0.5*alpha);
2351 ppl->SetHole(holeYmax, holeZmax);
2353 if((fGeom->GetRICHhole()) && (fGeomSector >= 12) && (fGeomSector <= 14)) {
2354 holeYmax = x*TMath::Tan(0.5*alpha);
2355 ppl->SetHole(holeYmax, holeZmax);
2359 tb_index = CookTimeBinIndex(plane, -steps);
2360 x = (x + dx/2 + xtop)/2;
2362 ppl = new AliTRDpropagationLayer(x,dx,rho,rad_length,tb_index);
2364 for(Int_t ch = 0; ch < nChambers; ch++) {
2365 ppl->SetZmax(ch, Zc[ch], Zmax[ch]);
2367 if((fGeom->GetPHOShole()) && (fGeomSector >= 2) && (fGeomSector <= 6)) {
2368 holeYmax = x*TMath::Tan(0.5*alpha);
2369 ppl->SetHole(holeYmax, holeZmax);
2371 if((fGeom->GetRICHhole()) && (fGeomSector >= 12) && (fGeomSector <= 14)) {
2372 holeYmax = x*TMath::Tan(0.5*alpha);
2373 ppl->SetHole(holeYmax, holeZmax);
2378 dx = fPar->GetTimeBinSize();
2379 steps = (Int_t) (dxDrift/dx);
2381 for(tb = 0; tb < steps; tb++) {
2382 x = x0 - tb * dx - dx/2;
2383 tb_index = CookTimeBinIndex(plane, tb);
2385 ppl = new AliTRDpropagationLayer(x,dx,rho,rad_length,tb_index);
2387 for(Int_t ch = 0; ch < nChambers; ch++) {
2388 ppl->SetZmax(ch, Zc[ch], Zmax[ch]);
2390 if((fGeom->GetPHOShole()) && (fGeomSector >= 2) && (fGeomSector <= 6)) {
2391 holeYmax = x*TMath::Tan(0.5*alpha);
2392 ppl->SetHole(holeYmax, holeZmax);
2394 if((fGeom->GetRICHhole()) && (fGeomSector >= 12) && (fGeomSector <= 14)) {
2395 holeYmax = x*TMath::Tan(0.5*alpha);
2396 ppl->SetHole(holeYmax, holeZmax);
2400 tb_index = CookTimeBinIndex(plane, steps);
2401 x = (x - dx/2 + xbottom)/2;
2403 ppl = new AliTRDpropagationLayer(x,dx,rho,rad_length,tb_index);
2405 for(Int_t ch = 0; ch < nChambers; ch++) {
2406 ppl->SetZmax(ch, Zc[ch], Zmax[ch]);
2408 if((fGeom->GetPHOShole()) && (fGeomSector >= 2) && (fGeomSector <= 6)) {
2409 holeYmax = x*TMath::Tan(0.5*alpha);
2410 ppl->SetHole(holeYmax, holeZmax);
2412 if((fGeom->GetRICHhole()) && (fGeomSector >= 12) && (fGeomSector <= 14)) {
2413 holeYmax = x*TMath::Tan(0.5*alpha);
2414 ppl->SetHole(holeYmax, holeZmax);
2419 xin = xtop; dx = 0.025; xout = xin + dx; rho = 1.7; rad_length = 33.0;
2420 ppl = new AliTRDpropagationLayer(xin+dx/2,dx,rho,rad_length,-1);
2421 if((fGeom->GetPHOShole()) && (fGeomSector >= 2) && (fGeomSector <= 6)) {
2422 holeYmax = (xin+dx/2)*TMath::Tan(0.5*alpha);
2423 ppl->SetHole(holeYmax, holeZmax);
2425 if((fGeom->GetRICHhole()) && (fGeomSector >= 12) && (fGeomSector <= 14)) {
2426 holeYmax = (xin+dx/2)*TMath::Tan(0.5*alpha);
2427 ppl->SetHole(holeYmax, holeZmax);
2432 xin = xout; xout = xtrd + (plane + 1) * dxPlane - dxSpace;
2433 steps = 5; dx = (xout - xin)/steps; rho = 0.074; rad_length = 40.6;
2434 for(Int_t i=0; i<steps; i++) {
2435 x = xin + i*dx + dx/2;
2436 ppl = new AliTRDpropagationLayer(x,dx,rho,rad_length,-1);
2437 if((fGeom->GetPHOShole()) && (fGeomSector >= 2) && (fGeomSector <= 6)) {
2438 holeYmax = x*TMath::Tan(0.5*alpha);
2439 ppl->SetHole(holeYmax, holeZmax);
2441 if((fGeom->GetRICHhole()) && (fGeomSector >= 12) && (fGeomSector <= 14)) {
2442 holeYmax = x*TMath::Tan(0.5*alpha);
2443 ppl->SetHole(holeYmax, holeZmax);
2448 // Space between the chambers, air
2449 xin = xout; xout = xtrd + (plane + 1) * dxPlane;
2450 steps = 5; dx = (xout - xin)/steps; rho = 1.29e-3; rad_length = 36.66;
2451 for(Int_t i=0; i<steps; i++) {
2452 x = xin + i*dx + dx/2;
2453 ppl = new AliTRDpropagationLayer(x,dx,rho,rad_length,-1);
2454 if((fGeom->GetPHOShole()) && (fGeomSector >= 2) && (fGeomSector <= 6)) {
2455 holeYmax = x*TMath::Tan(0.5*alpha);
2456 ppl->SetHole(holeYmax, holeZmax);
2458 if((fGeom->GetRICHhole()) && (fGeomSector >= 12) && (fGeomSector <= 14)) {
2459 holeYmax = x*TMath::Tan(0.5*alpha);
2460 ppl->SetHole(holeYmax, holeZmax);
2466 // Space between the TRD and RICH
2467 Double_t xRICH = 500.;
2468 xin = xout; xout = xRICH;
2469 steps = 200; dx = (xout - xin)/steps; rho = 1.29e-3; rad_length = 36.66;
2470 for(Int_t i=0; i<steps; i++) {
2471 x = xin + i*dx + dx/2;
2472 ppl = new AliTRDpropagationLayer(x,dx,rho,rad_length,-1);
2482 //______________________________________________________
2484 Int_t AliTRDtracker::AliTRDtrackingSector::CookTimeBinIndex(Int_t plane, Int_t local_tb) const
2487 // depending on the digitization parameters calculates "global"
2488 // time bin index for timebin <local_tb> in plane <plane>
2491 Double_t dxAmp = (Double_t) fGeom->CamHght(); // Amplification region
2492 Double_t dxDrift = (Double_t) fGeom->CdrHght(); // Drift region
2493 Double_t dx = (Double_t) fPar->GetTimeBinSize();
2495 Int_t tbAmp = fPar->GetTimeBefore();
2496 Int_t maxAmp = (Int_t) ((dxAmp+0.000001)/dx);
2497 if(kTRUE) maxAmp = 0; // intentional until we change parameter class
2498 Int_t tbDrift = fPar->GetTimeMax();
2499 Int_t maxDrift = (Int_t) ((dxDrift+0.000001)/dx);
2501 Int_t tb_per_plane = TMath::Min(tbAmp,maxAmp) + TMath::Min(tbDrift,maxDrift);
2503 Int_t gtb = (plane+1) * tb_per_plane - local_tb - 1 - TMath::Min(tbAmp,maxAmp);
2505 if((local_tb < 0) &&
2506 (TMath::Abs(local_tb) > TMath::Min(tbAmp,maxAmp))) return -1;
2507 if(local_tb >= TMath::Min(tbDrift,maxDrift)) return -1;
2514 //______________________________________________________
2516 void AliTRDtracker::AliTRDtrackingSector::MapTimeBinLayers()
2519 // For all sensitive time bins sets corresponding layer index
2520 // in the array fTimeBins
2525 for(Int_t i = 0; i < fN; i++) {
2526 index = fLayers[i]->GetTimeBinIndex();
2528 // printf("gtb %d -> pl %d -> x %f \n", index, i, fLayers[i]->GetX());
2530 if(index < 0) continue;
2531 if(index >= (Int_t) kMAX_TIME_BIN_INDEX) {
2532 printf("*** AliTRDtracker::MapTimeBinLayers: \n");
2533 printf(" index %d exceeds allowed maximum of %d!\n",
2534 index, kMAX_TIME_BIN_INDEX-1);
2537 fTimeBinIndex[index] = i;
2540 Double_t x1, dx1, x2, dx2, gap;
2542 for(Int_t i = 0; i < fN-1; i++) {
2543 x1 = fLayers[i]->GetX();
2544 dx1 = fLayers[i]->GetdX();
2545 x2 = fLayers[i+1]->GetX();
2546 dx2 = fLayers[i+1]->GetdX();
2547 gap = (x2 - dx2/2) - (x1 + dx1/2);
2549 printf("*** warning: layers %d and %d are overlayed:\n",i,i+1);
2550 printf(" %f + %f + %f > %f\n", x1, dx1/2, dx2/2, x2);
2553 printf("*** warning: layers %d and %d have a large gap:\n",i,i+1);
2554 printf(" (%f - %f) - (%f + %f) = %f\n",
2555 x2, dx2/2, x1, dx1, gap);
2561 //______________________________________________________
2564 Int_t AliTRDtracker::AliTRDtrackingSector::GetLayerNumber(Double_t x) const
2567 // Returns the number of time bin which in radial position is closest to <x>
2570 if(x >= fLayers[fN-1]->GetX()) return fN-1;
2571 if(x <= fLayers[0]->GetX()) return 0;
2573 Int_t b=0, e=fN-1, m=(b+e)/2;
2574 for (; b<e; m=(b+e)/2) {
2575 if (x > fLayers[m]->GetX()) b=m+1;
2578 if(TMath::Abs(x - fLayers[m]->GetX()) >
2579 TMath::Abs(x - fLayers[m+1]->GetX())) return m+1;
2584 //______________________________________________________
2586 Int_t AliTRDtracker::AliTRDtrackingSector::GetInnerTimeBin() const
2589 // Returns number of the innermost SENSITIVE propagation layer
2592 return GetLayerNumber(0);
2595 //______________________________________________________
2597 Int_t AliTRDtracker::AliTRDtrackingSector::GetOuterTimeBin() const
2600 // Returns number of the outermost SENSITIVE time bin
2603 return GetLayerNumber(GetNumberOfTimeBins() - 1);
2606 //______________________________________________________
2608 Int_t AliTRDtracker::AliTRDtrackingSector::GetNumberOfTimeBins() const
2611 // Returns number of SENSITIVE time bins
2615 for(tb = kMAX_TIME_BIN_INDEX-1; tb >=0; tb--) {
2616 layer = GetLayerNumber(tb);
2622 //______________________________________________________
2624 void AliTRDtracker::AliTRDtrackingSector::InsertLayer(AliTRDpropagationLayer* pl)
2627 // Insert layer <pl> in fLayers array.
2628 // Layers are sorted according to X coordinate.
2630 if ( fN == ((Int_t) kMAX_LAYERS_PER_SECTOR)) {
2631 printf("AliTRDtrackingSector::InsertLayer(): Too many layers !\n");
2634 if (fN==0) {fLayers[fN++] = pl; return;}
2635 Int_t i=Find(pl->GetX());
2637 memmove(fLayers+i+1 ,fLayers+i,(fN-i)*sizeof(AliTRDpropagationLayer*));
2638 fLayers[i]=pl; fN++;
2642 //______________________________________________________
2644 Int_t AliTRDtracker::AliTRDtrackingSector::Find(Double_t x) const
2647 // Returns index of the propagation layer nearest to X
2650 if (x <= fLayers[0]->GetX()) return 0;
2651 if (x > fLayers[fN-1]->GetX()) return fN;
2652 Int_t b=0, e=fN-1, m=(b+e)/2;
2653 for (; b<e; m=(b+e)/2) {
2654 if (x > fLayers[m]->GetX()) b=m+1;
2660 //______________________________________________________
2662 void AliTRDtracker::AliTRDpropagationLayer::GetPropagationParameters(
2663 Double_t y, Double_t z, Double_t &dx, Double_t &rho, Double_t &rad_length,
2664 Bool_t &lookForCluster) const
2667 // Returns radial step <dx>, density <rho>, rad. length <rad_length>,
2668 // and sensitivity <lookForCluster> in point <y,z>
2674 lookForCluster = kFALSE;
2676 // check dead regions
2677 if(fTimeBinIndex >= 0) {
2678 for(Int_t ch = 0; ch < (Int_t) kZONES; ch++) {
2679 if(TMath::Abs(z - fZc[ch]) < fZmax[ch])
2680 lookForCluster = kTRUE;
2681 // else { rho = 1.7; rad_length = 33.0; } // G10
2683 if(TMath::Abs(y) > fYmax) lookForCluster = kFALSE;
2684 if(!lookForCluster) {
2685 // rho = 1.7; rad_length = 33.0; // G10
2690 if(fHole && (TMath::Abs(y - fHoleYc) < fHoleYmax) &&
2691 (TMath::Abs(z - fHoleZc) < fHoleZmax)) {
2692 lookForCluster = kFALSE;
2694 rad_length = fHoleX0;
2700 //______________________________________________________
2702 void AliTRDtracker::AliTRDpropagationLayer::InsertCluster(AliTRDcluster* c,
2705 // Insert cluster in cluster array.
2706 // Clusters are sorted according to Y coordinate.
2708 if(fTimeBinIndex < 0) {
2709 printf("*** attempt to insert cluster into non-sensitive time bin!\n");
2713 if (fN== (Int_t) kMAX_CLUSTER_PER_TIME_BIN) {
2714 printf("AliTRDpropagationLayer::InsertCluster(): Too many clusters !\n");
2717 if (fN==0) {fIndex[0]=index; fClusters[fN++]=c; return;}
2718 Int_t i=Find(c->GetY());
2719 memmove(fClusters+i+1 ,fClusters+i,(fN-i)*sizeof(AliTRDcluster*));
2720 memmove(fIndex +i+1 ,fIndex +i,(fN-i)*sizeof(UInt_t));
2721 fIndex[i]=index; fClusters[i]=c; fN++;
2724 //______________________________________________________
2726 Int_t AliTRDtracker::AliTRDpropagationLayer::Find(Double_t y) const {
2728 // Returns index of the cluster nearest in Y
2730 if (y <= fClusters[0]->GetY()) return 0;
2731 if (y > fClusters[fN-1]->GetY()) return fN;
2732 Int_t b=0, e=fN-1, m=(b+e)/2;
2733 for (; b<e; m=(b+e)/2) {
2734 if (y > fClusters[m]->GetY()) b=m+1;
2740 //---------------------------------------------------------
2742 Double_t AliTRDtracker::GetTiltFactor(const AliTRDcluster* c) {
2744 // Returns correction factor for tilted pads geometry
2747 Double_t h01 = sin(TMath::Pi() / 180.0 * fPar->GetTiltingAngle());
2748 Int_t det = c->GetDetector();
2749 Int_t plane = fGeom->GetPlane(det);
2751 if((plane == 1) || (plane == 3) || (plane == 5)) h01=-h01;
2753 if(fNoTilt) h01 = 0;