Reducing dependencies (F.Carminati)
[u/mrichter/AliRoot.git] / TRD / AliTRDtracker.cxx
CommitLineData
46d29e70 1/**************************************************************************
2 * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
3 * *
4 * Author: The ALICE Off-line Project. *
5 * Contributors are mentioned in the code where appropriate. *
6 * *
7 * Permission to use, copy, modify and distribute this software and its *
8 * documentation strictly for non-commercial purposes is hereby granted *
9 * without fee, provided that the above copyright notice appears in all *
10 * copies and that both the copyright notice and this permission notice *
11 * appear in the supporting documentation. The authors make no claims *
12 * about the suitability of this software for any purpose. It is *
13 * provided "as is" without express or implied warranty. *
14 **************************************************************************/
15
c630aafd 16/*
17$Log$
73ae7b59 18Revision 1.29 2003/07/22 15:56:14 hristov
19Implementing ESD functionality in the NewIO (Yu.Belikov)
20
c630aafd 21Revision 1.27.2.2 2003/07/14 09:19:33 hristov
22TOF included in the combined PID (Yu.Belikov)
23
24Revision 1.27.2.1 2003/07/11 10:53:01 hristov
25Inward refit for TPC and TRD in the ESD schema (T.Kuhr)
26
27Revision 1.27 2003/05/27 17:46:13 hristov
28TRD PID included in the ESD schema (T.Kuhr)
29
30Revision 1.26 2003/04/10 10:36:54 hristov
31Code for unified TPC/TRD tracking (S.Radomski)
32
33Revision 1.25 2003/03/19 17:14:11 hristov
34Load/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)
35
36Revision 1.24 2003/02/19 09:02:28 hristov
37Track time measurement (S.Radomski)
38
39Revision 1.23 2003/02/10 14:06:10 cblume
40Add tracking without tilted pads as option
41
42Revision 1.22 2003/01/30 15:19:58 cblume
43New set of parameters
44
45Revision 1.21 2003/01/27 16:34:49 cblume
46Update of tracking by Sergei and Chuncheng
47
48Revision 1.20 2002/11/07 15:52:09 cblume
49Update of tracking code for tilted pads
50
51Revision 1.19 2002/10/22 15:53:08 alibrary
52Introducing Riostream.h
53
54Revision 1.18 2002/10/14 14:57:44 hristov
55Merging the VirtualMC branch to the main development branch (HEAD)
56
57Revision 1.14.6.2 2002/07/24 10:09:31 alibrary
58Updating VirtualMC
59
60Revision 1.17 2002/06/13 12:09:58 hristov
61Minor corrections
62
63Revision 1.16 2002/06/12 09:54:36 cblume
64Update of tracking code provided by Sergei
65
66Revision 1.14 2001/11/14 10:50:46 cblume
67Changes in digits IO. Add merging of summable digits
68
69Revision 1.13 2001/05/30 12:17:47 hristov
70Loop variables declared once
71
72Revision 1.12 2001/05/28 17:07:58 hristov
73Last minute changes; ExB correction in AliTRDclusterizerV1; taking into account of material in G10 TEC frames and material between TEC planes (C.Blume,S.Sedykh)
74
75Revision 1.8 2000/12/20 13:00:44 cblume
76Modifications for the HP-compiler
77
78Revision 1.7 2000/12/08 16:07:02 cblume
79Update of the tracking by Sergei
80
81Revision 1.6 2000/11/30 17:38:08 cblume
82Changes to get in line with new STEER and EVGEN
83
84Revision 1.5 2000/11/14 14:40:27 cblume
85Correction for the Sun compiler (kTRUE and kFALSE)
86
87Revision 1.4 2000/11/10 14:57:52 cblume
88Changes in the geometry constants for the DEC compiler
89
90Revision 1.3 2000/10/15 23:40:01 cblume
91Remove AliTRDconst
92
93Revision 1.2 2000/10/06 16:49:46 cblume
94Made Getters const
95
96Revision 1.1.2.2 2000/10/04 16:34:58 cblume
97Replace include files by forward declarations
98
99Revision 1.1.2.1 2000/09/22 14:47:52 cblume
100Add the tracking code
101
102*/
bbf92647 103
a2cb5b3d 104#include <Riostream.h>
46d29e70 105
106#include <TFile.h>
46d29e70 107#include <TBranch.h>
5443e65e 108#include <TTree.h>
c630aafd 109#include <TObjArray.h>
46d29e70 110
46d29e70 111#include "AliTRDgeometry.h"
5443e65e 112#include "AliTRDparameter.h"
113#include "AliTRDgeometryDetail.h"
46d29e70 114#include "AliTRDcluster.h"
115#include "AliTRDtrack.h"
c630aafd 116#include "AliTRDPartID.h"
5443e65e 117#include "../TPC/AliTPCtrack.h"
46d29e70 118
119#include "AliTRDtracker.h"
120
121ClassImp(AliTRDtracker)
122
c630aafd 123 const Float_t AliTRDtracker::fSeedDepth = 0.5;
124 const Float_t AliTRDtracker::fSeedStep = 0.10;
125 const Float_t AliTRDtracker::fSeedGap = 0.25;
5443e65e 126
c630aafd 127 const Float_t AliTRDtracker::fMaxSeedDeltaZ12 = 40.;
128 const Float_t AliTRDtracker::fMaxSeedDeltaZ = 25.;
129 const Float_t AliTRDtracker::fMaxSeedC = 0.0052;
130 const Float_t AliTRDtracker::fMaxSeedTan = 1.2;
131 const Float_t AliTRDtracker::fMaxSeedVertexZ = 150.;
a819a5f7 132
c630aafd 133 const Double_t AliTRDtracker::fSeedErrorSY = 0.2;
134 const Double_t AliTRDtracker::fSeedErrorSY3 = 2.5;
135 const Double_t AliTRDtracker::fSeedErrorSZ = 0.1;
bbf92647 136
c630aafd 137 const Float_t AliTRDtracker::fMinClustersInSeed = 0.7;
bbf92647 138
c630aafd 139 const Float_t AliTRDtracker::fMinClustersInTrack = 0.5;
140 const Float_t AliTRDtracker::fMinFractionOfFoundClusters = 0.8;
bbf92647 141
c630aafd 142 const Float_t AliTRDtracker::fSkipDepth = 0.3;
143 const Float_t AliTRDtracker::fLabelFraction = 0.8;
144 const Float_t AliTRDtracker::fWideRoad = 20.;
5443e65e 145
c630aafd 146 const Double_t AliTRDtracker::fMaxChi2 = 12.;
a819a5f7 147
c630aafd 148const Int_t AliTRDtracker::kFirstPlane = 5;
149const Int_t AliTRDtracker::kLastPlane = 17;
9c9d2487 150
bbf92647 151
46d29e70 152//____________________________________________________________________
c630aafd 153AliTRDtracker::AliTRDtracker(const TFile *geomfile):AliTracker()
46d29e70 154{
5443e65e 155 //
156 // Main constructor
157 //
46d29e70 158
c630aafd 159 //Float_t fTzero = 0;
b8dc2353 160
5443e65e 161 fAddTRDseeds = kFALSE;
5443e65e 162 fGeom = NULL;
b8dc2353 163 fNoTilt = kFALSE;
5443e65e 164
165 TDirectory *savedir=gDirectory;
166 TFile *in=(TFile*)geomfile;
167 if (!in->IsOpen()) {
168 printf("AliTRDtracker::AliTRDtracker(): geometry file is not open!\n");
169 printf(" DETAIL TRD geometry and DEFAULT TRD parameter will be used\n");
170 }
171 else {
172 in->cd();
c630aafd 173// in->ls();
5443e65e 174 fGeom = (AliTRDgeometry*) in->Get("TRDgeometry");
175 fPar = (AliTRDparameter*) in->Get("TRDparameter");
c630aafd 176// fGeom->Dump();
5443e65e 177 }
46d29e70 178
5443e65e 179 if(fGeom) {
180 // fTzero = geo->GetT0();
b8dc2353 181 printf("Found geometry version %d on file \n", fGeom->IsVersion());
5443e65e 182 }
183 else {
c630aafd 184 printf("AliTRDtracker::AliTRDtracker(): can't find TRD geometry!\n");
185 printf("The DETAIL TRD geometry will be used\n");
186 fGeom = new AliTRDgeometryDetail();
187 }
188
189 if (!fPar) {
190 printf("AliTRDtracker::AliTRDtracker(): can't find TRD parameter!\n");
191 printf("The DEFAULT TRD parameter will be used\n");
5443e65e 192 fPar = new AliTRDparameter();
193 }
c630aafd 194 fPar->ReInit();
5443e65e 195
196 savedir->cd();
46d29e70 197
5443e65e 198
199 // fGeom->SetT0(fTzero);
0a29d0f1 200
46d29e70 201 fNclusters = 0;
202 fClusters = new TObjArray(2000);
203 fNseeds = 0;
5443e65e 204 fSeeds = new TObjArray(2000);
46d29e70 205 fNtracks = 0;
5443e65e 206 fTracks = new TObjArray(1000);
a819a5f7 207
5443e65e 208 for(Int_t geom_s = 0; geom_s < kTRACKING_SECTORS; geom_s++) {
209 Int_t tr_s = CookSectorIndex(geom_s);
210 fTrSec[tr_s] = new AliTRDtrackingSector(fGeom, geom_s, fPar);
211 }
a819a5f7 212
b8dc2353 213 Float_t tilt_angle = TMath::Abs(fPar->GetTiltingAngle());
214 if(tilt_angle < 0.1) {
215 fNoTilt = kTRUE;
216 }
217
218 fSY2corr = 0.2;
219 fSZ2corr = 120.;
220
221 if(fNoTilt && (tilt_angle > 0.1)) fSY2corr = fSY2corr + tilt_angle * 0.05;
222
bbf92647 223
5443e65e 224 // calculate max gap on track
a819a5f7 225
5443e65e 226 Double_t dxAmp = (Double_t) fGeom->CamHght(); // Amplification region
227 Double_t dxDrift = (Double_t) fGeom->CdrHght(); // Drift region
a819a5f7 228
5443e65e 229 Double_t dx = (Double_t) fPar->GetTimeBinSize();
230 Int_t tbAmp = fPar->GetTimeBefore();
231 Int_t maxAmp = (Int_t) ((dxAmp+0.000001)/dx);
b3a5a838 232 if(kTRUE) maxAmp = 0; // intentional until we change the parameter class
5443e65e 233 Int_t tbDrift = fPar->GetTimeMax();
234 Int_t maxDrift = (Int_t) ((dxDrift+0.000001)/dx);
a819a5f7 235
5443e65e 236 tbDrift = TMath::Min(tbDrift,maxDrift);
237 tbAmp = TMath::Min(tbAmp,maxAmp);
46d29e70 238
5443e65e 239 fTimeBinsPerPlane = tbAmp + tbDrift;
c630aafd 240 fMaxGap = (Int_t) (fTimeBinsPerPlane * fGeom->Nplan() * fSkipDepth);
46d29e70 241
5443e65e 242 fVocal = kFALSE;
0a29d0f1 243
9c9d2487 244
245 // Barrel Tracks [SR, 03.04.2003]
246
247 fBarrelFile = 0;
248 fBarrelTree = 0;
249 fBarrelArray = 0;
250 fBarrelTrack = 0;
251
252 savedir->cd();
5443e65e 253}
46d29e70 254
5443e65e 255//___________________________________________________________________
256AliTRDtracker::~AliTRDtracker()
46d29e70 257{
5443e65e 258 delete fClusters;
259 delete fTracks;
260 delete fSeeds;
261 delete fGeom;
262 delete fPar;
0a29d0f1 263
5443e65e 264 for(Int_t geom_s = 0; geom_s < kTRACKING_SECTORS; geom_s++) {
265 delete fTrSec[geom_s];
266 }
267}
46d29e70 268
9c9d2487 269//_____________________________________________________________________
270
271void AliTRDtracker::SetBarrelTree(const char *mode) {
272 //
273 //
274 //
275
276 if (!IsStoringBarrel()) return;
277
278 TDirectory *sav = gDirectory;
279 if (!fBarrelFile) fBarrelFile = new TFile("AliBarrelTracks.root", "UPDATE");
280
281 char buff[40];
282 sprintf(buff, "BarrelTRD_%d_%s", GetEventNumber(), mode);
283
284 fBarrelFile->cd();
285 fBarrelTree = new TTree(buff, "Barrel TPC tracks");
286
287 Int_t nRefs = kLastPlane - kFirstPlane + 1;
288
289 if (!fBarrelArray) fBarrelArray = new TClonesArray("AliBarrelTrack", nRefs);
290 for(Int_t i=0; i<nRefs; i++) new((*fBarrelArray)[i]) AliBarrelTrack();
291
292 fBarrelTree->Branch("tracks", &fBarrelArray);
293 sav->cd();
294}
295
296//_____________________________________________________________________
297
298void AliTRDtracker::StoreBarrelTrack(AliTRDtrack *ps, Int_t refPlane, Int_t isIn) {
299 //
300 //
301 //
302
303 if (!IsStoringBarrel()) return;
304
305 static Int_t nClusters;
306 static Int_t nWrong;
307 static Double_t chi2;
308 static Int_t index;
309 static Bool_t wasLast = kTRUE;
310
311 Int_t newClusters, newWrong;
312 Double_t newChi2;
313
314 if (wasLast) {
315
316 fBarrelArray->Clear();
317 nClusters = nWrong = 0;
318 chi2 = 0.0;
319 index = 0;
320 wasLast = kFALSE;
321 }
322
323 fBarrelTrack = (AliBarrelTrack*)(*fBarrelArray)[index++];
324 ps->GetBarrelTrack(fBarrelTrack);
325
326 newClusters = ps->GetNumberOfClusters() - nClusters;
327 newWrong = ps->GetNWrong() - nWrong;
328 newChi2 = ps->GetChi2() - chi2;
329
330 nClusters = ps->GetNumberOfClusters();
331 nWrong = ps->GetNWrong();
332 chi2 = ps->GetChi2();
333
334 if (refPlane != kLastPlane) {
335 fBarrelTrack->SetNClusters(newClusters, newChi2);
336 fBarrelTrack->SetNWrongClusters(newWrong);
337 } else {
338 wasLast = kTRUE;
339 }
340
341 fBarrelTrack->SetRefPlane(refPlane, isIn);
342}
343
344//_____________________________________________________________________
345
346Bool_t AliTRDtracker::AdjustSector(AliTRDtrack *track) {
347 //
348 // Rotates the track when necessary
349 //
350
351 Double_t alpha = AliTRDgeometry::GetAlpha();
352 Double_t y = track->GetY();
353 Double_t ymax = track->GetX()*TMath::Tan(0.5*alpha);
354
c630aafd 355 //Int_t ns = AliTRDgeometry::kNsect;
9c9d2487 356 //Int_t s=Int_t(track->GetAlpha()/alpha)%ns;
357
358 if (y > ymax) {
359 //s = (s+1) % ns;
360 if (!track->Rotate(alpha)) return kFALSE;
361 } else if (y <-ymax) {
362 //s = (s-1+ns) % ns;
363 if (!track->Rotate(-alpha)) return kFALSE;
364 }
365
366 return kTRUE;
367}
368
46d29e70 369//_____________________________________________________________________
5443e65e 370inline Double_t f1trd(Double_t x1,Double_t y1,
a9814c09 371 Double_t x2,Double_t y2,
372 Double_t x3,Double_t y3)
46d29e70 373{
0a29d0f1 374 //
46d29e70 375 // Initial approximation of the track curvature
0a29d0f1 376 //
46d29e70 377 Double_t d=(x2-x1)*(y3-y2)-(x3-x2)*(y2-y1);
378 Double_t a=0.5*((y3-y2)*(y2*y2-y1*y1+x2*x2-x1*x1)-
379 (y2-y1)*(y3*y3-y2*y2+x3*x3-x2*x2));
380 Double_t b=0.5*((x2-x1)*(y3*y3-y2*y2+x3*x3-x2*x2)-
381 (x3-x2)*(y2*y2-y1*y1+x2*x2-x1*x1));
382
383 Double_t xr=TMath::Abs(d/(d*x1-a)), yr=d/(d*y1-b);
384
385 return -xr*yr/sqrt(xr*xr+yr*yr);
386}
387
388//_____________________________________________________________________
5443e65e 389inline Double_t f2trd(Double_t x1,Double_t y1,
a9814c09 390 Double_t x2,Double_t y2,
391 Double_t x3,Double_t y3)
46d29e70 392{
0a29d0f1 393 //
5443e65e 394 // Initial approximation of the track curvature times X coordinate
395 // of the center of curvature
0a29d0f1 396 //
46d29e70 397
398 Double_t d=(x2-x1)*(y3-y2)-(x3-x2)*(y2-y1);
399 Double_t a=0.5*((y3-y2)*(y2*y2-y1*y1+x2*x2-x1*x1)-
400 (y2-y1)*(y3*y3-y2*y2+x3*x3-x2*x2));
401 Double_t b=0.5*((x2-x1)*(y3*y3-y2*y2+x3*x3-x2*x2)-
402 (x3-x2)*(y2*y2-y1*y1+x2*x2-x1*x1));
403
404 Double_t xr=TMath::Abs(d/(d*x1-a)), yr=d/(d*y1-b);
405
406 return -a/(d*y1-b)*xr/sqrt(xr*xr+yr*yr);
407}
408
409//_____________________________________________________________________
5443e65e 410inline Double_t f3trd(Double_t x1,Double_t y1,
a9814c09 411 Double_t x2,Double_t y2,
412 Double_t z1,Double_t z2)
46d29e70 413{
0a29d0f1 414 //
46d29e70 415 // Initial approximation of the tangent of the track dip angle
0a29d0f1 416 //
46d29e70 417
418 return (z1 - z2)/sqrt((x1-x2)*(x1-x2)+(y1-y2)*(y1-y2));
419}
420
46d29e70 421//___________________________________________________________________
5443e65e 422Int_t AliTRDtracker::Clusters2Tracks(const TFile *inp, TFile *out)
46d29e70 423{
0a29d0f1 424 //
5443e65e 425 // Finds tracks within the TRD. File <inp> is expected to contain seeds
426 // at the outer part of the TRD. If <inp> is NULL, the seeds
427 // are found within the TRD if fAddTRDseeds is TRUE.
428 // The tracks are propagated to the innermost time bin
429 // of the TRD and stored in file <out>.
0a29d0f1 430 //
a819a5f7 431
5443e65e 432 LoadEvent();
433
434 TDirectory *savedir=gDirectory;
a819a5f7 435
5443e65e 436 char tname[100];
a819a5f7 437
5443e65e 438 if (!out->IsOpen()) {
439 cerr<<"AliTRDtracker::Clusters2Tracks(): output file is not open !\n";
440 return 1;
441 }
46d29e70 442
e24ea474 443 sprintf(tname,"seedTRDtoTPC_%d",GetEventNumber());
5443e65e 444 TTree tpc_tree(tname,"Tree with seeds from TRD at outer TPC pad row");
445 AliTPCtrack *iotrack=0;
446 tpc_tree.Branch("tracks","AliTPCtrack",&iotrack,32000,0);
447
e24ea474 448 sprintf(tname,"TreeT%d_TRD",GetEventNumber());
5443e65e 449 TTree trd_tree(tname,"TRD tracks at inner TRD time bin");
450 AliTRDtrack *iotrack_trd=0;
451 trd_tree.Branch("tracks","AliTRDtrack",&iotrack_trd,32000,0);
452
453 Int_t timeBins = fTrSec[0]->GetNumberOfTimeBins();
c630aafd 454 Float_t foundMin = fMinClustersInTrack * timeBins;
5443e65e 455
456 if (inp) {
457 TFile *in=(TFile*)inp;
458 if (!in->IsOpen()) {
c630aafd 459 cerr<<
460 "AliTRDtracker::Clusters2Tracks(): file with seeds is not open !\n";
5443e65e 461 cerr<<" ... going for seeds finding inside the TRD\n";
462 }
463 else {
464 in->cd();
e24ea474 465 sprintf(tname,"TRDb_%d",GetEventNumber());
5443e65e 466 TTree *seedTree=(TTree*)in->Get(tname);
467 if (!seedTree) {
a9814c09 468 cerr<<"AliTRDtracker::Clusters2Tracks(): ";
469 cerr<<"can't get a tree with track seeds !\n";
470 return 3;
5443e65e 471 }
472 AliTRDtrack *seed=new AliTRDtrack;
473 seedTree->SetBranchAddress("tracks",&seed);
474
475 Int_t n=(Int_t)seedTree->GetEntries();
476 for (Int_t i=0; i<n; i++) {
a9814c09 477 seedTree->GetEvent(i);
478 seed->ResetCovariance();
479 AliTRDtrack *tr = new AliTRDtrack(*seed,seed->GetAlpha());
480 fSeeds->AddLast(tr);
481 fNseeds++;
5443e65e 482 }
483 delete seed;
fd621f36 484 delete seedTree;
5443e65e 485 }
486 }
46d29e70 487
5443e65e 488 out->cd();
46d29e70 489
fd621f36 490
5443e65e 491 // find tracks from loaded seeds
a819a5f7 492
5443e65e 493 Int_t nseed=fSeeds->GetEntriesFast();
494 Int_t i, found = 0;
495 Int_t innerTB = fTrSec[0]->GetInnerTimeBin();
496
497 for (i=0; i<nseed; i++) {
498 AliTRDtrack *pt=(AliTRDtrack*)fSeeds->UncheckedAt(i), &t=*pt;
499 FollowProlongation(t, innerTB);
500 if (t.GetNumberOfClusters() >= foundMin) {
501 UseClusters(&t);
c630aafd 502 CookLabel(pt, 1-fLabelFraction);
5443e65e 503 // t.CookdEdx();
504 }
505 iotrack_trd = pt;
506 trd_tree.Fill();
e24ea474 507 found++;
508// cout<<found<<'\r';
5443e65e 509
510 if(PropagateToTPC(t)) {
511 AliTPCtrack *tpc = new AliTPCtrack(*pt,pt->GetAlpha());
512 iotrack = tpc;
513 tpc_tree.Fill();
514 delete tpc;
515 }
516 delete fSeeds->RemoveAt(i);
517 fNseeds--;
518 }
a819a5f7 519
5443e65e 520 cout<<"Number of loaded seeds: "<<nseed<<endl;
521 cout<<"Number of found tracks from loaded seeds: "<<found<<endl;
a819a5f7 522
5443e65e 523 // after tracks from loaded seeds are found and the corresponding
524 // clusters are used, look for additional seeds from TRD
46d29e70 525
5443e65e 526 if(fAddTRDseeds) {
527 // Find tracks for the seeds in the TRD
528 Int_t timeBins = fTrSec[0]->GetNumberOfTimeBins();
529
c630aafd 530 Int_t nSteps = (Int_t) (fSeedDepth / fSeedStep);
531 Int_t gap = (Int_t) (timeBins * fSeedGap);
532 Int_t step = (Int_t) (timeBins * fSeedStep);
5443e65e 533
534 // make a first turn with tight cut on initial curvature
535 for(Int_t turn = 1; turn <= 2; turn++) {
536 if(turn == 2) {
c630aafd 537 nSteps = (Int_t) (fSeedDepth / (3*fSeedStep));
538 step = (Int_t) (timeBins * (3*fSeedStep));
5443e65e 539 }
540 for(Int_t i=0; i<nSteps; i++) {
a9814c09 541 Int_t outer=timeBins-1-i*step;
542 Int_t inner=outer-gap;
46d29e70 543
a9814c09 544 nseed=fSeeds->GetEntriesFast();
5443e65e 545
a9814c09 546 MakeSeeds(inner, outer, turn);
5443e65e 547
a9814c09 548 nseed=fSeeds->GetEntriesFast();
549 printf("\n turn %d, step %d: number of seeds for TRD inward %d\n",
550 turn, i, nseed);
551
552 for (Int_t i=0; i<nseed; i++) {
553 AliTRDtrack *pt=(AliTRDtrack*)fSeeds->UncheckedAt(i), &t=*pt;
554 FollowProlongation(t,innerTB);
555 if (t.GetNumberOfClusters() >= foundMin) {
556 UseClusters(&t);
c630aafd 557 CookLabel(pt, 1-fLabelFraction);
a9814c09 558 t.CookdEdx();
c630aafd 559 found++;
e24ea474 560// cout<<found<<'\r';
a9814c09 561 iotrack_trd = pt;
562 trd_tree.Fill();
563 if(PropagateToTPC(t)) {
564 AliTPCtrack *tpc = new AliTPCtrack(*pt,pt->GetAlpha());
565 iotrack = tpc;
566 tpc_tree.Fill();
567 delete tpc;
568 }
569 }
570 delete fSeeds->RemoveAt(i);
571 fNseeds--;
572 }
46d29e70 573 }
5443e65e 574 }
575 }
576 tpc_tree.Write();
577 trd_tree.Write();
578
579 cout<<"Total number of found tracks: "<<found<<endl;
580
581 UnloadEvent();
582
583 savedir->cd();
584
585 return 0;
586}
c630aafd 587
588//___________________________________________________________________
589Int_t AliTRDtracker::Clusters2Tracks(AliESD* event)
590{
591 //
592 // Finds tracks within the TRD. The ESD event is expected to contain seeds
593 // at the outer part of the TRD. The seeds
594 // are found within the TRD if fAddTRDseeds is TRUE.
595 // The tracks are propagated to the innermost time bin
596 // of the TRD and the ESD event is updated
597 //
598
599 Int_t timeBins = fTrSec[0]->GetNumberOfTimeBins();
600 Float_t foundMin = fMinClustersInTrack * timeBins;
601 Int_t nseed = 0;
602 Int_t found = 0;
603 Int_t innerTB = fTrSec[0]->GetInnerTimeBin();
604
605 Int_t n = event->GetNumberOfTracks();
606 for (Int_t i=0; i<n; i++) {
607 AliESDtrack* seed=event->GetTrack(i);
608 ULong_t status=seed->GetStatus();
609 if ( (status & AliESDtrack::kTRDout ) == 0 ) continue;
610 if ( (status & AliESDtrack::kTRDin) != 0 ) continue;
611 nseed++;
612
613 AliTRDtrack* seed2 = new AliTRDtrack(*seed);
614 seed2->ResetCovariance();
615 AliTRDtrack *pt = new AliTRDtrack(*seed2,seed2->GetAlpha());
616 AliTRDtrack &t=*pt;
617 FollowProlongation(t, innerTB);
618 if (t.GetNumberOfClusters() >= foundMin) {
619 UseClusters(&t);
620 CookLabel(pt, 1-fLabelFraction);
621 // t.CookdEdx();
622 }
623 found++;
624// cout<<found<<'\r';
625
626 if(PropagateToTPC(t)) {
627 seed->UpdateTrackParams(pt, AliESDtrack::kTRDin);
628 }
629 delete seed2;
630 delete pt;
631 }
632
633 cout<<"Number of loaded seeds: "<<nseed<<endl;
634 cout<<"Number of found tracks from loaded seeds: "<<found<<endl;
635
636 // after tracks from loaded seeds are found and the corresponding
637 // clusters are used, look for additional seeds from TRD
638
639 if(fAddTRDseeds) {
640 // Find tracks for the seeds in the TRD
641 Int_t timeBins = fTrSec[0]->GetNumberOfTimeBins();
642
643 Int_t nSteps = (Int_t) (fSeedDepth / fSeedStep);
644 Int_t gap = (Int_t) (timeBins * fSeedGap);
645 Int_t step = (Int_t) (timeBins * fSeedStep);
646
647 // make a first turn with tight cut on initial curvature
648 for(Int_t turn = 1; turn <= 2; turn++) {
649 if(turn == 2) {
650 nSteps = (Int_t) (fSeedDepth / (3*fSeedStep));
651 step = (Int_t) (timeBins * (3*fSeedStep));
652 }
653 for(Int_t i=0; i<nSteps; i++) {
654 Int_t outer=timeBins-1-i*step;
655 Int_t inner=outer-gap;
656
657 nseed=fSeeds->GetEntriesFast();
658
659 MakeSeeds(inner, outer, turn);
660
661 nseed=fSeeds->GetEntriesFast();
662 printf("\n turn %d, step %d: number of seeds for TRD inward %d\n",
663 turn, i, nseed);
664
665 for (Int_t i=0; i<nseed; i++) {
666 AliTRDtrack *pt=(AliTRDtrack*)fSeeds->UncheckedAt(i), &t=*pt;
667 FollowProlongation(t,innerTB);
668 if (t.GetNumberOfClusters() >= foundMin) {
669 UseClusters(&t);
670 CookLabel(pt, 1-fLabelFraction);
671 t.CookdEdx();
672 found++;
673// cout<<found<<'\r';
674 if(PropagateToTPC(t)) {
675 AliESDtrack track;
676 track.UpdateTrackParams(pt,AliESDtrack::kTRDin);
677 event->AddTrack(&track);
678 }
679 }
680 delete fSeeds->RemoveAt(i);
681 fNseeds--;
682 }
683 }
684 }
685 }
686
687 cout<<"Total number of found tracks: "<<found<<endl;
688
689 return 0;
690}
5443e65e 691
c630aafd 692
5443e65e 693
694//_____________________________________________________________________________
695Int_t AliTRDtracker::PropagateBack(const TFile *inp, TFile *out) {
696 //
697 // Reads seeds from file <inp>. The seeds are AliTPCtrack's found and
698 // backpropagated by the TPC tracker. Each seed is first propagated
699 // to the TRD, and then its prolongation is searched in the TRD.
700 // If sufficiently long continuation of the track is found in the TRD
701 // the track is updated, otherwise it's stored as originaly defined
702 // by the TPC tracker.
703 //
704
5443e65e 705 LoadEvent();
706
707 TDirectory *savedir=gDirectory;
708
709 TFile *in=(TFile*)inp;
710
711 if (!in->IsOpen()) {
712 cerr<<"AliTRDtracker::PropagateBack(): ";
713 cerr<<"file with back propagated TPC tracks is not open !\n";
714 return 1;
715 }
716
717 if (!out->IsOpen()) {
718 cerr<<"AliTRDtracker::PropagateBack(): ";
719 cerr<<"file for back propagated TRD tracks is not open !\n";
720 return 2;
721 }
722
723 in->cd();
724 char tname[100];
e24ea474 725 sprintf(tname,"seedsTPCtoTRD_%d",GetEventNumber());
5443e65e 726 TTree *seedTree=(TTree*)in->Get(tname);
727 if (!seedTree) {
728 cerr<<"AliTRDtracker::PropagateBack(): ";
729 cerr<<"can't get a tree with seeds from TPC !\n";
730 cerr<<"check if your version of TPC tracker creates tree "<<tname<<"\n";
731 return 3;
732 }
46d29e70 733
5443e65e 734 AliTPCtrack *seed=new AliTPCtrack;
735 seedTree->SetBranchAddress("tracks",&seed);
736
737 Int_t n=(Int_t)seedTree->GetEntries();
738 for (Int_t i=0; i<n; i++) {
739 seedTree->GetEvent(i);
740 Int_t lbl = seed->GetLabel();
741 AliTRDtrack *tr = new AliTRDtrack(*seed,seed->GetAlpha());
742 tr->SetSeedLabel(lbl);
743 fSeeds->AddLast(tr);
744 fNseeds++;
745 }
a819a5f7 746
5443e65e 747 delete seed;
748 delete seedTree;
a819a5f7 749
5443e65e 750 out->cd();
a819a5f7 751
5443e65e 752 AliTPCtrack *otrack=0;
a819a5f7 753
e24ea474 754 sprintf(tname,"seedsTRDtoTOF1_%d",GetEventNumber());
5443e65e 755 TTree tofTree1(tname,"Tracks back propagated through TPC and TRD");
756 tofTree1.Branch("tracks","AliTPCtrack",&otrack,32000,0);
a819a5f7 757
e24ea474 758 sprintf(tname,"seedsTRDtoTOF2_%d",GetEventNumber());
5443e65e 759 TTree tofTree2(tname,"Tracks back propagated through TPC and TRD");
760 tofTree2.Branch("tracks","AliTPCtrack",&otrack,32000,0);
46d29e70 761
e24ea474 762 sprintf(tname,"seedsTRDtoPHOS_%d",GetEventNumber());
5443e65e 763 TTree phosTree(tname,"Tracks back propagated through TPC and TRD");
764 phosTree.Branch("tracks","AliTPCtrack",&otrack,32000,0);
a819a5f7 765
e24ea474 766 sprintf(tname,"seedsTRDtoRICH_%d",GetEventNumber());
5443e65e 767 TTree richTree(tname,"Tracks back propagated through TPC and TRD");
768 richTree.Branch("tracks","AliTPCtrack",&otrack,32000,0);
a819a5f7 769
e24ea474 770 sprintf(tname,"TRDb_%d",GetEventNumber());
5443e65e 771 TTree trdTree(tname,"Back propagated TRD tracks at outer TRD time bin");
772 AliTRDtrack *otrack_trd=0;
773 trdTree.Branch("tracks","AliTRDtrack",&otrack_trd,32000,0);
774
9c9d2487 775 if (IsStoringBarrel()) SetBarrelTree("back");
776 out->cd();
46d29e70 777
9c9d2487 778 Int_t found=0;
5443e65e 779 Int_t nseed=fSeeds->GetEntriesFast();
46d29e70 780
c630aafd 781 // Float_t foundMin = fMinClustersInTrack * fTimeBinsPerPlane * fGeom->Nplan();
9c9d2487 782 Float_t foundMin = 40;
a819a5f7 783
5443e65e 784 Int_t outermost_tb = fTrSec[0]->GetOuterTimeBin();
a819a5f7 785
5443e65e 786 for (Int_t i=0; i<nseed; i++) {
a819a5f7 787
5443e65e 788 AliTRDtrack *ps=(AliTRDtrack*)fSeeds->UncheckedAt(i), &s=*ps;
789 Int_t expectedClr = FollowBackProlongation(s);
9c9d2487 790
791 if (IsStoringBarrel()) {
792 StoreBarrelTrack(ps, kLastPlane, kTrackBack);
793 fBarrelTree->Fill();
794 }
795
5443e65e 796 Int_t foundClr = s.GetNumberOfClusters();
797 Int_t last_tb = fTrSec[0]->GetLayerNumber(s.GetX());
a819a5f7 798
fd621f36 799 // printf("seed %d: found %d out of %d expected clusters, Min is %f\n",
a9814c09 800 // i, foundClr, expectedClr, foundMin);
a819a5f7 801
5443e65e 802 if (foundClr >= foundMin) {
a9814c09 803 if(foundClr >= 2) {
804 s.CookdEdx();
c630aafd 805 CookLabel(ps, 1-fLabelFraction);
a9814c09 806 UseClusters(ps);
807 }
0d5b5c27 808
809 // Propagate to outer reference plane [SR, GSI, 18.02.2003]
810 ps->PropagateTo(364.8);
5443e65e 811 otrack_trd=ps;
812 trdTree.Fill();
e24ea474 813 found++;
814// cout<<found<<'\r';
46d29e70 815 }
a819a5f7 816
5443e65e 817 if(((expectedClr < 10) && (last_tb == outermost_tb)) ||
818 ((expectedClr >= 10) &&
a9814c09 819 (((Float_t) foundClr) / ((Float_t) expectedClr) >=
c630aafd 820 fMinFractionOfFoundClusters) && (last_tb == outermost_tb))) {
5443e65e 821
822 Double_t x_tof = 375.5;
823
824 if(PropagateToOuterPlane(s,x_tof)) {
a9814c09 825 AliTPCtrack *pt = new AliTPCtrack(*ps,ps->GetAlpha());
826 otrack = pt;
827 tofTree1.Fill();
828 delete pt;
5443e65e 829
a9814c09 830 x_tof = 381.5;
5443e65e 831
a9814c09 832 if(PropagateToOuterPlane(s,x_tof)) {
833 AliTPCtrack *pt = new AliTPCtrack(*ps,ps->GetAlpha());
834 otrack = pt;
835 tofTree2.Fill();
836 delete pt;
837
838 Double_t x_phos = 460.;
839
840 if(PropagateToOuterPlane(s,x_phos)) {
841 AliTPCtrack *pt = new AliTPCtrack(*ps,ps->GetAlpha());
842 otrack = pt;
843 phosTree.Fill();
844 delete pt;
845
846 Double_t x_rich = 490+1.267;
847
848 if(PropagateToOuterPlane(s,x_rich)) {
849 AliTPCtrack *pt = new AliTPCtrack(*ps,ps->GetAlpha());
850 otrack = pt;
851 richTree.Fill();
852 delete pt;
853 }
854 }
855 }
5443e65e 856 }
46d29e70 857 }
858 }
5443e65e 859
9c9d2487 860
861 out->cd();
5443e65e 862 tofTree1.Write();
863 tofTree2.Write();
864 phosTree.Write();
865 richTree.Write();
866 trdTree.Write();
46d29e70 867
9c9d2487 868 if (IsStoringBarrel()) { // [SR, 03.04.2003]
869 fBarrelFile->cd();
870 fBarrelTree->Write();
871 fBarrelFile->Flush();
872 }
873
5443e65e 874 savedir->cd();
875 cerr<<"Number of seeds: "<<nseed<<endl;
876 cerr<<"Number of back propagated TRD tracks: "<<found<<endl;
46d29e70 877
5443e65e 878 UnloadEvent();
46d29e70 879
5443e65e 880 return 0;
46d29e70 881
5443e65e 882}
46d29e70 883
c630aafd 884//_____________________________________________________________________________
885Int_t AliTRDtracker::PropagateBack(AliESD* event) {
886 //
887 // Gets seeds from ESD event. The seeds are AliTPCtrack's found and
888 // backpropagated by the TPC tracker. Each seed is first propagated
889 // to the TRD, and then its prolongation is searched in the TRD.
890 // If sufficiently long continuation of the track is found in the TRD
891 // the track is updated, otherwise it's stored as originaly defined
892 // by the TPC tracker.
893 //
894
895 Int_t found=0;
896 Float_t foundMin = 40;
897
898 Int_t n = event->GetNumberOfTracks();
899 for (Int_t i=0; i<n; i++) {
900 AliESDtrack* seed=event->GetTrack(i);
901 ULong_t status=seed->GetStatus();
902 if ( (status & AliESDtrack::kTPCout ) == 0 ) continue;
903 if ( (status & AliESDtrack::kTRDout) != 0 ) continue;
904
905 Int_t lbl = seed->GetLabel();
906 AliTRDtrack *track = new AliTRDtrack(*seed);
907 track->SetSeedLabel(lbl);
908 fNseeds++;
909
910 /*Int_t expectedClr = */FollowBackProlongation(*track);
911
912 Int_t foundClr = track->GetNumberOfClusters();
913 if (foundClr >= foundMin) {
914 if(foundClr >= 2) {
915 track->CookdEdx();
916// CookLabel(track, 1-fLabelFraction);
917 UseClusters(track);
918 }
919
920 // Propagate to outer reference plane [SR, GSI, 18.02.2003]
921// track->PropagateTo(364.8); why?
922
923 //seed->UpdateTrackParams(track, AliESDtrack::kTRDout);
924 //found++;
925 }
926
927 if (track->PropagateTo(376.)) { //Propagation to the TOF (I.Belikov)
928 seed->UpdateTrackParams(track, AliESDtrack::kTRDout);
929 found++;
930 }
931
932 }
933
934 cerr<<"Number of seeds: "<<fNseeds<<endl;
935 cerr<<"Number of back propagated TRD tracks: "<<found<<endl;
936
937 return 0;
938
939}
940
bbf92647 941
5443e65e 942//---------------------------------------------------------------------------
943Int_t AliTRDtracker::FollowProlongation(AliTRDtrack& t, Int_t rf)
944{
945 // Starting from current position on track=t this function tries
946 // to extrapolate the track up to timeBin=0 and to confirm prolongation
947 // if a close cluster is found. Returns the number of clusters
948 // expected to be found in sensitive layers
bbf92647 949
5443e65e 950 Float_t wIndex, wTB, wChi2;
951 Float_t wYrt, wYclosest, wYcorrect, wYwindow;
952 Float_t wZrt, wZclosest, wZcorrect, wZwindow;
953 Float_t wPx, wPy, wPz, wC;
954 Double_t Px, Py, Pz;
955 Float_t wSigmaC2, wSigmaTgl2, wSigmaY2, wSigmaZ2;
46d29e70 956
5443e65e 957 Int_t trackIndex = t.GetLabel();
46d29e70 958
5443e65e 959 Int_t ns=Int_t(2*TMath::Pi()/AliTRDgeometry::GetAlpha()+0.5);
46d29e70 960
5443e65e 961 Int_t try_again=fMaxGap;
46d29e70 962
5443e65e 963 Double_t alpha=t.GetAlpha();
c630aafd 964 alpha = TVector2::Phi_0_2pi(alpha);
46d29e70 965
5443e65e 966 Int_t s=Int_t(alpha/AliTRDgeometry::GetAlpha())%AliTRDgeometry::kNsect;
b3a5a838 967 Double_t rad_length, rho, x, dx, y, ymax, z;
46d29e70 968
5443e65e 969 Int_t expectedNumberOfClusters = 0;
970 Bool_t lookForCluster;
46d29e70 971
5443e65e 972 alpha=AliTRDgeometry::GetAlpha(); // note: change in meaning
46d29e70 973
5443e65e 974
975 for (Int_t nr=fTrSec[0]->GetLayerNumber(t.GetX()); nr>rf; nr--) {
976
977 y = t.GetY(); z = t.GetZ();
978
979 // first propagate to the inner surface of the current time bin
b3a5a838 980 fTrSec[s]->GetLayer(nr)->GetPropagationParameters(y,z,dx,rho,rad_length,lookForCluster);
5443e65e 981 x = fTrSec[s]->GetLayer(nr)->GetX()-dx/2; y = t.GetY(); z = t.GetZ();
b3a5a838 982 if(!t.PropagateTo(x,rad_length,rho)) break;
5443e65e 983 y = t.GetY();
984 ymax = x*TMath::Tan(0.5*alpha);
985 if (y > ymax) {
986 s = (s+1) % ns;
987 if (!t.Rotate(alpha)) break;
b3a5a838 988 if(!t.PropagateTo(x,rad_length,rho)) break;
5443e65e 989 } else if (y <-ymax) {
990 s = (s-1+ns) % ns;
991 if (!t.Rotate(-alpha)) break;
b3a5a838 992 if(!t.PropagateTo(x,rad_length,rho)) break;
5443e65e 993 }
46d29e70 994
5443e65e 995 y = t.GetY(); z = t.GetZ();
996
997 // now propagate to the middle plane of the next time bin
b3a5a838 998 fTrSec[s]->GetLayer(nr-1)->GetPropagationParameters(y,z,dx,rho,rad_length,lookForCluster);
5443e65e 999 x = fTrSec[s]->GetLayer(nr-1)->GetX(); y = t.GetY(); z = t.GetZ();
b3a5a838 1000 if(!t.PropagateTo(x,rad_length,rho)) break;
5443e65e 1001 y = t.GetY();
1002 ymax = x*TMath::Tan(0.5*alpha);
1003 if (y > ymax) {
1004 s = (s+1) % ns;
1005 if (!t.Rotate(alpha)) break;
b3a5a838 1006 if(!t.PropagateTo(x,rad_length,rho)) break;
5443e65e 1007 } else if (y <-ymax) {
1008 s = (s-1+ns) % ns;
1009 if (!t.Rotate(-alpha)) break;
b3a5a838 1010 if(!t.PropagateTo(x,rad_length,rho)) break;
5443e65e 1011 }
46d29e70 1012
46d29e70 1013
5443e65e 1014 if(lookForCluster) {
a819a5f7 1015
5443e65e 1016 expectedNumberOfClusters++;
5443e65e 1017 wIndex = (Float_t) t.GetLabel();
1018 wTB = nr;
46d29e70 1019
5443e65e 1020 AliTRDpropagationLayer& time_bin=*(fTrSec[s]->GetLayer(nr-1));
46d29e70 1021
5443e65e 1022 Double_t sy2=ExpectedSigmaY2(x,t.GetTgl(),t.GetPt());
5443e65e 1023 Double_t sz2=ExpectedSigmaZ2(x,t.GetTgl());
46d29e70 1024
5443e65e 1025 Double_t road;
1026 if((t.GetSigmaY2() + sy2) > 0) road=10.*sqrt(t.GetSigmaY2() + sy2);
1027 else return expectedNumberOfClusters;
1028
1029 wYrt = (Float_t) y;
1030 wZrt = (Float_t) z;
1031 wYwindow = (Float_t) road;
1032 t.GetPxPyPz(Px,Py,Pz);
1033 wPx = (Float_t) Px;
1034 wPy = (Float_t) Py;
1035 wPz = (Float_t) Pz;
1036 wC = (Float_t) t.GetC();
1037 wSigmaC2 = (Float_t) t.GetSigmaC2();
1038 wSigmaTgl2 = (Float_t) t.GetSigmaTgl2();
1039 wSigmaY2 = (Float_t) t.GetSigmaY2();
1040 wSigmaZ2 = (Float_t) t.GetSigmaZ2();
1041 wChi2 = -1;
1042
c630aafd 1043 if (road>fWideRoad) {
a9814c09 1044 if (t.GetNumberOfClusters()>4)
1045 cerr<<t.GetNumberOfClusters()
1046 <<"FindProlongation warning: Too broad road !\n";
1047 return 0;
5443e65e 1048 }
1049
1050 AliTRDcluster *cl=0;
1051 UInt_t index=0;
1052
c630aafd 1053 Double_t max_chi2=fMaxChi2;
5443e65e 1054
1055 wYclosest = 12345678;
1056 wYcorrect = 12345678;
1057 wZclosest = 12345678;
1058 wZcorrect = 12345678;
1059 wZwindow = TMath::Sqrt(2.25 * 12 * sz2);
1060
1061 // Find the closest correct cluster for debugging purposes
1062 if (time_bin) {
a9814c09 1063 Float_t minDY = 1000000;
1064 for (Int_t i=0; i<time_bin; i++) {
1065 AliTRDcluster* c=(AliTRDcluster*)(time_bin[i]);
1066 if((c->GetLabel(0) != trackIndex) &&
1067 (c->GetLabel(1) != trackIndex) &&
1068 (c->GetLabel(2) != trackIndex)) continue;
1069 if(TMath::Abs(c->GetY() - y) > minDY) continue;
1070 minDY = TMath::Abs(c->GetY() - y);
1071 wYcorrect = c->GetY();
1072 wZcorrect = c->GetZ();
1073
1074 Double_t h01 = GetTiltFactor(c);
1075 wChi2 = t.GetPredictedChi2(c, h01);
1076 }
5443e65e 1077 }
46d29e70 1078
5443e65e 1079 // Now go for the real cluster search
a819a5f7 1080
5443e65e 1081 if (time_bin) {
a819a5f7 1082
a9814c09 1083 for (Int_t i=time_bin.Find(y-road); i<time_bin; i++) {
1084 AliTRDcluster* c=(AliTRDcluster*)(time_bin[i]);
1085 if (c->GetY() > y+road) break;
1086 if (c->IsUsed() > 0) continue;
1087 if((c->GetZ()-z)*(c->GetZ()-z) > 3 * sz2) continue;
1088
1089 Double_t h01 = GetTiltFactor(c);
1090 Double_t chi2=t.GetPredictedChi2(c,h01);
1091
1092 if (chi2 > max_chi2) continue;
1093 max_chi2=chi2;
1094 cl=c;
1095 index=time_bin.GetIndex(i);
1096 }
1097
1098 if(!cl) {
1099
1100 for (Int_t i=time_bin.Find(y-road); i<time_bin; i++) {
1101 AliTRDcluster* c=(AliTRDcluster*)(time_bin[i]);
1102
1103 if (c->GetY() > y+road) break;
1104 if (c->IsUsed() > 0) continue;
1105 if((c->GetZ()-z)*(c->GetZ()-z) > 12 * sz2) continue;
1106
1107 Double_t h01 = GetTiltFactor(c);
1108 Double_t chi2=t.GetPredictedChi2(c, h01);
1109
1110 if (chi2 > max_chi2) continue;
1111 max_chi2=chi2;
1112 cl=c;
1113 index=time_bin.GetIndex(i);
1114 }
1115 }
1116
1117
1118 if (cl) {
1119 wYclosest = cl->GetY();
1120 wZclosest = cl->GetZ();
1121 Double_t h01 = GetTiltFactor(cl);
1122
1123 t.SetSampledEdx(cl->GetQ()/dx,t.GetNumberOfClusters());
1124 if(!t.Update(cl,max_chi2,index,h01)) {
1125 if(!try_again--) return 0;
1126 }
1127 else try_again=fMaxGap;
1128 }
1129 else {
1130 if (try_again==0) break;
1131 try_again--;
1132 }
1133
1134 /*
1135 if((((Int_t) wTB)%15 == 0) || (((Int_t) wTB)%15 == 14)) {
1136
1137 printf(" %f", wIndex); //1
1138 printf(" %f", wTB); //2
1139 printf(" %f", wYrt); //3
1140 printf(" %f", wYclosest); //4
1141 printf(" %f", wYcorrect); //5
1142 printf(" %f", wYwindow); //6
1143 printf(" %f", wZrt); //7
1144 printf(" %f", wZclosest); //8
1145 printf(" %f", wZcorrect); //9
1146 printf(" %f", wZwindow); //10
1147 printf(" %f", wPx); //11
1148 printf(" %f", wPy); //12
1149 printf(" %f", wPz); //13
1150 printf(" %f", wSigmaC2*1000000); //14
1151 printf(" %f", wSigmaTgl2*1000); //15
1152 printf(" %f", wSigmaY2); //16
1153 // printf(" %f", wSigmaZ2); //17
1154 printf(" %f", wChi2); //17
1155 printf(" %f", wC); //18
1156 printf("\n");
1157 }
1158 */
5443e65e 1159 }
1160 }
1161 }
1162 return expectedNumberOfClusters;
1163
1164
1165}
a819a5f7 1166
5443e65e 1167//___________________________________________________________________
46d29e70 1168
5443e65e 1169Int_t AliTRDtracker::FollowBackProlongation(AliTRDtrack& t)
1170{
1171 // Starting from current radial position of track <t> this function
1172 // extrapolates the track up to outer timebin and in the sensitive
1173 // layers confirms prolongation if a close cluster is found.
1174 // Returns the number of clusters expected to be found in sensitive layers
46d29e70 1175
5443e65e 1176 Float_t wIndex, wTB, wChi2;
1177 Float_t wYrt, wYclosest, wYcorrect, wYwindow;
1178 Float_t wZrt, wZclosest, wZcorrect, wZwindow;
1179 Float_t wPx, wPy, wPz, wC;
1180 Double_t Px, Py, Pz;
1181 Float_t wSigmaC2, wSigmaTgl2, wSigmaY2, wSigmaZ2;
46d29e70 1182
5443e65e 1183 Int_t trackIndex = t.GetLabel();
5443e65e 1184 Int_t try_again=fMaxGap;
46d29e70 1185
5443e65e 1186 Double_t alpha=t.GetAlpha();
9c9d2487 1187 TVector2::Phi_0_2pi(alpha);
46d29e70 1188
9c9d2487 1189 Int_t s;
46d29e70 1190
5443e65e 1191 Int_t outerTB = fTrSec[0]->GetOuterTimeBin();
9c9d2487 1192 Double_t rad_length, rho, x, dx, y, ymax = 0, z;
5443e65e 1193 Bool_t lookForCluster;
a819a5f7 1194
5443e65e 1195 Int_t expectedNumberOfClusters = 0;
1196 x = t.GetX();
46d29e70 1197
5443e65e 1198 alpha=AliTRDgeometry::GetAlpha(); // note: change in meaning
46d29e70 1199
9c9d2487 1200 Int_t nRefPlane = kFirstPlane;
1201 Bool_t isNewLayer = kFALSE;
46d29e70 1202
9c9d2487 1203 Double_t chi2;
1204 Double_t minDY;
46d29e70 1205
9c9d2487 1206 for (Int_t nr=fTrSec[0]->GetLayerNumber(t.GetX()); nr<outerTB+1; nr++) {
1207
1208 y = t.GetY();
1209 z = t.GetZ();
46d29e70 1210
5443e65e 1211 // first propagate to the outer surface of the current time bin
46d29e70 1212
9c9d2487 1213 s = t.GetSector();
b3a5a838 1214 fTrSec[s]->GetLayer(nr)->GetPropagationParameters(y,z,dx,rho,rad_length,lookForCluster);
9c9d2487 1215 x = fTrSec[s]->GetLayer(nr)->GetX()+dx/2;
1216 y = t.GetY();
1217 z = t.GetZ();
46d29e70 1218
b3a5a838 1219 if(!t.PropagateTo(x,rad_length,rho)) break;
9c9d2487 1220 if (!AdjustSector(&t)) break;
1221 s = t.GetSector();
1222 if (!t.PropagateTo(x,rad_length,rho)) break;
46d29e70 1223
5443e65e 1224 y = t.GetY();
9c9d2487 1225 z = t.GetZ();
a819a5f7 1226
9c9d2487 1227 // Barrel Tracks [SR, 04.04.2003]
46d29e70 1228
9c9d2487 1229 s = t.GetSector();
1230 if (fTrSec[s]->GetLayer(nr)->IsSensitive() !=
1231 fTrSec[s]->GetLayer(nr+1)->IsSensitive() ) {
46d29e70 1232
c630aafd 1233// if (IsStoringBarrel()) StoreBarrelTrack(&t, nRefPlane++, kTrackBack);
9c9d2487 1234 }
46d29e70 1235
9c9d2487 1236 if (fTrSec[s]->GetLayer(nr-1)->IsSensitive() &&
1237 ! fTrSec[s]->GetLayer(nr)->IsSensitive()) {
1238 isNewLayer = kTRUE;
1239 } else {isNewLayer = kFALSE;}
46d29e70 1240
5443e65e 1241 y = t.GetY();
9c9d2487 1242 z = t.GetZ();
a819a5f7 1243
9c9d2487 1244 // now propagate to the middle plane of the next time bin
1245 fTrSec[s]->GetLayer(nr+1)->GetPropagationParameters(y,z,dx,rho,rad_length,lookForCluster);
5443e65e 1246
9c9d2487 1247 x = fTrSec[s]->GetLayer(nr+1)->GetX();
b3a5a838 1248 if(!t.PropagateTo(x,rad_length,rho)) break;
9c9d2487 1249 if (!AdjustSector(&t)) break;
1250 s = t.GetSector();
b3a5a838 1251 if(!t.PropagateTo(x,rad_length,rho)) break;
46d29e70 1252
9c9d2487 1253 y = t.GetY();
1254 z = t.GetZ();
1255
1256 if(fVocal) printf("nr+1=%d, x %f, z %f, y %f, ymax %f\n",nr+1,x,z,y,ymax);
5443e65e 1257 // printf("label %d, pl %d, lookForCluster %d \n",
a9814c09 1258 // trackIndex, nr+1, lookForCluster);
5443e65e 1259
1260 if(lookForCluster) {
1261 expectedNumberOfClusters++;
1262
1263 wIndex = (Float_t) t.GetLabel();
1264 wTB = fTrSec[s]->GetLayer(nr+1)->GetTimeBinIndex();
1265
1266 AliTRDpropagationLayer& time_bin=*(fTrSec[s]->GetLayer(nr+1));
1267 Double_t sy2=ExpectedSigmaY2(t.GetX(),t.GetTgl(),t.GetPt());
1268 Double_t sz2=ExpectedSigmaZ2(t.GetX(),t.GetTgl());
1269 if((t.GetSigmaY2() + sy2) < 0) break;
1270 Double_t road = 10.*sqrt(t.GetSigmaY2() + sy2);
1271 Double_t y=t.GetY(), z=t.GetZ();
1272
1273 wYrt = (Float_t) y;
1274 wZrt = (Float_t) z;
1275 wYwindow = (Float_t) road;
1276 t.GetPxPyPz(Px,Py,Pz);
1277 wPx = (Float_t) Px;
1278 wPy = (Float_t) Py;
1279 wPz = (Float_t) Pz;
1280 wC = (Float_t) t.GetC();
1281 wSigmaC2 = (Float_t) t.GetSigmaC2();
1282 wSigmaTgl2 = (Float_t) t.GetSigmaTgl2();
1283 wSigmaY2 = (Float_t) t.GetSigmaY2();
1284 wSigmaZ2 = (Float_t) t.GetSigmaZ2();
1285 wChi2 = -1;
1286
c630aafd 1287 if (road>fWideRoad) {
a9814c09 1288 if (t.GetNumberOfClusters()>4)
1289 cerr<<t.GetNumberOfClusters()
1290 <<"FindProlongation warning: Too broad road !\n";
1291 return 0;
5443e65e 1292 }
1293
1294 AliTRDcluster *cl=0;
1295 UInt_t index=0;
1296
c630aafd 1297 Double_t max_chi2=fMaxChi2;
5443e65e 1298
9c9d2487 1299 if (isNewLayer) {
1300 road = 3 * road;
1301 //sz2 = 3 * sz2;
c630aafd 1302 max_chi2 = 10 * fMaxChi2;
9c9d2487 1303 }
1304
c630aafd 1305 if (nRefPlane == kFirstPlane) max_chi2 = 20 * fMaxChi2;
1306 if (nRefPlane == kFirstPlane+2) max_chi2 = 15 * fMaxChi2;
9c9d2487 1307 if (t.GetNRotate() > 0) max_chi2 = 3 * max_chi2;
1308
1309
5443e65e 1310 wYclosest = 12345678;
1311 wYcorrect = 12345678;
1312 wZclosest = 12345678;
1313 wZcorrect = 12345678;
1314 wZwindow = TMath::Sqrt(2.25 * 12 * sz2);
1315
1316 // Find the closest correct cluster for debugging purposes
1317 if (time_bin) {
9c9d2487 1318 minDY = 1000000;
a9814c09 1319 for (Int_t i=0; i<time_bin; i++) {
1320 AliTRDcluster* c=(AliTRDcluster*)(time_bin[i]);
1321 if((c->GetLabel(0) != trackIndex) &&
1322 (c->GetLabel(1) != trackIndex) &&
1323 (c->GetLabel(2) != trackIndex)) continue;
1324 if(TMath::Abs(c->GetY() - y) > minDY) continue;
9c9d2487 1325 //minDY = TMath::Abs(c->GetY() - y);
1326 minDY = c->GetY() - y;
a9814c09 1327 wYcorrect = c->GetY();
1328 wZcorrect = c->GetZ();
1329
1330 Double_t h01 = GetTiltFactor(c);
1331 wChi2 = t.GetPredictedChi2(c, h01);
1332 }
5443e65e 1333 }
46d29e70 1334
5443e65e 1335 // Now go for the real cluster search
46d29e70 1336
5443e65e 1337 if (time_bin) {
1338
a9814c09 1339 for (Int_t i=time_bin.Find(y-road); i<time_bin; i++) {
1340 AliTRDcluster* c=(AliTRDcluster*)(time_bin[i]);
1341 if (c->GetY() > y+road) break;
9c9d2487 1342 if (c->IsUsed() > 0) continue;
a9814c09 1343 if((c->GetZ()-z)*(c->GetZ()-z) > 3 * sz2) continue;
1344
1345 Double_t h01 = GetTiltFactor(c);
9c9d2487 1346 chi2=t.GetPredictedChi2(c,h01);
a9814c09 1347
1348 if (chi2 > max_chi2) continue;
1349 max_chi2=chi2;
1350 cl=c;
1351 index=time_bin.GetIndex(i);
9c9d2487 1352
1353 //check is correct
1354 if((c->GetLabel(0) != trackIndex) &&
1355 (c->GetLabel(1) != trackIndex) &&
1356 (c->GetLabel(2) != trackIndex)) t.AddNWrong();
a9814c09 1357 }
5443e65e 1358
a9814c09 1359 if(!cl) {
1360
1361 for (Int_t i=time_bin.Find(y-road); i<time_bin; i++) {
1362 AliTRDcluster* c=(AliTRDcluster*)(time_bin[i]);
1363
1364 if (c->GetY() > y+road) break;
9c9d2487 1365 if (c->IsUsed() > 0) continue;
a9814c09 1366 if((c->GetZ()-z)*(c->GetZ()-z) > 2.25 * 12 * sz2) continue;
1367
1368 Double_t h01 = GetTiltFactor(c);
9c9d2487 1369 chi2=t.GetPredictedChi2(c,h01);
a9814c09 1370
1371 if (chi2 > max_chi2) continue;
1372 max_chi2=chi2;
1373 cl=c;
1374 index=time_bin.GetIndex(i);
1375 }
1376 }
1377
1378 if (cl) {
1379 wYclosest = cl->GetY();
1380 wZclosest = cl->GetZ();
1381
1382 t.SetSampledEdx(cl->GetQ()/dx,t.GetNumberOfClusters());
1383 Double_t h01 = GetTiltFactor(cl);
1384 if(!t.Update(cl,max_chi2,index,h01)) {
1385 if(!try_again--) return 0;
1386 }
1387 else try_again=fMaxGap;
1388 }
1389 else {
1390 if (try_again==0) break;
1391 try_again--;
9c9d2487 1392
1393 //if (minDY < 1000000 && isNewLayer)
1394 //cout << "\t" << nRefPlane << "\t" << "\t" << t.GetNRotate() << "\t" <<
1395 // road << "\t" << minDY << "\t" << chi2 << "\t" << wChi2 << "\t" << max_chi2 << endl;
1396
a9814c09 1397 }
1398
9c9d2487 1399 isNewLayer = kFALSE;
1400
a9814c09 1401 /*
1402 if((((Int_t) wTB)%15 == 0) || (((Int_t) wTB)%15 == 14)) {
1403
1404 printf(" %f", wIndex); //1
1405 printf(" %f", wTB); //2
1406 printf(" %f", wYrt); //3
1407 printf(" %f", wYclosest); //4
1408 printf(" %f", wYcorrect); //5
1409 printf(" %f", wYwindow); //6
1410 printf(" %f", wZrt); //7
1411 printf(" %f", wZclosest); //8
1412 printf(" %f", wZcorrect); //9
1413 printf(" %f", wZwindow); //10
1414 printf(" %f", wPx); //11
1415 printf(" %f", wPy); //12
1416 printf(" %f", wPz); //13
1417 printf(" %f", wSigmaC2*1000000); //14
1418 printf(" %f", wSigmaTgl2*1000); //15
1419 printf(" %f", wSigmaY2); //16
1420 // printf(" %f", wSigmaZ2); //17
1421 printf(" %f", wChi2); //17
1422 printf(" %f", wC); //18
1423 printf("\n");
1424 }
1425 */
5443e65e 1426 }
1427 }
1428 }
1429 return expectedNumberOfClusters;
9c9d2487 1430
1431
5443e65e 1432}
1433
1434//___________________________________________________________________
1435
1436Int_t AliTRDtracker::PropagateToOuterPlane(AliTRDtrack& t, Double_t xToGo)
1437{
1438 // Starting from current radial position of track <t> this function
1439 // extrapolates the track up to radial position <xToGo>.
1440 // Returns 1 if track reaches the plane, and 0 otherwise
1441
1442 Int_t ns=Int_t(2*TMath::Pi()/AliTRDgeometry::GetAlpha()+0.5);
1443
1444 Double_t alpha=t.GetAlpha();
1445
1446 if (alpha > 2.*TMath::Pi()) alpha -= 2.*TMath::Pi();
1447 if (alpha < 0. ) alpha += 2.*TMath::Pi();
1448
1449 Int_t s=Int_t(alpha/AliTRDgeometry::GetAlpha())%AliTRDgeometry::kNsect;
1450
1451 Bool_t lookForCluster;
b3a5a838 1452 Double_t rad_length, rho, x, dx, y, ymax, z;
5443e65e 1453
1454 x = t.GetX();
1455
1456 alpha=AliTRDgeometry::GetAlpha(); // note: change in meaning
1457
1458 Int_t plToGo = fTrSec[0]->GetLayerNumber(xToGo);
1459
1460 for (Int_t nr=fTrSec[0]->GetLayerNumber(x); nr<plToGo; nr++) {
1461
1462 y = t.GetY(); z = t.GetZ();
1463
1464 // first propagate to the outer surface of the current time bin
b3a5a838 1465 fTrSec[s]->GetLayer(nr)->GetPropagationParameters(y,z,dx,rho,rad_length,lookForCluster);
5443e65e 1466 x = fTrSec[s]->GetLayer(nr)->GetX()+dx/2; y = t.GetY(); z = t.GetZ();
b3a5a838 1467 if(!t.PropagateTo(x,rad_length,rho)) return 0;
5443e65e 1468 y = t.GetY();
1469 ymax = x*TMath::Tan(0.5*alpha);
1470 if (y > ymax) {
1471 s = (s+1) % ns;
1472 if (!t.Rotate(alpha)) return 0;
1473 } else if (y <-ymax) {
1474 s = (s-1+ns) % ns;
1475 if (!t.Rotate(-alpha)) return 0;
1476 }
b3a5a838 1477 if(!t.PropagateTo(x,rad_length,rho)) return 0;
5443e65e 1478
1479 y = t.GetY(); z = t.GetZ();
1480
1481 // now propagate to the middle plane of the next time bin
b3a5a838 1482 fTrSec[s]->GetLayer(nr+1)->GetPropagationParameters(y,z,dx,rho,rad_length,lookForCluster);
5443e65e 1483 x = fTrSec[s]->GetLayer(nr+1)->GetX(); y = t.GetY(); z = t.GetZ();
b3a5a838 1484 if(!t.PropagateTo(x,rad_length,rho)) return 0;
5443e65e 1485 y = t.GetY();
1486 ymax = x*TMath::Tan(0.5*alpha);
1487 if (y > ymax) {
1488 s = (s+1) % ns;
1489 if (!t.Rotate(alpha)) return 0;
1490 } else if (y <-ymax) {
1491 s = (s-1+ns) % ns;
1492 if (!t.Rotate(-alpha)) return 0;
1493 }
b3a5a838 1494 if(!t.PropagateTo(x,rad_length,rho)) return 0;
5443e65e 1495 }
1496 return 1;
1497}
1498
1499//___________________________________________________________________
1500
1501Int_t AliTRDtracker::PropagateToTPC(AliTRDtrack& t)
1502{
1503 // Starting from current radial position of track <t> this function
1504 // extrapolates the track up to radial position of the outermost
1505 // padrow of the TPC.
1506 // Returns 1 if track reaches the TPC, and 0 otherwise
1507
c630aafd 1508 //Int_t ns=Int_t(2*TMath::Pi()/AliTRDgeometry::GetAlpha()+0.5);
5443e65e 1509
1510 Double_t alpha=t.GetAlpha();
c630aafd 1511 alpha = TVector2::Phi_0_2pi(alpha);
5443e65e 1512
1513 Int_t s=Int_t(alpha/AliTRDgeometry::GetAlpha())%AliTRDgeometry::kNsect;
1514
1515 Bool_t lookForCluster;
c630aafd 1516 Double_t rad_length, rho, x, dx, y, /*ymax,*/ z;
5443e65e 1517
1518 x = t.GetX();
1519
1520 alpha=AliTRDgeometry::GetAlpha(); // note: change in meaning
5443e65e 1521 Int_t plTPC = fTrSec[0]->GetLayerNumber(246.055);
1522
1523 for (Int_t nr=fTrSec[0]->GetLayerNumber(x); nr>plTPC; nr--) {
1524
9c9d2487 1525 y = t.GetY();
1526 z = t.GetZ();
5443e65e 1527
1528 // first propagate to the outer surface of the current time bin
b3a5a838 1529 fTrSec[s]->GetLayer(nr)->GetPropagationParameters(y,z,dx,rho,rad_length,lookForCluster);
9c9d2487 1530 x = fTrSec[s]->GetLayer(nr)->GetX()-dx/2;
1531
b3a5a838 1532 if(!t.PropagateTo(x,rad_length,rho)) return 0;
9c9d2487 1533 AdjustSector(&t);
b3a5a838 1534 if(!t.PropagateTo(x,rad_length,rho)) return 0;
5443e65e 1535
9c9d2487 1536 y = t.GetY();
1537 z = t.GetZ();
5443e65e 1538
1539 // now propagate to the middle plane of the next time bin
b3a5a838 1540 fTrSec[s]->GetLayer(nr-1)->GetPropagationParameters(y,z,dx,rho,rad_length,lookForCluster);
9c9d2487 1541 x = fTrSec[s]->GetLayer(nr-1)->GetX();
1542
b3a5a838 1543 if(!t.PropagateTo(x,rad_length,rho)) return 0;
9c9d2487 1544 AdjustSector(&t);
b3a5a838 1545 if(!t.PropagateTo(x,rad_length,rho)) return 0;
5443e65e 1546 }
1547 return 1;
1548}
1549
5443e65e 1550void AliTRDtracker::LoadEvent()
1551{
1552 // Fills clusters into TRD tracking_sectors
1553 // Note that the numbering scheme for the TRD tracking_sectors
1554 // differs from that of TRD sectors
1555
1556 ReadClusters(fClusters);
1557 Int_t ncl=fClusters->GetEntriesFast();
1558 cout<<"\n LoadSectors: sorting "<<ncl<<" clusters"<<endl;
1559
1560 UInt_t index;
1561 while (ncl--) {
e24ea474 1562// printf("\r %d left ",ncl);
5443e65e 1563 AliTRDcluster *c=(AliTRDcluster*)fClusters->UncheckedAt(ncl);
1564 Int_t detector=c->GetDetector(), local_time_bin=c->GetLocalTimeBin();
1565 Int_t sector=fGeom->GetSector(detector);
1566 Int_t plane=fGeom->GetPlane(detector);
1567
1568 Int_t tracking_sector = CookSectorIndex(sector);
1569
1570 Int_t gtb = fTrSec[tracking_sector]->CookTimeBinIndex(plane,local_time_bin);
b3a5a838 1571 if(gtb < 0) continue;
5443e65e 1572 Int_t layer = fTrSec[tracking_sector]->GetLayerNumber(gtb);
1573
1574 index=ncl;
1575 fTrSec[tracking_sector]->GetLayer(layer)->InsertCluster(c,index);
1576 }
1577 printf("\r\n");
1578
1579}
1580
c630aafd 1581//_____________________________________________________________________________
1582Int_t AliTRDtracker::LoadClusters(TTree *cTree)
1583{
1584 // Fills clusters into TRD tracking_sectors
1585 // Note that the numbering scheme for the TRD tracking_sectors
1586 // differs from that of TRD sectors
1587
1588 if (ReadClusters(fClusters,cTree)) {
1589 Error("LoadClusters","Problem with reading the clusters !");
1590 return 1;
1591 }
1592 Int_t ncl=fClusters->GetEntriesFast();
1593 cout<<"\n LoadSectors: sorting "<<ncl<<" clusters"<<endl;
1594
1595 UInt_t index;
1596 while (ncl--) {
1597// printf("\r %d left ",ncl);
1598 AliTRDcluster *c=(AliTRDcluster*)fClusters->UncheckedAt(ncl);
1599 Int_t detector=c->GetDetector(), local_time_bin=c->GetLocalTimeBin();
1600 Int_t sector=fGeom->GetSector(detector);
1601 Int_t plane=fGeom->GetPlane(detector);
1602
1603 Int_t tracking_sector = CookSectorIndex(sector);
1604
1605 Int_t gtb = fTrSec[tracking_sector]->CookTimeBinIndex(plane,local_time_bin);
1606 if(gtb < 0) continue;
1607 Int_t layer = fTrSec[tracking_sector]->GetLayerNumber(gtb);
1608
1609 index=ncl;
1610 fTrSec[tracking_sector]->GetLayer(layer)->InsertCluster(c,index);
1611 }
1612 printf("\r\n");
1613
1614 return 0;
1615}
1616
5443e65e 1617//_____________________________________________________________________________
1618void AliTRDtracker::UnloadEvent()
1619{
1620 //
1621 // Clears the arrays of clusters and tracks. Resets sectors and timebins
1622 //
1623
1624 Int_t i, nentr;
1625
1626 nentr = fClusters->GetEntriesFast();
1627 for (i = 0; i < nentr; i++) delete fClusters->RemoveAt(i);
1628
1629 nentr = fSeeds->GetEntriesFast();
1630 for (i = 0; i < nentr; i++) delete fSeeds->RemoveAt(i);
1631
1632 nentr = fTracks->GetEntriesFast();
1633 for (i = 0; i < nentr; i++) delete fTracks->RemoveAt(i);
1634
1635 Int_t nsec = AliTRDgeometry::kNsect;
1636
1637 for (i = 0; i < nsec; i++) {
1638 for(Int_t pl = 0; pl < fTrSec[i]->GetNumberOfLayers(); pl++) {
1639 fTrSec[i]->GetLayer(pl)->Clear();
1640 }
1641 }
1642
1643}
1644
1645//__________________________________________________________________________
1646void AliTRDtracker::MakeSeeds(Int_t inner, Int_t outer, Int_t turn)
1647{
1648 // Creates track seeds using clusters in timeBins=i1,i2
1649
1650 if(turn > 2) {
1651 cerr<<"MakeSeeds: turn "<<turn<<" exceeds the limit of 2"<<endl;
1652 return;
1653 }
1654
1655 Double_t x[5], c[15];
1656 Int_t max_sec=AliTRDgeometry::kNsect;
1657
1658 Double_t alpha=AliTRDgeometry::GetAlpha();
1659 Double_t shift=AliTRDgeometry::GetAlpha()/2.;
1660 Double_t cs=cos(alpha), sn=sin(alpha);
1661 Double_t cs2=cos(2.*alpha), sn2=sin(2.*alpha);
1662
1663
1664 Int_t i2 = fTrSec[0]->GetLayerNumber(inner);
1665 Int_t i1 = fTrSec[0]->GetLayerNumber(outer);
1666
1667 Double_t x1 =fTrSec[0]->GetX(i1);
1668 Double_t xx2=fTrSec[0]->GetX(i2);
1669
1670 for (Int_t ns=0; ns<max_sec; ns++) {
1671
1672 Int_t nl2 = *(fTrSec[(ns-2+max_sec)%max_sec]->GetLayer(i2));
1673 Int_t nl=(*fTrSec[(ns-1+max_sec)%max_sec]->GetLayer(i2));
1674 Int_t nm=(*fTrSec[ns]->GetLayer(i2));
1675 Int_t nu=(*fTrSec[(ns+1)%max_sec]->GetLayer(i2));
1676 Int_t nu2=(*fTrSec[(ns+2)%max_sec]->GetLayer(i2));
1677
1678 AliTRDpropagationLayer& r1=*(fTrSec[ns]->GetLayer(i1));
1679
1680 for (Int_t is=0; is < r1; is++) {
1681 Double_t y1=r1[is]->GetY(), z1=r1[is]->GetZ();
1682
1683 for (Int_t js=0; js < nl2+nl+nm+nu+nu2; js++) {
a9814c09 1684
1685 const AliTRDcluster *cl;
1686 Double_t x2, y2, z2;
1687 Double_t x3=0., y3=0.;
1688
1689 if (js<nl2) {
1690 if(turn != 2) continue;
1691 AliTRDpropagationLayer& r2=*(fTrSec[(ns-2+max_sec)%max_sec]->GetLayer(i2));
1692 cl=r2[js];
1693 y2=cl->GetY(); z2=cl->GetZ();
1694
1695 x2= xx2*cs2+y2*sn2;
1696 y2=-xx2*sn2+y2*cs2;
1697 }
1698 else if (js<nl2+nl) {
1699 if(turn != 1) continue;
1700 AliTRDpropagationLayer& r2=*(fTrSec[(ns-1+max_sec)%max_sec]->GetLayer(i2));
1701 cl=r2[js-nl2];
1702 y2=cl->GetY(); z2=cl->GetZ();
1703
1704 x2= xx2*cs+y2*sn;
1705 y2=-xx2*sn+y2*cs;
1706 }
1707 else if (js<nl2+nl+nm) {
1708 if(turn != 1) continue;
1709 AliTRDpropagationLayer& r2=*(fTrSec[ns]->GetLayer(i2));
1710 cl=r2[js-nl2-nl];
1711 x2=xx2; y2=cl->GetY(); z2=cl->GetZ();
1712 }
1713 else if (js<nl2+nl+nm+nu) {
1714 if(turn != 1) continue;
1715 AliTRDpropagationLayer& r2=*(fTrSec[(ns+1)%max_sec]->GetLayer(i2));
1716 cl=r2[js-nl2-nl-nm];
1717 y2=cl->GetY(); z2=cl->GetZ();
1718
1719 x2=xx2*cs-y2*sn;
1720 y2=xx2*sn+y2*cs;
1721 }
1722 else {
1723 if(turn != 2) continue;
1724 AliTRDpropagationLayer& r2=*(fTrSec[(ns+2)%max_sec]->GetLayer(i2));
1725 cl=r2[js-nl2-nl-nm-nu];
1726 y2=cl->GetY(); z2=cl->GetZ();
1727
1728 x2=xx2*cs2-y2*sn2;
1729 y2=xx2*sn2+y2*cs2;
1730 }
1731
c630aafd 1732 if(TMath::Abs(z1-z2) > fMaxSeedDeltaZ12) continue;
a9814c09 1733
1734 Double_t zz=z1 - z1/x1*(x1-x2);
1735
c630aafd 1736 if (TMath::Abs(zz-z2)>fMaxSeedDeltaZ) continue;
a9814c09 1737
1738 Double_t d=(x2-x1)*(0.-y2)-(0.-x2)*(y2-y1);
1739 if (d==0.) {cerr<<"TRD MakeSeeds: Straight seed !\n"; continue;}
1740
1741 x[0]=y1;
1742 x[1]=z1;
1743 x[4]=f1trd(x1,y1,x2,y2,x3,y3);
1744
c630aafd 1745 if (TMath::Abs(x[4]) > fMaxSeedC) continue;
a9814c09 1746
1747 x[2]=f2trd(x1,y1,x2,y2,x3,y3);
1748
1749 if (TMath::Abs(x[4]*x1-x[2]) >= 0.99999) continue;
1750
1751 x[3]=f3trd(x1,y1,x2,y2,z1,z2);
1752
c630aafd 1753 if (TMath::Abs(x[3]) > fMaxSeedTan) continue;
a9814c09 1754
1755 Double_t a=asin(x[2]);
1756 Double_t zv=z1 - x[3]/x[4]*(a+asin(x[4]*x1-x[2]));
1757
c630aafd 1758 if (TMath::Abs(zv)>fMaxSeedVertexZ) continue;
a9814c09 1759
1760 Double_t sy1=r1[is]->GetSigmaY2(), sz1=r1[is]->GetSigmaZ2();
1761 Double_t sy2=cl->GetSigmaY2(), sz2=cl->GetSigmaZ2();
c630aafd 1762 Double_t sy3=fSeedErrorSY3, sy=fSeedErrorSY, sz=fSeedErrorSZ;
a9814c09 1763
1764 // Tilt changes
1765 Double_t h01 = GetTiltFactor(r1[is]);
b8dc2353 1766 Double_t xu_factor = 100.;
1767 if(fNoTilt) {
1768 h01 = 0;
1769 xu_factor = 1;
1770 }
1771
fd621f36 1772 sy1=sy1+sz1*h01*h01;
b3a5a838 1773 Double_t syz=sz1*(-h01);
a9814c09 1774 // end of tilt changes
1775
b3a5a838 1776 Double_t f40=(f1trd(x1,y1+sy,x2,y2,x3,y3)-x[4])/sy;
1777 Double_t f42=(f1trd(x1,y1,x2,y2+sy,x3,y3)-x[4])/sy;
1778 Double_t f43=(f1trd(x1,y1,x2,y2,x3,y3+sy)-x[4])/sy;
1779 Double_t f20=(f2trd(x1,y1+sy,x2,y2,x3,y3)-x[2])/sy;
1780 Double_t f22=(f2trd(x1,y1,x2,y2+sy,x3,y3)-x[2])/sy;
1781 Double_t f23=(f2trd(x1,y1,x2,y2,x3,y3+sy)-x[2])/sy;
1782 Double_t f30=(f3trd(x1,y1+sy,x2,y2,z1,z2)-x[3])/sy;
1783 Double_t f31=(f3trd(x1,y1,x2,y2,z1+sz,z2)-x[3])/sz;
1784 Double_t f32=(f3trd(x1,y1,x2,y2+sy,z1,z2)-x[3])/sy;
1785 Double_t f34=(f3trd(x1,y1,x2,y2,z1,z2+sz)-x[3])/sz;
1786
a9814c09 1787
b3a5a838 1788 c[0]=sy1;
a9814c09 1789 // c[1]=0.; c[2]=sz1;
b8dc2353 1790 c[1]=syz; c[2]=sz1*xu_factor;
b3a5a838 1791 c[3]=f20*sy1; c[4]=0.; c[5]=f20*sy1*f20+f22*sy2*f22+f23*sy3*f23;
1792 c[6]=f30*sy1; c[7]=f31*sz1; c[8]=f30*sy1*f20+f32*sy2*f22;
1793 c[9]=f30*sy1*f30+f31*sz1*f31+f32*sy2*f32+f34*sz2*f34;
1794 c[10]=f40*sy1; c[11]=0.; c[12]=f40*sy1*f20+f42*sy2*f22+f43*sy3*f23;
1795 c[13]=f30*sy1*f40+f32*sy2*f42;
1796 c[14]=f40*sy1*f40+f42*sy2*f42+f43*sy3*f43;
a9814c09 1797
1798 UInt_t index=r1.GetIndex(is);
1799
1800 AliTRDtrack *track=new AliTRDtrack(r1[is],index,x,c,x1,ns*alpha+shift);
1801
1802 Int_t rc=FollowProlongation(*track, i2);
1803
1804 if ((rc < 1) ||
1805 (track->GetNumberOfClusters() <
c630aafd 1806 (outer-inner)*fMinClustersInSeed)) delete track;
a9814c09 1807 else {
1808 fSeeds->AddLast(track); fNseeds++;
e24ea474 1809// cerr<<"\r found seed "<<fNseeds;
a9814c09 1810 }
5443e65e 1811 }
1812 }
1813 }
1814}
1815
1816//_____________________________________________________________________________
c630aafd 1817Int_t AliTRDtracker::ReadClusters(TObjArray *array, TTree *ClusterTree)
5443e65e 1818{
1819 //
a819a5f7 1820 // Reads AliTRDclusters (option >= 0) or AliTRDrecPoints (option < 0)
1821 // from the file. The names of the cluster tree and branches
1822 // should match the ones used in AliTRDclusterizer::WriteClusters()
1823 //
5443e65e 1824 TObjArray *ClusterArray = new TObjArray(400);
1825
c630aafd 1826 TBranch *branch=ClusterTree->GetBranch("TRDcluster");
1827 if (!branch) {
1828 Error("ReadClusters","Can't get the branch !");
1829 return 1;
1830 }
1831 branch->SetAddress(&ClusterArray);
5443e65e 1832
1833 Int_t nEntries = (Int_t) ClusterTree->GetEntries();
1834 printf("found %d entries in %s.\n",nEntries,ClusterTree->GetName());
a819a5f7 1835
a819a5f7 1836 // Loop through all entries in the tree
1837 Int_t nbytes;
1838 AliTRDcluster *c = 0;
5443e65e 1839 printf("\n");
a819a5f7 1840
1841 for (Int_t iEntry = 0; iEntry < nEntries; iEntry++) {
1842
1843 // Import the tree
5443e65e 1844 nbytes += ClusterTree->GetEvent(iEntry);
1845
a819a5f7 1846 // Get the number of points in the detector
5443e65e 1847 Int_t nCluster = ClusterArray->GetEntriesFast();
e24ea474 1848// printf("\r Read %d clusters from entry %d", nCluster, iEntry);
5443e65e 1849
a819a5f7 1850 // Loop through all TRD digits
1851 for (Int_t iCluster = 0; iCluster < nCluster; iCluster++) {
5443e65e 1852 c = (AliTRDcluster*)ClusterArray->UncheckedAt(iCluster);
a819a5f7 1853 AliTRDcluster *co = new AliTRDcluster(*c);
1854 co->SetSigmaY2(c->GetSigmaY2() * fSY2corr);
5443e65e 1855 Int_t ltb = co->GetLocalTimeBin();
b8dc2353 1856 if(ltb == 19) co->SetSigmaZ2(c->GetSigmaZ2());
1857 else if(fNoTilt) co->SetSigmaZ2(c->GetSigmaZ2() * fSZ2corr);
a819a5f7 1858 array->AddLast(co);
5443e65e 1859 delete ClusterArray->RemoveAt(iCluster);
a819a5f7 1860 }
1861 }
1862
5443e65e 1863 delete ClusterArray;
5443e65e 1864
c630aafd 1865 return 0;
a819a5f7 1866}
1867
5443e65e 1868//______________________________________________________________________
1869void AliTRDtracker::ReadClusters(TObjArray *array, const Char_t *filename)
a819a5f7 1870{
1871 //
5443e65e 1872 // Reads AliTRDclusters from file <filename>. The names of the cluster
1873 // tree and branches should match the ones used in
1874 // AliTRDclusterizer::WriteClusters()
1875 // if <array> == 0, clusters are added into AliTRDtracker fCluster array
a819a5f7 1876 //
1877
5443e65e 1878 TDirectory *savedir=gDirectory;
46d29e70 1879
5443e65e 1880 TFile *file = TFile::Open(filename);
1881 if (!file->IsOpen()) {
1882 cerr<<"Can't open file with TRD clusters"<<endl;
1883 return;
1884 }
46d29e70 1885
5443e65e 1886 Char_t treeName[12];
e24ea474 1887 sprintf(treeName,"TreeR%d_TRD",GetEventNumber());
5443e65e 1888 TTree *ClusterTree = (TTree*) gDirectory->Get(treeName);
46d29e70 1889
5443e65e 1890 if (!ClusterTree) {
1891 cerr<<"AliTRDtracker::ReadClusters(): ";
1892 cerr<<"can't get a tree with clusters !\n";
1893 return;
1894 }
46d29e70 1895
5443e65e 1896 TObjArray *ClusterArray = new TObjArray(400);
46d29e70 1897
5443e65e 1898 ClusterTree->GetBranch("TRDcluster")->SetAddress(&ClusterArray);
46d29e70 1899
5443e65e 1900 Int_t nEntries = (Int_t) ClusterTree->GetEntries();
1901 cout<<"found "<<nEntries<<" in ClusterTree"<<endl;
a819a5f7 1902
5443e65e 1903 // Loop through all entries in the tree
1904 Int_t nbytes;
1905 AliTRDcluster *c = 0;
bbf92647 1906
5443e65e 1907 printf("\n");
bbf92647 1908
5443e65e 1909 for (Int_t iEntry = 0; iEntry < nEntries; iEntry++) {
46d29e70 1910
5443e65e 1911 // Import the tree
1912 nbytes += ClusterTree->GetEvent(iEntry);
0a29d0f1 1913
5443e65e 1914 // Get the number of points in the detector
1915 Int_t nCluster = ClusterArray->GetEntriesFast();
b3a5a838 1916 printf("\n Read %d clusters from entry %d", nCluster, iEntry);
5443e65e 1917
1918 // Loop through all TRD digits
1919 for (Int_t iCluster = 0; iCluster < nCluster; iCluster++) {
1920 c = (AliTRDcluster*)ClusterArray->UncheckedAt(iCluster);
1921 AliTRDcluster *co = new AliTRDcluster(*c);
1922 co->SetSigmaY2(c->GetSigmaY2() * fSY2corr);
1923 Int_t ltb = co->GetLocalTimeBin();
b8dc2353 1924 if(ltb == 19) co->SetSigmaZ2(c->GetSigmaZ2());
1925 else if(fNoTilt) co->SetSigmaZ2(c->GetSigmaZ2() * fSZ2corr);
5443e65e 1926 array->AddLast(co);
1927 delete ClusterArray->RemoveAt(iCluster);
1928 }
46d29e70 1929 }
0a29d0f1 1930
5443e65e 1931 file->Close();
1932 delete ClusterArray;
1933 savedir->cd();
1934
1935}
1936
c630aafd 1937void AliTRDtracker::ReadClusters(TObjArray *array, const TFile *inp)
1938{
1939 //
1940 // Reads AliTRDclusters (option >= 0) or AliTRDrecPoints (option < 0)
1941 // from the file. The names of the cluster tree and branches
1942 // should match the ones used in AliTRDclusterizer::WriteClusters()
1943 //
1944
1945 TDirectory *savedir=gDirectory;
1946
1947 if (inp) {
1948 TFile *in=(TFile*)inp;
1949 if (!in->IsOpen()) {
1950 cerr<<"AliTRDtracker::ReadClusters(): input file is not open !\n";
1951 return;
1952 }
1953 else{
1954 in->cd();
1955 }
1956 }
1957
1958 Char_t treeName[12];
1959 sprintf(treeName,"TreeR%d_TRD",GetEventNumber());
1960 TTree *ClusterTree = (TTree*) gDirectory->Get(treeName);
1961
1962 TObjArray *ClusterArray = new TObjArray(400);
1963
1964 ClusterTree->GetBranch("TRDcluster")->SetAddress(&ClusterArray);
1965
1966 Int_t nEntries = (Int_t) ClusterTree->GetEntries();
1967 printf("found %d entries in %s.\n",nEntries,ClusterTree->GetName());
1968
1969 // Loop through all entries in the tree
1970 Int_t nbytes;
1971 AliTRDcluster *c = 0;
1972 printf("\n");
1973
1974 for (Int_t iEntry = 0; iEntry < nEntries; iEntry++) {
1975
1976 // Import the tree
1977 nbytes += ClusterTree->GetEvent(iEntry);
1978
1979 // Get the number of points in the detector
1980 Int_t nCluster = ClusterArray->GetEntriesFast();
1981// printf("\r Read %d clusters from entry %d", nCluster, iEntry);
1982
1983 // Loop through all TRD digits
1984 for (Int_t iCluster = 0; iCluster < nCluster; iCluster++) {
1985 c = (AliTRDcluster*)ClusterArray->UncheckedAt(iCluster);
1986 AliTRDcluster *co = new AliTRDcluster(*c);
1987 co->SetSigmaY2(c->GetSigmaY2() * fSY2corr);
1988 Int_t ltb = co->GetLocalTimeBin();
1989 if(ltb == 19) co->SetSigmaZ2(c->GetSigmaZ2());
1990 else if(fNoTilt) co->SetSigmaZ2(c->GetSigmaZ2() * fSZ2corr);
1991 array->AddLast(co);
1992 delete ClusterArray->RemoveAt(iCluster);
1993 }
1994 }
1995
1996 delete ClusterArray;
1997 savedir->cd();
1998
1999}
46d29e70 2000
2001//__________________________________________________________________
5443e65e 2002void AliTRDtracker::CookLabel(AliKalmanTrack* pt, Float_t wrong) const {
46d29e70 2003
2004 Int_t label=123456789, index, i, j;
5443e65e 2005 Int_t ncl=pt->GetNumberOfClusters();
2006 const Int_t range = fTrSec[0]->GetOuterTimeBin()+1;
2007
2008 Bool_t label_added;
46d29e70 2009
5443e65e 2010 // Int_t s[range][2];
2011 Int_t **s = new Int_t* [range];
2012 for (i=0; i<range; i++) {
d1b06c24 2013 s[i] = new Int_t[2];
2014 }
5443e65e 2015 for (i=0; i<range; i++) {
46d29e70 2016 s[i][0]=-1;
2017 s[i][1]=0;
2018 }
2019
2020 Int_t t0,t1,t2;
2021 for (i=0; i<ncl; i++) {
5443e65e 2022 index=pt->GetClusterIndex(i);
46d29e70 2023 AliTRDcluster *c=(AliTRDcluster*)fClusters->UncheckedAt(index);
5443e65e 2024 t0=c->GetLabel(0);
2025 t1=c->GetLabel(1);
2026 t2=c->GetLabel(2);
46d29e70 2027 }
2028
2029 for (i=0; i<ncl; i++) {
5443e65e 2030 index=pt->GetClusterIndex(i);
46d29e70 2031 AliTRDcluster *c=(AliTRDcluster*)fClusters->UncheckedAt(index);
2032 for (Int_t k=0; k<3; k++) {
5443e65e 2033 label=c->GetLabel(k);
2034 label_added=kFALSE; j=0;
46d29e70 2035 if (label >= 0) {
a9814c09 2036 while ( (!label_added) && ( j < range ) ) {
2037 if (s[j][0]==label || s[j][1]==0) {
2038 s[j][0]=label;
2039 s[j][1]=s[j][1]+1;
2040 label_added=kTRUE;
2041 }
2042 j++;
2043 }
46d29e70 2044 }
2045 }
2046 }
2047
46d29e70 2048 Int_t max=0;
2049 label = -123456789;
2050
5443e65e 2051 for (i=0; i<range; i++) {
46d29e70 2052 if (s[i][1]>max) {
2053 max=s[i][1]; label=s[i][0];
2054 }
2055 }
5443e65e 2056
2057 for (i=0; i<range; i++) {
2058 delete []s[i];
2059 }
2060
d1b06c24 2061 delete []s;
5443e65e 2062
2063 if ((1.- Float_t(max)/ncl) > wrong) label=-label;
2064
2065 pt->SetLabel(label);
2066
46d29e70 2067}
2068
c630aafd 2069
5443e65e 2070//__________________________________________________________________
ca6c93d6 2071void AliTRDtracker::UseClusters(const AliKalmanTrack* t, Int_t from) const {
5443e65e 2072 Int_t ncl=t->GetNumberOfClusters();
2073 for (Int_t i=from; i<ncl; i++) {
2074 Int_t index = t->GetClusterIndex(i);
2075 AliTRDcluster *c=(AliTRDcluster*)fClusters->UncheckedAt(index);
2076 c->Use();
2077 }
2078}
2079
2080
2081//_____________________________________________________________________
73ae7b59 2082Double_t AliTRDtracker::ExpectedSigmaY2(Double_t , Double_t , Double_t )
5443e65e 2083{
2084 // Parametrised "expected" error of the cluster reconstruction in Y
2085
2086 Double_t s = 0.08 * 0.08;
2087 return s;
2088}
2089
2090//_____________________________________________________________________
73ae7b59 2091Double_t AliTRDtracker::ExpectedSigmaZ2(Double_t , Double_t )
0a29d0f1 2092{
5443e65e 2093 // Parametrised "expected" error of the cluster reconstruction in Z
2094
a9814c09 2095 Double_t s = 9 * 9 /12.;
5443e65e 2096 return s;
2097}
2098
2099
2100//_____________________________________________________________________
2101Double_t AliTRDtracker::GetX(Int_t sector, Int_t plane, Int_t local_tb) const
2102{
2103 //
2104 // Returns radial position which corresponds to time bin <local_tb>
2105 // in tracking sector <sector> and plane <plane>
2106 //
2107
2108 Int_t index = fTrSec[sector]->CookTimeBinIndex(plane, local_tb);
2109 Int_t pl = fTrSec[sector]->GetLayerNumber(index);
2110 return fTrSec[sector]->GetLayer(pl)->GetX();
2111
2112}
2113
c630aafd 2114
5443e65e 2115//_______________________________________________________
2116AliTRDtracker::AliTRDpropagationLayer::AliTRDpropagationLayer(Double_t x,
a9814c09 2117 Double_t dx, Double_t rho, Double_t rad_length, Int_t tb_index)
5443e65e 2118{
0a29d0f1 2119 //
5443e65e 2120 // AliTRDpropagationLayer constructor
0a29d0f1 2121 //
46d29e70 2122
b3a5a838 2123 fN = 0; fX = x; fdX = dx; fRho = rho; fX0 = rad_length;
5443e65e 2124 fClusters = NULL; fIndex = NULL; fTimeBinIndex = tb_index;
2125
46d29e70 2126
5443e65e 2127 for(Int_t i=0; i < (Int_t) kZONES; i++) {
2128 fZc[i]=0; fZmax[i] = 0;
a819a5f7 2129 }
5443e65e 2130
2131 fYmax = 0;
2132
2133 if(fTimeBinIndex >= 0) {
ca6c93d6 2134 fClusters = new AliTRDcluster*[kMAX_CLUSTER_PER_TIME_BIN];
2135 fIndex = new UInt_t[kMAX_CLUSTER_PER_TIME_BIN];
a819a5f7 2136 }
46d29e70 2137
5443e65e 2138 fHole = kFALSE;
2139 fHoleZc = 0;
2140 fHoleZmax = 0;
2141 fHoleYc = 0;
2142 fHoleYmax = 0;
2143 fHoleRho = 0;
2144 fHoleX0 = 0;
2145
2146}
2147
2148//_______________________________________________________
2149void AliTRDtracker::AliTRDpropagationLayer::SetHole(
a9814c09 2150 Double_t Zmax, Double_t Ymax, Double_t rho,
2151 Double_t rad_length, Double_t Yc, Double_t Zc)
5443e65e 2152{
2153 //
2154 // Sets hole in the layer
2155 //
2156
2157 fHole = kTRUE;
2158 fHoleZc = Zc;
2159 fHoleZmax = Zmax;
2160 fHoleYc = Yc;
2161 fHoleYmax = Ymax;
2162 fHoleRho = rho;
b3a5a838 2163 fHoleX0 = rad_length;
5443e65e 2164}
2165
46d29e70 2166
5443e65e 2167//_______________________________________________________
2168AliTRDtracker::AliTRDtrackingSector::AliTRDtrackingSector(AliTRDgeometry* geo, Int_t gs, AliTRDparameter* par)
2169{
2170 //
2171 // AliTRDtrackingSector Constructor
2172 //
2173
2174 fGeom = geo;
2175 fPar = par;
2176 fGeomSector = gs;
2177 fTzeroShift = 0.13;
2178 fN = 0;
2179
2180 for(UInt_t i=0; i < kMAX_TIME_BIN_INDEX; i++) fTimeBinIndex[i] = -1;
2181
2182
2183 AliTRDpropagationLayer* ppl;
2184
b3a5a838 2185 Double_t x, xin, xout, dx, rho, rad_length;
5443e65e 2186 Int_t steps;
46d29e70 2187
5443e65e 2188 // set time bins in the gas of the TPC
46d29e70 2189
5443e65e 2190 xin = 246.055; xout = 254.055; steps = 20; dx = (xout-xin)/steps;
b3a5a838 2191 rho = 0.9e-3; rad_length = 28.94;
5443e65e 2192
2193 for(Int_t i=0; i<steps; i++) {
2194 x = xin + i*dx + dx/2;
b3a5a838 2195 ppl = new AliTRDpropagationLayer(x,dx,rho,rad_length,-1);
5443e65e 2196 InsertLayer(ppl);
46d29e70 2197 }
2198
5443e65e 2199 // set time bins in the outer field cage vessel
46d29e70 2200
b3a5a838 2201 dx = 50e-4; xin = xout; xout = xin + dx; rho = 1.71; rad_length = 44.77; // Tedlar
2202 ppl = new AliTRDpropagationLayer(xin+dx/2,dx,rho,rad_length,-1);
5443e65e 2203 InsertLayer(ppl);
46d29e70 2204
b3a5a838 2205 dx = 0.02; xin = xout; xout = xin + dx; rho = 1.45; rad_length = 44.86; // prepreg
2206 ppl = new AliTRDpropagationLayer(xin+dx/2,dx,rho,rad_length,-1);
5443e65e 2207 InsertLayer(ppl);
2208
b3a5a838 2209 dx = 2.; xin = xout; xout = xin + dx; rho = 1.45*0.02; rad_length = 41.28; // Nomex
5443e65e 2210 steps = 5; dx = (xout - xin)/steps;
2211 for(Int_t i=0; i<steps; i++) {
2212 x = xin + i*dx + dx/2;
b3a5a838 2213 ppl = new AliTRDpropagationLayer(x,dx,rho,rad_length,-1);
5443e65e 2214 InsertLayer(ppl);
2215 }
2216
b3a5a838 2217 dx = 0.02; xin = xout; xout = xin + dx; rho = 1.45; rad_length = 44.86; // prepreg
2218 ppl = new AliTRDpropagationLayer(xin+dx/2,dx,rho,rad_length,-1);
5443e65e 2219 InsertLayer(ppl);
2220
b3a5a838 2221 dx = 50e-4; xin = xout; xout = xin + dx; rho = 1.71; rad_length = 44.77; // Tedlar
2222 ppl = new AliTRDpropagationLayer(xin+dx/2,dx,rho,rad_length,-1);
5443e65e 2223 InsertLayer(ppl);
0a29d0f1 2224
5443e65e 2225
2226 // set time bins in CO2
2227
2228 xin = xout; xout = 275.0;
2229 steps = 50; dx = (xout - xin)/steps;
b3a5a838 2230 rho = 1.977e-3; rad_length = 36.2;
5443e65e 2231
2232 for(Int_t i=0; i<steps; i++) {
2233 x = xin + i*dx + dx/2;
b3a5a838 2234 ppl = new AliTRDpropagationLayer(x,dx,rho,rad_length,-1);
5443e65e 2235 InsertLayer(ppl);
2236 }
2237
2238 // set time bins in the outer containment vessel
2239
b3a5a838 2240 dx = 50e-4; xin = xout; xout = xin + dx; rho = 2.7; rad_length = 24.01; // Al
2241 ppl = new AliTRDpropagationLayer(xin+dx/2,dx,rho,rad_length,-1);
5443e65e 2242 InsertLayer(ppl);
2243
b3a5a838 2244 dx = 50e-4; xin = xout; xout = xin + dx; rho = 1.71; rad_length = 44.77; // Tedlar
2245 ppl = new AliTRDpropagationLayer(xin+dx/2,dx,rho,rad_length,-1);
5443e65e 2246 InsertLayer(ppl);
2247
b3a5a838 2248 dx = 0.06; xin = xout; xout = xin + dx; rho = 1.45; rad_length = 44.86; // prepreg
2249 ppl = new AliTRDpropagationLayer(xin+dx/2,dx,rho,rad_length,-1);
5443e65e 2250 InsertLayer(ppl);
2251
b3a5a838 2252 dx = 3.; xin = xout; xout = xin + dx; rho = 1.45*0.02; rad_length = 41.28; // Nomex
5443e65e 2253 steps = 10; dx = (xout - xin)/steps;
2254 for(Int_t i=0; i<steps; i++) {
2255 x = xin + i*dx + dx/2;
b3a5a838 2256 ppl = new AliTRDpropagationLayer(x,dx,rho,rad_length,-1);
5443e65e 2257 InsertLayer(ppl);
2258 }
2259
b3a5a838 2260 dx = 0.06; xin = xout; xout = xin + dx; rho = 1.45; rad_length = 44.86; // prepreg
2261 ppl = new AliTRDpropagationLayer(xin+dx/2,dx,rho,rad_length,-1);
5443e65e 2262 InsertLayer(ppl);
2263
b3a5a838 2264 dx = 50e-4; xin = xout; xout = xin + dx; rho = 1.71; rad_length = 44.77; // Tedlar
2265 ppl = new AliTRDpropagationLayer(xin+dx/2,dx,rho,rad_length,-1);
5443e65e 2266 InsertLayer(ppl);
2267
b3a5a838 2268 dx = 50e-4; xin = xout; xout = xin + dx; rho = 2.7; rad_length = 24.01; // Al
2269 ppl = new AliTRDpropagationLayer(xin+dx/2,dx,rho,rad_length,-1);
5443e65e 2270 InsertLayer(ppl);
2271
2272 Double_t xtrd = (Double_t) fGeom->Rmin();
2273
2274 // add layers between TPC and TRD (Air temporarily)
2275 xin = xout; xout = xtrd;
2276 steps = 50; dx = (xout - xin)/steps;
b3a5a838 2277 rho = 1.2e-3; rad_length = 36.66;
5443e65e 2278
2279 for(Int_t i=0; i<steps; i++) {
2280 x = xin + i*dx + dx/2;
b3a5a838 2281 ppl = new AliTRDpropagationLayer(x,dx,rho,rad_length,-1);
5443e65e 2282 InsertLayer(ppl);
2283 }
2284
2285
2286 Double_t alpha=AliTRDgeometry::GetAlpha();
2287
2288 // add layers for each of the planes
2289
2290 Double_t dxRo = (Double_t) fGeom->CroHght(); // Rohacell
2291 Double_t dxSpace = (Double_t) fGeom->Cspace(); // Spacing between planes
2292 Double_t dxAmp = (Double_t) fGeom->CamHght(); // Amplification region
2293 Double_t dxDrift = (Double_t) fGeom->CdrHght(); // Drift region
2294 Double_t dxRad = (Double_t) fGeom->CraHght(); // Radiator
2295 Double_t dxTEC = dxRad + dxDrift + dxAmp + dxRo;
2296 Double_t dxPlane = dxTEC + dxSpace;
2297
5443e65e 2298 Int_t tb, tb_index;
2299 const Int_t nChambers = AliTRDgeometry::Ncham();
ca6c93d6 2300 Double_t Ymax = 0, holeYmax = 0;
2301 Double_t * Zc = new Double_t[nChambers];
2302 Double_t * Zmax = new Double_t[nChambers];
5443e65e 2303 Double_t holeZmax = 1000.; // the whole sector is missing
2304
5443e65e 2305 for(Int_t plane = 0; plane < AliTRDgeometry::Nplan(); plane++) {
2306
2307 // Radiator
2308 xin = xtrd + plane * dxPlane; xout = xin + dxRad;
b3a5a838 2309 steps = 12; dx = (xout - xin)/steps; rho = 0.074; rad_length = 40.6;
5443e65e 2310 for(Int_t i=0; i<steps; i++) {
2311 x = xin + i*dx + dx/2;
b3a5a838 2312 ppl = new AliTRDpropagationLayer(x,dx,rho,rad_length,-1);
5443e65e 2313 if((fGeom->GetPHOShole()) && (fGeomSector >= 2) && (fGeomSector <= 6)) {
a9814c09 2314 holeYmax = x*TMath::Tan(0.5*alpha);
2315 ppl->SetHole(holeYmax, holeZmax);
5443e65e 2316 }
2317 if((fGeom->GetRICHhole()) && (fGeomSector >= 12) && (fGeomSector <= 14)) {
a9814c09 2318 holeYmax = x*TMath::Tan(0.5*alpha);
2319 ppl->SetHole(holeYmax, holeZmax);
5443e65e 2320 }
2321 InsertLayer(ppl);
2322 }
2323
2324 Ymax = fGeom->GetChamberWidth(plane)/2;
2325 for(Int_t ch = 0; ch < nChambers; ch++) {
2326 Zmax[ch] = fGeom->GetChamberLength(plane,ch)/2;
2327 Float_t pad = fPar->GetRowPadSize(plane,ch,0);
2328 Float_t row0 = fPar->GetRow0(plane,ch,0);
2329 Int_t nPads = fPar->GetRowMax(plane,ch,0);
2330 Zc[ch] = (pad * nPads)/2 + row0 - pad/2;
2331 }
2332
2333 dx = fPar->GetTimeBinSize();
b3a5a838 2334 rho = 0.00295 * 0.85; rad_length = 11.0;
5443e65e 2335
2336 Double_t x0 = (Double_t) fPar->GetTime0(plane);
2337 Double_t xbottom = x0 - dxDrift;
2338 Double_t xtop = x0 + dxAmp;
2339
2340 // Amplification region
2341
2342 steps = (Int_t) (dxAmp/dx);
2343
2344 for(tb = 0; tb < steps; tb++) {
2345 x = x0 + tb * dx + dx/2;
2346 tb_index = CookTimeBinIndex(plane, -tb-1);
b3a5a838 2347 ppl = new AliTRDpropagationLayer(x,dx,rho,rad_length,tb_index);
5443e65e 2348 ppl->SetYmax(Ymax);
2349 for(Int_t ch = 0; ch < nChambers; ch++) {
a9814c09 2350 ppl->SetZmax(ch, Zc[ch], Zmax[ch]);
5443e65e 2351 }
2352 if((fGeom->GetPHOShole()) && (fGeomSector >= 2) && (fGeomSector <= 6)) {
a9814c09 2353 holeYmax = x*TMath::Tan(0.5*alpha);
2354 ppl->SetHole(holeYmax, holeZmax);
5443e65e 2355 }
2356 if((fGeom->GetRICHhole()) && (fGeomSector >= 12) && (fGeomSector <= 14)) {
a9814c09 2357 holeYmax = x*TMath::Tan(0.5*alpha);
2358 ppl->SetHole(holeYmax, holeZmax);
5443e65e 2359 }
2360 InsertLayer(ppl);
2361 }
2362 tb_index = CookTimeBinIndex(plane, -steps);
2363 x = (x + dx/2 + xtop)/2;
2364 dx = 2*(xtop-x);
b3a5a838 2365 ppl = new AliTRDpropagationLayer(x,dx,rho,rad_length,tb_index);
5443e65e 2366 ppl->SetYmax(Ymax);
2367 for(Int_t ch = 0; ch < nChambers; ch++) {
2368 ppl->SetZmax(ch, Zc[ch], Zmax[ch]);
2369 }
2370 if((fGeom->GetPHOShole()) && (fGeomSector >= 2) && (fGeomSector <= 6)) {
2371 holeYmax = x*TMath::Tan(0.5*alpha);
2372 ppl->SetHole(holeYmax, holeZmax);
2373 }
2374 if((fGeom->GetRICHhole()) && (fGeomSector >= 12) && (fGeomSector <= 14)) {
2375 holeYmax = x*TMath::Tan(0.5*alpha);
2376 ppl->SetHole(holeYmax, holeZmax);
2377 }
2378 InsertLayer(ppl);
2379
2380 // Drift region
2381 dx = fPar->GetTimeBinSize();
2382 steps = (Int_t) (dxDrift/dx);
2383
2384 for(tb = 0; tb < steps; tb++) {
2385 x = x0 - tb * dx - dx/2;
2386 tb_index = CookTimeBinIndex(plane, tb);
2387
b3a5a838 2388 ppl = new AliTRDpropagationLayer(x,dx,rho,rad_length,tb_index);
5443e65e 2389 ppl->SetYmax(Ymax);
2390 for(Int_t ch = 0; ch < nChambers; ch++) {
a9814c09 2391 ppl->SetZmax(ch, Zc[ch], Zmax[ch]);
5443e65e 2392 }
2393 if((fGeom->GetPHOShole()) && (fGeomSector >= 2) && (fGeomSector <= 6)) {
a9814c09 2394 holeYmax = x*TMath::Tan(0.5*alpha);
2395 ppl->SetHole(holeYmax, holeZmax);
5443e65e 2396 }
2397 if((fGeom->GetRICHhole()) && (fGeomSector >= 12) && (fGeomSector <= 14)) {
a9814c09 2398 holeYmax = x*TMath::Tan(0.5*alpha);
2399 ppl->SetHole(holeYmax, holeZmax);
5443e65e 2400 }
2401 InsertLayer(ppl);
2402 }
2403 tb_index = CookTimeBinIndex(plane, steps);
2404 x = (x - dx/2 + xbottom)/2;
2405 dx = 2*(x-xbottom);
b3a5a838 2406 ppl = new AliTRDpropagationLayer(x,dx,rho,rad_length,tb_index);
5443e65e 2407 ppl->SetYmax(Ymax);
2408 for(Int_t ch = 0; ch < nChambers; ch++) {
2409 ppl->SetZmax(ch, Zc[ch], Zmax[ch]);
2410 }
2411 if((fGeom->GetPHOShole()) && (fGeomSector >= 2) && (fGeomSector <= 6)) {
2412 holeYmax = x*TMath::Tan(0.5*alpha);
2413 ppl->SetHole(holeYmax, holeZmax);
2414 }
2415 if((fGeom->GetRICHhole()) && (fGeomSector >= 12) && (fGeomSector <= 14)) {
2416 holeYmax = x*TMath::Tan(0.5*alpha);
2417 ppl->SetHole(holeYmax, holeZmax);
2418 }
2419 InsertLayer(ppl);
2420
2421 // Pad Plane
b3a5a838 2422 xin = xtop; dx = 0.025; xout = xin + dx; rho = 1.7; rad_length = 33.0;
2423 ppl = new AliTRDpropagationLayer(xin+dx/2,dx,rho,rad_length,-1);
5443e65e 2424 if((fGeom->GetPHOShole()) && (fGeomSector >= 2) && (fGeomSector <= 6)) {
2425 holeYmax = (xin+dx/2)*TMath::Tan(0.5*alpha);
2426 ppl->SetHole(holeYmax, holeZmax);
2427 }
2428 if((fGeom->GetRICHhole()) && (fGeomSector >= 12) && (fGeomSector <= 14)) {
2429 holeYmax = (xin+dx/2)*TMath::Tan(0.5*alpha);
2430 ppl->SetHole(holeYmax, holeZmax);
2431 }
2432 InsertLayer(ppl);
2433
2434 // Rohacell
2435 xin = xout; xout = xtrd + (plane + 1) * dxPlane - dxSpace;
b3a5a838 2436 steps = 5; dx = (xout - xin)/steps; rho = 0.074; rad_length = 40.6;
5443e65e 2437 for(Int_t i=0; i<steps; i++) {
2438 x = xin + i*dx + dx/2;
b3a5a838 2439 ppl = new AliTRDpropagationLayer(x,dx,rho,rad_length,-1);
5443e65e 2440 if((fGeom->GetPHOShole()) && (fGeomSector >= 2) && (fGeomSector <= 6)) {
a9814c09 2441 holeYmax = x*TMath::Tan(0.5*alpha);
2442 ppl->SetHole(holeYmax, holeZmax);
5443e65e 2443 }
2444 if((fGeom->GetRICHhole()) && (fGeomSector >= 12) && (fGeomSector <= 14)) {
a9814c09 2445 holeYmax = x*TMath::Tan(0.5*alpha);
2446 ppl->SetHole(holeYmax, holeZmax);
5443e65e 2447 }
2448 InsertLayer(ppl);
2449 }
2450
2451 // Space between the chambers, air
2452 xin = xout; xout = xtrd + (plane + 1) * dxPlane;
b3a5a838 2453 steps = 5; dx = (xout - xin)/steps; rho = 1.29e-3; rad_length = 36.66;
5443e65e 2454 for(Int_t i=0; i<steps; i++) {
2455 x = xin + i*dx + dx/2;
b3a5a838 2456 ppl = new AliTRDpropagationLayer(x,dx,rho,rad_length,-1);
5443e65e 2457 if((fGeom->GetPHOShole()) && (fGeomSector >= 2) && (fGeomSector <= 6)) {
a9814c09 2458 holeYmax = x*TMath::Tan(0.5*alpha);
2459 ppl->SetHole(holeYmax, holeZmax);
5443e65e 2460 }
2461 if((fGeom->GetRICHhole()) && (fGeomSector >= 12) && (fGeomSector <= 14)) {
a9814c09 2462 holeYmax = x*TMath::Tan(0.5*alpha);
2463 ppl->SetHole(holeYmax, holeZmax);
5443e65e 2464 }
2465 InsertLayer(ppl);
2466 }
2467 }
2468
2469 // Space between the TRD and RICH
2470 Double_t xRICH = 500.;
2471 xin = xout; xout = xRICH;
b3a5a838 2472 steps = 200; dx = (xout - xin)/steps; rho = 1.29e-3; rad_length = 36.66;
5443e65e 2473 for(Int_t i=0; i<steps; i++) {
2474 x = xin + i*dx + dx/2;
b3a5a838 2475 ppl = new AliTRDpropagationLayer(x,dx,rho,rad_length,-1);
5443e65e 2476 InsertLayer(ppl);
2477 }
2478
2479 MapTimeBinLayers();
ca6c93d6 2480 delete [] Zc;
2481 delete [] Zmax;
5443e65e 2482
2483}
2484
2485//______________________________________________________
2486
2487Int_t AliTRDtracker::AliTRDtrackingSector::CookTimeBinIndex(Int_t plane, Int_t local_tb) const
2488{
2489 //
2490 // depending on the digitization parameters calculates "global"
2491 // time bin index for timebin <local_tb> in plane <plane>
2492 //
2493
2494 Double_t dxAmp = (Double_t) fGeom->CamHght(); // Amplification region
2495 Double_t dxDrift = (Double_t) fGeom->CdrHght(); // Drift region
2496 Double_t dx = (Double_t) fPar->GetTimeBinSize();
2497
2498 Int_t tbAmp = fPar->GetTimeBefore();
2499 Int_t maxAmp = (Int_t) ((dxAmp+0.000001)/dx);
b3a5a838 2500 if(kTRUE) maxAmp = 0; // intentional until we change parameter class
5443e65e 2501 Int_t tbDrift = fPar->GetTimeMax();
2502 Int_t maxDrift = (Int_t) ((dxDrift+0.000001)/dx);
2503
2504 Int_t tb_per_plane = TMath::Min(tbAmp,maxAmp) + TMath::Min(tbDrift,maxDrift);
2505
b3a5a838 2506 Int_t gtb = (plane+1) * tb_per_plane - local_tb - 1 - TMath::Min(tbAmp,maxAmp);
5443e65e 2507
2508 if((local_tb < 0) &&
2509 (TMath::Abs(local_tb) > TMath::Min(tbAmp,maxAmp))) return -1;
2510 if(local_tb >= TMath::Min(tbDrift,maxDrift)) return -1;
2511
2512 return gtb;
2513
2514
2515}
2516
2517//______________________________________________________
2518
2519void AliTRDtracker::AliTRDtrackingSector::MapTimeBinLayers()
2520{
2521 //
2522 // For all sensitive time bins sets corresponding layer index
2523 // in the array fTimeBins
2524 //
2525
2526 Int_t index;
2527
2528 for(Int_t i = 0; i < fN; i++) {
2529 index = fLayers[i]->GetTimeBinIndex();
2530
2531 // printf("gtb %d -> pl %d -> x %f \n", index, i, fLayers[i]->GetX());
2532
2533 if(index < 0) continue;
2534 if(index >= (Int_t) kMAX_TIME_BIN_INDEX) {
2535 printf("*** AliTRDtracker::MapTimeBinLayers: \n");
2536 printf(" index %d exceeds allowed maximum of %d!\n",
a9814c09 2537 index, kMAX_TIME_BIN_INDEX-1);
5443e65e 2538 continue;
2539 }
2540 fTimeBinIndex[index] = i;
2541 }
2542
2543 Double_t x1, dx1, x2, dx2, gap;
2544
2545 for(Int_t i = 0; i < fN-1; i++) {
2546 x1 = fLayers[i]->GetX();
2547 dx1 = fLayers[i]->GetdX();
2548 x2 = fLayers[i+1]->GetX();
2549 dx2 = fLayers[i+1]->GetdX();
2550 gap = (x2 - dx2/2) - (x1 + dx1/2);
2551 if(gap < -0.01) {
2552 printf("*** warning: layers %d and %d are overlayed:\n",i,i+1);
2553 printf(" %f + %f + %f > %f\n", x1, dx1/2, dx2/2, x2);
2554 }
2555 if(gap > 0.01) {
2556 printf("*** warning: layers %d and %d have a large gap:\n",i,i+1);
2557 printf(" (%f - %f) - (%f + %f) = %f\n",
a9814c09 2558 x2, dx2/2, x1, dx1, gap);
5443e65e 2559 }
2560 }
2561}
2562
2563
2564//______________________________________________________
2565
2566
2567Int_t AliTRDtracker::AliTRDtrackingSector::GetLayerNumber(Double_t x) const
2568{
2569 //
2570 // Returns the number of time bin which in radial position is closest to <x>
2571 //
2572
2573 if(x >= fLayers[fN-1]->GetX()) return fN-1;
2574 if(x <= fLayers[0]->GetX()) return 0;
2575
2576 Int_t b=0, e=fN-1, m=(b+e)/2;
2577 for (; b<e; m=(b+e)/2) {
2578 if (x > fLayers[m]->GetX()) b=m+1;
2579 else e=m;
2580 }
2581 if(TMath::Abs(x - fLayers[m]->GetX()) >
2582 TMath::Abs(x - fLayers[m+1]->GetX())) return m+1;
2583 else return m;
2584
2585}
2586
2587//______________________________________________________
2588
2589Int_t AliTRDtracker::AliTRDtrackingSector::GetInnerTimeBin() const
2590{
2591 //
2592 // Returns number of the innermost SENSITIVE propagation layer
2593 //
2594
2595 return GetLayerNumber(0);
2596}
2597
2598//______________________________________________________
2599
2600Int_t AliTRDtracker::AliTRDtrackingSector::GetOuterTimeBin() const
2601{
2602 //
2603 // Returns number of the outermost SENSITIVE time bin
2604 //
2605
2606 return GetLayerNumber(GetNumberOfTimeBins() - 1);
46d29e70 2607}
2608
5443e65e 2609//______________________________________________________
2610
2611Int_t AliTRDtracker::AliTRDtrackingSector::GetNumberOfTimeBins() const
2612{
2613 //
2614 // Returns number of SENSITIVE time bins
2615 //
2616
2617 Int_t tb, layer;
2618 for(tb = kMAX_TIME_BIN_INDEX-1; tb >=0; tb--) {
2619 layer = GetLayerNumber(tb);
2620 if(layer>=0) break;
2621 }
2622 return tb+1;
2623}
2624
2625//______________________________________________________
2626
2627void AliTRDtracker::AliTRDtrackingSector::InsertLayer(AliTRDpropagationLayer* pl)
2628{
2629 //
2630 // Insert layer <pl> in fLayers array.
2631 // Layers are sorted according to X coordinate.
2632
2633 if ( fN == ((Int_t) kMAX_LAYERS_PER_SECTOR)) {
2634 printf("AliTRDtrackingSector::InsertLayer(): Too many layers !\n");
2635 return;
2636 }
2637 if (fN==0) {fLayers[fN++] = pl; return;}
2638 Int_t i=Find(pl->GetX());
2639
2640 memmove(fLayers+i+1 ,fLayers+i,(fN-i)*sizeof(AliTRDpropagationLayer*));
2641 fLayers[i]=pl; fN++;
2642
2643}
2644
2645//______________________________________________________
2646
2647Int_t AliTRDtracker::AliTRDtrackingSector::Find(Double_t x) const
2648{
2649 //
2650 // Returns index of the propagation layer nearest to X
2651 //
2652
2653 if (x <= fLayers[0]->GetX()) return 0;
2654 if (x > fLayers[fN-1]->GetX()) return fN;
2655 Int_t b=0, e=fN-1, m=(b+e)/2;
2656 for (; b<e; m=(b+e)/2) {
2657 if (x > fLayers[m]->GetX()) b=m+1;
2658 else e=m;
2659 }
2660 return m;
2661}
2662
2663//______________________________________________________
2664
2665void AliTRDtracker::AliTRDpropagationLayer::GetPropagationParameters(
b3a5a838 2666 Double_t y, Double_t z, Double_t &dx, Double_t &rho, Double_t &rad_length,
a9814c09 2667 Bool_t &lookForCluster) const
5443e65e 2668{
2669 //
b3a5a838 2670 // Returns radial step <dx>, density <rho>, rad. length <rad_length>,
5443e65e 2671 // and sensitivity <lookForCluster> in point <y,z>
2672 //
2673
2674 dx = fdX;
2675 rho = fRho;
b3a5a838 2676 rad_length = fX0;
5443e65e 2677 lookForCluster = kFALSE;
2678
2679 // check dead regions
2680 if(fTimeBinIndex >= 0) {
2681 for(Int_t ch = 0; ch < (Int_t) kZONES; ch++) {
2682 if(TMath::Abs(z - fZc[ch]) < fZmax[ch])
a9814c09 2683 lookForCluster = kTRUE;
2684 // else { rho = 1.7; rad_length = 33.0; } // G10
5443e65e 2685 }
2686 if(TMath::Abs(y) > fYmax) lookForCluster = kFALSE;
2687 if(!lookForCluster) {
b3a5a838 2688 // rho = 1.7; rad_length = 33.0; // G10
5443e65e 2689 }
2690 }
2691
2692 // check hole
2693 if(fHole && (TMath::Abs(y - fHoleYc) < fHoleYmax) &&
2694 (TMath::Abs(z - fHoleZc) < fHoleZmax)) {
2695 lookForCluster = kFALSE;
2696 rho = fHoleRho;
b3a5a838 2697 rad_length = fHoleX0;
5443e65e 2698 }
2699
2700 return;
2701}
2702
2703//______________________________________________________
2704
2705void AliTRDtracker::AliTRDpropagationLayer::InsertCluster(AliTRDcluster* c,
a9814c09 2706 UInt_t index) {
5443e65e 2707
2708// Insert cluster in cluster array.
2709// Clusters are sorted according to Y coordinate.
2710
2711 if(fTimeBinIndex < 0) {
2712 printf("*** attempt to insert cluster into non-sensitive time bin!\n");
2713 return;
2714 }
2715
2716 if (fN== (Int_t) kMAX_CLUSTER_PER_TIME_BIN) {
2717 printf("AliTRDpropagationLayer::InsertCluster(): Too many clusters !\n");
2718 return;
2719 }
2720 if (fN==0) {fIndex[0]=index; fClusters[fN++]=c; return;}
2721 Int_t i=Find(c->GetY());
2722 memmove(fClusters+i+1 ,fClusters+i,(fN-i)*sizeof(AliTRDcluster*));
2723 memmove(fIndex +i+1 ,fIndex +i,(fN-i)*sizeof(UInt_t));
2724 fIndex[i]=index; fClusters[i]=c; fN++;
2725}
2726
2727//______________________________________________________
2728
2729Int_t AliTRDtracker::AliTRDpropagationLayer::Find(Double_t y) const {
2730
2731// Returns index of the cluster nearest in Y
2732
2733 if (y <= fClusters[0]->GetY()) return 0;
2734 if (y > fClusters[fN-1]->GetY()) return fN;
2735 Int_t b=0, e=fN-1, m=(b+e)/2;
2736 for (; b<e; m=(b+e)/2) {
2737 if (y > fClusters[m]->GetY()) b=m+1;
2738 else e=m;
2739 }
2740 return m;
2741}
2742
fd621f36 2743//---------------------------------------------------------
5443e65e 2744
fd621f36 2745Double_t AliTRDtracker::GetTiltFactor(const AliTRDcluster* c) {
2746//
2747// Returns correction factor for tilted pads geometry
2748//
5443e65e 2749
fd621f36 2750 Double_t h01 = sin(TMath::Pi() / 180.0 * fPar->GetTiltingAngle());
2751 Int_t det = c->GetDetector();
2752 Int_t plane = fGeom->GetPlane(det);
b3a5a838 2753
2754 if((plane == 1) || (plane == 3) || (plane == 5)) h01=-h01;
b8dc2353 2755
2756 if(fNoTilt) h01 = 0;
fd621f36 2757
2758 return h01;
2759}
5443e65e 2760
c630aafd 2761
2762
2763
2764
2765