]>
Commit | Line | Data |
---|---|---|
596a855f | 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 | **************************************************************************/ | |
74ea065c | 15 | // AliTOFtracker Class |
16 | // Task: Perform association of the ESD tracks to TOF Clusters | |
17 | // and Update ESD track with associated TOF Cluster parameters | |
18 | // | |
19 | // -- Authors : S. Arcelli, C. Zampolli (Bologna University and INFN) | |
20 | // -- Contacts: Annalisa.De.Caro@cern.ch | |
21 | // -- : Chiara.Zampolli@bo.infn.it | |
22 | // -- : Silvia.Arcelli@bo.infn.it | |
23 | //-------------------------------------------------------------------- | |
596a855f | 24 | |
2871e58d | 25 | #include <Rtypes.h> |
571dda3d | 26 | |
74ea065c | 27 | #include "TClonesArray.h" |
571dda3d | 28 | |
d076c8d5 | 29 | #include "AliLog.h" |
74ea065c | 30 | #include "AliRun.h" |
31 | #include "AliModule.h" | |
596a855f | 32 | |
571dda3d | 33 | #include "AliTOFcluster.h" |
34 | #include "AliTOFtrack.h" | |
35 | #include "AliTOFGeometry.h" | |
36 | #include "AliTOFtracker.h" | |
37 | ||
d4754572 | 38 | |
39 | #include "AliTrackPointArray.h" | |
40 | #include "AliAlignObj.h" | |
41 | ||
596a855f | 42 | ClassImp(AliTOFtracker) |
43 | ||
74ea065c | 44 | //_____________________________________________________________________________ |
45 | AliTOFtracker::AliTOFtracker(AliTOFGeometry * geom, Double_t parPID[2]) { | |
46 | //AliTOFtracker main Ctor | |
47 | ||
d3c7bfac | 48 | //fHoles=true; |
74ea065c | 49 | fNseeds=0; |
50 | fNseedsTOF=0; | |
51 | fngoodmatch=0; | |
52 | fnbadmatch=0; | |
53 | fnunmatch=0; | |
54 | fnmatch=0; | |
55 | fGeom = geom; | |
56 | fTOFpid = new AliTOFpidESD(parPID); | |
57 | fR=378.; | |
58 | fTOFHeigth=15.3; | |
59 | fdCut=3.; | |
60 | fDy=AliTOFGeometry::XPad(); | |
61 | fDz=AliTOFGeometry::ZPad(); | |
62 | fDx=1.5; | |
c0545837 | 63 | fDzMax=35.; |
64 | fDyMax=50.; | |
74ea065c | 65 | fSeeds=0x0; |
66 | fTracks=0x0; | |
67 | fN=0; | |
d3c7bfac | 68 | fHoles = fGeom->GetHoles(); |
74ea065c | 69 | } |
70 | //_____________________________________________________________________________ | |
71 | AliTOFtracker::AliTOFtracker(const AliTOFtracker &t):AliTracker() { | |
72 | //AliTOFtracker copy Ctor | |
73 | ||
74 | fHoles=t.fHoles; | |
75 | fNseeds=t.fNseeds; | |
76 | fNseedsTOF=t.fNseedsTOF; | |
77 | fngoodmatch=t.fngoodmatch; | |
78 | fnbadmatch=t.fnbadmatch; | |
79 | fnunmatch=t.fnunmatch; | |
80 | fnmatch=t.fnmatch; | |
81 | fGeom = t.fGeom; | |
82 | fTOFpid = t.fTOFpid; | |
83 | fR=t.fR; | |
84 | fTOFHeigth=t.fTOFHeigth; | |
85 | fdCut=t.fdCut; | |
86 | fDy=t.fDy; | |
87 | fDz=t.fDz; | |
a6a9820c | 88 | fDx=t.fDx; |
89 | fDzMax=t.fDzMax; | |
90 | fDyMax=t.fDyMax; | |
74ea065c | 91 | fSeeds=t.fSeeds; |
92 | fTracks=t.fTracks; | |
93 | fN=t.fN; | |
94 | } | |
95 | //_____________________________________________________________________________ | |
74ea065c | 96 | Int_t AliTOFtracker::PropagateBack(AliESD* event) { |
97 | // | |
98 | // Gets seeds from ESD event and Match with TOF Clusters | |
99 | // | |
100 | ||
101 | ||
102 | //Initialise some counters | |
103 | ||
104 | fNseeds=0; | |
105 | fNseedsTOF=0; | |
106 | fngoodmatch=0; | |
107 | fnbadmatch=0; | |
108 | fnunmatch=0; | |
109 | fnmatch=0; | |
110 | ||
111 | Int_t ntrk=event->GetNumberOfTracks(); | |
112 | fNseeds = ntrk; | |
7b61cd9c | 113 | fSeeds= new TClonesArray("AliESDtrack",ntrk); |
74ea065c | 114 | TClonesArray &aESDTrack = *fSeeds; |
115 | ||
116 | ||
117 | //Load ESD tracks into a local Array of ESD Seeds | |
118 | ||
119 | for (Int_t i=0; i<fNseeds; i++) { | |
120 | AliESDtrack *t=event->GetTrack(i); | |
121 | new(aESDTrack[i]) AliESDtrack(*t); | |
122 | } | |
123 | ||
124 | //Prepare ESD tracks candidates for TOF Matching | |
125 | CollectESD(); | |
126 | ||
127 | //First Step with Strict Matching Criterion | |
128 | MatchTracks(kFALSE); | |
7b61cd9c | 129 | /* |
130 | for (Int_t ijk=0; ijk<fN; ijk++) { | |
131 | AliInfo(Form("%4i %4i %f %f %f %f %f %2i %1i %2i %1i %2i",ijk, fClusters[ijk]->GetIndex(),fClusters[ijk]->GetZ(),fClusters[ijk]->GetR(),fClusters[ijk]->GetPhi(), fClusters[ijk]->GetTDC(),fClusters[ijk]->GetADC(),fClusters[ijk]->GetDetInd(0),fClusters[ijk]->GetDetInd(1),fClusters[ijk]->GetDetInd(2),fClusters[ijk]->GetDetInd(3),fClusters[ijk]->GetDetInd(4))); | |
132 | } | |
133 | */ | |
74ea065c | 134 | |
135 | //Second Step with Looser Matching Criterion | |
136 | MatchTracks(kTRUE); | |
137 | ||
d076c8d5 | 138 | AliInfo(Form("Number of matched tracks: %d",fnmatch)); |
139 | AliInfo(Form("Number of good matched tracks: %d",fngoodmatch)); | |
140 | AliInfo(Form("Number of bad matched tracks: %d",fnbadmatch)); | |
74ea065c | 141 | |
142 | //Update the matched ESD tracks | |
143 | ||
144 | for (Int_t i=0; i<ntrk; i++) { | |
145 | AliESDtrack *t=event->GetTrack(i); | |
146 | AliESDtrack *seed =(AliESDtrack*)fSeeds->UncheckedAt(i); | |
147 | if(seed->GetTOFsignal()>0){ | |
148 | t->SetTOFsignal(seed->GetTOFsignal()); | |
149 | t->SetTOFcluster(seed->GetTOFcluster()); | |
150 | AliTOFtrack *track = new AliTOFtrack(*seed); | |
151 | t->UpdateTrackParams(track,AliESDtrack::kTOFout); | |
152 | delete track; | |
153 | } | |
154 | } | |
155 | ||
156 | ||
157 | //Make TOF PID | |
158 | fTOFpid->MakePID(event); | |
159 | ||
7bf28302 | 160 | if (fSeeds) { |
161 | fSeeds->Delete(); | |
162 | delete fSeeds; | |
163 | fSeeds = 0x0; | |
164 | } | |
165 | if (fTracks) { | |
166 | fTracks->Delete(); | |
167 | delete fTracks; | |
168 | fTracks = 0x0; | |
169 | } | |
74ea065c | 170 | return 0; |
171 | ||
172 | } | |
173 | //_________________________________________________________________________ | |
174 | void AliTOFtracker::CollectESD() { | |
175 | //prepare the set of ESD tracks to be matched to clusters in TOF | |
176 | ||
177 | fTracks= new TClonesArray("AliTOFtrack"); | |
178 | TClonesArray &aTOFTrack = *fTracks; | |
179 | for (Int_t i=0; i<fNseeds; i++) { | |
180 | ||
181 | AliESDtrack *t =(AliESDtrack*)fSeeds->UncheckedAt(i); | |
182 | if ((t->GetStatus()&AliESDtrack::kTPCout)==0)continue; | |
183 | ||
184 | // TRD good tracks, already propagated at 371 cm | |
185 | ||
56da420e | 186 | AliTOFtrack *track = new AliTOFtrack(*t); // New |
187 | Double_t x = track->GetX(); //New | |
188 | ||
189 | if (((t->GetStatus()&AliESDtrack::kTRDout)!=0 ) && | |
d3c7bfac | 190 | ( x >= fGeom->RinTOF()) ){ |
74ea065c | 191 | track->SetSeedIndex(i); |
192 | t->UpdateTrackParams(track,AliESDtrack::kTOFout); | |
193 | new(aTOFTrack[fNseedsTOF]) AliTOFtrack(*track); | |
194 | fNseedsTOF++; | |
195 | delete track; | |
196 | } | |
197 | ||
198 | // Propagate the rest of TPCbp | |
199 | ||
200 | else { | |
74ea065c | 201 | if(track->PropagateToInnerTOF(fHoles)){ // temporary solution |
202 | // if(track->PropagateToInnerTOF(fGeom->GetHoles())){ | |
203 | track->SetSeedIndex(i); | |
204 | t->UpdateTrackParams(track,AliESDtrack::kTOFout); | |
205 | new(aTOFTrack[fNseedsTOF]) AliTOFtrack(*track); | |
206 | fNseedsTOF++; | |
207 | } | |
208 | delete track; | |
209 | } | |
210 | } | |
211 | ||
7b61cd9c | 212 | AliInfo(Form("Number of TOF seedds %i",fNseedsTOF)); |
213 | ||
74ea065c | 214 | // Sort according uncertainties on track position |
215 | fTracks->Sort(); | |
216 | ||
217 | } | |
218 | //_________________________________________________________________________ | |
219 | void AliTOFtracker::MatchTracks( Bool_t mLastStep){ | |
220 | ||
221 | //Match ESD tracks to clusters in TOF | |
222 | ||
74ea065c | 223 | Int_t nSteps=(Int_t)(fTOFHeigth/0.1); |
7bf28302 | 224 | |
225 | //PH Arrays (moved outside of the loop) | |
226 | Float_t * trackPos[4]; | |
227 | for (Int_t ii=0; ii<4; ii++) trackPos[ii] = new Float_t[nSteps]; | |
228 | Int_t * clind[6]; | |
229 | for (Int_t ii=0;ii<6;ii++) clind[ii] = new Int_t[fN]; | |
74ea065c | 230 | |
c0545837 | 231 | for (Int_t iseed=0; iseed<fNseedsTOF; iseed++) { |
74ea065c | 232 | |
c0545837 | 233 | AliTOFtrack *track =(AliTOFtrack*)fTracks->UncheckedAt(iseed); |
74ea065c | 234 | AliESDtrack *t =(AliESDtrack*)fSeeds->UncheckedAt(track->GetSeedIndex()); |
7bf28302 | 235 | if(t->GetTOFsignal()>0. ) continue; |
74ea065c | 236 | AliTOFtrack *trackTOFin =new AliTOFtrack(*track); |
74ea065c | 237 | |
d3c7bfac | 238 | // Some init |
74ea065c | 239 | |
240 | Int_t index[10000]; | |
241 | Float_t dist[10000]; | |
242 | Float_t cxpos[10000]; | |
243 | Float_t crecL[10000]; | |
c0545837 | 244 | TGeoHMatrix global[1000]; |
74ea065c | 245 | |
246 | // Determine a window around the track | |
247 | ||
248 | Double_t x,par[5]; | |
249 | trackTOFin->GetExternalParameters(x,par); | |
250 | Double_t cov[15]; | |
251 | trackTOFin->GetExternalCovariance(cov); | |
252 | Float_t scalefact=3.; | |
253 | Double_t dphi= | |
254 | scalefact* | |
255 | ((5*TMath::Sqrt(cov[0]) + 0.5*fDy + 2.5*TMath::Abs(par[2]))/fR); | |
256 | Double_t dz= | |
257 | scalefact* | |
258 | (5*TMath::Sqrt(cov[2]) + 0.5*fDz + 2.5*TMath::Abs(par[3])); | |
259 | ||
260 | Double_t phi=TMath::ATan2(par[0],x) + trackTOFin->GetAlpha(); | |
261 | if (phi<-TMath::Pi())phi+=2*TMath::Pi(); | |
262 | if (phi>=TMath::Pi())phi-=2*TMath::Pi(); | |
263 | Double_t z=par[1]; | |
264 | ||
c0545837 | 265 | //upper limit on window's size. |
266 | ||
267 | if(dz> fDzMax) dz=fDzMax; | |
268 | if(dphi*fR>fDyMax) dphi=fDyMax/fR; | |
269 | ||
270 | ||
74ea065c | 271 | Int_t nc=0; |
7b61cd9c | 272 | |
74ea065c | 273 | // find the clusters in the window of the track |
274 | ||
275 | for (Int_t k=FindClusterIndex(z-dz); k<fN; k++) { | |
7b61cd9c | 276 | |
74ea065c | 277 | AliTOFcluster *c=fClusters[k]; |
278 | if (c->GetZ() > z+dz) break; | |
279 | if (c->IsUsed()) continue; | |
280 | ||
7b61cd9c | 281 | //AliInfo(Form(" fClusters[k]->GetZ() (%f) z-dz (%f) %4i ", fClusters[k]->GetZ(), z-dz, k)); |
282 | ||
74ea065c | 283 | Double_t dph=TMath::Abs(c->GetPhi()-phi); |
284 | if (dph>TMath::Pi()) dph-=2.*TMath::Pi(); | |
9b49e4c9 | 285 | if (TMath::Abs(dph)>dphi) continue; |
74ea065c | 286 | |
287 | clind[0][nc] = c->GetDetInd(0); | |
288 | clind[1][nc] = c->GetDetInd(1); | |
289 | clind[2][nc] = c->GetDetInd(2); | |
290 | clind[3][nc] = c->GetDetInd(3); | |
291 | clind[4][nc] = c->GetDetInd(4); | |
292 | clind[5][nc] = k; | |
c0545837 | 293 | Char_t path[100]; |
294 | Int_t ind[5]; | |
295 | ind[0]=clind[0][nc]; | |
296 | ind[1]=clind[1][nc]; | |
297 | ind[2]=clind[2][nc]; | |
298 | ind[3]=clind[3][nc]; | |
299 | ind[4]=clind[4][nc]; | |
300 | fGeom->GetVolumePath(ind,path); | |
301 | gGeoManager->cd(path); | |
302 | global[nc] = *gGeoManager->GetCurrentMatrix(); | |
74ea065c | 303 | nc++; |
304 | } | |
305 | ||
7b61cd9c | 306 | //if (nc) AliInfo(Form("seed for TOF %4i and number of clusters in the track window %4i (cluster index %4i) %4i",i,nc, clind[5][0], fN)); |
307 | ||
74ea065c | 308 | //start fine propagation |
309 | ||
310 | Int_t nStepsDone = 0; | |
311 | for( Int_t istep=0; istep<nSteps; istep++){ | |
312 | ||
d3c7bfac | 313 | Float_t xs=fGeom->RinTOF()+istep*0.1; |
74ea065c | 314 | Double_t ymax=xs*TMath::Tan(0.5*AliTOFGeometry::GetAlpha()); |
315 | ||
316 | Bool_t skip=kFALSE; | |
317 | Double_t ysect=trackTOFin->GetYat(xs,skip); | |
318 | if(skip)break; | |
319 | if (ysect > ymax) { | |
320 | if (!trackTOFin->Rotate(AliTOFGeometry::GetAlpha())) { | |
321 | break; | |
322 | } | |
323 | } else if (ysect <-ymax) { | |
324 | if (!trackTOFin->Rotate(-AliTOFGeometry::GetAlpha())) { | |
325 | break; | |
326 | } | |
327 | } | |
328 | ||
329 | if(!trackTOFin->PropagateTo(xs)) { | |
330 | break; | |
331 | } | |
332 | ||
333 | nStepsDone++; | |
334 | ||
335 | // store the running point (Globalrf) - fine propagation | |
336 | ||
337 | Double_t x,y,z; | |
338 | trackTOFin->GetGlobalXYZ(x,y,z); | |
339 | trackPos[0][istep]= (Float_t) x; | |
340 | trackPos[1][istep]= (Float_t) y; | |
341 | trackPos[2][istep]= (Float_t) z; | |
342 | trackPos[3][istep]= trackTOFin->GetIntegratedLength(); | |
343 | } | |
344 | ||
345 | ||
346 | Int_t nfound = 0; | |
347 | for (Int_t istep=0; istep<nStepsDone; istep++) { | |
348 | ||
349 | Bool_t isInside =kFALSE; | |
350 | Float_t ctrackPos[3]; | |
351 | ||
352 | ctrackPos[0]= trackPos[0][istep]; | |
353 | ctrackPos[1]= trackPos[1][istep]; | |
354 | ctrackPos[2]= trackPos[2][istep]; | |
355 | ||
356 | //now see whether the track matches any of the TOF clusters | |
357 | ||
358 | for (Int_t i=0; i<nc; i++){ | |
359 | Int_t cind[5]; | |
360 | cind[0]= clind[0][i]; | |
361 | cind[1]= clind[1][i]; | |
362 | cind[2]= clind[2][i]; | |
363 | cind[3]= clind[3][i]; | |
364 | cind[4]= clind[4][i]; | |
365 | Bool_t accept = kFALSE; | |
c0545837 | 366 | if( mLastStep)accept = (fGeom->DistanceToPad(cind,global[i],ctrackPos)<fdCut); |
367 | if(!mLastStep)accept = (fGeom->IsInsideThePad(cind,global[i],ctrackPos)); | |
74ea065c | 368 | if(accept){ |
369 | if(!mLastStep)isInside=kTRUE; | |
c0545837 | 370 | dist[nfound]=fGeom->DistanceToPad(cind,global[i],ctrackPos); |
74ea065c | 371 | crecL[nfound]=trackPos[3][istep]; |
372 | index[nfound]=clind[5][i]; // store cluster id | |
d3c7bfac | 373 | cxpos[nfound]=fGeom->RinTOF()+istep*0.1; //store prop.radius |
74ea065c | 374 | nfound++; |
375 | if(isInside)break; | |
376 | }//end if accept | |
377 | } //end for on the clusters | |
9b49e4c9 | 378 | |
379 | ||
74ea065c | 380 | if(isInside)break; |
381 | } //end for on the steps | |
382 | ||
9b49e4c9 | 383 | |
384 | ||
74ea065c | 385 | if (nfound == 0 ) { |
386 | fnunmatch++; | |
7bf28302 | 387 | delete trackTOFin; |
74ea065c | 388 | continue; |
389 | } | |
390 | ||
391 | fnmatch++; | |
392 | ||
393 | // now choose the cluster to be matched with the track. | |
394 | ||
395 | Int_t idclus=0; | |
396 | Float_t recL = 0.; | |
397 | Float_t xpos=0.; | |
398 | Float_t mindist=1000.; | |
399 | for (Int_t iclus= 0; iclus<nfound;iclus++){ | |
400 | if (dist[iclus]< mindist){ | |
401 | mindist = dist[iclus]; | |
402 | xpos = cxpos[iclus]; | |
403 | idclus =index[iclus]; | |
404 | recL=crecL[iclus]+fDx*0.5; | |
405 | } | |
406 | } | |
407 | ||
408 | AliTOFcluster *c=fClusters[idclus]; | |
c0545837 | 409 | c->Use(); //AliInfo(Form("I am using the cluster")); |
74ea065c | 410 | |
411 | // Track length correction for matching Step 2 | |
412 | ||
413 | if(mLastStep){ | |
414 | Float_t rc=TMath::Sqrt(c->GetR()*c->GetR() + c->GetZ()*c->GetZ()); | |
415 | Float_t rt=TMath::Sqrt(trackPos[0][70]*trackPos[0][70] | |
416 | +trackPos[1][70]*trackPos[1][70] | |
417 | +trackPos[2][70]*trackPos[2][70]); | |
418 | Float_t dlt=rc-rt; | |
419 | recL=trackPos[3][70]+dlt; | |
420 | } | |
421 | ||
422 | if ( | |
423 | (c->GetLabel(0)==TMath::Abs(trackTOFin->GetLabel())) | |
424 | || | |
425 | (c->GetLabel(1)==TMath::Abs(trackTOFin->GetLabel())) | |
426 | || | |
427 | (c->GetLabel(2)==TMath::Abs(trackTOFin->GetLabel())) | |
428 | ) { | |
429 | fngoodmatch++; | |
d3c7bfac | 430 | |
431 | //AliInfo(Form(" track label good %5i",trackTOFin->GetLabel())); | |
432 | ||
74ea065c | 433 | } |
434 | else{ | |
435 | fnbadmatch++; | |
d3c7bfac | 436 | |
437 | //AliInfo(Form(" track label bad %5i",trackTOFin->GetLabel())); | |
438 | ||
74ea065c | 439 | } |
440 | ||
441 | delete trackTOFin; | |
442 | ||
43f77f2d | 443 | Double_t tof=AliTOFGeometry::TdcBinWidth()*c->GetTDC()+32; // in ps |
74ea065c | 444 | t->SetTOFsignal(tof); |
ee77ad87 | 445 | //t->SetTOFcluster(c->GetIndex()); // pointing to the digits tree |
446 | t->SetTOFcluster(idclus); // pointing to the recPoints tree | |
74ea065c | 447 | Double_t time[10]; t->GetIntegratedTimes(time); |
448 | Double_t mom=t->GetP(); | |
304864ab | 449 | for(Int_t j=0;j<=AliPID::kSPECIES;j++){ |
450 | Double_t mass=AliPID::ParticleMass(j); | |
74ea065c | 451 | time[j]+=(recL-trackPos[3][0])/3e-2*TMath::Sqrt(mom*mom+mass*mass)/mom; |
452 | } | |
453 | ||
454 | AliTOFtrack *trackTOFout = new AliTOFtrack(*t); | |
455 | trackTOFout->PropagateTo(xpos); | |
456 | t->UpdateTrackParams(trackTOFout,AliESDtrack::kTOFout); | |
457 | t->SetIntegratedLength(recL); | |
458 | t->SetIntegratedTimes(time); | |
459 | ||
460 | delete trackTOFout; | |
461 | } | |
7bf28302 | 462 | for (Int_t ii=0; ii<4; ii++) delete [] trackPos[ii]; |
463 | for (Int_t ii=0;ii<6;ii++) delete [] clind[ii]; | |
74ea065c | 464 | } |
465 | //_________________________________________________________________________ | |
7b61cd9c | 466 | Int_t AliTOFtracker::LoadClusters(TTree *cTree) { |
74ea065c | 467 | //-------------------------------------------------------------------- |
468 | //This function loads the TOF clusters | |
469 | //-------------------------------------------------------------------- | |
470 | ||
7b61cd9c | 471 | TBranch *branch=cTree->GetBranch("TOF"); |
74ea065c | 472 | if (!branch) { |
7b61cd9c | 473 | AliError("can't get the branch with the TOF clusters !"); |
74ea065c | 474 | return 1; |
475 | } | |
476 | ||
7b61cd9c | 477 | TClonesArray dummy("AliTOFcluster",10000), *clusters=&dummy; |
478 | branch->SetAddress(&clusters); | |
74ea065c | 479 | |
7b61cd9c | 480 | cTree->GetEvent(0); |
481 | Int_t nc=clusters->GetEntriesFast(); | |
482 | AliInfo(Form("Number of clusters: %d",nc)); | |
74ea065c | 483 | |
7b61cd9c | 484 | for (Int_t i=0; i<nc; i++) { |
485 | AliTOFcluster *c=(AliTOFcluster*)clusters->UncheckedAt(i); | |
7b61cd9c | 486 | fClusters[i]=new AliTOFcluster(*c); fN++; |
487 | ||
488 | //AliInfo(Form("%4i %4i %f %f %f %f %f %2i %1i %2i %1i %2i",i, fClusters[i]->GetIndex(),fClusters[i]->GetZ(),fClusters[i]->GetR(),fClusters[i]->GetPhi(), fClusters[i]->GetTDC(),fClusters[i]->GetADC(),fClusters[i]->GetDetInd(0),fClusters[i]->GetDetInd(1),fClusters[i]->GetDetInd(2),fClusters[i]->GetDetInd(3),fClusters[i]->GetDetInd(4))); | |
489 | //AliInfo(Form("%i %f",i, fClusters[i]->GetZ())); | |
490 | } | |
74ea065c | 491 | |
7b61cd9c | 492 | //AliInfo(Form("Number of clusters: %d",fN)); |
74ea065c | 493 | |
494 | return 0; | |
495 | } | |
496 | //_________________________________________________________________________ | |
497 | void AliTOFtracker::UnloadClusters() { | |
498 | //-------------------------------------------------------------------- | |
499 | //This function unloads TOF clusters | |
500 | //-------------------------------------------------------------------- | |
7b61cd9c | 501 | for (Int_t i=0; i<fN; i++) { |
502 | delete fClusters[i]; | |
503 | fClusters[i] = 0x0; | |
74ea065c | 504 | } |
7b61cd9c | 505 | fN=0; |
74ea065c | 506 | } |
507 | ||
508 | //_________________________________________________________________________ | |
509 | Int_t AliTOFtracker::FindClusterIndex(Double_t z) const { | |
510 | //-------------------------------------------------------------------- | |
511 | // This function returns the index of the nearest cluster | |
512 | //-------------------------------------------------------------------- | |
513 | if (fN==0) return 0; | |
514 | if (z <= fClusters[0]->GetZ()) return 0; | |
515 | if (z > fClusters[fN-1]->GetZ()) return fN; | |
516 | Int_t b=0, e=fN-1, m=(b+e)/2; | |
517 | for (; b<e; m=(b+e)/2) { | |
518 | if (z > fClusters[m]->GetZ()) b=m+1; | |
519 | else e=m; | |
520 | } | |
521 | return m; | |
522 | } | |
d4754572 | 523 | |
524 | //_________________________________________________________________________ | |
525 | Bool_t AliTOFtracker::GetTrackPoint(Int_t index, AliTrackPoint& p) const | |
526 | { | |
527 | // Get track space point with index i | |
528 | // Coordinates are in the global system | |
529 | AliTOFcluster *cl = fClusters[index]; | |
530 | Float_t xyz[3]; | |
531 | xyz[0] = cl->GetR()*TMath::Cos(cl->GetPhi()); | |
532 | xyz[1] = cl->GetR()*TMath::Sin(cl->GetPhi()); | |
533 | xyz[2] = cl->GetZ(); | |
534 | p.SetXYZ(xyz[0],xyz[1],xyz[2]); | |
535 | ||
536 | // Detector numbering scheme | |
537 | Int_t nSector = fGeom->NSectors(); | |
538 | Int_t nPlate = fGeom->NPlates(); | |
539 | Int_t nStripA = fGeom->NStripA(); | |
540 | Int_t nStripB = fGeom->NStripB(); | |
541 | Int_t nStripC = fGeom->NStripC(); | |
542 | ||
543 | Int_t isector = cl->GetDetInd(0); | |
544 | if (isector >= nSector) | |
545 | AliError(Form("Wrong sector number in TOF (%d) !",isector)); | |
546 | Int_t iplate = cl->GetDetInd(1); | |
547 | if (iplate >= nPlate) | |
548 | AliError(Form("Wrong plate number in TOF (%d) !",iplate)); | |
549 | Int_t istrip = cl->GetDetInd(2); | |
550 | ||
551 | Int_t stripOffset = 0; | |
552 | switch (iplate) { | |
553 | case 0: | |
554 | stripOffset = 0; | |
555 | break; | |
556 | case 1: | |
557 | stripOffset = nStripC; | |
558 | break; | |
559 | case 2: | |
560 | stripOffset = nStripC+nStripB; | |
561 | break; | |
562 | case 3: | |
563 | stripOffset = nStripC+nStripB+nStripA; | |
564 | break; | |
565 | case 4: | |
566 | stripOffset = nStripC+nStripB+nStripA+nStripB; | |
567 | break; | |
568 | default: | |
569 | AliError(Form("Wrong plate number in TOF (%d) !",iplate)); | |
570 | break; | |
571 | }; | |
572 | ||
573 | Int_t idet = (2*(nStripC+nStripB)+nStripA)*isector + | |
574 | stripOffset + | |
575 | istrip; | |
576 | UShort_t volid = AliAlignObj::LayerToVolUID(AliAlignObj::kTOF,idet); | |
577 | p.SetVolumeID((UShort_t)volid); | |
578 | return kTRUE; | |
579 | } |