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(const AliTOFtracker &t):
112 fTracks(new TClonesArray("AliTOFtrack")),
113 fSeeds(new TClonesArray("AliESDtrack")),
122 fHRecSigYVsPWin(0x0),
123 fHRecSigZVsPWin(0x0),
132 //AliTOFtracker copy Ctor
136 fNseedsTOF=t.fNseedsTOF;
137 fngoodmatch=t.fngoodmatch;
138 fnbadmatch=t.fnbadmatch;
139 fnunmatch=t.fnunmatch;
141 fRecoParam=t.fRecoParam;
148 //_____________________________________________________________________________
149 AliTOFtracker& AliTOFtracker::operator=(const AliTOFtracker &t)
151 //AliTOFtracker assignment operator
153 this->fNseeds=t.fNseeds;
154 this->fNseedsTOF=t.fNseedsTOF;
155 this->fngoodmatch=t.fngoodmatch;
156 this->fnbadmatch=t.fnbadmatch;
157 this->fnunmatch=t.fnunmatch;
158 this->fnmatch=t.fnmatch;
159 this->fRecoParam = t.fRecoParam;
162 this->fSeeds=t.fSeeds;
163 this->fTracks=t.fTracks;
168 //_____________________________________________________________________________
169 AliTOFtracker::~AliTOFtracker() {
176 if(!(AliCDBManager::Instance()->GetCacheFlag())){
183 delete fHDigClusTime;
189 delete fHRecSigYVsPWin;
190 delete fHRecSigZVsPWin;
204 //_____________________________________________________________________________
205 Int_t AliTOFtracker::PropagateBack(AliESDEvent* event) {
207 // Gets seeds from ESD event and Match with TOF Clusters
210 // initialize RecoParam for current event
212 AliInfo("Initializing params for TOF... ");
214 fRecoParam = AliTOFReconstructor::GetRecoParam(); // instantiate reco param from STEER...
216 if (fRecoParam == 0x0) {
217 AliFatal("No Reco Param found for TOF!!!");
219 //fRecoParam->Dump();
220 if(fRecoParam->GetApplyPbPbCuts())fRecoParam=fRecoParam->GetPbPbparam();
221 //fRecoParam->PrintParameters();
224 parPID[0]=fRecoParam->GetTimeResolution();
225 parPID[1]=fRecoParam->GetTimeNSigma();
226 fPid=new AliTOFpidESD(parPID);
228 //Initialise some counters
237 Int_t ntrk=event->GetNumberOfTracks();
239 TClonesArray &aESDTrack = *fSeeds;
242 //Load ESD tracks into a local Array of ESD Seeds
244 for (Int_t i=0; i<fNseeds; i++) {
245 AliESDtrack *t=event->GetTrack(i);
246 new(aESDTrack[i]) AliESDtrack(*t);
249 //Prepare ESD tracks candidates for TOF Matching
252 //First Step with Strict Matching Criterion
255 //Second Step with Looser Matching Criterion
258 AliInfo(Form("Number of matched tracks: %d",fnmatch));
259 AliInfo(Form("Number of good matched tracks: %d",fngoodmatch));
260 AliInfo(Form("Number of bad matched tracks: %d",fnbadmatch));
262 //Update the matched ESD tracks
264 for (Int_t i=0; i<ntrk; i++) {
265 AliESDtrack *t=event->GetTrack(i);
266 AliESDtrack *seed =(AliESDtrack*)fSeeds->UncheckedAt(i);
267 if(seed->GetTOFsignal()>0){
268 t->SetTOFsignal(seed->GetTOFsignal());
269 t->SetTOFcluster(seed->GetTOFcluster());
270 t->SetTOFsignalToT(seed->GetTOFsignalToT());
271 t->SetTOFsignalRaw(seed->GetTOFsignalRaw());
272 t->SetTOFsignalDz(seed->GetTOFsignalDz());
273 t->SetTOFCalChannel(seed->GetTOFCalChannel());
274 Int_t tlab[3]; seed->GetTOFLabel(tlab);
275 t->SetTOFLabel(tlab);
276 AliTOFtrack *track = new AliTOFtrack(*seed);
277 t->UpdateTrackParams(track,AliESDtrack::kTOFout);
282 //Handle Time Zero information
284 Double_t timeZero=0.;
285 Double_t timeZeroMax=99999.;
286 Bool_t usetimeZero = fRecoParam->UseTimeZero();
287 Bool_t timeZeroFromT0 = fRecoParam->GetTimeZerofromT0();
288 Bool_t timeZeroFromTOF = fRecoParam->GetTimeZerofromTOF();
290 AliDebug(1,Form("Use Time Zero?: %d",usetimeZero));
291 AliDebug(1,Form("Time Zero from T0? : %d",timeZeroFromT0));
292 AliDebug(1,Form("Time Zero From TOF? : %d",timeZeroFromTOF));
296 timeZero=GetTimeZerofromT0(event);
298 if(timeZeroFromTOF && (timeZero>timeZeroMax || !timeZeroFromT0)){
299 timeZero=GetTimeZerofromTOF(event);
302 AliDebug(2,Form("time Zero used in PID: %f",timeZero));
304 fPid->MakePID(event,timeZero);
311 //_________________________________________________________________________
312 void AliTOFtracker::CollectESD() {
313 //prepare the set of ESD tracks to be matched to clusters in TOF
318 TClonesArray &aTOFTrack = *fTracks;
319 for (Int_t i=0; i<fNseeds; i++) {
321 AliESDtrack *t =(AliESDtrack*)fSeeds->UncheckedAt(i);
322 if ((t->GetStatus()&AliESDtrack::kTPCout)==0)continue;
324 // TRD 'good' tracks, already propagated at 372 cm
326 AliTOFtrack *track = new AliTOFtrack(*t); // New
327 Double_t x = track->GetX(); //New
328 if (((t->GetStatus()&AliESDtrack::kTRDout)!=0 ) &&
329 ( x >= AliTOFGeometry::RinTOF()) ){
330 track->SetSeedIndex(i);
331 t->UpdateTrackParams(track,AliESDtrack::kTOFout);
332 new(aTOFTrack[fNseedsTOF]) AliTOFtrack(*track);
338 // Propagate the rest of TPCbp
341 if(track->PropagateToInnerTOF()){
342 track->SetSeedIndex(i);
343 t->UpdateTrackParams(track,AliESDtrack::kTOFout);
344 new(aTOFTrack[fNseedsTOF]) AliTOFtrack(*track);
352 AliInfo(Form("Number of TOF seeds %i",fNseedsTOF));
353 AliInfo(Form("Number of TOF seeds Type 1 %i",seedsTOF1));
354 AliInfo(Form("Number of TOF seeds Type 2 %i",seedsTOF2));
356 // Sort according uncertainties on track position
360 //_________________________________________________________________________
361 void AliTOFtracker::MatchTracks( Bool_t mLastStep){
364 // Parameters used/regulating the reconstruction
366 static Float_t corrLen=0.75;
367 static Float_t detDepth=15.3;
368 static Float_t padDepth=0.5;
370 Float_t dY=AliTOFGeometry::XPad();
371 Float_t dZ=AliTOFGeometry::ZPad();
373 Float_t sensRadius = fRecoParam->GetSensRadius();
374 Float_t stepSize = fRecoParam->GetStepSize();
375 Float_t scaleFact = fRecoParam->GetWindowScaleFact();
376 Float_t dyMax=fRecoParam->GetWindowSizeMaxY();
377 Float_t dzMax=fRecoParam->GetWindowSizeMaxZ();
378 Float_t dCut=fRecoParam->GetDistanceCut();
379 Double_t maxChi2=fRecoParam->GetMaxChi2TRD();
380 Bool_t timeWalkCorr = fRecoParam->GetTimeWalkCorr();
382 AliDebug(1,"++++++++++++++TOF Reconstruction Parameters:++++++++++++ \n");
383 AliDebug(1,Form("TOF sens radius: %f",sensRadius));
384 AliDebug(1,Form("TOF step size: %f",stepSize));
385 AliDebug(1,Form("TOF Window scale factor: %f",scaleFact));
386 AliDebug(1,Form("TOF Window max dy: %f",dyMax));
387 AliDebug(1,Form("TOF Window max dz: %f",dzMax));
388 AliDebug(1,Form("TOF distance Cut: %f",dCut));
389 AliDebug(1,Form("TOF Max Chi2: %f",maxChi2));
390 AliDebug(1,Form("Time Walk Correction? : %d",timeWalkCorr));
392 //Match ESD tracks to clusters in TOF
395 // Get the number of propagation steps
397 Int_t nSteps=(Int_t)(detDepth/stepSize);
399 //PH Arrays (moved outside of the loop)
401 Float_t * trackPos[4];
402 for (Int_t ii=0; ii<4; ii++) trackPos[ii] = new Float_t[nSteps];
403 Int_t * clind = new Int_t[fN];
405 for (Int_t iseed=0; iseed<fNseedsTOF; iseed++) {
407 AliTOFtrack *track =(AliTOFtrack*)fTracks->UncheckedAt(iseed);
408 AliESDtrack *t =(AliESDtrack*)fSeeds->UncheckedAt(track->GetSeedIndex());
409 if(t->GetTOFsignal()>0. ) continue;
410 AliTOFtrack *trackTOFin =new AliTOFtrack(*track);
416 Float_t distZ[10000];
417 Float_t cxpos[10000];
418 Float_t crecL[10000];
419 TGeoHMatrix global[1000];
421 // Determine a window around the track
424 trackTOFin->GetExternalParameters(x,par);
426 trackTOFin->GetExternalCovariance(cov);
430 ((5*TMath::Sqrt(cov[0]) + 0.5*dY + 2.5*TMath::Abs(par[2]))/sensRadius);
433 (5*TMath::Sqrt(cov[2]) + 0.5*dZ + 2.5*TMath::Abs(par[3]));
435 Double_t phi=TMath::ATan2(par[0],x) + trackTOFin->GetAlpha();
436 if (phi<-TMath::Pi())phi+=2*TMath::Pi();
437 if (phi>=TMath::Pi())phi-=2*TMath::Pi();
440 //upper limit on window's size.
442 if(dz> dzMax) dz=dzMax;
443 if(dphi*sensRadius> dyMax) dphi=dyMax/sensRadius;
448 // find the clusters in the window of the track
450 for (Int_t k=FindClusterIndex(z-dz); k<fN; k++) {
452 AliTOFcluster *c=fClusters[k];
453 if (c->GetZ() > z+dz) break;
454 if (c->IsUsed()) continue;
456 if (!c->GetStatus()) {
457 AliDebug(1,"Cluster in channel declared bad!");
458 continue; // skip bad channels as declared in OCDB
461 Double_t dph=TMath::Abs(c->GetPhi()-phi);
462 if (dph>TMath::Pi()) dph-=2.*TMath::Pi();
463 if (TMath::Abs(dph)>dphi) continue;
465 Double_t yc=(c->GetPhi() - trackTOFin->GetAlpha())*c->GetR();
466 Double_t p[2]={yc, c->GetZ()};
467 Double_t cov2[3]= {dY*dY/12., 0., dZ*dZ/12.};
468 if (trackTOFin->AliExternalTrackParam::GetPredictedChi2(p,cov2) > maxChi2)continue;
473 ind[0]=c->GetDetInd(0);
474 ind[1]=c->GetDetInd(1);
475 ind[2]=c->GetDetInd(2);
476 ind[3]=c->GetDetInd(3);
477 ind[4]=c->GetDetInd(4);
478 fGeom->GetVolumePath(ind,path);
479 gGeoManager->cd(path);
480 global[nc] = *gGeoManager->GetCurrentMatrix();
484 //start fine propagation
486 Int_t nStepsDone = 0;
487 for( Int_t istep=0; istep<nSteps; istep++){
489 Float_t xs=AliTOFGeometry::RinTOF()+istep*0.1;
490 Double_t ymax=xs*TMath::Tan(0.5*AliTOFGeometry::GetAlpha());
493 Double_t ysect=trackTOFin->GetYat(xs,skip);
496 if (!trackTOFin->Rotate(AliTOFGeometry::GetAlpha())) {
499 } else if (ysect <-ymax) {
500 if (!trackTOFin->Rotate(AliTOFGeometry::GetAlpha())) {
505 if(!trackTOFin->PropagateTo(xs)) {
511 // store the running point (Globalrf) - fine propagation
514 trackTOFin->GetXYZ(r);
515 trackPos[0][istep]= (Float_t) r[0];
516 trackPos[1][istep]= (Float_t) r[1];
517 trackPos[2][istep]= (Float_t) r[2];
518 trackPos[3][istep]= trackTOFin->GetIntegratedLength();
523 Bool_t accept = kFALSE;
524 Bool_t isInside =kFALSE;
525 for (Int_t istep=0; istep<nStepsDone; istep++) {
527 Float_t ctrackPos[3];
529 ctrackPos[0]= trackPos[0][istep];
530 ctrackPos[1]= trackPos[1][istep];
531 ctrackPos[2]= trackPos[2][istep];
533 //now see whether the track matches any of the TOF clusters
537 for (Int_t i=0; i<nc; i++){
538 isInside=fGeom->IsInsideThePad(global[i],ctrackPos,dist3d);
541 Float_t xLoc=dist3d[0];
542 Float_t rLoc=TMath::Sqrt(dist3d[1]*dist3d[1]+dist3d[2]*dist3d[2]);
543 accept = (TMath::Abs(xLoc)<padDepth*0.5 && rLoc<dCut);
549 dist[nfound]=TMath::Sqrt(dist3d[0]*dist3d[0]+dist3d[1]*dist3d[1]+dist3d[2]*dist3d[2]);
550 distZ[nfound]=dist3d[2];
551 crecL[nfound]=trackPos[3][istep];
552 index[nfound]=clind[i]; // store cluster id
553 cxpos[nfound]=AliTOFGeometry::RinTOF()+istep*0.1; //store prop.radius
555 if(accept &&!mLastStep)break;
557 } //end for on the clusters
558 if(accept &&!mLastStep)break;
559 } //end for on the steps
571 // now choose the cluster to be matched with the track.
576 Float_t mindist=1000.;
578 for (Int_t iclus= 0; iclus<nfound;iclus++){
579 if (dist[iclus]< mindist){
580 mindist = dist[iclus];
581 mindistZ = distZ[iclus];
583 idclus =index[iclus];
584 recL=crecL[iclus]+corrLen*0.5;
589 AliTOFcluster *c=fClusters[idclus];
591 AliDebug(2, Form("%7i %7i %10i %10i %10i %10i %7i",
594 TMath::Abs(trackTOFin->GetLabel()),
595 c->GetLabel(0), c->GetLabel(1), c->GetLabel(2),
600 // Track length correction for matching Step 2
603 Float_t rc=TMath::Sqrt(c->GetR()*c->GetR() + c->GetZ()*c->GetZ());
604 Float_t rt=TMath::Sqrt(trackPos[0][70]*trackPos[0][70]
605 +trackPos[1][70]*trackPos[1][70]
606 +trackPos[2][70]*trackPos[2][70]);
608 recL=trackPos[3][70]+dlt;
612 (c->GetLabel(0)==TMath::Abs(trackTOFin->GetLabel()))
614 (c->GetLabel(1)==TMath::Abs(trackTOFin->GetLabel()))
616 (c->GetLabel(2)==TMath::Abs(trackTOFin->GetLabel()))
620 AliDebug(2,Form(" track label good %5i",trackTOFin->GetLabel()));
626 AliDebug(2,Form(" track label bad %5i",trackTOFin->GetLabel()));
632 // Store quantities to be used in the TOF Calibration
633 Float_t tToT=AliTOFGeometry::ToTBinWidth()*c->GetToT()*1E-3; // in ns
634 t->SetTOFsignalToT(tToT);
635 Float_t rawTime=AliTOFGeometry::TdcBinWidth()*c->GetTDCRAW()+32; // RAW time,in ps
636 t->SetTOFsignalRaw(rawTime);
637 t->SetTOFsignalDz(mindistZ);
638 AliDebug(2,Form(" Setting TOF raw time: %f, z distance: %f time: %f = ",rawTime,mindistZ));
640 ind[0]=c->GetDetInd(0);
641 ind[1]=c->GetDetInd(1);
642 ind[2]=c->GetDetInd(2);
643 ind[3]=c->GetDetInd(3);
644 ind[4]=c->GetDetInd(4);
645 Int_t calindex = AliTOFGeometry::GetIndex(ind);
646 t->SetTOFCalChannel(calindex);
648 // keep track of the track labels in the matched cluster
650 tlab[0]=c->GetLabel(0);
651 tlab[1]=c->GetLabel(1);
652 tlab[2]=c->GetLabel(2);
653 AliDebug(2,Form(" tdc time of the matched track %i = ",c->GetTDC()));
654 Double_t tof=AliTOFGeometry::TdcBinWidth()*c->GetTDC()+32; // in ps
655 AliDebug(2,Form(" tof time of the matched track: %f = ",tof));
656 Double_t tofcorr=tof;
657 if(timeWalkCorr)tofcorr=CorrectTimeWalk(mindistZ,tof);
658 AliDebug(2,Form(" tof time of the matched track, after TW corr: %f = ",tofcorr));
659 //Set TOF time signal and pointer to the matched cluster
660 t->SetTOFsignal(tofcorr);
661 t->SetTOFcluster(idclus); // pointing to the recPoints tree
664 Double_t time[AliPID::kSPECIES]; t->GetIntegratedTimes(time);
665 Double_t mom=t->GetP();
666 for(Int_t j=0;j<AliPID::kSPECIES;j++){
667 Double_t mass=AliPID::ParticleMass(j);
668 time[j]+=(recL-trackPos[3][0])/3e-2*TMath::Sqrt(mom*mom+mass*mass)/mom;
671 AliTOFtrack *trackTOFout = new AliTOFtrack(*t);
672 trackTOFout->PropagateTo(xpos);
673 t->UpdateTrackParams(trackTOFout,AliESDtrack::kTOFout);
674 t->SetIntegratedLength(recL);
675 t->SetIntegratedTimes(time);
676 t->SetTOFLabel(tlab);
679 // Fill Reco-QA histos for Reconstruction
680 fHRecNClus->Fill(nc);
681 fHRecDist->Fill(mindist);
682 fHRecSigYVsP->Fill(mom,TMath::Sqrt(cov[0]));
683 fHRecSigZVsP->Fill(mom,TMath::Sqrt(cov[2]));
684 fHRecSigYVsPWin->Fill(mom,dphi*sensRadius);
685 fHRecSigZVsPWin->Fill(mom,dz);
687 // Fill Tree for on-the-fly offline Calibration
689 if ( !((t->GetStatus() & AliESDtrack::kTIME)==0 )){
700 for (Int_t ii=0; ii<4; ii++) delete [] trackPos[ii];
704 //_________________________________________________________________________
705 Int_t AliTOFtracker::LoadClusters(TTree *cTree) {
706 //--------------------------------------------------------------------
707 //This function loads the TOF clusters
708 //--------------------------------------------------------------------
710 Int_t npadX = AliTOFGeometry::NpadX();
711 Int_t npadZ = AliTOFGeometry::NpadZ();
712 Int_t nStripA = AliTOFGeometry::NStripA();
713 Int_t nStripB = AliTOFGeometry::NStripB();
714 Int_t nStripC = AliTOFGeometry::NStripC();
716 TBranch *branch=cTree->GetBranch("TOF");
718 AliError("can't get the branch with the TOF clusters !");
722 static TClonesArray dummy("AliTOFcluster",10000);
724 TClonesArray *clusters=&dummy;
725 branch->SetAddress(&clusters);
728 Int_t nc=clusters->GetEntriesFast();
729 fHDigNClus->Fill(nc);
731 AliInfo(Form("Number of clusters: %d",nc));
733 for (Int_t i=0; i<nc; i++) {
734 AliTOFcluster *c=(AliTOFcluster*)clusters->UncheckedAt(i);
735 fClusters[i]=new AliTOFcluster(*c); fN++;
737 // Fill Digits QA histos
739 Int_t isector = c->GetDetInd(0);
740 Int_t iplate = c->GetDetInd(1);
741 Int_t istrip = c->GetDetInd(2);
742 Int_t ipadX = c->GetDetInd(4);
743 Int_t ipadZ = c->GetDetInd(3);
745 Float_t time =(AliTOFGeometry::TdcBinWidth()*c->GetTDC())*1E-3; // in ns
746 Float_t tot = (AliTOFGeometry::TdcBinWidth()*c->GetToT())*1E-3;//in ns
748 Int_t stripOffset = 0;
754 stripOffset = nStripC;
757 stripOffset = nStripC+nStripB;
760 stripOffset = nStripC+nStripB+nStripA;
763 stripOffset = nStripC+nStripB+nStripA+nStripB;
766 AliError(Form("Wrong plate number in TOF (%d) !",iplate));
769 Int_t zindex=npadZ*(istrip+stripOffset)+(ipadZ+1);
770 Int_t phiindex=npadX*isector+ipadX+1;
771 fHDigClusMap->Fill(zindex,phiindex);
772 fHDigClusTime->Fill(time);
773 fHDigClusToT->Fill(tot);
780 //_________________________________________________________________________
781 void AliTOFtracker::UnloadClusters() {
782 //--------------------------------------------------------------------
783 //This function unloads TOF clusters
784 //--------------------------------------------------------------------
785 for (Int_t i=0; i<fN; i++) {
792 //_________________________________________________________________________
793 Int_t AliTOFtracker::FindClusterIndex(Double_t z) const {
794 //--------------------------------------------------------------------
795 // This function returns the index of the nearest cluster
796 //--------------------------------------------------------------------
798 if (z <= fClusters[0]->GetZ()) return 0;
799 if (z > fClusters[fN-1]->GetZ()) return fN;
800 Int_t b=0, e=fN-1, m=(b+e)/2;
801 for (; b<e; m=(b+e)/2) {
802 if (z > fClusters[m]->GetZ()) b=m+1;
808 //_________________________________________________________________________
809 Bool_t AliTOFtracker::GetTrackPoint(Int_t index, AliTrackPoint& p) const
811 // Get track space point with index i
812 // Coordinates are in the global system
813 AliTOFcluster *cl = fClusters[index];
815 xyz[0] = cl->GetR()*TMath::Cos(cl->GetPhi());
816 xyz[1] = cl->GetR()*TMath::Sin(cl->GetPhi());
818 Float_t phiangle = (Int_t(cl->GetPhi()*TMath::RadToDeg()/20.)+0.5)*20.*TMath::DegToRad();
819 Float_t sinphi = TMath::Sin(phiangle), cosphi = TMath::Cos(phiangle);
820 Float_t tiltangle = AliTOFGeometry::GetAngles(cl->GetDetInd(1),cl->GetDetInd(2))*TMath::DegToRad();
821 Float_t sinth = TMath::Sin(tiltangle), costh = TMath::Cos(tiltangle);
822 Float_t sigmay2 = AliTOFGeometry::XPad()*AliTOFGeometry::XPad()/12.;
823 Float_t sigmaz2 = AliTOFGeometry::ZPad()*AliTOFGeometry::ZPad()/12.;
825 cov[0] = sinphi*sinphi*sigmay2 + cosphi*cosphi*sinth*sinth*sigmaz2;
826 cov[1] = -sinphi*cosphi*sigmay2 + sinphi*cosphi*sinth*sinth*sigmaz2;
827 cov[2] = -cosphi*sinth*costh*sigmaz2;
828 cov[3] = cosphi*cosphi*sigmay2 + sinphi*sinphi*sinth*sinth*sigmaz2;
829 cov[4] = -sinphi*sinth*costh*sigmaz2;
830 cov[5] = costh*costh*sigmaz2;
831 p.SetXYZ(xyz[0],xyz[1],xyz[2],cov);
833 // Detector numbering scheme
834 Int_t nSector = AliTOFGeometry::NSectors();
835 Int_t nPlate = AliTOFGeometry::NPlates();
836 Int_t nStripA = AliTOFGeometry::NStripA();
837 Int_t nStripB = AliTOFGeometry::NStripB();
838 Int_t nStripC = AliTOFGeometry::NStripC();
840 Int_t isector = cl->GetDetInd(0);
841 if (isector >= nSector)
842 AliError(Form("Wrong sector number in TOF (%d) !",isector));
843 Int_t iplate = cl->GetDetInd(1);
844 if (iplate >= nPlate)
845 AliError(Form("Wrong plate number in TOF (%d) !",iplate));
846 Int_t istrip = cl->GetDetInd(2);
848 Int_t stripOffset = 0;
854 stripOffset = nStripC;
857 stripOffset = nStripC+nStripB;
860 stripOffset = nStripC+nStripB+nStripA;
863 stripOffset = nStripC+nStripB+nStripA+nStripB;
866 AliError(Form("Wrong plate number in TOF (%d) !",iplate));
870 Int_t idet = (2*(nStripC+nStripB)+nStripA)*isector +
873 UShort_t volid = AliGeomManager::LayerToVolUID(AliGeomManager::kTOF,idet);
874 p.SetVolumeID((UShort_t)volid);
877 //_________________________________________________________________________
878 void AliTOFtracker::InitCheckHists() {
880 //Init histos for Digits/Reco QA and Calibration
883 TDirectory *dir = gDirectory;
884 TFile *logFileTOF = 0;
886 TSeqCollection *list = gROOT->GetListOfFiles();
887 int n = list->GetEntries();
888 Bool_t isThere=kFALSE;
889 for(int i=0; i<n; i++) {
890 logFileTOF = (TFile*)list->At(i);
891 if (strstr(logFileTOF->GetName(), "TOFQA.root")){
897 if(!isThere)logFileTOF = new TFile( "TOFQA.root","RECREATE");
900 fCalTree = new TTree("CalTree", "Tree for TOF calibration");
901 fCalTree->Branch("TOFchannelindex",&fIch,"iTOFch/I");
902 fCalTree->Branch("ToT",&fToT,"TOFToT/F");
903 fCalTree->Branch("TOFtime",&fTime,"TOFtime/F");
904 fCalTree->Branch("PionExpTime",&fExpTimePi,"PiExpTime/F");
905 fCalTree->Branch("KaonExpTime",&fExpTimeKa,"KaExpTime/F");
906 fCalTree->Branch("ProtonExpTime",&fExpTimePr,"PrExpTime/F");
909 fHDigClusMap = new TH2F("TOFDig_ClusMap", "",182,0.5,182.5,864, 0.5,864.5);
910 fHDigNClus = new TH1F("TOFDig_NClus", "",200,0.5,200.5);
911 fHDigClusTime = new TH1F("TOFDig_ClusTime", "",2000,0.,200.);
912 fHDigClusToT = new TH1F("TOFDig_ClusToT", "",500,0.,100);
915 fHRecNClus =new TH1F("TOFRec_NClusW", "",50,0.5,50.5);
916 fHRecDist=new TH1F("TOFRec_Dist", "",50,0.5,10.5);
917 fHRecSigYVsP=new TH2F("TOFDig_SigYVsP", "",40,0.,4.,100, 0.,5.);
918 fHRecSigZVsP=new TH2F("TOFDig_SigZVsP", "",40,0.,4.,100, 0.,5.);
919 fHRecSigYVsPWin=new TH2F("TOFDig_SigYVsPWin", "",40,0.,4.,100, 0.,50.);
920 fHRecSigZVsPWin=new TH2F("TOFDig_SigZVsPWin", "",40,0.,4.,100, 0.,50.);
926 //_________________________________________________________________________
927 void AliTOFtracker::SaveCheckHists() {
929 //write histos for Digits/Reco QA and Calibration
931 TDirectory *dir = gDirectory;
932 TFile *logFileTOF = 0;
934 TSeqCollection *list = gROOT->GetListOfFiles();
935 int n = list->GetEntries();
936 Bool_t isThere=kFALSE;
937 for(int i=0; i<n; i++) {
938 logFileTOF = (TFile*)list->At(i);
939 if (strstr(logFileTOF->GetName(), "TOFQA.root")){
946 AliError(Form("File TOFQA.root not found!! not wring histograms...."));
950 fHDigClusMap->Write(fHDigClusMap->GetName(), TObject::kOverwrite);
951 fHDigNClus->Write(fHDigNClus->GetName(), TObject::kOverwrite);
952 fHDigClusTime->Write(fHDigClusTime->GetName(), TObject::kOverwrite);
953 fHDigClusToT->Write(fHDigClusToT->GetName(), TObject::kOverwrite);
954 fHRecNClus->Write(fHRecNClus->GetName(), TObject::kOverwrite);
955 fHRecDist->Write(fHRecDist->GetName(), TObject::kOverwrite);
956 fHRecSigYVsP->Write(fHRecSigYVsP->GetName(), TObject::kOverwrite);
957 fHRecSigZVsP->Write(fHRecSigZVsP->GetName(), TObject::kOverwrite);
958 fHRecSigYVsPWin->Write(fHRecSigYVsPWin->GetName(), TObject::kOverwrite);
959 fHRecSigZVsPWin->Write(fHRecSigZVsPWin->GetName(), TObject::kOverwrite);
960 fCalTree->Write(fCalTree->GetName(),TObject::kOverwrite);
965 //_________________________________________________________________________
966 Float_t AliTOFtracker::CorrectTimeWalk( Float_t dist, Float_t tof) {
968 //dummy, for the moment
970 if(dist<AliTOFGeometry::ZPad()*0.5){
972 //place here the actual correction
978 //_________________________________________________________________________
979 Float_t AliTOFtracker::GetTimeZerofromT0(AliESDEvent *event) const {
981 //Returns TimeZero as measured by T0 detector
983 return event->GetT0();
985 //_________________________________________________________________________
986 Float_t AliTOFtracker::GetTimeZerofromTOF(AliESDEvent * /*event*/) const {
988 //dummy, for the moment. T0 algorithm using tracks on TOF
990 //place T0 algo here...
994 //_________________________________________________________________________
996 void AliTOFtracker::FillClusterArray(TObjArray* arr) const
999 // Returns the TOF cluster array
1005 for (Int_t i=0; i<fN; ++i) arr->Add(fClusters[i]);