]> git.uio.no Git - u/mrichter/AliRoot.git/blame - TOF/AliTOFtrackerV1.cxx
Inserted the FillResiduals method call in the TOF trackers (I.Belikov)
[u/mrichter/AliRoot.git] / TOF / AliTOFtrackerV1.cxx
CommitLineData
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 54extern TROOT *gROOT;
55
56ClassImp(AliTOFtrackerV1)
57
58//_____________________________________________________________________________
59AliTOFtrackerV1::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//_____________________________________________________________________________
89AliTOFtrackerV1::~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//_____________________________________________________________________________
123Int_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//_________________________________________________________________________
227void 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//_________________________________________________________________________
277void 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
77a9ea9a 424 // Fill the track residual histograms.
425 FillResiduals(trackTOFin,bestCluster,kFALSE);
d686d062 426
427 //now take the local distance in Z from the pad center for time walk correction
ca270b6d 428 Float_t tiltangle = AliTOFGeometry::GetAngles(bestCluster->GetDetInd(1),bestCluster->GetDetInd(2))*TMath::DegToRad();
d686d062 429 Double_t dzTW=trackTOFin->GetZ()-bestCluster->GetZ(); // in cm
430 dzTW/=TMath::Cos(tiltangle);
431
432 //update the ESD track and delete the TOFtrack
433 t->UpdateTrackParams(trackTOFin,AliESDtrack::kTOFout);
434 delete trackTOFin;
435
436 // Store quantities to be used in the TOF Calibration
ca270b6d 437 Float_t tToT=AliTOFGeometry::ToTBinWidth()*bestCluster->GetToT()*1E-3; // in ns
d686d062 438 t->SetTOFsignalToT(tToT);
ca270b6d 439 Float_t rawTime=AliTOFGeometry::TdcBinWidth()*bestCluster->GetTDCRAW()+32; // RAW time,in ps
d686d062 440 t->SetTOFsignalRaw(rawTime);
441 t->SetTOFsignalDz(dzTW);
442 AliDebug(2,Form(" Setting TOF raw time: %f z distance: %f time: %f = ",rawTime,dzTW));
443 Int_t ind[5];
444 ind[0]=bestCluster->GetDetInd(0);
445 ind[1]=bestCluster->GetDetInd(1);
446 ind[2]=bestCluster->GetDetInd(2);
447 ind[3]=bestCluster->GetDetInd(3);
448 ind[4]=bestCluster->GetDetInd(4);
ca270b6d 449 Int_t calindex = AliTOFGeometry::GetIndex(ind);
d686d062 450 t->SetTOFCalChannel(calindex);
451
452 // keep track of the track labels in the matched cluster
453 Int_t tlab[3];
454 tlab[0]=bestCluster->GetLabel(0);
455 tlab[1]=bestCluster->GetLabel(1);
456 tlab[2]=bestCluster->GetLabel(2);
457 AliDebug(2,Form(" tdc time of the matched track %i = ",bestCluster->GetTDC()));
ca270b6d 458 Double_t tof=AliTOFGeometry::TdcBinWidth()*bestCluster->GetTDC()+32; // in ps
d686d062 459 AliDebug(2,Form(" tof time of the matched track: %f = ",tof));
460 Double_t tofcorr=tof;
461 if(timeWalkCorr)tofcorr=CorrectTimeWalk(dzTW,tof);
462 AliDebug(2,Form(" tof time of the matched track, after TW corr: %f = ",tofcorr));
463 //Set TOF time signal and pointer to the matched cluster
464 t->SetTOFsignal(tofcorr);
465 t->SetTOFcluster(idclus); // pointing to the recPoints tree
466 t->SetTOFLabel(tlab);
467
468 Double_t mom=t->GetP();
469 // Fill Reco-QA histos for Reconstruction
470 fHRecNClus->Fill(nc);
471 fHRecChi2->Fill(bestChi2);
472 fHRecDistZ->Fill(dzTW);
473 fHRecSigYVsP->Fill(mom,TMath::Sqrt(cov[0]));
474 fHRecSigZVsP->Fill(mom,TMath::Sqrt(cov[2]));
475 fHRecSigYVsPWin->Fill(mom,dphi*sensRadius);
476 fHRecSigZVsPWin->Fill(mom,dz);
477
478 // Fill Tree for on-the-fly offline Calibration
479 // no longer there - all info is in the ESDs now
480
481 }
d686d062 482
483}
484//_________________________________________________________________________
485Int_t AliTOFtrackerV1::LoadClusters(TTree *cTree) {
486 //--------------------------------------------------------------------
487 //This function loads the TOF clusters
488 //--------------------------------------------------------------------
489
ca270b6d 490 Int_t npadX = AliTOFGeometry::NpadX();
491 Int_t npadZ = AliTOFGeometry::NpadZ();
492 Int_t nStripA = AliTOFGeometry::NStripA();
493 Int_t nStripB = AliTOFGeometry::NStripB();
494 Int_t nStripC = AliTOFGeometry::NStripC();
d686d062 495
496 TBranch *branch=cTree->GetBranch("TOF");
497 if (!branch) {
498 AliError("can't get the branch with the TOF clusters !");
499 return 1;
500 }
501
b42a5ea1 502 static TClonesArray dummy("AliTOFcluster",10000);
503 dummy.Clear();
504 TClonesArray *clusters=&dummy;
d686d062 505 branch->SetAddress(&clusters);
506
507 cTree->GetEvent(0);
508 Int_t nc=clusters->GetEntriesFast();
509 fHDigNClus->Fill(nc);
510
b42a5ea1 511 AliInfo(Form("Number of clusters: %d",nc));
512
d686d062 513 for (Int_t i=0; i<nc; i++) {
514 AliTOFcluster *c=(AliTOFcluster*)clusters->UncheckedAt(i);
515 fClusters[i]=new AliTOFcluster(*c); fN++;
516
517 // Fill Digits QA histos
518
519 Int_t isector = c->GetDetInd(0);
520 Int_t iplate = c->GetDetInd(1);
521 Int_t istrip = c->GetDetInd(2);
522 Int_t ipadX = c->GetDetInd(4);
523 Int_t ipadZ = c->GetDetInd(3);
524
ca270b6d 525 Float_t time =(AliTOFGeometry::TdcBinWidth()*c->GetTDC())*1E-3; // in ns
526 Float_t tot = (AliTOFGeometry::TdcBinWidth()*c->GetToT())*1E-3;//in ns
d686d062 527
528 Int_t stripOffset = 0;
529 switch (iplate) {
530 case 0:
531 stripOffset = 0;
532 break;
533 case 1:
534 stripOffset = nStripC;
535 break;
536 case 2:
537 stripOffset = nStripC+nStripB;
538 break;
539 case 3:
540 stripOffset = nStripC+nStripB+nStripA;
541 break;
542 case 4:
543 stripOffset = nStripC+nStripB+nStripA+nStripB;
544 break;
545 default:
546 AliError(Form("Wrong plate number in TOF (%d) !",iplate));
547 break;
548 };
549 Int_t zindex=npadZ*(istrip+stripOffset)+(ipadZ+1);
550 Int_t phiindex=npadX*isector+ipadX+1;
551 fHDigClusMap->Fill(zindex,phiindex);
552 fHDigClusTime->Fill(time);
553 fHDigClusToT->Fill(tot);
554 }
555
556
557 return 0;
558}
559//_________________________________________________________________________
560void AliTOFtrackerV1::UnloadClusters() {
561 //--------------------------------------------------------------------
562 //This function unloads TOF clusters
563 //--------------------------------------------------------------------
564 for (Int_t i=0; i<fN; i++) {
565 delete fClusters[i];
566 fClusters[i] = 0x0;
567 }
568 fN=0;
569}
570
571//_________________________________________________________________________
572Int_t AliTOFtrackerV1::FindClusterIndex(Double_t z) const {
573 //--------------------------------------------------------------------
574 // This function returns the index of the nearest cluster
575 //--------------------------------------------------------------------
576 //MOD
577 //Here we need to get the Z in the tracking system
578
579 if (fN==0) return 0;
580 if (z <= fClusters[0]->GetZ()) return 0;
581 if (z > fClusters[fN-1]->GetZ()) return fN;
582 Int_t b=0, e=fN-1, m=(b+e)/2;
583 for (; b<e; m=(b+e)/2) {
584 if (z > fClusters[m]->GetZ()) b=m+1;
585 else e=m;
586 }
587 return m;
588}
589
590//_________________________________________________________________________
591Bool_t AliTOFtrackerV1::GetTrackPoint(Int_t index, AliTrackPoint& p) const
592{
593 // Get track space point with index i
594 // Coordinates are in the global system
595 AliTOFcluster *cl = fClusters[index];
596 Float_t xyz[3];
597 cl->GetGlobalXYZ(xyz);
598 Float_t phi=TMath::ATan2(xyz[1],xyz[0]);
599 Float_t phiangle = (Int_t(phi*TMath::RadToDeg()/20.)+0.5)*20.*TMath::DegToRad();
600 Float_t sinphi = TMath::Sin(phiangle), cosphi = TMath::Cos(phiangle);
ca270b6d 601 Float_t tiltangle = AliTOFGeometry::GetAngles(cl->GetDetInd(1),cl->GetDetInd(2))*TMath::DegToRad();
d686d062 602 Float_t sinth = TMath::Sin(tiltangle), costh = TMath::Cos(tiltangle);
ca270b6d 603 Float_t sigmay2 = AliTOFGeometry::XPad()*AliTOFGeometry::XPad()/12.;
604 Float_t sigmaz2 = AliTOFGeometry::ZPad()*AliTOFGeometry::ZPad()/12.;
d686d062 605 Float_t cov[6];
606 cov[0] = sinphi*sinphi*sigmay2 + cosphi*cosphi*sinth*sinth*sigmaz2;
607 cov[1] = -sinphi*cosphi*sigmay2 + sinphi*cosphi*sinth*sinth*sigmaz2;
608 cov[2] = -cosphi*sinth*costh*sigmaz2;
609 cov[3] = cosphi*cosphi*sigmay2 + sinphi*sinphi*sinth*sinth*sigmaz2;
610 cov[4] = -sinphi*sinth*costh*sigmaz2;
611 cov[5] = costh*costh*sigmaz2;
612 p.SetXYZ(xyz[0],xyz[1],xyz[2],cov);
613
614 // Detector numbering scheme
ca270b6d 615 Int_t nSector = AliTOFGeometry::NSectors();
616 Int_t nPlate = AliTOFGeometry::NPlates();
617 Int_t nStripA = AliTOFGeometry::NStripA();
618 Int_t nStripB = AliTOFGeometry::NStripB();
619 Int_t nStripC = AliTOFGeometry::NStripC();
d686d062 620
621 Int_t isector = cl->GetDetInd(0);
622 if (isector >= nSector)
623 AliError(Form("Wrong sector number in TOF (%d) !",isector));
624 Int_t iplate = cl->GetDetInd(1);
625 if (iplate >= nPlate)
626 AliError(Form("Wrong plate number in TOF (%d) !",iplate));
627 Int_t istrip = cl->GetDetInd(2);
628
629 Int_t stripOffset = 0;
630 switch (iplate) {
631 case 0:
632 stripOffset = 0;
633 break;
634 case 1:
635 stripOffset = nStripC;
636 break;
637 case 2:
638 stripOffset = nStripC+nStripB;
639 break;
640 case 3:
641 stripOffset = nStripC+nStripB+nStripA;
642 break;
643 case 4:
644 stripOffset = nStripC+nStripB+nStripA+nStripB;
645 break;
646 default:
647 AliError(Form("Wrong plate number in TOF (%d) !",iplate));
648 break;
649 };
650
651 Int_t idet = (2*(nStripC+nStripB)+nStripA)*isector +
652 stripOffset +
653 istrip;
654 UShort_t volid = AliGeomManager::LayerToVolUID(AliGeomManager::kTOF,idet);
655 p.SetVolumeID((UShort_t)volid);
656 return kTRUE;
657}
658//_________________________________________________________________________
659void AliTOFtrackerV1::InitCheckHists() {
660
661 //Init histos for Digits/Reco QA and Calibration
662
3a646035 663 TDirectory *dir = gDirectory;
664 TFile *logFileTOF = 0;
665
666 TSeqCollection *list = gROOT->GetListOfFiles();
667 int n = list->GetEntries();
668 Bool_t isThere=kFALSE;
669 for(int i=0; i<n; i++) {
670 logFileTOF = (TFile*)list->At(i);
671 if (strstr(logFileTOF->GetName(), "TOFQA.root")){
672 isThere=kTRUE;
673 break;
674 }
675 }
676
677 if(!isThere)logFileTOF = new TFile( "TOFQA.root","RECREATE");
678 logFileTOF->cd();
679
d686d062 680 //Digits "QA"
681 fHDigClusMap = new TH2F("TOFDig_ClusMap", "",182,0.5,182.5,864, 0.5,864.5);
682 fHDigNClus = new TH1F("TOFDig_NClus", "",200,0.5,200.5);
683 fHDigClusTime = new TH1F("TOFDig_ClusTime", "",2000,0.,200.);
684 fHDigClusToT = new TH1F("TOFDig_ClusToT", "",500,0.,100);
685
686 //Reco "QA"
687 fHRecNClus =new TH1F("TOFRec_NClusW", "",50,0.5,50.5);
688 fHRecDistZ=new TH1F("TOFRec_DistZ", "",50,0.5,10.5);
689 fHRecChi2=new TH1F("TOFRec_Chi2", "",100,0.,10.);
690 fHRecSigYVsP=new TH2F("TOFDig_SigYVsP", "",40,0.,4.,100, 0.,5.);
691 fHRecSigZVsP=new TH2F("TOFDig_SigZVsP", "",40,0.,4.,100, 0.,5.);
692 fHRecSigYVsPWin=new TH2F("TOFDig_SigYVsPWin", "",40,0.,4.,100, 0.,50.);
693 fHRecSigZVsPWin=new TH2F("TOFDig_SigZVsPWin", "",40,0.,4.,100, 0.,50.);
3a646035 694
695 dir->cd();
696
d686d062 697}
698
699//_________________________________________________________________________
700void AliTOFtrackerV1::SaveCheckHists() {
701
702 //write histos for Digits/Reco QA and Calibration
703
704 TDirectory *dir = gDirectory;
705 TFile *logFile = 0;
706 TFile *logFileTOF = 0;
707
708 TSeqCollection *list = gROOT->GetListOfFiles();
709 int n = list->GetEntries();
710 for(int i=0; i<n; i++) {
711 logFile = (TFile*)list->At(i);
712 if (strstr(logFile->GetName(), "AliESDs.root")) break;
713 }
714
715 Bool_t isThere=kFALSE;
716 for(int i=0; i<n; i++) {
717 logFileTOF = (TFile*)list->At(i);
718 if (strstr(logFileTOF->GetName(), "TOFQA.root")){
719 isThere=kTRUE;
720 break;
721 }
722 }
723
3a646035 724 if(!isThere) {
725 AliError(Form("File TOFQA.root not found!! not wring histograms...."));
726 return;
727 }
d686d062 728 logFile->cd();
729 fHDigClusMap->Write(fHDigClusMap->GetName(), TObject::kOverwrite);
730 fHDigNClus->Write(fHDigNClus->GetName(), TObject::kOverwrite);
731 fHDigClusTime->Write(fHDigClusTime->GetName(), TObject::kOverwrite);
732 fHDigClusToT->Write(fHDigClusToT->GetName(), TObject::kOverwrite);
733 fHRecNClus->Write(fHRecNClus->GetName(), TObject::kOverwrite);
734 fHRecChi2->Write(fHRecChi2->GetName(), TObject::kOverwrite);
735 fHRecDistZ->Write(fHRecDistZ->GetName(), TObject::kOverwrite);
736 fHRecSigYVsP->Write(fHRecSigYVsP->GetName(), TObject::kOverwrite);
737 fHRecSigZVsP->Write(fHRecSigZVsP->GetName(), TObject::kOverwrite);
738 fHRecSigYVsPWin->Write(fHRecSigYVsPWin->GetName(), TObject::kOverwrite);
739 fHRecSigZVsPWin->Write(fHRecSigZVsPWin->GetName(), TObject::kOverwrite);
740 logFile->Flush();
741
d686d062 742 dir->cd();
3a646035 743
d686d062 744 }
745//_________________________________________________________________________
746Float_t AliTOFtrackerV1::CorrectTimeWalk( Float_t dist, Float_t tof) {
747
748 //dummy, for the moment
749 Float_t tofcorr=0.;
ca270b6d 750 if(dist<AliTOFGeometry::ZPad()*0.5){
d686d062 751 tofcorr=tof;
752 //place here the actual correction
753 }else{
754 tofcorr=tof;
755 }
756 return tofcorr;
757}
758//_________________________________________________________________________
759Float_t AliTOFtrackerV1::GetTimeZerofromT0(AliESDEvent *event) const {
760
761 //Returns TimeZero as measured by T0 detector
762
763 return event->GetT0();
764}
765//_________________________________________________________________________
766Float_t AliTOFtrackerV1::GetTimeZerofromTOF(AliESDEvent * /*event*/) const {
767
768 //dummy, for the moment. T0 algorithm using tracks on TOF
769 {
770 //place T0 algo here...
771 }
772 return 0.;
773}
128563f6 774//_________________________________________________________________________
775
776void AliTOFtrackerV1::FillClusterArray(TObjArray* arr) const
777{
778 //
779 // Returns the TOF cluster array
780 //
781
782 if (fN==0)
783 arr = 0x0;
784 else
785 for (Int_t i=0; i<fN; ++i) arr->Add(fClusters[i]);
786
787}