]>
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> |
596a855f | 26 | #include "AliTOFtracker.h" |
74ea065c | 27 | #include "AliTOFtrack.h" |
28 | #include "TClonesArray.h" | |
29 | #include "TError.h" | |
30 | #include "AliTOFdigit.h" | |
31 | #include "AliTOFGeometry.h" | |
32 | #include "AliTOF.h" | |
33 | #include "AliRun.h" | |
34 | #include "AliModule.h" | |
596a855f | 35 | |
36 | ClassImp(AliTOFtracker) | |
37 | ||
74ea065c | 38 | //_____________________________________________________________________________ |
39 | AliTOFtracker::AliTOFtracker(AliTOFGeometry * geom, Double_t parPID[2]) { | |
40 | //AliTOFtracker main Ctor | |
41 | ||
42 | fHoles=true; | |
43 | fNseeds=0; | |
44 | fNseedsTOF=0; | |
45 | fngoodmatch=0; | |
46 | fnbadmatch=0; | |
47 | fnunmatch=0; | |
48 | fnmatch=0; | |
49 | fGeom = geom; | |
50 | fTOFpid = new AliTOFpidESD(parPID); | |
51 | fR=378.; | |
52 | fTOFHeigth=15.3; | |
53 | fdCut=3.; | |
54 | fDy=AliTOFGeometry::XPad(); | |
55 | fDz=AliTOFGeometry::ZPad(); | |
56 | fDx=1.5; | |
57 | fSeeds=0x0; | |
58 | fTracks=0x0; | |
59 | fN=0; | |
60 | Init(); // temporary solution to know about Holes/no Holes | |
61 | } | |
62 | //_____________________________________________________________________________ | |
63 | AliTOFtracker::AliTOFtracker(const AliTOFtracker &t):AliTracker() { | |
64 | //AliTOFtracker copy Ctor | |
65 | ||
66 | fHoles=t.fHoles; | |
67 | fNseeds=t.fNseeds; | |
68 | fNseedsTOF=t.fNseedsTOF; | |
69 | fngoodmatch=t.fngoodmatch; | |
70 | fnbadmatch=t.fnbadmatch; | |
71 | fnunmatch=t.fnunmatch; | |
72 | fnmatch=t.fnmatch; | |
73 | fGeom = t.fGeom; | |
74 | fTOFpid = t.fTOFpid; | |
75 | fR=t.fR; | |
76 | fTOFHeigth=t.fTOFHeigth; | |
77 | fdCut=t.fdCut; | |
78 | fDy=t.fDy; | |
79 | fDz=t.fDz; | |
80 | fDx=1.5; | |
81 | fSeeds=t.fSeeds; | |
82 | fTracks=t.fTracks; | |
83 | fN=t.fN; | |
84 | } | |
85 | //_____________________________________________________________________________ | |
86 | void AliTOFtracker::Init() { | |
87 | ||
88 | // temporary solution to know about Holes/no Holes, will be implemented as | |
89 | // an AliTOFGeometry getter | |
90 | ||
91 | AliModule* frame=gAlice->GetModule("FRAME"); | |
92 | ||
93 | if(!frame) { | |
94 | Error("Init","Could Not load FRAME! Assume Frame with Holes \n"); | |
95 | fHoles=true; | |
96 | } else{ | |
97 | if(frame->IsVersion()==1) {fHoles=false;} | |
98 | else {fHoles=true;} | |
99 | } | |
100 | } | |
101 | //_____________________________________________________________________________ | |
102 | Int_t AliTOFtracker::PropagateBack(AliESD* event) { | |
103 | // | |
104 | // Gets seeds from ESD event and Match with TOF Clusters | |
105 | // | |
106 | ||
107 | ||
108 | //Initialise some counters | |
109 | ||
110 | fNseeds=0; | |
111 | fNseedsTOF=0; | |
112 | fngoodmatch=0; | |
113 | fnbadmatch=0; | |
114 | fnunmatch=0; | |
115 | fnmatch=0; | |
116 | ||
117 | Int_t ntrk=event->GetNumberOfTracks(); | |
118 | fNseeds = ntrk; | |
119 | fSeeds= new TClonesArray("AliESDtrack"); | |
120 | TClonesArray &aESDTrack = *fSeeds; | |
121 | ||
122 | ||
123 | //Load ESD tracks into a local Array of ESD Seeds | |
124 | ||
125 | for (Int_t i=0; i<fNseeds; i++) { | |
126 | AliESDtrack *t=event->GetTrack(i); | |
127 | new(aESDTrack[i]) AliESDtrack(*t); | |
128 | } | |
129 | ||
130 | //Prepare ESD tracks candidates for TOF Matching | |
131 | CollectESD(); | |
132 | ||
133 | //First Step with Strict Matching Criterion | |
134 | MatchTracks(kFALSE); | |
135 | ||
136 | //Second Step with Looser Matching Criterion | |
137 | MatchTracks(kTRUE); | |
138 | ||
139 | Info("PropagateBack","Number of matched tracks: %d",fnmatch); | |
140 | Info("PropagateBack","Number of good matched tracks: %d",fngoodmatch); | |
141 | Info("PropagateBack","Number of bad matched tracks: %d",fnbadmatch); | |
142 | ||
143 | //Update the matched ESD tracks | |
144 | ||
145 | for (Int_t i=0; i<ntrk; i++) { | |
146 | AliESDtrack *t=event->GetTrack(i); | |
147 | AliESDtrack *seed =(AliESDtrack*)fSeeds->UncheckedAt(i); | |
148 | if(seed->GetTOFsignal()>0){ | |
149 | t->SetTOFsignal(seed->GetTOFsignal()); | |
150 | t->SetTOFcluster(seed->GetTOFcluster()); | |
151 | AliTOFtrack *track = new AliTOFtrack(*seed); | |
152 | t->UpdateTrackParams(track,AliESDtrack::kTOFout); | |
153 | delete track; | |
154 | } | |
155 | } | |
156 | ||
157 | ||
158 | //Make TOF PID | |
159 | fTOFpid->MakePID(event); | |
160 | ||
7bf28302 | 161 | if (fSeeds) { |
162 | fSeeds->Delete(); | |
163 | delete fSeeds; | |
164 | fSeeds = 0x0; | |
165 | } | |
166 | if (fTracks) { | |
167 | fTracks->Delete(); | |
168 | delete fTracks; | |
169 | fTracks = 0x0; | |
170 | } | |
74ea065c | 171 | return 0; |
172 | ||
173 | } | |
174 | //_________________________________________________________________________ | |
175 | void AliTOFtracker::CollectESD() { | |
176 | //prepare the set of ESD tracks to be matched to clusters in TOF | |
177 | ||
178 | fTracks= new TClonesArray("AliTOFtrack"); | |
179 | TClonesArray &aTOFTrack = *fTracks; | |
180 | for (Int_t i=0; i<fNseeds; i++) { | |
181 | ||
182 | AliESDtrack *t =(AliESDtrack*)fSeeds->UncheckedAt(i); | |
183 | if ((t->GetStatus()&AliESDtrack::kTPCout)==0)continue; | |
184 | ||
185 | // TRD good tracks, already propagated at 371 cm | |
186 | ||
187 | if ( | |
188 | ((t->GetStatus()&AliESDtrack::kTRDout)!=0) && | |
189 | ((t->GetStatus()&AliESDtrack::kTRDStop)==0)){ | |
190 | AliTOFtrack *track = new AliTOFtrack(*t); | |
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 { | |
201 | AliTOFtrack *track = new AliTOFtrack(*t); | |
202 | if(track->PropagateToInnerTOF(fHoles)){ // temporary solution | |
203 | // if(track->PropagateToInnerTOF(fGeom->GetHoles())){ | |
204 | track->SetSeedIndex(i); | |
205 | t->UpdateTrackParams(track,AliESDtrack::kTOFout); | |
206 | new(aTOFTrack[fNseedsTOF]) AliTOFtrack(*track); | |
207 | fNseedsTOF++; | |
208 | } | |
209 | delete track; | |
210 | } | |
211 | } | |
212 | ||
213 | // Sort according uncertainties on track position | |
214 | fTracks->Sort(); | |
215 | ||
216 | } | |
217 | //_________________________________________________________________________ | |
218 | void AliTOFtracker::MatchTracks( Bool_t mLastStep){ | |
219 | ||
220 | //Match ESD tracks to clusters in TOF | |
221 | ||
222 | static const Double_t kMasses[]={ | |
223 | 0.000511, 0.105658, 0.139570, 0.493677, 0.938272, 1.875613 | |
224 | }; | |
225 | ||
226 | Int_t nSteps=(Int_t)(fTOFHeigth/0.1); | |
7bf28302 | 227 | |
228 | //PH Arrays (moved outside of the loop) | |
229 | Float_t * trackPos[4]; | |
230 | for (Int_t ii=0; ii<4; ii++) trackPos[ii] = new Float_t[nSteps]; | |
231 | Int_t * clind[6]; | |
232 | for (Int_t ii=0;ii<6;ii++) clind[ii] = new Int_t[fN]; | |
74ea065c | 233 | |
234 | for (Int_t i=0; i<fNseedsTOF; i++) { | |
235 | ||
236 | AliTOFtrack *track =(AliTOFtrack*)fTracks->UncheckedAt(i); | |
237 | AliESDtrack *t =(AliESDtrack*)fSeeds->UncheckedAt(track->GetSeedIndex()); | |
7bf28302 | 238 | if(t->GetTOFsignal()>0. ) continue; |
74ea065c | 239 | AliTOFtrack *trackTOFin =new AliTOFtrack(*track); |
74ea065c | 240 | |
241 | // Some init | |
242 | ||
243 | Int_t index[10000]; | |
244 | Float_t dist[10000]; | |
245 | Float_t cxpos[10000]; | |
246 | Float_t crecL[10000]; | |
74ea065c | 247 | |
248 | // Determine a window around the track | |
249 | ||
250 | Double_t x,par[5]; | |
251 | trackTOFin->GetExternalParameters(x,par); | |
252 | Double_t cov[15]; | |
253 | trackTOFin->GetExternalCovariance(cov); | |
254 | Float_t scalefact=3.; | |
255 | Double_t dphi= | |
256 | scalefact* | |
257 | ((5*TMath::Sqrt(cov[0]) + 0.5*fDy + 2.5*TMath::Abs(par[2]))/fR); | |
258 | Double_t dz= | |
259 | scalefact* | |
260 | (5*TMath::Sqrt(cov[2]) + 0.5*fDz + 2.5*TMath::Abs(par[3])); | |
261 | ||
262 | Double_t phi=TMath::ATan2(par[0],x) + trackTOFin->GetAlpha(); | |
263 | if (phi<-TMath::Pi())phi+=2*TMath::Pi(); | |
264 | if (phi>=TMath::Pi())phi-=2*TMath::Pi(); | |
265 | Double_t z=par[1]; | |
266 | ||
74ea065c | 267 | Int_t nc=0; |
268 | ||
269 | // find the clusters in the window of the track | |
270 | ||
271 | for (Int_t k=FindClusterIndex(z-dz); k<fN; k++) { | |
272 | AliTOFcluster *c=fClusters[k]; | |
273 | if (c->GetZ() > z+dz) break; | |
274 | if (c->IsUsed()) continue; | |
275 | ||
276 | Double_t dph=TMath::Abs(c->GetPhi()-phi); | |
277 | if (dph>TMath::Pi()) dph-=2.*TMath::Pi(); | |
9b49e4c9 | 278 | if (TMath::Abs(dph)>dphi) continue; |
74ea065c | 279 | |
280 | clind[0][nc] = c->GetDetInd(0); | |
281 | clind[1][nc] = c->GetDetInd(1); | |
282 | clind[2][nc] = c->GetDetInd(2); | |
283 | clind[3][nc] = c->GetDetInd(3); | |
284 | clind[4][nc] = c->GetDetInd(4); | |
285 | clind[5][nc] = k; | |
286 | nc++; | |
287 | } | |
288 | ||
289 | //start fine propagation | |
290 | ||
291 | Int_t nStepsDone = 0; | |
292 | for( Int_t istep=0; istep<nSteps; istep++){ | |
293 | ||
294 | Float_t xs=AliTOFGeometry::RinTOF()+istep*0.1; | |
295 | Double_t ymax=xs*TMath::Tan(0.5*AliTOFGeometry::GetAlpha()); | |
296 | ||
297 | Bool_t skip=kFALSE; | |
298 | Double_t ysect=trackTOFin->GetYat(xs,skip); | |
299 | if(skip)break; | |
300 | if (ysect > ymax) { | |
301 | if (!trackTOFin->Rotate(AliTOFGeometry::GetAlpha())) { | |
302 | break; | |
303 | } | |
304 | } else if (ysect <-ymax) { | |
305 | if (!trackTOFin->Rotate(-AliTOFGeometry::GetAlpha())) { | |
306 | break; | |
307 | } | |
308 | } | |
309 | ||
310 | if(!trackTOFin->PropagateTo(xs)) { | |
311 | break; | |
312 | } | |
313 | ||
314 | nStepsDone++; | |
315 | ||
316 | // store the running point (Globalrf) - fine propagation | |
317 | ||
318 | Double_t x,y,z; | |
319 | trackTOFin->GetGlobalXYZ(x,y,z); | |
320 | trackPos[0][istep]= (Float_t) x; | |
321 | trackPos[1][istep]= (Float_t) y; | |
322 | trackPos[2][istep]= (Float_t) z; | |
323 | trackPos[3][istep]= trackTOFin->GetIntegratedLength(); | |
324 | } | |
325 | ||
326 | ||
327 | Int_t nfound = 0; | |
328 | for (Int_t istep=0; istep<nStepsDone; istep++) { | |
329 | ||
330 | Bool_t isInside =kFALSE; | |
331 | Float_t ctrackPos[3]; | |
332 | ||
333 | ctrackPos[0]= trackPos[0][istep]; | |
334 | ctrackPos[1]= trackPos[1][istep]; | |
335 | ctrackPos[2]= trackPos[2][istep]; | |
336 | ||
337 | //now see whether the track matches any of the TOF clusters | |
338 | ||
339 | for (Int_t i=0; i<nc; i++){ | |
340 | Int_t cind[5]; | |
341 | cind[0]= clind[0][i]; | |
342 | cind[1]= clind[1][i]; | |
343 | cind[2]= clind[2][i]; | |
344 | cind[3]= clind[3][i]; | |
345 | cind[4]= clind[4][i]; | |
346 | Bool_t accept = kFALSE; | |
347 | if( mLastStep)accept = (fGeom->DistanceToPad(cind,ctrackPos)<fdCut); | |
348 | if(!mLastStep)accept = (fGeom->IsInsideThePad(cind,ctrackPos)); | |
349 | if(accept){ | |
350 | if(!mLastStep)isInside=kTRUE; | |
351 | dist[nfound]=fGeom->DistanceToPad(cind,ctrackPos); | |
352 | crecL[nfound]=trackPos[3][istep]; | |
353 | index[nfound]=clind[5][i]; // store cluster id | |
354 | cxpos[nfound]=AliTOFGeometry::RinTOF()+istep*0.1; //store prop.radius | |
355 | nfound++; | |
356 | if(isInside)break; | |
357 | }//end if accept | |
358 | } //end for on the clusters | |
9b49e4c9 | 359 | |
360 | ||
74ea065c | 361 | if(isInside)break; |
362 | } //end for on the steps | |
363 | ||
9b49e4c9 | 364 | |
365 | ||
74ea065c | 366 | if (nfound == 0 ) { |
367 | fnunmatch++; | |
7bf28302 | 368 | delete trackTOFin; |
74ea065c | 369 | continue; |
370 | } | |
371 | ||
372 | fnmatch++; | |
373 | ||
374 | // now choose the cluster to be matched with the track. | |
375 | ||
376 | Int_t idclus=0; | |
377 | Float_t recL = 0.; | |
378 | Float_t xpos=0.; | |
379 | Float_t mindist=1000.; | |
380 | for (Int_t iclus= 0; iclus<nfound;iclus++){ | |
381 | if (dist[iclus]< mindist){ | |
382 | mindist = dist[iclus]; | |
383 | xpos = cxpos[iclus]; | |
384 | idclus =index[iclus]; | |
385 | recL=crecL[iclus]+fDx*0.5; | |
386 | } | |
387 | } | |
388 | ||
389 | AliTOFcluster *c=fClusters[idclus]; | |
390 | c->Use(); | |
391 | ||
392 | // Track length correction for matching Step 2 | |
393 | ||
394 | if(mLastStep){ | |
395 | Float_t rc=TMath::Sqrt(c->GetR()*c->GetR() + c->GetZ()*c->GetZ()); | |
396 | Float_t rt=TMath::Sqrt(trackPos[0][70]*trackPos[0][70] | |
397 | +trackPos[1][70]*trackPos[1][70] | |
398 | +trackPos[2][70]*trackPos[2][70]); | |
399 | Float_t dlt=rc-rt; | |
400 | recL=trackPos[3][70]+dlt; | |
401 | } | |
402 | ||
403 | if ( | |
404 | (c->GetLabel(0)==TMath::Abs(trackTOFin->GetLabel())) | |
405 | || | |
406 | (c->GetLabel(1)==TMath::Abs(trackTOFin->GetLabel())) | |
407 | || | |
408 | (c->GetLabel(2)==TMath::Abs(trackTOFin->GetLabel())) | |
409 | ) { | |
410 | fngoodmatch++; | |
411 | } | |
412 | else{ | |
413 | fnbadmatch++; | |
414 | } | |
415 | ||
416 | delete trackTOFin; | |
417 | ||
418 | Double_t tof=50*c->GetTDC()+32; // in ps | |
419 | t->SetTOFsignal(tof); | |
420 | t->SetTOFcluster(c->GetIndex()); | |
421 | Double_t time[10]; t->GetIntegratedTimes(time); | |
422 | Double_t mom=t->GetP(); | |
423 | for(Int_t j=0;j<=5;j++){ | |
424 | Double_t mass=kMasses[j]; | |
425 | time[j]+=(recL-trackPos[3][0])/3e-2*TMath::Sqrt(mom*mom+mass*mass)/mom; | |
426 | } | |
427 | ||
428 | AliTOFtrack *trackTOFout = new AliTOFtrack(*t); | |
429 | trackTOFout->PropagateTo(xpos); | |
430 | t->UpdateTrackParams(trackTOFout,AliESDtrack::kTOFout); | |
431 | t->SetIntegratedLength(recL); | |
432 | t->SetIntegratedTimes(time); | |
433 | ||
434 | delete trackTOFout; | |
435 | } | |
7bf28302 | 436 | for (Int_t ii=0; ii<4; ii++) delete [] trackPos[ii]; |
437 | for (Int_t ii=0;ii<6;ii++) delete [] clind[ii]; | |
74ea065c | 438 | } |
439 | //_________________________________________________________________________ | |
440 | Int_t AliTOFtracker::LoadClusters(TTree *dTree) { | |
441 | //-------------------------------------------------------------------- | |
442 | //This function loads the TOF clusters | |
443 | //-------------------------------------------------------------------- | |
444 | ||
445 | TBranch *branch=dTree->GetBranch("TOF"); | |
446 | if (!branch) { | |
447 | Error("LoadClusters"," can't get the branch with the TOF digits !\n"); | |
448 | return 1; | |
449 | } | |
450 | ||
451 | TClonesArray dummy("AliTOFdigit",10000), *digits=&dummy; | |
452 | branch->SetAddress(&digits); | |
453 | ||
454 | dTree->GetEvent(0); | |
455 | Int_t nd=digits->GetEntriesFast(); | |
456 | Info("LoadClusters","number of digits: %d",nd); | |
457 | ||
458 | for (Int_t i=0; i<nd; i++) { | |
459 | AliTOFdigit *d=(AliTOFdigit*)digits->UncheckedAt(i); | |
460 | Int_t dig[5]; Float_t g[3]; | |
461 | dig[0]=d->GetSector(); | |
462 | dig[1]=d->GetPlate(); | |
463 | dig[2]=d->GetStrip(); | |
464 | dig[3]=d->GetPadz(); | |
465 | dig[4]=d->GetPadx(); | |
466 | ||
467 | fGeom->GetPos(dig,g); | |
468 | ||
469 | Double_t h[5]; | |
470 | h[0]=TMath::Sqrt(g[0]*g[0]+g[1]*g[1]); | |
471 | h[1]=TMath::ATan2(g[1],g[0]); h[2]=g[2]; | |
472 | h[3]=d->GetTdc(); h[4]=d->GetAdc(); | |
473 | ||
474 | AliTOFcluster *cl=new AliTOFcluster(h,d->GetTracks(),dig,i); | |
475 | InsertCluster(cl); | |
476 | } | |
477 | ||
478 | return 0; | |
479 | } | |
480 | //_________________________________________________________________________ | |
481 | void AliTOFtracker::UnloadClusters() { | |
482 | //-------------------------------------------------------------------- | |
483 | //This function unloads TOF clusters | |
484 | //-------------------------------------------------------------------- | |
485 | for (Int_t i=0; i<fN; i++) delete fClusters[i]; | |
486 | fN=0; | |
487 | } | |
488 | ||
489 | //_________________________________________________________________________ | |
490 | Int_t AliTOFtracker::InsertCluster(AliTOFcluster *c) { | |
491 | //-------------------------------------------------------------------- | |
492 | //This function adds a cluster to the array of clusters sorted in Z | |
493 | //-------------------------------------------------------------------- | |
494 | if (fN==kMaxCluster) { | |
495 | Error("InsertCluster","Too many clusters !\n"); | |
496 | return 1; | |
497 | } | |
498 | ||
499 | if (fN==0) {fClusters[fN++]=c; return 0;} | |
500 | Int_t i=FindClusterIndex(c->GetZ()); | |
501 | memmove(fClusters+i+1 ,fClusters+i,(fN-i)*sizeof(AliTOFcluster*)); | |
502 | fClusters[i]=c; fN++; | |
503 | ||
504 | return 0; | |
505 | } | |
506 | ||
507 | //_________________________________________________________________________ | |
508 | Int_t AliTOFtracker::FindClusterIndex(Double_t z) const { | |
509 | //-------------------------------------------------------------------- | |
510 | // This function returns the index of the nearest cluster | |
511 | //-------------------------------------------------------------------- | |
512 | if (fN==0) return 0; | |
513 | if (z <= fClusters[0]->GetZ()) return 0; | |
514 | if (z > fClusters[fN-1]->GetZ()) return fN; | |
515 | Int_t b=0, e=fN-1, m=(b+e)/2; | |
516 | for (; b<e; m=(b+e)/2) { | |
517 | if (z > fClusters[m]->GetZ()) b=m+1; | |
518 | else e=m; | |
519 | } | |
520 | return m; | |
521 | } | |
522 |