]>
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 | **************************************************************************/ | |
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 | // -- Authors : S. Arcelli, C. Zampolli (Bologna University and INFN) // | |
23 | // -- Contacts: Annalisa.De.Caro@cern.ch // | |
24 | // -- : Chiara.Zampolli@bo.infn.it // | |
25 | // -- : Silvia.Arcelli@bo.infn.it // | |
26 | // // | |
27 | //--------------------------------------------------------------------// | |
28 | ||
08048cd3 | 29 | #include <Rtypes.h> |
30 | #include <TROOT.h> | |
571dda3d | 31 | |
08048cd3 | 32 | #include <TClonesArray.h> |
33 | #include <TGeoManager.h> | |
34 | #include <TTree.h> | |
35 | #include <TFile.h> | |
36 | #include <TH2F.h> | |
571dda3d | 37 | |
0e46b9ae | 38 | #include "AliAlignObj.h" |
39 | #include "AliESDtrack.h" | |
40 | #include "AliESD.h" | |
d076c8d5 | 41 | #include "AliLog.h" |
0e46b9ae | 42 | #include "AliTrackPointArray.h" |
596a855f | 43 | |
0e46b9ae | 44 | #include "AliTOFcalib.h" |
571dda3d | 45 | #include "AliTOFcluster.h" |
571dda3d | 46 | #include "AliTOFGeometry.h" |
47 | #include "AliTOFtracker.h" | |
0e46b9ae | 48 | #include "AliTOFtrack.h" |
571dda3d | 49 | |
0e46b9ae | 50 | extern TGeoManager *gGeoManager; |
d200609f | 51 | extern TROOT *gROOT; |
d4754572 | 52 | |
596a855f | 53 | ClassImp(AliTOFtracker) |
54 | ||
74ea065c | 55 | //_____________________________________________________________________________ |
58d8d9a3 | 56 | AliTOFtracker::AliTOFtracker(AliTOFGeometry * geom, Double_t parPID[2]): |
57 | fGeom(geom), | |
58 | fTOFpid(new AliTOFpidESD(parPID)), | |
59 | fHoles(kFALSE), | |
60 | fN(0), | |
61 | fNseeds(0), | |
62 | fNseedsTOF(0), | |
63 | fngoodmatch(0), | |
64 | fnbadmatch(0), | |
65 | fnunmatch(0), | |
66 | fnmatch(0), | |
67 | fR(378.), | |
68 | fTOFHeigth(15.3), | |
69 | fdCut(3.), | |
70 | fDx(1.5), | |
71 | fDy(0), | |
72 | fDz(0), | |
73 | fDzMax(35.), | |
74 | fDyMax(50.), | |
75 | fTracks(0x0), | |
5664c6ed | 76 | fSeeds(0x0), |
77 | fHDigClusMap(0x0), | |
78 | fHDigNClus(0x0), | |
79 | fHDigClusTime(0x0), | |
80 | fHDigClusToT(0x0), | |
81 | fHRecNClus(0x0), | |
82 | fHRecDist(0x0), | |
83 | fHRecSigYVsP(0x0), | |
84 | fHRecSigZVsP(0x0), | |
85 | fHRecSigYVsPWin(0x0), | |
86 | fHRecSigZVsPWin(0x0), | |
87 | fCalTree(0x0), | |
88 | fIch(-1), | |
89 | fToT(-1.), | |
90 | fTime(-1.), | |
91 | fExpTimePi(-1.), | |
92 | fExpTimeKa(-1.), | |
93 | fExpTimePr(-1.) | |
58d8d9a3 | 94 | { |
74ea065c | 95 | //AliTOFtracker main Ctor |
96 | ||
74ea065c | 97 | fDy=AliTOFGeometry::XPad(); |
98 | fDz=AliTOFGeometry::ZPad(); | |
2869b386 | 99 | InitCheckHists(); |
74ea065c | 100 | } |
101 | //_____________________________________________________________________________ | |
58d8d9a3 | 102 | AliTOFtracker::AliTOFtracker(const AliTOFtracker &t): |
103 | AliTracker(), | |
104 | fGeom(0x0), | |
105 | fTOFpid(0x0), | |
106 | fHoles(kFALSE), | |
107 | fN(0), | |
108 | fNseeds(0), | |
109 | fNseedsTOF(0), | |
110 | fngoodmatch(0), | |
111 | fnbadmatch(0), | |
112 | fnunmatch(0), | |
113 | fnmatch(0), | |
114 | fR(378.), | |
115 | fTOFHeigth(15.3), | |
116 | fdCut(3.), | |
117 | fDx(1.5), | |
118 | fDy(0), | |
119 | fDz(0), | |
120 | fDzMax(35.), | |
121 | fDyMax(50.), | |
122 | fTracks(0x0), | |
5664c6ed | 123 | fSeeds(0x0), |
124 | fHDigClusMap(0x0), | |
125 | fHDigNClus(0x0), | |
126 | fHDigClusTime(0x0), | |
127 | fHDigClusToT(0x0), | |
128 | fHRecNClus(0x0), | |
129 | fHRecDist(0x0), | |
130 | fHRecSigYVsP(0x0), | |
131 | fHRecSigZVsP(0x0), | |
132 | fHRecSigYVsPWin(0x0), | |
133 | fHRecSigZVsPWin(0x0), | |
134 | fCalTree(0x0), | |
135 | fIch(-1), | |
136 | fToT(-1.), | |
137 | fTime(-1.), | |
138 | fExpTimePi(-1.), | |
139 | fExpTimeKa(-1.), | |
140 | fExpTimePr(-1.) | |
58d8d9a3 | 141 | { |
74ea065c | 142 | //AliTOFtracker copy Ctor |
143 | ||
144 | fHoles=t.fHoles; | |
145 | fNseeds=t.fNseeds; | |
146 | fNseedsTOF=t.fNseedsTOF; | |
147 | fngoodmatch=t.fngoodmatch; | |
148 | fnbadmatch=t.fnbadmatch; | |
149 | fnunmatch=t.fnunmatch; | |
150 | fnmatch=t.fnmatch; | |
151 | fGeom = t.fGeom; | |
152 | fTOFpid = t.fTOFpid; | |
153 | fR=t.fR; | |
154 | fTOFHeigth=t.fTOFHeigth; | |
155 | fdCut=t.fdCut; | |
156 | fDy=t.fDy; | |
157 | fDz=t.fDz; | |
a6a9820c | 158 | fDx=t.fDx; |
159 | fDzMax=t.fDzMax; | |
160 | fDyMax=t.fDyMax; | |
74ea065c | 161 | fSeeds=t.fSeeds; |
162 | fTracks=t.fTracks; | |
163 | fN=t.fN; | |
164 | } | |
7aeeaf38 | 165 | |
166 | //_____________________________________________________________________________ | |
167 | AliTOFtracker& AliTOFtracker::operator=(const AliTOFtracker &t) | |
168 | { | |
169 | //AliTOFtracker assignment operator | |
170 | ||
171 | this->fHoles=t.fHoles; | |
172 | this->fNseeds=t.fNseeds; | |
173 | this->fNseedsTOF=t.fNseedsTOF; | |
174 | this->fngoodmatch=t.fngoodmatch; | |
175 | this->fnbadmatch=t.fnbadmatch; | |
176 | this->fnunmatch=t.fnunmatch; | |
177 | this->fnmatch=t.fnmatch; | |
178 | this->fGeom = t.fGeom; | |
179 | this->fTOFpid = t.fTOFpid; | |
180 | this->fR=t.fR; | |
181 | this->fTOFHeigth=t.fTOFHeigth; | |
182 | this->fdCut=t.fdCut; | |
183 | this->fDy=t.fDy; | |
184 | this->fDz=t.fDz; | |
185 | this->fDx=t.fDx; | |
186 | this->fDzMax=t.fDzMax; | |
187 | this->fDyMax=t.fDyMax; | |
188 | this->fSeeds=t.fSeeds; | |
189 | this->fTracks=t.fTracks; | |
190 | this->fN=t.fN; | |
191 | return *this; | |
192 | ||
193 | } | |
5664c6ed | 194 | //_____________________________________________________________________________ |
195 | AliTOFtracker::~AliTOFtracker() { | |
196 | // | |
197 | // Dtor | |
198 | // | |
199 | SaveCheckHists(); | |
200 | delete fTOFpid; | |
201 | delete fHDigClusMap; | |
202 | delete fHDigNClus; | |
203 | delete fHDigClusTime; | |
204 | delete fHDigClusToT; | |
205 | delete fHRecNClus; | |
206 | delete fHRecDist; | |
207 | delete fHRecSigYVsP; | |
208 | delete fHRecSigZVsP; | |
209 | delete fHRecSigYVsPWin; | |
210 | delete fHRecSigZVsPWin; | |
211 | delete fCalTree; | |
212 | } | |
74ea065c | 213 | //_____________________________________________________________________________ |
74ea065c | 214 | Int_t AliTOFtracker::PropagateBack(AliESD* event) { |
215 | // | |
216 | // Gets seeds from ESD event and Match with TOF Clusters | |
217 | // | |
218 | ||
219 | ||
220 | //Initialise some counters | |
221 | ||
222 | fNseeds=0; | |
223 | fNseedsTOF=0; | |
224 | fngoodmatch=0; | |
225 | fnbadmatch=0; | |
226 | fnunmatch=0; | |
227 | fnmatch=0; | |
228 | ||
229 | Int_t ntrk=event->GetNumberOfTracks(); | |
230 | fNseeds = ntrk; | |
7b61cd9c | 231 | fSeeds= new TClonesArray("AliESDtrack",ntrk); |
74ea065c | 232 | TClonesArray &aESDTrack = *fSeeds; |
233 | ||
234 | ||
235 | //Load ESD tracks into a local Array of ESD Seeds | |
236 | ||
237 | for (Int_t i=0; i<fNseeds; i++) { | |
238 | AliESDtrack *t=event->GetTrack(i); | |
239 | new(aESDTrack[i]) AliESDtrack(*t); | |
240 | } | |
241 | ||
242 | //Prepare ESD tracks candidates for TOF Matching | |
243 | CollectESD(); | |
244 | ||
245 | //First Step with Strict Matching Criterion | |
246 | MatchTracks(kFALSE); | |
7b61cd9c | 247 | /* |
248 | for (Int_t ijk=0; ijk<fN; ijk++) { | |
249 | 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))); | |
250 | } | |
251 | */ | |
74ea065c | 252 | |
253 | //Second Step with Looser Matching Criterion | |
254 | MatchTracks(kTRUE); | |
255 | ||
d076c8d5 | 256 | AliInfo(Form("Number of matched tracks: %d",fnmatch)); |
257 | AliInfo(Form("Number of good matched tracks: %d",fngoodmatch)); | |
258 | AliInfo(Form("Number of bad matched tracks: %d",fnbadmatch)); | |
74ea065c | 259 | |
260 | //Update the matched ESD tracks | |
261 | ||
262 | for (Int_t i=0; i<ntrk; i++) { | |
263 | AliESDtrack *t=event->GetTrack(i); | |
264 | AliESDtrack *seed =(AliESDtrack*)fSeeds->UncheckedAt(i); | |
265 | if(seed->GetTOFsignal()>0){ | |
266 | t->SetTOFsignal(seed->GetTOFsignal()); | |
267 | t->SetTOFcluster(seed->GetTOFcluster()); | |
a533f541 | 268 | t->SetTOFsignalToT(seed->GetTOFsignalToT()); |
269 | t->SetTOFCalChannel(seed->GetTOFCalChannel()); | |
11c7ff68 | 270 | Int_t tlab[3]; seed->GetTOFLabel(tlab); |
271 | t->SetTOFLabel(tlab); | |
74ea065c | 272 | AliTOFtrack *track = new AliTOFtrack(*seed); |
a533f541 | 273 | t->UpdateTrackParams(track,AliESDtrack::kTOFout); |
74ea065c | 274 | delete track; |
275 | } | |
276 | } | |
277 | ||
278 | ||
279 | //Make TOF PID | |
280 | fTOFpid->MakePID(event); | |
281 | ||
7bf28302 | 282 | if (fSeeds) { |
283 | fSeeds->Delete(); | |
284 | delete fSeeds; | |
285 | fSeeds = 0x0; | |
286 | } | |
287 | if (fTracks) { | |
288 | fTracks->Delete(); | |
289 | delete fTracks; | |
290 | fTracks = 0x0; | |
291 | } | |
74ea065c | 292 | return 0; |
293 | ||
294 | } | |
295 | //_________________________________________________________________________ | |
296 | void AliTOFtracker::CollectESD() { | |
297 | //prepare the set of ESD tracks to be matched to clusters in TOF | |
298 | ||
299 | fTracks= new TClonesArray("AliTOFtrack"); | |
300 | TClonesArray &aTOFTrack = *fTracks; | |
301 | for (Int_t i=0; i<fNseeds; i++) { | |
302 | ||
303 | AliESDtrack *t =(AliESDtrack*)fSeeds->UncheckedAt(i); | |
304 | if ((t->GetStatus()&AliESDtrack::kTPCout)==0)continue; | |
305 | ||
306 | // TRD good tracks, already propagated at 371 cm | |
307 | ||
56da420e | 308 | AliTOFtrack *track = new AliTOFtrack(*t); // New |
309 | Double_t x = track->GetX(); //New | |
310 | ||
311 | if (((t->GetStatus()&AliESDtrack::kTRDout)!=0 ) && | |
d3c7bfac | 312 | ( x >= fGeom->RinTOF()) ){ |
74ea065c | 313 | track->SetSeedIndex(i); |
314 | t->UpdateTrackParams(track,AliESDtrack::kTOFout); | |
315 | new(aTOFTrack[fNseedsTOF]) AliTOFtrack(*track); | |
316 | fNseedsTOF++; | |
317 | delete track; | |
318 | } | |
319 | ||
320 | // Propagate the rest of TPCbp | |
321 | ||
322 | else { | |
74ea065c | 323 | if(track->PropagateToInnerTOF(fHoles)){ // temporary solution |
324 | // if(track->PropagateToInnerTOF(fGeom->GetHoles())){ | |
325 | track->SetSeedIndex(i); | |
326 | t->UpdateTrackParams(track,AliESDtrack::kTOFout); | |
327 | new(aTOFTrack[fNseedsTOF]) AliTOFtrack(*track); | |
328 | fNseedsTOF++; | |
329 | } | |
330 | delete track; | |
331 | } | |
332 | } | |
333 | ||
7b61cd9c | 334 | AliInfo(Form("Number of TOF seedds %i",fNseedsTOF)); |
335 | ||
74ea065c | 336 | // Sort according uncertainties on track position |
337 | fTracks->Sort(); | |
338 | ||
339 | } | |
340 | //_________________________________________________________________________ | |
341 | void AliTOFtracker::MatchTracks( Bool_t mLastStep){ | |
342 | ||
343 | //Match ESD tracks to clusters in TOF | |
344 | ||
a533f541 | 345 | |
74ea065c | 346 | Int_t nSteps=(Int_t)(fTOFHeigth/0.1); |
7bf28302 | 347 | |
a533f541 | 348 | AliTOFcalib *calib = new AliTOFcalib(fGeom); |
7bf28302 | 349 | //PH Arrays (moved outside of the loop) |
350 | Float_t * trackPos[4]; | |
351 | for (Int_t ii=0; ii<4; ii++) trackPos[ii] = new Float_t[nSteps]; | |
352 | Int_t * clind[6]; | |
353 | for (Int_t ii=0;ii<6;ii++) clind[ii] = new Int_t[fN]; | |
74ea065c | 354 | |
c0545837 | 355 | for (Int_t iseed=0; iseed<fNseedsTOF; iseed++) { |
74ea065c | 356 | |
c0545837 | 357 | AliTOFtrack *track =(AliTOFtrack*)fTracks->UncheckedAt(iseed); |
74ea065c | 358 | AliESDtrack *t =(AliESDtrack*)fSeeds->UncheckedAt(track->GetSeedIndex()); |
7bf28302 | 359 | if(t->GetTOFsignal()>0. ) continue; |
74ea065c | 360 | AliTOFtrack *trackTOFin =new AliTOFtrack(*track); |
74ea065c | 361 | |
d3c7bfac | 362 | // Some init |
74ea065c | 363 | |
364 | Int_t index[10000]; | |
365 | Float_t dist[10000]; | |
366 | Float_t cxpos[10000]; | |
367 | Float_t crecL[10000]; | |
c0545837 | 368 | TGeoHMatrix global[1000]; |
74ea065c | 369 | |
370 | // Determine a window around the track | |
371 | ||
372 | Double_t x,par[5]; | |
373 | trackTOFin->GetExternalParameters(x,par); | |
374 | Double_t cov[15]; | |
375 | trackTOFin->GetExternalCovariance(cov); | |
6c94f330 | 376 | |
74ea065c | 377 | Float_t scalefact=3.; |
378 | Double_t dphi= | |
379 | scalefact* | |
380 | ((5*TMath::Sqrt(cov[0]) + 0.5*fDy + 2.5*TMath::Abs(par[2]))/fR); | |
381 | Double_t dz= | |
382 | scalefact* | |
383 | (5*TMath::Sqrt(cov[2]) + 0.5*fDz + 2.5*TMath::Abs(par[3])); | |
6c94f330 | 384 | |
74ea065c | 385 | Double_t phi=TMath::ATan2(par[0],x) + trackTOFin->GetAlpha(); |
386 | if (phi<-TMath::Pi())phi+=2*TMath::Pi(); | |
387 | if (phi>=TMath::Pi())phi-=2*TMath::Pi(); | |
388 | Double_t z=par[1]; | |
389 | ||
c0545837 | 390 | //upper limit on window's size. |
391 | ||
392 | if(dz> fDzMax) dz=fDzMax; | |
393 | if(dphi*fR>fDyMax) dphi=fDyMax/fR; | |
394 | ||
395 | ||
74ea065c | 396 | Int_t nc=0; |
7b61cd9c | 397 | |
74ea065c | 398 | // find the clusters in the window of the track |
399 | ||
400 | for (Int_t k=FindClusterIndex(z-dz); k<fN; k++) { | |
7b61cd9c | 401 | |
74ea065c | 402 | AliTOFcluster *c=fClusters[k]; |
403 | if (c->GetZ() > z+dz) break; | |
404 | if (c->IsUsed()) continue; | |
11c7ff68 | 405 | |
406 | if (!c->GetStatus()) continue; // skip bad channels as declared in OCDB | |
407 | ||
7b61cd9c | 408 | //AliInfo(Form(" fClusters[k]->GetZ() (%f) z-dz (%f) %4i ", fClusters[k]->GetZ(), z-dz, k)); |
409 | ||
74ea065c | 410 | Double_t dph=TMath::Abs(c->GetPhi()-phi); |
411 | if (dph>TMath::Pi()) dph-=2.*TMath::Pi(); | |
9b49e4c9 | 412 | if (TMath::Abs(dph)>dphi) continue; |
6c94f330 | 413 | |
414 | { | |
3a3ece53 | 415 | //Double_t maxChi2=150.; // "calibration constant". Needs to be tuned. |
6c94f330 | 416 | Double_t yc=(c->GetPhi() - trackTOFin->GetAlpha())*c->GetR(); |
417 | Double_t p[2]={yc, c->GetZ()}; | |
418 | Double_t cov[3]={fDy*fDy/12., 0., fDz*fDz/12.}; | |
419 | if (trackTOFin->AliExternalTrackParam::GetPredictedChi2(p,cov) > 150.) | |
420 | continue; | |
421 | } | |
422 | ||
74ea065c | 423 | clind[0][nc] = c->GetDetInd(0); |
424 | clind[1][nc] = c->GetDetInd(1); | |
425 | clind[2][nc] = c->GetDetInd(2); | |
426 | clind[3][nc] = c->GetDetInd(3); | |
427 | clind[4][nc] = c->GetDetInd(4); | |
428 | clind[5][nc] = k; | |
c0545837 | 429 | Char_t path[100]; |
430 | Int_t ind[5]; | |
431 | ind[0]=clind[0][nc]; | |
432 | ind[1]=clind[1][nc]; | |
433 | ind[2]=clind[2][nc]; | |
434 | ind[3]=clind[3][nc]; | |
435 | ind[4]=clind[4][nc]; | |
436 | fGeom->GetVolumePath(ind,path); | |
437 | gGeoManager->cd(path); | |
438 | global[nc] = *gGeoManager->GetCurrentMatrix(); | |
74ea065c | 439 | nc++; |
440 | } | |
441 | ||
7b61cd9c | 442 | //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)); |
443 | ||
74ea065c | 444 | //start fine propagation |
445 | ||
446 | Int_t nStepsDone = 0; | |
447 | for( Int_t istep=0; istep<nSteps; istep++){ | |
448 | ||
d3c7bfac | 449 | Float_t xs=fGeom->RinTOF()+istep*0.1; |
74ea065c | 450 | Double_t ymax=xs*TMath::Tan(0.5*AliTOFGeometry::GetAlpha()); |
451 | ||
452 | Bool_t skip=kFALSE; | |
453 | Double_t ysect=trackTOFin->GetYat(xs,skip); | |
6c94f330 | 454 | if (skip) break; |
74ea065c | 455 | if (ysect > ymax) { |
456 | if (!trackTOFin->Rotate(AliTOFGeometry::GetAlpha())) { | |
457 | break; | |
458 | } | |
459 | } else if (ysect <-ymax) { | |
460 | if (!trackTOFin->Rotate(-AliTOFGeometry::GetAlpha())) { | |
461 | break; | |
462 | } | |
463 | } | |
464 | ||
465 | if(!trackTOFin->PropagateTo(xs)) { | |
466 | break; | |
467 | } | |
468 | ||
469 | nStepsDone++; | |
470 | ||
471 | // store the running point (Globalrf) - fine propagation | |
472 | ||
6c94f330 | 473 | Double_t r[3]; |
474 | trackTOFin->GetXYZ(r); | |
475 | trackPos[0][istep]= (Float_t) r[0]; | |
476 | trackPos[1][istep]= (Float_t) r[1]; | |
477 | trackPos[2][istep]= (Float_t) r[2]; | |
74ea065c | 478 | trackPos[3][istep]= trackTOFin->GetIntegratedLength(); |
479 | } | |
480 | ||
481 | ||
482 | Int_t nfound = 0; | |
483 | for (Int_t istep=0; istep<nStepsDone; istep++) { | |
484 | ||
485 | Bool_t isInside =kFALSE; | |
486 | Float_t ctrackPos[3]; | |
487 | ||
488 | ctrackPos[0]= trackPos[0][istep]; | |
489 | ctrackPos[1]= trackPos[1][istep]; | |
490 | ctrackPos[2]= trackPos[2][istep]; | |
491 | ||
492 | //now see whether the track matches any of the TOF clusters | |
493 | ||
494 | for (Int_t i=0; i<nc; i++){ | |
495 | Int_t cind[5]; | |
496 | cind[0]= clind[0][i]; | |
497 | cind[1]= clind[1][i]; | |
498 | cind[2]= clind[2][i]; | |
499 | cind[3]= clind[3][i]; | |
500 | cind[4]= clind[4][i]; | |
501 | Bool_t accept = kFALSE; | |
c0545837 | 502 | if( mLastStep)accept = (fGeom->DistanceToPad(cind,global[i],ctrackPos)<fdCut); |
503 | if(!mLastStep)accept = (fGeom->IsInsideThePad(cind,global[i],ctrackPos)); | |
74ea065c | 504 | if(accept){ |
505 | if(!mLastStep)isInside=kTRUE; | |
c0545837 | 506 | dist[nfound]=fGeom->DistanceToPad(cind,global[i],ctrackPos); |
74ea065c | 507 | crecL[nfound]=trackPos[3][istep]; |
508 | index[nfound]=clind[5][i]; // store cluster id | |
d3c7bfac | 509 | cxpos[nfound]=fGeom->RinTOF()+istep*0.1; //store prop.radius |
74ea065c | 510 | nfound++; |
511 | if(isInside)break; | |
512 | }//end if accept | |
513 | } //end for on the clusters | |
9b49e4c9 | 514 | |
515 | ||
74ea065c | 516 | if(isInside)break; |
517 | } //end for on the steps | |
518 | ||
9b49e4c9 | 519 | |
520 | ||
74ea065c | 521 | if (nfound == 0 ) { |
522 | fnunmatch++; | |
7bf28302 | 523 | delete trackTOFin; |
74ea065c | 524 | continue; |
525 | } | |
526 | ||
527 | fnmatch++; | |
528 | ||
529 | // now choose the cluster to be matched with the track. | |
530 | ||
531 | Int_t idclus=0; | |
532 | Float_t recL = 0.; | |
533 | Float_t xpos=0.; | |
534 | Float_t mindist=1000.; | |
535 | for (Int_t iclus= 0; iclus<nfound;iclus++){ | |
536 | if (dist[iclus]< mindist){ | |
537 | mindist = dist[iclus]; | |
538 | xpos = cxpos[iclus]; | |
539 | idclus =index[iclus]; | |
540 | recL=crecL[iclus]+fDx*0.5; | |
541 | } | |
542 | } | |
543 | ||
544 | AliTOFcluster *c=fClusters[idclus]; | |
c0545837 | 545 | c->Use(); //AliInfo(Form("I am using the cluster")); |
74ea065c | 546 | |
547 | // Track length correction for matching Step 2 | |
548 | ||
549 | if(mLastStep){ | |
550 | Float_t rc=TMath::Sqrt(c->GetR()*c->GetR() + c->GetZ()*c->GetZ()); | |
551 | Float_t rt=TMath::Sqrt(trackPos[0][70]*trackPos[0][70] | |
552 | +trackPos[1][70]*trackPos[1][70] | |
553 | +trackPos[2][70]*trackPos[2][70]); | |
554 | Float_t dlt=rc-rt; | |
555 | recL=trackPos[3][70]+dlt; | |
556 | } | |
557 | ||
558 | if ( | |
559 | (c->GetLabel(0)==TMath::Abs(trackTOFin->GetLabel())) | |
560 | || | |
561 | (c->GetLabel(1)==TMath::Abs(trackTOFin->GetLabel())) | |
562 | || | |
563 | (c->GetLabel(2)==TMath::Abs(trackTOFin->GetLabel())) | |
564 | ) { | |
565 | fngoodmatch++; | |
d3c7bfac | 566 | |
567 | //AliInfo(Form(" track label good %5i",trackTOFin->GetLabel())); | |
568 | ||
74ea065c | 569 | } |
570 | else{ | |
571 | fnbadmatch++; | |
d3c7bfac | 572 | |
573 | //AliInfo(Form(" track label bad %5i",trackTOFin->GetLabel())); | |
574 | ||
74ea065c | 575 | } |
576 | ||
577 | delete trackTOFin; | |
578 | ||
a533f541 | 579 | // Store quantities to be used in the TOF Calibration |
5664c6ed | 580 | Float_t tToT=AliTOFGeometry::TdcBinWidth()*c->GetToT()*1E-3; // in ns |
7aeeaf38 | 581 | t->SetTOFsignalToT(tToT); |
a533f541 | 582 | Int_t ind[5]; |
583 | ind[0]=c->GetDetInd(0); | |
584 | ind[1]=c->GetDetInd(1); | |
585 | ind[2]=c->GetDetInd(2); | |
586 | ind[3]=c->GetDetInd(3); | |
587 | ind[4]=c->GetDetInd(4); | |
588 | Int_t calindex = calib->GetIndex(ind); | |
589 | t->SetTOFCalChannel(calindex); | |
11c7ff68 | 590 | |
591 | // keep track of the track labels in the matched cluster | |
592 | Int_t tlab[3]; | |
593 | tlab[0]=c->GetLabel(0); | |
594 | tlab[1]=c->GetLabel(1); | |
595 | tlab[2]=c->GetLabel(2); | |
a533f541 | 596 | |
43f77f2d | 597 | Double_t tof=AliTOFGeometry::TdcBinWidth()*c->GetTDC()+32; // in ps |
74ea065c | 598 | t->SetTOFsignal(tof); |
ee77ad87 | 599 | //t->SetTOFcluster(c->GetIndex()); // pointing to the digits tree |
600 | t->SetTOFcluster(idclus); // pointing to the recPoints tree | |
74ea065c | 601 | Double_t time[10]; t->GetIntegratedTimes(time); |
602 | Double_t mom=t->GetP(); | |
304864ab | 603 | for(Int_t j=0;j<=AliPID::kSPECIES;j++){ |
604 | Double_t mass=AliPID::ParticleMass(j); | |
74ea065c | 605 | time[j]+=(recL-trackPos[3][0])/3e-2*TMath::Sqrt(mom*mom+mass*mass)/mom; |
606 | } | |
607 | ||
608 | AliTOFtrack *trackTOFout = new AliTOFtrack(*t); | |
609 | trackTOFout->PropagateTo(xpos); | |
610 | t->UpdateTrackParams(trackTOFout,AliESDtrack::kTOFout); | |
611 | t->SetIntegratedLength(recL); | |
612 | t->SetIntegratedTimes(time); | |
11c7ff68 | 613 | t->SetTOFLabel(tlab); |
5664c6ed | 614 | // Fill Reco-QA histos for Reconstruction |
615 | fHRecNClus->Fill(nc); | |
616 | fHRecDist->Fill(mindist); | |
617 | fHRecSigYVsP->Fill(mom,TMath::Sqrt(cov[0])); | |
618 | fHRecSigZVsP->Fill(mom,TMath::Sqrt(cov[2])); | |
619 | fHRecSigYVsPWin->Fill(mom,dphi*fR); | |
620 | fHRecSigZVsPWin->Fill(mom,dz); | |
621 | ||
622 | // Fill Tree for on-the-fly offline Calibration | |
623 | ||
624 | if ( !((t->GetStatus() & AliESDtrack::kTIME)==0 )){ | |
625 | Float_t rawtime=AliTOFGeometry::TdcBinWidth()*c->GetTDCRAW()+32; // RAW time,in ps | |
626 | fIch=calindex; | |
627 | fToT=tToT; | |
628 | fTime=rawtime; | |
629 | fExpTimePi=time[2]; | |
630 | fExpTimeKa=time[3]; | |
631 | fExpTimePr=time[4]; | |
632 | fCalTree->Fill(); | |
633 | } | |
74ea065c | 634 | delete trackTOFout; |
635 | } | |
7bf28302 | 636 | for (Int_t ii=0; ii<4; ii++) delete [] trackPos[ii]; |
637 | for (Int_t ii=0;ii<6;ii++) delete [] clind[ii]; | |
a533f541 | 638 | delete calib; |
74ea065c | 639 | } |
640 | //_________________________________________________________________________ | |
7b61cd9c | 641 | Int_t AliTOFtracker::LoadClusters(TTree *cTree) { |
74ea065c | 642 | //-------------------------------------------------------------------- |
643 | //This function loads the TOF clusters | |
644 | //-------------------------------------------------------------------- | |
645 | ||
5664c6ed | 646 | Int_t npadX = fGeom->NpadX(); |
647 | Int_t npadZ = fGeom->NpadZ(); | |
648 | Int_t nStripA = fGeom->NStripA(); | |
649 | Int_t nStripB = fGeom->NStripB(); | |
650 | Int_t nStripC = fGeom->NStripC(); | |
651 | ||
7b61cd9c | 652 | TBranch *branch=cTree->GetBranch("TOF"); |
74ea065c | 653 | if (!branch) { |
7b61cd9c | 654 | AliError("can't get the branch with the TOF clusters !"); |
74ea065c | 655 | return 1; |
656 | } | |
657 | ||
7b61cd9c | 658 | TClonesArray dummy("AliTOFcluster",10000), *clusters=&dummy; |
659 | branch->SetAddress(&clusters); | |
74ea065c | 660 | |
7b61cd9c | 661 | cTree->GetEvent(0); |
662 | Int_t nc=clusters->GetEntriesFast(); | |
5664c6ed | 663 | fHDigNClus->Fill(nc); |
664 | ||
7b61cd9c | 665 | AliInfo(Form("Number of clusters: %d",nc)); |
74ea065c | 666 | |
7b61cd9c | 667 | for (Int_t i=0; i<nc; i++) { |
668 | AliTOFcluster *c=(AliTOFcluster*)clusters->UncheckedAt(i); | |
7b61cd9c | 669 | fClusters[i]=new AliTOFcluster(*c); fN++; |
5664c6ed | 670 | |
671 | // Fill Digits QA histos | |
672 | ||
673 | Int_t isector = c->GetDetInd(0); | |
674 | Int_t iplate = c->GetDetInd(1); | |
675 | Int_t istrip = c->GetDetInd(2); | |
676 | Int_t ipadX = c->GetDetInd(4); | |
677 | Int_t ipadZ = c->GetDetInd(3); | |
678 | ||
679 | Float_t time = (AliTOFGeometry::TdcBinWidth()*c->GetTDC())*1E-3; // in ns | |
680 | Float_t tot = (AliTOFGeometry::TdcBinWidth()*c->GetToT())*1E-3;//in ns | |
681 | ||
682 | Int_t stripOffset = 0; | |
683 | switch (iplate) { | |
684 | case 0: | |
685 | stripOffset = 0; | |
686 | break; | |
687 | case 1: | |
688 | stripOffset = nStripC; | |
689 | break; | |
690 | case 2: | |
691 | stripOffset = nStripC+nStripB; | |
692 | break; | |
693 | case 3: | |
694 | stripOffset = nStripC+nStripB+nStripA; | |
695 | break; | |
696 | case 4: | |
697 | stripOffset = nStripC+nStripB+nStripA+nStripB; | |
698 | break; | |
699 | default: | |
700 | AliError(Form("Wrong plate number in TOF (%d) !",iplate)); | |
701 | break; | |
702 | }; | |
703 | Int_t zindex=npadZ*(istrip+stripOffset)+(ipadZ+1); | |
704 | Int_t phiindex=npadX*isector+ipadX+1; | |
705 | fHDigClusMap->Fill(zindex,phiindex); | |
706 | fHDigClusTime->Fill(time); | |
707 | fHDigClusToT->Fill(tot); | |
708 | ||
7b61cd9c | 709 | //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))); |
710 | //AliInfo(Form("%i %f",i, fClusters[i]->GetZ())); | |
711 | } | |
74ea065c | 712 | |
7b61cd9c | 713 | //AliInfo(Form("Number of clusters: %d",fN)); |
74ea065c | 714 | |
715 | return 0; | |
716 | } | |
717 | //_________________________________________________________________________ | |
718 | void AliTOFtracker::UnloadClusters() { | |
719 | //-------------------------------------------------------------------- | |
720 | //This function unloads TOF clusters | |
721 | //-------------------------------------------------------------------- | |
7b61cd9c | 722 | for (Int_t i=0; i<fN; i++) { |
723 | delete fClusters[i]; | |
724 | fClusters[i] = 0x0; | |
74ea065c | 725 | } |
7b61cd9c | 726 | fN=0; |
74ea065c | 727 | } |
728 | ||
729 | //_________________________________________________________________________ | |
730 | Int_t AliTOFtracker::FindClusterIndex(Double_t z) const { | |
731 | //-------------------------------------------------------------------- | |
732 | // This function returns the index of the nearest cluster | |
733 | //-------------------------------------------------------------------- | |
734 | if (fN==0) return 0; | |
735 | if (z <= fClusters[0]->GetZ()) return 0; | |
736 | if (z > fClusters[fN-1]->GetZ()) return fN; | |
737 | Int_t b=0, e=fN-1, m=(b+e)/2; | |
738 | for (; b<e; m=(b+e)/2) { | |
739 | if (z > fClusters[m]->GetZ()) b=m+1; | |
740 | else e=m; | |
741 | } | |
742 | return m; | |
743 | } | |
d4754572 | 744 | |
745 | //_________________________________________________________________________ | |
746 | Bool_t AliTOFtracker::GetTrackPoint(Int_t index, AliTrackPoint& p) const | |
747 | { | |
748 | // Get track space point with index i | |
749 | // Coordinates are in the global system | |
750 | AliTOFcluster *cl = fClusters[index]; | |
751 | Float_t xyz[3]; | |
752 | xyz[0] = cl->GetR()*TMath::Cos(cl->GetPhi()); | |
753 | xyz[1] = cl->GetR()*TMath::Sin(cl->GetPhi()); | |
754 | xyz[2] = cl->GetZ(); | |
468f26c6 | 755 | Float_t phiangle = (Int_t(cl->GetPhi()*TMath::RadToDeg()/20.)+0.5)*20.*TMath::DegToRad(); |
756 | Float_t sinphi = TMath::Sin(phiangle), cosphi = TMath::Cos(phiangle); | |
757 | Float_t tiltangle = fGeom->GetAngles(cl->GetDetInd(1),cl->GetDetInd(2))*TMath::DegToRad(); | |
758 | Float_t sinth = TMath::Sin(tiltangle), costh = TMath::Cos(tiltangle); | |
759 | Float_t sigmay2 = fGeom->XPad()*fGeom->XPad()/12.; | |
760 | Float_t sigmaz2 = fGeom->ZPad()*fGeom->ZPad()/12.; | |
761 | Float_t cov[6]; | |
762 | cov[0] = sinphi*sinphi*sigmay2 + cosphi*cosphi*sinth*sinth*sigmaz2; | |
763 | cov[1] = -sinphi*cosphi*sigmay2 + sinphi*cosphi*sinth*sinth*sigmaz2; | |
764 | cov[2] = -cosphi*sinth*costh*sigmaz2; | |
765 | cov[3] = cosphi*cosphi*sigmay2 + sinphi*sinphi*sinth*sinth*sigmaz2; | |
766 | cov[4] = -sinphi*sinth*costh*sigmaz2; | |
767 | cov[5] = costh*costh*sigmaz2; | |
768 | p.SetXYZ(xyz[0],xyz[1],xyz[2],cov); | |
d4754572 | 769 | |
770 | // Detector numbering scheme | |
771 | Int_t nSector = fGeom->NSectors(); | |
772 | Int_t nPlate = fGeom->NPlates(); | |
773 | Int_t nStripA = fGeom->NStripA(); | |
774 | Int_t nStripB = fGeom->NStripB(); | |
775 | Int_t nStripC = fGeom->NStripC(); | |
776 | ||
777 | Int_t isector = cl->GetDetInd(0); | |
778 | if (isector >= nSector) | |
779 | AliError(Form("Wrong sector number in TOF (%d) !",isector)); | |
780 | Int_t iplate = cl->GetDetInd(1); | |
781 | if (iplate >= nPlate) | |
782 | AliError(Form("Wrong plate number in TOF (%d) !",iplate)); | |
783 | Int_t istrip = cl->GetDetInd(2); | |
784 | ||
785 | Int_t stripOffset = 0; | |
786 | switch (iplate) { | |
787 | case 0: | |
788 | stripOffset = 0; | |
789 | break; | |
790 | case 1: | |
791 | stripOffset = nStripC; | |
792 | break; | |
793 | case 2: | |
794 | stripOffset = nStripC+nStripB; | |
795 | break; | |
796 | case 3: | |
797 | stripOffset = nStripC+nStripB+nStripA; | |
798 | break; | |
799 | case 4: | |
800 | stripOffset = nStripC+nStripB+nStripA+nStripB; | |
801 | break; | |
802 | default: | |
803 | AliError(Form("Wrong plate number in TOF (%d) !",iplate)); | |
804 | break; | |
805 | }; | |
806 | ||
807 | Int_t idet = (2*(nStripC+nStripB)+nStripA)*isector + | |
808 | stripOffset + | |
809 | istrip; | |
810 | UShort_t volid = AliAlignObj::LayerToVolUID(AliAlignObj::kTOF,idet); | |
811 | p.SetVolumeID((UShort_t)volid); | |
812 | return kTRUE; | |
813 | } | |
5664c6ed | 814 | //_________________________________________________________________________ |
815 | void AliTOFtracker::InitCheckHists() { | |
816 | ||
817 | //Init histos for Digits/Reco QA and Calibration | |
818 | ||
819 | ||
820 | fCalTree = new TTree("CalTree", "Tree for TOF calibration"); | |
821 | fCalTree->Branch("TOFchannelindex",&fIch,"iTOFch/I"); | |
822 | fCalTree->Branch("ToT",&fToT,"TOFToT/F"); | |
823 | fCalTree->Branch("TOFtime",&fTime,"TOFtime/F"); | |
824 | fCalTree->Branch("PionExpTime",&fExpTimePi,"PiExpTime/F"); | |
825 | fCalTree->Branch("KaonExpTime",&fExpTimeKa,"KaExpTime/F"); | |
826 | fCalTree->Branch("ProtonExpTime",&fExpTimePr,"PrExpTime/F"); | |
827 | ||
828 | //Digits "QA" | |
829 | fHDigClusMap = new TH2F("TOFDig_ClusMap", "",182,0.5,182.5,864, 0.5,864.5); | |
830 | fHDigNClus = new TH1F("TOFDig_NClus", "",200,0.5,200.5); | |
831 | fHDigClusTime = new TH1F("TOFDig_ClusTime", "",2000,0.,200.); | |
832 | fHDigClusToT = new TH1F("TOFDig_ClusToT", "",500,0.,100); | |
833 | ||
834 | //Reco "QA" | |
835 | fHRecNClus =new TH1F("TOFRec_NClusW", "",50,0.5,50.5); | |
836 | fHRecDist=new TH1F("TOFRec_Dist", "",50,0.5,10.5); | |
837 | fHRecSigYVsP=new TH2F("TOFDig_SigYVsP", "",40,0.,4.,100, 0.,5.); | |
838 | fHRecSigZVsP=new TH2F("TOFDig_SigZVsP", "",40,0.,4.,100, 0.,5.); | |
839 | fHRecSigYVsPWin=new TH2F("TOFDig_SigYVsPWin", "",40,0.,4.,100, 0.,50.); | |
840 | fHRecSigZVsPWin=new TH2F("TOFDig_SigZVsPWin", "",40,0.,4.,100, 0.,50.); | |
841 | } | |
842 | ||
843 | //_________________________________________________________________________ | |
844 | void AliTOFtracker::SaveCheckHists() { | |
845 | ||
846 | //write histos for Digits/Reco QA and Calibration | |
847 | ||
848 | TDirectory *dir = gDirectory; | |
849 | TFile *logFile = 0; | |
850 | TFile *logFileTOF = 0; | |
851 | ||
852 | TSeqCollection *list = gROOT->GetListOfFiles(); | |
d200609f | 853 | int n = list->GetEntries(); |
854 | for(int i=0; i<n; i++) { | |
5664c6ed | 855 | logFile = (TFile*)list->At(i); |
856 | if (strstr(logFile->GetName(), "AliESDs.root")) break; | |
857 | } | |
858 | ||
859 | Bool_t isThere=kFALSE; | |
d200609f | 860 | for(int i=0; i<n; i++) { |
5664c6ed | 861 | logFileTOF = (TFile*)list->At(i); |
862 | if (strstr(logFileTOF->GetName(), "TOFQA.root")){ | |
863 | isThere=kTRUE; | |
864 | break; | |
865 | } | |
866 | } | |
867 | ||
868 | logFile->cd(); | |
869 | fHDigClusMap->Write(fHDigClusMap->GetName(), TObject::kOverwrite); | |
870 | fHDigNClus->Write(fHDigNClus->GetName(), TObject::kOverwrite); | |
871 | fHDigClusTime->Write(fHDigClusTime->GetName(), TObject::kOverwrite); | |
872 | fHDigClusToT->Write(fHDigClusToT->GetName(), TObject::kOverwrite); | |
873 | fHRecNClus->Write(fHRecNClus->GetName(), TObject::kOverwrite); | |
874 | fHRecDist->Write(fHRecDist->GetName(), TObject::kOverwrite); | |
875 | fHRecSigYVsP->Write(fHRecSigYVsP->GetName(), TObject::kOverwrite); | |
876 | fHRecSigZVsP->Write(fHRecSigZVsP->GetName(), TObject::kOverwrite); | |
877 | fHRecSigYVsPWin->Write(fHRecSigYVsPWin->GetName(), TObject::kOverwrite); | |
878 | fHRecSigZVsPWin->Write(fHRecSigZVsPWin->GetName(), TObject::kOverwrite); | |
879 | fCalTree->Write(fCalTree->GetName(),TObject::kOverwrite); | |
880 | logFile->Flush(); | |
881 | ||
882 | if(!isThere)logFileTOF = new TFile( "TOFQA.root","RECREATE"); | |
883 | logFileTOF->cd(); | |
884 | fHDigClusMap->Write(fHDigClusMap->GetName(), TObject::kOverwrite); | |
885 | fHDigNClus->Write(fHDigNClus->GetName(), TObject::kOverwrite); | |
886 | fHDigClusTime->Write(fHDigClusTime->GetName(), TObject::kOverwrite); | |
887 | fHDigClusToT->Write(fHDigClusToT->GetName(), TObject::kOverwrite); | |
888 | fHRecNClus->Write(fHRecNClus->GetName(), TObject::kOverwrite); | |
889 | fHRecDist->Write(fHRecDist->GetName(), TObject::kOverwrite); | |
890 | fHRecSigYVsP->Write(fHRecSigYVsP->GetName(), TObject::kOverwrite); | |
891 | fHRecSigZVsP->Write(fHRecSigZVsP->GetName(), TObject::kOverwrite); | |
892 | fHRecSigYVsPWin->Write(fHRecSigYVsPWin->GetName(), TObject::kOverwrite); | |
893 | fHRecSigZVsPWin->Write(fHRecSigZVsPWin->GetName(), TObject::kOverwrite); | |
894 | fCalTree->Write(fCalTree->GetName(),TObject::kOverwrite); | |
895 | logFileTOF->Flush(); | |
896 | ||
897 | dir->cd(); | |
898 | } |