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