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>
37 #include <TSeqCollection.h>
39 #include "AliESDtrack.h"
40 #include "AliESDEvent.h"
41 #include "AliESDpid.h"
43 #include "AliTrackPointArray.h"
44 #include "AliGeomManager.h"
45 #include "AliCDBManager.h"
47 #include "AliTOFRecoParam.h"
48 #include "AliTOFReconstructor.h"
49 #include "AliTOFcluster.h"
50 #include "AliTOFGeometry.h"
51 #include "AliTOFtrackerV1.h"
52 #include "AliTOFtrack.h"
56 ClassImp(AliTOFtrackerV1)
58 //_____________________________________________________________________________
59 AliTOFtrackerV1::AliTOFtrackerV1():
68 fTracks(new TClonesArray("AliTOFtrack")),
69 fSeeds(new TClonesArray("AliESDtrack")),
82 //AliTOFtrackerV1 main Ctor
87 //_____________________________________________________________________________
88 AliTOFtrackerV1::~AliTOFtrackerV1() {
95 if(!(AliCDBManager::Instance()->GetCacheFlag())){
100 delete fHDigClusTime;
107 delete fHRecSigYVsPWin;
108 delete fHRecSigZVsPWin;
120 //_____________________________________________________________________________
121 void AliTOFtrackerV1::GetPidSettings(AliESDpid *esdPID) {
123 // Sets TOF resolution from RecoParams
126 esdPID->GetTOFResponse().SetTimeResolution(fRecoParam->GetTimeResolution());
128 AliWarning("fRecoParam not yet set; cannot set PID settings");
130 //_____________________________________________________________________________
131 Int_t AliTOFtrackerV1::PropagateBack(AliESDEvent* event) {
133 // Gets seeds from ESD event and Match with TOF Clusters
136 // initialize RecoParam for current event
137 AliDebug(1,"Initializing params for TOF");
139 fRecoParam = AliTOFReconstructor::GetRecoParam(); // instantiate reco param from STEER...
141 if (fRecoParam == 0x0) {
142 AliFatal("No Reco Param found for TOF!!!");
144 //fRecoParam->Dump();
145 //if(fRecoParam->GetApplyPbPbCuts())fRecoParam=fRecoParam->GetPbPbparam();
146 //fRecoParam->PrintParameters();
148 //Handle Time Zero information
150 Double_t timeZero=0.;
151 Double_t timeZeroMax=99999.;
153 //Initialise some counters
162 Int_t ntrk=event->GetNumberOfTracks();
164 TClonesArray &aESDTrack = *fSeeds;
167 //Load ESD tracks into a local Array of ESD Seeds
169 for (Int_t i=0; i<fNseeds; i++) {
170 AliESDtrack *t=event->GetTrack(i);
171 new(aESDTrack[i]) AliESDtrack(*t);
174 //Prepare ESD tracks candidates for TOF Matching
180 AliInfo(Form("Number of matched tracks = %d (good = %d, bad = %d)",fnmatch,fngoodmatch,fnbadmatch));
182 //Update the matched ESD tracks
184 for (Int_t i=0; i<ntrk; i++) {
185 AliESDtrack *t=event->GetTrack(i);
186 AliESDtrack *seed =(AliESDtrack*)fSeeds->UncheckedAt(i);
188 if ( (seed->GetStatus()&AliESDtrack::kTOFin)!=0 ) {
189 t->SetStatus(AliESDtrack::kTOFin);
190 //if(seed->GetTOFsignal()>0){
191 if ( (seed->GetStatus()&AliESDtrack::kTOFout)!=0 ) {
192 t->SetStatus(AliESDtrack::kTOFout);
193 t->SetTOFsignal(seed->GetTOFsignal());
194 t->SetTOFcluster(seed->GetTOFcluster());
195 t->SetTOFsignalToT(seed->GetTOFsignalToT());
196 t->SetTOFsignalRaw(seed->GetTOFsignalRaw());
197 t->SetTOFsignalDz(seed->GetTOFsignalDz());
198 t->SetTOFsignalDx(seed->GetTOFsignalDx());
199 t->SetTOFCalChannel(seed->GetTOFCalChannel());
200 Int_t tlab[3]; seed->GetTOFLabel(tlab);
201 t->SetTOFLabel(tlab);
203 Double_t alphaA = dynamic_cast<AliExternalTrackParam*>(t)->GetAlpha();
204 Double_t xA = dynamic_cast<AliExternalTrackParam*>(t)->GetX();
205 Double_t yA = dynamic_cast<AliExternalTrackParam*>(t)->GetY();
206 Double_t zA = dynamic_cast<AliExternalTrackParam*>(t)->GetZ();
207 Double_t p1A = dynamic_cast<AliExternalTrackParam*>(t)->GetSnp();
208 Double_t p2A = dynamic_cast<AliExternalTrackParam*>(t)->GetTgl();
209 Double_t p3A = dynamic_cast<AliExternalTrackParam*>(t)->GetSigned1Pt();
210 const Double_t *covA = dynamic_cast<AliExternalTrackParam*>(t)->GetCovariance();
212 // Make attention, please:
213 // AliESDtrack::fTOFInfo array does not be stored in the AliESDs.root file
214 // it is there only for a check during the reconstruction step.
215 Float_t info[10]={0.,0.,0.,0.,0.,0.,0.,0.,0.,0.};
216 seed->GetTOFInfo(info);
218 AliDebug(2,Form(" distance=%f; residual in the pad reference frame: dX=%f, dZ=%f", info[0],info[1],info[2]));
221 // by calling the AliESDtrack::UpdateTrackParams,
222 // the current track parameters are changed
223 // and it could cause refit problems.
224 // We need to update only the following track parameters:
225 // the track length and expected times.
226 // Removed AliESDtrack::UpdateTrackParams call
227 // Called AliESDtrack::SetIntegratedTimes(...) and
228 // AliESDtrack::SetIntegratedLength() routines.
230 AliTOFtrack *track = new AliTOFtrack(*seed);
231 t->UpdateTrackParams(track,AliESDtrack::kTOFout); // to be checked - AdC
233 Double_t time[10]; t->GetIntegratedTimes(time);
236 Double_t time[10]; seed->GetIntegratedTimes(time);
237 t->SetIntegratedTimes(time);
239 Double_t length = seed->GetIntegratedLength();
240 t->SetIntegratedLength(length);
242 Double_t alphaB = dynamic_cast<AliExternalTrackParam*>(t)->GetAlpha();
243 Double_t xB = dynamic_cast<AliExternalTrackParam*>(t)->GetX();
244 Double_t yB = dynamic_cast<AliExternalTrackParam*>(t)->GetY();
245 Double_t zB = dynamic_cast<AliExternalTrackParam*>(t)->GetZ();
246 Double_t p1B = dynamic_cast<AliExternalTrackParam*>(t)->GetSnp();
247 Double_t p2B = dynamic_cast<AliExternalTrackParam*>(t)->GetTgl();
248 Double_t p3B = dynamic_cast<AliExternalTrackParam*>(t)->GetSigned1Pt();
249 const Double_t *covB = dynamic_cast<AliExternalTrackParam*>(t)->GetCovariance();
250 AliDebug(2,"Track params -now(before)-:");
251 AliDebug(2,Form(" X: %f(%f), Y: %f(%f), Z: %f(%f) --- alpha: %f(%f)",
256 AliDebug(2,Form(" p1: %f(%f), p2: %f(%f), p3: %f(%f)",
260 AliDebug(2,Form(" cov1: %f(%f), cov2: %f(%f), cov3: %f(%f)"
261 " cov4: %f(%f), cov5: %f(%f), cov6: %f(%f)"
262 " cov7: %f(%f), cov8: %f(%f), cov9: %f(%f)"
263 " cov10: %f(%f), cov11: %f(%f), cov12: %f(%f)"
264 " cov13: %f(%f), cov14: %f(%f), cov15: %f(%f)",
281 AliDebug(3,Form(" %6d %f %f %f %f % %6d %3d %f %f %f %f %f %f",
283 t->GetTOFsignalRaw(),
285 t->GetTOFsignalToT(),
288 t->GetTOFCalChannel(),
290 t->GetIntegratedLength(),
291 time[0], time[1], time[2], time[3], time[4]
303 //_________________________________________________________________________
304 void AliTOFtrackerV1::CollectESD() {
305 //prepare the set of ESD tracks to be matched to clusters in TOF
310 TClonesArray &aTOFTrack = *fTracks;
311 for (Int_t i=0; i<fNseeds; i++) {
313 AliESDtrack *t =(AliESDtrack*)fSeeds->UncheckedAt(i);
314 if ((t->GetStatus()&AliESDtrack::kTPCout)==0)continue;
316 AliTOFtrack *track = new AliTOFtrack(*t); // New
317 Float_t x = (Float_t)track->GetX(); //New
319 // TRD 'good' tracks, already propagated at 371 cm
320 if ( ( (t->GetStatus()&AliESDtrack::kTRDout)!=0 ) &&
321 ( x >= AliTOFGeometry::Rmin() ) ) {
322 if ( track->PropagateToInnerTOF() ) {
324 AliDebug(1,Form(" TRD propagated track till rho = %fcm."
325 " And then the track has been propagated till rho = %fcm.",
326 x, (Float_t)track->GetX()));
328 track->SetSeedIndex(i);
329 t->UpdateTrackParams(track,AliESDtrack::kTOFin);
330 new(aTOFTrack[fNseedsTOF]) AliTOFtrack(*track);
337 // Propagate the rest of TPCbp
339 if ( track->PropagateToInnerTOF() ) {
341 AliDebug(1,Form(" TRD propagated track till rho = %fcm."
342 " And then the track has been propagated till rho = %fcm.",
343 x, (Float_t)track->GetX()));
345 track->SetSeedIndex(i);
346 t->UpdateTrackParams(track,AliESDtrack::kTOFin);
347 new(aTOFTrack[fNseedsTOF]) AliTOFtrack(*track);
355 AliInfo(Form("Number of TOF seeds = %d (Type 1 = %d, Type 2 = %d)",fNseedsTOF,seedsTOF1,seedsTOF2));
357 // Sort according uncertainties on track position
361 //_________________________________________________________________________
362 void AliTOFtrackerV1::MatchTracks( ){
364 //Match ESD tracks to clusters in TOF
368 // Parameters regulating the reconstruction
369 Float_t dY=AliTOFGeometry::XPad();
370 Float_t dZ=AliTOFGeometry::ZPad();
372 const Float_t kTimeOffset = 32.; // time offset for tracking algorithm [ps]
374 const Int_t kncmax = 100;
375 Float_t sensRadius = fRecoParam->GetSensRadius();
376 Float_t scaleFact = fRecoParam->GetWindowScaleFact();
377 Float_t dyMax=fRecoParam->GetWindowSizeMaxY();
378 Float_t dzMax=fRecoParam->GetWindowSizeMaxZ();
379 Double_t maxChi2=fRecoParam->GetMaxChi2();
380 Bool_t timeWalkCorr = fRecoParam->GetTimeWalkCorr();
381 AliDebug(1,"++++++++++++++TOF Reconstruction Parameters:++++++++++++ \n");
382 AliDebug(1,Form("TOF sens radius: %f",sensRadius));
383 AliDebug(1,Form("TOF Window scale factor: %f",scaleFact));
384 AliDebug(1,Form("TOF Window max dy: %f",dyMax));
385 AliDebug(1,Form("TOF Window max dz: %f",dzMax));
386 AliDebug(1,Form("TOF Max Chi2: %f",maxChi2));
387 AliDebug(1,Form("Time Walk Correction? : %d",timeWalkCorr));
391 for (Int_t iseed=0; iseed<fNseedsTOF; iseed++) {
393 AliTOFtrack *track =(AliTOFtrack*)fTracks->UncheckedAt(iseed);
394 AliESDtrack *t =(AliESDtrack*)fSeeds->UncheckedAt(track->GetSeedIndex());
395 //if ( t->GetTOFsignal()>0. ) continue;
396 if ( (t->GetStatus()&AliESDtrack::kTOFout)!=0 ) continue;
397 AliTOFtrack *trackTOFin =new AliTOFtrack(*track);
399 // Determine a window around the track
400 Double_t x,par[5]; trackTOFin->GetExternalParameters(x,par);
401 Double_t cov[15]; trackTOFin->GetExternalCovariance(cov);
403 if (cov[0]<0. || cov[2]<0.) {
404 AliWarning(Form("Very strange track (%d)! At least one of its covariance matrix diagonal elements is negative!",iseed));
410 Double_t dz = scaleFact*3.*TMath::Sqrt(TMath::Abs(cov[2])+dZ*dZ/12.);
411 Double_t dphi = scaleFact*3.*TMath::Sqrt(TMath::Abs(cov[0])+dY*dY/12.)/sensRadius;
413 Double_t phi=TMath::ATan2(par[0],x) + trackTOFin->GetAlpha();
414 if (phi<-TMath::Pi())phi+=2*TMath::Pi();
415 if (phi>=TMath::Pi())phi-=2*TMath::Pi();
417 //upper limit on window's size.
418 if(dz> dzMax) dz=dzMax;
419 if(dphi*sensRadius> dyMax) dphi=dyMax/sensRadius;
421 // find the clusters inside the selected window
423 AliTOFcluster *clusters[kncmax]; // pointers to the clusters in the window
424 Int_t index[kncmax];//to keep track of the cluster index
425 for (Int_t k=FindClusterIndex(z-dz); k<fN; k++) {
426 AliTOFcluster *c=fClusters[k];
427 // if(nc>kncmax)break; /* R+ fix (buffer overflow) */
429 AliWarning("No more matchable clusters can be stored! Please, increase the corresponding vectors size.");
430 break; /* R+ fix (buffer overflow protection) */
432 if(c->GetZ() > z+dz) break;
433 if(c->IsUsed()) continue;
434 if(!c->GetStatus()) {
435 AliDebug(1,"Cluster in channel declared bad!");
436 continue; // skip bad channels as declared in OCDB
438 Float_t xyz[3]; c->GetGlobalXYZ(xyz);
439 Double_t clPhi=TMath::ATan2(xyz[1],xyz[0]);
440 Double_t dph=TMath::Abs(clPhi-phi);
441 if (dph>TMath::Pi()) dph-=2.*TMath::Pi();
442 if (TMath::Abs(dph)>dphi) continue;
448 AliDebug(1,Form(" Number of matchable TOF clusters for the track number %d: %d",iseed,nc));
450 //start propagation: go to the average TOF pad middle plane at ~379.5 cm
452 Float_t xTOF = sensRadius;
453 Double_t ymax = xTOF*TMath::Tan(0.5*AliTOFGeometry::GetAlpha());
454 Bool_t skip = kFALSE;
455 Double_t ysect = trackTOFin->GetYat(xTOF,skip);
458 if (!trackTOFin->Rotate(AliTOFGeometry::GetAlpha())) {
461 } else if (ysect <-ymax) {
462 if (!trackTOFin->Rotate(-AliTOFGeometry::GetAlpha())) {
466 if(!trackTOFin->PropagateTo(xTOF)) {
471 AliTOFcluster *bestCluster=0;
472 Double_t bestChi2=maxChi2;
474 // for (Int_t i=0; i<nc; i++){ /* R+ fix (unsafe) */
475 for (Int_t i=0; i<nc && i<kncmax; i++){ /* R+ fix (buffer overflow protection) */
476 AliTOFcluster *c=clusters[i]; // one of the preselected clusters
477 Double_t chi2=trackTOFin->GetPredictedChi2((AliCluster3D*)c);
478 if (chi2 >= bestChi2) continue;
484 if (!bestCluster) { // no matching , go to the next track
492 AliDebug(2, Form("%7i %7i %10i %10i %10i %10i %7i",
495 TMath::Abs(trackTOFin->GetLabel()),
496 bestCluster->GetLabel(0),
497 bestCluster->GetLabel(1),
498 bestCluster->GetLabel(2),
503 (bestCluster->GetLabel(0)==TMath::Abs(trackTOFin->GetLabel()))
505 (bestCluster->GetLabel(1)==TMath::Abs(trackTOFin->GetLabel()))
507 (bestCluster->GetLabel(2)==TMath::Abs(trackTOFin->GetLabel()))
510 AliDebug(2,Form(" track label good %5d",trackTOFin->GetLabel()));
515 AliDebug(2,Form(" track label bad %5d",trackTOFin->GetLabel()));
518 //Propagate the track to the best matched cluster
519 trackTOFin->PropagateTo(bestCluster);
521 // Fill the track residual histograms.
522 FillResiduals(trackTOFin,bestCluster,kFALSE);
524 //now take the local distance in Z from the pad center for time walk correction
525 Float_t tiltangle = AliTOFGeometry::GetAngles(bestCluster->GetDetInd(1),bestCluster->GetDetInd(2))*TMath::DegToRad();
526 Double_t dzTW=trackTOFin->GetZ()-bestCluster->GetZ(); // in cm - in the ALICE RF -
527 dzTW/=TMath::Cos(tiltangle); // from ALICE/tracking RF to pad RF (1)
528 dzTW=-dzTW; // from ALICE/tracking RF to pad RF (2)
529 if (tiltangle!=0.) AliDebug(2,Form(" rho_track = %f --- rho_cluster = %f ",trackTOFin->GetX(),bestCluster->GetX()));
531 //update the ESD track and delete the TOFtrack
532 t->UpdateTrackParams(trackTOFin,AliESDtrack::kTOFout);
534 // Store quantities to be used in the TOF Calibration
535 Float_t tToT=AliTOFGeometry::ToTBinWidth()*bestCluster->GetToT()*1E-3; // in ns
536 t->SetTOFsignalToT(tToT);
537 Float_t rawTime=AliTOFGeometry::TdcBinWidth()*bestCluster->GetTDCRAW()+kTimeOffset; // RAW time,in ps
538 t->SetTOFsignalRaw(rawTime);
539 t->SetTOFsignalDz(dzTW);
541 Float_t deltaY = trackTOFin->GetY()-bestCluster->GetY();
542 t->SetTOFsignalDx(deltaY);
544 Float_t distR = (trackTOFin->GetX()-bestCluster->GetX())*
545 (trackTOFin->GetX()-bestCluster->GetX());
546 distR+=deltaY*deltaY;
548 distR = TMath::Sqrt(distR);
549 Float_t info[10] = {distR, deltaY, dzTW,
550 0.,0.,0.,0.,0.,0.,0.};
554 ind[0]=bestCluster->GetDetInd(0);
555 ind[1]=bestCluster->GetDetInd(1);
556 ind[2]=bestCluster->GetDetInd(2);
557 ind[3]=bestCluster->GetDetInd(3);
558 ind[4]=bestCluster->GetDetInd(4);
559 Int_t calindex = AliTOFGeometry::GetIndex(ind);
560 t->SetTOFCalChannel(calindex);
562 // keep track of the track labels in the matched cluster
564 tlab[0]=bestCluster->GetLabel(0);
565 tlab[1]=bestCluster->GetLabel(1);
566 tlab[2]=bestCluster->GetLabel(2);
567 AliDebug(2,Form(" tdc time of the matched track %6d = ",bestCluster->GetTDC()));
568 Double_t tof=AliTOFGeometry::TdcBinWidth()*bestCluster->GetTDC()+kTimeOffset; // in ps
569 AliDebug(2,Form(" tof time of the matched track: %f = ",tof));
570 Double_t tofcorr=tof;
571 if(timeWalkCorr)tofcorr=CorrectTimeWalk(dzTW,tof);
572 AliDebug(2,Form(" tof time of the matched track, after TW corr: %f = ",tofcorr));
573 //Set TOF time signal and pointer to the matched cluster
574 t->SetTOFsignal(tofcorr);
575 t->SetTOFcluster(idclus); // pointing to the recPoints tree
576 t->SetTOFLabel(tlab);
578 AliDebug(2,Form(" Setting TOF raw time: %f z distance: %f corrected time: %f",rawTime,dzTW,tofcorr));
580 Double_t mom=t->GetP();
581 AliDebug(2,Form(" Momentum for track %d -> %f", iseed,mom));
582 // Fill Reco-QA histos for Reconstruction
583 fHRecNClus->Fill(nc);
584 fHRecChi2->Fill(bestChi2);
585 fHRecDistZ->Fill(dzTW);
586 fHRecSigYVsP->Fill(mom,TMath::Sqrt(cov[0]));
587 fHRecSigZVsP->Fill(mom,TMath::Sqrt(cov[2]));
588 fHRecSigYVsPWin->Fill(mom,dphi*sensRadius);
589 fHRecSigZVsPWin->Fill(mom,dz);
591 // Fill Tree for on-the-fly offline Calibration
592 // no longer there - all info is in the ESDs now
598 //_________________________________________________________________________
599 Int_t AliTOFtrackerV1::LoadClusters(TTree *cTree) {
600 //--------------------------------------------------------------------
601 //This function loads the TOF clusters
602 //--------------------------------------------------------------------
604 Int_t npadX = AliTOFGeometry::NpadX();
605 Int_t npadZ = AliTOFGeometry::NpadZ();
606 Int_t nStripA = AliTOFGeometry::NStripA();
607 Int_t nStripB = AliTOFGeometry::NStripB();
608 Int_t nStripC = AliTOFGeometry::NStripC();
610 TBranch *branch=cTree->GetBranch("TOF");
612 AliError("can't get the branch with the TOF clusters !");
616 static TClonesArray dummy("AliTOFcluster",10000);
618 TClonesArray *clusters=&dummy;
619 branch->SetAddress(&clusters);
622 Int_t nc=clusters->GetEntriesFast();
623 fHDigNClus->Fill(nc);
625 AliInfo(Form("Number of clusters: %d",nc));
627 for (Int_t i=0; i<nc; i++) {
628 AliTOFcluster *c=(AliTOFcluster*)clusters->UncheckedAt(i);
629 //PH fClusters[i]=new AliTOFcluster(*c); fN++;
630 fClusters[i]=c; fN++;
632 // Fill Digits QA histos
634 Int_t isector = c->GetDetInd(0);
635 Int_t iplate = c->GetDetInd(1);
636 Int_t istrip = c->GetDetInd(2);
637 Int_t ipadX = c->GetDetInd(4);
638 Int_t ipadZ = c->GetDetInd(3);
640 Float_t time =(AliTOFGeometry::TdcBinWidth()*c->GetTDC())*1E-3; // in ns
641 Float_t tot = (AliTOFGeometry::TdcBinWidth()*c->GetToT())*1E-3;//in ns
643 Int_t stripOffset = 0;
649 stripOffset = nStripC;
652 stripOffset = nStripC+nStripB;
655 stripOffset = nStripC+nStripB+nStripA;
658 stripOffset = nStripC+nStripB+nStripA+nStripB;
661 AliError(Form("Wrong plate number in TOF (%d) !",iplate));
664 Int_t zindex=npadZ*(istrip+stripOffset)+(ipadZ+1);
665 Int_t phiindex=npadX*isector+ipadX+1;
666 fHDigClusMap->Fill(zindex,phiindex);
667 fHDigClusTime->Fill(time);
668 fHDigClusToT->Fill(tot);
674 //_________________________________________________________________________
675 void AliTOFtrackerV1::UnloadClusters() {
676 //--------------------------------------------------------------------
677 //This function unloads TOF clusters
678 //--------------------------------------------------------------------
679 for (Int_t i=0; i<fN; i++) {
680 //PH delete fClusters[i];
686 //_________________________________________________________________________
687 Int_t AliTOFtrackerV1::FindClusterIndex(Double_t z) const {
688 //--------------------------------------------------------------------
689 // This function returns the index of the nearest cluster
690 //--------------------------------------------------------------------
692 //Here we need to get the Z in the tracking system
695 if (z <= fClusters[0]->GetZ()) return 0;
696 if (z > fClusters[fN-1]->GetZ()) return fN;
697 Int_t b=0, e=fN-1, m=(b+e)/2;
698 for (; b<e; m=(b+e)/2) {
699 if (z > fClusters[m]->GetZ()) b=m+1;
705 //_________________________________________________________________________
706 Bool_t AliTOFtrackerV1::GetTrackPoint(Int_t index, AliTrackPoint& p) const
708 // Get track space point with index i
709 // Coordinates are in the global system
710 AliTOFcluster *cl = fClusters[index];
712 cl->GetGlobalXYZ(xyz);
713 Float_t phi=TMath::ATan2(xyz[1],xyz[0]);
714 Float_t phiangle = (Int_t(phi*TMath::RadToDeg()/20.)+0.5)*20.*TMath::DegToRad();
715 Float_t sinphi = TMath::Sin(phiangle), cosphi = TMath::Cos(phiangle);
716 Float_t tiltangle = AliTOFGeometry::GetAngles(cl->GetDetInd(1),cl->GetDetInd(2))*TMath::DegToRad();
717 Float_t sinth = TMath::Sin(tiltangle), costh = TMath::Cos(tiltangle);
718 Float_t sigmay2 = AliTOFGeometry::XPad()*AliTOFGeometry::XPad()/12.;
719 Float_t sigmaz2 = AliTOFGeometry::ZPad()*AliTOFGeometry::ZPad()/12.;
721 cov[0] = sinphi*sinphi*sigmay2 + cosphi*cosphi*sinth*sinth*sigmaz2;
722 cov[1] = -sinphi*cosphi*sigmay2 + sinphi*cosphi*sinth*sinth*sigmaz2;
723 cov[2] = -cosphi*sinth*costh*sigmaz2;
724 cov[3] = cosphi*cosphi*sigmay2 + sinphi*sinphi*sinth*sinth*sigmaz2;
725 cov[4] = -sinphi*sinth*costh*sigmaz2;
726 cov[5] = costh*costh*sigmaz2;
727 p.SetXYZ(xyz[0],xyz[1],xyz[2],cov);
729 // Detector numbering scheme
730 Int_t nSector = AliTOFGeometry::NSectors();
731 Int_t nPlate = AliTOFGeometry::NPlates();
732 Int_t nStripA = AliTOFGeometry::NStripA();
733 Int_t nStripB = AliTOFGeometry::NStripB();
734 Int_t nStripC = AliTOFGeometry::NStripC();
736 Int_t isector = cl->GetDetInd(0);
737 if (isector >= nSector)
738 AliError(Form("Wrong sector number in TOF (%d) !",isector));
739 Int_t iplate = cl->GetDetInd(1);
740 if (iplate >= nPlate)
741 AliError(Form("Wrong plate number in TOF (%d) !",iplate));
742 Int_t istrip = cl->GetDetInd(2);
744 Int_t stripOffset = 0;
750 stripOffset = nStripC;
753 stripOffset = nStripC+nStripB;
756 stripOffset = nStripC+nStripB+nStripA;
759 stripOffset = nStripC+nStripB+nStripA+nStripB;
762 AliError(Form("Wrong plate number in TOF (%d) !",iplate));
766 Int_t idet = (2*(nStripC+nStripB)+nStripA)*isector +
769 UShort_t volid = AliGeomManager::LayerToVolUID(AliGeomManager::kTOF,idet);
770 p.SetVolumeID((UShort_t)volid);
773 //_________________________________________________________________________
774 void AliTOFtrackerV1::InitCheckHists() {
776 //Init histos for Digits/Reco QA and Calibration
778 TDirectory *dir = gDirectory;
779 TFile *logFileTOF = 0;
781 TSeqCollection *list = gROOT->GetListOfFiles();
782 int n = list->GetEntries();
783 Bool_t isThere=kFALSE;
784 for(int i=0; i<n; i++) {
785 logFileTOF = (TFile*)list->At(i);
786 if (strstr(logFileTOF->GetName(), "TOFQA.root")){
792 if(!isThere)logFileTOF = new TFile( "TOFQA.root","RECREATE");
796 fHDigClusMap = new TH2F("TOFDig_ClusMap", "",182,0.5,182.5,864, 0.5,864.5);
797 fHDigNClus = new TH1F("TOFDig_NClus", "",200,0.5,200.5);
798 fHDigClusTime = new TH1F("TOFDig_ClusTime", "",2000,0.,200.);
799 fHDigClusToT = new TH1F("TOFDig_ClusToT", "",500,0.,100);
802 fHRecNClus =new TH1F("TOFRec_NClusW", "",50,0.5,50.5);
803 fHRecDistZ=new TH1F("TOFRec_DistZ", "",50,0.5,10.5);
804 fHRecChi2=new TH1F("TOFRec_Chi2", "",100,0.,10.);
805 fHRecSigYVsP=new TH2F("TOFDig_SigYVsP", "",40,0.,4.,100, 0.,5.);
806 fHRecSigZVsP=new TH2F("TOFDig_SigZVsP", "",40,0.,4.,100, 0.,5.);
807 fHRecSigYVsPWin=new TH2F("TOFDig_SigYVsPWin", "",40,0.,4.,100, 0.,50.);
808 fHRecSigZVsPWin=new TH2F("TOFDig_SigZVsPWin", "",40,0.,4.,100, 0.,50.);
814 //_________________________________________________________________________
815 void AliTOFtrackerV1::SaveCheckHists() {
817 //write histos for Digits/Reco QA and Calibration
819 TDirectory *dir = gDirectory;
821 TFile *logFileTOF = 0;
823 TSeqCollection *list = gROOT->GetListOfFiles();
824 int n = list->GetEntries();
825 for(int i=0; i<n; i++) {
826 logFile = (TFile*)list->At(i);
827 if (strstr(logFile->GetName(), "AliESDs.root")) break;
830 Bool_t isThere=kFALSE;
831 for(int i=0; i<n; i++) {
832 logFileTOF = (TFile*)list->At(i);
833 if (strstr(logFileTOF->GetName(), "TOFQA.root")){
840 AliError(Form("File TOFQA.root not found!! not wring histograms...."));
844 fHDigClusMap->Write(fHDigClusMap->GetName(), TObject::kOverwrite);
845 fHDigNClus->Write(fHDigNClus->GetName(), TObject::kOverwrite);
846 fHDigClusTime->Write(fHDigClusTime->GetName(), TObject::kOverwrite);
847 fHDigClusToT->Write(fHDigClusToT->GetName(), TObject::kOverwrite);
848 fHRecNClus->Write(fHRecNClus->GetName(), TObject::kOverwrite);
849 fHRecChi2->Write(fHRecChi2->GetName(), TObject::kOverwrite);
850 fHRecDistZ->Write(fHRecDistZ->GetName(), TObject::kOverwrite);
851 fHRecSigYVsP->Write(fHRecSigYVsP->GetName(), TObject::kOverwrite);
852 fHRecSigZVsP->Write(fHRecSigZVsP->GetName(), TObject::kOverwrite);
853 fHRecSigYVsPWin->Write(fHRecSigYVsPWin->GetName(), TObject::kOverwrite);
854 fHRecSigZVsPWin->Write(fHRecSigZVsPWin->GetName(), TObject::kOverwrite);
860 //_________________________________________________________________________
861 Float_t AliTOFtrackerV1::CorrectTimeWalk( Float_t dist, Float_t tof) {
863 //dummy, for the moment
865 if(dist<AliTOFGeometry::ZPad()*0.5){
867 //place here the actual correction
873 //_________________________________________________________________________
874 Float_t AliTOFtrackerV1::GetTimeZerofromT0(AliESDEvent *event) const {
876 //Returns TimeZero as measured by T0 detector
878 return event->GetT0();
880 //_________________________________________________________________________
881 Float_t AliTOFtrackerV1::GetTimeZerofromTOF(AliESDEvent * /*event*/) const {
883 //dummy, for the moment. T0 algorithm using tracks on TOF
885 //place T0 algo here...
889 //_________________________________________________________________________
891 void AliTOFtrackerV1::FillClusterArray(TObjArray* arr) const
894 // Returns the TOF cluster array
900 for (Int_t i=0; i<fN; ++i) arr->Add(fClusters[i]);