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 // AliTOFtracker 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 <TSeqCollection.h>
33 #include <TClonesArray.h>
34 #include <TGeoManager.h>
39 #include "AliGeomManager.h"
40 #include "AliESDtrack.h"
41 #include "AliESDEvent.h"
43 #include "AliTrackPointArray.h"
44 #include "AliCDBManager.h"
46 #include "AliTOFpidESD.h"
47 #include "AliTOFRecoParam.h"
48 #include "AliTOFReconstructor.h"
49 #include "AliTOFcluster.h"
50 #include "AliTOFGeometry.h"
51 #include "AliTOFtracker.h"
52 #include "AliTOFtrack.h"
54 extern TGeoManager *gGeoManager;
57 ClassImp(AliTOFtracker)
59 //_____________________________________________________________________________
60 AliTOFtracker::AliTOFtracker():
71 fTracks(new TClonesArray("AliTOFtrack")),
72 fSeeds(new TClonesArray("AliESDtrack")),
91 //AliTOFtracker main Ctor
93 // Gettimg the geometry
94 fGeom= new AliTOFGeometry();
99 //_____________________________________________________________________________
100 AliTOFtracker::~AliTOFtracker() {
107 if(!(AliCDBManager::Instance()->GetCacheFlag())){
114 delete fHDigClusTime;
120 delete fHRecSigYVsPWin;
121 delete fHRecSigZVsPWin;
135 //_____________________________________________________________________________
136 Int_t AliTOFtracker::PropagateBack(AliESDEvent* event) {
138 // Gets seeds from ESD event and Match with TOF Clusters
141 // initialize RecoParam for current event
143 AliInfo("Initializing params for TOF... ");
145 fRecoParam = AliTOFReconstructor::GetRecoParam(); // instantiate reco param from STEER...
147 if (fRecoParam == 0x0) {
148 AliFatal("No Reco Param found for TOF!!!");
150 //fRecoParam->Dump();
151 //if(fRecoParam->GetApplyPbPbCuts())fRecoParam=fRecoParam->GetPbPbparam();
152 //fRecoParam->PrintParameters();
155 parPID[0]=fRecoParam->GetTimeResolution();
156 parPID[1]=fRecoParam->GetTimeNSigma();
157 fPid=new AliTOFpidESD(parPID);
159 //Initialise some counters
168 Int_t ntrk=event->GetNumberOfTracks();
170 TClonesArray &aESDTrack = *fSeeds;
173 //Load ESD tracks into a local Array of ESD Seeds
175 for (Int_t i=0; i<fNseeds; i++) {
176 AliESDtrack *t=event->GetTrack(i);
177 new(aESDTrack[i]) AliESDtrack(*t);
180 //Prepare ESD tracks candidates for TOF Matching
183 //First Step with Strict Matching Criterion
186 //Second Step with Looser Matching Criterion
189 AliInfo(Form("Number of matched tracks: %d",fnmatch));
190 AliInfo(Form("Number of good matched tracks: %d",fngoodmatch));
191 AliInfo(Form("Number of bad matched tracks: %d",fnbadmatch));
193 //Update the matched ESD tracks
195 for (Int_t i=0; i<ntrk; i++) {
196 AliESDtrack *t=event->GetTrack(i);
197 AliESDtrack *seed =(AliESDtrack*)fSeeds->UncheckedAt(i);
198 if(seed->GetTOFsignal()>0){
199 t->SetTOFsignal(seed->GetTOFsignal());
200 t->SetTOFcluster(seed->GetTOFcluster());
201 t->SetTOFsignalToT(seed->GetTOFsignalToT());
202 t->SetTOFsignalRaw(seed->GetTOFsignalRaw());
203 t->SetTOFsignalDz(seed->GetTOFsignalDz());
204 t->SetTOFCalChannel(seed->GetTOFCalChannel());
205 Int_t tlab[3]; seed->GetTOFLabel(tlab);
206 t->SetTOFLabel(tlab);
207 AliTOFtrack *track = new AliTOFtrack(*seed);
208 t->UpdateTrackParams(track,AliESDtrack::kTOFout);
213 //Handle Time Zero information
215 Double_t timeZero=0.;
216 Double_t timeZeroMax=99999.;
217 Bool_t usetimeZero = fRecoParam->UseTimeZero();
218 Bool_t timeZeroFromT0 = fRecoParam->GetTimeZerofromT0();
219 Bool_t timeZeroFromTOF = fRecoParam->GetTimeZerofromTOF();
221 AliDebug(1,Form("Use Time Zero?: %d",usetimeZero));
222 AliDebug(1,Form("Time Zero from T0? : %d",timeZeroFromT0));
223 AliDebug(1,Form("Time Zero From TOF? : %d",timeZeroFromTOF));
227 timeZero=GetTimeZerofromT0(event);
229 if(timeZeroFromTOF && (timeZero>timeZeroMax || !timeZeroFromT0)){
230 timeZero=GetTimeZerofromTOF(event);
233 AliDebug(2,Form("time Zero used in PID: %f",timeZero));
235 fPid->MakePID(event,timeZero);
242 //_________________________________________________________________________
243 void AliTOFtracker::CollectESD() {
244 //prepare the set of ESD tracks to be matched to clusters in TOF
249 TClonesArray &aTOFTrack = *fTracks;
250 for (Int_t i=0; i<fNseeds; i++) {
252 AliESDtrack *t =(AliESDtrack*)fSeeds->UncheckedAt(i);
253 if ((t->GetStatus()&AliESDtrack::kTPCout)==0)continue;
255 // TRD 'good' tracks, already propagated at 372 cm
257 AliTOFtrack *track = new AliTOFtrack(*t); // New
258 Double_t x = track->GetX(); //New
259 if (((t->GetStatus()&AliESDtrack::kTRDout)!=0 ) &&
260 ( x >= AliTOFGeometry::RinTOF()) ){
261 track->SetSeedIndex(i);
262 t->UpdateTrackParams(track,AliESDtrack::kTOFout);
263 new(aTOFTrack[fNseedsTOF]) AliTOFtrack(*track);
269 // Propagate the rest of TPCbp
272 if(track->PropagateToInnerTOF()){
273 track->SetSeedIndex(i);
274 t->UpdateTrackParams(track,AliESDtrack::kTOFout);
275 new(aTOFTrack[fNseedsTOF]) AliTOFtrack(*track);
283 AliInfo(Form("Number of TOF seeds %i",fNseedsTOF));
284 AliInfo(Form("Number of TOF seeds Type 1 %i",seedsTOF1));
285 AliInfo(Form("Number of TOF seeds Type 2 %i",seedsTOF2));
287 // Sort according uncertainties on track position
291 //_________________________________________________________________________
292 void AliTOFtracker::MatchTracks( Bool_t mLastStep){
295 // Parameters used/regulating the reconstruction
297 static Float_t corrLen=0.75;
298 static Float_t detDepth=15.3;
299 static Float_t padDepth=0.5;
301 Float_t dY=AliTOFGeometry::XPad();
302 Float_t dZ=AliTOFGeometry::ZPad();
304 Float_t sensRadius = fRecoParam->GetSensRadius();
305 Float_t stepSize = fRecoParam->GetStepSize();
306 Float_t scaleFact = fRecoParam->GetWindowScaleFact();
307 Float_t dyMax=fRecoParam->GetWindowSizeMaxY();
308 Float_t dzMax=fRecoParam->GetWindowSizeMaxZ();
309 Float_t dCut=fRecoParam->GetDistanceCut();
310 Double_t maxChi2=fRecoParam->GetMaxChi2TRD();
311 Bool_t timeWalkCorr = fRecoParam->GetTimeWalkCorr();
313 AliDebug(1,"++++++++++++++TOF Reconstruction Parameters:++++++++++++ \n");
314 AliDebug(1,Form("TOF sens radius: %f",sensRadius));
315 AliDebug(1,Form("TOF step size: %f",stepSize));
316 AliDebug(1,Form("TOF Window scale factor: %f",scaleFact));
317 AliDebug(1,Form("TOF Window max dy: %f",dyMax));
318 AliDebug(1,Form("TOF Window max dz: %f",dzMax));
319 AliDebug(1,Form("TOF distance Cut: %f",dCut));
320 AliDebug(1,Form("TOF Max Chi2: %f",maxChi2));
321 AliDebug(1,Form("Time Walk Correction? : %d",timeWalkCorr));
323 //Match ESD tracks to clusters in TOF
326 // Get the number of propagation steps
328 Int_t nSteps=(Int_t)(detDepth/stepSize);
330 //PH Arrays (moved outside of the loop)
332 Float_t * trackPos[4];
333 for (Int_t ii=0; ii<4; ii++) trackPos[ii] = new Float_t[nSteps];
334 Int_t * clind = new Int_t[fN];
336 for (Int_t iseed=0; iseed<fNseedsTOF; iseed++) {
338 AliTOFtrack *track =(AliTOFtrack*)fTracks->UncheckedAt(iseed);
339 AliESDtrack *t =(AliESDtrack*)fSeeds->UncheckedAt(track->GetSeedIndex());
340 if(t->GetTOFsignal()>0. ) continue;
341 AliTOFtrack *trackTOFin =new AliTOFtrack(*track);
347 Float_t distZ[10000];
348 Float_t cxpos[10000];
349 Float_t crecL[10000];
350 TGeoHMatrix global[1000];
352 // Determine a window around the track
355 trackTOFin->GetExternalParameters(x,par);
357 trackTOFin->GetExternalCovariance(cov);
361 ((5*TMath::Sqrt(cov[0]) + 0.5*dY + 2.5*TMath::Abs(par[2]))/sensRadius);
364 (5*TMath::Sqrt(cov[2]) + 0.5*dZ + 2.5*TMath::Abs(par[3]));
366 Double_t phi=TMath::ATan2(par[0],x) + trackTOFin->GetAlpha();
367 if (phi<-TMath::Pi())phi+=2*TMath::Pi();
368 if (phi>=TMath::Pi())phi-=2*TMath::Pi();
371 //upper limit on window's size.
373 if(dz> dzMax) dz=dzMax;
374 if(dphi*sensRadius> dyMax) dphi=dyMax/sensRadius;
379 // find the clusters in the window of the track
381 for (Int_t k=FindClusterIndex(z-dz); k<fN; k++) {
383 AliTOFcluster *c=fClusters[k];
384 if (c->GetZ() > z+dz) break;
385 if (c->IsUsed()) continue;
387 if (!c->GetStatus()) {
388 AliDebug(1,"Cluster in channel declared bad!");
389 continue; // skip bad channels as declared in OCDB
392 Double_t dph=TMath::Abs(c->GetPhi()-phi);
393 if (dph>TMath::Pi()) dph-=2.*TMath::Pi();
394 if (TMath::Abs(dph)>dphi) continue;
396 Double_t yc=(c->GetPhi() - trackTOFin->GetAlpha())*c->GetR();
397 Double_t p[2]={yc, c->GetZ()};
398 Double_t cov2[3]= {dY*dY/12., 0., dZ*dZ/12.};
399 if (trackTOFin->AliExternalTrackParam::GetPredictedChi2(p,cov2) > maxChi2)continue;
404 ind[0]=c->GetDetInd(0);
405 ind[1]=c->GetDetInd(1);
406 ind[2]=c->GetDetInd(2);
407 ind[3]=c->GetDetInd(3);
408 ind[4]=c->GetDetInd(4);
409 fGeom->GetVolumePath(ind,path);
410 gGeoManager->cd(path);
411 global[nc] = *gGeoManager->GetCurrentMatrix();
415 //start fine propagation
417 Int_t nStepsDone = 0;
418 for( Int_t istep=0; istep<nSteps; istep++){
420 Float_t xs=AliTOFGeometry::RinTOF()+istep*0.1;
421 Double_t ymax=xs*TMath::Tan(0.5*AliTOFGeometry::GetAlpha());
424 Double_t ysect=trackTOFin->GetYat(xs,skip);
427 if (!trackTOFin->Rotate(AliTOFGeometry::GetAlpha())) {
430 } else if (ysect <-ymax) {
431 if (!trackTOFin->Rotate(AliTOFGeometry::GetAlpha())) {
436 if(!trackTOFin->PropagateTo(xs)) {
442 // store the running point (Globalrf) - fine propagation
445 trackTOFin->GetXYZ(r);
446 trackPos[0][istep]= (Float_t) r[0];
447 trackPos[1][istep]= (Float_t) r[1];
448 trackPos[2][istep]= (Float_t) r[2];
449 trackPos[3][istep]= trackTOFin->GetIntegratedLength();
454 Bool_t accept = kFALSE;
455 Bool_t isInside =kFALSE;
456 for (Int_t istep=0; istep<nStepsDone; istep++) {
458 Float_t ctrackPos[3];
460 ctrackPos[0]= trackPos[0][istep];
461 ctrackPos[1]= trackPos[1][istep];
462 ctrackPos[2]= trackPos[2][istep];
464 //now see whether the track matches any of the TOF clusters
468 for (Int_t i=0; i<nc; i++){
469 isInside=fGeom->IsInsideThePad(global[i],ctrackPos,dist3d);
472 Float_t xLoc=dist3d[0];
473 Float_t rLoc=TMath::Sqrt(dist3d[1]*dist3d[1]+dist3d[2]*dist3d[2]);
474 accept = (TMath::Abs(xLoc)<padDepth*0.5 && rLoc<dCut);
480 dist[nfound]=TMath::Sqrt(dist3d[0]*dist3d[0]+dist3d[1]*dist3d[1]+dist3d[2]*dist3d[2]);
481 distZ[nfound]=dist3d[2];
482 crecL[nfound]=trackPos[3][istep];
483 index[nfound]=clind[i]; // store cluster id
484 cxpos[nfound]=AliTOFGeometry::RinTOF()+istep*0.1; //store prop.radius
486 if(accept &&!mLastStep)break;
488 } //end for on the clusters
489 if(accept &&!mLastStep)break;
490 } //end for on the steps
502 // now choose the cluster to be matched with the track.
507 Float_t mindist=1000.;
509 for (Int_t iclus= 0; iclus<nfound;iclus++){
510 if (dist[iclus]< mindist){
511 mindist = dist[iclus];
512 mindistZ = distZ[iclus];
514 idclus =index[iclus];
515 recL=crecL[iclus]+corrLen*0.5;
520 AliTOFcluster *c=fClusters[idclus];
522 AliDebug(2, Form("%7i %7i %10i %10i %10i %10i %7i",
525 TMath::Abs(trackTOFin->GetLabel()),
526 c->GetLabel(0), c->GetLabel(1), c->GetLabel(2),
531 // Track length correction for matching Step 2
534 Float_t rc=TMath::Sqrt(c->GetR()*c->GetR() + c->GetZ()*c->GetZ());
535 Float_t rt=TMath::Sqrt(trackPos[0][70]*trackPos[0][70]
536 +trackPos[1][70]*trackPos[1][70]
537 +trackPos[2][70]*trackPos[2][70]);
539 recL=trackPos[3][70]+dlt;
543 (c->GetLabel(0)==TMath::Abs(trackTOFin->GetLabel()))
545 (c->GetLabel(1)==TMath::Abs(trackTOFin->GetLabel()))
547 (c->GetLabel(2)==TMath::Abs(trackTOFin->GetLabel()))
551 AliDebug(2,Form(" track label good %5i",trackTOFin->GetLabel()));
557 AliDebug(2,Form(" track label bad %5i",trackTOFin->GetLabel()));
563 // Store quantities to be used in the TOF Calibration
564 Float_t tToT=AliTOFGeometry::ToTBinWidth()*c->GetToT()*1E-3; // in ns
565 t->SetTOFsignalToT(tToT);
566 Float_t rawTime=AliTOFGeometry::TdcBinWidth()*c->GetTDCRAW()+32; // RAW time,in ps
567 t->SetTOFsignalRaw(rawTime);
568 t->SetTOFsignalDz(mindistZ);
569 AliDebug(2,Form(" Setting TOF raw time: %f, z distance: %f time: %f = ",rawTime,mindistZ));
571 ind[0]=c->GetDetInd(0);
572 ind[1]=c->GetDetInd(1);
573 ind[2]=c->GetDetInd(2);
574 ind[3]=c->GetDetInd(3);
575 ind[4]=c->GetDetInd(4);
576 Int_t calindex = AliTOFGeometry::GetIndex(ind);
577 t->SetTOFCalChannel(calindex);
579 // keep track of the track labels in the matched cluster
581 tlab[0]=c->GetLabel(0);
582 tlab[1]=c->GetLabel(1);
583 tlab[2]=c->GetLabel(2);
584 AliDebug(2,Form(" tdc time of the matched track %i = ",c->GetTDC()));
585 Double_t tof=AliTOFGeometry::TdcBinWidth()*c->GetTDC()+32; // in ps
586 AliDebug(2,Form(" tof time of the matched track: %f = ",tof));
587 Double_t tofcorr=tof;
588 if(timeWalkCorr)tofcorr=CorrectTimeWalk(mindistZ,tof);
589 AliDebug(2,Form(" tof time of the matched track, after TW corr: %f = ",tofcorr));
590 //Set TOF time signal and pointer to the matched cluster
591 t->SetTOFsignal(tofcorr);
592 t->SetTOFcluster(idclus); // pointing to the recPoints tree
595 Double_t time[AliPID::kSPECIES]; t->GetIntegratedTimes(time);
596 Double_t mom=t->GetP();
597 for(Int_t j=0;j<AliPID::kSPECIES;j++){
598 Double_t mass=AliPID::ParticleMass(j);
599 time[j]+=(recL-trackPos[3][0])/3e-2*TMath::Sqrt(mom*mom+mass*mass)/mom;
602 AliTOFtrack *trackTOFout = new AliTOFtrack(*t);
603 trackTOFout->PropagateTo(xpos);
605 // Fill the track residual histograms.
606 FillResiduals(trackTOFout,c,kFALSE);
608 t->UpdateTrackParams(trackTOFout,AliESDtrack::kTOFout);
609 t->SetIntegratedLength(recL);
610 t->SetIntegratedTimes(time);
611 t->SetTOFLabel(tlab);
614 // Fill Reco-QA histos for Reconstruction
615 fHRecNClus->Fill(nc);
616 fHRecDist->Fill(mindist);
617 fHRecSigYVsP->Fill(mom,TMath::Sqrt(cov[0]));
618 fHRecSigZVsP->Fill(mom,TMath::Sqrt(cov[2]));
619 fHRecSigYVsPWin->Fill(mom,dphi*sensRadius);
620 fHRecSigZVsPWin->Fill(mom,dz);
622 // Fill Tree for on-the-fly offline Calibration
624 if ( !((t->GetStatus() & AliESDtrack::kTIME)==0 )){
635 for (Int_t ii=0; ii<4; ii++) delete [] trackPos[ii];
639 //_________________________________________________________________________
640 Int_t AliTOFtracker::LoadClusters(TTree *cTree) {
641 //--------------------------------------------------------------------
642 //This function loads the TOF clusters
643 //--------------------------------------------------------------------
645 Int_t npadX = AliTOFGeometry::NpadX();
646 Int_t npadZ = AliTOFGeometry::NpadZ();
647 Int_t nStripA = AliTOFGeometry::NStripA();
648 Int_t nStripB = AliTOFGeometry::NStripB();
649 Int_t nStripC = AliTOFGeometry::NStripC();
651 TBranch *branch=cTree->GetBranch("TOF");
653 AliError("can't get the branch with the TOF clusters !");
657 static TClonesArray dummy("AliTOFcluster",10000);
659 TClonesArray *clusters=&dummy;
660 branch->SetAddress(&clusters);
663 Int_t nc=clusters->GetEntriesFast();
664 fHDigNClus->Fill(nc);
666 AliInfo(Form("Number of clusters: %d",nc));
668 for (Int_t i=0; i<nc; i++) {
669 AliTOFcluster *c=(AliTOFcluster*)clusters->UncheckedAt(i);
670 fClusters[i]=new AliTOFcluster(*c); fN++;
672 // Fill Digits QA histos
674 Int_t isector = c->GetDetInd(0);
675 Int_t iplate = c->GetDetInd(1);
676 Int_t istrip = c->GetDetInd(2);
677 Int_t ipadX = c->GetDetInd(4);
678 Int_t ipadZ = c->GetDetInd(3);
680 Float_t time =(AliTOFGeometry::TdcBinWidth()*c->GetTDC())*1E-3; // in ns
681 Float_t tot = (AliTOFGeometry::TdcBinWidth()*c->GetToT())*1E-3;//in ns
683 Int_t stripOffset = 0;
689 stripOffset = nStripC;
692 stripOffset = nStripC+nStripB;
695 stripOffset = nStripC+nStripB+nStripA;
698 stripOffset = nStripC+nStripB+nStripA+nStripB;
701 AliError(Form("Wrong plate number in TOF (%d) !",iplate));
704 Int_t zindex=npadZ*(istrip+stripOffset)+(ipadZ+1);
705 Int_t phiindex=npadX*isector+ipadX+1;
706 fHDigClusMap->Fill(zindex,phiindex);
707 fHDigClusTime->Fill(time);
708 fHDigClusToT->Fill(tot);
715 //_________________________________________________________________________
716 void AliTOFtracker::UnloadClusters() {
717 //--------------------------------------------------------------------
718 //This function unloads TOF clusters
719 //--------------------------------------------------------------------
720 for (Int_t i=0; i<fN; i++) {
727 //_________________________________________________________________________
728 Int_t AliTOFtracker::FindClusterIndex(Double_t z) const {
729 //--------------------------------------------------------------------
730 // This function returns the index of the nearest cluster
731 //--------------------------------------------------------------------
733 if (z <= fClusters[0]->GetZ()) return 0;
734 if (z > fClusters[fN-1]->GetZ()) return fN;
735 Int_t b=0, e=fN-1, m=(b+e)/2;
736 for (; b<e; m=(b+e)/2) {
737 if (z > fClusters[m]->GetZ()) b=m+1;
743 //_________________________________________________________________________
744 Bool_t AliTOFtracker::GetTrackPoint(Int_t index, AliTrackPoint& p) const
746 // Get track space point with index i
747 // Coordinates are in the global system
748 AliTOFcluster *cl = fClusters[index];
750 xyz[0] = cl->GetR()*TMath::Cos(cl->GetPhi());
751 xyz[1] = cl->GetR()*TMath::Sin(cl->GetPhi());
753 Float_t phiangle = (Int_t(cl->GetPhi()*TMath::RadToDeg()/20.)+0.5)*20.*TMath::DegToRad();
754 Float_t sinphi = TMath::Sin(phiangle), cosphi = TMath::Cos(phiangle);
755 Float_t tiltangle = AliTOFGeometry::GetAngles(cl->GetDetInd(1),cl->GetDetInd(2))*TMath::DegToRad();
756 Float_t sinth = TMath::Sin(tiltangle), costh = TMath::Cos(tiltangle);
757 Float_t sigmay2 = AliTOFGeometry::XPad()*AliTOFGeometry::XPad()/12.;
758 Float_t sigmaz2 = AliTOFGeometry::ZPad()*AliTOFGeometry::ZPad()/12.;
760 cov[0] = sinphi*sinphi*sigmay2 + cosphi*cosphi*sinth*sinth*sigmaz2;
761 cov[1] = -sinphi*cosphi*sigmay2 + sinphi*cosphi*sinth*sinth*sigmaz2;
762 cov[2] = -cosphi*sinth*costh*sigmaz2;
763 cov[3] = cosphi*cosphi*sigmay2 + sinphi*sinphi*sinth*sinth*sigmaz2;
764 cov[4] = -sinphi*sinth*costh*sigmaz2;
765 cov[5] = costh*costh*sigmaz2;
766 p.SetXYZ(xyz[0],xyz[1],xyz[2],cov);
768 // Detector numbering scheme
769 Int_t nSector = AliTOFGeometry::NSectors();
770 Int_t nPlate = AliTOFGeometry::NPlates();
771 Int_t nStripA = AliTOFGeometry::NStripA();
772 Int_t nStripB = AliTOFGeometry::NStripB();
773 Int_t nStripC = AliTOFGeometry::NStripC();
775 Int_t isector = cl->GetDetInd(0);
776 if (isector >= nSector)
777 AliError(Form("Wrong sector number in TOF (%d) !",isector));
778 Int_t iplate = cl->GetDetInd(1);
779 if (iplate >= nPlate)
780 AliError(Form("Wrong plate number in TOF (%d) !",iplate));
781 Int_t istrip = cl->GetDetInd(2);
783 Int_t stripOffset = 0;
789 stripOffset = nStripC;
792 stripOffset = nStripC+nStripB;
795 stripOffset = nStripC+nStripB+nStripA;
798 stripOffset = nStripC+nStripB+nStripA+nStripB;
801 AliError(Form("Wrong plate number in TOF (%d) !",iplate));
805 Int_t idet = (2*(nStripC+nStripB)+nStripA)*isector +
808 UShort_t volid = AliGeomManager::LayerToVolUID(AliGeomManager::kTOF,idet);
809 p.SetVolumeID((UShort_t)volid);
812 //_________________________________________________________________________
813 void AliTOFtracker::InitCheckHists() {
815 //Init histos for Digits/Reco QA and Calibration
818 TDirectory *dir = gDirectory;
819 TFile *logFileTOF = 0;
821 TSeqCollection *list = gROOT->GetListOfFiles();
822 int n = list->GetEntries();
823 Bool_t isThere=kFALSE;
824 for(int i=0; i<n; i++) {
825 logFileTOF = (TFile*)list->At(i);
826 if (strstr(logFileTOF->GetName(), "TOFQA.root")){
832 if(!isThere)logFileTOF = new TFile( "TOFQA.root","RECREATE");
835 fCalTree = new TTree("CalTree", "Tree for TOF calibration");
836 fCalTree->Branch("TOFchannelindex",&fIch,"iTOFch/I");
837 fCalTree->Branch("ToT",&fToT,"TOFToT/F");
838 fCalTree->Branch("TOFtime",&fTime,"TOFtime/F");
839 fCalTree->Branch("PionExpTime",&fExpTimePi,"PiExpTime/F");
840 fCalTree->Branch("KaonExpTime",&fExpTimeKa,"KaExpTime/F");
841 fCalTree->Branch("ProtonExpTime",&fExpTimePr,"PrExpTime/F");
844 fHDigClusMap = new TH2F("TOFDig_ClusMap", "",182,0.5,182.5,864, 0.5,864.5);
845 fHDigNClus = new TH1F("TOFDig_NClus", "",200,0.5,200.5);
846 fHDigClusTime = new TH1F("TOFDig_ClusTime", "",2000,0.,200.);
847 fHDigClusToT = new TH1F("TOFDig_ClusToT", "",500,0.,100);
850 fHRecNClus =new TH1F("TOFRec_NClusW", "",50,0.5,50.5);
851 fHRecDist=new TH1F("TOFRec_Dist", "",50,0.5,10.5);
852 fHRecSigYVsP=new TH2F("TOFDig_SigYVsP", "",40,0.,4.,100, 0.,5.);
853 fHRecSigZVsP=new TH2F("TOFDig_SigZVsP", "",40,0.,4.,100, 0.,5.);
854 fHRecSigYVsPWin=new TH2F("TOFDig_SigYVsPWin", "",40,0.,4.,100, 0.,50.);
855 fHRecSigZVsPWin=new TH2F("TOFDig_SigZVsPWin", "",40,0.,4.,100, 0.,50.);
861 //_________________________________________________________________________
862 void AliTOFtracker::SaveCheckHists() {
864 //write histos for Digits/Reco QA and Calibration
866 TDirectory *dir = gDirectory;
867 TFile *logFileTOF = 0;
869 TSeqCollection *list = gROOT->GetListOfFiles();
870 int n = list->GetEntries();
871 Bool_t isThere=kFALSE;
872 for(int i=0; i<n; i++) {
873 logFileTOF = (TFile*)list->At(i);
874 if (strstr(logFileTOF->GetName(), "TOFQA.root")){
881 AliError(Form("File TOFQA.root not found!! not wring histograms...."));
885 fHDigClusMap->Write(fHDigClusMap->GetName(), TObject::kOverwrite);
886 fHDigNClus->Write(fHDigNClus->GetName(), TObject::kOverwrite);
887 fHDigClusTime->Write(fHDigClusTime->GetName(), TObject::kOverwrite);
888 fHDigClusToT->Write(fHDigClusToT->GetName(), TObject::kOverwrite);
889 fHRecNClus->Write(fHRecNClus->GetName(), TObject::kOverwrite);
890 fHRecDist->Write(fHRecDist->GetName(), TObject::kOverwrite);
891 fHRecSigYVsP->Write(fHRecSigYVsP->GetName(), TObject::kOverwrite);
892 fHRecSigZVsP->Write(fHRecSigZVsP->GetName(), TObject::kOverwrite);
893 fHRecSigYVsPWin->Write(fHRecSigYVsPWin->GetName(), TObject::kOverwrite);
894 fHRecSigZVsPWin->Write(fHRecSigZVsPWin->GetName(), TObject::kOverwrite);
895 fCalTree->Write(fCalTree->GetName(),TObject::kOverwrite);
900 //_________________________________________________________________________
901 Float_t AliTOFtracker::CorrectTimeWalk( Float_t dist, Float_t tof) {
903 //dummy, for the moment
905 if(dist<AliTOFGeometry::ZPad()*0.5){
907 //place here the actual correction
913 //_________________________________________________________________________
914 Float_t AliTOFtracker::GetTimeZerofromT0(AliESDEvent *event) const {
916 //Returns TimeZero as measured by T0 detector
918 return event->GetT0();
920 //_________________________________________________________________________
921 Float_t AliTOFtracker::GetTimeZerofromTOF(AliESDEvent * /*event*/) const {
923 //dummy, for the moment. T0 algorithm using tracks on TOF
925 //place T0 algo here...
929 //_________________________________________________________________________
931 void AliTOFtracker::FillClusterArray(TObjArray* arr) const
934 // Returns the TOF cluster array
940 for (Int_t i=0; i<fN; ++i) arr->Add(fClusters[i]);