+//_________________________________________________________________________
+Bool_t AliTOFtracker::GetTrackPoint(Int_t index, AliTrackPoint& p) const
+{
+ // Get track space point with index i
+ // Coordinates are in the global system
+ AliTOFcluster *cl = fClusters[index];
+ Float_t xyz[3];
+ xyz[0] = cl->GetR()*TMath::Cos(cl->GetPhi());
+ xyz[1] = cl->GetR()*TMath::Sin(cl->GetPhi());
+ xyz[2] = cl->GetZ();
+ Float_t phiangle = (Int_t(cl->GetPhi()*TMath::RadToDeg()/20.)+0.5)*20.*TMath::DegToRad();
+ Float_t sinphi = TMath::Sin(phiangle), cosphi = TMath::Cos(phiangle);
+ Float_t tiltangle = AliTOFGeometry::GetAngles(cl->GetDetInd(1),cl->GetDetInd(2))*TMath::DegToRad();
+ Float_t sinth = TMath::Sin(tiltangle), costh = TMath::Cos(tiltangle);
+ Float_t sigmay2 = AliTOFGeometry::XPad()*AliTOFGeometry::XPad()/12.;
+ Float_t sigmaz2 = AliTOFGeometry::ZPad()*AliTOFGeometry::ZPad()/12.;
+ Float_t cov[6];
+ cov[0] = sinphi*sinphi*sigmay2 + cosphi*cosphi*sinth*sinth*sigmaz2;
+ cov[1] = -sinphi*cosphi*sigmay2 + sinphi*cosphi*sinth*sinth*sigmaz2;
+ cov[2] = -cosphi*sinth*costh*sigmaz2;
+ cov[3] = cosphi*cosphi*sigmay2 + sinphi*sinphi*sinth*sinth*sigmaz2;
+ cov[4] = -sinphi*sinth*costh*sigmaz2;
+ cov[5] = costh*costh*sigmaz2;
+ p.SetXYZ(xyz[0],xyz[1],xyz[2],cov);
+
+ // Detector numbering scheme
+ Int_t nSector = AliTOFGeometry::NSectors();
+ Int_t nPlate = AliTOFGeometry::NPlates();
+ Int_t nStripA = AliTOFGeometry::NStripA();
+ Int_t nStripB = AliTOFGeometry::NStripB();
+ Int_t nStripC = AliTOFGeometry::NStripC();
+
+ Int_t isector = cl->GetDetInd(0);
+ if (isector >= nSector)
+ AliError(Form("Wrong sector number in TOF (%d) !",isector));
+ Int_t iplate = cl->GetDetInd(1);
+ if (iplate >= nPlate)
+ AliError(Form("Wrong plate number in TOF (%d) !",iplate));
+ Int_t istrip = cl->GetDetInd(2);
+
+ Int_t stripOffset = 0;
+ switch (iplate) {
+ case 0:
+ stripOffset = 0;
+ break;
+ case 1:
+ stripOffset = nStripC;
+ break;
+ case 2:
+ stripOffset = nStripC+nStripB;
+ break;
+ case 3:
+ stripOffset = nStripC+nStripB+nStripA;
+ break;
+ case 4:
+ stripOffset = nStripC+nStripB+nStripA+nStripB;
+ break;
+ default:
+ AliError(Form("Wrong plate number in TOF (%d) !",iplate));
+ break;
+ };
+
+ Int_t idet = (2*(nStripC+nStripB)+nStripA)*isector +
+ stripOffset +
+ istrip;
+ UShort_t volid = AliGeomManager::LayerToVolUID(AliGeomManager::kTOF,idet);
+ p.SetVolumeID((UShort_t)volid);
+ return kTRUE;
+}
+//_________________________________________________________________________
+void AliTOFtracker::InitCheckHists() {
+
+ //Init histos for Digits/Reco QA and Calibration
+
+
+ TDirectory *dir = gDirectory;
+ TFile *logFileTOF = 0;
+
+ TSeqCollection *list = gROOT->GetListOfFiles();
+ int n = list->GetEntries();
+ Bool_t isThere=kFALSE;
+ for(int i=0; i<n; i++) {
+ logFileTOF = (TFile*)list->At(i);
+ if (strstr(logFileTOF->GetName(), "TOFQA.root")){
+ isThere=kTRUE;
+ break;
+ }
+ }
+
+ if(!isThere)logFileTOF = new TFile( "TOFQA.root","RECREATE");
+ logFileTOF->cd();
+
+ fCalTree = new TTree("CalTree", "Tree for TOF calibration");
+ fCalTree->Branch("TOFchannelindex",&fIch,"iTOFch/I");
+ fCalTree->Branch("ToT",&fToT,"TOFToT/F");
+ fCalTree->Branch("TOFtime",&fTime,"TOFtime/F");
+ fCalTree->Branch("PionExpTime",&fExpTimePi,"PiExpTime/F");
+ fCalTree->Branch("KaonExpTime",&fExpTimeKa,"KaExpTime/F");
+ fCalTree->Branch("ProtonExpTime",&fExpTimePr,"PrExpTime/F");
+
+ //Digits "QA"
+ fHDigClusMap = new TH2F("TOFDig_ClusMap", "",182,0.5,182.5,864, 0.5,864.5);
+ fHDigNClus = new TH1F("TOFDig_NClus", "",200,0.5,200.5);
+ fHDigClusTime = new TH1F("TOFDig_ClusTime", "",2000,0.,200.);
+ fHDigClusToT = new TH1F("TOFDig_ClusToT", "",500,0.,100);
+
+ //Reco "QA"
+ fHRecNClus =new TH1F("TOFRec_NClusW", "",50,0.5,50.5);
+ fHRecDist=new TH1F("TOFRec_Dist", "",50,0.5,10.5);
+ fHRecSigYVsP=new TH2F("TOFDig_SigYVsP", "",40,0.,4.,100, 0.,5.);
+ fHRecSigZVsP=new TH2F("TOFDig_SigZVsP", "",40,0.,4.,100, 0.,5.);
+ fHRecSigYVsPWin=new TH2F("TOFDig_SigYVsPWin", "",40,0.,4.,100, 0.,50.);
+ fHRecSigZVsPWin=new TH2F("TOFDig_SigZVsPWin", "",40,0.,4.,100, 0.,50.);
+
+ dir->cd();
+
+}
+
+//_________________________________________________________________________
+void AliTOFtracker::SaveCheckHists() {
+
+ //write histos for Digits/Reco QA and Calibration
+
+ TDirectory *dir = gDirectory;
+ TFile *logFileTOF = 0;
+
+ TSeqCollection *list = gROOT->GetListOfFiles();
+ int n = list->GetEntries();
+ Bool_t isThere=kFALSE;
+ for(int i=0; i<n; i++) {
+ logFileTOF = (TFile*)list->At(i);
+ if (strstr(logFileTOF->GetName(), "TOFQA.root")){
+ isThere=kTRUE;
+ break;
+ }
+ }
+
+ if(!isThere) {
+ AliError(Form("File TOFQA.root not found!! not wring histograms...."));
+ return;
+ }
+ logFileTOF->cd();
+ fHDigClusMap->Write(fHDigClusMap->GetName(), TObject::kOverwrite);
+ fHDigNClus->Write(fHDigNClus->GetName(), TObject::kOverwrite);
+ fHDigClusTime->Write(fHDigClusTime->GetName(), TObject::kOverwrite);
+ fHDigClusToT->Write(fHDigClusToT->GetName(), TObject::kOverwrite);
+ fHRecNClus->Write(fHRecNClus->GetName(), TObject::kOverwrite);
+ fHRecDist->Write(fHRecDist->GetName(), TObject::kOverwrite);
+ fHRecSigYVsP->Write(fHRecSigYVsP->GetName(), TObject::kOverwrite);
+ fHRecSigZVsP->Write(fHRecSigZVsP->GetName(), TObject::kOverwrite);
+ fHRecSigYVsPWin->Write(fHRecSigYVsPWin->GetName(), TObject::kOverwrite);
+ fHRecSigZVsPWin->Write(fHRecSigZVsPWin->GetName(), TObject::kOverwrite);
+ fCalTree->Write(fCalTree->GetName(),TObject::kOverwrite);
+ logFileTOF->Flush();
+
+ dir->cd();
+ }
+//_________________________________________________________________________
+Float_t AliTOFtracker::CorrectTimeWalk( Float_t dist, Float_t tof) const {
+
+ //dummy, for the moment
+ Float_t tofcorr=0.;
+ if(dist<AliTOFGeometry::ZPad()*0.5){
+ tofcorr=tof;
+ //place here the actual correction
+ }else{
+ tofcorr=tof;
+ }
+ return tofcorr;
+}
+//_________________________________________________________________________
+
+void AliTOFtracker::FillClusterArray(TObjArray* arr) const
+{
+ //
+ // Returns the TOF cluster array
+ //
+
+ if (fN==0)
+ arr = 0x0;
+ else
+ for (Int_t i=0; i<fN; ++i) arr->Add(fClusters[i]);
+
+}
+//_________________________________________________________________________
+