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