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
85 for (Int_t ii=0; ii<kMaxCluster; ii++) fClusters[ii]=0x0;
90 //_____________________________________________________________________________
91 AliTOFtrackerV1::~AliTOFtrackerV1() {
98 if(!(AliCDBManager::Instance()->GetCacheFlag())){
103 delete fHDigClusTime;
110 delete fHRecSigYVsPWin;
111 delete fHRecSigZVsPWin;
124 for (Int_t ii=0; ii<kMaxCluster; ii++)
125 if (fClusters[ii]) fClusters[ii]->Delete();
128 //_____________________________________________________________________________
129 void AliTOFtrackerV1::GetPidSettings(AliESDpid *esdPID) {
131 // Sets TOF resolution from RecoParams
134 esdPID->GetTOFResponse().SetTimeResolution(fkRecoParam->GetTimeResolution());
136 AliWarning("fkRecoParam not yet set; cannot set PID settings");
138 //_____________________________________________________________________________
139 Int_t AliTOFtrackerV1::PropagateBack(AliESDEvent * const event) {
141 // Gets seeds from ESD event and Match with TOF Clusters
144 // initialize RecoParam for current event
145 AliDebug(1,"Initializing params for TOF");
147 fkRecoParam = AliTOFReconstructor::GetRecoParam(); // instantiate reco param from STEER...
149 if (fkRecoParam == 0x0) {
150 AliFatal("No Reco Param found for TOF!!!");
152 //fkRecoParam->Dump();
153 //if(fkRecoParam->GetApplyPbPbCuts())fkRecoParam=fkRecoParam->GetPbPbparam();
154 //fkRecoParam->PrintParameters();
156 //Initialise some counters
165 Int_t ntrk=event->GetNumberOfTracks();
168 //Load ESD tracks into a local Array of ESD Seeds
169 for (Int_t i=0; i<fNseeds; i++)
170 fSeeds->AddLast(event->GetTrack(i));
172 //Prepare ESD tracks candidates for TOF Matching
178 AliInfo(Form("Number of matched tracks = %d (good = %d, bad = %d)",fnmatch,fngoodmatch,fnbadmatch));
180 //Update the matched ESD tracks
182 for (Int_t i=0; i<ntrk; i++) {
183 AliESDtrack *t=event->GetTrack(i);
184 AliESDtrack *seed =(AliESDtrack*)fSeeds->At(i);
186 if ( (seed->GetStatus()&AliESDtrack::kTOFin)!=0 ) {
187 t->SetStatus(AliESDtrack::kTOFin);
188 //if(seed->GetTOFsignal()>0){
189 if ( (seed->GetStatus()&AliESDtrack::kTOFout)!=0 ) {
190 t->SetStatus(AliESDtrack::kTOFout);
191 t->SetTOFsignal(seed->GetTOFsignal());
192 t->SetTOFcluster(seed->GetTOFcluster());
193 t->SetTOFsignalToT(seed->GetTOFsignalToT());
194 t->SetTOFsignalRaw(seed->GetTOFsignalRaw());
195 t->SetTOFsignalDz(seed->GetTOFsignalDz());
196 t->SetTOFsignalDx(seed->GetTOFsignalDx());
197 t->SetTOFDeltaBC(seed->GetTOFDeltaBC());
198 t->SetTOFL0L1(seed->GetTOFL0L1());
199 t->SetTOFCalChannel(seed->GetTOFCalChannel());
200 Int_t tlab[3]; seed->GetTOFLabel(tlab);
201 t->SetTOFLabel(tlab);
203 Double_t alphaA = (Double_t)t->GetAlpha();
204 Double_t xA = (Double_t)t->GetX();
205 Double_t yA = (Double_t)t->GetY();
206 Double_t zA = (Double_t)t->GetZ();
207 Double_t p1A = (Double_t)t->GetSnp();
208 Double_t p2A = (Double_t)t->GetTgl();
209 Double_t p3A = (Double_t)t->GetSigned1Pt();
210 const Double_t *covA = (Double_t*)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 = (Double_t)t->GetAlpha();
243 Double_t xB = (Double_t)t->GetX();
244 Double_t yB = (Double_t)t->GetY();
245 Double_t zB = (Double_t)t->GetZ();
246 Double_t p1B = (Double_t)t->GetSnp();
247 Double_t p2B = (Double_t)t->GetTgl();
248 Double_t p3B = (Double_t)t->GetSigned1Pt();
249 const Double_t *covB = (Double_t*)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 %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
311 TClonesArray &aTOFTrack = *fTracks;
312 for (Int_t i=0; i<fNseeds; i++) {
314 AliESDtrack *t =(AliESDtrack*)fSeeds->At(i);
315 if ((t->GetStatus()&AliESDtrack::kTPCout)==0)continue;
317 AliTOFtrack *track = new AliTOFtrack(*t); // New
318 Float_t x = (Float_t)track->GetX(); //New
321 if ( ( (t->GetStatus()&AliESDtrack::kTRDout)!=0 ) ) {
323 AliDebug(1,Form(" Before propagation till inner TOF radius, ESDtrackLength=%f, TOFtrackLength=%f",t->GetIntegratedLength(),track->GetIntegratedLength()));
325 // TRD 'good' tracks, already propagated at 371 cm
326 if ( x >= AliTOFGeometry::Rmin() ) {
328 if ( track->PropagateToInnerTOF() ) {
330 AliDebug(1,Form(" TRD propagated track till rho = %fcm."
331 " And then the track has been propagated till rho = %fcm.",
332 x, (Float_t)track->GetX()));
334 track->SetSeedIndex(i);
335 t->UpdateTrackParams(track,AliESDtrack::kTOFin);
336 new(aTOFTrack[fNseedsTOF]) AliTOFtrack(*track);
340 AliDebug(1,Form(" After propagation till inner TOF radius, ESDtrackLength=%f, TOFtrackLength=%f",t->GetIntegratedLength(),track->GetIntegratedLength()));
345 else { // TRD 'good' tracks, propagated rho<371cm
347 if ( track->PropagateToInnerTOF() ) {
349 AliDebug(1,Form(" TRD propagated track till rho = %fcm."
350 " And then the track has been propagated till rho = %fcm.",
351 x, (Float_t)track->GetX()));
353 track->SetSeedIndex(i);
354 t->UpdateTrackParams(track,AliESDtrack::kTOFin);
355 new(aTOFTrack[fNseedsTOF]) AliTOFtrack(*track);
359 AliDebug(1,Form(" After propagation till inner TOF radius, ESDtrackLength=%f, TOFtrackLength=%f",t->GetIntegratedLength(),track->GetIntegratedLength()));
367 else { // Propagate the rest of TPCbp
369 AliDebug(1,Form(" Before propagation till inner TOF radius, ESDtrackLength=%f, TOFtrackLength=%f",t->GetIntegratedLength(),track->GetIntegratedLength()));
371 if ( track->PropagateToInnerTOF() ) {
373 AliDebug(1,Form(" TRD propagated track till rho = %fcm."
374 " And then the track has been propagated till rho = %fcm.",
375 x, (Float_t)track->GetX()));
377 track->SetSeedIndex(i);
378 t->UpdateTrackParams(track,AliESDtrack::kTOFin);
379 new(aTOFTrack[fNseedsTOF]) AliTOFtrack(*track);
387 AliInfo(Form("Number of TOF seeds = %d (kTRDout371 = %d, kTRDoutLess371 = %d, !kTRDout = %d)",fNseedsTOF,seedsTOF1,seedsTOF3,seedsTOF2));
389 // Sort according uncertainties on track position
393 //_________________________________________________________________________
394 void AliTOFtrackerV1::MatchTracks( ){
396 //Match ESD tracks to clusters in TOF
400 // Parameters regulating the reconstruction
401 Float_t dY=AliTOFGeometry::XPad();
402 Float_t dZ=AliTOFGeometry::ZPad();
404 const Float_t kTimeOffset = 0.; // time offset for tracking algorithm [ps]
406 const Int_t kncmax = 100;
407 Float_t sensRadius = fkRecoParam->GetSensRadius();
408 Float_t scaleFact = fkRecoParam->GetWindowScaleFact();
409 Float_t dyMax=fkRecoParam->GetWindowSizeMaxY();
410 Float_t dzMax=fkRecoParam->GetWindowSizeMaxZ();
411 Double_t maxChi2=fkRecoParam->GetMaxChi2();
412 Bool_t timeWalkCorr = fkRecoParam->GetTimeWalkCorr();
413 AliDebug(1,"++++++++++++++TOF Reconstruction Parameters:++++++++++++ \n");
414 AliDebug(1,Form("TOF sens radius: %f",sensRadius));
415 AliDebug(1,Form("TOF Window scale factor: %f",scaleFact));
416 AliDebug(1,Form("TOF Window max dy: %f",dyMax));
417 AliDebug(1,Form("TOF Window max dz: %f",dzMax));
418 AliDebug(1,Form("TOF Max Chi2: %f",maxChi2));
419 AliDebug(1,Form("Time Walk Correction? : %d",timeWalkCorr));
423 for (Int_t iseed=0; iseed<fNseedsTOF; iseed++) {
425 AliTOFtrack *track =(AliTOFtrack*)fTracks->UncheckedAt(iseed);
426 AliESDtrack *t =(AliESDtrack*)fSeeds->At(track->GetSeedIndex());
427 //if ( t->GetTOFsignal()>0. ) continue;
428 if ( (t->GetStatus()&AliESDtrack::kTOFout)!=0 ) continue;
429 AliTOFtrack *trackTOFin = new AliTOFtrack(*track);
431 // Determine a window around the track
432 Double_t x,par[5]; trackTOFin->GetExternalParameters(x,par);
433 Double_t cov[15]; trackTOFin->GetExternalCovariance(cov);
435 if (cov[0]<0. || cov[2]<0.) {
436 AliWarning(Form("Very strange track (%d)! At least one of its covariance matrix diagonal elements is negative!",iseed));
442 Double_t dz = scaleFact*3.*TMath::Sqrt(TMath::Abs(cov[2])+dZ*dZ/12.);
443 Double_t dphi = scaleFact*3.*TMath::Sqrt(TMath::Abs(cov[0])+dY*dY/12.)/sensRadius;
445 Double_t phi=TMath::ATan2(par[0],x) + trackTOFin->GetAlpha();
446 if (phi<-TMath::Pi())phi+=2*TMath::Pi();
447 if (phi>=TMath::Pi())phi-=2*TMath::Pi();
449 //upper limit on window's size.
450 if (dz> dzMax) dz=dzMax;
451 if (dphi*sensRadius> dyMax) dphi=dyMax/sensRadius;
453 // find the clusters inside the selected window
455 AliTOFcluster *clusters[kncmax]; // pointers to the clusters in the window
456 Int_t index[kncmax];//to keep track of the cluster index
457 for (Int_t k=FindClusterIndex(z-dz); k<fN; k++) {
458 AliTOFcluster *c=fClusters[k];
459 // if(nc>kncmax)break; /* R+ fix (buffer overflow) */
461 AliWarning("No more matchable clusters can be stored! Please, increase the corresponding vectors size.");
462 break; /* R+ fix (buffer overflow protection) */
464 if (c->GetZ() > z+dz) break;
465 if (c->IsUsed()) continue;
466 if (!c->GetStatus()) {
467 AliDebug(1,"Cluster in channel declared bad!");
468 continue; // skip bad channels as declared in OCDB
470 Float_t xyz[3]; c->GetGlobalXYZ(xyz);
471 Double_t clPhi=TMath::ATan2(xyz[1],xyz[0]);
472 Double_t dph=TMath::Abs(clPhi-phi);
473 if (dph>TMath::Pi()) dph-=2.*TMath::Pi();
474 if (TMath::Abs(dph)>dphi) continue;
480 AliDebug(1,Form(" Number of matchable TOF clusters for the track number %d: %d",iseed,nc));
482 //start propagation: go to the average TOF pad middle plane at ~379.5 cm
484 // First of all, propagate the track...
485 Float_t xTOF = sensRadius;
486 if (!(trackTOFin->PropagateTo(xTOF))) {
491 // ...and then, if necessary, rotate the track
492 Double_t ymax = xTOF*TMath::Tan(0.5*AliTOFGeometry::GetAlpha());
493 Double_t ysect = trackTOFin->GetY();
495 if (!(trackTOFin->Rotate(AliTOFGeometry::GetAlpha()))) {
499 } else if (ysect <-ymax) {
500 if (!(trackTOFin->Rotate(-AliTOFGeometry::GetAlpha()))) {
507 AliTOFcluster *bestCluster=0;
508 Double_t bestChi2=maxChi2;
510 // for (Int_t i=0; i<nc; i++){ /* R+ fix (unsafe) */
511 for (Int_t i=0; i<nc && i<kncmax; i++){ /* R+ fix (buffer overflow protection) */
512 AliTOFcluster *c=clusters[i]; // one of the preselected clusters
513 Double_t chi2=trackTOFin->GetPredictedChi2((AliCluster3D*)c);
514 if (chi2 >= bestChi2) continue;
520 if (!bestCluster) { // no matching , go to the next track
528 AliDebug(2, Form("%7i %7i %10i %10i %10i %10i %7i",
531 TMath::Abs(trackTOFin->GetLabel()),
532 bestCluster->GetLabel(0),
533 bestCluster->GetLabel(1),
534 bestCluster->GetLabel(2),
539 (bestCluster->GetLabel(0)==TMath::Abs(trackTOFin->GetLabel()))
541 (bestCluster->GetLabel(1)==TMath::Abs(trackTOFin->GetLabel()))
543 (bestCluster->GetLabel(2)==TMath::Abs(trackTOFin->GetLabel()))
546 AliDebug(2,Form(" track label good %5d",trackTOFin->GetLabel()));
550 AliDebug(2,Form(" track label bad %5d",trackTOFin->GetLabel()));
553 //Propagate the track to the best matched cluster
554 if (!(trackTOFin->PropagateTo(bestCluster))) {
559 // If necessary, rotate the track
560 Double_t yATxMax = trackTOFin->GetX()*TMath::Tan(0.5*AliTOFGeometry::GetAlpha());
561 Double_t yATx = trackTOFin->GetY();
562 if (yATx > yATxMax) {
563 if (!(trackTOFin->Rotate(AliTOFGeometry::GetAlpha()))) {
567 } else if (yATx <-yATxMax) {
568 if (!(trackTOFin->Rotate(-AliTOFGeometry::GetAlpha()))) {
574 // Fill the track residual histograms.
575 FillResiduals(trackTOFin,bestCluster,kFALSE);
577 //now take the local distance in Z from the pad center for time walk correction
578 Float_t tiltangle = AliTOFGeometry::GetAngles(bestCluster->GetDetInd(1),bestCluster->GetDetInd(2))*TMath::DegToRad();
579 Double_t dzTW=trackTOFin->GetZ()-bestCluster->GetZ(); // in cm - in the ALICE RF -
580 dzTW/=TMath::Cos(tiltangle); // from ALICE/tracking RF to pad RF (1)
581 dzTW=-dzTW; // from ALICE/tracking RF to pad RF (2)
582 if (tiltangle!=0.) AliDebug(2,Form(" rho_track = %f --- rho_cluster = %f ",trackTOFin->GetX(),bestCluster->GetX()));
584 //update the ESD track and delete the TOFtrack
585 t->UpdateTrackParams(trackTOFin,AliESDtrack::kTOFout);
587 // Store quantities to be used in the TOF Calibration
588 Float_t tToT=AliTOFGeometry::ToTBinWidth()*bestCluster->GetToT()*1E-3; // in ns
589 t->SetTOFsignalToT(tToT);
590 Float_t rawTime=AliTOFGeometry::TdcBinWidth()*bestCluster->GetTDCRAW()+kTimeOffset; // RAW time,in ps
591 t->SetTOFsignalRaw(rawTime);
592 t->SetTOFsignalDz(dzTW);
594 Float_t deltaY = trackTOFin->GetY()-bestCluster->GetY();
595 t->SetTOFsignalDx(deltaY);
597 t->SetTOFDeltaBC(bestCluster->GetDeltaBC());
598 t->SetTOFL0L1(bestCluster->GetL0L1Latency());
600 Float_t distR = (trackTOFin->GetX()-bestCluster->GetX())*
601 (trackTOFin->GetX()-bestCluster->GetX());
602 distR+=deltaY*deltaY;
604 distR = TMath::Sqrt(distR);
605 Float_t info[10] = {distR, deltaY, dzTW,
606 0.,0.,0.,0.,0.,0.,0.};
610 ind[0]=bestCluster->GetDetInd(0);
611 ind[1]=bestCluster->GetDetInd(1);
612 ind[2]=bestCluster->GetDetInd(2);
613 ind[3]=bestCluster->GetDetInd(3);
614 ind[4]=bestCluster->GetDetInd(4);
615 Int_t calindex = AliTOFGeometry::GetIndex(ind);
616 t->SetTOFCalChannel(calindex);
618 // keep track of the track labels in the matched cluster
620 tlab[0]=bestCluster->GetLabel(0);
621 tlab[1]=bestCluster->GetLabel(1);
622 tlab[2]=bestCluster->GetLabel(2);
623 AliDebug(2,Form(" tdc time of the matched track %6d = ",bestCluster->GetTDC()));
624 Double_t tof=AliTOFGeometry::TdcBinWidth()*bestCluster->GetTDC()+kTimeOffset; // in ps
625 AliDebug(2,Form(" tof time of the matched track: %f = ",tof));
626 Double_t tofcorr=tof;
627 if(timeWalkCorr)tofcorr=CorrectTimeWalk(dzTW,tof);
628 AliDebug(2,Form(" tof time of the matched track, after TW corr: %f = ",tofcorr));
629 //Set TOF time signal and pointer to the matched cluster
630 t->SetTOFsignal(tofcorr);
631 t->SetTOFcluster(idclus); // pointing to the recPoints tree
632 t->SetTOFLabel(tlab);
634 AliDebug(2,Form(" Setting TOF raw time: %f z distance: %f corrected time: %f",rawTime,dzTW,tofcorr));
636 Double_t mom=t->GetP();
637 AliDebug(2,Form(" Momentum for track %d -> %f", iseed,mom));
638 // Fill Reco-QA histos for Reconstruction
639 fHRecNClus->Fill(nc);
640 fHRecChi2->Fill(bestChi2);
641 fHRecDistZ->Fill(dzTW);
643 fHRecSigYVsP->Fill(mom,TMath::Sqrt(cov[0]));
645 fHRecSigYVsP->Fill(mom,-TMath::Sqrt(-cov[0]));
647 fHRecSigZVsP->Fill(mom,TMath::Sqrt(cov[2]));
649 fHRecSigZVsP->Fill(mom,-TMath::Sqrt(-cov[2]));
650 fHRecSigYVsPWin->Fill(mom,dphi*sensRadius);
651 fHRecSigZVsPWin->Fill(mom,dz);
653 // Fill Tree for on-the-fly offline Calibration
654 // no longer there - all info is in the ESDs now
661 //_________________________________________________________________________
662 Int_t AliTOFtrackerV1::LoadClusters(TTree *cTree) {
663 //--------------------------------------------------------------------
664 //This function loads the TOF clusters
665 //--------------------------------------------------------------------
667 Int_t npadX = AliTOFGeometry::NpadX();
668 Int_t npadZ = AliTOFGeometry::NpadZ();
669 Int_t nStripA = AliTOFGeometry::NStripA();
670 Int_t nStripB = AliTOFGeometry::NStripB();
671 Int_t nStripC = AliTOFGeometry::NStripC();
673 TBranch *branch=cTree->GetBranch("TOF");
675 AliError("can't get the branch with the TOF clusters !");
679 static TClonesArray dummy("AliTOFcluster",10000);
681 TClonesArray *clusters=&dummy;
682 branch->SetAddress(&clusters);
685 Int_t nc=clusters->GetEntriesFast();
686 fHDigNClus->Fill(nc);
688 AliInfo(Form("Number of clusters: %d",nc));
690 for (Int_t i=0; i<nc; i++) {
691 AliTOFcluster *c=(AliTOFcluster*)clusters->UncheckedAt(i);
692 //PH fClusters[i]=new AliTOFcluster(*c); fN++;
693 fClusters[i]=c; fN++;
695 // Fill Digits QA histos
697 Int_t isector = c->GetDetInd(0);
698 Int_t iplate = c->GetDetInd(1);
699 Int_t istrip = c->GetDetInd(2);
700 Int_t ipadX = c->GetDetInd(4);
701 Int_t ipadZ = c->GetDetInd(3);
703 Float_t time =(AliTOFGeometry::TdcBinWidth()*c->GetTDC())*1E-3; // in ns
704 Float_t tot = (AliTOFGeometry::TdcBinWidth()*c->GetToT())*1E-3;//in ns
706 Int_t stripOffset = 0;
712 stripOffset = nStripC;
715 stripOffset = nStripC+nStripB;
718 stripOffset = nStripC+nStripB+nStripA;
721 stripOffset = nStripC+nStripB+nStripA+nStripB;
724 AliError(Form("Wrong plate number in TOF (%d) !",iplate));
727 Int_t zindex=npadZ*(istrip+stripOffset)+(ipadZ+1);
728 Int_t phiindex=npadX*isector+ipadX+1;
729 fHDigClusMap->Fill(zindex,phiindex);
730 fHDigClusTime->Fill(time);
731 fHDigClusToT->Fill(tot);
737 //_________________________________________________________________________
738 void AliTOFtrackerV1::UnloadClusters() {
739 //--------------------------------------------------------------------
740 //This function unloads TOF clusters
741 //--------------------------------------------------------------------
742 for (Int_t i=0; i<fN; i++) {
743 //PH delete fClusters[i];
749 //_________________________________________________________________________
750 Int_t AliTOFtrackerV1::FindClusterIndex(Double_t z) const {
751 //--------------------------------------------------------------------
752 // This function returns the index of the nearest cluster
753 //--------------------------------------------------------------------
755 //Here we need to get the Z in the tracking system
758 if (z <= fClusters[0]->GetZ()) return 0;
759 if (z > fClusters[fN-1]->GetZ()) return fN;
760 Int_t b=0, e=fN-1, m=(b+e)/2;
761 for (; b<e; m=(b+e)/2) {
762 if (z > fClusters[m]->GetZ()) b=m+1;
768 //_________________________________________________________________________
769 Bool_t AliTOFtrackerV1::GetTrackPoint(Int_t index, AliTrackPoint& p) const
771 // Get track space point with index i
772 // Coordinates are in the global system
773 AliTOFcluster *cl = fClusters[index];
775 cl->GetGlobalXYZ(xyz);
776 Float_t phi=TMath::ATan2(xyz[1],xyz[0]);
777 Float_t phiangle = (Int_t(phi*TMath::RadToDeg()/20.)+0.5)*20.*TMath::DegToRad();
778 Float_t sinphi = TMath::Sin(phiangle), cosphi = TMath::Cos(phiangle);
779 Float_t tiltangle = AliTOFGeometry::GetAngles(cl->GetDetInd(1),cl->GetDetInd(2))*TMath::DegToRad();
780 Float_t sinth = TMath::Sin(tiltangle), costh = TMath::Cos(tiltangle);
781 Float_t sigmay2 = AliTOFGeometry::XPad()*AliTOFGeometry::XPad()/12.;
782 Float_t sigmaz2 = AliTOFGeometry::ZPad()*AliTOFGeometry::ZPad()/12.;
784 cov[0] = sinphi*sinphi*sigmay2 + cosphi*cosphi*sinth*sinth*sigmaz2;
785 cov[1] = -sinphi*cosphi*sigmay2 + sinphi*cosphi*sinth*sinth*sigmaz2;
786 cov[2] = -cosphi*sinth*costh*sigmaz2;
787 cov[3] = cosphi*cosphi*sigmay2 + sinphi*sinphi*sinth*sinth*sigmaz2;
788 cov[4] = -sinphi*sinth*costh*sigmaz2;
789 cov[5] = costh*costh*sigmaz2;
790 p.SetXYZ(xyz[0],xyz[1],xyz[2],cov);
792 // Detector numbering scheme
793 Int_t nSector = AliTOFGeometry::NSectors();
794 Int_t nPlate = AliTOFGeometry::NPlates();
795 Int_t nStripA = AliTOFGeometry::NStripA();
796 Int_t nStripB = AliTOFGeometry::NStripB();
797 Int_t nStripC = AliTOFGeometry::NStripC();
799 Int_t isector = cl->GetDetInd(0);
800 if (isector >= nSector)
801 AliError(Form("Wrong sector number in TOF (%d) !",isector));
802 Int_t iplate = cl->GetDetInd(1);
803 if (iplate >= nPlate)
804 AliError(Form("Wrong plate number in TOF (%d) !",iplate));
805 Int_t istrip = cl->GetDetInd(2);
807 Int_t stripOffset = 0;
813 stripOffset = nStripC;
816 stripOffset = nStripC+nStripB;
819 stripOffset = nStripC+nStripB+nStripA;
822 stripOffset = nStripC+nStripB+nStripA+nStripB;
825 AliError(Form("Wrong plate number in TOF (%d) !",iplate));
829 Int_t idet = (2*(nStripC+nStripB)+nStripA)*isector +
832 UShort_t volid = AliGeomManager::LayerToVolUID(AliGeomManager::kTOF,idet);
833 p.SetVolumeID((UShort_t)volid);
836 //_________________________________________________________________________
837 void AliTOFtrackerV1::InitCheckHists() {
839 //Init histos for Digits/Reco QA and Calibration
841 TDirectory *dir = gDirectory;
842 TFile *logFileTOF = 0;
844 TSeqCollection *list = gROOT->GetListOfFiles();
845 int n = list->GetEntries();
846 Bool_t isThere=kFALSE;
847 for(int i=0; i<n; i++) {
848 logFileTOF = (TFile*)list->At(i);
849 if (strstr(logFileTOF->GetName(), "TOFQA.root")){
855 if(!isThere)logFileTOF = new TFile( "TOFQA.root","RECREATE");
859 fHDigClusMap = new TH2F("TOFDig_ClusMap", "",182,0.5,182.5,864, 0.5,864.5);
860 fHDigNClus = new TH1F("TOFDig_NClus", "",200,0.5,200.5);
861 fHDigClusTime = new TH1F("TOFDig_ClusTime", "",2000,0.,200.);
862 fHDigClusToT = new TH1F("TOFDig_ClusToT", "",500,0.,100);
865 fHRecNClus =new TH1F("TOFRec_NClusW", "",50,0.5,50.5);
866 fHRecDistZ=new TH1F("TOFRec_DistZ", "",50,0.5,10.5);
867 fHRecChi2=new TH1F("TOFRec_Chi2", "",100,0.,10.);
868 fHRecSigYVsP=new TH2F("TOFDig_SigYVsP", "",40,0.,4.,100, 0.,5.);
869 fHRecSigZVsP=new TH2F("TOFDig_SigZVsP", "",40,0.,4.,100, 0.,5.);
870 fHRecSigYVsPWin=new TH2F("TOFDig_SigYVsPWin", "",40,0.,4.,100, 0.,50.);
871 fHRecSigZVsPWin=new TH2F("TOFDig_SigZVsPWin", "",40,0.,4.,100, 0.,50.);
877 //_________________________________________________________________________
878 void AliTOFtrackerV1::SaveCheckHists() {
880 //write histos for Digits/Reco QA and Calibration
882 TDirectory *dir = gDirectory;
883 //TFile *logFile = 0;
884 TFile *logFileTOF = 0;
886 TSeqCollection *list = gROOT->GetListOfFiles();
887 int n = list->GetEntries();
889 for(int i=0; i<n; i++) {
890 logFile = (TFile*)list->At(i);
891 if (strstr(logFile->GetName(), "AliESDs.root")) break;
894 Bool_t isThere=kFALSE;
895 for(int i=0; i<n; i++) {
896 logFileTOF = (TFile*)list->At(i);
897 if (strstr(logFileTOF->GetName(), "TOFQA.root")){
904 AliError(Form("File TOFQA.root not found!! not wring histograms...."));
909 fHDigClusMap->Write(fHDigClusMap->GetName(), TObject::kOverwrite);
910 fHDigNClus->Write(fHDigNClus->GetName(), TObject::kOverwrite);
911 fHDigClusTime->Write(fHDigClusTime->GetName(), TObject::kOverwrite);
912 fHDigClusToT->Write(fHDigClusToT->GetName(), TObject::kOverwrite);
913 fHRecNClus->Write(fHRecNClus->GetName(), TObject::kOverwrite);
914 fHRecChi2->Write(fHRecChi2->GetName(), TObject::kOverwrite);
915 fHRecDistZ->Write(fHRecDistZ->GetName(), TObject::kOverwrite);
916 fHRecSigYVsP->Write(fHRecSigYVsP->GetName(), TObject::kOverwrite);
917 fHRecSigZVsP->Write(fHRecSigZVsP->GetName(), TObject::kOverwrite);
918 fHRecSigYVsPWin->Write(fHRecSigYVsPWin->GetName(), TObject::kOverwrite);
919 fHRecSigZVsPWin->Write(fHRecSigZVsPWin->GetName(), TObject::kOverwrite);
926 //_________________________________________________________________________
927 Float_t AliTOFtrackerV1::CorrectTimeWalk( Float_t dist, Float_t tof) const {
929 //dummy, for the moment
931 if(dist<AliTOFGeometry::ZPad()*0.5){
933 //place here the actual correction
939 //_________________________________________________________________________
940 Float_t AliTOFtrackerV1::GetTimeZerofromT0(const AliESDEvent * const event) const {
942 //Returns TimeZero as measured by T0 detector
944 return event->GetT0();
946 //_________________________________________________________________________
947 Float_t AliTOFtrackerV1::GetTimeZerofromTOF(AliESDEvent * /*event*/) const {
949 //dummy, for the moment. T0 algorithm using tracks on TOF
951 //place T0 algo here...
955 //_________________________________________________________________________
957 void AliTOFtrackerV1::FillClusterArray(TObjArray* arr) const
960 // Returns the TOF cluster array
966 for (Int_t i=0; i<fN; ++i) arr->Add(fClusters[i]);