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