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