]>
Commit | Line | Data |
---|---|---|
d686d062 | 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 | **************************************************************************/ | |
15 | ||
16 | //--------------------------------------------------------------------// | |
17 | // // | |
3a646035 | 18 | // AliTOFtrackerV1 Class // |
d686d062 | 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 | ||
29 | #include <Rtypes.h> | |
30 | #include <TROOT.h> | |
31 | ||
32 | #include <TClonesArray.h> | |
33 | #include <TTree.h> | |
34 | #include <TFile.h> | |
35 | #include <TH1F.h> | |
36 | #include <TH2F.h> | |
5c7c93fa | 37 | #include <TSeqCollection.h> |
d686d062 | 38 | |
d686d062 | 39 | #include "AliESDtrack.h" |
40 | #include "AliESDEvent.h" | |
41 | #include "AliLog.h" | |
42 | #include "AliTrackPointArray.h" | |
5c7c93fa | 43 | #include "AliGeomManager.h" |
44 | #include "AliCDBManager.h" | |
d686d062 | 45 | |
d686d062 | 46 | #include "AliTOFRecoParam.h" |
3a646035 | 47 | #include "AliTOFReconstructor.h" |
d686d062 | 48 | #include "AliTOFcluster.h" |
ca270b6d | 49 | #include "AliTOFGeometry.h" |
d686d062 | 50 | #include "AliTOFtrackerV1.h" |
51 | #include "AliTOFtrack.h" | |
5c7c93fa | 52 | #include "AliTOFpidESD.h" |
d0c2872c | 53 | |
d686d062 | 54 | extern TROOT *gROOT; |
55 | ||
56 | ClassImp(AliTOFtrackerV1) | |
57 | ||
58 | //_____________________________________________________________________________ | |
59 | AliTOFtrackerV1::AliTOFtrackerV1(): | |
60 | fRecoParam(0x0), | |
d686d062 | 61 | fPid(0x0), |
62 | fN(0), | |
63 | fNseeds(0), | |
64 | fNseedsTOF(0), | |
65 | fngoodmatch(0), | |
66 | fnbadmatch(0), | |
67 | fnunmatch(0), | |
68 | fnmatch(0), | |
b42a5ea1 | 69 | fTracks(new TClonesArray("AliTOFtrack")), |
70 | fSeeds(new TClonesArray("AliESDtrack")), | |
d686d062 | 71 | fHDigClusMap(0x0), |
72 | fHDigNClus(0x0), | |
73 | fHDigClusTime(0x0), | |
74 | fHDigClusToT(0x0), | |
75 | fHRecNClus(0x0), | |
76 | fHRecChi2(0x0), | |
77 | fHRecDistZ(0x0), | |
78 | fHRecSigYVsP(0x0), | |
79 | fHRecSigZVsP(0x0), | |
80 | fHRecSigYVsPWin(0x0), | |
81 | fHRecSigZVsPWin(0x0) | |
82 | { | |
83 | //AliTOFtrackerV1 main Ctor | |
3a646035 | 84 | |
d686d062 | 85 | InitCheckHists(); |
86 | ||
87 | } | |
88 | //_____________________________________________________________________________ | |
89 | AliTOFtrackerV1::AliTOFtrackerV1(const AliTOFtrackerV1 &t): | |
90 | AliTracker(), | |
91 | fRecoParam(0x0), | |
d686d062 | 92 | fPid(0x0), |
93 | fN(0), | |
94 | fNseeds(0), | |
95 | fNseedsTOF(0), | |
96 | fngoodmatch(0), | |
97 | fnbadmatch(0), | |
98 | fnunmatch(0), | |
99 | fnmatch(0), | |
b42a5ea1 | 100 | fTracks(new TClonesArray("AliTOFtrack")), |
101 | fSeeds(new TClonesArray("AliESDtrack")), | |
d686d062 | 102 | fHDigClusMap(0x0), |
103 | fHDigNClus(0x0), | |
104 | fHDigClusTime(0x0), | |
105 | fHDigClusToT(0x0), | |
106 | fHRecNClus(0x0), | |
107 | fHRecChi2(0x0), | |
108 | fHRecDistZ(0x0), | |
109 | fHRecSigYVsP(0x0), | |
110 | fHRecSigZVsP(0x0), | |
111 | fHRecSigYVsPWin(0x0), | |
112 | fHRecSigZVsPWin(0x0) | |
113 | { | |
114 | //AliTOFtrackerV1 copy Ctor | |
115 | ||
116 | fNseeds=t.fNseeds; | |
117 | fNseeds=t.fNseeds; | |
118 | fNseedsTOF=t.fNseedsTOF; | |
119 | fngoodmatch=t.fngoodmatch; | |
120 | fnbadmatch=t.fnbadmatch; | |
121 | fnunmatch=t.fnunmatch; | |
122 | fnmatch=t.fnmatch; | |
123 | fRecoParam=t.fRecoParam; | |
d686d062 | 124 | fPid=t.fPid; |
125 | fSeeds=t.fSeeds; | |
126 | fTracks=t.fTracks; | |
127 | fN=t.fN; | |
128 | } | |
129 | ||
130 | //_____________________________________________________________________________ | |
131 | AliTOFtrackerV1& AliTOFtrackerV1::operator=(const AliTOFtrackerV1 &t) | |
132 | { | |
133 | //AliTOFtrackerV1 assignment operator | |
134 | ||
135 | this->fNseeds=t.fNseeds; | |
136 | this->fNseedsTOF=t.fNseedsTOF; | |
137 | this->fngoodmatch=t.fngoodmatch; | |
138 | this->fnbadmatch=t.fnbadmatch; | |
139 | this->fnunmatch=t.fnunmatch; | |
140 | this->fnmatch=t.fnmatch; | |
141 | this->fRecoParam = t.fRecoParam; | |
d686d062 | 142 | this->fPid = t.fPid; |
143 | this->fSeeds=t.fSeeds; | |
144 | this->fTracks=t.fTracks; | |
145 | this->fN=t.fN; | |
146 | return *this; | |
147 | ||
148 | } | |
149 | //_____________________________________________________________________________ | |
150 | AliTOFtrackerV1::~AliTOFtrackerV1() { | |
151 | // | |
152 | // Dtor | |
153 | // | |
154 | ||
155 | SaveCheckHists(); | |
156 | ||
5d456bcd | 157 | if(!(AliCDBManager::Instance()->GetCacheFlag())){ |
158 | delete fRecoParam; | |
159 | } | |
d686d062 | 160 | delete fPid; |
161 | delete fHDigClusMap; | |
162 | delete fHDigNClus; | |
163 | delete fHDigClusTime; | |
164 | delete fHDigClusToT; | |
165 | delete fHRecNClus; | |
166 | delete fHRecChi2; | |
167 | delete fHRecDistZ; | |
168 | delete fHRecSigYVsP; | |
169 | delete fHRecSigZVsP; | |
170 | delete fHRecSigYVsPWin; | |
171 | delete fHRecSigZVsPWin; | |
b42a5ea1 | 172 | if (fTracks){ |
173 | fTracks->Delete(); | |
174 | delete fTracks; | |
175 | fTracks=0x0; | |
176 | } | |
177 | if (fSeeds){ | |
178 | fSeeds->Delete(); | |
179 | delete fSeeds; | |
180 | fSeeds=0x0; | |
181 | } | |
d686d062 | 182 | } |
183 | //_____________________________________________________________________________ | |
184 | Int_t AliTOFtrackerV1::PropagateBack(AliESDEvent* event) { | |
185 | // | |
186 | // Gets seeds from ESD event and Match with TOF Clusters | |
187 | // | |
188 | ||
3a646035 | 189 | // initialize RecoParam for current event |
190 | ||
191 | AliInfo("Initializing params for TOF... "); | |
192 | ||
193 | fRecoParam = AliTOFReconstructor::GetRecoParam(); // instantiate reco param from STEER... | |
90b234fe | 194 | |
3a646035 | 195 | if (fRecoParam == 0x0) { |
196 | AliFatal("No Reco Param found for TOF!!!"); | |
197 | } | |
198 | //fRecoParam->Dump(); | |
199 | if(fRecoParam->GetApplyPbPbCuts())fRecoParam=fRecoParam->GetPbPbparam(); | |
90b234fe | 200 | //fRecoParam->PrintParameters(); |
201 | ||
3a646035 | 202 | Double_t parPID[2]; |
203 | parPID[0]=fRecoParam->GetTimeResolution(); | |
204 | parPID[1]=fRecoParam->GetTimeNSigma(); | |
205 | fPid=new AliTOFpidESD(parPID); | |
d686d062 | 206 | |
207 | //Initialise some counters | |
208 | ||
209 | fNseeds=0; | |
210 | fNseedsTOF=0; | |
211 | fngoodmatch=0; | |
212 | fnbadmatch=0; | |
213 | fnunmatch=0; | |
214 | fnmatch=0; | |
215 | ||
216 | Int_t ntrk=event->GetNumberOfTracks(); | |
217 | fNseeds = ntrk; | |
d686d062 | 218 | TClonesArray &aESDTrack = *fSeeds; |
219 | ||
220 | ||
221 | //Load ESD tracks into a local Array of ESD Seeds | |
222 | ||
223 | for (Int_t i=0; i<fNseeds; i++) { | |
224 | AliESDtrack *t=event->GetTrack(i); | |
225 | new(aESDTrack[i]) AliESDtrack(*t); | |
226 | } | |
227 | ||
228 | //Prepare ESD tracks candidates for TOF Matching | |
229 | CollectESD(); | |
230 | ||
231 | //Matching Step | |
232 | MatchTracks(); | |
233 | ||
234 | AliInfo(Form("Number of matched tracks: %d",fnmatch)); | |
235 | AliInfo(Form("Number of good matched tracks: %d",fngoodmatch)); | |
236 | AliInfo(Form("Number of bad matched tracks: %d",fnbadmatch)); | |
237 | ||
238 | //Update the matched ESD tracks | |
239 | ||
240 | for (Int_t i=0; i<ntrk; i++) { | |
241 | AliESDtrack *t=event->GetTrack(i); | |
242 | AliESDtrack *seed =(AliESDtrack*)fSeeds->UncheckedAt(i); | |
243 | if(seed->GetTOFsignal()>0){ | |
244 | t->SetTOFsignal(seed->GetTOFsignal()); | |
245 | t->SetTOFcluster(seed->GetTOFcluster()); | |
246 | t->SetTOFsignalToT(seed->GetTOFsignalToT()); | |
247 | t->SetTOFsignalRaw(seed->GetTOFsignalRaw()); | |
248 | t->SetTOFsignalDz(seed->GetTOFsignalDz()); | |
249 | t->SetTOFCalChannel(seed->GetTOFCalChannel()); | |
250 | Int_t tlab[3]; seed->GetTOFLabel(tlab); | |
251 | t->SetTOFLabel(tlab); | |
252 | AliTOFtrack *track = new AliTOFtrack(*seed); | |
253 | t->UpdateTrackParams(track,AliESDtrack::kTOFout); | |
254 | delete track; | |
255 | } | |
256 | } | |
257 | ||
258 | //Handle Time Zero information | |
259 | ||
260 | Double_t timeZero=0.; | |
261 | Double_t timeZeroMax=99999.; | |
262 | Bool_t usetimeZero = fRecoParam->UseTimeZero(); | |
263 | Bool_t timeZeroFromT0 = fRecoParam->GetTimeZerofromT0(); | |
264 | Bool_t timeZeroFromTOF = fRecoParam->GetTimeZerofromTOF(); | |
265 | ||
266 | AliDebug(1,Form("Use Time Zero?: %d",usetimeZero)); | |
267 | AliDebug(1,Form("Time Zero from T0? : %d",timeZeroFromT0)); | |
268 | AliDebug(1,Form("Time Zero From TOF? : %d",timeZeroFromTOF)); | |
269 | ||
270 | if(usetimeZero){ | |
271 | if(timeZeroFromT0){ | |
272 | timeZero=GetTimeZerofromT0(event); | |
273 | } | |
274 | if(timeZeroFromTOF && (timeZero>timeZeroMax || !timeZeroFromT0)){ | |
275 | timeZero=GetTimeZerofromTOF(event); | |
276 | } | |
277 | } | |
278 | AliDebug(2,Form("time Zero used in PID: %f",timeZero)); | |
279 | //Make TOF PID | |
280 | fPid->MakePID(event,timeZero); | |
281 | ||
b42a5ea1 | 282 | fSeeds->Clear(); |
283 | fTracks->Clear(); | |
d686d062 | 284 | return 0; |
285 | ||
286 | } | |
287 | //_________________________________________________________________________ | |
288 | void AliTOFtrackerV1::CollectESD() { | |
289 | //prepare the set of ESD tracks to be matched to clusters in TOF | |
290 | ||
291 | Int_t seedsTOF1=0; | |
292 | Int_t seedsTOF2=0; | |
293 | ||
d686d062 | 294 | TClonesArray &aTOFTrack = *fTracks; |
295 | for (Int_t i=0; i<fNseeds; i++) { | |
296 | ||
297 | AliESDtrack *t =(AliESDtrack*)fSeeds->UncheckedAt(i); | |
298 | if ((t->GetStatus()&AliESDtrack::kTPCout)==0)continue; | |
299 | ||
8dacd1bb | 300 | // TRD 'good' tracks, already propagated at 372 cm |
d686d062 | 301 | |
302 | AliTOFtrack *track = new AliTOFtrack(*t); // New | |
303 | Double_t x = track->GetX(); //New | |
304 | ||
305 | if (((t->GetStatus()&AliESDtrack::kTRDout)!=0 ) && | |
ca270b6d | 306 | ( x >= AliTOFGeometry::RinTOF()) ){ |
d686d062 | 307 | track->SetSeedIndex(i); |
308 | t->UpdateTrackParams(track,AliESDtrack::kTOFout); | |
309 | new(aTOFTrack[fNseedsTOF]) AliTOFtrack(*track); | |
310 | fNseedsTOF++; | |
311 | seedsTOF1++; | |
312 | delete track; | |
313 | } | |
314 | ||
315 | // Propagate the rest of TPCbp | |
316 | ||
317 | else { | |
318 | if(track->PropagateToInnerTOF()){ | |
319 | track->SetSeedIndex(i); | |
320 | t->UpdateTrackParams(track,AliESDtrack::kTOFout); | |
321 | new(aTOFTrack[fNseedsTOF]) AliTOFtrack(*track); | |
322 | fNseedsTOF++; | |
323 | seedsTOF2++; | |
324 | } | |
325 | delete track; | |
326 | } | |
327 | } | |
328 | ||
329 | AliInfo(Form("Number of TOF seeds %i",fNseedsTOF)); | |
330 | AliInfo(Form("Number of TOF seeds Type 1 %i",seedsTOF1)); | |
331 | AliInfo(Form("Number of TOF seeds Type 2 %i",seedsTOF2)); | |
332 | ||
333 | // Sort according uncertainties on track position | |
334 | fTracks->Sort(); | |
335 | ||
336 | } | |
337 | //_________________________________________________________________________ | |
338 | void AliTOFtrackerV1::MatchTracks( ){ | |
339 | // | |
340 | //Match ESD tracks to clusters in TOF | |
341 | // | |
342 | ||
343 | ||
344 | // Parameters regulating the reconstruction | |
ca270b6d | 345 | Float_t dY=AliTOFGeometry::XPad(); |
346 | Float_t dZ=AliTOFGeometry::ZPad(); | |
d686d062 | 347 | |
3da9d64f | 348 | const Int_t kncmax = 100; |
d686d062 | 349 | Float_t sensRadius = fRecoParam->GetSensRadius(); |
350 | Float_t scaleFact = fRecoParam->GetWindowScaleFact(); | |
351 | Float_t dyMax=fRecoParam->GetWindowSizeMaxY(); | |
352 | Float_t dzMax=fRecoParam->GetWindowSizeMaxZ(); | |
353 | Double_t maxChi2=fRecoParam->GetMaxChi2(); | |
354 | Bool_t timeWalkCorr = fRecoParam->GetTimeWalkCorr(); | |
355 | AliDebug(1,"++++++++++++++TOF Reconstruction Parameters:++++++++++++ \n"); | |
356 | AliDebug(1,Form("TOF sens radius: %f",sensRadius)); | |
357 | AliDebug(1,Form("TOF Window scale factor: %f",scaleFact)); | |
358 | AliDebug(1,Form("TOF Window max dy: %f",dyMax)); | |
359 | AliDebug(1,Form("TOF Window max dz: %f",dzMax)); | |
360 | AliDebug(1,Form("TOF Max Chi2: %f",maxChi2)); | |
361 | AliDebug(1,Form("Time Walk Correction? : %d",timeWalkCorr)); | |
362 | ||
363 | ||
364 | //The matching loop | |
365 | ||
d686d062 | 366 | for (Int_t iseed=0; iseed<fNseedsTOF; iseed++) { |
367 | ||
368 | AliTOFtrack *track =(AliTOFtrack*)fTracks->UncheckedAt(iseed); | |
369 | AliESDtrack *t =(AliESDtrack*)fSeeds->UncheckedAt(track->GetSeedIndex()); | |
370 | if(t->GetTOFsignal()>0. ) continue; | |
371 | AliTOFtrack *trackTOFin =new AliTOFtrack(*track); | |
372 | ||
373 | // Determine a window around the track | |
374 | Double_t x,par[5]; trackTOFin->GetExternalParameters(x,par); | |
375 | Double_t cov[15]; trackTOFin->GetExternalCovariance(cov); | |
376 | ||
377 | Double_t z = par[1]; | |
3a646035 | 378 | Double_t dz = scaleFact*3.*TMath::Sqrt(cov[2]+dZ*dZ/12.); |
d686d062 | 379 | Double_t dphi = scaleFact*3.*TMath::Sqrt(cov[0]+dY*dY/12.)/sensRadius; |
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 | ||
385 | //upper limit on window's size. | |
386 | if(dz> dzMax) dz=dzMax; | |
387 | if(dphi*sensRadius> dyMax) dphi=dyMax/sensRadius; | |
388 | ||
389 | ||
390 | // find the clusters inside the selected window | |
391 | Int_t nc=0; | |
3da9d64f | 392 | AliTOFcluster *clusters[kncmax]; // pointers to the clusters in the window |
393 | Int_t index[kncmax];//to keep track of the cluster index | |
d686d062 | 394 | for (Int_t k=FindClusterIndex(z-dz); k<fN; k++) { |
395 | AliTOFcluster *c=fClusters[k]; | |
c0b60ae7 | 396 | // if(nc>kncmax)break; /* R+ fix (buffer overflow) */ |
397 | if(nc>=kncmax)break; /* R+ fix (buffer overflow protection) */ | |
d686d062 | 398 | if(c->GetZ() > z+dz) break; |
399 | if(c->IsUsed()) continue; | |
17149e6b | 400 | if(!c->GetStatus()) { |
401 | AliDebug(1,"Cluster in channel declared bad!"); | |
402 | continue; // skip bad channels as declared in OCDB | |
403 | } | |
d686d062 | 404 | Float_t xyz[3]; c->GetGlobalXYZ(xyz); |
405 | Double_t clPhi=TMath::ATan2(xyz[1],xyz[0]); | |
406 | Double_t dph=TMath::Abs(clPhi-phi); | |
407 | if (dph>TMath::Pi()) dph-=2.*TMath::Pi(); | |
408 | if (TMath::Abs(dph)>dphi) continue; | |
409 | clusters[nc]=c; | |
410 | index[nc] = k; | |
411 | nc++; | |
412 | } | |
413 | ||
8dacd1bb | 414 | //start propagation: go to the average TOF pad middle plane at ~379.5 cm |
d686d062 | 415 | |
416 | Float_t xTOF = sensRadius; | |
ca270b6d | 417 | Double_t ymax = xTOF*TMath::Tan(0.5*AliTOFGeometry::GetAlpha()); |
d686d062 | 418 | Bool_t skip = kFALSE; |
419 | Double_t ysect = trackTOFin->GetYat(xTOF,skip); | |
420 | if (skip) break; | |
421 | if (ysect > ymax) { | |
ca270b6d | 422 | if (!trackTOFin->Rotate(AliTOFGeometry::GetAlpha())) { |
d686d062 | 423 | break; |
424 | } | |
425 | } else if (ysect <-ymax) { | |
ca270b6d | 426 | if (!trackTOFin->Rotate(AliTOFGeometry::GetAlpha())) { |
d686d062 | 427 | break; |
428 | } | |
429 | } | |
430 | if(!trackTOFin->PropagateTo(xTOF)) { | |
431 | break; | |
432 | } | |
433 | ||
434 | ||
435 | AliTOFcluster *bestCluster=0; | |
436 | Double_t bestChi2=maxChi2; | |
437 | Int_t idclus=-1; | |
c0b60ae7 | 438 | // for (Int_t i=0; i<nc; i++){ /* R+ fix (unsafe) */ |
439 | for (Int_t i=0; i<nc && i<kncmax; i++){ /* R+ fix (buffer overflow protection) */ | |
d686d062 | 440 | AliTOFcluster *c=clusters[i]; // one of the preselected clusters |
441 | Double_t chi2=trackTOFin->GetPredictedChi2((AliCluster3D*)c); | |
442 | if (chi2 >= bestChi2) continue; | |
443 | bestChi2=chi2; | |
444 | bestCluster=c; | |
445 | idclus=index[i]; | |
446 | } | |
447 | ||
448 | if (!bestCluster) { // no matching , go to the next track | |
449 | fnunmatch++; | |
450 | delete trackTOFin; | |
451 | continue; | |
452 | } | |
453 | ||
454 | fnmatch++; | |
32ead898 | 455 | |
3a646035 | 456 | AliDebug(2, Form("%7i %7i %10i %10i %10i %10i %7i", |
32ead898 | 457 | iseed, |
3a646035 | 458 | fnmatch-1, |
32ead898 | 459 | TMath::Abs(trackTOFin->GetLabel()), |
460 | bestCluster->GetLabel(0), | |
461 | bestCluster->GetLabel(1), | |
3a646035 | 462 | bestCluster->GetLabel(2), |
463 | idclus)); // AdC | |
32ead898 | 464 | |
d686d062 | 465 | bestCluster->Use(); |
466 | if ( | |
467 | (bestCluster->GetLabel(0)==TMath::Abs(trackTOFin->GetLabel())) | |
468 | || | |
469 | (bestCluster->GetLabel(1)==TMath::Abs(trackTOFin->GetLabel())) | |
470 | || | |
471 | (bestCluster->GetLabel(2)==TMath::Abs(trackTOFin->GetLabel())) | |
472 | ) { | |
473 | fngoodmatch++; | |
474 | AliDebug(2,Form(" track label good %5i",trackTOFin->GetLabel())); | |
475 | ||
476 | } | |
477 | else{ | |
478 | fnbadmatch++; | |
479 | AliDebug(2,Form(" track label bad %5i",trackTOFin->GetLabel())); | |
480 | } | |
481 | ||
482 | //Propagate the track to the best matched cluster | |
483 | trackTOFin->PropagateTo(bestCluster); | |
484 | ||
485 | ||
486 | //now take the local distance in Z from the pad center for time walk correction | |
ca270b6d | 487 | Float_t tiltangle = AliTOFGeometry::GetAngles(bestCluster->GetDetInd(1),bestCluster->GetDetInd(2))*TMath::DegToRad(); |
d686d062 | 488 | Double_t dzTW=trackTOFin->GetZ()-bestCluster->GetZ(); // in cm |
489 | dzTW/=TMath::Cos(tiltangle); | |
490 | ||
491 | //update the ESD track and delete the TOFtrack | |
492 | t->UpdateTrackParams(trackTOFin,AliESDtrack::kTOFout); | |
493 | delete trackTOFin; | |
494 | ||
495 | // Store quantities to be used in the TOF Calibration | |
ca270b6d | 496 | Float_t tToT=AliTOFGeometry::ToTBinWidth()*bestCluster->GetToT()*1E-3; // in ns |
d686d062 | 497 | t->SetTOFsignalToT(tToT); |
ca270b6d | 498 | Float_t rawTime=AliTOFGeometry::TdcBinWidth()*bestCluster->GetTDCRAW()+32; // RAW time,in ps |
d686d062 | 499 | t->SetTOFsignalRaw(rawTime); |
500 | t->SetTOFsignalDz(dzTW); | |
501 | AliDebug(2,Form(" Setting TOF raw time: %f z distance: %f time: %f = ",rawTime,dzTW)); | |
502 | Int_t ind[5]; | |
503 | ind[0]=bestCluster->GetDetInd(0); | |
504 | ind[1]=bestCluster->GetDetInd(1); | |
505 | ind[2]=bestCluster->GetDetInd(2); | |
506 | ind[3]=bestCluster->GetDetInd(3); | |
507 | ind[4]=bestCluster->GetDetInd(4); | |
ca270b6d | 508 | Int_t calindex = AliTOFGeometry::GetIndex(ind); |
d686d062 | 509 | t->SetTOFCalChannel(calindex); |
510 | ||
511 | // keep track of the track labels in the matched cluster | |
512 | Int_t tlab[3]; | |
513 | tlab[0]=bestCluster->GetLabel(0); | |
514 | tlab[1]=bestCluster->GetLabel(1); | |
515 | tlab[2]=bestCluster->GetLabel(2); | |
516 | AliDebug(2,Form(" tdc time of the matched track %i = ",bestCluster->GetTDC())); | |
ca270b6d | 517 | Double_t tof=AliTOFGeometry::TdcBinWidth()*bestCluster->GetTDC()+32; // in ps |
d686d062 | 518 | AliDebug(2,Form(" tof time of the matched track: %f = ",tof)); |
519 | Double_t tofcorr=tof; | |
520 | if(timeWalkCorr)tofcorr=CorrectTimeWalk(dzTW,tof); | |
521 | AliDebug(2,Form(" tof time of the matched track, after TW corr: %f = ",tofcorr)); | |
522 | //Set TOF time signal and pointer to the matched cluster | |
523 | t->SetTOFsignal(tofcorr); | |
524 | t->SetTOFcluster(idclus); // pointing to the recPoints tree | |
525 | t->SetTOFLabel(tlab); | |
526 | ||
527 | Double_t mom=t->GetP(); | |
528 | // Fill Reco-QA histos for Reconstruction | |
529 | fHRecNClus->Fill(nc); | |
530 | fHRecChi2->Fill(bestChi2); | |
531 | fHRecDistZ->Fill(dzTW); | |
532 | fHRecSigYVsP->Fill(mom,TMath::Sqrt(cov[0])); | |
533 | fHRecSigZVsP->Fill(mom,TMath::Sqrt(cov[2])); | |
534 | fHRecSigYVsPWin->Fill(mom,dphi*sensRadius); | |
535 | fHRecSigZVsPWin->Fill(mom,dz); | |
536 | ||
537 | // Fill Tree for on-the-fly offline Calibration | |
538 | // no longer there - all info is in the ESDs now | |
539 | ||
540 | } | |
d686d062 | 541 | |
542 | } | |
543 | //_________________________________________________________________________ | |
544 | Int_t AliTOFtrackerV1::LoadClusters(TTree *cTree) { | |
545 | //-------------------------------------------------------------------- | |
546 | //This function loads the TOF clusters | |
547 | //-------------------------------------------------------------------- | |
548 | ||
ca270b6d | 549 | Int_t npadX = AliTOFGeometry::NpadX(); |
550 | Int_t npadZ = AliTOFGeometry::NpadZ(); | |
551 | Int_t nStripA = AliTOFGeometry::NStripA(); | |
552 | Int_t nStripB = AliTOFGeometry::NStripB(); | |
553 | Int_t nStripC = AliTOFGeometry::NStripC(); | |
d686d062 | 554 | |
555 | TBranch *branch=cTree->GetBranch("TOF"); | |
556 | if (!branch) { | |
557 | AliError("can't get the branch with the TOF clusters !"); | |
558 | return 1; | |
559 | } | |
560 | ||
b42a5ea1 | 561 | static TClonesArray dummy("AliTOFcluster",10000); |
562 | dummy.Clear(); | |
563 | TClonesArray *clusters=&dummy; | |
d686d062 | 564 | branch->SetAddress(&clusters); |
565 | ||
566 | cTree->GetEvent(0); | |
567 | Int_t nc=clusters->GetEntriesFast(); | |
568 | fHDigNClus->Fill(nc); | |
569 | ||
b42a5ea1 | 570 | AliInfo(Form("Number of clusters: %d",nc)); |
571 | ||
d686d062 | 572 | for (Int_t i=0; i<nc; i++) { |
573 | AliTOFcluster *c=(AliTOFcluster*)clusters->UncheckedAt(i); | |
574 | fClusters[i]=new AliTOFcluster(*c); fN++; | |
575 | ||
576 | // Fill Digits QA histos | |
577 | ||
578 | Int_t isector = c->GetDetInd(0); | |
579 | Int_t iplate = c->GetDetInd(1); | |
580 | Int_t istrip = c->GetDetInd(2); | |
581 | Int_t ipadX = c->GetDetInd(4); | |
582 | Int_t ipadZ = c->GetDetInd(3); | |
583 | ||
ca270b6d | 584 | Float_t time =(AliTOFGeometry::TdcBinWidth()*c->GetTDC())*1E-3; // in ns |
585 | Float_t tot = (AliTOFGeometry::TdcBinWidth()*c->GetToT())*1E-3;//in ns | |
d686d062 | 586 | |
587 | Int_t stripOffset = 0; | |
588 | switch (iplate) { | |
589 | case 0: | |
590 | stripOffset = 0; | |
591 | break; | |
592 | case 1: | |
593 | stripOffset = nStripC; | |
594 | break; | |
595 | case 2: | |
596 | stripOffset = nStripC+nStripB; | |
597 | break; | |
598 | case 3: | |
599 | stripOffset = nStripC+nStripB+nStripA; | |
600 | break; | |
601 | case 4: | |
602 | stripOffset = nStripC+nStripB+nStripA+nStripB; | |
603 | break; | |
604 | default: | |
605 | AliError(Form("Wrong plate number in TOF (%d) !",iplate)); | |
606 | break; | |
607 | }; | |
608 | Int_t zindex=npadZ*(istrip+stripOffset)+(ipadZ+1); | |
609 | Int_t phiindex=npadX*isector+ipadX+1; | |
610 | fHDigClusMap->Fill(zindex,phiindex); | |
611 | fHDigClusTime->Fill(time); | |
612 | fHDigClusToT->Fill(tot); | |
613 | } | |
614 | ||
615 | ||
616 | return 0; | |
617 | } | |
618 | //_________________________________________________________________________ | |
619 | void AliTOFtrackerV1::UnloadClusters() { | |
620 | //-------------------------------------------------------------------- | |
621 | //This function unloads TOF clusters | |
622 | //-------------------------------------------------------------------- | |
623 | for (Int_t i=0; i<fN; i++) { | |
624 | delete fClusters[i]; | |
625 | fClusters[i] = 0x0; | |
626 | } | |
627 | fN=0; | |
628 | } | |
629 | ||
630 | //_________________________________________________________________________ | |
631 | Int_t AliTOFtrackerV1::FindClusterIndex(Double_t z) const { | |
632 | //-------------------------------------------------------------------- | |
633 | // This function returns the index of the nearest cluster | |
634 | //-------------------------------------------------------------------- | |
635 | //MOD | |
636 | //Here we need to get the Z in the tracking system | |
637 | ||
638 | if (fN==0) return 0; | |
639 | if (z <= fClusters[0]->GetZ()) return 0; | |
640 | if (z > fClusters[fN-1]->GetZ()) return fN; | |
641 | Int_t b=0, e=fN-1, m=(b+e)/2; | |
642 | for (; b<e; m=(b+e)/2) { | |
643 | if (z > fClusters[m]->GetZ()) b=m+1; | |
644 | else e=m; | |
645 | } | |
646 | return m; | |
647 | } | |
648 | ||
649 | //_________________________________________________________________________ | |
650 | Bool_t AliTOFtrackerV1::GetTrackPoint(Int_t index, AliTrackPoint& p) const | |
651 | { | |
652 | // Get track space point with index i | |
653 | // Coordinates are in the global system | |
654 | AliTOFcluster *cl = fClusters[index]; | |
655 | Float_t xyz[3]; | |
656 | cl->GetGlobalXYZ(xyz); | |
657 | Float_t phi=TMath::ATan2(xyz[1],xyz[0]); | |
658 | Float_t phiangle = (Int_t(phi*TMath::RadToDeg()/20.)+0.5)*20.*TMath::DegToRad(); | |
659 | Float_t sinphi = TMath::Sin(phiangle), cosphi = TMath::Cos(phiangle); | |
ca270b6d | 660 | Float_t tiltangle = AliTOFGeometry::GetAngles(cl->GetDetInd(1),cl->GetDetInd(2))*TMath::DegToRad(); |
d686d062 | 661 | Float_t sinth = TMath::Sin(tiltangle), costh = TMath::Cos(tiltangle); |
ca270b6d | 662 | Float_t sigmay2 = AliTOFGeometry::XPad()*AliTOFGeometry::XPad()/12.; |
663 | Float_t sigmaz2 = AliTOFGeometry::ZPad()*AliTOFGeometry::ZPad()/12.; | |
d686d062 | 664 | Float_t cov[6]; |
665 | cov[0] = sinphi*sinphi*sigmay2 + cosphi*cosphi*sinth*sinth*sigmaz2; | |
666 | cov[1] = -sinphi*cosphi*sigmay2 + sinphi*cosphi*sinth*sinth*sigmaz2; | |
667 | cov[2] = -cosphi*sinth*costh*sigmaz2; | |
668 | cov[3] = cosphi*cosphi*sigmay2 + sinphi*sinphi*sinth*sinth*sigmaz2; | |
669 | cov[4] = -sinphi*sinth*costh*sigmaz2; | |
670 | cov[5] = costh*costh*sigmaz2; | |
671 | p.SetXYZ(xyz[0],xyz[1],xyz[2],cov); | |
672 | ||
673 | // Detector numbering scheme | |
ca270b6d | 674 | Int_t nSector = AliTOFGeometry::NSectors(); |
675 | Int_t nPlate = AliTOFGeometry::NPlates(); | |
676 | Int_t nStripA = AliTOFGeometry::NStripA(); | |
677 | Int_t nStripB = AliTOFGeometry::NStripB(); | |
678 | Int_t nStripC = AliTOFGeometry::NStripC(); | |
d686d062 | 679 | |
680 | Int_t isector = cl->GetDetInd(0); | |
681 | if (isector >= nSector) | |
682 | AliError(Form("Wrong sector number in TOF (%d) !",isector)); | |
683 | Int_t iplate = cl->GetDetInd(1); | |
684 | if (iplate >= nPlate) | |
685 | AliError(Form("Wrong plate number in TOF (%d) !",iplate)); | |
686 | Int_t istrip = cl->GetDetInd(2); | |
687 | ||
688 | Int_t stripOffset = 0; | |
689 | switch (iplate) { | |
690 | case 0: | |
691 | stripOffset = 0; | |
692 | break; | |
693 | case 1: | |
694 | stripOffset = nStripC; | |
695 | break; | |
696 | case 2: | |
697 | stripOffset = nStripC+nStripB; | |
698 | break; | |
699 | case 3: | |
700 | stripOffset = nStripC+nStripB+nStripA; | |
701 | break; | |
702 | case 4: | |
703 | stripOffset = nStripC+nStripB+nStripA+nStripB; | |
704 | break; | |
705 | default: | |
706 | AliError(Form("Wrong plate number in TOF (%d) !",iplate)); | |
707 | break; | |
708 | }; | |
709 | ||
710 | Int_t idet = (2*(nStripC+nStripB)+nStripA)*isector + | |
711 | stripOffset + | |
712 | istrip; | |
713 | UShort_t volid = AliGeomManager::LayerToVolUID(AliGeomManager::kTOF,idet); | |
714 | p.SetVolumeID((UShort_t)volid); | |
715 | return kTRUE; | |
716 | } | |
717 | //_________________________________________________________________________ | |
718 | void AliTOFtrackerV1::InitCheckHists() { | |
719 | ||
720 | //Init histos for Digits/Reco QA and Calibration | |
721 | ||
3a646035 | 722 | TDirectory *dir = gDirectory; |
723 | TFile *logFileTOF = 0; | |
724 | ||
725 | TSeqCollection *list = gROOT->GetListOfFiles(); | |
726 | int n = list->GetEntries(); | |
727 | Bool_t isThere=kFALSE; | |
728 | for(int i=0; i<n; i++) { | |
729 | logFileTOF = (TFile*)list->At(i); | |
730 | if (strstr(logFileTOF->GetName(), "TOFQA.root")){ | |
731 | isThere=kTRUE; | |
732 | break; | |
733 | } | |
734 | } | |
735 | ||
736 | if(!isThere)logFileTOF = new TFile( "TOFQA.root","RECREATE"); | |
737 | logFileTOF->cd(); | |
738 | ||
d686d062 | 739 | //Digits "QA" |
740 | fHDigClusMap = new TH2F("TOFDig_ClusMap", "",182,0.5,182.5,864, 0.5,864.5); | |
741 | fHDigNClus = new TH1F("TOFDig_NClus", "",200,0.5,200.5); | |
742 | fHDigClusTime = new TH1F("TOFDig_ClusTime", "",2000,0.,200.); | |
743 | fHDigClusToT = new TH1F("TOFDig_ClusToT", "",500,0.,100); | |
744 | ||
745 | //Reco "QA" | |
746 | fHRecNClus =new TH1F("TOFRec_NClusW", "",50,0.5,50.5); | |
747 | fHRecDistZ=new TH1F("TOFRec_DistZ", "",50,0.5,10.5); | |
748 | fHRecChi2=new TH1F("TOFRec_Chi2", "",100,0.,10.); | |
749 | fHRecSigYVsP=new TH2F("TOFDig_SigYVsP", "",40,0.,4.,100, 0.,5.); | |
750 | fHRecSigZVsP=new TH2F("TOFDig_SigZVsP", "",40,0.,4.,100, 0.,5.); | |
751 | fHRecSigYVsPWin=new TH2F("TOFDig_SigYVsPWin", "",40,0.,4.,100, 0.,50.); | |
752 | fHRecSigZVsPWin=new TH2F("TOFDig_SigZVsPWin", "",40,0.,4.,100, 0.,50.); | |
3a646035 | 753 | |
754 | dir->cd(); | |
755 | ||
d686d062 | 756 | } |
757 | ||
758 | //_________________________________________________________________________ | |
759 | void AliTOFtrackerV1::SaveCheckHists() { | |
760 | ||
761 | //write histos for Digits/Reco QA and Calibration | |
762 | ||
763 | TDirectory *dir = gDirectory; | |
764 | TFile *logFile = 0; | |
765 | TFile *logFileTOF = 0; | |
766 | ||
767 | TSeqCollection *list = gROOT->GetListOfFiles(); | |
768 | int n = list->GetEntries(); | |
769 | for(int i=0; i<n; i++) { | |
770 | logFile = (TFile*)list->At(i); | |
771 | if (strstr(logFile->GetName(), "AliESDs.root")) break; | |
772 | } | |
773 | ||
774 | Bool_t isThere=kFALSE; | |
775 | for(int i=0; i<n; i++) { | |
776 | logFileTOF = (TFile*)list->At(i); | |
777 | if (strstr(logFileTOF->GetName(), "TOFQA.root")){ | |
778 | isThere=kTRUE; | |
779 | break; | |
780 | } | |
781 | } | |
782 | ||
3a646035 | 783 | if(!isThere) { |
784 | AliError(Form("File TOFQA.root not found!! not wring histograms....")); | |
785 | return; | |
786 | } | |
d686d062 | 787 | logFile->cd(); |
788 | fHDigClusMap->Write(fHDigClusMap->GetName(), TObject::kOverwrite); | |
789 | fHDigNClus->Write(fHDigNClus->GetName(), TObject::kOverwrite); | |
790 | fHDigClusTime->Write(fHDigClusTime->GetName(), TObject::kOverwrite); | |
791 | fHDigClusToT->Write(fHDigClusToT->GetName(), TObject::kOverwrite); | |
792 | fHRecNClus->Write(fHRecNClus->GetName(), TObject::kOverwrite); | |
793 | fHRecChi2->Write(fHRecChi2->GetName(), TObject::kOverwrite); | |
794 | fHRecDistZ->Write(fHRecDistZ->GetName(), TObject::kOverwrite); | |
795 | fHRecSigYVsP->Write(fHRecSigYVsP->GetName(), TObject::kOverwrite); | |
796 | fHRecSigZVsP->Write(fHRecSigZVsP->GetName(), TObject::kOverwrite); | |
797 | fHRecSigYVsPWin->Write(fHRecSigYVsPWin->GetName(), TObject::kOverwrite); | |
798 | fHRecSigZVsPWin->Write(fHRecSigZVsPWin->GetName(), TObject::kOverwrite); | |
799 | logFile->Flush(); | |
800 | ||
d686d062 | 801 | dir->cd(); |
3a646035 | 802 | |
d686d062 | 803 | } |
804 | //_________________________________________________________________________ | |
805 | Float_t AliTOFtrackerV1::CorrectTimeWalk( Float_t dist, Float_t tof) { | |
806 | ||
807 | //dummy, for the moment | |
808 | Float_t tofcorr=0.; | |
ca270b6d | 809 | if(dist<AliTOFGeometry::ZPad()*0.5){ |
d686d062 | 810 | tofcorr=tof; |
811 | //place here the actual correction | |
812 | }else{ | |
813 | tofcorr=tof; | |
814 | } | |
815 | return tofcorr; | |
816 | } | |
817 | //_________________________________________________________________________ | |
818 | Float_t AliTOFtrackerV1::GetTimeZerofromT0(AliESDEvent *event) const { | |
819 | ||
820 | //Returns TimeZero as measured by T0 detector | |
821 | ||
822 | return event->GetT0(); | |
823 | } | |
824 | //_________________________________________________________________________ | |
825 | Float_t AliTOFtrackerV1::GetTimeZerofromTOF(AliESDEvent * /*event*/) const { | |
826 | ||
827 | //dummy, for the moment. T0 algorithm using tracks on TOF | |
828 | { | |
829 | //place T0 algo here... | |
830 | } | |
831 | return 0.; | |
832 | } | |
128563f6 | 833 | //_________________________________________________________________________ |
834 | ||
835 | void AliTOFtrackerV1::FillClusterArray(TObjArray* arr) const | |
836 | { | |
837 | // | |
838 | // Returns the TOF cluster array | |
839 | // | |
840 | ||
841 | if (fN==0) | |
842 | arr = 0x0; | |
843 | else | |
844 | for (Int_t i=0; i<fN; ++i) arr->Add(fClusters[i]); | |
845 | ||
846 | } |