]>
Commit | Line | Data |
---|---|---|
d88fbf15 | 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 | **************************************************************************/ | |
0e46b9ae | 15 | |
16 | //-----------------------------------------------------------------// | |
17 | // // | |
18 | // AliTOFtracker Class // | |
19 | // Task: Perform association of the ESD tracks to TOF Clusters // | |
20 | // and Update ESD track with associated TOF Cluster parameters // | |
21 | // // | |
22 | //-----------------------------------------------------------------// | |
d88fbf15 | 23 | |
24 | #include <Rtypes.h> | |
0e46b9ae | 25 | |
d88fbf15 | 26 | #include "TClonesArray.h" |
0e46b9ae | 27 | #include "TTree.h" |
d88fbf15 | 28 | #include "TTreeStream.h" |
0e46b9ae | 29 | |
af885e0f | 30 | #include "AliESDEvent.h" |
0e46b9ae | 31 | #include "AliESDtrack.h" |
32 | ||
e0ddb533 | 33 | #include "AliTOFRecoParam.h" |
a533f541 | 34 | #include "AliTOFcalib.h" |
0e46b9ae | 35 | #include "AliTOFcluster.h" |
96f01799 | 36 | #include "AliTOFGeometry.h" |
0e46b9ae | 37 | #include "AliTOFtrackerMI.h" |
38 | #include "AliTOFtrack.h" | |
5c7c93fa | 39 | #include "AliTOFpidESD.h" |
40 | ||
41 | class TGeoManager; | |
0e46b9ae | 42 | |
43 | extern TGeoManager *gGeoManager; | |
d88fbf15 | 44 | |
45 | ClassImp(AliTOFtrackerMI) | |
46 | ||
47 | //_____________________________________________________________________________ | |
e0ddb533 | 48 | AliTOFtrackerMI::AliTOFtrackerMI(): |
49 | fRecoParam(0x0), | |
50 | fGeom(0x0), | |
51 | fPid(0x0), | |
58d8d9a3 | 52 | fN(0), |
53 | fNseeds(0), | |
54 | fNseedsTOF(0), | |
55 | fngoodmatch(0), | |
56 | fnbadmatch(0), | |
57 | fnunmatch(0), | |
58 | fnmatch(0), | |
8dacd1bb | 59 | fR(379.), |
58d8d9a3 | 60 | fTOFHeigth(15.3), |
61 | fdCut(3.), | |
62 | fDx(1.5), | |
63 | fDy(0), | |
64 | fDz(0), | |
b42a5ea1 | 65 | fTracks(new TClonesArray("AliTOFtrack")), |
66 | fSeeds(new TClonesArray("AliESDtrack")), | |
58d8d9a3 | 67 | fDebugStreamer(0x0) |
68 | { | |
d88fbf15 | 69 | //AliTOFtrackerMI main Ctor |
70 | ||
e0ddb533 | 71 | fRecoParam=new AliTOFRecoParam(); |
96f01799 | 72 | fGeom=new AliTOFGeometry(); |
e0ddb533 | 73 | Double_t parPID[2]; |
74 | parPID[0]=fRecoParam->GetTimeResolution(); | |
75 | parPID[1]=fRecoParam->GetTimeNSigma(); | |
76 | fPid=new AliTOFpidESD(parPID); | |
96f01799 | 77 | fDy=AliTOFGeometry::XPad(); |
78 | fDz=AliTOFGeometry::ZPad(); | |
e0ddb533 | 79 | fDebugStreamer = new TTreeSRedirector("TOFdebug.root"); |
d88fbf15 | 80 | } |
81 | //_____________________________________________________________________________ | |
58d8d9a3 | 82 | AliTOFtrackerMI::AliTOFtrackerMI(const AliTOFtrackerMI &t): |
83 | AliTracker(), | |
e0ddb533 | 84 | fRecoParam(0x0), |
58d8d9a3 | 85 | fGeom(0x0), |
e0ddb533 | 86 | fPid(0x0), |
58d8d9a3 | 87 | fN(0), |
88 | fNseeds(0), | |
89 | fNseedsTOF(0), | |
90 | fngoodmatch(0), | |
91 | fnbadmatch(0), | |
92 | fnunmatch(0), | |
93 | fnmatch(0), | |
8dacd1bb | 94 | fR(379.), |
58d8d9a3 | 95 | fTOFHeigth(15.3), |
96 | fdCut(3.), | |
97 | fDx(1.5), | |
98 | fDy(0), | |
99 | fDz(0), | |
b42a5ea1 | 100 | fTracks(new TClonesArray("AliTOFtrack")), |
101 | fSeeds(new TClonesArray("AliESDtrack")), | |
58d8d9a3 | 102 | fDebugStreamer(0x0) |
103 | { | |
d88fbf15 | 104 | //AliTOFtrackerMI copy Ctor |
105 | ||
d88fbf15 | 106 | fNseeds=t.fNseeds; |
107 | fNseedsTOF=t.fNseedsTOF; | |
108 | fngoodmatch=t.fngoodmatch; | |
109 | fnbadmatch=t.fnbadmatch; | |
110 | fnunmatch=t.fnunmatch; | |
111 | fnmatch=t.fnmatch; | |
e0ddb533 | 112 | fRecoParam = t.fRecoParam; |
96f01799 | 113 | fGeom=t.fGeom; |
e0ddb533 | 114 | fPid = t.fPid; |
d88fbf15 | 115 | fR=t.fR; |
116 | fTOFHeigth=t.fTOFHeigth; | |
117 | fdCut=t.fdCut; | |
118 | fDy=t.fDy; | |
119 | fDz=t.fDz; | |
120 | fDx=1.5; | |
121 | fSeeds=t.fSeeds; | |
122 | fTracks=t.fTracks; | |
123 | fN=t.fN; | |
124 | } | |
125 | ||
126 | //_________________________________________________________________________________ | |
7aeeaf38 | 127 | AliTOFtrackerMI& AliTOFtrackerMI::operator=(const AliTOFtrackerMI &t) |
128 | { | |
129 | //AliTOFtrackerMI assignment operator | |
130 | ||
7aeeaf38 | 131 | this->fNseeds=t.fNseeds; |
132 | this->fNseedsTOF=t.fNseedsTOF; | |
133 | this->fngoodmatch=t.fngoodmatch; | |
134 | this->fnbadmatch=t.fnbadmatch; | |
135 | this->fnunmatch=t.fnunmatch; | |
136 | this->fnmatch=t.fnmatch; | |
e0ddb533 | 137 | this->fRecoParam = t.fRecoParam; |
7aeeaf38 | 138 | this->fGeom = t.fGeom; |
e0ddb533 | 139 | this->fPid = t.fPid; |
7aeeaf38 | 140 | this->fR=t.fR; |
141 | this->fTOFHeigth=t.fTOFHeigth; | |
142 | this->fdCut=t.fdCut; | |
143 | this->fDy=t.fDy; | |
144 | this->fDz=t.fDz; | |
145 | this->fDx=t.fDx; | |
146 | this->fSeeds=t.fSeeds; | |
147 | this->fTracks=t.fTracks; | |
148 | this->fN=t.fN; | |
149 | return *this; | |
150 | ||
151 | } | |
152 | ||
153 | //_____________________________________________________________________________ | |
d88fbf15 | 154 | AliTOFtrackerMI::~AliTOFtrackerMI(){ |
155 | // | |
156 | // | |
157 | // | |
158 | if (fDebugStreamer) { | |
159 | //fDebugStreamer->Close(); | |
160 | delete fDebugStreamer; | |
161 | } | |
e0ddb533 | 162 | delete fRecoParam; |
163 | delete fGeom; | |
164 | delete fPid; | |
b42a5ea1 | 165 | if (fTracks){ |
166 | fTracks->Delete(); | |
167 | delete fTracks; | |
168 | fTracks=0x0; | |
169 | } | |
170 | if (fSeeds){ | |
171 | fSeeds->Delete(); | |
172 | delete fSeeds; | |
173 | fSeeds=0x0; | |
174 | } | |
d88fbf15 | 175 | } |
176 | ||
d88fbf15 | 177 | //_____________________________________________________________________________ |
af885e0f | 178 | Int_t AliTOFtrackerMI::PropagateBack(AliESDEvent* event) { |
d88fbf15 | 179 | // |
180 | // Gets seeds from ESD event and Match with TOF Clusters | |
181 | // | |
182 | ||
183 | ||
184 | //Initialise some counters | |
185 | ||
186 | fNseeds=0; | |
187 | fNseedsTOF=0; | |
188 | fngoodmatch=0; | |
189 | fnbadmatch=0; | |
190 | fnunmatch=0; | |
191 | fnmatch=0; | |
192 | ||
193 | Int_t ntrk=event->GetNumberOfTracks(); | |
194 | fNseeds = ntrk; | |
d88fbf15 | 195 | TClonesArray &aESDTrack = *fSeeds; |
196 | ||
197 | ||
198 | //Load ESD tracks into a local Array of ESD Seeds | |
199 | ||
200 | for (Int_t i=0; i<fNseeds; i++) { | |
201 | AliESDtrack *t=event->GetTrack(i); | |
202 | new(aESDTrack[i]) AliESDtrack(*t); | |
203 | } | |
204 | ||
205 | //Prepare ESD tracks candidates for TOF Matching | |
206 | CollectESD(); | |
207 | ||
208 | //First Step with Strict Matching Criterion | |
209 | //MatchTracks(kFALSE); | |
210 | ||
211 | //Second Step with Looser Matching Criterion | |
212 | //MatchTracks(kTRUE); | |
213 | MatchTracksMI(kFALSE); // assign track to clusters | |
214 | MatchTracksMI(kTRUE); // assign clusters to esd | |
215 | ||
216 | Info("PropagateBack","Number of matched tracks: %d",fnmatch); | |
217 | Info("PropagateBack","Number of good matched tracks: %d",fngoodmatch); | |
218 | Info("PropagateBack","Number of bad matched tracks: %d",fnbadmatch); | |
219 | ||
220 | //Update the matched ESD tracks | |
221 | ||
222 | for (Int_t i=0; i<ntrk; i++) { | |
223 | AliESDtrack *t=event->GetTrack(i); | |
224 | AliESDtrack *seed =(AliESDtrack*)fSeeds->UncheckedAt(i); | |
225 | if(seed->GetTOFsignal()>0){ | |
226 | t->SetTOFsignal(seed->GetTOFsignal()); | |
227 | t->SetTOFcluster(seed->GetTOFcluster()); | |
228 | Int_t tlab[3]; | |
229 | seed->GetTOFLabel(tlab); | |
230 | t->SetTOFLabel(tlab); | |
231 | AliTOFtrack *track = new AliTOFtrack(*seed); | |
232 | Float_t info[10]; | |
233 | Double_t times[10]; | |
234 | seed->GetTOFInfo(info); | |
235 | seed->GetIntegratedTimes(times); | |
236 | t->UpdateTrackParams(track,AliESDtrack::kTOFout); | |
237 | t->SetIntegratedLength(seed->GetIntegratedLength()); | |
238 | t->SetIntegratedTimes(times); | |
a533f541 | 239 | t->SetTOFsignalToT(seed->GetTOFsignalToT()); |
240 | t->SetTOFCalChannel(seed->GetTOFCalChannel()); | |
d88fbf15 | 241 | // |
242 | t->SetTOFInfo(info); | |
243 | delete track; | |
244 | } | |
245 | } | |
246 | ||
247 | ||
248 | //Make TOF PID | |
e0ddb533 | 249 | fPid->MakePID(event); |
d88fbf15 | 250 | |
b42a5ea1 | 251 | fSeeds->Clear(); |
252 | fTracks->Clear(); | |
d88fbf15 | 253 | return 0; |
254 | ||
255 | } | |
256 | //_________________________________________________________________________ | |
257 | void AliTOFtrackerMI::CollectESD() { | |
258 | //prepare the set of ESD tracks to be matched to clusters in TOF | |
259 | ||
d88fbf15 | 260 | TClonesArray &aTOFTrack = *fTracks; |
261 | Int_t c0=0; | |
262 | Int_t c1=0; | |
263 | for (Int_t i=0; i<fNseeds; i++) { | |
264 | ||
265 | AliESDtrack *t =(AliESDtrack*)fSeeds->UncheckedAt(i); | |
266 | if ((t->GetStatus()&AliESDtrack::kTPCout)==0)continue; | |
267 | ||
8dacd1bb | 268 | // TRD good tracks, already propagated at 372 cm |
d88fbf15 | 269 | |
270 | AliTOFtrack *track = new AliTOFtrack(*t); // New | |
271 | Double_t x = track->GetX(); //New | |
272 | ||
273 | if (((t->GetStatus()&AliESDtrack::kTRDout)!=0 ) && | |
96f01799 | 274 | ( x >= AliTOFGeometry::RinTOF()) ){ |
d88fbf15 | 275 | track->SetSeedIndex(i); |
276 | t->UpdateTrackParams(track,AliESDtrack::kTOFout); | |
277 | new(aTOFTrack[fNseedsTOF]) AliTOFtrack(*track); | |
278 | fNseedsTOF++; | |
279 | c0++; | |
280 | delete track; | |
281 | } | |
282 | ||
283 | // Propagate the rest of TPCbp | |
284 | ||
285 | else { | |
e0ddb533 | 286 | if(track->PropagateToInnerTOF()){ // temporary solution |
d88fbf15 | 287 | track->SetSeedIndex(i); |
288 | t->UpdateTrackParams(track,AliESDtrack::kTOFout); | |
289 | new(aTOFTrack[fNseedsTOF]) AliTOFtrack(*track); | |
290 | fNseedsTOF++; | |
291 | c1++; | |
292 | } | |
293 | delete track; | |
294 | } | |
295 | } | |
296 | // | |
297 | // | |
298 | printf("TRD\tOn\t%d\tOff\t%d\n",c0,c1); | |
299 | ||
300 | // Sort according uncertainties on track position | |
301 | fTracks->Sort(); | |
302 | ||
303 | } | |
304 | ||
305 | ||
306 | ||
307 | ||
308 | ||
309 | ||
310 | ||
311 | // | |
312 | // | |
313 | //_________________________________________________________________________ | |
314 | void AliTOFtrackerMI::MatchTracks( Bool_t /*mLastStep*/){ | |
315 | return; | |
316 | } | |
317 | // | |
318 | // | |
319 | //_________________________________________________________________________ | |
320 | void AliTOFtrackerMI::MatchTracksMI(Bool_t mLastStep){ | |
321 | ||
322 | //Match ESD tracks to clusters in TOF | |
323 | const Float_t kTofOffset = 26; // time offset | |
324 | const Float_t kMinQuality = -6.; // minimal quality | |
325 | const Float_t kMaxQualityD = 1.; // max delta quality if cluster used | |
326 | const Float_t kForbiddenR = 0.1; // minimal PID according TPC | |
327 | ||
328 | static const Double_t kMasses[]={ | |
329 | 0.000511, 0.105658, 0.139570, 0.493677, 0.938272, 1.875613 | |
330 | }; | |
331 | ||
332 | Int_t nSteps=(Int_t)(fTOFHeigth/0.1); | |
333 | ||
96f01799 | 334 | AliTOFcalib *calib = new AliTOFcalib(); |
a533f541 | 335 | |
d88fbf15 | 336 | //PH Arrays (moved outside of the loop) |
337 | Float_t * trackPos[4]; | |
338 | for (Int_t ii=0; ii<4; ii++) trackPos[ii] = new Float_t[nSteps]; | |
128563f6 | 339 | Int_t * clind = new Int_t[fN]; |
d88fbf15 | 340 | |
341 | // Some init | |
342 | ||
343 | Int_t index[1000]; | |
3c609b5c | 344 | Float_t quality[1000]; |
d88fbf15 | 345 | Float_t dist3D[1000][6]; |
346 | Double_t times[1000][6]; | |
347 | Float_t mintimedist[1000]; | |
348 | Float_t likelihood[1000]; | |
349 | Float_t length[1000]; | |
350 | AliTOFcluster *clusters[1000]; | |
3c609b5c | 351 | Double_t tpcpid[5]; |
d88fbf15 | 352 | dist3D[0][0]=1; |
353 | ||
354 | for (Int_t i=0; i<fNseedsTOF; i++) { | |
355 | ||
356 | AliTOFtrack *track =(AliTOFtrack*)fTracks->UncheckedAt(i); | |
357 | AliESDtrack *t =(AliESDtrack*)fSeeds->UncheckedAt(track->GetSeedIndex()); | |
358 | Bool_t hasTime = ( (t->GetStatus()& AliESDtrack::kTIME)>0) ? kTRUE:kFALSE; // did we integrate time | |
359 | Float_t trdquality = t->GetTRDQuality(); | |
360 | // | |
361 | // Normalize tpc pid | |
362 | // | |
363 | t->GetTPCpid(tpcpid); | |
364 | Double_t sumpid=0; | |
365 | for (Int_t ipid=0;ipid<5;ipid++){ | |
366 | sumpid+=tpcpid[ipid]; | |
367 | } | |
368 | for (Int_t ipid=0;ipid<5;ipid++){ | |
369 | if (sumpid>0) tpcpid[ipid]/=sumpid; | |
370 | else{ | |
371 | tpcpid[ipid]=0.2; | |
372 | } | |
373 | } | |
374 | ||
375 | if (trdquality<0) continue; // no chance | |
376 | // | |
377 | AliTOFtrack *trackTOFin =new AliTOFtrack(*track); | |
378 | // | |
379 | //propagat track to the middle of TOF | |
380 | // | |
8dacd1bb | 381 | Float_t xs = 379.2; // should be defined in the TOF geometry |
96f01799 | 382 | Double_t ymax=xs*TMath::Tan(0.5*AliTOFGeometry::GetAlpha()); |
d3c7bfac | 383 | Bool_t skip=kFALSE; |
d88fbf15 | 384 | Double_t ysect=trackTOFin->GetYat(xs,skip); |
385 | if (skip){ | |
8dacd1bb | 386 | xs = 373.; |
96f01799 | 387 | ymax=xs*TMath::Tan(0.5*AliTOFGeometry::GetAlpha()); |
d88fbf15 | 388 | ysect=trackTOFin->GetYat(xs,skip); |
389 | } | |
390 | if (ysect > ymax) { | |
96f01799 | 391 | if (!trackTOFin->Rotate(AliTOFGeometry::GetAlpha())) { |
d88fbf15 | 392 | continue; |
393 | } | |
394 | } else if (ysect <-ymax) { | |
96f01799 | 395 | if (!trackTOFin->Rotate(-AliTOFGeometry::GetAlpha())) { |
d88fbf15 | 396 | continue; |
397 | } | |
398 | } | |
399 | if(!trackTOFin->PropagateTo(xs)) { | |
400 | continue; | |
401 | } | |
402 | // | |
403 | // Determine a window around the track | |
404 | // | |
405 | Double_t x,par[5]; | |
406 | trackTOFin->GetExternalParameters(x,par); | |
407 | Double_t cov[15]; | |
408 | trackTOFin->GetExternalCovariance(cov); | |
409 | Float_t scalefact=3.; | |
410 | Double_t dphi= | |
411 | scalefact* | |
412 | ((5*TMath::Sqrt(cov[0]) + 3.*fDy +10.*TMath::Abs(par[2]))/fR); | |
413 | Double_t dz= | |
414 | scalefact* | |
415 | (5*TMath::Sqrt(cov[2]) + 3.*fDz +10.*TMath::Abs(par[3])); | |
416 | ||
417 | Double_t phi=TMath::ATan2(par[0],x) + trackTOFin->GetAlpha(); | |
418 | if (phi<-TMath::Pi())phi+=2*TMath::Pi(); | |
419 | if (phi>=TMath::Pi())phi-=2*TMath::Pi(); | |
420 | Double_t z=par[1]; | |
421 | ||
422 | Int_t nc =0; | |
423 | Int_t nfound =0; | |
424 | // find the clusters in the window of the track | |
425 | ||
426 | for (Int_t k=FindClusterIndex(z-dz); k<fN; k++) { | |
427 | AliTOFcluster *c=fClusters[k]; | |
428 | if (c->GetZ() > z+dz) break; | |
429 | // if (c->IsUsed()) continue; | |
430 | ||
431 | Double_t dph=TMath::Abs(c->GetPhi()-phi); | |
432 | if (dph>TMath::Pi()) dph-=2.*TMath::Pi(); | |
433 | if (TMath::Abs(dph)>dphi) continue; | |
3c609b5c | 434 | |
128563f6 | 435 | clind[nc] = k; |
d88fbf15 | 436 | nc++; |
437 | } | |
438 | ||
439 | // | |
440 | // select close clusters | |
441 | // | |
442 | Double_t mom=t->GetP(); | |
443 | // Bool_t dump = kTRUE; | |
444 | for (Int_t icl=0; icl<nc; icl++){ | |
445 | Float_t distances[5]; | |
446 | if (nfound>=1000) break; | |
128563f6 | 447 | index[nfound]=clind[icl]; |
448 | AliTOFcluster *cluster = fClusters[clind[icl]]; | |
d88fbf15 | 449 | GetLinearDistances(trackTOFin,cluster, distances); |
450 | dist3D[nfound][0] = distances[4]; | |
451 | dist3D[nfound][1] = distances[1]; | |
452 | dist3D[nfound][2] = distances[2]; | |
453 | // cut on distance | |
454 | if (TMath::Abs(dist3D[nfound][1])>20 || TMath::Abs(dist3D[nfound][2])>20) continue; | |
455 | // | |
456 | GetLikelihood(distances[1],distances[2],cov,trackTOFin, dist3D[nfound][3], dist3D[nfound][4]); | |
457 | // | |
458 | // cut on likelihood | |
459 | if (dist3D[nfound][3]*dist3D[nfound][4]<0.00000000000001) continue; // log likelihood | |
460 | if (TMath::Log(dist3D[nfound][3]*dist3D[nfound][4])<-9) continue; // log likelihood | |
461 | // | |
462 | clusters[nfound] = cluster; | |
463 | // | |
464 | //length and TOF updates | |
465 | trackTOFin->GetIntegratedTimes(times[nfound]); | |
466 | length[nfound] = trackTOFin->GetIntegratedLength(); | |
467 | length[nfound]+=distances[4]; | |
468 | mintimedist[nfound]=1000; | |
96f01799 | 469 | Double_t tof2=AliTOFGeometry::TdcBinWidth()*cluster->GetTDC()+kTofOffset; // in ps |
d88fbf15 | 470 | // Float_t tgamma = TMath::Sqrt(cluster->GetR()*cluster->GetR()+cluster->GetZ()*cluster->GetZ())/0.03; //time for "primary" gamma |
471 | //if (trackTOFin->GetPt()<0.7 && TMath::Abs(tgamma-tof2)<350) continue; // gamma conversion candidate - TEMPORARY | |
472 | for(Int_t j=0;j<=5;j++){ | |
473 | Double_t mass=kMasses[j]; | |
474 | times[nfound][j]+=distances[4]/3e-2*TMath::Sqrt(mom*mom+mass*mass)/mom; // add time distance | |
475 | if ( TMath::Abs(times[nfound][j]-tof2)<mintimedist[nfound] && tpcpid[j]>kForbiddenR){ | |
476 | mintimedist[nfound]=TMath::Abs(times[nfound][j]-tof2); | |
477 | } | |
478 | } | |
479 | // | |
480 | Float_t liketime = TMath::Exp(-mintimedist[nfound]/90.)+0.25*TMath::Exp(-mintimedist[nfound]/180.); | |
481 | if (!hasTime) liketime=0.2; | |
482 | likelihood[nfound] = TMath::Log(dist3D[nfound][3]*dist3D[nfound][4]*liketime); | |
483 | ||
484 | if (TMath::Log(dist3D[nfound][3]*dist3D[nfound][4])<-1){ | |
485 | if (likelihood[nfound]<-9.) continue; | |
486 | } | |
487 | // | |
488 | nfound++; | |
489 | } | |
490 | if (nfound == 0 ) { | |
491 | fnunmatch++; | |
492 | delete trackTOFin; | |
493 | continue; | |
494 | } | |
495 | // | |
496 | //choose the best cluster | |
497 | // | |
3c609b5c | 498 | //Float_t quality[1000]; |
499 | //Int_t index[1000]; | |
500 | for (Int_t kk=0; kk<1000; kk++) quality[kk]=0; | |
d88fbf15 | 501 | // |
502 | AliTOFcluster * cgold=0; | |
503 | Int_t igold =-1; | |
504 | for (Int_t icl=0;icl<nfound;icl++){ | |
505 | quality[icl] = dist3D[icl][3]*dist3D[icl][4]; | |
506 | } | |
507 | TMath::Sort(nfound,quality,index,kTRUE); | |
508 | igold = index[0]; | |
509 | cgold = clusters[igold]; | |
510 | if (nfound>1 &&likelihood[index[1]]>likelihood[index[0]]){ | |
511 | if ( quality[index[0]]<quality[index[1]]+0.5){ | |
512 | igold = index[1]; | |
513 | cgold = clusters[igold]; | |
514 | } | |
515 | } | |
516 | // | |
517 | // | |
518 | Float_t qualityGold = TMath::Log(0.0000001+(quality[igold]*(0.1+TMath::Exp(-mintimedist[igold]/80.))*(0.2+trdquality))); | |
519 | if (!mLastStep){ | |
520 | if (cgold->GetQuality()<qualityGold) cgold->SetQuality(qualityGold); | |
521 | continue; | |
522 | } | |
523 | // | |
524 | if (mLastStep){ | |
525 | //signed better cluster | |
526 | if (cgold->GetQuality()>qualityGold+kMaxQualityD) continue; | |
527 | if (2.*qualityGold-cgold->GetQuality()<kMinQuality) continue; | |
528 | } | |
529 | ||
530 | Int_t inonfake=-1; | |
531 | ||
532 | for (Int_t icl=0;icl<nfound;icl++){ | |
533 | if ( | |
534 | (clusters[index[icl]]->GetLabel(0)==TMath::Abs(trackTOFin->GetLabel())) | |
535 | || | |
536 | (clusters[index[icl]]->GetLabel(1)==TMath::Abs(trackTOFin->GetLabel())) | |
537 | || | |
538 | (clusters[index[icl]]->GetLabel(2)==TMath::Abs(trackTOFin->GetLabel())) | |
539 | ) { | |
540 | inonfake = icl; | |
541 | break; | |
542 | } | |
543 | } | |
544 | fnmatch++;; | |
545 | if (inonfake==0) fngoodmatch++; | |
546 | else{ | |
547 | fnbadmatch++; | |
548 | } | |
549 | ||
550 | Int_t tlab[3]; | |
551 | tlab[0]=cgold->GetLabel(0); | |
552 | tlab[1]=cgold->GetLabel(1); | |
553 | tlab[2]=cgold->GetLabel(2); | |
554 | // Double_t tof2=25.*cgold->GetTDC()-350; // in ps | |
96f01799 | 555 | Double_t tof2=AliTOFGeometry::TdcBinWidth()*cgold->GetTDC()+kTofOffset; // in ps |
d88fbf15 | 556 | Float_t tgamma = TMath::Sqrt(cgold->GetR()*cgold->GetR()+cgold->GetZ()*cgold->GetZ())/0.03; |
557 | Float_t info[11]={dist3D[igold][0],dist3D[igold][1],dist3D[igold][2],dist3D[igold][3],dist3D[igold][4],mintimedist[igold], | |
558 | -1,tgamma, qualityGold,cgold->GetQuality(),0}; | |
559 | // GetLinearDistances(trackTOFin,cgold,&info[6]); | |
560 | if (inonfake>=0){ | |
561 | info[6] = inonfake; | |
562 | // info[7] = mintimedist[index[inonfake]]; | |
563 | } | |
564 | // | |
a533f541 | 565 | // Store quantities to be used for TOF Calibration |
7aeeaf38 | 566 | Float_t tToT=cgold->GetToT(); // in ps |
567 | t->SetTOFsignalToT(tToT); | |
a533f541 | 568 | Int_t ind[5]; |
569 | ind[0]=cgold->GetDetInd(0); | |
570 | ind[1]=cgold->GetDetInd(1); | |
571 | ind[2]=cgold->GetDetInd(2); | |
572 | ind[3]=cgold->GetDetInd(3); | |
573 | ind[4]=cgold->GetDetInd(4); | |
96f01799 | 574 | Int_t calindex = AliTOFGeometry::GetIndex(ind); |
a533f541 | 575 | t->SetTOFCalChannel(calindex); |
576 | ||
d88fbf15 | 577 | t->SetTOFInfo(info); |
578 | t->SetTOFsignal(tof2); | |
579 | t->SetTOFcluster(cgold->GetIndex()); | |
580 | AliTOFtrack *trackTOFout = new AliTOFtrack(*t); | |
8dacd1bb | 581 | trackTOFout->PropagateTo(379.); |
d88fbf15 | 582 | t->UpdateTrackParams(trackTOFout,AliESDtrack::kTOFout); |
583 | t->SetIntegratedLength(length[igold]); | |
584 | t->SetIntegratedTimes(times[igold]); | |
585 | t->SetTOFLabel(tlab); | |
586 | // | |
587 | delete trackTOFin; | |
588 | delete trackTOFout; | |
589 | // | |
590 | } | |
591 | // | |
592 | // | |
593 | // | |
594 | for (Int_t ii=0; ii<4; ii++) delete [] trackPos[ii]; | |
128563f6 | 595 | delete [] clind; |
a533f541 | 596 | delete calib; |
d88fbf15 | 597 | } |
d88fbf15 | 598 | //_________________________________________________________________________ |
128563f6 | 599 | |
d88fbf15 | 600 | Int_t AliTOFtrackerMI::LoadClusters(TTree *cTree) { |
601 | //-------------------------------------------------------------------- | |
602 | //This function loads the TOF clusters | |
603 | //-------------------------------------------------------------------- | |
604 | ||
605 | TBranch *branch=cTree->GetBranch("TOF"); | |
606 | if (!branch) { | |
607 | AliError("can't get the branch with the TOF clusters !"); | |
608 | return 1; | |
609 | } | |
610 | ||
b42a5ea1 | 611 | static TClonesArray dummy("AliTOFcluster",10000); |
612 | dummy.Clear(); | |
613 | TClonesArray *clusters=&dummy; | |
d88fbf15 | 614 | branch->SetAddress(&clusters); |
615 | ||
616 | cTree->GetEvent(0); | |
617 | Int_t nc=clusters->GetEntriesFast(); | |
618 | AliInfo(Form("Number of clusters: %d",nc)); | |
619 | ||
620 | for (Int_t i=0; i<nc; i++) { | |
621 | AliTOFcluster *c=(AliTOFcluster*)clusters->UncheckedAt(i); | |
d88fbf15 | 622 | |
d88fbf15 | 623 | fClusters[i]=new AliTOFcluster(*c); fN++; |
624 | ||
625 | //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))); | |
626 | //AliInfo(Form("%i %f",i, fClusters[i]->GetZ())); | |
627 | } | |
628 | ||
629 | //AliInfo(Form("Number of clusters: %d",fN)); | |
630 | ||
631 | return 0; | |
632 | } | |
633 | //_________________________________________________________________________ | |
634 | void AliTOFtrackerMI::UnloadClusters() { | |
635 | //-------------------------------------------------------------------- | |
636 | //This function unloads TOF clusters | |
637 | //-------------------------------------------------------------------- | |
638 | for (Int_t i=0; i<fN; i++) { | |
639 | delete fClusters[i]; | |
640 | fClusters[i] = 0x0; | |
641 | } | |
642 | fN=0; | |
643 | } | |
644 | ||
645 | ||
646 | ||
647 | ||
648 | //_________________________________________________________________________ | |
649 | Int_t AliTOFtrackerMI::InsertCluster(AliTOFcluster *c) { | |
650 | //-------------------------------------------------------------------- | |
651 | //This function adds a cluster to the array of clusters sorted in Z | |
652 | //-------------------------------------------------------------------- | |
653 | if (fN==kMaxCluster) { | |
0e46b9ae | 654 | AliError("Too many clusters !"); |
d88fbf15 | 655 | return 1; |
656 | } | |
657 | ||
658 | if (fN==0) {fClusters[fN++]=c; return 0;} | |
659 | Int_t i=FindClusterIndex(c->GetZ()); | |
660 | memmove(fClusters+i+1 ,fClusters+i,(fN-i)*sizeof(AliTOFcluster*)); | |
661 | fClusters[i]=c; fN++; | |
662 | ||
663 | return 0; | |
664 | } | |
665 | ||
666 | //_________________________________________________________________________ | |
667 | Int_t AliTOFtrackerMI::FindClusterIndex(Double_t z) const { | |
668 | //-------------------------------------------------------------------- | |
669 | // This function returns the index of the nearest cluster | |
670 | //-------------------------------------------------------------------- | |
671 | if (fN==0) return 0; | |
672 | if (z <= fClusters[0]->GetZ()) return 0; | |
673 | if (z > fClusters[fN-1]->GetZ()) return fN; | |
674 | Int_t b=0, e=fN-1, m=(b+e)/2; | |
675 | for (; b<e; m=(b+e)/2) { | |
676 | if (z > fClusters[m]->GetZ()) b=m+1; | |
677 | else e=m; | |
678 | } | |
679 | return m; | |
680 | } | |
681 | ||
682 | ||
683 | ||
684 | Float_t AliTOFtrackerMI::GetLinearDistances(AliTOFtrack * track, AliTOFcluster *cluster, Float_t distances[5]) | |
685 | { | |
686 | // | |
687 | // calclates distance between cluster and track | |
688 | // use linear aproximation | |
689 | // | |
690 | const Float_t kRaddeg = 180/3.14159265358979312; | |
691 | // | |
692 | // Float_t tiltangle = fGeom->GetAngles(cluster->fdetIndex[1],cluster->fdetIndex[2])/kRaddeg; //tiltangle | |
693 | Int_t cind[5]; | |
694 | cind[0]= cluster->GetDetInd(0); | |
695 | cind[1]= cluster->GetDetInd(1); | |
696 | cind[2]= cluster->GetDetInd(2); | |
697 | cind[3]= cluster->GetDetInd(3); | |
698 | cind[4]= cluster->GetDetInd(4); | |
96f01799 | 699 | Float_t tiltangle = AliTOFGeometry::GetAngles(cluster->GetDetInd(1),cluster->GetDetInd(2))/kRaddeg; //tiltangle |
d88fbf15 | 700 | |
701 | Float_t cpos[3]; //cluster position | |
702 | Float_t cpos0[3]; //cluster position | |
703 | // fGeom->GetPos(cluster->fdetIndex,cpos); | |
704 | //fGeom->GetPos(cluster->fdetIndex,cpos0); | |
705 | // | |
706 | fGeom->GetPos(cind,cpos); | |
707 | fGeom->GetPos(cind,cpos0); | |
708 | ||
709 | Float_t phi = TMath::ATan2(cpos[1],cpos[0]); | |
710 | if(phi<0) phi=2.*TMath::Pi()+phi; | |
711 | // Get the local angle in the sector philoc | |
712 | Float_t phiangle = (Int_t (phi*kRaddeg/20.) + 0.5)*20./kRaddeg; | |
713 | // | |
714 | Double_t v0[3]; | |
715 | Double_t dir[3]; | |
6c94f330 | 716 | track->GetXYZ(v0); |
717 | track->GetPxPyPz(dir); | |
d88fbf15 | 718 | dir[0]/=track->GetP(); |
719 | dir[1]/=track->GetP(); | |
720 | dir[2]/=track->GetP(); | |
721 | // | |
722 | // | |
723 | //rotate 0 | |
724 | Float_t sinphi = TMath::Sin(phiangle); | |
725 | Float_t cosphi = TMath::Cos(phiangle); | |
726 | Float_t sinth = TMath::Sin(tiltangle); | |
727 | Float_t costh = TMath::Cos(tiltangle); | |
728 | // | |
729 | Float_t temp; | |
730 | temp = cpos[0]*cosphi+cpos[1]*sinphi; | |
731 | cpos[1] = -cpos[0]*sinphi+cpos[1]*cosphi; | |
732 | cpos[0] = temp; | |
733 | temp = v0[0]*cosphi+v0[1]*sinphi; | |
734 | v0[1] = -v0[0]*sinphi+v0[1]*cosphi; | |
735 | v0[0] = temp; | |
736 | // | |
737 | temp = cpos[0]*costh+cpos[2]*sinth; | |
738 | cpos[2] = -cpos[0]*sinth+cpos[2]*costh; | |
739 | cpos[0] = temp; | |
740 | temp = v0[0]*costh+v0[2]*sinth; | |
741 | v0[2] = -v0[0]*sinth+v0[2]*costh; | |
742 | v0[0] = temp; | |
743 | // | |
744 | // | |
745 | //rotate direction vector | |
746 | // | |
747 | temp = dir[0]*cosphi+dir[1]*sinphi; | |
748 | dir[1] = -dir[0]*sinphi+dir[1]*cosphi; | |
749 | dir[0] = temp; | |
750 | // | |
751 | temp = dir[0]*costh+dir[2]*sinth; | |
752 | dir[2] = -dir[0]*sinth+dir[2]*costh; | |
753 | dir[0] = temp; | |
754 | // | |
755 | Float_t v3[3]; | |
756 | Float_t k = (cpos[0]-v0[0])/dir[0]; | |
757 | v3[0] = v0[0]+k*dir[0]; | |
758 | v3[1] = v0[1]+k*dir[1]; | |
759 | v3[2] = v0[2]+k*dir[2]; | |
760 | // | |
761 | distances[0] = v3[0]-cpos[0]; | |
762 | distances[1] = v3[1]-cpos[1]; | |
763 | distances[2] = v3[2]-cpos[2]; | |
764 | distances[3] = TMath::Sqrt( distances[0]*distances[0]+distances[1]*distances[1]+distances[2]*distances[2]); //distance | |
765 | distances[4] = k; //length | |
766 | ||
767 | // | |
768 | // Debuging part of the matching | |
769 | // | |
770 | if (track->GetLabel()==cluster->GetLabel(0) ||track->GetLabel()==cluster->GetLabel(1) ){ | |
771 | TTreeSRedirector& cstream = *fDebugStreamer; | |
772 | Float_t tdc = cluster->GetTDC(); | |
773 | cstream<<"Tracks"<< | |
774 | "TOF.="<<track<< | |
775 | "Cx="<<cpos0[0]<< | |
776 | "Cy="<<cpos0[1]<< | |
777 | "Cz="<<cpos0[2]<< | |
778 | "Dist="<<k<< | |
779 | "Dist0="<<distances[0]<< | |
780 | "Dist1="<<distances[1]<< | |
781 | "Dist2="<<distances[2]<< | |
782 | "TDC="<<tdc<< | |
783 | "\n"; | |
784 | } | |
785 | return distances[3]; | |
786 | } | |
787 | ||
788 | ||
789 | ||
790 | void AliTOFtrackerMI::GetLikelihood(Float_t dy, Float_t dz, const Double_t *cov, AliTOFtrack * /*track*/, Float_t & py, Float_t &pz) | |
791 | { | |
792 | // | |
793 | // get likelihood - track covariance taken | |
794 | // 75 % of gauss with expected sigma | |
795 | // 25 % of gauss with extended sigma | |
796 | ||
797 | Double_t kMaxSigmaY = 0.6; // ~ 90% of TRD tracks | |
798 | Double_t kMaxSigmaZ = 1.2; // ~ 90% of TRD tracks | |
799 | Double_t kMeanSigmaY = 0.25; // mean TRD sigma | |
800 | Double_t kMeanSigmaZ = 0.5; // mean TRD sigma | |
801 | ||
802 | ||
803 | Float_t normwidth, normd, p0,p1; | |
804 | Float_t sigmay = TMath::Max(TMath::Sqrt(cov[0]+kMeanSigmaY*kMeanSigmaY),kMaxSigmaY); | |
805 | Float_t sigmaz = TMath::Max(TMath::Sqrt(cov[2]+kMeanSigmaZ*kMeanSigmaZ),kMaxSigmaZ); | |
806 | ||
807 | py=0; | |
808 | pz=0; | |
809 | // | |
810 | // py calculation - 75% admixture of original sigma - 25% tails | |
811 | // | |
812 | normwidth = fDy/sigmay; | |
813 | normd = dy/sigmay; | |
814 | p0 = 0.5*(1+TMath::Erf(normd-normwidth*0.5)); | |
815 | p1 = 0.5*(1+TMath::Erf(normd+normwidth*0.5)); | |
816 | py+= 0.75*(p1-p0); | |
817 | // | |
818 | normwidth = fDy/(3.*sigmay); | |
819 | normd = dy/(3.*sigmay); | |
820 | p0 = 0.5*(1+TMath::Erf(normd-normwidth*0.5)); | |
821 | p1 = 0.5*(1+TMath::Erf(normd+normwidth*0.5)); | |
822 | py+= 0.25*(p1-p0); | |
823 | // | |
824 | // pz calculation - 75% admixture of original sigma - 25% tails | |
825 | // | |
826 | normwidth = fDz/sigmaz; | |
827 | normd = dz/sigmaz; | |
828 | p0 = 0.5*(1+TMath::Erf(normd-normwidth*0.5)); | |
829 | p1 = 0.5*(1+TMath::Erf(normd+normwidth*0.5)); | |
830 | pz+= 0.75*(p1-p0); | |
831 | // | |
832 | normwidth = fDz/(3.*sigmaz); | |
833 | normd = dz/(3.*sigmaz); | |
834 | p0 = 0.5*(1+TMath::Erf(normd-normwidth*0.5)); | |
835 | p1 = 0.5*(1+TMath::Erf(normd+normwidth*0.5)); | |
836 | pz+= 0.25*(p1-p0); | |
837 | } | |
128563f6 | 838 | //_________________________________________________________________________ |
839 | ||
840 | void AliTOFtrackerMI::FillClusterArray(TObjArray* arr) const | |
841 | { | |
842 | // | |
843 | // Returns the TOF cluster array | |
844 | // | |
845 | ||
846 | if (fN==0) | |
847 | arr = 0x0; | |
848 | else | |
849 | for (Int_t i=0; i<fN; ++i) arr->Add(fClusters[i]); | |
850 | ||
851 | } |