1 /**************************************************************************
2 * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
4 * Author: The ALICE Off-line Project. *
5 * Contributors are mentioned in the code where appropriate. *
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 **************************************************************************/
16 //--------------------------------------------------------------------//
18 // AliTOFtrackerV1 Class //
19 // Task: Perform association of the ESD tracks to TOF Clusters //
20 // and Update ESD track with associated TOF Cluster parameters //
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 //
27 //--------------------------------------------------------------------//
32 #include <TClonesArray.h>
33 #include <TObjArray.h>
38 #include <TSeqCollection.h>
40 #include "AliESDtrack.h"
41 #include "AliESDEvent.h"
42 #include "AliESDpid.h"
44 #include "AliTrackPointArray.h"
45 #include "AliGeomManager.h"
46 #include "AliCDBManager.h"
48 #include "AliTOFRecoParam.h"
49 #include "AliTOFReconstructor.h"
50 #include "AliTOFcluster.h"
51 #include "AliTOFGeometry.h"
52 #include "AliTOFtrackerV1.h"
53 #include "AliTOFtrack.h"
57 ClassImp(AliTOFtrackerV1)
59 //_____________________________________________________________________________
60 AliTOFtrackerV1::AliTOFtrackerV1():
69 fTracks(new TClonesArray("AliTOFtrack")),
70 fSeeds(new TObjArray(100)),
83 //AliTOFtrackerV1 main Ctor
88 //_____________________________________________________________________________
89 AliTOFtrackerV1::~AliTOFtrackerV1() {
96 if(!(AliCDBManager::Instance()->GetCacheFlag())){
101 delete fHDigClusTime;
108 delete fHRecSigYVsPWin;
109 delete fHRecSigZVsPWin;
121 //_____________________________________________________________________________
122 void AliTOFtrackerV1::GetPidSettings(AliESDpid *esdPID) {
124 // Sets TOF resolution from RecoParams
127 esdPID->GetTOFResponse().SetTimeResolution(fkRecoParam->GetTimeResolution());
129 AliWarning("fkRecoParam not yet set; cannot set PID settings");
131 //_____________________________________________________________________________
132 Int_t AliTOFtrackerV1::PropagateBack(AliESDEvent * const event) {
134 // Gets seeds from ESD event and Match with TOF Clusters
137 // initialize RecoParam for current event
138 AliDebug(1,"Initializing params for TOF");
140 fkRecoParam = AliTOFReconstructor::GetRecoParam(); // instantiate reco param from STEER...
142 if (fkRecoParam == 0x0) {
143 AliFatal("No Reco Param found for TOF!!!");
145 //fkRecoParam->Dump();
146 //if(fkRecoParam->GetApplyPbPbCuts())fkRecoParam=fkRecoParam->GetPbPbparam();
147 //fkRecoParam->PrintParameters();
149 //Initialise some counters
158 Int_t ntrk=event->GetNumberOfTracks();
161 //Load ESD tracks into a local Array of ESD Seeds
162 for (Int_t i=0; i<fNseeds; i++)
163 fSeeds->AddLast(event->GetTrack(i));
165 //Prepare ESD tracks candidates for TOF Matching
171 AliInfo(Form("Number of matched tracks = %d (good = %d, bad = %d)",fnmatch,fngoodmatch,fnbadmatch));
173 //Update the matched ESD tracks
175 for (Int_t i=0; i<ntrk; i++) {
176 AliESDtrack *t=event->GetTrack(i);
177 AliESDtrack *seed =(AliESDtrack*)fSeeds->At(i);
179 if ( (seed->GetStatus()&AliESDtrack::kTOFin)!=0 ) {
180 t->SetStatus(AliESDtrack::kTOFin);
181 //if(seed->GetTOFsignal()>0){
182 if ( (seed->GetStatus()&AliESDtrack::kTOFout)!=0 ) {
183 t->SetStatus(AliESDtrack::kTOFout);
184 t->SetTOFsignal(seed->GetTOFsignal());
185 t->SetTOFcluster(seed->GetTOFcluster());
186 t->SetTOFsignalToT(seed->GetTOFsignalToT());
187 t->SetTOFsignalRaw(seed->GetTOFsignalRaw());
188 t->SetTOFsignalDz(seed->GetTOFsignalDz());
189 t->SetTOFsignalDx(seed->GetTOFsignalDx());
190 t->SetTOFDeltaBC(seed->GetTOFDeltaBC());
191 t->SetTOFL0L1(seed->GetTOFL0L1());
192 t->SetTOFCalChannel(seed->GetTOFCalChannel());
193 Int_t tlab[3]; seed->GetTOFLabel(tlab);
194 t->SetTOFLabel(tlab);
196 Double_t alphaA = (Double_t)t->GetAlpha();
197 Double_t xA = (Double_t)t->GetX();
198 Double_t yA = (Double_t)t->GetY();
199 Double_t zA = (Double_t)t->GetZ();
200 Double_t p1A = (Double_t)t->GetSnp();
201 Double_t p2A = (Double_t)t->GetTgl();
202 Double_t p3A = (Double_t)t->GetSigned1Pt();
203 const Double_t *covA = (Double_t*)t->GetCovariance();
205 // Make attention, please:
206 // AliESDtrack::fTOFInfo array does not be stored in the AliESDs.root file
207 // it is there only for a check during the reconstruction step.
208 Float_t info[10]={0.,0.,0.,0.,0.,0.,0.,0.,0.,0.};
209 seed->GetTOFInfo(info);
211 AliDebug(2,Form(" distance=%f; residual in the pad reference frame: dX=%f, dZ=%f", info[0],info[1],info[2]));
214 // by calling the AliESDtrack::UpdateTrackParams,
215 // the current track parameters are changed
216 // and it could cause refit problems.
217 // We need to update only the following track parameters:
218 // the track length and expected times.
219 // Removed AliESDtrack::UpdateTrackParams call
220 // Called AliESDtrack::SetIntegratedTimes(...) and
221 // AliESDtrack::SetIntegratedLength() routines.
223 AliTOFtrack *track = new AliTOFtrack(*seed);
224 t->UpdateTrackParams(track,AliESDtrack::kTOFout); // to be checked - AdC
226 Double_t time[10]; t->GetIntegratedTimes(time);
229 Double_t time[10]; seed->GetIntegratedTimes(time);
230 t->SetIntegratedTimes(time);
232 Double_t length = seed->GetIntegratedLength();
233 t->SetIntegratedLength(length);
235 Double_t alphaB = (Double_t)t->GetAlpha();
236 Double_t xB = (Double_t)t->GetX();
237 Double_t yB = (Double_t)t->GetY();
238 Double_t zB = (Double_t)t->GetZ();
239 Double_t p1B = (Double_t)t->GetSnp();
240 Double_t p2B = (Double_t)t->GetTgl();
241 Double_t p3B = (Double_t)t->GetSigned1Pt();
242 const Double_t *covB = (Double_t*)t->GetCovariance();
243 AliDebug(2,"Track params -now(before)-:");
244 AliDebug(2,Form(" X: %f(%f), Y: %f(%f), Z: %f(%f) --- alpha: %f(%f)",
249 AliDebug(2,Form(" p1: %f(%f), p2: %f(%f), p3: %f(%f)",
253 AliDebug(2,Form(" cov1: %f(%f), cov2: %f(%f), cov3: %f(%f)"
254 " cov4: %f(%f), cov5: %f(%f), cov6: %f(%f)"
255 " cov7: %f(%f), cov8: %f(%f), cov9: %f(%f)"
256 " cov10: %f(%f), cov11: %f(%f), cov12: %f(%f)"
257 " cov13: %f(%f), cov14: %f(%f), cov15: %f(%f)",
274 AliDebug(3,Form(" %6d %f %f %f %f % %6d %3d %f %f %f %f %f %f",
276 t->GetTOFsignalRaw(),
278 t->GetTOFsignalToT(),
281 t->GetTOFCalChannel(),
283 t->GetIntegratedLength(),
284 time[0], time[1], time[2], time[3], time[4]
296 //_________________________________________________________________________
297 void AliTOFtrackerV1::CollectESD() {
298 //prepare the set of ESD tracks to be matched to clusters in TOF
303 TClonesArray &aTOFTrack = *fTracks;
304 for (Int_t i=0; i<fNseeds; i++) {
306 AliESDtrack *t =(AliESDtrack*)fSeeds->At(i);
307 if ((t->GetStatus()&AliESDtrack::kTPCout)==0)continue;
309 AliTOFtrack *track = new AliTOFtrack(*t); // New
310 Float_t x = (Float_t)track->GetX(); //New
312 // TRD 'good' tracks, already propagated at 371 cm
313 if ( ( (t->GetStatus()&AliESDtrack::kTRDout)!=0 ) &&
314 ( x >= AliTOFGeometry::Rmin() ) ) {
315 if ( track->PropagateToInnerTOF() ) {
317 AliDebug(1,Form(" TRD propagated track till rho = %fcm."
318 " And then the track has been propagated till rho = %fcm.",
319 x, (Float_t)track->GetX()));
321 track->SetSeedIndex(i);
322 t->UpdateTrackParams(track,AliESDtrack::kTOFin);
323 new(aTOFTrack[fNseedsTOF]) AliTOFtrack(*track);
330 // Propagate the rest of TPCbp
332 if ( track->PropagateToInnerTOF() ) {
334 AliDebug(1,Form(" TRD propagated track till rho = %fcm."
335 " And then the track has been propagated till rho = %fcm.",
336 x, (Float_t)track->GetX()));
338 track->SetSeedIndex(i);
339 t->UpdateTrackParams(track,AliESDtrack::kTOFin);
340 new(aTOFTrack[fNseedsTOF]) AliTOFtrack(*track);
348 AliInfo(Form("Number of TOF seeds = %d (Type 1 = %d, Type 2 = %d)",fNseedsTOF,seedsTOF1,seedsTOF2));
350 // Sort according uncertainties on track position
354 //_________________________________________________________________________
355 void AliTOFtrackerV1::MatchTracks( ){
357 //Match ESD tracks to clusters in TOF
361 // Parameters regulating the reconstruction
362 Float_t dY=AliTOFGeometry::XPad();
363 Float_t dZ=AliTOFGeometry::ZPad();
365 const Float_t kTimeOffset = 32.; // time offset for tracking algorithm [ps]
367 const Int_t kncmax = 100;
368 Float_t sensRadius = fkRecoParam->GetSensRadius();
369 Float_t scaleFact = fkRecoParam->GetWindowScaleFact();
370 Float_t dyMax=fkRecoParam->GetWindowSizeMaxY();
371 Float_t dzMax=fkRecoParam->GetWindowSizeMaxZ();
372 Double_t maxChi2=fkRecoParam->GetMaxChi2();
373 Bool_t timeWalkCorr = fkRecoParam->GetTimeWalkCorr();
374 AliDebug(1,"++++++++++++++TOF Reconstruction Parameters:++++++++++++ \n");
375 AliDebug(1,Form("TOF sens radius: %f",sensRadius));
376 AliDebug(1,Form("TOF Window scale factor: %f",scaleFact));
377 AliDebug(1,Form("TOF Window max dy: %f",dyMax));
378 AliDebug(1,Form("TOF Window max dz: %f",dzMax));
379 AliDebug(1,Form("TOF Max Chi2: %f",maxChi2));
380 AliDebug(1,Form("Time Walk Correction? : %d",timeWalkCorr));
384 for (Int_t iseed=0; iseed<fNseedsTOF; iseed++) {
386 AliTOFtrack *track =(AliTOFtrack*)fTracks->UncheckedAt(iseed);
387 AliESDtrack *t =(AliESDtrack*)fSeeds->At(track->GetSeedIndex());
388 //if ( t->GetTOFsignal()>0. ) continue;
389 if ( (t->GetStatus()&AliESDtrack::kTOFout)!=0 ) continue;
390 AliTOFtrack *trackTOFin = new AliTOFtrack(*track);
392 // Determine a window around the track
393 Double_t x,par[5]; trackTOFin->GetExternalParameters(x,par);
394 Double_t cov[15]; trackTOFin->GetExternalCovariance(cov);
396 if (cov[0]<0. || cov[2]<0.) {
397 AliWarning(Form("Very strange track (%d)! At least one of its covariance matrix diagonal elements is negative!",iseed));
403 Double_t dz = scaleFact*3.*TMath::Sqrt(TMath::Abs(cov[2])+dZ*dZ/12.);
404 Double_t dphi = scaleFact*3.*TMath::Sqrt(TMath::Abs(cov[0])+dY*dY/12.)/sensRadius;
406 Double_t phi=TMath::ATan2(par[0],x) + trackTOFin->GetAlpha();
407 if (phi<-TMath::Pi())phi+=2*TMath::Pi();
408 if (phi>=TMath::Pi())phi-=2*TMath::Pi();
410 //upper limit on window's size.
411 if (dz> dzMax) dz=dzMax;
412 if (dphi*sensRadius> dyMax) dphi=dyMax/sensRadius;
414 // find the clusters inside the selected window
416 AliTOFcluster *clusters[kncmax]; // pointers to the clusters in the window
417 Int_t index[kncmax];//to keep track of the cluster index
418 for (Int_t k=FindClusterIndex(z-dz); k<fN; k++) {
419 AliTOFcluster *c=fClusters[k];
420 // if(nc>kncmax)break; /* R+ fix (buffer overflow) */
422 AliWarning("No more matchable clusters can be stored! Please, increase the corresponding vectors size.");
423 break; /* R+ fix (buffer overflow protection) */
425 if (c->GetZ() > z+dz) break;
426 if (c->IsUsed()) continue;
427 if (!c->GetStatus()) {
428 AliDebug(1,"Cluster in channel declared bad!");
429 continue; // skip bad channels as declared in OCDB
431 Float_t xyz[3]; c->GetGlobalXYZ(xyz);
432 Double_t clPhi=TMath::ATan2(xyz[1],xyz[0]);
433 Double_t dph=TMath::Abs(clPhi-phi);
434 if (dph>TMath::Pi()) dph-=2.*TMath::Pi();
435 if (TMath::Abs(dph)>dphi) continue;
441 AliDebug(1,Form(" Number of matchable TOF clusters for the track number %d: %d",iseed,nc));
443 //start propagation: go to the average TOF pad middle plane at ~379.5 cm
445 Float_t xTOF = sensRadius;
446 Double_t ymax = xTOF*TMath::Tan(0.5*AliTOFGeometry::GetAlpha());
447 Bool_t skip = kFALSE;
448 Double_t ysect = trackTOFin->GetYat(xTOF,skip);
451 if (!trackTOFin->Rotate(AliTOFGeometry::GetAlpha())) {
454 } else if (ysect <-ymax) {
455 if (!trackTOFin->Rotate(-AliTOFGeometry::GetAlpha())) {
459 if(!trackTOFin->PropagateTo(xTOF)) {
464 AliTOFcluster *bestCluster=0;
465 Double_t bestChi2=maxChi2;
467 // for (Int_t i=0; i<nc; i++){ /* R+ fix (unsafe) */
468 for (Int_t i=0; i<nc && i<kncmax; i++){ /* R+ fix (buffer overflow protection) */
469 AliTOFcluster *c=clusters[i]; // one of the preselected clusters
470 Double_t chi2=trackTOFin->GetPredictedChi2((AliCluster3D*)c);
471 if (chi2 >= bestChi2) continue;
477 if (!bestCluster) { // no matching , go to the next track
485 AliDebug(2, Form("%7i %7i %10i %10i %10i %10i %7i",
488 TMath::Abs(trackTOFin->GetLabel()),
489 bestCluster->GetLabel(0),
490 bestCluster->GetLabel(1),
491 bestCluster->GetLabel(2),
496 (bestCluster->GetLabel(0)==TMath::Abs(trackTOFin->GetLabel()))
498 (bestCluster->GetLabel(1)==TMath::Abs(trackTOFin->GetLabel()))
500 (bestCluster->GetLabel(2)==TMath::Abs(trackTOFin->GetLabel()))
503 AliDebug(2,Form(" track label good %5d",trackTOFin->GetLabel()));
508 AliDebug(2,Form(" track label bad %5d",trackTOFin->GetLabel()));
511 //Propagate the track to the best matched cluster
512 trackTOFin->PropagateTo(bestCluster);
514 // Fill the track residual histograms.
515 FillResiduals(trackTOFin,bestCluster,kFALSE);
517 //now take the local distance in Z from the pad center for time walk correction
518 Float_t tiltangle = AliTOFGeometry::GetAngles(bestCluster->GetDetInd(1),bestCluster->GetDetInd(2))*TMath::DegToRad();
519 Double_t dzTW=trackTOFin->GetZ()-bestCluster->GetZ(); // in cm - in the ALICE RF -
520 dzTW/=TMath::Cos(tiltangle); // from ALICE/tracking RF to pad RF (1)
521 dzTW=-dzTW; // from ALICE/tracking RF to pad RF (2)
522 if (tiltangle!=0.) AliDebug(2,Form(" rho_track = %f --- rho_cluster = %f ",trackTOFin->GetX(),bestCluster->GetX()));
524 //update the ESD track and delete the TOFtrack
525 t->UpdateTrackParams(trackTOFin,AliESDtrack::kTOFout);
527 // Store quantities to be used in the TOF Calibration
528 Float_t tToT=AliTOFGeometry::ToTBinWidth()*bestCluster->GetToT()*1E-3; // in ns
529 t->SetTOFsignalToT(tToT);
530 Float_t rawTime=AliTOFGeometry::TdcBinWidth()*bestCluster->GetTDCRAW()+kTimeOffset; // RAW time,in ps
531 t->SetTOFsignalRaw(rawTime);
532 t->SetTOFsignalDz(dzTW);
534 Float_t deltaY = trackTOFin->GetY()-bestCluster->GetY();
535 t->SetTOFsignalDx(deltaY);
537 t->SetTOFDeltaBC(bestCluster->GetDeltaBC());
538 t->SetTOFL0L1(bestCluster->GetL0L1Latency());
540 Float_t distR = (trackTOFin->GetX()-bestCluster->GetX())*
541 (trackTOFin->GetX()-bestCluster->GetX());
542 distR+=deltaY*deltaY;
544 distR = TMath::Sqrt(distR);
545 Float_t info[10] = {distR, deltaY, dzTW,
546 0.,0.,0.,0.,0.,0.,0.};
550 ind[0]=bestCluster->GetDetInd(0);
551 ind[1]=bestCluster->GetDetInd(1);
552 ind[2]=bestCluster->GetDetInd(2);
553 ind[3]=bestCluster->GetDetInd(3);
554 ind[4]=bestCluster->GetDetInd(4);
555 Int_t calindex = AliTOFGeometry::GetIndex(ind);
556 t->SetTOFCalChannel(calindex);
558 // keep track of the track labels in the matched cluster
560 tlab[0]=bestCluster->GetLabel(0);
561 tlab[1]=bestCluster->GetLabel(1);
562 tlab[2]=bestCluster->GetLabel(2);
563 AliDebug(2,Form(" tdc time of the matched track %6d = ",bestCluster->GetTDC()));
564 Double_t tof=AliTOFGeometry::TdcBinWidth()*bestCluster->GetTDC()+kTimeOffset; // in ps
565 AliDebug(2,Form(" tof time of the matched track: %f = ",tof));
566 Double_t tofcorr=tof;
567 if(timeWalkCorr)tofcorr=CorrectTimeWalk(dzTW,tof);
568 AliDebug(2,Form(" tof time of the matched track, after TW corr: %f = ",tofcorr));
569 //Set TOF time signal and pointer to the matched cluster
570 t->SetTOFsignal(tofcorr);
571 t->SetTOFcluster(idclus); // pointing to the recPoints tree
572 t->SetTOFLabel(tlab);
574 AliDebug(2,Form(" Setting TOF raw time: %f z distance: %f corrected time: %f",rawTime,dzTW,tofcorr));
576 Double_t mom=t->GetP();
577 AliDebug(2,Form(" Momentum for track %d -> %f", iseed,mom));
578 // Fill Reco-QA histos for Reconstruction
579 fHRecNClus->Fill(nc);
580 fHRecChi2->Fill(bestChi2);
581 fHRecDistZ->Fill(dzTW);
583 fHRecSigYVsP->Fill(mom,TMath::Sqrt(cov[0]));
585 fHRecSigYVsP->Fill(mom,-TMath::Sqrt(-cov[0]));
587 fHRecSigZVsP->Fill(mom,TMath::Sqrt(cov[2]));
589 fHRecSigZVsP->Fill(mom,-TMath::Sqrt(-cov[2]));
590 fHRecSigYVsPWin->Fill(mom,dphi*sensRadius);
591 fHRecSigZVsPWin->Fill(mom,dz);
593 // Fill Tree for on-the-fly offline Calibration
594 // no longer there - all info is in the ESDs now
600 //_________________________________________________________________________
601 Int_t AliTOFtrackerV1::LoadClusters(TTree *cTree) {
602 //--------------------------------------------------------------------
603 //This function loads the TOF clusters
604 //--------------------------------------------------------------------
606 Int_t npadX = AliTOFGeometry::NpadX();
607 Int_t npadZ = AliTOFGeometry::NpadZ();
608 Int_t nStripA = AliTOFGeometry::NStripA();
609 Int_t nStripB = AliTOFGeometry::NStripB();
610 Int_t nStripC = AliTOFGeometry::NStripC();
612 TBranch *branch=cTree->GetBranch("TOF");
614 AliError("can't get the branch with the TOF clusters !");
618 static TClonesArray dummy("AliTOFcluster",10000);
620 TClonesArray *clusters=&dummy;
621 branch->SetAddress(&clusters);
624 Int_t nc=clusters->GetEntriesFast();
625 fHDigNClus->Fill(nc);
627 AliInfo(Form("Number of clusters: %d",nc));
629 for (Int_t i=0; i<nc; i++) {
630 AliTOFcluster *c=(AliTOFcluster*)clusters->UncheckedAt(i);
631 //PH fClusters[i]=new AliTOFcluster(*c); fN++;
632 fClusters[i]=c; fN++;
634 // Fill Digits QA histos
636 Int_t isector = c->GetDetInd(0);
637 Int_t iplate = c->GetDetInd(1);
638 Int_t istrip = c->GetDetInd(2);
639 Int_t ipadX = c->GetDetInd(4);
640 Int_t ipadZ = c->GetDetInd(3);
642 Float_t time =(AliTOFGeometry::TdcBinWidth()*c->GetTDC())*1E-3; // in ns
643 Float_t tot = (AliTOFGeometry::TdcBinWidth()*c->GetToT())*1E-3;//in ns
645 Int_t stripOffset = 0;
651 stripOffset = nStripC;
654 stripOffset = nStripC+nStripB;
657 stripOffset = nStripC+nStripB+nStripA;
660 stripOffset = nStripC+nStripB+nStripA+nStripB;
663 AliError(Form("Wrong plate number in TOF (%d) !",iplate));
666 Int_t zindex=npadZ*(istrip+stripOffset)+(ipadZ+1);
667 Int_t phiindex=npadX*isector+ipadX+1;
668 fHDigClusMap->Fill(zindex,phiindex);
669 fHDigClusTime->Fill(time);
670 fHDigClusToT->Fill(tot);
676 //_________________________________________________________________________
677 void AliTOFtrackerV1::UnloadClusters() {
678 //--------------------------------------------------------------------
679 //This function unloads TOF clusters
680 //--------------------------------------------------------------------
681 for (Int_t i=0; i<fN; i++) {
682 //PH delete fClusters[i];
688 //_________________________________________________________________________
689 Int_t AliTOFtrackerV1::FindClusterIndex(Double_t z) const {
690 //--------------------------------------------------------------------
691 // This function returns the index of the nearest cluster
692 //--------------------------------------------------------------------
694 //Here we need to get the Z in the tracking system
697 if (z <= fClusters[0]->GetZ()) return 0;
698 if (z > fClusters[fN-1]->GetZ()) return fN;
699 Int_t b=0, e=fN-1, m=(b+e)/2;
700 for (; b<e; m=(b+e)/2) {
701 if (z > fClusters[m]->GetZ()) b=m+1;
707 //_________________________________________________________________________
708 Bool_t AliTOFtrackerV1::GetTrackPoint(Int_t index, AliTrackPoint& p) const
710 // Get track space point with index i
711 // Coordinates are in the global system
712 AliTOFcluster *cl = fClusters[index];
714 cl->GetGlobalXYZ(xyz);
715 Float_t phi=TMath::ATan2(xyz[1],xyz[0]);
716 Float_t phiangle = (Int_t(phi*TMath::RadToDeg()/20.)+0.5)*20.*TMath::DegToRad();
717 Float_t sinphi = TMath::Sin(phiangle), cosphi = TMath::Cos(phiangle);
718 Float_t tiltangle = AliTOFGeometry::GetAngles(cl->GetDetInd(1),cl->GetDetInd(2))*TMath::DegToRad();
719 Float_t sinth = TMath::Sin(tiltangle), costh = TMath::Cos(tiltangle);
720 Float_t sigmay2 = AliTOFGeometry::XPad()*AliTOFGeometry::XPad()/12.;
721 Float_t sigmaz2 = AliTOFGeometry::ZPad()*AliTOFGeometry::ZPad()/12.;
723 cov[0] = sinphi*sinphi*sigmay2 + cosphi*cosphi*sinth*sinth*sigmaz2;
724 cov[1] = -sinphi*cosphi*sigmay2 + sinphi*cosphi*sinth*sinth*sigmaz2;
725 cov[2] = -cosphi*sinth*costh*sigmaz2;
726 cov[3] = cosphi*cosphi*sigmay2 + sinphi*sinphi*sinth*sinth*sigmaz2;
727 cov[4] = -sinphi*sinth*costh*sigmaz2;
728 cov[5] = costh*costh*sigmaz2;
729 p.SetXYZ(xyz[0],xyz[1],xyz[2],cov);
731 // Detector numbering scheme
732 Int_t nSector = AliTOFGeometry::NSectors();
733 Int_t nPlate = AliTOFGeometry::NPlates();
734 Int_t nStripA = AliTOFGeometry::NStripA();
735 Int_t nStripB = AliTOFGeometry::NStripB();
736 Int_t nStripC = AliTOFGeometry::NStripC();
738 Int_t isector = cl->GetDetInd(0);
739 if (isector >= nSector)
740 AliError(Form("Wrong sector number in TOF (%d) !",isector));
741 Int_t iplate = cl->GetDetInd(1);
742 if (iplate >= nPlate)
743 AliError(Form("Wrong plate number in TOF (%d) !",iplate));
744 Int_t istrip = cl->GetDetInd(2);
746 Int_t stripOffset = 0;
752 stripOffset = nStripC;
755 stripOffset = nStripC+nStripB;
758 stripOffset = nStripC+nStripB+nStripA;
761 stripOffset = nStripC+nStripB+nStripA+nStripB;
764 AliError(Form("Wrong plate number in TOF (%d) !",iplate));
768 Int_t idet = (2*(nStripC+nStripB)+nStripA)*isector +
771 UShort_t volid = AliGeomManager::LayerToVolUID(AliGeomManager::kTOF,idet);
772 p.SetVolumeID((UShort_t)volid);
775 //_________________________________________________________________________
776 void AliTOFtrackerV1::InitCheckHists() {
778 //Init histos for Digits/Reco QA and Calibration
780 TDirectory *dir = gDirectory;
781 TFile *logFileTOF = 0;
783 TSeqCollection *list = gROOT->GetListOfFiles();
784 int n = list->GetEntries();
785 Bool_t isThere=kFALSE;
786 for(int i=0; i<n; i++) {
787 logFileTOF = (TFile*)list->At(i);
788 if (strstr(logFileTOF->GetName(), "TOFQA.root")){
794 if(!isThere)logFileTOF = new TFile( "TOFQA.root","RECREATE");
798 fHDigClusMap = new TH2F("TOFDig_ClusMap", "",182,0.5,182.5,864, 0.5,864.5);
799 fHDigNClus = new TH1F("TOFDig_NClus", "",200,0.5,200.5);
800 fHDigClusTime = new TH1F("TOFDig_ClusTime", "",2000,0.,200.);
801 fHDigClusToT = new TH1F("TOFDig_ClusToT", "",500,0.,100);
804 fHRecNClus =new TH1F("TOFRec_NClusW", "",50,0.5,50.5);
805 fHRecDistZ=new TH1F("TOFRec_DistZ", "",50,0.5,10.5);
806 fHRecChi2=new TH1F("TOFRec_Chi2", "",100,0.,10.);
807 fHRecSigYVsP=new TH2F("TOFDig_SigYVsP", "",40,0.,4.,100, 0.,5.);
808 fHRecSigZVsP=new TH2F("TOFDig_SigZVsP", "",40,0.,4.,100, 0.,5.);
809 fHRecSigYVsPWin=new TH2F("TOFDig_SigYVsPWin", "",40,0.,4.,100, 0.,50.);
810 fHRecSigZVsPWin=new TH2F("TOFDig_SigZVsPWin", "",40,0.,4.,100, 0.,50.);
816 //_________________________________________________________________________
817 void AliTOFtrackerV1::SaveCheckHists() {
819 //write histos for Digits/Reco QA and Calibration
821 TDirectory *dir = gDirectory;
823 TFile *logFileTOF = 0;
825 TSeqCollection *list = gROOT->GetListOfFiles();
826 int n = list->GetEntries();
827 for(int i=0; i<n; i++) {
828 logFile = (TFile*)list->At(i);
829 if (strstr(logFile->GetName(), "AliESDs.root")) break;
832 Bool_t isThere=kFALSE;
833 for(int i=0; i<n; i++) {
834 logFileTOF = (TFile*)list->At(i);
835 if (strstr(logFileTOF->GetName(), "TOFQA.root")){
842 AliError(Form("File TOFQA.root not found!! not wring histograms...."));
846 fHDigClusMap->Write(fHDigClusMap->GetName(), TObject::kOverwrite);
847 fHDigNClus->Write(fHDigNClus->GetName(), TObject::kOverwrite);
848 fHDigClusTime->Write(fHDigClusTime->GetName(), TObject::kOverwrite);
849 fHDigClusToT->Write(fHDigClusToT->GetName(), TObject::kOverwrite);
850 fHRecNClus->Write(fHRecNClus->GetName(), TObject::kOverwrite);
851 fHRecChi2->Write(fHRecChi2->GetName(), TObject::kOverwrite);
852 fHRecDistZ->Write(fHRecDistZ->GetName(), TObject::kOverwrite);
853 fHRecSigYVsP->Write(fHRecSigYVsP->GetName(), TObject::kOverwrite);
854 fHRecSigZVsP->Write(fHRecSigZVsP->GetName(), TObject::kOverwrite);
855 fHRecSigYVsPWin->Write(fHRecSigYVsPWin->GetName(), TObject::kOverwrite);
856 fHRecSigZVsPWin->Write(fHRecSigZVsPWin->GetName(), TObject::kOverwrite);
862 //_________________________________________________________________________
863 Float_t AliTOFtrackerV1::CorrectTimeWalk( Float_t dist, Float_t tof) const {
865 //dummy, for the moment
867 if(dist<AliTOFGeometry::ZPad()*0.5){
869 //place here the actual correction
875 //_________________________________________________________________________
876 Float_t AliTOFtrackerV1::GetTimeZerofromT0(const AliESDEvent * const event) const {
878 //Returns TimeZero as measured by T0 detector
880 return event->GetT0();
882 //_________________________________________________________________________
883 Float_t AliTOFtrackerV1::GetTimeZerofromTOF(AliESDEvent * /*event*/) const {
885 //dummy, for the moment. T0 algorithm using tracks on TOF
887 //place T0 algo here...
891 //_________________________________________________________________________
893 void AliTOFtrackerV1::FillClusterArray(TObjArray* arr) const
896 // Returns the TOF cluster array
902 for (Int_t i=0; i<fN; ++i) arr->Add(fClusters[i]);