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.18 2002/10/14 14:57:44 hristov
19 Merging the VirtualMC branch to the main development branch (HEAD)
21 Revision 1.14.6.2 2002/07/24 10:09:31 alibrary
24 Revision 1.17 2002/06/13 12:09:58 hristov
27 Revision 1.16 2002/06/12 09:54:36 cblume
28 Update of tracking code provided by Sergei
30 Revision 1.14 2001/11/14 10:50:46 cblume
31 Changes in digits IO. Add merging of summable digits
33 Revision 1.13 2001/05/30 12:17:47 hristov
34 Loop variables declared once
36 Revision 1.12 2001/05/28 17:07:58 hristov
37 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)
39 Revision 1.8 2000/12/20 13:00:44 cblume
40 Modifications for the HP-compiler
42 Revision 1.7 2000/12/08 16:07:02 cblume
43 Update of the tracking by Sergei
45 Revision 1.6 2000/11/30 17:38:08 cblume
46 Changes to get in line with new STEER and EVGEN
48 Revision 1.5 2000/11/14 14:40:27 cblume
49 Correction for the Sun compiler (kTRUE and kFALSE)
51 Revision 1.4 2000/11/10 14:57:52 cblume
52 Changes in the geometry constants for the DEC compiler
54 Revision 1.3 2000/10/15 23:40:01 cblume
57 Revision 1.2 2000/10/06 16:49:46 cblume
60 Revision 1.1.2.2 2000/10/04 16:34:58 cblume
61 Replace include files by forward declarations
63 Revision 1.1.2.1 2000/09/22 14:47:52 cblume
68 #include <Riostream.h>
73 #include <TObjArray.h>
75 #include "AliTRDgeometry.h"
76 #include "AliTRDparameter.h"
77 #include "AliTRDgeometryDetail.h"
78 #include "AliTRDcluster.h"
79 #include "AliTRDtrack.h"
80 #include "../TPC/AliTPCtrack.h"
82 #include "AliTRDtracker.h"
84 ClassImp(AliTRDtracker)
86 const Float_t AliTRDtracker::fSeedDepth = 0.5;
87 const Float_t AliTRDtracker::fSeedStep = 0.10;
88 const Float_t AliTRDtracker::fSeedGap = 0.25;
90 const Float_t AliTRDtracker::fMaxSeedDeltaZ12 = 40.;
91 const Float_t AliTRDtracker::fMaxSeedDeltaZ = 25.;
92 const Float_t AliTRDtracker::fMaxSeedC = 0.0052;
93 const Float_t AliTRDtracker::fMaxSeedTan = 1.2;
94 const Float_t AliTRDtracker::fMaxSeedVertexZ = 150.;
96 const Double_t AliTRDtracker::fSeedErrorSY = 0.2;
97 const Double_t AliTRDtracker::fSeedErrorSY3 = 2.5;
98 const Double_t AliTRDtracker::fSeedErrorSZ = 0.1;
100 const Float_t AliTRDtracker::fMinClustersInSeed = 0.7;
102 const Float_t AliTRDtracker::fMinClustersInTrack = 0.5;
103 const Float_t AliTRDtracker::fMinFractionOfFoundClusters = 0.8;
105 const Float_t AliTRDtracker::fSkipDepth = 0.05;
106 const Float_t AliTRDtracker::fLabelFraction = 0.8;
107 const Float_t AliTRDtracker::fWideRoad = 20.;
109 const Double_t AliTRDtracker::fMaxChi2 = 24.;
112 //____________________________________________________________________
113 AliTRDtracker::AliTRDtracker(const TFile *geomfile)
122 fAddTRDseeds = kFALSE;
126 TDirectory *savedir=gDirectory;
127 TFile *in=(TFile*)geomfile;
129 printf("AliTRDtracker::AliTRDtracker(): geometry file is not open!\n");
130 printf(" DETAIL TRD geometry and DEFAULT TRD parameter will be used\n");
135 fGeom = (AliTRDgeometry*) in->Get("TRDgeometry");
136 fPar = (AliTRDparameter*) in->Get("TRDparameter");
141 // fTzero = geo->GetT0();
143 version = fGeom->IsVersion();
144 printf("Found geometry version %d on file \n", version);
147 printf("AliTRDtracker::AliTRDtracker(): cann't find TRD geometry!\n");
148 printf(" DETAIL TRD geometry and DEFAULT TRD parameter will be used\n");
149 fGeom = new AliTRDgeometryDetail();
150 fPar = new AliTRDparameter();
156 // fGeom->SetT0(fTzero);
161 fClusters = new TObjArray(2000);
163 fSeeds = new TObjArray(2000);
165 fTracks = new TObjArray(1000);
167 for(Int_t geom_s = 0; geom_s < kTRACKING_SECTORS; geom_s++) {
168 Int_t tr_s = CookSectorIndex(geom_s);
169 fTrSec[tr_s] = new AliTRDtrackingSector(fGeom, geom_s, fPar);
175 // calculate max gap on track
177 Double_t dxAmp = (Double_t) fGeom->CamHght(); // Amplification region
178 Double_t dxDrift = (Double_t) fGeom->CdrHght(); // Drift region
180 Double_t dx = (Double_t) fPar->GetTimeBinSize();
181 Int_t tbAmp = fPar->GetTimeBefore();
182 Int_t maxAmp = (Int_t) ((dxAmp+0.000001)/dx);
183 Int_t tbDrift = fPar->GetTimeMax();
184 Int_t maxDrift = (Int_t) ((dxDrift+0.000001)/dx);
186 tbDrift = TMath::Min(tbDrift,maxDrift);
187 tbAmp = TMath::Min(tbAmp,maxAmp);
189 fTimeBinsPerPlane = tbAmp + tbDrift;
190 fMaxGap = (Int_t) (fTimeBinsPerPlane * fGeom->Nplan() * fSkipDepth);
196 //___________________________________________________________________
197 AliTRDtracker::~AliTRDtracker()
205 for(Int_t geom_s = 0; geom_s < kTRACKING_SECTORS; geom_s++) {
206 delete fTrSec[geom_s];
210 //_____________________________________________________________________
211 inline Double_t f1trd(Double_t x1,Double_t y1,
212 Double_t x2,Double_t y2,
213 Double_t x3,Double_t y3)
216 // Initial approximation of the track curvature
218 Double_t d=(x2-x1)*(y3-y2)-(x3-x2)*(y2-y1);
219 Double_t a=0.5*((y3-y2)*(y2*y2-y1*y1+x2*x2-x1*x1)-
220 (y2-y1)*(y3*y3-y2*y2+x3*x3-x2*x2));
221 Double_t b=0.5*((x2-x1)*(y3*y3-y2*y2+x3*x3-x2*x2)-
222 (x3-x2)*(y2*y2-y1*y1+x2*x2-x1*x1));
224 Double_t xr=TMath::Abs(d/(d*x1-a)), yr=d/(d*y1-b);
226 return -xr*yr/sqrt(xr*xr+yr*yr);
229 //_____________________________________________________________________
230 inline Double_t f2trd(Double_t x1,Double_t y1,
231 Double_t x2,Double_t y2,
232 Double_t x3,Double_t y3)
235 // Initial approximation of the track curvature times X coordinate
236 // of the center of curvature
239 Double_t d=(x2-x1)*(y3-y2)-(x3-x2)*(y2-y1);
240 Double_t a=0.5*((y3-y2)*(y2*y2-y1*y1+x2*x2-x1*x1)-
241 (y2-y1)*(y3*y3-y2*y2+x3*x3-x2*x2));
242 Double_t b=0.5*((x2-x1)*(y3*y3-y2*y2+x3*x3-x2*x2)-
243 (x3-x2)*(y2*y2-y1*y1+x2*x2-x1*x1));
245 Double_t xr=TMath::Abs(d/(d*x1-a)), yr=d/(d*y1-b);
247 return -a/(d*y1-b)*xr/sqrt(xr*xr+yr*yr);
250 //_____________________________________________________________________
251 inline Double_t f3trd(Double_t x1,Double_t y1,
252 Double_t x2,Double_t y2,
253 Double_t z1,Double_t z2)
256 // Initial approximation of the tangent of the track dip angle
259 return (z1 - z2)/sqrt((x1-x2)*(x1-x2)+(y1-y2)*(y1-y2));
262 //___________________________________________________________________
263 Int_t AliTRDtracker::Clusters2Tracks(const TFile *inp, TFile *out)
266 // Finds tracks within the TRD. File <inp> is expected to contain seeds
267 // at the outer part of the TRD. If <inp> is NULL, the seeds
268 // are found within the TRD if fAddTRDseeds is TRUE.
269 // The tracks are propagated to the innermost time bin
270 // of the TRD and stored in file <out>.
275 TDirectory *savedir=gDirectory;
279 if (!out->IsOpen()) {
280 cerr<<"AliTRDtracker::Clusters2Tracks(): output file is not open !\n";
284 sprintf(tname,"seedTRDtoTPC_%d",fEvent);
285 TTree tpc_tree(tname,"Tree with seeds from TRD at outer TPC pad row");
286 AliTPCtrack *iotrack=0;
287 tpc_tree.Branch("tracks","AliTPCtrack",&iotrack,32000,0);
289 sprintf(tname,"TreeT%d_TRD",fEvent);
290 TTree trd_tree(tname,"TRD tracks at inner TRD time bin");
291 AliTRDtrack *iotrack_trd=0;
292 trd_tree.Branch("tracks","AliTRDtrack",&iotrack_trd,32000,0);
294 Int_t timeBins = fTrSec[0]->GetNumberOfTimeBins();
295 Float_t foundMin = fMinClustersInTrack * timeBins;
298 TFile *in=(TFile*)inp;
300 cerr<<"AliTRDtracker::Clusters2Tracks(): file with seeds is not open !\n";
301 cerr<<" ... going for seeds finding inside the TRD\n";
305 sprintf(tname,"TRDb_%d",fEvent);
306 TTree *seedTree=(TTree*)in->Get(tname);
308 cerr<<"AliTRDtracker::Clusters2Tracks(): ";
309 cerr<<"can't get a tree with track seeds !\n";
312 AliTRDtrack *seed=new AliTRDtrack;
313 seedTree->SetBranchAddress("tracks",&seed);
315 Int_t n=(Int_t)seedTree->GetEntries();
316 for (Int_t i=0; i<n; i++) {
317 seedTree->GetEvent(i);
318 seed->ResetCovariance();
319 fSeeds->AddLast(new AliTRDtrack(*seed));
328 // find tracks from loaded seeds
330 Int_t nseed=fSeeds->GetEntriesFast();
332 Int_t innerTB = fTrSec[0]->GetInnerTimeBin();
334 for (i=0; i<nseed; i++) {
335 AliTRDtrack *pt=(AliTRDtrack*)fSeeds->UncheckedAt(i), &t=*pt;
336 FollowProlongation(t, innerTB);
337 if (t.GetNumberOfClusters() >= foundMin) {
339 CookLabel(pt, 1-fLabelFraction);
346 if(PropagateToTPC(t)) {
347 AliTPCtrack *tpc = new AliTPCtrack(*pt,pt->GetAlpha());
352 delete fSeeds->RemoveAt(i);
356 cout<<"Number of loaded seeds: "<<nseed<<endl;
357 cout<<"Number of found tracks from loaded seeds: "<<found<<endl;
359 // after tracks from loaded seeds are found and the corresponding
360 // clusters are used, look for additional seeds from TRD
363 // Find tracks for the seeds in the TRD
364 Int_t timeBins = fTrSec[0]->GetNumberOfTimeBins();
366 Int_t nSteps = (Int_t) (fSeedDepth / fSeedStep);
367 Int_t gap = (Int_t) (timeBins * fSeedGap);
368 Int_t step = (Int_t) (timeBins * fSeedStep);
370 // make a first turn with tight cut on initial curvature
371 for(Int_t turn = 1; turn <= 2; turn++) {
373 nSteps = (Int_t) (fSeedDepth / (3*fSeedStep));
374 step = (Int_t) (timeBins * (3*fSeedStep));
376 for(Int_t i=0; i<nSteps; i++) {
377 Int_t outer=timeBins-1-i*step;
378 Int_t inner=outer-gap;
380 nseed=fSeeds->GetEntriesFast();
381 printf("\n initial number of seeds %d\n", nseed);
383 MakeSeeds(inner, outer, turn);
385 nseed=fSeeds->GetEntriesFast();
386 printf("\n number of seeds after MakeSeeds %d\n", nseed);
389 for (Int_t i=0; i<nseed; i++) {
390 AliTRDtrack *pt=(AliTRDtrack*)fSeeds->UncheckedAt(i), &t=*pt;
391 FollowProlongation(t,innerTB);
392 if (t.GetNumberOfClusters() >= foundMin) {
394 CookLabel(pt, 1-fLabelFraction);
399 if(PropagateToTPC(t)) {
400 AliTPCtrack *tpc = new AliTPCtrack(*pt,pt->GetAlpha());
406 delete fSeeds->RemoveAt(i);
415 cout<<"Total number of found tracks: "<<found<<endl;
426 //_____________________________________________________________________________
427 Int_t AliTRDtracker::PropagateBack(const TFile *inp, TFile *out) {
429 // Reads seeds from file <inp>. The seeds are AliTPCtrack's found and
430 // backpropagated by the TPC tracker. Each seed is first propagated
431 // to the TRD, and then its prolongation is searched in the TRD.
432 // If sufficiently long continuation of the track is found in the TRD
433 // the track is updated, otherwise it's stored as originaly defined
434 // by the TPC tracker.
440 TDirectory *savedir=gDirectory;
442 TFile *in=(TFile*)inp;
445 cerr<<"AliTRDtracker::PropagateBack(): ";
446 cerr<<"file with back propagated TPC tracks is not open !\n";
450 if (!out->IsOpen()) {
451 cerr<<"AliTRDtracker::PropagateBack(): ";
452 cerr<<"file for back propagated TRD tracks is not open !\n";
458 sprintf(tname,"seedsTPCtoTRD_%d",fEvent);
459 TTree *seedTree=(TTree*)in->Get(tname);
461 cerr<<"AliTRDtracker::PropagateBack(): ";
462 cerr<<"can't get a tree with seeds from TPC !\n";
463 cerr<<"check if your version of TPC tracker creates tree "<<tname<<"\n";
467 AliTPCtrack *seed=new AliTPCtrack;
468 seedTree->SetBranchAddress("tracks",&seed);
470 Int_t n=(Int_t)seedTree->GetEntries();
471 for (Int_t i=0; i<n; i++) {
472 seedTree->GetEvent(i);
473 Int_t lbl = seed->GetLabel();
474 AliTRDtrack *tr = new AliTRDtrack(*seed,seed->GetAlpha());
475 tr->SetSeedLabel(lbl);
485 AliTPCtrack *otrack=0;
487 sprintf(tname,"seedsTRDtoTOF1_%d",fEvent);
488 TTree tofTree1(tname,"Tracks back propagated through TPC and TRD");
489 tofTree1.Branch("tracks","AliTPCtrack",&otrack,32000,0);
491 sprintf(tname,"seedsTRDtoTOF2_%d",fEvent);
492 TTree tofTree2(tname,"Tracks back propagated through TPC and TRD");
493 tofTree2.Branch("tracks","AliTPCtrack",&otrack,32000,0);
495 sprintf(tname,"seedsTRDtoPHOS_%d",fEvent);
496 TTree phosTree(tname,"Tracks back propagated through TPC and TRD");
497 phosTree.Branch("tracks","AliTPCtrack",&otrack,32000,0);
499 sprintf(tname,"seedsTRDtoRICH_%d",fEvent);
500 TTree richTree(tname,"Tracks back propagated through TPC and TRD");
501 richTree.Branch("tracks","AliTPCtrack",&otrack,32000,0);
503 sprintf(tname,"TRDb_%d",fEvent);
504 TTree trdTree(tname,"Back propagated TRD tracks at outer TRD time bin");
505 AliTRDtrack *otrack_trd=0;
506 trdTree.Branch("tracks","AliTRDtrack",&otrack_trd,32000,0);
510 Int_t nseed=fSeeds->GetEntriesFast();
512 Float_t foundMin = fMinClustersInTrack * fTimeBinsPerPlane * fGeom->Nplan();
514 Int_t outermost_tb = fTrSec[0]->GetOuterTimeBin();
516 for (Int_t i=0; i<nseed; i++) {
518 AliTRDtrack *ps=(AliTRDtrack*)fSeeds->UncheckedAt(i), &s=*ps;
519 Int_t expectedClr = FollowBackProlongation(s);
520 Int_t foundClr = s.GetNumberOfClusters();
521 Int_t last_tb = fTrSec[0]->GetLayerNumber(s.GetX());
523 printf("seed %d: found %d out of %d expected clusters, Min is %f\n",
524 i, foundClr, expectedClr, foundMin);
526 if (foundClr >= foundMin) {
528 CookLabel(ps, 1-fLabelFraction);
535 if(((expectedClr < 10) && (last_tb == outermost_tb)) ||
536 ((expectedClr >= 10) &&
537 (((Float_t) foundClr) / ((Float_t) expectedClr) >=
538 fMinFractionOfFoundClusters) && (last_tb == outermost_tb))) {
540 Double_t x_tof = 375.5;
542 if(PropagateToOuterPlane(s,x_tof)) {
543 AliTPCtrack *pt = new AliTPCtrack(*ps,ps->GetAlpha());
550 if(PropagateToOuterPlane(s,x_tof)) {
551 AliTPCtrack *pt = new AliTPCtrack(*ps,ps->GetAlpha());
556 Double_t x_phos = 460.;
558 if(PropagateToOuterPlane(s,x_phos)) {
559 AliTPCtrack *pt = new AliTPCtrack(*ps,ps->GetAlpha());
564 Double_t x_rich = 490+1.267;
566 if(PropagateToOuterPlane(s,x_rich)) {
567 AliTPCtrack *pt = new AliTPCtrack(*ps,ps->GetAlpha());
585 cerr<<"Number of seeds: "<<nseed<<endl;
586 cerr<<"Number of back propagated TRD tracks: "<<found<<endl;
595 //---------------------------------------------------------------------------
596 Int_t AliTRDtracker::FollowProlongation(AliTRDtrack& t, Int_t rf)
598 // Starting from current position on track=t this function tries
599 // to extrapolate the track up to timeBin=0 and to confirm prolongation
600 // if a close cluster is found. Returns the number of clusters
601 // expected to be found in sensitive layers
603 Float_t wIndex, wTB, wChi2;
604 Float_t wYrt, wYclosest, wYcorrect, wYwindow;
605 Float_t wZrt, wZclosest, wZcorrect, wZwindow;
606 Float_t wPx, wPy, wPz, wC;
608 Float_t wSigmaC2, wSigmaTgl2, wSigmaY2, wSigmaZ2;
610 Int_t trackIndex = t.GetLabel();
612 Int_t ns=Int_t(2*TMath::Pi()/AliTRDgeometry::GetAlpha()+0.5);
614 Int_t try_again=fMaxGap;
616 Double_t alpha=t.GetAlpha();
618 if (alpha > 2.*TMath::Pi()) alpha -= 2.*TMath::Pi();
619 if (alpha < 0. ) alpha += 2.*TMath::Pi();
621 Int_t s=Int_t(alpha/AliTRDgeometry::GetAlpha())%AliTRDgeometry::kNsect;
623 Double_t x0, rho, x, dx, y, ymax, z;
625 Int_t expectedNumberOfClusters = 0;
626 Bool_t lookForCluster;
628 alpha=AliTRDgeometry::GetAlpha(); // note: change in meaning
631 for (Int_t nr=fTrSec[0]->GetLayerNumber(t.GetX()); nr>rf; nr--) {
633 y = t.GetY(); z = t.GetZ();
635 // first propagate to the inner surface of the current time bin
636 fTrSec[s]->GetLayer(nr)->GetPropagationParameters(y,z,dx,rho,x0,lookForCluster);
637 x = fTrSec[s]->GetLayer(nr)->GetX()-dx/2; y = t.GetY(); z = t.GetZ();
638 if(!t.PropagateTo(x,x0,rho,0.139)) break;
640 ymax = x*TMath::Tan(0.5*alpha);
643 if (!t.Rotate(alpha)) break;
644 if(!t.PropagateTo(x,x0,rho,0.139)) break;
645 } else if (y <-ymax) {
647 if (!t.Rotate(-alpha)) break;
648 if(!t.PropagateTo(x,x0,rho,0.139)) break;
651 y = t.GetY(); z = t.GetZ();
653 // now propagate to the middle plane of the next time bin
654 fTrSec[s]->GetLayer(nr-1)->GetPropagationParameters(y,z,dx,rho,x0,lookForCluster);
655 x = fTrSec[s]->GetLayer(nr-1)->GetX(); y = t.GetY(); z = t.GetZ();
656 if(!t.PropagateTo(x,x0,rho,0.139)) break;
658 ymax = x*TMath::Tan(0.5*alpha);
661 if (!t.Rotate(alpha)) break;
662 if(!t.PropagateTo(x,x0,rho,0.139)) break;
663 } else if (y <-ymax) {
665 if (!t.Rotate(-alpha)) break;
666 if(!t.PropagateTo(x,x0,rho,0.139)) break;
673 expectedNumberOfClusters++;
675 wIndex = (Float_t) t.GetLabel();
679 AliTRDpropagationLayer& time_bin=*(fTrSec[s]->GetLayer(nr-1));
682 Double_t sy2=ExpectedSigmaY2(x,t.GetTgl(),t.GetPt());
685 Double_t sz2=ExpectedSigmaZ2(x,t.GetTgl());
688 if((t.GetSigmaY2() + sy2) > 0) road=10.*sqrt(t.GetSigmaY2() + sy2);
689 else return expectedNumberOfClusters;
693 wYwindow = (Float_t) road;
694 t.GetPxPyPz(Px,Py,Pz);
698 wC = (Float_t) t.GetC();
699 wSigmaC2 = (Float_t) t.GetSigmaC2();
700 wSigmaTgl2 = (Float_t) t.GetSigmaTgl2();
701 wSigmaY2 = (Float_t) t.GetSigmaY2();
702 wSigmaZ2 = (Float_t) t.GetSigmaZ2();
705 if (road>fWideRoad) {
706 if (t.GetNumberOfClusters()>4)
707 cerr<<t.GetNumberOfClusters()
708 <<"FindProlongation warning: Too broad road !\n";
715 Double_t max_chi2=fMaxChi2;
717 wYclosest = 12345678;
718 wYcorrect = 12345678;
719 wZclosest = 12345678;
720 wZcorrect = 12345678;
721 wZwindow = TMath::Sqrt(2.25 * 12 * sz2);
723 // Find the closest correct cluster for debugging purposes
725 Float_t minDY = 1000000;
726 for (Int_t i=0; i<time_bin; i++) {
727 AliTRDcluster* c=(AliTRDcluster*)(time_bin[i]);
728 if((c->GetLabel(0) != trackIndex) &&
729 (c->GetLabel(1) != trackIndex) &&
730 (c->GetLabel(2) != trackIndex)) continue;
731 if(TMath::Abs(c->GetY() - y) > minDY) continue;
732 minDY = TMath::Abs(c->GetY() - y);
733 wYcorrect = c->GetY();
734 wZcorrect = c->GetZ();
735 wChi2 = t.GetPredictedChi2(c);
739 // Now go for the real cluster search
743 for (Int_t i=time_bin.Find(y-road); i<time_bin; i++) {
744 AliTRDcluster* c=(AliTRDcluster*)(time_bin[i]);
745 if (c->GetY() > y+road) break;
746 if (c->IsUsed() > 0) continue;
747 if((c->GetZ()-z)*(c->GetZ()-z) > 3 * sz2) continue;
748 Double_t chi2=t.GetPredictedChi2(c);
750 if (chi2 > max_chi2) continue;
753 index=time_bin.GetIndex(i);
758 for (Int_t i=time_bin.Find(y-road); i<time_bin; i++) {
759 AliTRDcluster* c=(AliTRDcluster*)(time_bin[i]);
761 if (c->GetY() > y+road) break;
762 if (c->IsUsed() > 0) continue;
763 if((c->GetZ()-z)*(c->GetZ()-z) > 2.25 * 12 * sz2) continue;
765 Double_t chi2=t.GetPredictedChi2(c);
767 if (chi2 > max_chi2) continue;
770 index=time_bin.GetIndex(i);
776 wYclosest = cl->GetY();
777 wZclosest = cl->GetZ();
779 t.SetSampledEdx(cl->GetQ()/dx,t.GetNumberOfClusters());
780 if(!t.Update(cl,max_chi2,index)) {
781 if(!try_again--) return 0;
783 else try_again=fMaxGap;
786 if (try_again==0) break;
791 if((((Int_t) wTB)%15 == 0) || (((Int_t) wTB)%15 == 14)) {
793 printf(" %f", wIndex); //1
794 printf(" %f", wTB); //2
795 printf(" %f", wYrt); //3
796 printf(" %f", wYclosest); //4
797 printf(" %f", wYcorrect); //5
798 printf(" %f", wYwindow); //6
799 printf(" %f", wZrt); //7
800 printf(" %f", wZclosest); //8
801 printf(" %f", wZcorrect); //9
802 printf(" %f", wZwindow); //10
803 printf(" %f", wPx); //11
804 printf(" %f", wPy); //12
805 printf(" %f", wPz); //13
806 printf(" %f", wSigmaC2*1000000); //14
807 printf(" %f", wSigmaTgl2*1000); //15
808 printf(" %f", wSigmaY2); //16
809 // printf(" %f", wSigmaZ2); //17
810 printf(" %f", wChi2); //17
811 printf(" %f", wC); //18
818 return expectedNumberOfClusters;
823 //___________________________________________________________________
825 Int_t AliTRDtracker::FollowBackProlongation(AliTRDtrack& t)
827 // Starting from current radial position of track <t> this function
828 // extrapolates the track up to outer timebin and in the sensitive
829 // layers confirms prolongation if a close cluster is found.
830 // Returns the number of clusters expected to be found in sensitive layers
832 Float_t wIndex, wTB, wChi2;
833 Float_t wYrt, wYclosest, wYcorrect, wYwindow;
834 Float_t wZrt, wZclosest, wZcorrect, wZwindow;
835 Float_t wPx, wPy, wPz, wC;
837 Float_t wSigmaC2, wSigmaTgl2, wSigmaY2, wSigmaZ2;
839 Int_t trackIndex = t.GetLabel();
841 Int_t ns=Int_t(2*TMath::Pi()/AliTRDgeometry::GetAlpha()+0.5);
843 Int_t try_again=fMaxGap;
845 Double_t alpha=t.GetAlpha();
847 if (alpha > 2.*TMath::Pi()) alpha -= 2.*TMath::Pi();
848 if (alpha < 0. ) alpha += 2.*TMath::Pi();
850 Int_t s=Int_t(alpha/AliTRDgeometry::GetAlpha())%AliTRDgeometry::kNsect;
852 Int_t outerTB = fTrSec[0]->GetOuterTimeBin();
854 Double_t x0, rho, x, dx, y, ymax, z;
856 Bool_t lookForCluster;
858 Int_t expectedNumberOfClusters = 0;
861 alpha=AliTRDgeometry::GetAlpha(); // note: change in meaning
864 for (Int_t nr=fTrSec[0]->GetLayerNumber(t.GetX()); nr<outerTB; nr++) {
866 y = t.GetY(); z = t.GetZ();
868 // first propagate to the outer surface of the current time bin
870 fTrSec[s]->GetLayer(nr)->GetPropagationParameters(y,z,dx,rho,x0,lookForCluster);
871 x = fTrSec[s]->GetLayer(nr)->GetX()+dx/2; y = t.GetY(); z = t.GetZ();
873 if(!t.PropagateTo(x,x0,rho,0.139)) break;
876 ymax = x*TMath::Tan(0.5*alpha);
880 if (!t.Rotate(alpha)) break;
881 if(!t.PropagateTo(x,x0,rho,0.139)) break;
882 } else if (y <-ymax) {
884 if (!t.Rotate(-alpha)) break;
885 if(!t.PropagateTo(x,x0,rho,0.139)) break;
887 y = t.GetY(); z = t.GetZ();
889 // now propagate to the middle plane of the next time bin
890 fTrSec[s]->GetLayer(nr+1)->GetPropagationParameters(y,z,dx,rho,x0,lookForCluster);
892 x = fTrSec[s]->GetLayer(nr+1)->GetX(); y = t.GetY(); z = t.GetZ();
894 if(!t.PropagateTo(x,x0,rho,0.139)) break;
898 ymax = x*TMath::Tan(0.5*alpha);
900 if(fVocal) printf("nr+1=%d, x %f, z %f, y %f, ymax %f\n",nr+1,x,z,y,ymax);
904 if (!t.Rotate(alpha)) break;
905 if(!t.PropagateTo(x,x0,rho,0.139)) break;
906 } else if (y <-ymax) {
908 if (!t.Rotate(-alpha)) break;
909 if(!t.PropagateTo(x,x0,rho,0.139)) break;
912 // printf("label %d, pl %d, lookForCluster %d \n",
913 // trackIndex, nr+1, lookForCluster);
916 expectedNumberOfClusters++;
918 wIndex = (Float_t) t.GetLabel();
919 wTB = fTrSec[s]->GetLayer(nr+1)->GetTimeBinIndex();
921 AliTRDpropagationLayer& time_bin=*(fTrSec[s]->GetLayer(nr+1));
922 Double_t sy2=ExpectedSigmaY2(t.GetX(),t.GetTgl(),t.GetPt());
923 Double_t sz2=ExpectedSigmaZ2(t.GetX(),t.GetTgl());
924 if((t.GetSigmaY2() + sy2) < 0) break;
925 Double_t road = 10.*sqrt(t.GetSigmaY2() + sy2);
926 Double_t y=t.GetY(), z=t.GetZ();
930 wYwindow = (Float_t) road;
931 t.GetPxPyPz(Px,Py,Pz);
935 wC = (Float_t) t.GetC();
936 wSigmaC2 = (Float_t) t.GetSigmaC2();
937 wSigmaTgl2 = (Float_t) t.GetSigmaTgl2();
938 wSigmaY2 = (Float_t) t.GetSigmaY2();
939 wSigmaZ2 = (Float_t) t.GetSigmaZ2();
942 if (road>fWideRoad) {
943 if (t.GetNumberOfClusters()>4)
944 cerr<<t.GetNumberOfClusters()
945 <<"FindProlongation warning: Too broad road !\n";
952 Double_t max_chi2=fMaxChi2;
954 wYclosest = 12345678;
955 wYcorrect = 12345678;
956 wZclosest = 12345678;
957 wZcorrect = 12345678;
958 wZwindow = TMath::Sqrt(2.25 * 12 * sz2);
960 // Find the closest correct cluster for debugging purposes
962 Float_t minDY = 1000000;
963 for (Int_t i=0; i<time_bin; i++) {
964 AliTRDcluster* c=(AliTRDcluster*)(time_bin[i]);
965 if((c->GetLabel(0) != trackIndex) &&
966 (c->GetLabel(1) != trackIndex) &&
967 (c->GetLabel(2) != trackIndex)) continue;
968 if(TMath::Abs(c->GetY() - y) > minDY) continue;
969 minDY = TMath::Abs(c->GetY() - y);
970 wYcorrect = c->GetY();
971 wZcorrect = c->GetZ();
972 wChi2 = t.GetPredictedChi2(c);
976 // Now go for the real cluster search
980 for (Int_t i=time_bin.Find(y-road); i<time_bin; i++) {
981 AliTRDcluster* c=(AliTRDcluster*)(time_bin[i]);
982 if (c->GetY() > y+road) break;
983 if (c->IsUsed() > 0) continue;
984 if((c->GetZ()-z)*(c->GetZ()-z) > 3 * sz2) continue;
985 Double_t chi2=t.GetPredictedChi2(c);
987 if (chi2 > max_chi2) continue;
990 index=time_bin.GetIndex(i);
995 for (Int_t i=time_bin.Find(y-road); i<time_bin; i++) {
996 AliTRDcluster* c=(AliTRDcluster*)(time_bin[i]);
998 if (c->GetY() > y+road) break;
999 if (c->IsUsed() > 0) continue;
1000 if((c->GetZ()-z)*(c->GetZ()-z) > 2.25 * 12 * sz2) continue;
1002 Double_t chi2=t.GetPredictedChi2(c);
1004 if (chi2 > max_chi2) continue;
1007 index=time_bin.GetIndex(i);
1012 wYclosest = cl->GetY();
1013 wZclosest = cl->GetZ();
1015 t.SetSampledEdx(cl->GetQ()/dx,t.GetNumberOfClusters());
1016 if(!t.Update(cl,max_chi2,index)) {
1017 if(!try_again--) return 0;
1019 else try_again=fMaxGap;
1022 if (try_again==0) break;
1027 if((((Int_t) wTB)%15 == 0) || (((Int_t) wTB)%15 == 14)) {
1029 printf(" %f", wIndex); //1
1030 printf(" %f", wTB); //2
1031 printf(" %f", wYrt); //3
1032 printf(" %f", wYclosest); //4
1033 printf(" %f", wYcorrect); //5
1034 printf(" %f", wYwindow); //6
1035 printf(" %f", wZrt); //7
1036 printf(" %f", wZclosest); //8
1037 printf(" %f", wZcorrect); //9
1038 printf(" %f", wZwindow); //10
1039 printf(" %f", wPx); //11
1040 printf(" %f", wPy); //12
1041 printf(" %f", wPz); //13
1042 printf(" %f", wSigmaC2*1000000); //14
1043 printf(" %f", wSigmaTgl2*1000); //15
1044 printf(" %f", wSigmaY2); //16
1045 // printf(" %f", wSigmaZ2); //17
1046 printf(" %f", wChi2); //17
1047 printf(" %f", wC); //18
1054 return expectedNumberOfClusters;
1057 //___________________________________________________________________
1059 Int_t AliTRDtracker::PropagateToOuterPlane(AliTRDtrack& t, Double_t xToGo)
1061 // Starting from current radial position of track <t> this function
1062 // extrapolates the track up to radial position <xToGo>.
1063 // Returns 1 if track reaches the plane, and 0 otherwise
1065 Int_t ns=Int_t(2*TMath::Pi()/AliTRDgeometry::GetAlpha()+0.5);
1067 Double_t alpha=t.GetAlpha();
1069 if (alpha > 2.*TMath::Pi()) alpha -= 2.*TMath::Pi();
1070 if (alpha < 0. ) alpha += 2.*TMath::Pi();
1072 Int_t s=Int_t(alpha/AliTRDgeometry::GetAlpha())%AliTRDgeometry::kNsect;
1074 Bool_t lookForCluster;
1075 Double_t x0, rho, x, dx, y, ymax, z;
1079 alpha=AliTRDgeometry::GetAlpha(); // note: change in meaning
1081 Int_t plToGo = fTrSec[0]->GetLayerNumber(xToGo);
1083 for (Int_t nr=fTrSec[0]->GetLayerNumber(x); nr<plToGo; nr++) {
1085 y = t.GetY(); z = t.GetZ();
1087 // first propagate to the outer surface of the current time bin
1088 fTrSec[s]->GetLayer(nr)->GetPropagationParameters(y,z,dx,rho,x0,lookForCluster);
1089 x = fTrSec[s]->GetLayer(nr)->GetX()+dx/2; y = t.GetY(); z = t.GetZ();
1090 if(!t.PropagateTo(x,x0,rho,0.139)) return 0;
1092 ymax = x*TMath::Tan(0.5*alpha);
1095 if (!t.Rotate(alpha)) return 0;
1096 } else if (y <-ymax) {
1098 if (!t.Rotate(-alpha)) return 0;
1100 if(!t.PropagateTo(x,x0,rho,0.139)) return 0;
1102 y = t.GetY(); z = t.GetZ();
1104 // now propagate to the middle plane of the next time bin
1105 fTrSec[s]->GetLayer(nr+1)->GetPropagationParameters(y,z,dx,rho,x0,lookForCluster);
1106 x = fTrSec[s]->GetLayer(nr+1)->GetX(); y = t.GetY(); z = t.GetZ();
1107 if(!t.PropagateTo(x,x0,rho,0.139)) return 0;
1109 ymax = x*TMath::Tan(0.5*alpha);
1112 if (!t.Rotate(alpha)) return 0;
1113 } else if (y <-ymax) {
1115 if (!t.Rotate(-alpha)) return 0;
1117 if(!t.PropagateTo(x,x0,rho,0.139)) return 0;
1122 //___________________________________________________________________
1124 Int_t AliTRDtracker::PropagateToTPC(AliTRDtrack& t)
1126 // Starting from current radial position of track <t> this function
1127 // extrapolates the track up to radial position of the outermost
1128 // padrow of the TPC.
1129 // Returns 1 if track reaches the TPC, and 0 otherwise
1131 Int_t ns=Int_t(2*TMath::Pi()/AliTRDgeometry::GetAlpha()+0.5);
1133 Double_t alpha=t.GetAlpha();
1135 if (alpha > 2.*TMath::Pi()) alpha -= 2.*TMath::Pi();
1136 if (alpha < 0. ) alpha += 2.*TMath::Pi();
1138 Int_t s=Int_t(alpha/AliTRDgeometry::GetAlpha())%AliTRDgeometry::kNsect;
1140 Bool_t lookForCluster;
1141 Double_t x0, rho, x, dx, y, ymax, z;
1145 alpha=AliTRDgeometry::GetAlpha(); // note: change in meaning
1147 Int_t plTPC = fTrSec[0]->GetLayerNumber(246.055);
1149 for (Int_t nr=fTrSec[0]->GetLayerNumber(x); nr>plTPC; nr--) {
1151 y = t.GetY(); z = t.GetZ();
1153 // first propagate to the outer surface of the current time bin
1154 fTrSec[s]->GetLayer(nr)->GetPropagationParameters(y,z,dx,rho,x0,lookForCluster);
1155 x = fTrSec[s]->GetLayer(nr)->GetX()-dx/2; y = t.GetY(); z = t.GetZ();
1156 if(!t.PropagateTo(x,x0,rho,0.139)) return 0;
1158 ymax = x*TMath::Tan(0.5*alpha);
1161 if (!t.Rotate(alpha)) return 0;
1162 } else if (y <-ymax) {
1164 if (!t.Rotate(-alpha)) return 0;
1166 if(!t.PropagateTo(x,x0,rho,0.139)) return 0;
1168 y = t.GetY(); z = t.GetZ();
1170 // now propagate to the middle plane of the next time bin
1171 fTrSec[s]->GetLayer(nr-1)->GetPropagationParameters(y,z,dx,rho,x0,lookForCluster);
1172 x = fTrSec[s]->GetLayer(nr-1)->GetX(); y = t.GetY(); z = t.GetZ();
1173 if(!t.PropagateTo(x,x0,rho,0.139)) return 0;
1175 ymax = x*TMath::Tan(0.5*alpha);
1178 if (!t.Rotate(alpha)) return 0;
1179 } else if (y <-ymax) {
1181 if (!t.Rotate(-alpha)) return 0;
1183 if(!t.PropagateTo(x,x0,rho,0.139)) return 0;
1189 //_____________________________________________________________________________
1190 void AliTRDtracker::LoadEvent()
1192 // Fills clusters into TRD tracking_sectors
1193 // Note that the numbering scheme for the TRD tracking_sectors
1194 // differs from that of TRD sectors
1196 ReadClusters(fClusters);
1197 Int_t ncl=fClusters->GetEntriesFast();
1198 cout<<"\n LoadSectors: sorting "<<ncl<<" clusters"<<endl;
1202 printf("\r %d left ",ncl);
1203 AliTRDcluster *c=(AliTRDcluster*)fClusters->UncheckedAt(ncl);
1204 Int_t detector=c->GetDetector(), local_time_bin=c->GetLocalTimeBin();
1205 Int_t sector=fGeom->GetSector(detector);
1206 Int_t plane=fGeom->GetPlane(detector);
1208 Int_t tracking_sector = CookSectorIndex(sector);
1210 Int_t gtb = fTrSec[tracking_sector]->CookTimeBinIndex(plane,local_time_bin);
1211 Int_t layer = fTrSec[tracking_sector]->GetLayerNumber(gtb);
1214 fTrSec[tracking_sector]->GetLayer(layer)->InsertCluster(c,index);
1220 //_____________________________________________________________________________
1221 void AliTRDtracker::UnloadEvent()
1224 // Clears the arrays of clusters and tracks. Resets sectors and timebins
1229 nentr = fClusters->GetEntriesFast();
1230 for (i = 0; i < nentr; i++) delete fClusters->RemoveAt(i);
1232 nentr = fSeeds->GetEntriesFast();
1233 for (i = 0; i < nentr; i++) delete fSeeds->RemoveAt(i);
1235 nentr = fTracks->GetEntriesFast();
1236 for (i = 0; i < nentr; i++) delete fTracks->RemoveAt(i);
1238 Int_t nsec = AliTRDgeometry::kNsect;
1240 for (i = 0; i < nsec; i++) {
1241 for(Int_t pl = 0; pl < fTrSec[i]->GetNumberOfLayers(); pl++) {
1242 fTrSec[i]->GetLayer(pl)->Clear();
1248 //__________________________________________________________________________
1249 void AliTRDtracker::MakeSeeds(Int_t inner, Int_t outer, Int_t turn)
1251 // Creates track seeds using clusters in timeBins=i1,i2
1254 cerr<<"MakeSeeds: turn "<<turn<<" exceeds the limit of 2"<<endl;
1258 Double_t x[5], c[15];
1259 Int_t max_sec=AliTRDgeometry::kNsect;
1261 Double_t alpha=AliTRDgeometry::GetAlpha();
1262 Double_t shift=AliTRDgeometry::GetAlpha()/2.;
1263 Double_t cs=cos(alpha), sn=sin(alpha);
1264 Double_t cs2=cos(2.*alpha), sn2=sin(2.*alpha);
1267 Int_t i2 = fTrSec[0]->GetLayerNumber(inner);
1268 Int_t i1 = fTrSec[0]->GetLayerNumber(outer);
1270 Double_t x1 =fTrSec[0]->GetX(i1);
1271 Double_t xx2=fTrSec[0]->GetX(i2);
1273 for (Int_t ns=0; ns<max_sec; ns++) {
1275 Int_t nl2 = *(fTrSec[(ns-2+max_sec)%max_sec]->GetLayer(i2));
1276 Int_t nl=(*fTrSec[(ns-1+max_sec)%max_sec]->GetLayer(i2));
1277 Int_t nm=(*fTrSec[ns]->GetLayer(i2));
1278 Int_t nu=(*fTrSec[(ns+1)%max_sec]->GetLayer(i2));
1279 Int_t nu2=(*fTrSec[(ns+2)%max_sec]->GetLayer(i2));
1281 AliTRDpropagationLayer& r1=*(fTrSec[ns]->GetLayer(i1));
1283 for (Int_t is=0; is < r1; is++) {
1284 Double_t y1=r1[is]->GetY(), z1=r1[is]->GetZ();
1286 for (Int_t js=0; js < nl2+nl+nm+nu+nu2; js++) {
1288 const AliTRDcluster *cl;
1289 Double_t x2, y2, z2;
1290 Double_t x3=0., y3=0.;
1293 if(turn != 2) continue;
1294 AliTRDpropagationLayer& r2=*(fTrSec[(ns-2+max_sec)%max_sec]->GetLayer(i2));
1296 y2=cl->GetY(); z2=cl->GetZ();
1301 else if (js<nl2+nl) {
1302 if(turn != 1) continue;
1303 AliTRDpropagationLayer& r2=*(fTrSec[(ns-1+max_sec)%max_sec]->GetLayer(i2));
1305 y2=cl->GetY(); z2=cl->GetZ();
1310 else if (js<nl2+nl+nm) {
1311 if(turn != 1) continue;
1312 AliTRDpropagationLayer& r2=*(fTrSec[ns]->GetLayer(i2));
1314 x2=xx2; y2=cl->GetY(); z2=cl->GetZ();
1316 else if (js<nl2+nl+nm+nu) {
1317 if(turn != 1) continue;
1318 AliTRDpropagationLayer& r2=*(fTrSec[(ns+1)%max_sec]->GetLayer(i2));
1319 cl=r2[js-nl2-nl-nm];
1320 y2=cl->GetY(); z2=cl->GetZ();
1326 if(turn != 2) continue;
1327 AliTRDpropagationLayer& r2=*(fTrSec[(ns+2)%max_sec]->GetLayer(i2));
1328 cl=r2[js-nl2-nl-nm-nu];
1329 y2=cl->GetY(); z2=cl->GetZ();
1335 if(TMath::Abs(z1-z2) > fMaxSeedDeltaZ12) continue;
1337 Double_t zz=z1 - z1/x1*(x1-x2);
1339 if (TMath::Abs(zz-z2)>fMaxSeedDeltaZ) continue;
1341 Double_t d=(x2-x1)*(0.-y2)-(0.-x2)*(y2-y1);
1342 if (d==0.) {cerr<<"TRD MakeSeeds: Straight seed !\n"; continue;}
1346 x[2]=f1trd(x1,y1,x2,y2,x3,y3);
1348 if (TMath::Abs(x[2]) > fMaxSeedC) continue;
1350 x[3]=f2trd(x1,y1,x2,y2,x3,y3);
1352 if (TMath::Abs(x[2]*x1-x[3]) >= 0.99999) continue;
1354 x[4]=f3trd(x1,y1,x2,y2,z1,z2);
1356 if (TMath::Abs(x[4]) > fMaxSeedTan) continue;
1358 Double_t a=asin(x[3]);
1359 Double_t zv=z1 - x[4]/x[2]*(a+asin(x[2]*x1-x[3]));
1361 if (TMath::Abs(zv)>fMaxSeedVertexZ) continue;
1363 Double_t sy1=r1[is]->GetSigmaY2(), sz1=r1[is]->GetSigmaZ2();
1364 Double_t sy2=cl->GetSigmaY2(), sz2=cl->GetSigmaZ2();
1365 Double_t sy3=fSeedErrorSY3, sy=fSeedErrorSY, sz=fSeedErrorSZ;
1367 Double_t f20=(f1trd(x1,y1+sy,x2,y2,x3,y3)-x[2])/sy;
1368 Double_t f22=(f1trd(x1,y1,x2,y2+sy,x3,y3)-x[2])/sy;
1369 Double_t f24=(f1trd(x1,y1,x2,y2,x3,y3+sy)-x[2])/sy;
1370 Double_t f30=(f2trd(x1,y1+sy,x2,y2,x3,y3)-x[3])/sy;
1371 Double_t f32=(f2trd(x1,y1,x2,y2+sy,x3,y3)-x[3])/sy;
1372 Double_t f34=(f2trd(x1,y1,x2,y2,x3,y3+sy)-x[3])/sy;
1373 Double_t f40=(f3trd(x1,y1+sy,x2,y2,z1,z2)-x[4])/sy;
1374 Double_t f41=(f3trd(x1,y1,x2,y2,z1+sz,z2)-x[4])/sz;
1375 Double_t f42=(f3trd(x1,y1,x2,y2+sy,z1,z2)-x[4])/sy;
1376 Double_t f43=(f3trd(x1,y1,x2,y2,z1,z2+sz)-x[4])/sz;
1380 c[3]=f20*sy1; c[4]=0.; c[5]=f20*sy1*f20+f22*sy2*f22+f24*sy3*f24;
1381 c[6]=f30*sy1; c[7]=0.; c[8]=f30*sy1*f20+f32*sy2*f22+f34*sy3*f24;
1382 c[9]=f30*sy1*f30+f32*sy2*f32+f34*sy3*f34;
1383 c[10]=f40*sy1; c[11]=f41*sz1; c[12]=f40*sy1*f20+f42*sy2*f22;
1384 c[13]=f40*sy1*f30+f42*sy2*f32;
1385 c[14]=f40*sy1*f40+f41*sz1*f41+f42*sy2*f42+f43*sz2*f43;
1387 UInt_t index=r1.GetIndex(is);
1389 AliTRDtrack *track=new AliTRDtrack(r1[is],index,x,c,x1,ns*alpha+shift);
1391 Int_t rc=FollowProlongation(*track, i2);
1394 (track->GetNumberOfClusters() <
1395 (outer-inner)*fMinClustersInSeed)) delete track;
1397 fSeeds->AddLast(track); fNseeds++;
1398 cerr<<"\r found seed "<<fNseeds;
1405 //_____________________________________________________________________________
1406 void AliTRDtracker::ReadClusters(TObjArray *array, const TFile *inp)
1409 // Reads AliTRDclusters (option >= 0) or AliTRDrecPoints (option < 0)
1410 // from the file. The names of the cluster tree and branches
1411 // should match the ones used in AliTRDclusterizer::WriteClusters()
1414 TDirectory *savedir=gDirectory;
1417 TFile *in=(TFile*)inp;
1418 if (!in->IsOpen()) {
1419 cerr<<"AliTRDtracker::ReadClusters(): input file is not open !\n";
1427 Char_t treeName[12];
1428 sprintf(treeName,"TreeR%d_TRD",fEvent);
1429 TTree *ClusterTree = (TTree*) gDirectory->Get(treeName);
1431 TObjArray *ClusterArray = new TObjArray(400);
1433 ClusterTree->GetBranch("TRDcluster")->SetAddress(&ClusterArray);
1435 Int_t nEntries = (Int_t) ClusterTree->GetEntries();
1436 printf("found %d entries in %s.\n",nEntries,ClusterTree->GetName());
1438 // Loop through all entries in the tree
1440 AliTRDcluster *c = 0;
1443 for (Int_t iEntry = 0; iEntry < nEntries; iEntry++) {
1446 nbytes += ClusterTree->GetEvent(iEntry);
1448 // Get the number of points in the detector
1449 Int_t nCluster = ClusterArray->GetEntriesFast();
1450 printf("\r Read %d clusters from entry %d", nCluster, iEntry);
1452 // Loop through all TRD digits
1453 for (Int_t iCluster = 0; iCluster < nCluster; iCluster++) {
1454 c = (AliTRDcluster*)ClusterArray->UncheckedAt(iCluster);
1455 AliTRDcluster *co = new AliTRDcluster(*c);
1456 co->SetSigmaY2(c->GetSigmaY2() * fSY2corr);
1457 Int_t ltb = co->GetLocalTimeBin();
1458 if(ltb != 0) co->SetSigmaZ2(c->GetSigmaZ2() * fSZ2corr);
1461 delete ClusterArray->RemoveAt(iCluster);
1465 delete ClusterArray;
1470 //______________________________________________________________________
1471 void AliTRDtracker::ReadClusters(TObjArray *array, const Char_t *filename)
1474 // Reads AliTRDclusters from file <filename>. The names of the cluster
1475 // tree and branches should match the ones used in
1476 // AliTRDclusterizer::WriteClusters()
1477 // if <array> == 0, clusters are added into AliTRDtracker fCluster array
1480 TDirectory *savedir=gDirectory;
1482 TFile *file = TFile::Open(filename);
1483 if (!file->IsOpen()) {
1484 cerr<<"Can't open file with TRD clusters"<<endl;
1488 Char_t treeName[12];
1489 sprintf(treeName,"TreeR%d_TRD",fEvent);
1490 TTree *ClusterTree = (TTree*) gDirectory->Get(treeName);
1493 cerr<<"AliTRDtracker::ReadClusters(): ";
1494 cerr<<"can't get a tree with clusters !\n";
1498 TObjArray *ClusterArray = new TObjArray(400);
1500 ClusterTree->GetBranch("TRDcluster")->SetAddress(&ClusterArray);
1502 Int_t nEntries = (Int_t) ClusterTree->GetEntries();
1503 cout<<"found "<<nEntries<<" in ClusterTree"<<endl;
1505 // Loop through all entries in the tree
1507 AliTRDcluster *c = 0;
1511 for (Int_t iEntry = 0; iEntry < nEntries; iEntry++) {
1514 nbytes += ClusterTree->GetEvent(iEntry);
1516 // Get the number of points in the detector
1517 Int_t nCluster = ClusterArray->GetEntriesFast();
1518 printf("\r Read %d clusters from entry %d", nCluster, iEntry);
1520 // Loop through all TRD digits
1521 for (Int_t iCluster = 0; iCluster < nCluster; iCluster++) {
1522 c = (AliTRDcluster*)ClusterArray->UncheckedAt(iCluster);
1523 AliTRDcluster *co = new AliTRDcluster(*c);
1524 co->SetSigmaY2(c->GetSigmaY2() * fSY2corr);
1525 Int_t ltb = co->GetLocalTimeBin();
1526 if(ltb != 0) co->SetSigmaZ2(c->GetSigmaZ2() * fSZ2corr);
1528 delete ClusterArray->RemoveAt(iCluster);
1533 delete ClusterArray;
1539 //__________________________________________________________________
1540 void AliTRDtracker::CookLabel(AliKalmanTrack* pt, Float_t wrong) const {
1542 Int_t label=123456789, index, i, j;
1543 Int_t ncl=pt->GetNumberOfClusters();
1544 const Int_t range = fTrSec[0]->GetOuterTimeBin()+1;
1548 // Int_t s[range][2];
1549 Int_t **s = new Int_t* [range];
1550 for (i=0; i<range; i++) {
1551 s[i] = new Int_t[2];
1553 for (i=0; i<range; i++) {
1559 for (i=0; i<ncl; i++) {
1560 index=pt->GetClusterIndex(i);
1561 AliTRDcluster *c=(AliTRDcluster*)fClusters->UncheckedAt(index);
1567 for (i=0; i<ncl; i++) {
1568 index=pt->GetClusterIndex(i);
1569 AliTRDcluster *c=(AliTRDcluster*)fClusters->UncheckedAt(index);
1570 for (Int_t k=0; k<3; k++) {
1571 label=c->GetLabel(k);
1572 label_added=kFALSE; j=0;
1574 while ( (!label_added) && ( j < range ) ) {
1575 if (s[j][0]==label || s[j][1]==0) {
1589 for (i=0; i<range; i++) {
1591 max=s[i][1]; label=s[i][0];
1595 for (i=0; i<range; i++) {
1601 if ((1.- Float_t(max)/ncl) > wrong) label=-label;
1603 pt->SetLabel(label);
1608 //__________________________________________________________________
1609 void AliTRDtracker::UseClusters(const AliKalmanTrack* t, Int_t from) const {
1610 Int_t ncl=t->GetNumberOfClusters();
1611 for (Int_t i=from; i<ncl; i++) {
1612 Int_t index = t->GetClusterIndex(i);
1613 AliTRDcluster *c=(AliTRDcluster*)fClusters->UncheckedAt(index);
1619 //_____________________________________________________________________
1620 Double_t AliTRDtracker::ExpectedSigmaY2(Double_t r, Double_t tgl, Double_t pt)
1622 // Parametrised "expected" error of the cluster reconstruction in Y
1624 Double_t s = 0.08 * 0.08;
1628 //_____________________________________________________________________
1629 Double_t AliTRDtracker::ExpectedSigmaZ2(Double_t r, Double_t tgl)
1631 // Parametrised "expected" error of the cluster reconstruction in Z
1633 Double_t s = 6 * 6 /12.;
1638 //_____________________________________________________________________
1639 Double_t AliTRDtracker::GetX(Int_t sector, Int_t plane, Int_t local_tb) const
1642 // Returns radial position which corresponds to time bin <local_tb>
1643 // in tracking sector <sector> and plane <plane>
1646 Int_t index = fTrSec[sector]->CookTimeBinIndex(plane, local_tb);
1647 Int_t pl = fTrSec[sector]->GetLayerNumber(index);
1648 return fTrSec[sector]->GetLayer(pl)->GetX();
1653 //_______________________________________________________
1654 AliTRDtracker::AliTRDpropagationLayer::AliTRDpropagationLayer(Double_t x,
1655 Double_t dx, Double_t rho, Double_t x0, Int_t tb_index)
1658 // AliTRDpropagationLayer constructor
1661 fN = 0; fX = x; fdX = dx; fRho = rho; fX0 = x0;
1662 fClusters = NULL; fIndex = NULL; fTimeBinIndex = tb_index;
1665 for(Int_t i=0; i < (Int_t) kZONES; i++) {
1666 fZc[i]=0; fZmax[i] = 0;
1671 if(fTimeBinIndex >= 0) {
1672 fClusters = new AliTRDcluster*[kMAX_CLUSTER_PER_TIME_BIN];
1673 fIndex = new UInt_t[kMAX_CLUSTER_PER_TIME_BIN];
1686 //_______________________________________________________
1687 void AliTRDtracker::AliTRDpropagationLayer::SetHole(
1688 Double_t Zmax, Double_t Ymax, Double_t rho,
1689 Double_t x0, Double_t Yc, Double_t Zc)
1692 // Sets hole in the layer
1705 //_______________________________________________________
1706 AliTRDtracker::AliTRDtrackingSector::AliTRDtrackingSector(AliTRDgeometry* geo, Int_t gs, AliTRDparameter* par)
1709 // AliTRDtrackingSector Constructor
1718 for(UInt_t i=0; i < kMAX_TIME_BIN_INDEX; i++) fTimeBinIndex[i] = -1;
1721 AliTRDpropagationLayer* ppl;
1723 Double_t x, xin, xout, dx, rho, x0;
1726 // set time bins in the gas of the TPC
1728 xin = 246.055; xout = 254.055; steps = 20; dx = (xout-xin)/steps;
1729 rho = 0.9e-3; x0 = 28.94;
1731 for(Int_t i=0; i<steps; i++) {
1732 x = xin + i*dx + dx/2;
1733 ppl = new AliTRDpropagationLayer(x,dx,rho,x0,-1);
1737 // set time bins in the outer field cage vessel
1739 dx = 50e-4; xin = xout; xout = xin + dx; rho = 1.71; x0 = 44.77; // Tedlar
1740 ppl = new AliTRDpropagationLayer(xin+dx/2,dx,rho,x0,-1);
1743 dx = 0.02; xin = xout; xout = xin + dx; rho = 1.45; x0 = 44.86; // prepreg
1744 ppl = new AliTRDpropagationLayer(xin+dx/2,dx,rho,x0,-1);
1747 dx = 2.; xin = xout; xout = xin + dx; rho = 1.45*0.02; x0 = 41.28; // Nomex
1748 steps = 5; dx = (xout - xin)/steps;
1749 for(Int_t i=0; i<steps; i++) {
1750 x = xin + i*dx + dx/2;
1751 ppl = new AliTRDpropagationLayer(x,dx,rho,x0,-1);
1755 dx = 0.02; xin = xout; xout = xin + dx; rho = 1.45; x0 = 44.86; // prepreg
1756 ppl = new AliTRDpropagationLayer(xin+dx/2,dx,rho,x0,-1);
1759 dx = 50e-4; xin = xout; xout = xin + dx; rho = 1.71; x0 = 44.77; // Tedlar
1760 ppl = new AliTRDpropagationLayer(xin+dx/2,dx,rho,x0,-1);
1764 // set time bins in CO2
1766 xin = xout; xout = 275.0;
1767 steps = 50; dx = (xout - xin)/steps;
1768 rho = 1.977e-3; x0 = 36.2;
1770 for(Int_t i=0; i<steps; i++) {
1771 x = xin + i*dx + dx/2;
1772 ppl = new AliTRDpropagationLayer(x,dx,rho,x0,-1);
1776 // set time bins in the outer containment vessel
1778 dx = 50e-4; xin = xout; xout = xin + dx; rho = 2.7; x0 = 24.01; // Al
1779 ppl = new AliTRDpropagationLayer(xin+dx/2,dx,rho,x0,-1);
1782 dx = 50e-4; xin = xout; xout = xin + dx; rho = 1.71; x0 = 44.77; // Tedlar
1783 ppl = new AliTRDpropagationLayer(xin+dx/2,dx,rho,x0,-1);
1786 dx = 0.06; xin = xout; xout = xin + dx; rho = 1.45; x0 = 44.86; // prepreg
1787 ppl = new AliTRDpropagationLayer(xin+dx/2,dx,rho,x0,-1);
1790 dx = 3.; xin = xout; xout = xin + dx; rho = 1.45*0.02; x0 = 41.28; // Nomex
1791 steps = 10; dx = (xout - xin)/steps;
1792 for(Int_t i=0; i<steps; i++) {
1793 x = xin + i*dx + dx/2;
1794 ppl = new AliTRDpropagationLayer(x,dx,rho,x0,-1);
1798 dx = 0.06; xin = xout; xout = xin + dx; rho = 1.45; x0 = 44.86; // prepreg
1799 ppl = new AliTRDpropagationLayer(xin+dx/2,dx,rho,x0,-1);
1802 dx = 50e-4; xin = xout; xout = xin + dx; rho = 1.71; x0 = 44.77; // Tedlar
1803 ppl = new AliTRDpropagationLayer(xin+dx/2,dx,rho,x0,-1);
1806 dx = 50e-4; xin = xout; xout = xin + dx; rho = 2.7; x0 = 24.01; // Al
1807 ppl = new AliTRDpropagationLayer(xin+dx/2,dx,rho,x0,-1);
1810 Double_t xtrd = (Double_t) fGeom->Rmin();
1812 // add layers between TPC and TRD (Air temporarily)
1813 xin = xout; xout = xtrd;
1814 steps = 50; dx = (xout - xin)/steps;
1815 rho = 1.2e-3; x0 = 36.66;
1817 for(Int_t i=0; i<steps; i++) {
1818 x = xin + i*dx + dx/2;
1819 ppl = new AliTRDpropagationLayer(x,dx,rho,x0,-1);
1824 Double_t alpha=AliTRDgeometry::GetAlpha();
1826 // add layers for each of the planes
1828 Double_t dxRo = (Double_t) fGeom->CroHght(); // Rohacell
1829 Double_t dxSpace = (Double_t) fGeom->Cspace(); // Spacing between planes
1830 Double_t dxAmp = (Double_t) fGeom->CamHght(); // Amplification region
1831 Double_t dxDrift = (Double_t) fGeom->CdrHght(); // Drift region
1832 Double_t dxRad = (Double_t) fGeom->CraHght(); // Radiator
1833 Double_t dxTEC = dxRad + dxDrift + dxAmp + dxRo;
1834 Double_t dxPlane = dxTEC + dxSpace;
1836 Int_t tbBefore = (Int_t) (dxAmp/fPar->GetTimeBinSize());
1837 if(tbBefore > fPar->GetTimeBefore()) tbBefore = fPar->GetTimeBefore();
1840 const Int_t nChambers = AliTRDgeometry::Ncham();
1841 Double_t Ymax = 0, holeYmax = 0;
1842 Double_t * Zc = new Double_t[nChambers];
1843 Double_t * Zmax = new Double_t[nChambers];
1844 Double_t holeZmax = 1000.; // the whole sector is missing
1847 for(Int_t plane = 0; plane < AliTRDgeometry::Nplan(); plane++) {
1850 xin = xtrd + plane * dxPlane; xout = xin + dxRad;
1851 steps = 12; dx = (xout - xin)/steps; rho = 0.074; x0 = 40.6;
1852 for(Int_t i=0; i<steps; i++) {
1853 x = xin + i*dx + dx/2;
1854 ppl = new AliTRDpropagationLayer(x,dx,rho,x0,-1);
1855 if((fGeom->GetPHOShole()) && (fGeomSector >= 2) && (fGeomSector <= 6)) {
1856 holeYmax = x*TMath::Tan(0.5*alpha);
1857 ppl->SetHole(holeYmax, holeZmax);
1859 if((fGeom->GetRICHhole()) && (fGeomSector >= 12) && (fGeomSector <= 14)) {
1860 holeYmax = x*TMath::Tan(0.5*alpha);
1861 ppl->SetHole(holeYmax, holeZmax);
1866 Ymax = fGeom->GetChamberWidth(plane)/2;
1867 for(Int_t ch = 0; ch < nChambers; ch++) {
1868 Zmax[ch] = fGeom->GetChamberLength(plane,ch)/2;
1869 Float_t pad = fPar->GetRowPadSize(plane,ch,0);
1870 Float_t row0 = fPar->GetRow0(plane,ch,0);
1871 Int_t nPads = fPar->GetRowMax(plane,ch,0);
1872 Zc[ch] = (pad * nPads)/2 + row0 - pad/2;
1875 dx = fPar->GetTimeBinSize();
1876 rho = 0.00295 * 0.85; x0 = 11.0;
1878 Double_t x0 = (Double_t) fPar->GetTime0(plane);
1879 Double_t xbottom = x0 - dxDrift;
1880 Double_t xtop = x0 + dxAmp;
1882 // Amplification region
1884 steps = (Int_t) (dxAmp/dx);
1886 for(tb = 0; tb < steps; tb++) {
1887 x = x0 + tb * dx + dx/2;
1888 tb_index = CookTimeBinIndex(plane, -tb-1);
1889 ppl = new AliTRDpropagationLayer(x,dx,rho,x0,tb_index);
1891 for(Int_t ch = 0; ch < nChambers; ch++) {
1892 ppl->SetZmax(ch, Zc[ch], Zmax[ch]);
1894 if((fGeom->GetPHOShole()) && (fGeomSector >= 2) && (fGeomSector <= 6)) {
1895 holeYmax = x*TMath::Tan(0.5*alpha);
1896 ppl->SetHole(holeYmax, holeZmax);
1898 if((fGeom->GetRICHhole()) && (fGeomSector >= 12) && (fGeomSector <= 14)) {
1899 holeYmax = x*TMath::Tan(0.5*alpha);
1900 ppl->SetHole(holeYmax, holeZmax);
1904 tb_index = CookTimeBinIndex(plane, -steps);
1905 x = (x + dx/2 + xtop)/2;
1907 ppl = new AliTRDpropagationLayer(x,dx,rho,x0,tb_index);
1909 for(Int_t ch = 0; ch < nChambers; ch++) {
1910 ppl->SetZmax(ch, Zc[ch], Zmax[ch]);
1912 if((fGeom->GetPHOShole()) && (fGeomSector >= 2) && (fGeomSector <= 6)) {
1913 holeYmax = x*TMath::Tan(0.5*alpha);
1914 ppl->SetHole(holeYmax, holeZmax);
1916 if((fGeom->GetRICHhole()) && (fGeomSector >= 12) && (fGeomSector <= 14)) {
1917 holeYmax = x*TMath::Tan(0.5*alpha);
1918 ppl->SetHole(holeYmax, holeZmax);
1923 dx = fPar->GetTimeBinSize();
1924 steps = (Int_t) (dxDrift/dx);
1926 for(tb = 0; tb < steps; tb++) {
1927 x = x0 - tb * dx - dx/2;
1928 tb_index = CookTimeBinIndex(plane, tb);
1930 ppl = new AliTRDpropagationLayer(x,dx,rho,x0,tb_index);
1932 for(Int_t ch = 0; ch < nChambers; ch++) {
1933 ppl->SetZmax(ch, Zc[ch], Zmax[ch]);
1935 if((fGeom->GetPHOShole()) && (fGeomSector >= 2) && (fGeomSector <= 6)) {
1936 holeYmax = x*TMath::Tan(0.5*alpha);
1937 ppl->SetHole(holeYmax, holeZmax);
1939 if((fGeom->GetRICHhole()) && (fGeomSector >= 12) && (fGeomSector <= 14)) {
1940 holeYmax = x*TMath::Tan(0.5*alpha);
1941 ppl->SetHole(holeYmax, holeZmax);
1945 tb_index = CookTimeBinIndex(plane, steps);
1946 x = (x - dx/2 + xbottom)/2;
1948 ppl = new AliTRDpropagationLayer(x,dx,rho,x0,tb_index);
1950 for(Int_t ch = 0; ch < nChambers; ch++) {
1951 ppl->SetZmax(ch, Zc[ch], Zmax[ch]);
1953 if((fGeom->GetPHOShole()) && (fGeomSector >= 2) && (fGeomSector <= 6)) {
1954 holeYmax = x*TMath::Tan(0.5*alpha);
1955 ppl->SetHole(holeYmax, holeZmax);
1957 if((fGeom->GetRICHhole()) && (fGeomSector >= 12) && (fGeomSector <= 14)) {
1958 holeYmax = x*TMath::Tan(0.5*alpha);
1959 ppl->SetHole(holeYmax, holeZmax);
1964 xin = xtop; dx = 0.025; xout = xin + dx; rho = 1.7; x0 = 33.0;
1965 ppl = new AliTRDpropagationLayer(xin+dx/2,dx,rho,x0,-1);
1966 if((fGeom->GetPHOShole()) && (fGeomSector >= 2) && (fGeomSector <= 6)) {
1967 holeYmax = (xin+dx/2)*TMath::Tan(0.5*alpha);
1968 ppl->SetHole(holeYmax, holeZmax);
1970 if((fGeom->GetRICHhole()) && (fGeomSector >= 12) && (fGeomSector <= 14)) {
1971 holeYmax = (xin+dx/2)*TMath::Tan(0.5*alpha);
1972 ppl->SetHole(holeYmax, holeZmax);
1977 xin = xout; xout = xtrd + (plane + 1) * dxPlane - dxSpace;
1978 steps = 5; dx = (xout - xin)/steps; rho = 0.074; x0 = 40.6;
1979 for(Int_t i=0; i<steps; i++) {
1980 x = xin + i*dx + dx/2;
1981 ppl = new AliTRDpropagationLayer(x,dx,rho,x0,-1);
1982 if((fGeom->GetPHOShole()) && (fGeomSector >= 2) && (fGeomSector <= 6)) {
1983 holeYmax = x*TMath::Tan(0.5*alpha);
1984 ppl->SetHole(holeYmax, holeZmax);
1986 if((fGeom->GetRICHhole()) && (fGeomSector >= 12) && (fGeomSector <= 14)) {
1987 holeYmax = x*TMath::Tan(0.5*alpha);
1988 ppl->SetHole(holeYmax, holeZmax);
1993 // Space between the chambers, air
1994 xin = xout; xout = xtrd + (plane + 1) * dxPlane;
1995 steps = 5; dx = (xout - xin)/steps; rho = 1.29e-3; x0 = 36.66;
1996 for(Int_t i=0; i<steps; i++) {
1997 x = xin + i*dx + dx/2;
1998 ppl = new AliTRDpropagationLayer(x,dx,rho,x0,-1);
1999 if((fGeom->GetPHOShole()) && (fGeomSector >= 2) && (fGeomSector <= 6)) {
2000 holeYmax = x*TMath::Tan(0.5*alpha);
2001 ppl->SetHole(holeYmax, holeZmax);
2003 if((fGeom->GetRICHhole()) && (fGeomSector >= 12) && (fGeomSector <= 14)) {
2004 holeYmax = x*TMath::Tan(0.5*alpha);
2005 ppl->SetHole(holeYmax, holeZmax);
2011 // Space between the TRD and RICH
2012 Double_t xRICH = 500.;
2013 xin = xout; xout = xRICH;
2014 steps = 200; dx = (xout - xin)/steps; rho = 1.29e-3; x0 = 36.66;
2015 for(Int_t i=0; i<steps; i++) {
2016 x = xin + i*dx + dx/2;
2017 ppl = new AliTRDpropagationLayer(x,dx,rho,x0,-1);
2027 //______________________________________________________
2029 Int_t AliTRDtracker::AliTRDtrackingSector::CookTimeBinIndex(Int_t plane, Int_t local_tb) const
2032 // depending on the digitization parameters calculates "global"
2033 // time bin index for timebin <local_tb> in plane <plane>
2036 Double_t dxAmp = (Double_t) fGeom->CamHght(); // Amplification region
2037 Double_t dxDrift = (Double_t) fGeom->CdrHght(); // Drift region
2038 Double_t dx = (Double_t) fPar->GetTimeBinSize();
2040 Int_t tbAmp = fPar->GetTimeBefore();
2041 Int_t maxAmp = (Int_t) ((dxAmp+0.000001)/dx);
2042 Int_t tbDrift = fPar->GetTimeMax();
2043 Int_t maxDrift = (Int_t) ((dxDrift+0.000001)/dx);
2045 Int_t tb_per_plane = TMath::Min(tbAmp,maxAmp) + TMath::Min(tbDrift,maxDrift);
2047 Int_t gtb = (plane+1) * tb_per_plane - local_tb - 1;
2049 if((local_tb < 0) &&
2050 (TMath::Abs(local_tb) > TMath::Min(tbAmp,maxAmp))) return -1;
2051 if(local_tb >= TMath::Min(tbDrift,maxDrift)) return -1;
2058 //______________________________________________________
2060 void AliTRDtracker::AliTRDtrackingSector::MapTimeBinLayers()
2063 // For all sensitive time bins sets corresponding layer index
2064 // in the array fTimeBins
2069 for(Int_t i = 0; i < fN; i++) {
2070 index = fLayers[i]->GetTimeBinIndex();
2072 // printf("gtb %d -> pl %d -> x %f \n", index, i, fLayers[i]->GetX());
2074 if(index < 0) continue;
2075 if(index >= (Int_t) kMAX_TIME_BIN_INDEX) {
2076 printf("*** AliTRDtracker::MapTimeBinLayers: \n");
2077 printf(" index %d exceeds allowed maximum of %d!\n",
2078 index, kMAX_TIME_BIN_INDEX-1);
2081 fTimeBinIndex[index] = i;
2084 Double_t x1, dx1, x2, dx2, gap;
2086 for(Int_t i = 0; i < fN-1; i++) {
2087 x1 = fLayers[i]->GetX();
2088 dx1 = fLayers[i]->GetdX();
2089 x2 = fLayers[i+1]->GetX();
2090 dx2 = fLayers[i+1]->GetdX();
2091 gap = (x2 - dx2/2) - (x1 + dx1/2);
2093 printf("*** warning: layers %d and %d are overlayed:\n",i,i+1);
2094 printf(" %f + %f + %f > %f\n", x1, dx1/2, dx2/2, x2);
2097 printf("*** warning: layers %d and %d have a large gap:\n",i,i+1);
2098 printf(" (%f - %f) - (%f + %f) = %f\n",
2099 x2, dx2/2, x1, dx1, gap);
2105 //______________________________________________________
2108 Int_t AliTRDtracker::AliTRDtrackingSector::GetLayerNumber(Double_t x) const
2111 // Returns the number of time bin which in radial position is closest to <x>
2114 if(x >= fLayers[fN-1]->GetX()) return fN-1;
2115 if(x <= fLayers[0]->GetX()) return 0;
2117 Int_t b=0, e=fN-1, m=(b+e)/2;
2118 for (; b<e; m=(b+e)/2) {
2119 if (x > fLayers[m]->GetX()) b=m+1;
2122 if(TMath::Abs(x - fLayers[m]->GetX()) >
2123 TMath::Abs(x - fLayers[m+1]->GetX())) return m+1;
2128 //______________________________________________________
2130 Int_t AliTRDtracker::AliTRDtrackingSector::GetInnerTimeBin() const
2133 // Returns number of the innermost SENSITIVE propagation layer
2136 return GetLayerNumber(0);
2139 //______________________________________________________
2141 Int_t AliTRDtracker::AliTRDtrackingSector::GetOuterTimeBin() const
2144 // Returns number of the outermost SENSITIVE time bin
2147 return GetLayerNumber(GetNumberOfTimeBins() - 1);
2150 //______________________________________________________
2152 Int_t AliTRDtracker::AliTRDtrackingSector::GetNumberOfTimeBins() const
2155 // Returns number of SENSITIVE time bins
2159 for(tb = kMAX_TIME_BIN_INDEX-1; tb >=0; tb--) {
2160 layer = GetLayerNumber(tb);
2166 //______________________________________________________
2168 void AliTRDtracker::AliTRDtrackingSector::InsertLayer(AliTRDpropagationLayer* pl)
2171 // Insert layer <pl> in fLayers array.
2172 // Layers are sorted according to X coordinate.
2174 if ( fN == ((Int_t) kMAX_LAYERS_PER_SECTOR)) {
2175 printf("AliTRDtrackingSector::InsertLayer(): Too many layers !\n");
2178 if (fN==0) {fLayers[fN++] = pl; return;}
2179 Int_t i=Find(pl->GetX());
2181 memmove(fLayers+i+1 ,fLayers+i,(fN-i)*sizeof(AliTRDpropagationLayer*));
2182 fLayers[i]=pl; fN++;
2186 //______________________________________________________
2188 Int_t AliTRDtracker::AliTRDtrackingSector::Find(Double_t x) const
2191 // Returns index of the propagation layer nearest to X
2194 if (x <= fLayers[0]->GetX()) return 0;
2195 if (x > fLayers[fN-1]->GetX()) return fN;
2196 Int_t b=0, e=fN-1, m=(b+e)/2;
2197 for (; b<e; m=(b+e)/2) {
2198 if (x > fLayers[m]->GetX()) b=m+1;
2204 //______________________________________________________
2206 void AliTRDtracker::AliTRDpropagationLayer::GetPropagationParameters(
2207 Double_t y, Double_t z, Double_t &dx, Double_t &rho, Double_t &x0,
2208 Bool_t &lookForCluster) const
2211 // Returns radial step <dx>, density <rho>, rad. length <x0>,
2212 // and sensitivity <lookForCluster> in point <y,z>
2218 lookForCluster = kFALSE;
2220 // check dead regions
2221 if(fTimeBinIndex >= 0) {
2222 for(Int_t ch = 0; ch < (Int_t) kZONES; ch++) {
2223 if(TMath::Abs(z - fZc[ch]) < fZmax[ch])
2224 lookForCluster = kTRUE;
2226 if(TMath::Abs(y) > fYmax) lookForCluster = kFALSE;
2227 if(!lookForCluster) {
2228 // rho = 1.7; x0 = 33.0; // G10
2233 if(fHole && (TMath::Abs(y - fHoleYc) < fHoleYmax) &&
2234 (TMath::Abs(z - fHoleZc) < fHoleZmax)) {
2235 lookForCluster = kFALSE;
2243 //______________________________________________________
2245 void AliTRDtracker::AliTRDpropagationLayer::InsertCluster(AliTRDcluster* c,
2248 // Insert cluster in cluster array.
2249 // Clusters are sorted according to Y coordinate.
2251 if(fTimeBinIndex < 0) {
2252 printf("*** attempt to insert cluster into non-sensitive time bin!\n");
2256 if (fN== (Int_t) kMAX_CLUSTER_PER_TIME_BIN) {
2257 printf("AliTRDpropagationLayer::InsertCluster(): Too many clusters !\n");
2260 if (fN==0) {fIndex[0]=index; fClusters[fN++]=c; return;}
2261 Int_t i=Find(c->GetY());
2262 memmove(fClusters+i+1 ,fClusters+i,(fN-i)*sizeof(AliTRDcluster*));
2263 memmove(fIndex +i+1 ,fIndex +i,(fN-i)*sizeof(UInt_t));
2264 fIndex[i]=index; fClusters[i]=c; fN++;
2267 //______________________________________________________
2269 Int_t AliTRDtracker::AliTRDpropagationLayer::Find(Double_t y) const {
2271 // Returns index of the cluster nearest in Y
2273 if (y <= fClusters[0]->GetY()) return 0;
2274 if (y > fClusters[fN-1]->GetY()) return fN;
2275 Int_t b=0, e=fN-1, m=(b+e)/2;
2276 for (; b<e; m=(b+e)/2) {
2277 if (y > fClusters[m]->GetY()) b=m+1;