LCOV - code coverage report
Current view: top level - TOF/TOFrec - AliTOFtrackerV1.cxx (source / functions) Hit Total Coverage
Test: coverage.info Lines: 1 501 0.2 %
Date: 2016-06-14 17:26:59 Functions: 1 20 5.0 %

          Line data    Source code
       1             : /**************************************************************************
       2             :  * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
       3             :  *                                                                        *
       4             :  * Author: The ALICE Off-line Project.                                    *
       5             :  * Contributors are mentioned in the code where appropriate.              *
       6             :  *                                                                        *
       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             : **************************************************************************/
      15             : 
      16             : //--------------------------------------------------------------------//
      17             : //                                                                    //
      18             : // AliTOFtrackerV1 Class                                              //
      19             : // Task: Perform association of the ESD tracks to TOF Clusters        //
      20             : // and Update ESD track with associated TOF Cluster parameters        //
      21             : //                                                                    //
      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                             //
      26             : //                                                                    //
      27             : //--------------------------------------------------------------------//
      28             : 
      29             : #include <Rtypes.h>
      30             : #include <TROOT.h>
      31             : 
      32             : #include <TClonesArray.h>
      33             : #include <TObjArray.h>
      34             : #include <TTree.h>
      35             : #include <TFile.h>
      36             : #include <TH1F.h>
      37             : #include <TH2F.h>
      38             : #include <TSeqCollection.h>
      39             : 
      40             : #include "AliESDtrack.h"
      41             : #include "AliESDEvent.h"
      42             : #include "AliESDpid.h"
      43             : #include "AliLog.h"
      44             : #include "AliTrackPointArray.h"
      45             : #include "AliGeomManager.h"
      46             : #include "AliCDBManager.h"
      47             : 
      48             : #include "AliTOFRecoParam.h"
      49             : #include "AliTOFReconstructor.h"
      50             : #include "AliTOFcluster.h"
      51             : #include "AliTOFGeometry.h"
      52             : #include "AliTOFtrackerV1.h"
      53             : #include "AliTOFtrack.h"
      54             : 
      55             : //extern TROOT *gROOT;
      56             : 
      57          26 : ClassImp(AliTOFtrackerV1)
      58             : 
      59             : //_____________________________________________________________________________
      60           0 : AliTOFtrackerV1::AliTOFtrackerV1():
      61           0 :   fkRecoParam(0x0),
      62           0 :   fN(0),
      63           0 :   fNseeds(0),
      64           0 :   fNseedsTOF(0),
      65           0 :   fngoodmatch(0),
      66           0 :   fnbadmatch(0),
      67           0 :   fnunmatch(0),
      68           0 :   fnmatch(0),
      69           0 :   fTracks(new TClonesArray("AliTOFtrack")),
      70           0 :   fSeeds(new TObjArray(100)),
      71           0 :   fHDigClusMap(0x0),
      72           0 :   fHDigNClus(0x0),
      73           0 :   fHDigClusTime(0x0),
      74           0 :   fHDigClusToT(0x0),
      75           0 :   fHRecNClus(0x0),
      76           0 :   fHRecChi2(0x0),
      77           0 :   fHRecDistZ(0x0),
      78           0 :   fHRecSigYVsP(0x0),
      79           0 :   fHRecSigZVsP(0x0),
      80           0 :   fHRecSigYVsPWin(0x0),
      81           0 :   fHRecSigZVsPWin(0x0)
      82           0 :  { 
      83             :    //AliTOFtrackerV1 main Ctor
      84             : 
      85           0 :    for (Int_t ii=0; ii<kMaxCluster; ii++) fClusters[ii]=0x0;
      86             : 
      87           0 :    InitCheckHists();
      88             : 
      89           0 : }
      90             : //_____________________________________________________________________________
      91           0 : AliTOFtrackerV1::~AliTOFtrackerV1() {
      92             :   //
      93             :   // Dtor
      94             :   //
      95             : 
      96           0 :   SaveCheckHists();
      97             : 
      98           0 :   if(!(AliCDBManager::Instance()->GetCacheFlag())){
      99           0 :     delete fkRecoParam;
     100             :   }
     101           0 :   delete fHDigClusMap;
     102           0 :   delete fHDigNClus;
     103           0 :   delete fHDigClusTime;
     104           0 :   delete fHDigClusToT;
     105           0 :   delete fHRecNClus;
     106           0 :   delete fHRecChi2;
     107           0 :   delete fHRecDistZ;
     108           0 :   delete fHRecSigYVsP;
     109           0 :   delete fHRecSigZVsP;
     110           0 :   delete fHRecSigYVsPWin;
     111           0 :   delete fHRecSigZVsPWin;
     112           0 :   if (fTracks){
     113           0 :     fTracks->Delete();
     114           0 :     delete fTracks;
     115           0 :     fTracks=0x0;
     116           0 :   }
     117           0 :   if (fSeeds){
     118           0 :     fSeeds->Delete();
     119           0 :     delete fSeeds;
     120           0 :     fSeeds=0x0;
     121           0 :   }
     122             : 
     123             : 
     124           0 :   for (Int_t ii=0; ii<kMaxCluster; ii++)
     125           0 :     if (fClusters[ii]) fClusters[ii]->Delete();
     126             : 
     127           0 : }
     128             : //_____________________________________________________________________________
     129             : void AliTOFtrackerV1::GetPidSettings(AliESDpid *esdPID) {
     130             :   // 
     131             :   // Sets TOF resolution from RecoParams
     132             :   //
     133           0 :   if (fkRecoParam)
     134           0 :     esdPID->GetTOFResponse().SetTimeResolution(fkRecoParam->GetTimeResolution());
     135             :   else
     136           0 :     AliWarning("fkRecoParam not yet set; cannot set PID settings");
     137           0 : }
     138             : //_____________________________________________________________________________
     139             : Int_t AliTOFtrackerV1::PropagateBack(AliESDEvent * const event) {
     140             :   //
     141             :   // Gets seeds from ESD event and Match with TOF Clusters
     142             :   //
     143             : 
     144           0 :   if (fN==0) {
     145           0 :     AliInfo("No TOF recPoints to be matched with reconstructed tracks");
     146           0 :     return 0;
     147             :   }
     148             : 
     149             :   // initialize RecoParam for current event
     150           0 :   AliDebug(1,"Initializing params for TOF");
     151             : 
     152           0 :   fkRecoParam = AliTOFReconstructor::GetRecoParam();  // instantiate reco param from STEER...
     153             : 
     154           0 :   if (fkRecoParam == 0x0) { 
     155           0 :     AliFatal("No Reco Param found for TOF!!!");
     156           0 :   }
     157             :   //fkRecoParam->Dump();
     158             :   //if(fkRecoParam->GetApplyPbPbCuts())fkRecoParam=fkRecoParam->GetPbPbparam();
     159             :   //fkRecoParam->PrintParameters();
     160             : 
     161             :   //Initialise some counters
     162             : 
     163           0 :   fNseeds=0;
     164           0 :   fNseedsTOF=0;
     165           0 :   fngoodmatch=0;
     166           0 :   fnbadmatch=0;
     167           0 :   fnunmatch=0;
     168           0 :   fnmatch=0;
     169             : 
     170           0 :   Int_t ntrk=event->GetNumberOfTracks();
     171           0 :   fNseeds = ntrk;
     172             : 
     173             :   //Load ESD tracks into a local Array of ESD Seeds
     174           0 :   for (Int_t i=0; i<fNseeds; i++){
     175           0 :     fSeeds->AddLast(event->GetTrack(i));
     176           0 :     event->GetTrack(i)->SetESDEvent(event);
     177             :   }
     178             : 
     179             :   //Prepare ESD tracks candidates for TOF Matching
     180           0 :   CollectESD();
     181             : 
     182           0 :   if (fNseeds==0 || fNseedsTOF==0) {
     183           0 :     AliInfo("No seeds to try TOF match");
     184           0 :     return 0;
     185             :   }
     186             : 
     187             :   //Matching Step
     188           0 :   MatchTracks();
     189             : 
     190           0 :   AliInfo(Form("Number of matched tracks = %d (good = %d, bad = %d)",fnmatch,fngoodmatch,fnbadmatch));
     191             : 
     192             :   //Update the matched ESD tracks
     193             : 
     194           0 :   for (Int_t i=0; i<ntrk; i++) {
     195           0 :     AliESDtrack *t=event->GetTrack(i);
     196           0 :     AliESDtrack *seed =(AliESDtrack*)fSeeds->At(i);
     197             : 
     198           0 :     if ( (seed->GetStatus()&AliESDtrack::kTOFin)!=0 ) {
     199           0 :       t->SetStatus(AliESDtrack::kTOFin);
     200             :       //if(seed->GetTOFsignal()>0){
     201           0 :       if ( (seed->GetStatus()&AliESDtrack::kTOFout)!=0 ) {
     202           0 :         t->SetStatus(AliESDtrack::kTOFout);
     203           0 :         t->SetTOFsignal(seed->GetTOFsignal());
     204           0 :         t->SetTOFcluster(seed->GetTOFcluster());
     205           0 :         t->SetTOFsignalToT(seed->GetTOFsignalToT());
     206           0 :         t->SetTOFsignalRaw(seed->GetTOFsignalRaw());
     207           0 :         t->SetTOFsignalDz(seed->GetTOFsignalDz());
     208           0 :         t->SetTOFsignalDx(seed->GetTOFsignalDx());
     209           0 :         t->SetTOFDeltaBC(seed->GetTOFDeltaBC());
     210           0 :         t->SetTOFL0L1(seed->GetTOFL0L1());
     211           0 :         t->SetTOFCalChannel(seed->GetTOFCalChannel());
     212           0 :         Int_t tlab[3]; seed->GetTOFLabel(tlab);
     213           0 :         t->SetTOFLabel(tlab);
     214             : 
     215           0 :         Double_t alphaA = (Double_t)t->GetAlpha();
     216           0 :         Double_t xA = (Double_t)t->GetX();
     217           0 :         Double_t yA = (Double_t)t->GetY();
     218           0 :         Double_t zA = (Double_t)t->GetZ();
     219           0 :         Double_t p1A = (Double_t)t->GetSnp();
     220           0 :         Double_t p2A = (Double_t)t->GetTgl();
     221           0 :         Double_t p3A = (Double_t)t->GetSigned1Pt();
     222           0 :         const Double_t *covA = (Double_t*)t->GetCovariance();
     223             : 
     224             :         // Make attention, please:
     225             :         //      AliESDtrack::fTOFInfo array does not be stored in the AliESDs.root file
     226             :         //      it is there only for a check during the reconstruction step.
     227           0 :         Float_t info[10]={0.,0.,0.,0.,0.,0.,0.,0.,0.,0.};
     228           0 :         seed->GetTOFInfo(info);
     229           0 :         t->SetTOFInfo(info);
     230           0 :         AliDebug(2,Form(" distance=%f; residual in the pad reference frame: dX=%f, dZ=%f", info[0],info[1],info[2]));
     231             : 
     232             :         // Check done:
     233             :         //       by calling the AliESDtrack::UpdateTrackParams,
     234             :         //       the current track parameters are changed
     235             :         //       and it could cause refit problems.
     236             :         //       We need to update only the following track parameters:
     237             :         //            the track length and expected times.
     238             :         //       Removed AliESDtrack::UpdateTrackParams call
     239             :         //       Called AliESDtrack::SetIntegratedTimes(...) and
     240             :         //       AliESDtrack::SetIntegratedLength() routines.
     241             :         /*
     242             :           AliTOFtrack *track = new AliTOFtrack(*seed);
     243             :           t->UpdateTrackParams(track,AliESDtrack::kTOFout); // to be checked - AdC
     244             :           delete track;
     245             :           Double_t time[AliPID::kSPECIESC]; t->GetIntegratedTimes(time);
     246             :         */
     247             : 
     248           0 :         Double_t time[AliPID::kSPECIESC]; seed->GetIntegratedTimes(time,AliPID::kSPECIESC);
     249           0 :         t->SetIntegratedTimes(time);
     250             : 
     251           0 :         Double_t length =  seed->GetIntegratedLength();
     252           0 :         t->SetIntegratedLength(length);
     253             : 
     254           0 :         Double_t alphaB = (Double_t)t->GetAlpha();
     255           0 :         Double_t xB = (Double_t)t->GetX();
     256           0 :         Double_t yB = (Double_t)t->GetY();
     257           0 :         Double_t zB = (Double_t)t->GetZ();
     258           0 :         Double_t p1B = (Double_t)t->GetSnp();
     259           0 :         Double_t p2B = (Double_t)t->GetTgl();
     260           0 :         Double_t p3B = (Double_t)t->GetSigned1Pt();
     261           0 :         const Double_t *covB = (Double_t*)t->GetCovariance();
     262           0 :         AliDebug(3,"Track params -now(before)-:");
     263           0 :         AliDebug(3,Form("    X: %f(%f), Y: %f(%f), Z: %f(%f) --- alpha: %f(%f)",
     264             :                         xB,xA,
     265             :                         yB,yA,
     266             :                         zB,zA,
     267             :                         alphaB,alphaA));
     268           0 :         AliDebug(3,Form("    p1: %f(%f), p2: %f(%f), p3: %f(%f)",
     269             :                         p1B,p1A,
     270             :                         p2B,p2A,
     271             :                         p3B,p3A));
     272           0 :         AliDebug(3,Form("    cov1: %f(%f), cov2: %f(%f), cov3: %f(%f)"
     273             :                         " cov4: %f(%f), cov5: %f(%f), cov6: %f(%f)"
     274             :                         " cov7: %f(%f), cov8: %f(%f), cov9: %f(%f)"
     275             :                         " cov10: %f(%f), cov11: %f(%f), cov12: %f(%f)"
     276             :                         " cov13: %f(%f), cov14: %f(%f), cov15: %f(%f)",
     277             :                         covB[0],covA[0],
     278             :                         covB[1],covA[1],
     279             :                         covB[2],covA[2],
     280             :                         covB[3],covA[3],
     281             :                         covB[4],covA[4],
     282             :                         covB[5],covA[5],
     283             :                         covB[6],covA[6],
     284             :                         covB[7],covA[7],
     285             :                         covB[8],covA[8],
     286             :                         covB[9],covA[9],
     287             :                         covB[10],covA[10],
     288             :                         covB[11],covA[11],
     289             :                         covB[12],covA[12],
     290             :                         covB[13],covA[13],
     291             :                         covB[14],covA[14]
     292             :                         ));
     293           0 :         AliDebug(2,Form(" TOF params: %6d  %f %f %f %f %f  %6d %3d  %f",
     294             :                         i,
     295             :                         t->GetTOFsignalRaw(),
     296             :                         t->GetTOFsignal(),
     297             :                         t->GetTOFsignalToT(),
     298             :                         t->GetTOFsignalDz(),
     299             :                         t->GetTOFsignalDx(),
     300             :                         t->GetTOFCalChannel(),
     301             :                         t->GetTOFcluster(),
     302             :                         t->GetIntegratedLength()));
     303           0 :         AliDebug(2,Form(" %f %f %f %f %f %f %f %f %f",
     304             :                         time[0], time[1], time[2], time[3], time[4], time[5], time[6], time[7], time[8]));
     305           0 :       }
     306             :     }
     307             :   }
     308             : 
     309           0 :   fSeeds->Clear();
     310           0 :   fTracks->Delete();
     311           0 :   return 0;
     312             :   
     313           0 : }
     314             : //_________________________________________________________________________
     315             : void AliTOFtrackerV1::CollectESD() {
     316             :    //prepare the set of ESD tracks to be matched to clusters in TOF
     317             : 
     318             :   Int_t seedsTOF1=0;
     319             :   Int_t seedsTOF3=0;
     320             :   Int_t seedsTOF2=0;
     321             :  
     322           0 :   TClonesArray &aTOFTrack = *fTracks;
     323           0 :   for (Int_t i=0; i<fNseeds; i++) {
     324             : 
     325           0 :     AliESDtrack *t =(AliESDtrack*)fSeeds->At(i);
     326           0 :     if ((t->GetStatus()&AliESDtrack::kTPCout)==0)continue;
     327             : 
     328           0 :     AliTOFtrack *track = new AliTOFtrack(*t); // New
     329           0 :     Float_t x = (Float_t)track->GetX(); //New
     330             : 
     331             :     // TRD 'good' tracks
     332           0 :     if ( ( (t->GetStatus()&AliESDtrack::kTRDout)!=0 ) )  {
     333             : 
     334           0 :       AliDebug(1,Form(" Before propagation till inner TOF radius, ESDtrackLength=%f, TOFtrackLength=%f",t->GetIntegratedLength(),track->GetIntegratedLength()));
     335             : 
     336             :       // TRD 'good' tracks, already propagated at 371 cm
     337           0 :       if ( x >= AliTOFGeometry::Rmin() ) {
     338             : 
     339           0 :         if ( track->PropagateToInnerTOF() ) {
     340             : 
     341           0 :           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()));
     344             : 
     345           0 :           track->SetSeedIndex(i);
     346           0 :           t->UpdateTrackParams(track,AliESDtrack::kTOFin);
     347           0 :           new(aTOFTrack[fNseedsTOF]) AliTOFtrack(*track);
     348           0 :           fNseedsTOF++;
     349           0 :           seedsTOF1++;
     350             : 
     351           0 :           AliDebug(1,Form(" After propagation till inner TOF radius, ESDtrackLength=%f, TOFtrackLength=%f",t->GetIntegratedLength(),track->GetIntegratedLength()));
     352             :         }
     353           0 :         delete track;
     354             : 
     355             :       }
     356             :       else { // TRD 'good' tracks, propagated rho<371cm
     357             : 
     358           0 :         if  ( track->PropagateToInnerTOF() ) {
     359             : 
     360           0 :           AliDebug(1,Form(" TRD propagated track till rho = %fcm."
     361             :                           " And then the track has been propagated till rho = %fcm.",
     362             :                           x, (Float_t)track->GetX()));
     363             : 
     364           0 :           track->SetSeedIndex(i);
     365           0 :           t->UpdateTrackParams(track,AliESDtrack::kTOFin);
     366           0 :           new(aTOFTrack[fNseedsTOF]) AliTOFtrack(*track);
     367           0 :           fNseedsTOF++;
     368           0 :           seedsTOF3++;
     369             : 
     370           0 :           AliDebug(1,Form(" After propagation till inner TOF radius, ESDtrackLength=%f, TOFtrackLength=%f",t->GetIntegratedLength(),track->GetIntegratedLength()));
     371             :         }
     372           0 :         delete track;
     373             : 
     374             :       }
     375             : 
     376             :     }
     377             : 
     378             :     else { // Propagate the rest of TPCbp
     379             : 
     380           0 :       AliDebug(1,Form(" Before propagation till inner TOF radius, ESDtrackLength=%f, TOFtrackLength=%f",t->GetIntegratedLength(),track->GetIntegratedLength()));
     381             : 
     382           0 :       if ( track->PropagateToInnerTOF() ) {
     383             : 
     384           0 :         AliDebug(1,Form(" TRD propagated track till rho = %fcm."
     385             :                         " And then the track has been propagated till rho = %fcm.",
     386             :                         x, (Float_t)track->GetX()));
     387             : 
     388           0 :         track->SetSeedIndex(i);
     389           0 :         t->UpdateTrackParams(track,AliESDtrack::kTOFin);
     390           0 :         new(aTOFTrack[fNseedsTOF]) AliTOFtrack(*track);
     391           0 :         fNseedsTOF++;
     392           0 :         seedsTOF2++;
     393           0 :       }
     394           0 :       delete track;
     395             :     }
     396           0 :   }
     397             : 
     398           0 :   AliInfo(Form("Number of TOF seeds = %d (kTRDout371 = %d, kTRDoutLess371 = %d, !kTRDout = %d)",fNseedsTOF,seedsTOF1,seedsTOF3,seedsTOF2));
     399             : 
     400             :   // Sort according uncertainties on track position 
     401           0 :   fTracks->Sort();
     402             : 
     403           0 : }
     404             : //_________________________________________________________________________
     405             : void AliTOFtrackerV1::MatchTracks( ){
     406             :   //
     407             :   //Match ESD tracks to clusters in TOF
     408             :   //
     409             : 
     410             : 
     411             :   // Parameters regulating the reconstruction
     412           0 :   Float_t dY=AliTOFGeometry::XPad(); 
     413           0 :   Float_t dZ=AliTOFGeometry::ZPad(); 
     414             : 
     415             :   const Float_t kTimeOffset = 0.; // time offset for tracking algorithm [ps]
     416             : 
     417             :   const Int_t kncmax = 100;
     418           0 :   Float_t sensRadius = fkRecoParam->GetSensRadius();
     419           0 :   Float_t scaleFact   = fkRecoParam->GetWindowScaleFact();
     420           0 :   Float_t dyMax=fkRecoParam->GetWindowSizeMaxY(); 
     421           0 :   Float_t dzMax=fkRecoParam->GetWindowSizeMaxZ();
     422           0 :   Double_t maxChi2=fkRecoParam->GetMaxChi2();
     423           0 :   Bool_t timeWalkCorr    = fkRecoParam->GetTimeWalkCorr();
     424           0 :   AliDebug(1,"++++++++++++++TOF Reconstruction Parameters:++++++++++++");
     425           0 :   AliDebug(1,Form("TOF sens radius: %f",sensRadius));
     426           0 :   AliDebug(1,Form("TOF Window scale factor: %f",scaleFact));
     427           0 :   AliDebug(1,Form("TOF Window max dy: %f",dyMax));
     428           0 :   AliDebug(1,Form("TOF Window max dz: %f",dzMax));
     429           0 :   AliDebug(1,Form("TOF Max Chi2: %f",maxChi2));
     430           0 :   AliDebug(1,Form("Time Walk Correction? : %d",timeWalkCorr));   
     431           0 :   AliDebug(1,"++++++++++++++++++++++++++++++++++++++++++++++++++++++++");
     432             : 
     433             :   //The matching loop
     434           0 :   for (Int_t iseed=0; iseed<fNseedsTOF; iseed++) {
     435             : 
     436           0 :     AliTOFtrack *track =(AliTOFtrack*)fTracks->UncheckedAt(iseed);
     437           0 :     AliESDtrack *t =(AliESDtrack*)fSeeds->At(track->GetSeedIndex());
     438             :     //if ( t->GetTOFsignal()>0. ) continue;
     439           0 :     if ( (t->GetStatus()&AliESDtrack::kTOFout)!=0 ) continue;
     440           0 :     AliTOFtrack *trackTOFin = new AliTOFtrack(*track);
     441             :      
     442             :     // Determine a window around the track
     443           0 :     Double_t x,par[5]; trackTOFin->GetExternalParameters(x,par);
     444           0 :     Double_t cov[15]; trackTOFin->GetExternalCovariance(cov);
     445             : 
     446           0 :     if (cov[0]<0. || cov[2]<0.) {
     447           0 :       AliWarning(Form("Very strange track (%d)! At least one of its covariance matrix diagonal elements is negative!",iseed));
     448             :       //delete trackTOFin;
     449             :       //continue;
     450           0 :     }
     451             : 
     452           0 :     Double_t z    = par[1];   
     453           0 :     Double_t dz   = scaleFact*3.*TMath::Sqrt(TMath::Abs(cov[2])+dZ*dZ/12.);
     454           0 :     Double_t dphi = scaleFact*3.*TMath::Sqrt(TMath::Abs(cov[0])+dY*dY/12.)/sensRadius; 
     455             : 
     456           0 :     Double_t phi=TMath::ATan2(par[0],x) + trackTOFin->GetAlpha();
     457           0 :     if (phi<-TMath::Pi())phi+=2*TMath::Pi();
     458           0 :     if (phi>=TMath::Pi())phi-=2*TMath::Pi();
     459             : 
     460             :     //upper limit on window's size.
     461           0 :     if (dz> dzMax) dz=dzMax;
     462           0 :     if (dphi*sensRadius> dyMax) dphi=dyMax/sensRadius;
     463             : 
     464             :     // find the clusters inside the selected window 
     465             :     Int_t nc=0;
     466           0 :     AliTOFcluster *clusters[kncmax]; // pointers to the clusters in the window
     467           0 :     Int_t index[kncmax];//to keep track of the cluster index
     468           0 :     for (Int_t k=FindClusterIndex(z-dz); k<fN; k++) {  
     469           0 :       AliTOFcluster *c=fClusters[k];
     470             :       //      if(nc>kncmax)break; /* R+ fix (buffer overflow) */
     471           0 :       if (nc>=kncmax) {
     472           0 :         AliWarning("No more matchable clusters can be stored! Please, increase the corresponding vectors size.");
     473           0 :         break; /* R+ fix (buffer overflow protection) */
     474             :       }
     475           0 :       if (c->GetZ() > z+dz) break;
     476           0 :       if (c->IsUsed()) continue;      
     477           0 :       if (!c->GetStatus()) {
     478           0 :         AliDebug(1,"Cluster in channel declared bad!");
     479           0 :         continue; // skip bad channels as declared in OCDB  
     480             :       }
     481           0 :       Float_t xyz[3]; c->GetGlobalXYZ(xyz);
     482           0 :       Double_t clPhi=TMath::ATan2(xyz[1],xyz[0]);
     483           0 :       Double_t dph=TMath::Abs(clPhi-phi);
     484           0 :       if (dph>TMath::Pi()) dph-=2.*TMath::Pi();
     485           0 :       if (TMath::Abs(dph)>dphi) continue;
     486           0 :       clusters[nc]=c;
     487           0 :       index[nc] = k;      
     488           0 :       nc++;  
     489           0 :     }
     490             : 
     491           0 :     AliDebug(1,Form(" Number of matchable TOF clusters for the track number %d: %d",iseed,nc));
     492             : 
     493             :     //start propagation: go to the average TOF pad middle plane at ~379.5 cm
     494             : 
     495             :     // First of all, propagate the track...
     496             :     Float_t xTOF = sensRadius;
     497           0 :     if (!(trackTOFin->PropagateTo(xTOF))) {
     498           0 :       delete trackTOFin;
     499           0 :       continue;
     500             :     }
     501             : 
     502             :     // ...and then, if necessary, rotate the track
     503           0 :     Double_t ymax = xTOF*TMath::Tan(0.5*AliTOFGeometry::GetAlpha());
     504           0 :     Double_t ysect = trackTOFin->GetY();
     505           0 :     if (ysect > ymax) {
     506           0 :       if (!(trackTOFin->Rotate(AliTOFGeometry::GetAlpha()))) {
     507           0 :         delete trackTOFin;
     508           0 :         continue;
     509             :       }
     510           0 :     } else if (ysect <-ymax) {
     511           0 :       if (!(trackTOFin->Rotate(-AliTOFGeometry::GetAlpha()))) {
     512           0 :         delete trackTOFin;
     513           0 :         continue;
     514             :       }
     515             :     }
     516             : 
     517             : 
     518             :     AliTOFcluster *bestCluster=0;
     519             :     Double_t bestChi2=maxChi2; 
     520             :     Int_t idclus=-1;
     521             :     //    for (Int_t i=0; i<nc; i++){ /* R+ fix (unsafe) */
     522           0 :     for (Int_t i=0; i<nc && i<kncmax; i++){ /* R+ fix (buffer overflow protection) */
     523           0 :       AliTOFcluster *c=clusters[i];  // one of the preselected clusters     
     524           0 :       Double_t chi2=trackTOFin->GetPredictedChi2((AliCluster3D*)c); 
     525           0 :       if (chi2 >= bestChi2) continue;
     526             :       bestChi2=chi2;
     527             :       bestCluster=c;
     528           0 :       idclus=index[i];
     529           0 :     }
     530             :     
     531           0 :     if (!bestCluster) {  // no matching , go to the next track 
     532           0 :       AliDebug(1,Form("No track points for the track number %d",iseed));
     533           0 :       fnunmatch++;
     534           0 :       delete trackTOFin;
     535           0 :       continue;
     536             :     }
     537             : 
     538           0 :     fnmatch++;
     539           0 :     AliDebug(1,Form(" Matched TOF cluster %d for the track number %d",idclus,iseed));
     540             : 
     541           0 :     AliDebug(3, Form("%7i     %7i     %10i     %10i  %10i  %10i      %7i",
     542             :                      iseed,
     543             :                      fnmatch-1,
     544             :                      TMath::Abs(trackTOFin->GetLabel()),
     545             :                      bestCluster->GetLabel(0), 
     546             :                      bestCluster->GetLabel(1), 
     547             :                      bestCluster->GetLabel(2),
     548             :                      idclus)); // AdC
     549             : 
     550           0 :     bestCluster->Use(); 
     551             :     if (
     552           0 :         (bestCluster->GetLabel(0)==TMath::Abs(trackTOFin->GetLabel()))
     553           0 :         ||
     554           0 :         (bestCluster->GetLabel(1)==TMath::Abs(trackTOFin->GetLabel()))
     555           0 :         ||
     556           0 :         (bestCluster->GetLabel(2)==TMath::Abs(trackTOFin->GetLabel()))
     557             :         ) {
     558           0 :       fngoodmatch++;
     559           0 :        AliDebug(2,Form(" track label good %5d",trackTOFin->GetLabel()));
     560             : 
     561             :     } else {
     562           0 :       fnbadmatch++;
     563           0 :       AliDebug(2,Form(" track label bad %5d",trackTOFin->GetLabel()));
     564             :     }
     565             : 
     566             :     //Propagate the track to the best matched cluster
     567           0 :     if (!(trackTOFin->PropagateTo(bestCluster))) {
     568           0 :       delete trackTOFin;
     569           0 :       continue;
     570             :     }
     571             : 
     572             :     // If necessary, rotate the track
     573           0 :     Double_t yATxMax = trackTOFin->GetX()*TMath::Tan(0.5*AliTOFGeometry::GetAlpha());
     574           0 :     Double_t yATx = trackTOFin->GetY();
     575           0 :     if (yATx > yATxMax) {
     576           0 :       if (!(trackTOFin->Rotate(AliTOFGeometry::GetAlpha()))) {
     577           0 :         delete trackTOFin;
     578           0 :         continue;
     579             :       }
     580           0 :     } else if (yATx <-yATxMax) {
     581           0 :       if (!(trackTOFin->Rotate(-AliTOFGeometry::GetAlpha()))) {
     582           0 :         delete trackTOFin;
     583           0 :         continue;
     584             :       }
     585             :     }
     586             : 
     587             :     // Fill the track residual histograms.
     588           0 :     FillResiduals(trackTOFin,bestCluster,kFALSE);
     589             : 
     590             :     //now take the local distance in Z from the pad center for time walk correction
     591           0 :     Float_t tiltangle = AliTOFGeometry::GetAngles(bestCluster->GetDetInd(1),bestCluster->GetDetInd(2))*TMath::DegToRad();
     592           0 :     Double_t dzTW=trackTOFin->GetZ()-bestCluster->GetZ(); // in cm - in the ALICE RF -
     593           0 :     dzTW/=TMath::Cos(tiltangle); // from ALICE/tracking RF to pad RF (1)
     594           0 :     dzTW=-dzTW; // from ALICE/tracking RF to pad RF (2)
     595           0 :     if (tiltangle!=0.) AliDebug(3,Form(" rho_track = %f --- rho_cluster = %f ",trackTOFin->GetX(),bestCluster->GetX()));
     596             : 
     597             :     //update the ESD track and delete the TOFtrack
     598           0 :     t->UpdateTrackParams(trackTOFin,AliESDtrack::kTOFout);
     599             : 
     600             :     //  Store quantities to be used in the TOF Calibration
     601           0 :     Float_t tToT=AliTOFGeometry::ToTBinWidth()*bestCluster->GetToT()*1E-3; // in ns
     602           0 :     t->SetTOFsignalToT(tToT);
     603           0 :     Float_t rawTime=AliTOFGeometry::TdcBinWidth()*bestCluster->GetTDCRAW()+kTimeOffset; // RAW time,in ps
     604           0 :     t->SetTOFsignalRaw(rawTime);
     605           0 :     t->SetTOFsignalDz(dzTW);
     606             : 
     607           0 :     Float_t deltaY = trackTOFin->GetY()-bestCluster->GetY();
     608           0 :     t->SetTOFsignalDx(deltaY);
     609             : 
     610           0 :     t->SetTOFDeltaBC(bestCluster->GetDeltaBC());
     611           0 :     t->SetTOFL0L1(bestCluster->GetL0L1Latency());
     612             : 
     613           0 :     Float_t distR = (trackTOFin->GetX()-bestCluster->GetX())*
     614           0 :       (trackTOFin->GetX()-bestCluster->GetX());
     615           0 :     distR+=deltaY*deltaY;
     616           0 :     distR+=dzTW*dzTW;
     617           0 :     distR = TMath::Sqrt(distR);
     618           0 :     Float_t info[10] = {distR, deltaY, static_cast<Float_t>(dzTW),
     619             :                         0.,0.,0.,0.,0.,0.,0.};
     620           0 :     t->SetTOFInfo(info);
     621             : 
     622           0 :     Int_t ind[5];
     623           0 :     ind[0]=bestCluster->GetDetInd(0);
     624           0 :     ind[1]=bestCluster->GetDetInd(1);
     625           0 :     ind[2]=bestCluster->GetDetInd(2);
     626           0 :     ind[3]=bestCluster->GetDetInd(3);
     627           0 :     ind[4]=bestCluster->GetDetInd(4);
     628           0 :     Int_t calindex = AliTOFGeometry::GetIndex(ind);
     629           0 :     t->SetTOFCalChannel(calindex);
     630             : 
     631             :     // keep track of the track labels in the matched cluster
     632           0 :     Int_t tlab[3];
     633           0 :     tlab[0]=bestCluster->GetLabel(0);
     634           0 :     tlab[1]=bestCluster->GetLabel(1);
     635           0 :     tlab[2]=bestCluster->GetLabel(2);
     636           0 :     AliDebug(3,Form(" tdc time of the matched track %6d = ",bestCluster->GetTDC()));    
     637           0 :     Double_t tof=AliTOFGeometry::TdcBinWidth()*bestCluster->GetTDC()+kTimeOffset; // in ps
     638           0 :     AliDebug(3,Form(" tof time of the matched track: %f = ",tof));
     639             :     Double_t tofcorr=tof;
     640           0 :     if(timeWalkCorr)tofcorr=CorrectTimeWalk(dzTW,tof);
     641           0 :     AliDebug(3,Form(" tof time of the matched track, after TW corr: %f = ",tofcorr));    
     642             :     //Set TOF time signal and pointer to the matched cluster
     643           0 :     t->SetTOFsignal(tofcorr);
     644           0 :     t->SetTOFcluster(idclus); // pointing to the recPoints tree
     645           0 :     t->SetTOFLabel(tlab);
     646             : 
     647           0 :     AliDebug(3,Form(" Setting TOF raw time: %f  z distance: %f  corrected time: %f",rawTime,dzTW,tofcorr));
     648             : 
     649           0 :     Double_t mom=t->GetP();
     650           0 :     AliDebug(3,Form(" Momentum for track %d -> %f", iseed,mom));
     651             :     // Fill Reco-QA histos for Reconstruction
     652           0 :     fHRecNClus->Fill(nc);
     653           0 :     fHRecChi2->Fill(bestChi2);
     654           0 :     fHRecDistZ->Fill(dzTW);
     655           0 :     if (cov[0]>=0.)
     656           0 :       fHRecSigYVsP->Fill(mom,TMath::Sqrt(cov[0]));
     657             :     else
     658           0 :       fHRecSigYVsP->Fill(mom,-TMath::Sqrt(-cov[0]));
     659           0 :     if (cov[2]>=0.)
     660           0 :       fHRecSigZVsP->Fill(mom,TMath::Sqrt(cov[2]));
     661             :     else
     662           0 :       fHRecSigZVsP->Fill(mom,-TMath::Sqrt(-cov[2]));
     663           0 :     fHRecSigYVsPWin->Fill(mom,dphi*sensRadius);
     664           0 :     fHRecSigZVsPWin->Fill(mom,dz);
     665             : 
     666             :     // Fill Tree for on-the-fly offline Calibration
     667             :     // no longer there - all info is in the ESDs now
     668             : 
     669           0 :     delete trackTOFin;
     670             : 
     671           0 :   }
     672             : 
     673           0 : }
     674             : //_________________________________________________________________________
     675             : Int_t AliTOFtrackerV1::LoadClusters(TTree *cTree) {
     676             :   //--------------------------------------------------------------------
     677             :   //This function loads the TOF clusters
     678             :   //--------------------------------------------------------------------
     679             : 
     680           0 :   Int_t npadX = AliTOFGeometry::NpadX();
     681           0 :   Int_t npadZ = AliTOFGeometry::NpadZ();
     682           0 :   Int_t nStripA = AliTOFGeometry::NStripA();
     683           0 :   Int_t nStripB = AliTOFGeometry::NStripB();
     684           0 :   Int_t nStripC = AliTOFGeometry::NStripC();
     685             : 
     686           0 :   TBranch *branch=cTree->GetBranch("TOF");
     687           0 :   if (!branch) { 
     688           0 :     AliError("can't get the branch with the TOF clusters !");
     689           0 :     return 1;
     690             :   }
     691             : 
     692           0 :   static TClonesArray dummy("AliTOFcluster",10000);
     693           0 :   dummy.Clear();
     694           0 :   TClonesArray *clusters=&dummy;
     695           0 :   branch->SetAddress(&clusters);
     696             : 
     697           0 :   cTree->GetEvent(0);
     698           0 :   Int_t nc=clusters->GetEntriesFast();
     699           0 :   fHDigNClus->Fill(nc);
     700             : 
     701           0 :   AliInfo(Form("Number of clusters: %d",nc));
     702             : 
     703           0 :   for (Int_t i=0; i<nc; i++) {
     704           0 :     AliTOFcluster *c=(AliTOFcluster*)clusters->UncheckedAt(i);
     705             : //PH    fClusters[i]=new AliTOFcluster(*c); fN++;
     706           0 :     fClusters[i]=c; fN++;
     707             : 
     708             :   // Fill Digits QA histos
     709             :  
     710           0 :     Int_t isector = c->GetDetInd(0);
     711           0 :     Int_t iplate = c->GetDetInd(1);
     712           0 :     Int_t istrip = c->GetDetInd(2);
     713           0 :     Int_t ipadX = c->GetDetInd(4);
     714           0 :     Int_t ipadZ = c->GetDetInd(3);
     715             : 
     716           0 :     Float_t time =(AliTOFGeometry::TdcBinWidth()*c->GetTDC())*1E-3; // in ns
     717           0 :     Float_t tot = (AliTOFGeometry::TdcBinWidth()*c->GetToT())*1E-3;//in ns
     718             :  
     719             :     Int_t stripOffset = 0;
     720           0 :     switch (iplate) {
     721             :     case 0:
     722             :       stripOffset = 0;
     723           0 :       break;
     724             :     case 1:
     725             :       stripOffset = nStripC;
     726           0 :       break;
     727             :     case 2:
     728           0 :       stripOffset = nStripC+nStripB;
     729           0 :       break;
     730             :     case 3:
     731           0 :       stripOffset = nStripC+nStripB+nStripA;
     732           0 :       break;
     733             :     case 4:
     734           0 :       stripOffset = nStripC+nStripB+nStripA+nStripB;
     735           0 :       break;
     736             :     default:
     737           0 :       AliError(Form("Wrong plate number in TOF (%d) !",iplate));
     738           0 :       break;
     739             :     };
     740           0 :     Int_t zindex=npadZ*(istrip+stripOffset)+(ipadZ+1);
     741           0 :     Int_t phiindex=npadX*isector+ipadX+1;
     742           0 :     fHDigClusMap->Fill(zindex,phiindex);
     743           0 :     fHDigClusTime->Fill(time);
     744           0 :     fHDigClusToT->Fill(tot);
     745             :   }
     746             : 
     747             : 
     748             :   return 0;
     749           0 : }
     750             : //_________________________________________________________________________
     751             : void AliTOFtrackerV1::UnloadClusters() {
     752             :   //--------------------------------------------------------------------
     753             :   //This function unloads TOF clusters
     754             :   //--------------------------------------------------------------------
     755           0 :   for (Int_t i=0; i<fN; i++) {
     756             : //PH    delete fClusters[i];
     757           0 :     fClusters[i] = 0x0;
     758             :   }
     759           0 :   fN=0;
     760           0 : }
     761             : 
     762             : //_________________________________________________________________________
     763             : Int_t AliTOFtrackerV1::FindClusterIndex(Double_t z) const {
     764             :   //--------------------------------------------------------------------
     765             :   // This function returns the index of the nearest cluster 
     766             :   //--------------------------------------------------------------------
     767             :   //MOD
     768             :   //Here we need to get the Z in the tracking system
     769             : 
     770           0 :   if (fN==0) return 0;
     771           0 :   if (z <= fClusters[0]->GetZ()) return 0;
     772           0 :   if (z > fClusters[fN-1]->GetZ()) return fN;
     773           0 :   Int_t b=0, e=fN-1, m=(b+e)/2;
     774           0 :   for (; b<e; m=(b+e)/2) {
     775           0 :     if (z > fClusters[m]->GetZ()) b=m+1;
     776             :     else e=m; 
     777             :   }
     778             :   return m;
     779           0 : }
     780             : 
     781             : //_________________________________________________________________________
     782             : Bool_t AliTOFtrackerV1::GetTrackPoint(Int_t index, AliTrackPoint& p) const
     783             : {
     784             :   // Get track space point with index i
     785             :   // Coordinates are in the global system
     786           0 :   AliTOFcluster *cl = fClusters[index];
     787           0 :   Float_t xyz[3];
     788           0 :   cl->GetGlobalXYZ(xyz);
     789           0 :   Float_t phi=TMath::ATan2(xyz[1],xyz[0]);
     790           0 :   Float_t phiangle = (Int_t(phi*TMath::RadToDeg()/20.)+0.5)*20.*TMath::DegToRad();
     791           0 :   Float_t sinphi = TMath::Sin(phiangle), cosphi = TMath::Cos(phiangle);
     792           0 :   Float_t tiltangle = AliTOFGeometry::GetAngles(cl->GetDetInd(1),cl->GetDetInd(2))*TMath::DegToRad();
     793           0 :   Float_t sinth = TMath::Sin(tiltangle), costh = TMath::Cos(tiltangle);
     794           0 :   Float_t sigmay2 = AliTOFGeometry::XPad()*AliTOFGeometry::XPad()/12.;
     795           0 :   Float_t sigmaz2 = AliTOFGeometry::ZPad()*AliTOFGeometry::ZPad()/12.;
     796           0 :   Float_t cov[6];
     797           0 :   cov[0] = sinphi*sinphi*sigmay2 + cosphi*cosphi*sinth*sinth*sigmaz2;
     798           0 :   cov[1] = -sinphi*cosphi*sigmay2 + sinphi*cosphi*sinth*sinth*sigmaz2;
     799           0 :   cov[2] = -cosphi*sinth*costh*sigmaz2;
     800           0 :   cov[3] = cosphi*cosphi*sigmay2 + sinphi*sinphi*sinth*sinth*sigmaz2;
     801           0 :   cov[4] = -sinphi*sinth*costh*sigmaz2;
     802           0 :   cov[5] = costh*costh*sigmaz2;
     803           0 :   p.SetXYZ(xyz[0],xyz[1],xyz[2],cov);
     804             : 
     805             :   // Detector numbering scheme
     806           0 :   Int_t nSector = AliTOFGeometry::NSectors();
     807           0 :   Int_t nPlate  = AliTOFGeometry::NPlates();
     808           0 :   Int_t nStripA = AliTOFGeometry::NStripA();
     809           0 :   Int_t nStripB = AliTOFGeometry::NStripB();
     810           0 :   Int_t nStripC = AliTOFGeometry::NStripC();
     811             : 
     812           0 :   Int_t isector = cl->GetDetInd(0);
     813           0 :   if (isector >= nSector)
     814           0 :     AliError(Form("Wrong sector number in TOF (%d) !",isector));
     815           0 :   Int_t iplate = cl->GetDetInd(1);
     816           0 :   if (iplate >= nPlate)
     817           0 :     AliError(Form("Wrong plate number in TOF (%d) !",iplate));
     818           0 :   Int_t istrip = cl->GetDetInd(2);
     819             : 
     820             :   Int_t stripOffset = 0;
     821           0 :   switch (iplate) {
     822             :   case 0:
     823             :     stripOffset = 0;
     824           0 :     break;
     825             :   case 1:
     826             :     stripOffset = nStripC;
     827           0 :     break;
     828             :   case 2:
     829           0 :     stripOffset = nStripC+nStripB;
     830           0 :     break;
     831             :   case 3:
     832           0 :     stripOffset = nStripC+nStripB+nStripA;
     833           0 :     break;
     834             :   case 4:
     835           0 :     stripOffset = nStripC+nStripB+nStripA+nStripB;
     836           0 :     break;
     837             :   default:
     838           0 :     AliError(Form("Wrong plate number in TOF (%d) !",iplate));
     839           0 :     break;
     840             :   };
     841             : 
     842           0 :   Int_t idet = (2*(nStripC+nStripB)+nStripA)*isector +
     843           0 :                stripOffset +
     844             :                istrip;
     845           0 :   UShort_t volid = AliGeomManager::LayerToVolUID(AliGeomManager::kTOF,idet);
     846           0 :   p.SetVolumeID((UShort_t)volid);
     847           0 :   return kTRUE;
     848           0 : }
     849             : //_________________________________________________________________________
     850             : void AliTOFtrackerV1::InitCheckHists() {
     851             : 
     852             :   //Init histos for Digits/Reco QA and Calibration
     853             : 
     854           0 :   TDirectory *dir = gDirectory;
     855             :   TFile *logFileTOF = 0;
     856             : 
     857           0 :   TSeqCollection *list = gROOT->GetListOfFiles();
     858           0 :   int n = list->GetEntries();
     859             :   Bool_t isThere=kFALSE;
     860           0 :   for(int i=0; i<n; i++) {
     861           0 :     logFileTOF = (TFile*)list->At(i);
     862           0 :     if (strstr(logFileTOF->GetName(), "TOFQA.root")){
     863             :       isThere=kTRUE;
     864           0 :       break;
     865             :     } 
     866             :   }
     867             : 
     868           0 :   if(!isThere)logFileTOF = new TFile( "TOFQA.root","RECREATE");
     869           0 :   logFileTOF->cd(); 
     870             : 
     871             :   //Digits "QA" 
     872           0 :   fHDigClusMap = new TH2F("TOFDig_ClusMap", "",182,0.5,182.5,864, 0.5,864.5);  
     873           0 :   fHDigNClus = new TH1F("TOFDig_NClus", "",200,0.5,200.5);  
     874           0 :   fHDigClusTime = new TH1F("TOFDig_ClusTime", "",2000,0.,200.);  
     875           0 :   fHDigClusToT = new TH1F("TOFDig_ClusToT", "",500,0.,100);  
     876             : 
     877             :   //Reco "QA"
     878           0 :   fHRecNClus =new TH1F("TOFRec_NClusW", "",50,0.5,50.5);
     879           0 :   fHRecDistZ=new TH1F("TOFRec_DistZ", "",50,0.5,10.5);
     880           0 :   fHRecChi2=new TH1F("TOFRec_Chi2", "",100,0.,10.);
     881           0 :   fHRecSigYVsP=new TH2F("TOFDig_SigYVsP", "",40,0.,4.,100, 0.,5.);
     882           0 :   fHRecSigZVsP=new TH2F("TOFDig_SigZVsP", "",40,0.,4.,100, 0.,5.);
     883           0 :   fHRecSigYVsPWin=new TH2F("TOFDig_SigYVsPWin", "",40,0.,4.,100, 0.,50.);
     884           0 :   fHRecSigZVsPWin=new TH2F("TOFDig_SigZVsPWin", "",40,0.,4.,100, 0.,50.);
     885             : 
     886           0 :   dir->cd();
     887             : 
     888           0 : }
     889             : 
     890             : //_________________________________________________________________________
     891             : void AliTOFtrackerV1::SaveCheckHists() {
     892             : 
     893             :   //write histos for Digits/Reco QA and Calibration
     894             : 
     895           0 :   TDirectory *dir = gDirectory;
     896             :   //TFile *logFile = 0;
     897             :   TFile *logFileTOF = 0;
     898             : 
     899           0 :   TSeqCollection *list = gROOT->GetListOfFiles();
     900           0 :   int n = list->GetEntries();
     901             :   /*
     902             :   for(int i=0; i<n; i++) {
     903             :     logFile = (TFile*)list->At(i);
     904             :     if (strstr(logFile->GetName(), "AliESDs.root")) break;
     905             :   }
     906             :   */
     907             :   Bool_t isThere=kFALSE;
     908           0 :   for(int i=0; i<n; i++) {
     909           0 :     logFileTOF = (TFile*)list->At(i);
     910           0 :     if (strstr(logFileTOF->GetName(), "TOFQA.root")){
     911             :       isThere=kTRUE;
     912           0 :       break;
     913             :     } 
     914             :   }
     915             :    
     916           0 :   if(!isThere) {
     917           0 :           AliError(Form("File TOFQA.root not found!! not wring histograms...."));
     918           0 :           return;
     919             :   }
     920             :   //logFile->cd();
     921           0 :   logFileTOF->cd();
     922           0 :   fHDigClusMap->Write(fHDigClusMap->GetName(), TObject::kOverwrite);
     923           0 :   fHDigNClus->Write(fHDigNClus->GetName(), TObject::kOverwrite);
     924           0 :   fHDigClusTime->Write(fHDigClusTime->GetName(), TObject::kOverwrite);
     925           0 :   fHDigClusToT->Write(fHDigClusToT->GetName(), TObject::kOverwrite);
     926           0 :   fHRecNClus->Write(fHRecNClus->GetName(), TObject::kOverwrite);
     927           0 :   fHRecChi2->Write(fHRecChi2->GetName(), TObject::kOverwrite);
     928           0 :   fHRecDistZ->Write(fHRecDistZ->GetName(), TObject::kOverwrite);
     929           0 :   fHRecSigYVsP->Write(fHRecSigYVsP->GetName(), TObject::kOverwrite);
     930           0 :   fHRecSigZVsP->Write(fHRecSigZVsP->GetName(), TObject::kOverwrite);
     931           0 :   fHRecSigYVsPWin->Write(fHRecSigYVsPWin->GetName(), TObject::kOverwrite);
     932           0 :   fHRecSigZVsPWin->Write(fHRecSigZVsPWin->GetName(), TObject::kOverwrite);
     933             :   //logFile->Flush();  
     934           0 :   logFileTOF->Flush();  
     935             : 
     936           0 :   dir->cd();
     937             : 
     938           0 :   }
     939             : //_________________________________________________________________________
     940             : Float_t AliTOFtrackerV1::CorrectTimeWalk( Float_t dist, Float_t tof) const {
     941             : 
     942             :   //dummy, for the moment
     943             :   Float_t tofcorr=0.;
     944           0 :   if(dist<AliTOFGeometry::ZPad()*0.5){
     945             :     tofcorr=tof;
     946             :     //place here the actual correction
     947             :   }else{
     948             :     tofcorr=tof; 
     949             :   } 
     950           0 :   return tofcorr;
     951             : }
     952             : //_________________________________________________________________________
     953             : Float_t AliTOFtrackerV1::GetTimeZerofromT0(const AliESDEvent * const event) const {
     954             : 
     955             :   //Returns TimeZero as measured by T0 detector
     956             : 
     957           0 :   return event->GetT0();
     958             : }
     959             : //_________________________________________________________________________
     960             : Float_t AliTOFtrackerV1::GetTimeZerofromTOF(AliESDEvent * /*event*/) const {
     961             : 
     962             :   //dummy, for the moment. T0 algorithm using tracks on TOF
     963             :   {
     964             :     //place T0 algo here...
     965             :   }
     966           0 :   return 0.;
     967             : }
     968             : //_________________________________________________________________________
     969             : 
     970             : void AliTOFtrackerV1::FillClusterArray(TObjArray* arr) const
     971             : {
     972             :   //
     973             :   // Returns the TOF cluster array
     974             :   //
     975             : 
     976           0 :   if (fN==0)
     977           0 :     arr = 0x0;
     978             :   else
     979           0 :     for (Int_t i=0; i<fN; ++i) arr->Add(fClusters[i]);
     980             : 
     981           0 : }

Generated by: LCOV version 1.11