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