]> git.uio.no Git - u/mrichter/AliRoot.git/blobdiff - TOF/AliTOFClusterFinderV1.cxx
Improved QAchecker and plots for DQM
[u/mrichter/AliRoot.git] / TOF / AliTOFClusterFinderV1.cxx
index 1606479ddb3bda80e8d32e7e8112ff2ac453b283..2fc971f592cba25a285bbd3a75cf8161ea6a6590 100644 (file)
 
 /*
 $Log: AliTOFClusterFinderV1.cxx,v $
+Revision 2009/04/20 A. De Caro
+    - added two new global variables, called fTOFGeometry and fTOFdigits;
+    - added a new method, called FindClustersWithoutTOT,
+      to transform TOF digits with fTOT=0 in one pad clusters;
+    - update of the covariance matrix elements for the TOF clusters
+
 Revision 0.01  2008/05/10 A. De Caro
  */
 
@@ -38,6 +44,7 @@ Revision 0.01  2008/05/10 A. De Caro
 #include "AliDAQ.h"
 #include "AliLog.h"
 #include "AliRawReader.h"
+#include "AliLoader.h"
 #include "AliRunLoader.h"
 #include "AliGeomManager.h"
 
@@ -48,73 +55,124 @@ Revision 0.01  2008/05/10 A. De Caro
 #include "AliTOFClusterFinderV1.h"
 #include "AliTOFcluster.h"
 #include "AliTOFdigit.h"
-//#include "AliTOFselectedDigit.h"
 #include "AliTOFDigitMap.h"
-#include "AliTOFGeometry.h"
 #include "AliTOFrawData.h"
-#include "AliTOFRawStream.h"
+#include "AliTOFReconstructor.h"
+#include "AliTOFRecoParam.h"
 
 ClassImp(AliTOFClusterFinderV1)
 
+//_____________________________________________________________________________
 AliTOFClusterFinderV1::AliTOFClusterFinderV1(AliTOFcalib *calib):
+  TNamed("AliTOFClusterFinderV1",""),
   fRunLoader(0),
   fDigits(new TClonesArray("AliTOFdigit", 4000)),
   fRecPoints(new TClonesArray("AliTOFcluster", 4000)),
   fNumberOfTofClusters(0),
   fNumberOfTofDigits(0),
-  fMaxDeltaTime(10),
+  fkRecoParam(0),//AliTOFReconstructor::GetRecoParam()),
+  fMaxDeltaTime(0),//fkRecoParam->GetMaxDeltaTime()),
   fVerbose(0),
   fDecoderVersion(0),
   fTOFcalib(calib),
-  fTOFdigitMap(new AliTOFDigitMap())
-
+  fTOFdigitMap(new AliTOFDigitMap()),
+  fTOFGeometry(new AliTOFGeometry()),
+  fTOFdigits(new TTree()),
+  fTOFRawStream(AliTOFRawStream()),
+  fCalibrateTOFtimes(1)
 {
 //
 // Constructor
 //
 
+  for (Int_t ii=0; ii<kTofMaxCluster; ii++) fTofClusters[ii]=0x0;
+
+  if (AliTOFReconstructor::GetRecoParam()) {
+    fkRecoParam = AliTOFReconstructor::GetRecoParam();
+    fMaxDeltaTime = fkRecoParam->GetMaxDeltaTime();
+  }
+  else
+    fMaxDeltaTime = 2;
+
+  TString validity = (TString)fTOFcalib->GetOfflineValidity();
+  if (validity.CompareTo("valid")==0) {
+    AliInfo(Form(" validity = %s - Using offline calibration parameters", validity.Data()));
+  } else {
+    AliInfo(Form(" validity = %s - Using online calibration parameters", validity.Data()));
+  }
+
 }
-//_____________________________________________________________________________
 
+//_____________________________________________________________________________
 AliTOFClusterFinderV1::AliTOFClusterFinderV1(AliRunLoader* runLoader, AliTOFcalib *calib):
+  TNamed("AliTOFClusterFinderV1",""),
   fRunLoader(runLoader),
   fDigits(new TClonesArray("AliTOFdigit", 4000)),
   fRecPoints(new TClonesArray("AliTOFcluster", 4000)),
   fNumberOfTofClusters(0),
   fNumberOfTofDigits(0),
-  fMaxDeltaTime(10),
+  fkRecoParam(0),//AliTOFReconstructor::GetRecoParam()),
+  fMaxDeltaTime(0),//fkRecoParam->GetMaxDeltaTime()),
   fVerbose(0),
   fDecoderVersion(0),
   fTOFcalib(calib),
-  fTOFdigitMap(new AliTOFDigitMap())
-
+  fTOFdigitMap(new AliTOFDigitMap()),
+  fTOFGeometry(new AliTOFGeometry()),
+  fTOFdigits(new TTree()),
+  fTOFRawStream(AliTOFRawStream()),
+  fCalibrateTOFtimes(1)
 {
 //
 // Constructor
 //
 
+  for (Int_t ii=0; ii<kTofMaxCluster; ii++) fTofClusters[ii]=0x0;
+
+  if (AliTOFReconstructor::GetRecoParam()) {
+    fkRecoParam = AliTOFReconstructor::GetRecoParam();
+    fMaxDeltaTime = fkRecoParam->GetMaxDeltaTime();
+  }
+  else
+    fMaxDeltaTime = 2;
+
+  TString validity = (TString)fTOFcalib->GetOfflineValidity();
+  if (validity.CompareTo("valid")==0) {
+    AliInfo(Form(" validity = %s - Using offline calibration parameters", validity.Data()));
+  } else {
+    AliInfo(Form(" validity = %s - Using online calibration parameters", validity.Data()));
+  }
+
 }
 //_____________________________________________________________________________
 
 AliTOFClusterFinderV1::AliTOFClusterFinderV1(const AliTOFClusterFinderV1 &source)
-  :TObject(),
-  fRunLoader(0),
-  fDigits(new TClonesArray("AliTOFdigit", 4000)),
-  fRecPoints(new TClonesArray("AliTOFcluster", 4000)),
-  fNumberOfTofClusters(0),
-  fNumberOfTofDigits(0),
-  fMaxDeltaTime(10),
-  fVerbose(0),
-  fDecoderVersion(0),
-  fTOFcalib(0),
-  fTOFdigitMap(new AliTOFDigitMap())
-
+  :TNamed(source),
+   fRunLoader(0),
+   fDigits(source.fDigits),
+   fRecPoints(source.fRecPoints),
+   fNumberOfTofClusters(0),
+   fNumberOfTofDigits(0),
+   fkRecoParam(0),//AliTOFReconstructor::GetRecoParam()),
+   fMaxDeltaTime(0),//fkRecoParam->GetMaxDeltaTime()),
+   fVerbose(0),
+   fDecoderVersion(source.fDecoderVersion),
+   fTOFcalib(source.fTOFcalib),
+   fTOFdigitMap(new AliTOFDigitMap()),
+   fTOFGeometry(new AliTOFGeometry()),
+   fTOFdigits(source.fTOFdigits),
+   fTOFRawStream(source.fTOFRawStream),
+   fCalibrateTOFtimes(1)
 {
   // copy constructor
-  this->fDigits=source.fDigits;
-  this->fRecPoints=source.fRecPoints;
-  this->fDecoderVersion=source.fDecoderVersion;
-  this->fTOFcalib=source.fTOFcalib;
+
+  for (Int_t ii=0; ii<kTofMaxCluster; ii++) fTofClusters[ii]=source.fTofClusters[ii];
+
+  if (AliTOFReconstructor::GetRecoParam()) {
+    fkRecoParam = AliTOFReconstructor::GetRecoParam();
+    fMaxDeltaTime = fkRecoParam->GetMaxDeltaTime();
+  }
+  else
+    fMaxDeltaTime = 2;
 
 }
 //_____________________________________________________________________________
@@ -122,12 +180,22 @@ AliTOFClusterFinderV1::AliTOFClusterFinderV1(const AliTOFClusterFinderV1 &source
 AliTOFClusterFinderV1& AliTOFClusterFinderV1::operator=(const AliTOFClusterFinderV1 &source)
 {
   // ass. op.
-  this->fDigits=source.fDigits;
-  this->fRecPoints=source.fRecPoints;
-  this->fVerbose=source.fVerbose;
-  this->fDecoderVersion=source.fDecoderVersion;
-  this->fTOFcalib=source.fTOFcalib;
-  this->fTOFdigitMap=source.fTOFdigitMap;
+
+  if (this == &source)
+    return *this;
+
+  TObject::operator=(source);
+  for (Int_t ii=0; ii<kTofMaxCluster; ii++) fTofClusters[ii]=source.fTofClusters[ii];
+  fDigits=source.fDigits;
+  fRecPoints=source.fRecPoints;
+  fVerbose=source.fVerbose;
+  fDecoderVersion=source.fDecoderVersion;
+  fTOFcalib=source.fTOFcalib;
+  fTOFdigitMap=source.fTOFdigitMap;
+  fTOFGeometry=source.fTOFGeometry;
+  fTOFdigits=source.fTOFdigits;
+  fTOFRawStream=source.fTOFRawStream;
+  fCalibrateTOFtimes=source.fCalibrateTOFtimes;
   return *this;
 
 }
@@ -155,6 +223,17 @@ AliTOFClusterFinderV1::~AliTOFClusterFinderV1()
 
   delete fTOFdigitMap;
 
+  delete fTOFGeometry;
+
+  delete fTOFdigits;
+
+  //if (fTofClusters || fNumberOfTofClusters) {
+  if (fNumberOfTofClusters) {
+    for (Int_t ii=0; ii<fNumberOfTofClusters; ii++)
+      if (fTofClusters[ii]) fTofClusters[ii]->Delete();
+    fNumberOfTofClusters = 0;
+  }
+
 }
 //_____________________________________________________________________________
 
@@ -169,10 +248,13 @@ void AliTOFClusterFinderV1::Digits2RecPoints(TTree* digitsTree, TTree* clusterTr
 
   Int_t inholes = 0;
 
+  fDigits->Clear();
   TClonesArray &aDigits = *fDigits;
 
-  if (digitsTree == 0x0)
+  if (digitsTree == 0x0) {
     AliFatal("Can not get TreeD for TOF");
+    return;
+  }
 
   TBranch *branch = digitsTree->GetBranch("TOF");
   if (!branch) {
@@ -185,7 +267,7 @@ void AliTOFClusterFinderV1::Digits2RecPoints(TTree* digitsTree, TTree* clusterTr
   TClonesArray *digits = &staticDigits;
   branch->SetAddress(&digits);
   digitsTree->GetEvent(0);
-  AliInfo(Form("Number of TOF digits: %d", digits->GetEntriesFast()));
+  AliDebug(1,Form("Number of TOF digits: %d", digits->GetEntriesFast()));
 
   AliTOFdigit *tofDigit;
 
@@ -201,15 +283,14 @@ void AliTOFClusterFinderV1::Digits2RecPoints(TTree* digitsTree, TTree* clusterTr
 
   Bool_t status = kTRUE;
 
-  AliInfo(" Calibrating TOF Digits: ");
+  AliDebug(1," Calibrating TOF Digits");
+  /*
   TString validity = (TString)fTOFcalib->GetOfflineValidity();
-  AliInfo(Form(" validity = %s", validity.Data()));
   if (validity.CompareTo("valid")==0) {
-    AliInfo(" ...using offline calibration parameters");
-  }
-  else {
-    AliInfo(" ...using online calibration parameters");
-  }
+    AliInfo(Form(" validity = %s - Using offline calibration parameters", validity.Data()));
+  } else
+    AliInfo(Form(" validity = %s - Using online calibration parameters", validity.Data()));
+  */
 
   Int_t ii = 0;
   for (ii=0; ii<digits->GetEntriesFast(); ii++) {
@@ -227,6 +308,7 @@ void AliTOFClusterFinderV1::Digits2RecPoints(TTree* digitsTree, TTree* clusterTr
       }
     }
 
+    tdcCorr = tofDigit->GetTdc();
     status = MakeSlewingCorrection(detectorIndex, tofDigit->GetToT(), tofDigit->GetTdc(), tdcCorr);
 
     for (jj=0; jj<4; jj++) info[jj] = -1;
@@ -243,7 +325,7 @@ void AliTOFClusterFinderV1::Digits2RecPoints(TTree* digitsTree, TTree* clusterTr
     new (aDigits[last]) AliTOFdigit(tracks, detectorIndex, info);
     if (status) fTOFdigitMap->AddDigit(detectorIndex, last);
 
-    AliDebug(2, Form(" Digits reading %2i -> %2i %1i %2i %1i %2i (%d, %d, %d)",
+    AliDebug(2, Form(" Digits reading %2d -> %2d %1d %2d %1d %2d (%d, %d, %d)",
                     last,
                     detectorIndex[0], detectorIndex[1], detectorIndex[2], detectorIndex[3], detectorIndex[4],
                     info[0], info[1], info[3]));
@@ -260,7 +342,7 @@ void AliTOFClusterFinderV1::Digits2RecPoints(TTree* digitsTree, TTree* clusterTr
   FillRecPoint();
   clusterTree->Fill();
 
-  AliInfo(Form("Number of found TOF clusters: %d", fNumberOfTofClusters));
+  AliDebug(1,Form("Number of found clusters: %d", fNumberOfTofClusters));
 
   ResetRecpoint();
 
@@ -268,8 +350,8 @@ void AliTOFClusterFinderV1::Digits2RecPoints(TTree* digitsTree, TTree* clusterTr
 
   ResetDigits();
 
-  AliInfo(Form("Execution time to read TOF digits and to write TOF clusters : R:%.4fs C:%.4fs",
-              stopwatch.RealTime(),stopwatch.CpuTime()));
+  AliDebug(1,Form("Execution time to read TOF digits and to write TOF clusters : R:%.4fs C:%.4fs",
+                 stopwatch.RealTime(),stopwatch.CpuTime()));
 
   if (inholes) AliWarning(Form("Clusters in the TOF holes: %d",inholes));
 
@@ -287,11 +369,12 @@ void AliTOFClusterFinderV1::Digits2RecPoints(AliRawReader *rawReader, TTree *clu
 
 
   AliDebug(2, "TreeD re-creation");
-  TTree *digitsTree = new TTree();
+  //TTree *digitsTree = new TTree();
+  //Raw2Digits(rawReader, digitsTree);
 
-  Raw2Digits(rawReader, digitsTree);
+  Raw2Digits(rawReader, fTOFdigits);
 
-  AliDebug(2,Form("Number of TOF digits: %d", fNumberOfTofDigits));
+  AliDebug(1,Form("Number of TOF digits: %d", fNumberOfTofDigits));
   ResetRecpoint();
 
   Int_t bufsize = 32000;
@@ -300,7 +383,7 @@ void AliTOFClusterFinderV1::Digits2RecPoints(AliRawReader *rawReader, TTree *clu
 
   clustersTree->Fill();
 
-  AliInfo(Form("Number of found clusters: %i", fNumberOfTofClusters));
+  AliDebug(1,Form("Number of found clusters: %d", fNumberOfTofClusters));
 
   ResetRecpoint();
 
@@ -308,8 +391,8 @@ void AliTOFClusterFinderV1::Digits2RecPoints(AliRawReader *rawReader, TTree *clu
 
   ResetDigits();
 
-  AliInfo(Form("Execution time to read TOF raw data and to write TOF clusters : R:%.4fs C:%.4fs",
-                  stopwatch.RealTime(),stopwatch.CpuTime()));
+  AliDebug(1,Form("Execution time to read TOF raw data and to write TOF clusters : R:%.4fs C:%.4fs",
+                 stopwatch.RealTime(),stopwatch.CpuTime()));
 
 }
 
@@ -332,7 +415,8 @@ void AliTOFClusterFinderV1::Raw2Digits(AliRawReader *rawReader, TTree* digitsTre
   digitsTree->Branch("TOF", &fDigits);
   TClonesArray &aDigits = *fDigits;
 
-  AliTOFRawStream tofInput(rawReader);
+  fTOFRawStream.Clear();
+  fTOFRawStream.SetRawReader(rawReader);
 
   ofstream ftxt;
   if (fVerbose==2) ftxt.open("TOFdigitsRead.txt",ios::app);
@@ -352,29 +436,28 @@ void AliTOFClusterFinderV1::Raw2Digits(AliRawReader *rawReader, TTree* digitsTre
 
   Bool_t status = kTRUE;
 
-  AliInfo(" Calibrating TOF Digits: ");
+  /*
   TString validity = (TString)fTOFcalib->GetOfflineValidity();
-  AliInfo(Form(" validity = %s", validity.Data()));
   if (validity.CompareTo("valid")==0) {
-    AliInfo(" ...using offline calibration parameters");
-  }
-  else {
-    AliInfo(" ...using online calibration parameters");
-  }
+    AliInfo(Form(" validity = %s - Using offline calibration parameters", validity.Data()));
+  } else
+    AliInfo(Form(" validity = %s - Using online calibration parameters", validity.Data()));
+  */
+
+  if (fDecoderVersion)
+    AliInfo("Using New Decoder");
 
   Int_t indexDDL = 0;
   Int_t iRawData = 0;
   for (indexDDL=0; indexDDL<kDDL; indexDDL++) {
 
     rawReader->Reset();
-    if (fDecoderVersion) {
-      AliInfo("Using New Decoder \n"); 
-      tofInput.LoadRawDataBuffers(indexDDL,fVerbose);
-    }
-    else tofInput.LoadRawData(indexDDL);
+    if (fDecoderVersion)
+      fTOFRawStream.LoadRawDataBuffers(indexDDL,fVerbose);
+    else fTOFRawStream.LoadRawData(indexDDL);
 
-    clonesRawData = (TClonesArray*)tofInput.GetRawData();
-    if (clonesRawData->GetEntriesFast()!=0) AliInfo(Form(" TOF raw data number = %3i", clonesRawData->GetEntriesFast()));
+    clonesRawData = (TClonesArray*)fTOFRawStream.GetRawData();
+    if (clonesRawData->GetEntriesFast()!=0) AliDebug(2,Form(" TOF raw data number = %3d", clonesRawData->GetEntriesFast()));
     for (iRawData = 0; iRawData<clonesRawData->GetEntriesFast(); iRawData++) {
 
       AliTOFrawData *tofRawDatum = (AliTOFrawData*)clonesRawData->UncheckedAt(iRawData);
@@ -382,24 +465,29 @@ void AliTOFClusterFinderV1::Raw2Digits(AliRawReader *rawReader, TTree* digitsTre
       //if (tofRawDatum->GetTOT()==-1 || tofRawDatum->GetTOF()==-1) continue;
       if (tofRawDatum->GetTOF()==-1) continue;
 
-      tofInput.EquipmentId2VolumeId(indexDDL, tofRawDatum->GetTRM(), tofRawDatum->GetTRMchain(),
-                                   tofRawDatum->GetTDC(), tofRawDatum->GetTDCchannel(), detectorIndex);
+      fTOFRawStream.EquipmentId2VolumeId(indexDDL, tofRawDatum->GetTRM(), tofRawDatum->GetTRMchain(),
+                                        tofRawDatum->GetTDC(), tofRawDatum->GetTDCchannel(), detectorIndex);
 
       tdcCorr = 0;
       dummy = detectorIndex[3];
       detectorIndex[3] = detectorIndex[4];//padz
       detectorIndex[4] = dummy;//padx
+
+      tdcCorr = tofRawDatum->GetTOF();
       status = MakeSlewingCorrection(detectorIndex, tofRawDatum->GetTOT(), tofRawDatum->GetTOF(), tdcCorr);
 
       digit[0] = tdcCorr;
       digit[1] = tofRawDatum->GetTOT();
       digit[2] = tofRawDatum->GetTOT();
-      digit[3] = tofRawDatum->GetTOF();
+      digit[3] = -1;//tofRawDatum->GetTOF(); //tofND
 
       dummy = detectorIndex[3];
       detectorIndex[3] = detectorIndex[4];//padx
       detectorIndex[4] = dummy;//padz
 
+      /* check valid index */
+      if (detectorIndex[0]==-1||detectorIndex[1]==-1||detectorIndex[2]==-1||detectorIndex[3]==-1||detectorIndex[4]==-1) continue;
+
       // Do not reconstruct anything in the holes
       if (detectorIndex[0]==13 || detectorIndex[0]==14 || detectorIndex[0]==15 ) { // sectors with holes
        if (detectorIndex[1]==2) { // plate with holes
@@ -440,7 +528,7 @@ void AliTOFClusterFinderV1::Raw2Digits(AliRawReader *rawReader, TTree* digitsTre
        else ftxt << "   " << digit[3] << endl;
       }
 
-      AliDebug(2, Form(" Raw data reading %2i -> %2i %1i %2i %1i %2i (%d, %d, %d)",
+      AliDebug(2, Form(" Raw data reading %2d -> %2d %1d %2d %1d %2d (%d, %d, %d)",
                       last,
                       detectorIndex[0], detectorIndex[1], detectorIndex[2], detectorIndex[4], detectorIndex[3],
                       digit[0], digit[1], digit[3]));
@@ -473,73 +561,103 @@ void AliTOFClusterFinderV1::FillRecPoint()
   // i.e. fRecPoints
   //
 
-  //Int_t dummy4_1 = -1;
-  //Int_t dummy3_1 = -1;
-  //Int_t dummy2_1 = -1;
-  Int_t dummy    = -1;
+  Int_t dummy4 = -1;
+  Int_t dummy3 = -1;
+  Int_t dummy2 = -1;
+  Int_t dummy  = -1;
 
-  for(Int_t iPlate=0; iPlate<AliTOFGeometry::NPlates(); iPlate++) {
-    for(Int_t iStrip=0; iStrip<AliTOFGeometry::NStrip(iPlate); iStrip++) {
+  for(Int_t iPlate=AliTOFGeometry::NPlates()-1; iPlate>=0; iPlate--) {
+    for(Int_t iStrip=AliTOFGeometry::NStrip(iPlate)-1; iStrip>=0; iStrip--) {
+      //for (Int_t iSector=AliTOFGeometry::NSectors()-1; iSector>=0; iSector--) {
       for (Int_t iSector=0; iSector<AliTOFGeometry::NSectors(); iSector++) {
-       /*
-       if (!(fTOFdigitMap->StripDigitCheck(iSector,iPlate,iStrip))) continue;
-       FindClustersPerStrip(iSector, iPlate, iStrip, 4); // 4 pads clusters
-       dummy4_1 = fNumberOfTofClusters;
-       if (!(fTOFdigitMap->StripDigitCheck(iSector,iPlate,iStrip))) continue;
-       FindClustersPerStrip(iSector, iPlate, iStrip, 4); // 4 pads clusters
-       if (fNumberOfTofClusters!=dummy4_1)
-         AliDebug(2, Form(" (4): n1= %5i, n2 = %5", dummy4_1, fNumberOfTofClusters));
-       */
-       /*
-       if (!(fTOFdigitMap->StripDigitCheck(iSector,iPlate,iStrip))) continue;
-       FindClustersPerStrip(iSector, iPlate, iStrip, 3); // 3 pads clusters
-       dummy3_1 = fNumberOfTofClusters;
-       if (!(fTOFdigitMap->StripDigitCheck(iSector,iPlate,iStrip))) continue;
-       FindClustersPerStrip(iSector, iPlate, iStrip, 3); // 3 pads clusters
-       if (fNumberOfTofClusters!=dummy3_1)
-         AliDebug(2, Form(" (3): n1= %5i, n2 = %5", dummy3_1, fNumberOfTofClusters));
-       */
-       /*
-       if (!(fTOFdigitMap->StripDigitCheck(iSector,iPlate,iStrip))) continue;
-       FindClustersPerStrip(iSector, iPlate, iStrip, 2); // 2 pads clusters
-       dummy2_1 = fNumberOfTofClusters;
-       if (!(fTOFdigitMap->StripDigitCheck(iSector,iPlate,iStrip))) continue;
-       FindClustersPerStrip(iSector, iPlate, iStrip, 2); // 2 pads clusters
-       if (fNumberOfTofClusters!=dummy2_1)
-         AliDebug(2, Form(" (2): n1= %5i, n2 =%5", dummy2_1, fNumberOfTofClusters));
-       */
-       /*
-       if (!(fTOFdigitMap->StripDigitCheck(iSector,iPlate,iStrip))) continue;
-       dummy = fNumberOfTofClusters;
-       FindClusters34(iSector, iPlate, iStrip); // 3 pads clusters between 4 hit pads
-       if (fNumberOfTofClusters!=dummy)
-         AliDebug(2, Form(" (3 between 4): n1 = %5i, n2 = %5i", fNumberOfTofClusters, dummy));
-       */
-       /*
-       if (!(fTOFdigitMap->StripDigitCheck(iSector,iPlate,iStrip))) continue;
-       dummy = fNumberOfTofClusters;
-       FindClusters23(iSector, iPlate, iStrip); // 2 pads clusters between 3 hit pads
-       if (fNumberOfTofClusters!=dummy)
-         AliDebug(2, Form(" (2 between 3): n1 = %5i, n2 = %5i", fNumberOfTofClusters, dummy));
 
-       if (!(fTOFdigitMap->StripDigitCheck(iSector,iPlate,iStrip))) continue;
-       dummy = fNumberOfTofClusters;
-       FindClusters24(iSector, iPlate, iStrip); // 2 pads clusters between 4 hit pads
-       if (fNumberOfTofClusters!=dummy)
-         AliDebug(2, Form(" (2 between 4): n1 = %5i, n2 = %5i", fNumberOfTofClusters, dummy));
-       */
 
+       if (fTOFdigitMap->StripDigitCheck(iSector,iPlate,iStrip))
+         AliDebug(1,Form(" Number of TOF digits in (%2d,%1d,%2d) -> %d",
+                         iSector,iPlate,iStrip,fTOFdigitMap->FilledCellsInStrip(iSector,iPlate,iStrip)));
 
        if (!(fTOFdigitMap->StripDigitCheck(iSector,iPlate,iStrip))) continue;
-       dummy = fNumberOfTofClusters;
-       FindOnePadClusterPerStrip(iSector, iPlate, iStrip); // 1 pad clusters
-       if (fNumberOfTofClusters!=dummy)
-         AliDebug(2,Form(" (1): n1 = %5i, n2 = %5i", fNumberOfTofClusters, dummy));
+       FindClustersWithoutTOT(iSector, iPlate, iStrip); // clusters coming from digits without TOT measurement
+
+       if (fMaxDeltaTime>0) {
+
+         if (!(fTOFdigitMap->StripDigitCheck(iSector,iPlate,iStrip))) continue;
+         //if (fTOFdigitMap->FilledCellsInStrip(iSector,iPlate,iStrip)>=4)
+         FindClustersPerStrip(iSector, iPlate, iStrip, 4); // 4 pads clusters
+         if (!(fTOFdigitMap->StripDigitCheck(iSector,iPlate,iStrip))) continue;
+
+         dummy4 = fNumberOfTofClusters;
+         FindClustersPerStrip(iSector, iPlate, iStrip, 4); // 4 pads clusters
+         if (fNumberOfTofClusters!=dummy4)
+           AliDebug(2, Form(" (4): n1= %5d, n2 = %5d", dummy4, fNumberOfTofClusters));
+
+
+         if (!(fTOFdigitMap->StripDigitCheck(iSector,iPlate,iStrip))) continue;
+         FindClustersPerStrip(iSector, iPlate, iStrip, 3); // 3 pads clusters
+         if (!(fTOFdigitMap->StripDigitCheck(iSector,iPlate,iStrip))) continue;
+
+         dummy3 = fNumberOfTofClusters;
+         FindClustersPerStrip(iSector, iPlate, iStrip, 3); // 3 pads clusters
+         if (fNumberOfTofClusters!=dummy3)
+           AliDebug(2, Form(" (3): n1= %5d, n2 = %5d", dummy3, fNumberOfTofClusters));
+
+
+         if (!(fTOFdigitMap->StripDigitCheck(iSector,iPlate,iStrip))) continue;
+         FindClustersPerStrip(iSector, iPlate, iStrip, 2); // 2 pads clusters
+         if (!(fTOFdigitMap->StripDigitCheck(iSector,iPlate,iStrip))) continue;
+
+         dummy2 = fNumberOfTofClusters;
+         FindClustersPerStrip(iSector, iPlate, iStrip, 2); // 2 pads clusters
+         if (fNumberOfTofClusters!=dummy2)
+           AliDebug(2, Form(" (2): n1= %5d, n2 =%5d", dummy2, fNumberOfTofClusters));
+
+
+         if (!(fTOFdigitMap->StripDigitCheck(iSector,iPlate,iStrip))) continue;
+         dummy = fNumberOfTofClusters;
+         FindClusters34(iSector, iPlate, iStrip); // 3 pads clusters between 4 hit pads
+         if (fNumberOfTofClusters!=dummy)
+           AliDebug(2, Form(" (3 between 4): n1 = %5d, n2 = %5d", fNumberOfTofClusters, dummy));
+
+
+         if (!(fTOFdigitMap->StripDigitCheck(iSector,iPlate,iStrip))) continue;
+         dummy = fNumberOfTofClusters;
+         FindClusters23(iSector, iPlate, iStrip); // 2 pads clusters between 3 hit pads
+         if (fNumberOfTofClusters!=dummy)
+           AliDebug(2, Form(" (2 between 3): n1 = %5d, n2 = %5d", fNumberOfTofClusters, dummy));
+
+         if (!(fTOFdigitMap->StripDigitCheck(iSector,iPlate,iStrip))) continue;
+         dummy = fNumberOfTofClusters;
+         FindClusters24(iSector, iPlate, iStrip); // 2 pads clusters between 4 hit pads
+         if (fNumberOfTofClusters!=dummy)
+           AliDebug(2, Form(" (2 between 4): n1 = %5d, n2 = %5d", fNumberOfTofClusters, dummy));
+
+
+         if (!(fTOFdigitMap->StripDigitCheck(iSector,iPlate,iStrip))) continue;
+         dummy = fNumberOfTofClusters;
+         FindOnePadClusterPerStrip(iSector, iPlate, iStrip); // 1 pad clusters
+         if (fNumberOfTofClusters!=dummy)
+           AliDebug(2,Form(" (1): n1 = %5d, n2 = %5d", fNumberOfTofClusters, dummy));
+
+         if (fTOFdigitMap->DigitInStrip(iSector,iPlate,iStrip)>0)
+           AliDebug(2, Form(" (1): number of clusters = %5d (remaining digit %2d), -%2d %1d %2d-",
+                            fNumberOfTofClusters, fTOFdigitMap->DigitInStrip(iSector,iPlate,iStrip),
+                            iSector, iPlate, iStrip));
+
+       }
+       else {
+         if (!(fTOFdigitMap->StripDigitCheck(iSector,iPlate,iStrip))) continue;
+         dummy = fNumberOfTofClusters;
+         FindOnePadClusterPerStrip(iSector, iPlate, iStrip); // 1 pad clusters
+         if (fNumberOfTofClusters!=dummy)
+           AliDebug(2,Form(" (1): n1 = %5d, n2 = %5d", fNumberOfTofClusters, dummy));
+
+         if (fTOFdigitMap->DigitInStrip(iSector,iPlate,iStrip)>0)
+           AliDebug(2, Form(" (1): number of clusters = %5d (remaining digit %2d), -%2d %1d %2d-",
+                            fNumberOfTofClusters, fTOFdigitMap->DigitInStrip(iSector,iPlate,iStrip),
+                            iSector, iPlate, iStrip));
+
+       }
 
-       if (fTOFdigitMap->DigitInStrip(iSector,iPlate,iStrip)>0)
-         AliDebug(2, Form(" (1): numero di clusters = %5i (remaining digit %2i), -%2i %1i %2i-",
-                       fNumberOfTofClusters, fTOFdigitMap->DigitInStrip(iSector,iPlate,iStrip),
-                       iSector, iPlate, iStrip));
 
       }
     }
@@ -551,8 +669,11 @@ void AliTOFClusterFinderV1::FillRecPoint()
   Int_t ii, jj;
 
   Int_t detectorIndex[5];
-  Int_t parTOF[5];
+  for (jj=0; jj<5; jj++) detectorIndex[jj] = -1;
+  Int_t parTOF[7];
+  for (jj=0; jj<7; jj++) parTOF[jj] = -1;
   Int_t trackLabels[3];
+  for (jj=0; jj<3; jj++) trackLabels[jj] = -1;
   Int_t digitIndex = -1;
   Bool_t status = kTRUE;
   Float_t posClus[3];
@@ -565,13 +686,16 @@ void AliTOFClusterFinderV1::FillRecPoint()
 
     digitIndex = fTofClusters[ii]->GetIndex();
     for(jj=0; jj<5; jj++) detectorIndex[jj] = fTofClusters[ii]->GetDetInd(jj);
-    volIdClus = GetClusterVolIndex(detectorIndex);
+    volIdClus = fTOFGeometry->GetAliSensVolIndex(detectorIndex[0],detectorIndex[1],detectorIndex[2]);
+    //volIdClus = GetClusterVolIndex(detectorIndex);
     for(jj=0; jj<3; jj++) trackLabels[jj] = fTofClusters[ii]->GetLabel(jj);
     parTOF[0] = fTofClusters[ii]->GetTDC(); // TDC
     parTOF[1] = fTofClusters[ii]->GetToT(); // TOT
     parTOF[2] = fTofClusters[ii]->GetADC(); // ADC=TOT
     parTOF[3] = fTofClusters[ii]->GetTDCND(); // TDCND
     parTOF[4] = fTofClusters[ii]->GetTDCRAW();//RAW
+    parTOF[5] = 0;
+    parTOF[6] = 0;
     status = fTofClusters[ii]->GetStatus();
 
     posClus[0] = fTofClusters[ii]->GetX();
@@ -592,7 +716,7 @@ void AliTOFClusterFinderV1::FillRecPoint()
                                      //(Double_t)covClus[3], (Double_t)covClus[4], (Double_t)covClus[5],
                                      trackLabels, detectorIndex, parTOF, status, digitIndex);
 
-    AliDebug(2, Form(" %4i  %4i  %f %f %f  %f %f %f %f %f %f  %3i %3i %3i  %2i %1i %2i %1i %2i  %4i %3i %3i %4i %4i  %1i  %4i", 
+    AliDebug(2, Form(" %4d  %4d  %f %f %f  %f %f %f %f %f %f  %3d %3d %3d  %2d %1d %2d %1d %2d  %4d %3d %3d %4d %4d  %1d  %4d", 
                     ii, volIdClus, posClus[0], posClus[1], posClus[2],
                     fTofClusters[ii]->GetSigmaX2(),
                     fTofClusters[ii]->GetSigmaXY(),
@@ -612,7 +736,7 @@ void AliTOFClusterFinderV1::FillRecPoint()
     for(Int_t iPlate=0; iPlate<AliTOFGeometry::NPlates(); iPlate++) {
       for(Int_t iStrip=0; iStrip<AliTOFGeometry::NStrip(iPlate); iStrip++) {
        if (!(fTOFdigitMap->StripDigitCheck(iSector,iPlate,iStrip))) continue;
-       AliDebug(2, Form(" END %2i %1i %2i   %5i",
+       AliDebug(2, Form(" END %2d %1d %2d   %5d",
                         iSector, iPlate, iStrip, fTOFdigitMap->DigitInStrip(iSector,iPlate,iStrip)));
       }
     }
@@ -632,12 +756,10 @@ void AliTOFClusterFinderV1::FindOnePadClusterPerStrip(Int_t nSector,
   //
 
   const Int_t kMaxNumberOfTracksPerDigit = 3;
-  const Int_t kMaxNumberOfDigitsPerVolume = 3;
+  const Int_t kMaxNumberOfDigitsPerVolume = 10;
 
   Int_t jj = 0;
 
-  AliTOFGeometry *tofGeometry = new AliTOFGeometry();
-
   Int_t det[5] = {nSector,nPlate,nStrip,-1,-1};//sector,plate,strip,padZ,padX
   Int_t vol[5] = {nSector,nPlate,nStrip,-1,-1};//sector,plate,strip,padX,padZ
   UShort_t volIdClus = 0;
@@ -650,16 +772,15 @@ void AliTOFClusterFinderV1::FindOnePadClusterPerStrip(Int_t nSector,
   Double_t covClus[6];
   for (jj=0; jj<6; jj++) covClus[jj] = 0.;
 
-  Int_t parTOF[5];
-  for (jj=0; jj<5; jj++) parTOF[jj] = 0;
+  Int_t parTOF[7];
+  for (jj=0; jj<7; jj++) parTOF[jj] = 0;
 
   Bool_t status = kTRUE; //assume all sim channels ok in the beginning...
 
   Int_t tracks[kMaxNumberOfTracksPerDigit];
-  for (jj=0; jj<3; jj++) tracks[jj] = -1;
+  for (jj=0; jj<kMaxNumberOfTracksPerDigit; jj++) tracks[jj] = -1;
 
   Int_t dummyCounter=-1;
-  //Int_t dummyPad=-1;
 
   AliTOFdigit *digitInteresting;
 
@@ -669,7 +790,7 @@ void AliTOFClusterFinderV1::FindOnePadClusterPerStrip(Int_t nSector,
     for (iPadZ=0; iPadZ<AliTOFGeometry::NpadZ(); iPadZ++) {
       vol[4] = iPadZ  , vol[3]  = iPadX;
 
-      AliDebug(3, Form(" %1i %2i\n", iPadZ, iPadX));
+      AliDebug(3, Form(" %1d %2d\n", iPadZ, iPadX));
 
       if (fTOFdigitMap->GetNumberOfDigits(vol)==0) continue;
 
@@ -677,31 +798,32 @@ void AliTOFClusterFinderV1::FindOnePadClusterPerStrip(Int_t nSector,
        if (fTOFdigitMap->GetDigitIndex(vol,digIndex)<0) continue;
        digitInteresting = (AliTOFdigit*)fDigits->UncheckedAt(fTOFdigitMap->GetDigitIndex(vol,digIndex));
 
-       AliDebug(2, Form(" %2i %1i %2i %1i %2i  %f %f %f  %5i  %5i %5i %5i",
+       AliDebug(2, Form(" %3d  %5d    %2d %1d %2d %1d %2d  %d %d %d  %5d  %5d %5d %5d",
+                        fTOFdigitMap->GetNumberOfDigits(vol), digIndex,
                         vol[0], vol[1], vol[2] ,vol[4], vol[3],
                         digitInteresting->GetTdc(), digitInteresting->GetAdc(),
                         digitInteresting->GetToT(),
                         fTOFdigitMap->GetDigitIndex(vol,digIndex),
                         digitInteresting->GetTrack(0), digitInteresting->GetTrack(1), digitInteresting->GetTrack(2)));
        
-       //dummyPad = vol[3];
-       //vol[3] = vol[4];
-       //vol[4] = dummyPad;
-       det[3] = vol[4];
-       det[4] = vol[3];
-       tofGeometry->GetPosPar(det,pos);
+       det[3] = vol[4]; // padz
+       det[4] = vol[3]; // padx
+       fTOFGeometry->GetPosPar(det,pos);
        AliDebug(1,Form(" %f %f %f", pos[0], pos[1], pos[2]));
 
        //insert cluster
        for (jj=0; jj<3; jj++) posClus[jj] = pos[jj];
 
        parTOF[0] = Int_t(digitInteresting->GetTdc());
-       parTOF[1] = Int_t(digitInteresting->GetAdc());
-       parTOF[2] = Int_t(digitInteresting->GetToT());
-       parTOF[3] = Int_t(digitInteresting->GetTdc());
+       parTOF[1] = Int_t(digitInteresting->GetToT());
+       parTOF[2] = Int_t(digitInteresting->GetAdc());
+       parTOF[3] = Int_t(digitInteresting->GetTdcND());
        parTOF[4] = Int_t(digitInteresting->GetTdc());
+       parTOF[5] = 0;
+       parTOF[6] = 0;
 
-       volIdClus = GetClusterVolIndex(det);
+       volIdClus = fTOFGeometry->GetAliSensVolIndex(det[0],det[1],det[2]);
+       //volIdClus = GetClusterVolIndex(det);
 
        for (jj=0; jj<6; jj++) covClus[jj] = 0.;
        GetClusterPars(det, posClus, covClus);
@@ -723,7 +845,7 @@ void AliTOFClusterFinderV1::FindOnePadClusterPerStrip(Int_t nSector,
                            tracks, det, parTOF, status, fTOFdigitMap->GetDigitIndex(vol,digIndex));
        InsertCluster(tofCluster);
 
-       AliDebug(2, Form("       %4i  %f %f %f  %f %f %f %f %f %f  %3i %3i %3i  %2i %1i %2i %1i %2i  %4i %3i %3i %4i %4i  %1i  %4i", 
+       AliDebug(2, Form("       %4d  %f %f %f  %f %f %f %f %f %f  %3d %3d %3d  %2d %1d %2d %1d %2d  %4d %3d %3d %4d %4d  %1d  %4d", 
                         volIdClus, posClus[0], posClus[1], posClus[2],
                         covClus[0], covClus[1], covClus[2], covClus[3], covClus[4], covClus[5],
                         tracks[0], tracks[1], tracks[2],
@@ -732,11 +854,131 @@ void AliTOFClusterFinderV1::FindOnePadClusterPerStrip(Int_t nSector,
                         status, fTOFdigitMap->GetDigitIndex(vol,digIndex)));
 
        AliDebug(2, Form("        %f %f %f", pos[0], pos[1], pos[2]));
-       AliDebug(2, Form("           %f %f", parTOF[0], parTOF[2]));
+       AliDebug(2, Form("           %d %d", parTOF[0], parTOF[2]));
+
+       fTOFdigitMap->ResetDigit(vol, digIndex);
+
+      }
+
+    }
+  }
+
+}
+//_____________________________________________________________________________
+
+void AliTOFClusterFinderV1::FindClustersWithoutTOT(Int_t nSector,
+                                                  Int_t nPlate,
+                                                  Int_t nStrip)
+{
+  //
+  // This function searches the isolated digits without TOT
+  // measurement (stored in the fDigits object), to perform clusters
+  // (stored in the fTofClusters array). This research has been made
+  // by checking the fTOFdigitMap object, filled at digits/raw-data
+  // reading time.
+  //
+
+  const Int_t kMaxNumberOfTracksPerDigit = 3;
+  const Int_t kMaxNumberOfDigitsPerVolume = 10;
+
+  Int_t jj = 0;
+
+  Int_t det[5] = {nSector,nPlate,nStrip,-1,-1};//sector,plate,strip,padZ,padX
+  Int_t vol[5] = {nSector,nPlate,nStrip,-1,-1};//sector,plate,strip,padX,padZ
+  UShort_t volIdClus = 0;
+
+  Float_t pos[3];
+  for (jj=0; jj<3; jj++) pos[jj] = 0.;
+  Double_t posClus[3];
+  for (jj=0; jj<3; jj++) posClus[jj] = 0.;
+
+  Double_t covClus[6];
+  for (jj=0; jj<6; jj++) covClus[jj] = 0.;
+
+  Int_t parTOF[7];
+  for (jj=0; jj<7; jj++) parTOF[jj] = 0;
+
+  Bool_t status = kTRUE; //assume all sim channels ok in the beginning...
+  Int_t tracks[kMaxNumberOfTracksPerDigit];
+  for (jj=0; jj<kMaxNumberOfTracksPerDigit; jj++) tracks[jj] = -1;
+
+  Int_t dummyCounter=-1;
+
+  AliTOFdigit *digitInteresting;
+
+  Int_t iPadX = -1;
+  Int_t iPadZ = -1;
+  for (iPadX=0; iPadX<AliTOFGeometry::NpadX(); iPadX++) {
+    for (iPadZ=0; iPadZ<AliTOFGeometry::NpadZ(); iPadZ++) {
+      vol[4] = iPadZ  , vol[3]  = iPadX;
+
+      AliDebug(3, Form(" %1d %2d\n", iPadZ, iPadX));
+
+      if (fTOFdigitMap->GetNumberOfDigits(vol)==0) continue;
+
+      for(Int_t digIndex=0; digIndex<kMaxNumberOfDigitsPerVolume; digIndex++) {
+       if (fTOFdigitMap->GetDigitIndex(vol,digIndex)<0) continue;
+       digitInteresting = (AliTOFdigit*)fDigits->UncheckedAt(fTOFdigitMap->GetDigitIndex(vol,digIndex));
+       if (digitInteresting->GetToT()>0) continue; // AdC
+
+       AliDebug(2, Form(" %3d  %5d    %2d %1d %2d %1d %2d  %d %d %d  %5d  %5d %5d %5d",
+                        fTOFdigitMap->GetNumberOfDigits(vol), digIndex,
+                        vol[0], vol[1], vol[2] ,vol[4], vol[3],
+                        digitInteresting->GetTdc(), digitInteresting->GetAdc(),
+                        digitInteresting->GetToT(),
+                        fTOFdigitMap->GetDigitIndex(vol,digIndex),
+                        digitInteresting->GetTrack(0), digitInteresting->GetTrack(1), digitInteresting->GetTrack(2)));
+       
+       det[3] = vol[4]; // padz
+       det[4] = vol[3]; // padx
+       fTOFGeometry->GetPosPar(det,pos);
+       AliDebug(1,Form(" %f %f %f", pos[0], pos[1], pos[2]));
+
+       //insert cluster
+       for (jj=0; jj<3; jj++) posClus[jj] = pos[jj];
+
+       parTOF[0] = Int_t(digitInteresting->GetTdc());
+       parTOF[1] = Int_t(digitInteresting->GetToT());
+       parTOF[2] = Int_t(digitInteresting->GetAdc());
+       parTOF[3] = Int_t(digitInteresting->GetTdcND());
+       parTOF[4] = Int_t(digitInteresting->GetTdc());
+       parTOF[5] = 0;
+       parTOF[6] = 0;
+
+       volIdClus = fTOFGeometry->GetAliSensVolIndex(det[0],det[1],det[2]);
+       //volIdClus = GetClusterVolIndex(det);
+
+       for (jj=0; jj<6; jj++) covClus[jj] = 0.;
+       GetClusterPars(det, posClus, covClus);
+
+       // To fill the track index array
+       dummyCounter=-1;
+       for (jj=0; jj<kMaxNumberOfTracksPerDigit; jj++) tracks[jj] = -1;
+       for (jj=0; jj<kMaxNumberOfTracksPerDigit; jj++) { // three is the max number of tracks associated to one digit
+         if (digitInteresting->GetTrack(jj)==-1) continue;
+         else {
+           dummyCounter++;
+           tracks[dummyCounter] = digitInteresting->GetTrack(jj);
+         }
+       }
+
+       AliTOFcluster *tofCluster =
+         new AliTOFcluster(volIdClus, posClus[0], posClus[1], posClus[2],
+                           covClus[0], covClus[1], covClus[2], covClus[3], covClus[4], covClus[5],
+                           tracks, det, parTOF, status, fTOFdigitMap->GetDigitIndex(vol,digIndex));
+       InsertCluster(tofCluster);
+
+       AliDebug(2, Form("       %4d  %f %f %f  %f %f %f %f %f %f  %3d %3d %3d  %2d %1d %2d %1d %2d  %4d %3d %3d %4d %4d  %1d  %4d", 
+                        volIdClus, posClus[0], posClus[1], posClus[2],
+                        covClus[0], covClus[1], covClus[2], covClus[3], covClus[4], covClus[5],
+                        tracks[0], tracks[1], tracks[2],
+                        det[0], det[1], det[2], det[3], det[4],
+                        parTOF[0], parTOF[1], parTOF[2], parTOF[3], parTOF[4],
+                        status, fTOFdigitMap->GetDigitIndex(vol,digIndex)));
+
+       AliDebug(2, Form("        %f %f %f", pos[0], pos[1], pos[2]));
+       AliDebug(2, Form("           %d %d", parTOF[0], parTOF[2]));
 
-       //dummyPad = vol[3];
-       //vol[3] = vol[4];
-       //vol[4] = dummyPad;
        fTOFdigitMap->ResetDigit(vol, digIndex);
 
       }
@@ -761,7 +1003,7 @@ void AliTOFClusterFinderV1::FindClusters34(Int_t nSector,
 
   const Int_t kMaxNumberOfInterestingPads = 4;
   const Int_t kMaxNumberOfTracksPerDigit = 3;
-  const Int_t kMaxNumberOfDigitsPerVolume = 3;
+  const Int_t kMaxNumberOfDigitsPerVolume = 10;
 
   Int_t ii = 0;
 
@@ -769,7 +1011,6 @@ void AliTOFClusterFinderV1::FindClusters34(Int_t nSector,
   for (ii=0; ii<kMaxNumberOfDigitsPerVolume; ii++)
     digitsInVolumeIndices[ii] = -1;
 
-  AliTOFGeometry *tofGeometry = new AliTOFGeometry();
   Int_t vol[5] = {nSector,nPlate,nStrip,-1,-1};
 
   Float_t pos[3] = {0.,0.,0.};
@@ -805,12 +1046,13 @@ void AliTOFClusterFinderV1::FindClusters34(Int_t nSector,
   for (jj=3; jj<11; jj++) padsCluster[jj] = -1;
 
   Int_t interestingCounter=-1;
+  Int_t  digitIndexLocal=-1; // AdC
   Int_t iPad  = -1;
   Int_t iPadX = -1;
   Int_t iPadZ = -1;
 
-  Int_t parTOF[5];
-  for (jj=0; jj<5; jj++) parTOF[jj] = 0;
+  Int_t parTOF[7];
+  for (jj=0; jj<7; jj++) parTOF[jj] = 0;
   Double_t posClus[3];
   for (jj=0; jj<3; jj++) posClus[jj] = 0.;
   Int_t det[5];
@@ -823,7 +1065,7 @@ void AliTOFClusterFinderV1::FindClusters34(Int_t nSector,
   Double_t covClus[6];
   for (jj=0; jj<6; jj++) covClus[jj] = 0.;
   Int_t tracks[kMaxNumberOfTracksPerDigit];
-  for (jj=0; jj<3; jj++) tracks[jj] = -1;
+  for (jj=0; jj<kMaxNumberOfTracksPerDigit; jj++) tracks[jj] = -1;
   Int_t dummyCounter=-1;
   Bool_t alreadyStored = kFALSE;
 
@@ -841,7 +1083,7 @@ void AliTOFClusterFinderV1::FindClusters34(Int_t nSector,
     iPadZ = iPad%AliTOFGeometry::NpadZ(); //iPad%2;
     iPadX = iPad/AliTOFGeometry::NpadZ(); //iPad/2;
 
-    AliDebug(3, Form("%2i %1i %2i\n", iPad, iPadZ, iPadX));
+    AliDebug(3, Form("%2d %1d %2d\n", iPad, iPadZ, iPadX));
 
 
 
@@ -882,11 +1124,14 @@ void AliTOFClusterFinderV1::FindClusters34(Int_t nSector,
       for (ii=0; ii<kMaxNumberOfDigitsPerVolume; ii++)
        digitsInVolumeIndices[ii] = -1;
       fTOFdigitMap->GetDigitIndex(vol, digitsInVolumeIndices);
+      digitIndexLocal=-1; // AdC
       for(Int_t digIndex=0; digIndex<kMaxNumberOfDigitsPerVolume; digIndex++) {
        if (digitsInVolumeIndices[digIndex]<0) continue;
        digitInteresting = (AliTOFdigit*)fDigits->UncheckedAt(digitsInVolumeIndices[digIndex]);
+       if (digitInteresting->GetToT()<=0) continue; // AdC
+       digitIndexLocal++; // AdC
 
-       AliDebug(1,Form(" %2i %1i %2i %1i %2i  %f %f %f %f  %5i  %5i %5i %5i",
+       AliDebug(1,Form(" %2d %1d %2d %1d %2d  %d %d %d %d  %5d  %5d %5d %5d",
                        vol[0], vol[1], vol[2] ,vol[4], vol[3],
                        digitInteresting->GetTdc(), digitInteresting->GetAdc(),
                        digitInteresting->GetToT(), digitInteresting->GetToT()*digitInteresting->GetToT(),
@@ -894,13 +1139,14 @@ void AliTOFClusterFinderV1::FindClusters34(Int_t nSector,
                        digitInteresting->GetTrack(0), digitInteresting->GetTrack(1), digitInteresting->GetTrack(2)));
 
 
-       selectedDigit[interestingCounter][digIndex] = new
+       selectedDigit[interestingCounter][digitIndexLocal] = new // AdC
          AliTOFselectedDigit(vol, digitInteresting->GetTdc(),
                              digitInteresting->GetAdc(), digitInteresting->GetToT(),
                              digitInteresting->GetToT()*digitInteresting->GetToT(),
                              digitsInVolumeIndices[digIndex],
                              digitInteresting->GetTracks());
       }
+      if (digitIndexLocal==-1) interestingCounter--; // AdC
     }
 
 
@@ -911,11 +1157,14 @@ void AliTOFClusterFinderV1::FindClusters34(Int_t nSector,
       for (ii=0; ii<kMaxNumberOfDigitsPerVolume; ii++)
        digitsInVolumeIndices[ii] = -1;
       fTOFdigitMap->GetDigitIndex(vol, digitsInVolumeIndices);
+      digitIndexLocal=-1; // AdC
       for(Int_t digIndex=0; digIndex<kMaxNumberOfDigitsPerVolume; digIndex++) {
        if (digitsInVolumeIndices[digIndex]<0) continue;
        digitInteresting = (AliTOFdigit*)fDigits->UncheckedAt(digitsInVolumeIndices[digIndex]);
+       if (digitInteresting->GetToT()<=0) continue; // AdC
+       digitIndexLocal++; // AdC
 
-       AliDebug(1,Form(" %2i %1i %2i %1i %2i  %f %f %f %f  %5i  %5i %5i %5i",
+       AliDebug(1,Form(" %2d %1d %2d %1d %2d  %d %d %d %d  %5d  %5d %5d %5d",
                        vol[0], vol[1], vol[2] ,vol[4], vol[3],
                        digitInteresting->GetTdc(), digitInteresting->GetAdc(),
                        digitInteresting->GetToT(), digitInteresting->GetToT()*digitInteresting->GetToT(),
@@ -923,13 +1172,14 @@ void AliTOFClusterFinderV1::FindClusters34(Int_t nSector,
                        digitInteresting->GetTrack(0), digitInteresting->GetTrack(1), digitInteresting->GetTrack(2)));
 
 
-       selectedDigit[interestingCounter][digIndex] = new
+       selectedDigit[interestingCounter][digitIndexLocal] = new // AdC
          AliTOFselectedDigit(vol, digitInteresting->GetTdc(),
                              digitInteresting->GetAdc(), digitInteresting->GetToT(),
                              digitInteresting->GetToT()*digitInteresting->GetToT(),
                              digitsInVolumeIndices[digIndex],
                              digitInteresting->GetTracks());
       }
+      if (digitIndexLocal==-1) interestingCounter--; // AdC
     }
 
 
@@ -940,11 +1190,14 @@ void AliTOFClusterFinderV1::FindClusters34(Int_t nSector,
       for (ii=0; ii<kMaxNumberOfDigitsPerVolume; ii++)
        digitsInVolumeIndices[ii] = -1;
       fTOFdigitMap->GetDigitIndex(vol, digitsInVolumeIndices);
+      digitIndexLocal=-1; // AdC
       for(Int_t digIndex=0; digIndex<kMaxNumberOfDigitsPerVolume; digIndex++) {
        if (digitsInVolumeIndices[digIndex]<0) continue;
        digitInteresting = (AliTOFdigit*)fDigits->UncheckedAt(digitsInVolumeIndices[digIndex]);
+       if (digitInteresting->GetToT()<=0) continue; // AdC
+       digitIndexLocal++; // AdC
 
-       AliDebug(1,Form(" %2i %1i %2i %1i %2i  %f %f %f %f  %5i  %5i %5i %5i",
+       AliDebug(1,Form(" %2d %1d %2d %1d %2d  %d %d %d %d  %5d  %5d %5d %5d",
                        vol[0], vol[1], vol[2] ,vol[4], vol[3],
                        digitInteresting->GetTdc(), digitInteresting->GetAdc(),
                        digitInteresting->GetToT(), digitInteresting->GetToT()*digitInteresting->GetToT(),
@@ -952,13 +1205,14 @@ void AliTOFClusterFinderV1::FindClusters34(Int_t nSector,
                        digitInteresting->GetTrack(0), digitInteresting->GetTrack(1), digitInteresting->GetTrack(2)));
 
 
-       selectedDigit[interestingCounter][digIndex] = new
+       selectedDigit[interestingCounter][digitIndexLocal] = new // AdC
          AliTOFselectedDigit(vol, digitInteresting->GetTdc(),
                              digitInteresting->GetAdc(), digitInteresting->GetToT(),
                              digitInteresting->GetToT()*digitInteresting->GetToT(),
                              digitsInVolumeIndices[digIndex],
                              digitInteresting->GetTracks());
       }
+      if (digitIndexLocal==-1) interestingCounter--; // AdC
     }
 
 
@@ -969,28 +1223,31 @@ void AliTOFClusterFinderV1::FindClusters34(Int_t nSector,
       for (ii=0; ii<kMaxNumberOfDigitsPerVolume; ii++)
        digitsInVolumeIndices[ii] = -1;
       fTOFdigitMap->GetDigitIndex(vol, digitsInVolumeIndices);
+      digitIndexLocal=-1;
       for(Int_t digIndex=0; digIndex<kMaxNumberOfDigitsPerVolume; digIndex++) {
        if (digitsInVolumeIndices[digIndex]<0) continue;
        digitInteresting = (AliTOFdigit*)fDigits->UncheckedAt(digitsInVolumeIndices[digIndex]);
+       if (digitInteresting->GetToT()<=0) continue; // AdC
+       digitIndexLocal++; // AdC
 
-       AliDebug(1,Form(" %2i %1i %2i %1i %2i  %f %f %f %f  %5i  %5i %5i %5i",
+       AliDebug(1,Form(" %2d %1d %2d %1d %2d  %d %d %d %d  %5d  %5d %5d %5d",
                        vol[0], vol[1], vol[2] ,vol[4], vol[3],
                        digitInteresting->GetTdc(), digitInteresting->GetAdc(),
                        digitInteresting->GetToT(), digitInteresting->GetToT()*digitInteresting->GetToT(),
                        digitsInVolumeIndices[digIndex],
                        digitInteresting->GetTrack(0), digitInteresting->GetTrack(1), digitInteresting->GetTrack(2)));
 
-
-       selectedDigit[interestingCounter][digIndex] = new
+       selectedDigit[interestingCounter][digitIndexLocal] = new // AdC
          AliTOFselectedDigit(vol, digitInteresting->GetTdc(),
                              digitInteresting->GetAdc(), digitInteresting->GetToT(),
                              digitInteresting->GetToT()*digitInteresting->GetToT(),
                              digitsInVolumeIndices[digIndex],
                              digitInteresting->GetTracks());
       }
+      if (digitIndexLocal==-1) interestingCounter--; // AdC
     }
 
-    AliDebug(1,Form(" e adesso %1i", interestingCounter+1));
+    AliDebug(1,Form(" e adesso %1d", interestingCounter+1));
 
     for (Int_t adesso1=0; adesso1<interestingCounter+1; adesso1++) {
       for (Int_t firstIndex=0; firstIndex<kMaxNumberOfDigitsPerVolume; firstIndex++) {
@@ -1016,11 +1273,11 @@ void AliTOFClusterFinderV1::FindClusters34(Int_t nSector,
                interestingADC[0] = selectedDigit[adesso1][firstIndex]->GetADC();
                interestingWeight[0] = selectedDigit[adesso1][firstIndex]->GetWeight();
                Int_t vol1[5]; for(jj=0; jj<5; jj++) vol1[jj] = selectedDigit[adesso1][firstIndex]->GetDetectorIndex(jj);
-               AliDebug(1,Form(" %2i %1i %2i %1i %2i", vol1[0], vol1[1], vol1[2], vol1[4], vol1[3]));
+               AliDebug(1,Form(" %2d %1d %2d %1d %2d", vol1[0], vol1[1], vol1[2], vol1[4], vol1[3]));
                Int_t volDum = vol1[3];
                vol1[3] = vol1[4];
                vol1[4] = volDum;
-               tofGeometry->GetPosPar(vol1,pos);
+               fTOFGeometry->GetPosPar(vol1,pos);
                interestingX[0] = pos[0];
                interestingY[0] = pos[1];
                interestingZ[0] = pos[2];
@@ -1030,11 +1287,11 @@ void AliTOFClusterFinderV1::FindClusters34(Int_t nSector,
                interestingADC[1] = selectedDigit[adesso2][secondIndex]->GetADC();
                interestingWeight[1] = selectedDigit[adesso2][secondIndex]->GetWeight();
                Int_t vol2[5]; for(jj=0; jj<5; jj++) vol2[jj] = selectedDigit[adesso2][secondIndex]->GetDetectorIndex(jj);
-               AliDebug(1,Form(" %2i %1i %2i %1i %2i", vol2[0], vol2[1], vol2[2], vol2[4], vol2[3]));
+               AliDebug(1,Form(" %2d %1d %2d %1d %2d", vol2[0], vol2[1], vol2[2], vol2[4], vol2[3]));
                volDum = vol2[3];
                vol2[3] = vol2[4];
                vol2[4] = volDum;
-               tofGeometry->GetPosPar(vol2,pos);
+               fTOFGeometry->GetPosPar(vol2,pos);
                interestingX[1] = pos[0];
                interestingY[1] = pos[1];
                interestingZ[1] = pos[2];
@@ -1044,11 +1301,11 @@ void AliTOFClusterFinderV1::FindClusters34(Int_t nSector,
                interestingADC[2] = selectedDigit[adesso3][thirdIndex]->GetADC();
                interestingWeight[2] = selectedDigit[adesso3][thirdIndex]->GetWeight();
                Int_t vol3[5]; for(jj=0; jj<5; jj++) vol3[jj] = selectedDigit[adesso3][thirdIndex]->GetDetectorIndex(jj);
-               AliDebug(1,Form(" %2i %1i %2i %1i %2i", vol3[0], vol3[1], vol3[2], vol3[4], vol3[3]));
+               AliDebug(1,Form(" %2d %1d %2d %1d %2d", vol3[0], vol3[1], vol3[2], vol3[4], vol3[3]));
                volDum = vol3[3];
                vol3[3] = vol3[4];
                vol3[4] = volDum;
-               tofGeometry->GetPosPar(vol3,pos);
+               fTOFGeometry->GetPosPar(vol3,pos);
                interestingX[2] = pos[0];
                interestingY[2] = pos[1];
                interestingZ[2] = pos[2];
@@ -1062,9 +1319,10 @@ void AliTOFClusterFinderV1::FindClusters34(Int_t nSector,
 
                for (jj=0; jj<5; jj++) det[jj] = -1;
                for (jj=0; jj<3; jj++) posF[jj] = posClus[jj];
-               tofGeometry->GetDetID(posF, det);
+               fTOFGeometry->GetDetID(posF, det);
 
-               volIdClus = GetClusterVolIndex(det);
+               volIdClus = fTOFGeometry->GetAliSensVolIndex(det[0],det[1],det[2]);
+               //volIdClus = GetClusterVolIndex(det);
 
                for (jj=3; jj<11; jj++) padsCluster[jj] = -1;
                padsCluster[3] = selectedDigit[adesso1][firstIndex]->GetDetectorIndex(4);
@@ -1082,8 +1340,9 @@ void AliTOFClusterFinderV1::FindClusters34(Int_t nSector,
                for (jj=0; jj<3; jj++) indDet[jj][2] = nStrip;
                for (jj=0; jj<3; jj++) indDet[jj][3] = padsCluster[2*jj+3];
                for (jj=0; jj<3; jj++) indDet[jj][4] = padsCluster[2*jj+1+3];
-               GetClusterPars(check, 3, indDet, interestingWeight, posClus, covClus);
+               GetClusterPars(/*check,*/ 3, indDet, interestingWeight, posClus, covClus);
                for (jj=0; jj<3; jj++) delete [] indDet[jj];
+               delete [] indDet;
 
                // To fill the track index array
                dummyCounter=-1;
@@ -1143,7 +1402,7 @@ void AliTOFClusterFinderV1::FindClusters34(Int_t nSector,
                                    tracks, det, parTOF, status, selectedDigit[adesso1][firstIndex]->GetIndex()); // to be updated
                InsertCluster(tofCluster);
 
-               AliDebug(2, Form("       %4i  %f %f %f  %f %f %f %f %f %f  %3i %3i %3i  %2i %1i %2i %1i %2i  %4i %3i %3i %4i %4i  %1i  %4i", 
+               AliDebug(2, Form("       %4d  %f %f %f  %f %f %f %f %f %f  %3d %3d %3d  %2d %1d %2d %1d %2d  %4d %3d %3d %4d %4d  %1d  %4d", 
                                 volIdClus, posClus[0], posClus[1], posClus[2],
                                 covClus[0], covClus[1], covClus[2], covClus[3], covClus[4], covClus[5],
                                 tracks[0], tracks[1], tracks[2],
@@ -1181,12 +1440,16 @@ void AliTOFClusterFinderV1::FindClusters34(Int_t nSector,
 
   } // loop on iPad
 
-  for (ii=0; ii<kMaxNumberOfInterestingPads; ii++)
+  for (ii=0; ii<kMaxNumberOfInterestingPads; ii++) {
     for (jj=0; jj<kMaxNumberOfDigitsPerVolume; jj++) {
-      delete selectedDigit[ii][jj];
+      delete [] selectedDigit[ii][jj];
       selectedDigit[ii][jj] = 0x0;
     }
-
+    delete [] selectedDigit[ii];
+    selectedDigit[ii] = 0x0;
+  }
+  delete [] selectedDigit;
+  selectedDigit = 0x0;
 
 }
 //_____________________________________________________________________________
@@ -1205,7 +1468,7 @@ void AliTOFClusterFinderV1::FindClusters23(Int_t nSector,
 
   const Int_t kMaxNumberOfInterestingPads = 4;
   const Int_t kMaxNumberOfTracksPerDigit = 3;
-  const Int_t kMaxNumberOfDigitsPerVolume = 3;
+  const Int_t kMaxNumberOfDigitsPerVolume = 10;
 
   Int_t ii = 0;
 
@@ -1213,7 +1476,6 @@ void AliTOFClusterFinderV1::FindClusters23(Int_t nSector,
   for (ii=0; ii<kMaxNumberOfDigitsPerVolume; ii++)
     digitsInVolumeIndices[ii] = -1;
 
-  AliTOFGeometry *tofGeometry = new AliTOFGeometry();
   Int_t vol[5] = {nSector,nPlate,nStrip,-1,-1};
 
   Float_t pos[3] = {0.,0.,0.};
@@ -1249,13 +1511,14 @@ void AliTOFClusterFinderV1::FindClusters23(Int_t nSector,
   for (jj=3; jj<11; jj++) padsCluster[jj] = -1;
 
   Int_t interestingCounter=-1;
+  Int_t digitIndexLocal = -1;
   Int_t iPad  = -1;
   Int_t iPadX = -1;
   Int_t iPadZ = -1;
 
   Bool_t check = kFALSE;
-  Int_t parTOF[5];
-  for (jj=0; jj<5; jj++) parTOF[jj] = 0;
+  Int_t parTOF[7];
+  for (jj=0; jj<7; jj++) parTOF[jj] = 0;
   Double_t posClus[3];
   for (jj=0; jj<3; jj++) posClus[jj] = 0.;
   Int_t det[5];
@@ -1267,7 +1530,7 @@ void AliTOFClusterFinderV1::FindClusters23(Int_t nSector,
   Double_t covClus[6];
   for (jj=0; jj<6; jj++) covClus[jj] = 0.;
   Int_t tracks[kMaxNumberOfTracksPerDigit];
-  for (jj=0; jj<3; jj++) tracks[jj] = -1;
+  for (jj=0; jj<kMaxNumberOfTracksPerDigit; jj++) tracks[jj] = -1;
   Int_t dummyCounter=-1;
   Bool_t alreadyStored = kFALSE;
 
@@ -1285,7 +1548,7 @@ void AliTOFClusterFinderV1::FindClusters23(Int_t nSector,
     iPadZ = iPad%AliTOFGeometry::NpadZ(); //iPad%2;
     iPadX = iPad/AliTOFGeometry::NpadZ(); //iPad/2;
 
-    AliDebug(3, Form("%2i %1i %2i\n", iPad, iPadZ, iPadX));
+    AliDebug(3, Form("%2d %1d %2d\n", iPad, iPadZ, iPadX));
 
 
 
@@ -1326,25 +1589,28 @@ void AliTOFClusterFinderV1::FindClusters23(Int_t nSector,
       for (ii=0; ii<kMaxNumberOfDigitsPerVolume; ii++)
        digitsInVolumeIndices[ii] = -1;
       fTOFdigitMap->GetDigitIndex(vol, digitsInVolumeIndices);
+      digitIndexLocal=-1;
       for(Int_t digIndex=0; digIndex<kMaxNumberOfDigitsPerVolume; digIndex++) {
        if (digitsInVolumeIndices[digIndex]<0) continue;
        digitInteresting = (AliTOFdigit*)fDigits->UncheckedAt(digitsInVolumeIndices[digIndex]);
+       if (digitInteresting->GetToT()<=0) continue; // AdC
+       digitIndexLocal++; // AdC
 
-       AliDebug(1,Form(" %2i %1i %2i %1i %2i  %f %f %f %f  %5i  %5i %5i %5i",
+       AliDebug(1,Form(" %2d %1d %2d %1d %2d  %d %d %d %d  %5d  %5d %5d %5d",
                        vol[0], vol[1], vol[2] ,vol[4], vol[3],
                        digitInteresting->GetTdc(), digitInteresting->GetAdc(),
                        digitInteresting->GetToT(), digitInteresting->GetToT()*digitInteresting->GetToT(),
                        digitsInVolumeIndices[digIndex],
                        digitInteresting->GetTrack(0), digitInteresting->GetTrack(1), digitInteresting->GetTrack(2)));
 
-
-       selectedDigit[interestingCounter][digIndex] = new
+       selectedDigit[interestingCounter][digitIndexLocal] = new // AdC
          AliTOFselectedDigit(vol, digitInteresting->GetTdc(),
                              digitInteresting->GetAdc(), digitInteresting->GetToT(),
                              digitInteresting->GetToT()*digitInteresting->GetToT(),
                              digitsInVolumeIndices[digIndex],
                              digitInteresting->GetTracks());
       }
+      if (digitIndexLocal==-1) interestingCounter--; // AdC
     }
 
 
@@ -1355,25 +1621,28 @@ void AliTOFClusterFinderV1::FindClusters23(Int_t nSector,
       for (ii=0; ii<kMaxNumberOfDigitsPerVolume; ii++)
        digitsInVolumeIndices[ii] = -1;
       fTOFdigitMap->GetDigitIndex(vol, digitsInVolumeIndices);
+      digitIndexLocal=-1; // AdC
       for(Int_t digIndex=0; digIndex<kMaxNumberOfDigitsPerVolume; digIndex++) {
        if (digitsInVolumeIndices[digIndex]<0) continue;
        digitInteresting = (AliTOFdigit*)fDigits->UncheckedAt(digitsInVolumeIndices[digIndex]);
+       if (digitInteresting->GetToT()<=0) continue; // AdC
+       digitIndexLocal++; // AdC
 
-       AliDebug(1,Form(" %2i %1i %2i %1i %2i  %f %f %f %f  %5i  %5i %5i %5i",
+       AliDebug(1,Form(" %2d %1d %2d %1d %2d  %d %d %d %d  %5d  %5d %5d %5d",
                        vol[0], vol[1], vol[2] ,vol[4], vol[3],
                        digitInteresting->GetTdc(), digitInteresting->GetAdc(),
                        digitInteresting->GetToT(), digitInteresting->GetToT()*digitInteresting->GetToT(),
                        digitsInVolumeIndices[digIndex],
                        digitInteresting->GetTrack(0), digitInteresting->GetTrack(1), digitInteresting->GetTrack(2)));
 
-
-       selectedDigit[interestingCounter][digIndex] = new
+       selectedDigit[interestingCounter][digitIndexLocal] = new // AdC
          AliTOFselectedDigit(vol, digitInteresting->GetTdc(),
                              digitInteresting->GetAdc(), digitInteresting->GetToT(),
                              digitInteresting->GetToT()*digitInteresting->GetToT(),
                              digitsInVolumeIndices[digIndex],
                              digitInteresting->GetTracks());
       }
+      if (digitIndexLocal==-1) interestingCounter--; // AdC
     }
 
 
@@ -1384,25 +1653,28 @@ void AliTOFClusterFinderV1::FindClusters23(Int_t nSector,
       for (ii=0; ii<kMaxNumberOfDigitsPerVolume; ii++)
        digitsInVolumeIndices[ii] = -1;
       fTOFdigitMap->GetDigitIndex(vol, digitsInVolumeIndices);
+      digitIndexLocal=-1; // AdC
       for(Int_t digIndex=0; digIndex<kMaxNumberOfDigitsPerVolume; digIndex++) {
        if (digitsInVolumeIndices[digIndex]<0) continue;
        digitInteresting = (AliTOFdigit*)fDigits->UncheckedAt(digitsInVolumeIndices[digIndex]);
+       if (digitInteresting->GetToT()<=0) continue; // AdC
+       digitIndexLocal++; // AdC
 
-       AliDebug(1,Form(" %2i %1i %2i %1i %2i  %f %f %f %f  %5i  %5i %5i %5i",
+       AliDebug(1,Form(" %2d %1d %2d %1d %2d  %d %d %d %d  %5d  %5d %5d %5d",
                        vol[0], vol[1], vol[2] ,vol[4], vol[3],
                        digitInteresting->GetTdc(), digitInteresting->GetAdc(),
                        digitInteresting->GetToT(), digitInteresting->GetToT()*digitInteresting->GetToT(),
                        digitsInVolumeIndices[digIndex],
                        digitInteresting->GetTrack(0), digitInteresting->GetTrack(1), digitInteresting->GetTrack(2)));
 
-
-       selectedDigit[interestingCounter][digIndex] = new
+       selectedDigit[interestingCounter][digitIndexLocal] = new // AdC
          AliTOFselectedDigit(vol, digitInteresting->GetTdc(),
                              digitInteresting->GetAdc(), digitInteresting->GetToT(),
                              digitInteresting->GetToT()*digitInteresting->GetToT(),
                              digitsInVolumeIndices[digIndex],
                              digitInteresting->GetTracks());
       }
+      if (digitIndexLocal==-1) interestingCounter--; // AdC
     }
 
 
@@ -1413,28 +1685,31 @@ void AliTOFClusterFinderV1::FindClusters23(Int_t nSector,
       for (ii=0; ii<kMaxNumberOfDigitsPerVolume; ii++)
        digitsInVolumeIndices[ii] = -1;
       fTOFdigitMap->GetDigitIndex(vol, digitsInVolumeIndices);
+      digitIndexLocal=-1; // AdC
       for(Int_t digIndex=0; digIndex<kMaxNumberOfDigitsPerVolume; digIndex++) {
        if (digitsInVolumeIndices[digIndex]<0) continue;
        digitInteresting = (AliTOFdigit*)fDigits->UncheckedAt(digitsInVolumeIndices[digIndex]);
+       if (digitInteresting->GetToT()<=0) continue; // AdC
+       digitIndexLocal++; // AdC
 
-       AliDebug(1,Form(" %2i %1i %2i %1i %2i  %f %f %f %f  %5i  %5i %5i %5i",
+       AliDebug(1,Form(" %2d %1d %2d %1d %2d  %d %d %d %d  %5d  %5d %5d %5d",
                        vol[0], vol[1], vol[2] ,vol[4], vol[3],
                        digitInteresting->GetTdc(), digitInteresting->GetAdc(),
                        digitInteresting->GetToT(), digitInteresting->GetToT()*digitInteresting->GetToT(),
                        digitsInVolumeIndices[digIndex],
                        digitInteresting->GetTrack(0), digitInteresting->GetTrack(1), digitInteresting->GetTrack(2)));
 
-
-       selectedDigit[interestingCounter][digIndex] = new
+       selectedDigit[interestingCounter][digitIndexLocal] = new // AdC
          AliTOFselectedDigit(vol, digitInteresting->GetTdc(),
                              digitInteresting->GetAdc(), digitInteresting->GetToT(),
                              digitInteresting->GetToT()*digitInteresting->GetToT(),
                              digitsInVolumeIndices[digIndex],
                              digitInteresting->GetTracks());
       }
+      if (digitIndexLocal==-1) interestingCounter--; // AdC
     }
 
-    AliDebug(1,Form(" e adesso %1i", interestingCounter+1));
+    AliDebug(1,Form(" e adesso %1d", interestingCounter+1));
 
     for (Int_t adesso1=0; adesso1<interestingCounter+1; adesso1++) {
       for (Int_t firstIndex=0; firstIndex<kMaxNumberOfDigitsPerVolume; firstIndex++) {
@@ -1451,11 +1726,11 @@ void AliTOFClusterFinderV1::FindClusters23(Int_t nSector,
            interestingADC[0] = selectedDigit[adesso1][firstIndex]->GetADC();
            interestingWeight[0] = selectedDigit[adesso1][firstIndex]->GetWeight();
            Int_t vol1[5]; for(jj=0; jj<5; jj++) vol1[jj] = selectedDigit[adesso1][firstIndex]->GetDetectorIndex(jj);
-           AliDebug(1,Form(" %2i %1i %2i %1i %2i", vol1[0], vol1[1], vol1[2], vol1[4], vol1[3]));
+           AliDebug(1,Form(" %2d %1d %2d %1d %2d", vol1[0], vol1[1], vol1[2], vol1[4], vol1[3]));
            Int_t volDum = vol1[3];
            vol1[3] = vol1[4];
            vol1[4] = volDum;
-           tofGeometry->GetPosPar(vol1,pos);
+           fTOFGeometry->GetPosPar(vol1,pos);
            interestingX[0] = pos[0];
            interestingY[0] = pos[1];
            interestingZ[0] = pos[2];
@@ -1465,11 +1740,11 @@ void AliTOFClusterFinderV1::FindClusters23(Int_t nSector,
            interestingADC[1] = selectedDigit[adesso2][secondIndex]->GetADC();
            interestingWeight[1] = selectedDigit[adesso2][secondIndex]->GetWeight();
            Int_t vol2[5]; for(jj=0; jj<5; jj++) vol2[jj] = selectedDigit[adesso2][secondIndex]->GetDetectorIndex(jj);
-           AliDebug(1,Form(" %2i %1i %2i %1i %2i", vol2[0], vol2[1], vol2[2], vol2[4], vol2[3]));
+           AliDebug(1,Form(" %2d %1d %2d %1d %2d", vol2[0], vol2[1], vol2[2], vol2[4], vol2[3]));
            volDum = vol2[3];
            vol2[3] = vol2[4];
            vol2[4] = volDum;
-           tofGeometry->GetPosPar(vol2,pos);
+           fTOFGeometry->GetPosPar(vol2,pos);
            interestingX[1] = pos[0];
            interestingY[1] = pos[1];
            interestingZ[1] = pos[2];
@@ -1481,9 +1756,10 @@ void AliTOFClusterFinderV1::FindClusters23(Int_t nSector,
 
            for (jj=0; jj<5; jj++) det[jj] = -1;
            for (jj=0; jj<3; jj++) posF[jj] = posClus[jj];
-           tofGeometry->GetDetID(posF, det);
+           fTOFGeometry->GetDetID(posF, det);
 
-           volIdClus = GetClusterVolIndex(det);
+           volIdClus = fTOFGeometry->GetAliSensVolIndex(det[0],det[1],det[2]);
+           //volIdClus = GetClusterVolIndex(det);
 
            for (jj=3; jj<11; jj++) padsCluster[jj] = -1;
            padsCluster[3] = selectedDigit[adesso1][firstIndex]->GetDetectorIndex(4);
@@ -1499,8 +1775,9 @@ void AliTOFClusterFinderV1::FindClusters23(Int_t nSector,
            for (jj=0; jj<2; jj++) indDet[jj][2] = nStrip;
            for (jj=0; jj<2; jj++) indDet[jj][3] = padsCluster[2*jj+3];
            for (jj=0; jj<2; jj++) indDet[jj][4] = padsCluster[2*jj+1+3];
-           GetClusterPars(check, 2, indDet, interestingWeight, posClus, covClus);
+           GetClusterPars(/*check,*/ 2, indDet, interestingWeight, posClus, covClus);
            for (jj=0; jj<2; jj++) delete [] indDet[jj];
+           delete [] indDet;
 
            // To fill the track index array
            dummyCounter=-1;
@@ -1540,7 +1817,7 @@ void AliTOFClusterFinderV1::FindClusters23(Int_t nSector,
                                tracks, det, parTOF, status, selectedDigit[adesso1][firstIndex]->GetIndex()); // to be updated
            InsertCluster(tofCluster);
 
-           AliDebug(2, Form("       %4i  %f %f %f  %f %f %f %f %f %f  %3i %3i %3i  %2i %1i %2i %1i %2i  %4i %3i %3i %4i %4i  %1i  %4i", 
+           AliDebug(2, Form("       %4d  %f %f %f  %f %f %f %f %f %f  %3d %3d %3d  %2d %1d %2d %1d %2d  %4d %3d %3d %4d %4d  %1d  %4d", 
                             volIdClus, posClus[0], posClus[1], posClus[2],
                             covClus[0], covClus[1], covClus[2], covClus[3], covClus[4], covClus[5],
                             tracks[0], tracks[1], tracks[2],
@@ -1570,12 +1847,16 @@ void AliTOFClusterFinderV1::FindClusters23(Int_t nSector,
 
   } // loop on iPad
 
-  for (ii=0; ii<kMaxNumberOfInterestingPads; ii++)
+  for (ii=0; ii<kMaxNumberOfInterestingPads; ii++) {
     for (jj=0; jj<kMaxNumberOfDigitsPerVolume; jj++) {
-      delete selectedDigit[ii][jj];
+      delete [] selectedDigit[ii][jj];
       selectedDigit[ii][jj] = 0x0;
     }
-
+    delete [] selectedDigit[ii];
+    selectedDigit[ii] = 0x0;
+  }
+  delete [] selectedDigit;
+  selectedDigit = 0x0;
 
 }
 //_____________________________________________________________________________
@@ -1594,7 +1875,7 @@ void AliTOFClusterFinderV1::FindClusters24(Int_t nSector,
 
   const Int_t kMaxNumberOfInterestingPads = 4;
   const Int_t kMaxNumberOfTracksPerDigit = 3;
-  const Int_t kMaxNumberOfDigitsPerVolume = 3;
+  const Int_t kMaxNumberOfDigitsPerVolume = 10;
 
   Int_t ii = 0;
 
@@ -1602,7 +1883,6 @@ void AliTOFClusterFinderV1::FindClusters24(Int_t nSector,
   for (ii=0; ii<kMaxNumberOfDigitsPerVolume; ii++)
     digitsInVolumeIndices[ii] = -1;
 
-  AliTOFGeometry *tofGeometry = new AliTOFGeometry();
   Int_t vol[5] = {nSector,nPlate,nStrip,-1,-1};
 
   Float_t pos[3] = {0.,0.,0.};
@@ -1638,13 +1918,14 @@ void AliTOFClusterFinderV1::FindClusters24(Int_t nSector,
   for (jj=3; jj<11; jj++) padsCluster[jj] = -1;
 
   Int_t interestingCounter=-1;
+  Int_t digitIndexLocal = -1;
   Int_t iPad  = -1;
   Int_t iPadX = -1;
   Int_t iPadZ = -1;
 
   Bool_t check = kFALSE;
-  Int_t parTOF[5];
-  for (jj=0; jj<5; jj++) parTOF[jj] = 0;
+  Int_t parTOF[7];
+  for (jj=0; jj<7; jj++) parTOF[jj] = 0;
   Double_t posClus[3];
   for (jj=0; jj<3; jj++) posClus[jj] = 0.;
   Int_t det[5];
@@ -1656,7 +1937,7 @@ void AliTOFClusterFinderV1::FindClusters24(Int_t nSector,
   Double_t covClus[6];
   for (jj=0; jj<6; jj++) covClus[jj] = 0.;
   Int_t tracks[kMaxNumberOfTracksPerDigit];
-  for (jj=0; jj<3; jj++) tracks[jj] = -1;
+  for (jj=0; jj<kMaxNumberOfTracksPerDigit; jj++) tracks[jj] = -1;
   Int_t dummyCounter=-1;
   Bool_t alreadyStored = kFALSE;
 
@@ -1674,7 +1955,7 @@ void AliTOFClusterFinderV1::FindClusters24(Int_t nSector,
     iPadZ = iPad%AliTOFGeometry::NpadZ(); //iPad%2;
     iPadX = iPad/AliTOFGeometry::NpadZ(); //iPad/2;
 
-    AliDebug(3, Form("%2i %1i %2i\n", iPad, iPadZ, iPadX));
+    AliDebug(3, Form("%2d %1d %2d\n", iPad, iPadZ, iPadX));
 
 
 
@@ -1715,25 +1996,28 @@ void AliTOFClusterFinderV1::FindClusters24(Int_t nSector,
       for (ii=0; ii<kMaxNumberOfDigitsPerVolume; ii++)
        digitsInVolumeIndices[ii] = -1;
       fTOFdigitMap->GetDigitIndex(vol, digitsInVolumeIndices);
+      digitIndexLocal=-1; // AdC
       for(Int_t digIndex=0; digIndex<kMaxNumberOfDigitsPerVolume; digIndex++) {
        if (digitsInVolumeIndices[digIndex]<0) continue;
        digitInteresting = (AliTOFdigit*)fDigits->UncheckedAt(digitsInVolumeIndices[digIndex]);
+       if (digitInteresting->GetToT()<=0) continue; // AdC
+       digitIndexLocal++; // AdC
 
-       AliDebug(1,Form(" %2i %1i %2i %1i %2i  %f %f %f %f  %5i  %5i %5i %5i",
+       AliDebug(1,Form(" %2d %1d %2d %1d %2d  %d %d %d %d  %5d  %5d %5d %5d",
                        vol[0], vol[1], vol[2] ,vol[4], vol[3],
                        digitInteresting->GetTdc(), digitInteresting->GetAdc(),
                        digitInteresting->GetToT(), digitInteresting->GetToT()*digitInteresting->GetToT(),
                        digitsInVolumeIndices[digIndex],
                        digitInteresting->GetTrack(0), digitInteresting->GetTrack(1), digitInteresting->GetTrack(2)));
 
-
-       selectedDigit[interestingCounter][digIndex] = new
+       selectedDigit[interestingCounter][digitIndexLocal] = new // AdC
          AliTOFselectedDigit(vol, digitInteresting->GetTdc(),
                              digitInteresting->GetAdc(), digitInteresting->GetToT(),
                              digitInteresting->GetToT()*digitInteresting->GetToT(),
                              digitsInVolumeIndices[digIndex],
                              digitInteresting->GetTracks());
       }
+      if (digitIndexLocal==-1) interestingCounter--; // AdC
     }
 
 
@@ -1744,25 +2028,28 @@ void AliTOFClusterFinderV1::FindClusters24(Int_t nSector,
       for (ii=0; ii<kMaxNumberOfDigitsPerVolume; ii++)
        digitsInVolumeIndices[ii] = -1;
       fTOFdigitMap->GetDigitIndex(vol, digitsInVolumeIndices);
+      digitIndexLocal=-1; // AdC
       for(Int_t digIndex=0; digIndex<kMaxNumberOfDigitsPerVolume; digIndex++) {
        if (digitsInVolumeIndices[digIndex]<0) continue;
        digitInteresting = (AliTOFdigit*)fDigits->UncheckedAt(digitsInVolumeIndices[digIndex]);
+       if (digitInteresting->GetToT()<=0) continue; // AdC
+       digitIndexLocal++; // AdC
 
-       AliDebug(1,Form(" %2i %1i %2i %1i %2i  %f %f %f %f  %5i  %5i %5i %5i",
+       AliDebug(1,Form(" %2d %1d %2d %1d %2d  %d %d %d %d  %5d  %5d %5d %5d",
                        vol[0], vol[1], vol[2] ,vol[4], vol[3],
                        digitInteresting->GetTdc(), digitInteresting->GetAdc(),
                        digitInteresting->GetToT(), digitInteresting->GetToT()*digitInteresting->GetToT(),
                        digitsInVolumeIndices[digIndex],
                        digitInteresting->GetTrack(0), digitInteresting->GetTrack(1), digitInteresting->GetTrack(2)));
 
-
-       selectedDigit[interestingCounter][digIndex] = new
+       selectedDigit[interestingCounter][digitIndexLocal] = new // AdC
          AliTOFselectedDigit(vol, digitInteresting->GetTdc(),
                              digitInteresting->GetAdc(), digitInteresting->GetToT(),
                              digitInteresting->GetToT()*digitInteresting->GetToT(),
                              digitsInVolumeIndices[digIndex],
                              digitInteresting->GetTracks());
       }
+      if (digitIndexLocal==-1) interestingCounter--; // AdC
     }
 
 
@@ -1773,25 +2060,28 @@ void AliTOFClusterFinderV1::FindClusters24(Int_t nSector,
       for (ii=0; ii<kMaxNumberOfDigitsPerVolume; ii++)
        digitsInVolumeIndices[ii] = -1;
       fTOFdigitMap->GetDigitIndex(vol, digitsInVolumeIndices);
+      digitIndexLocal=-1; // AdC
       for(Int_t digIndex=0; digIndex<kMaxNumberOfDigitsPerVolume; digIndex++) {
        if (digitsInVolumeIndices[digIndex]<0) continue;
        digitInteresting = (AliTOFdigit*)fDigits->UncheckedAt(digitsInVolumeIndices[digIndex]);
+       if (digitInteresting->GetToT()<=0) continue; // AdC
+       digitIndexLocal++; // AdC
 
-       AliDebug(1,Form(" %2i %1i %2i %1i %2i  %f %f %f %f  %5i  %5i %5i %5i",
+       AliDebug(1,Form(" %2d %1d %2d %1d %2d  %d %d %d %d  %5d  %5d %5d %5d",
                        vol[0], vol[1], vol[2] ,vol[4], vol[3],
                        digitInteresting->GetTdc(), digitInteresting->GetAdc(),
                        digitInteresting->GetToT(), digitInteresting->GetToT()*digitInteresting->GetToT(),
                        digitsInVolumeIndices[digIndex],
                        digitInteresting->GetTrack(0), digitInteresting->GetTrack(1), digitInteresting->GetTrack(2)));
 
-
-       selectedDigit[interestingCounter][digIndex] = new
+       selectedDigit[interestingCounter][digitIndexLocal] = new // AdC
          AliTOFselectedDigit(vol, digitInteresting->GetTdc(),
                              digitInteresting->GetAdc(), digitInteresting->GetToT(),
                              digitInteresting->GetToT()*digitInteresting->GetToT(),
                              digitsInVolumeIndices[digIndex],
                              digitInteresting->GetTracks());
       }
+      if (digitIndexLocal==-1) interestingCounter--; // AdC
     }
 
 
@@ -1802,28 +2092,31 @@ void AliTOFClusterFinderV1::FindClusters24(Int_t nSector,
       for (ii=0; ii<kMaxNumberOfDigitsPerVolume; ii++)
        digitsInVolumeIndices[ii] = -1;
       fTOFdigitMap->GetDigitIndex(vol, digitsInVolumeIndices);
+      digitIndexLocal=-1; // AdC
       for(Int_t digIndex=0; digIndex<kMaxNumberOfDigitsPerVolume; digIndex++) {
        if (digitsInVolumeIndices[digIndex]<0) continue;
        digitInteresting = (AliTOFdigit*)fDigits->UncheckedAt(digitsInVolumeIndices[digIndex]);
+       if (digitInteresting->GetToT()<=0) continue; // AdC
+       digitIndexLocal++; // AdC
 
-       AliDebug(1,Form(" %2i %1i %2i %1i %2i  %f %f %f %f  %5i  %5i %5i %5i",
+       AliDebug(1,Form(" %2d %1d %2d %1d %2d  %d %d %d %d  %5d  %5d %5d %5d",
                        vol[0], vol[1], vol[2] ,vol[4], vol[3],
                        digitInteresting->GetTdc(), digitInteresting->GetAdc(),
                        digitInteresting->GetToT(), digitInteresting->GetToT()*digitInteresting->GetToT(),
                        digitsInVolumeIndices[digIndex],
                        digitInteresting->GetTrack(0), digitInteresting->GetTrack(1), digitInteresting->GetTrack(2)));
 
-
-       selectedDigit[interestingCounter][digIndex] = new
+       selectedDigit[interestingCounter][digitIndexLocal] = new // AdC
          AliTOFselectedDigit(vol, digitInteresting->GetTdc(),
                              digitInteresting->GetAdc(), digitInteresting->GetToT(),
                              digitInteresting->GetToT()*digitInteresting->GetToT(),
                              digitsInVolumeIndices[digIndex],
                              digitInteresting->GetTracks());
       }
+      if (digitIndexLocal==-1) interestingCounter--; // AdC
     }
 
-    AliDebug(1,Form(" e adesso %1i", interestingCounter+1));
+    AliDebug(1,Form(" e adesso %1d", interestingCounter+1));
 
     for (Int_t adesso1=0; adesso1<interestingCounter+1; adesso1++) {
       for (Int_t firstIndex=0; firstIndex<kMaxNumberOfDigitsPerVolume; firstIndex++) {
@@ -1840,11 +2133,11 @@ void AliTOFClusterFinderV1::FindClusters24(Int_t nSector,
            interestingADC[0] = selectedDigit[adesso1][firstIndex]->GetADC();
            interestingWeight[0] = selectedDigit[adesso1][firstIndex]->GetWeight();
            Int_t vol1[5]; for(jj=0; jj<5; jj++) vol1[jj] = selectedDigit[adesso1][firstIndex]->GetDetectorIndex(jj);
-           AliDebug(1,Form(" %2i %1i %2i %1i %2i", vol1[0], vol1[1], vol1[2], vol1[4], vol1[3]));
+           AliDebug(1,Form(" %2d %1d %2d %1d %2d", vol1[0], vol1[1], vol1[2], vol1[4], vol1[3]));
            Int_t volDum = vol1[3];
            vol1[3] = vol1[4];
            vol1[4] = volDum;
-           tofGeometry->GetPosPar(vol1,pos);
+           fTOFGeometry->GetPosPar(vol1,pos);
            interestingX[0] = pos[0];
            interestingY[0] = pos[1];
            interestingZ[0] = pos[2];
@@ -1854,11 +2147,11 @@ void AliTOFClusterFinderV1::FindClusters24(Int_t nSector,
            interestingADC[1] = selectedDigit[adesso2][secondIndex]->GetADC();
            interestingWeight[1] = selectedDigit[adesso2][secondIndex]->GetWeight();
            Int_t vol2[5]; for(jj=0; jj<5; jj++) vol2[jj] = selectedDigit[adesso2][secondIndex]->GetDetectorIndex(jj);
-           AliDebug(1,Form(" %2i %1i %2i %1i %2i", vol2[0], vol2[1], vol2[2], vol2[4], vol2[3]));
+           AliDebug(1,Form(" %2d %1d %2d %1d %2d", vol2[0], vol2[1], vol2[2], vol2[4], vol2[3]));
            volDum = vol2[3];
            vol2[3] = vol2[4];
            vol2[4] = volDum;
-           tofGeometry->GetPosPar(vol2,pos);
+           fTOFGeometry->GetPosPar(vol2,pos);
            interestingX[1] = pos[0];
            interestingY[1] = pos[1];
            interestingZ[1] = pos[2];
@@ -1871,9 +2164,10 @@ void AliTOFClusterFinderV1::FindClusters24(Int_t nSector,
 
            for (jj=0; jj<5; jj++) det[jj] = -1;
            for (jj=0; jj<3; jj++) posF[jj] = posClus[jj];
-           tofGeometry->GetDetID(posF, det);
+           fTOFGeometry->GetDetID(posF, det);
 
-           volIdClus = GetClusterVolIndex(det);
+           volIdClus = fTOFGeometry->GetAliSensVolIndex(det[0],det[1],det[2]);
+           //volIdClus = GetClusterVolIndex(det);
 
            for (jj=3; jj<11; jj++) padsCluster[jj] = -1;
            padsCluster[3] = selectedDigit[adesso1][firstIndex]->GetDetectorIndex(4);
@@ -1889,8 +2183,9 @@ void AliTOFClusterFinderV1::FindClusters24(Int_t nSector,
            for (jj=0; jj<2; jj++) indDet[jj][2] = nStrip;
            for (jj=0; jj<2; jj++) indDet[jj][3] = padsCluster[2*jj+3];
            for (jj=0; jj<2; jj++) indDet[jj][4] = padsCluster[2*jj+1+3];
-           GetClusterPars(check, 2, indDet, interestingWeight, posClus, covClus);
+           GetClusterPars(/*check,*/ 2, indDet, interestingWeight, posClus, covClus);
            for (jj=0; jj<2; jj++) delete [] indDet[jj];
+           delete [] indDet;
 
            // To fill the track index array
            dummyCounter=-1;
@@ -1930,7 +2225,7 @@ void AliTOFClusterFinderV1::FindClusters24(Int_t nSector,
                                tracks, det, parTOF, status, selectedDigit[adesso1][firstIndex]->GetIndex()); // to be updated
            InsertCluster(tofCluster);
 
-           AliDebug(2, Form("       %4i  %f %f %f  %f %f %f %f %f %f  %3i %3i %3i  %2i %1i %2i %1i %2i  %4i %3i %3i %4i %4i  %1i  %4i", 
+           AliDebug(2, Form("       %4d  %f %f %f  %f %f %f %f %f %f  %3d %3d %3d  %2d %1d %2d %1d %2d  %4d %3d %3d %4d %4d  %1d  %4d", 
                             volIdClus, posClus[0], posClus[1], posClus[2],
                             covClus[0], covClus[1], covClus[2], covClus[3], covClus[4], covClus[5],
                             tracks[0], tracks[1], tracks[2],
@@ -1960,12 +2255,16 @@ void AliTOFClusterFinderV1::FindClusters24(Int_t nSector,
 
   } // loop on iPad
 
-  for (ii=0; ii<kMaxNumberOfInterestingPads; ii++)
+  for (ii=0; ii<kMaxNumberOfInterestingPads; ii++) {
     for (jj=0; jj<kMaxNumberOfDigitsPerVolume; jj++) {
-      delete selectedDigit[ii][jj];
+      delete [] selectedDigit[ii][jj];
       selectedDigit[ii][jj] = 0x0;
     }
-
+    delete [] selectedDigit[ii];
+    selectedDigit[ii] = 0x0;
+  }
+  delete [] selectedDigit;
+  selectedDigit = 0x0;
 
 }
 //_____________________________________________________________________________
@@ -1994,7 +2293,7 @@ void AliTOFClusterFinderV1::FindClustersPerStrip(Int_t nSector,
 
   const Int_t kMaxNumberOfInterestingPads = 4;
   const Int_t kMaxNumberOfTracksPerDigit = 3;
-  const Int_t kMaxNumberOfDigitsPerVolume = 3;
+  const Int_t kMaxNumberOfDigitsPerVolume = 10;
 
   Int_t ii = 0;
 
@@ -2002,8 +2301,6 @@ void AliTOFClusterFinderV1::FindClustersPerStrip(Int_t nSector,
   for (ii=0; ii<kMaxNumberOfDigitsPerVolume; ii++)
     digitsInVolumeIndices[ii] = -1;
 
-  AliTOFGeometry *tofGeometry = new AliTOFGeometry();
-
   Int_t vol[5] = {nSector,nPlate,nStrip,-1,-1};
 
   Float_t pos[3] = {0.,0.,0.};
@@ -2039,13 +2336,14 @@ void AliTOFClusterFinderV1::FindClustersPerStrip(Int_t nSector,
   for (jj=3; jj<11; jj++) padsCluster[jj] = -1;
 
   Int_t interestingCounter=-1;
+  Int_t digitIndexLocal = -1;
   Int_t iPad  = -1;
   Int_t iPadX = -1;
   Int_t iPadZ = -1;
 
   Bool_t check = kFALSE;
-  Int_t parTOF[5];
-  for (jj=0; jj<5; jj++) parTOF[jj] = 0;
+  Int_t parTOF[7];
+  for (jj=0; jj<7; jj++) parTOF[jj] = 0;
   Double_t posClus[3];
   for (jj=0; jj<3; jj++) posClus[jj] = 0.;
   Int_t det[5];
@@ -2057,7 +2355,7 @@ void AliTOFClusterFinderV1::FindClustersPerStrip(Int_t nSector,
   Double_t covClus[6];
   for (jj=0; jj<6; jj++) covClus[jj] = 0.;
   Int_t tracks[kMaxNumberOfTracksPerDigit];
-  for (jj=0; jj<3; jj++) tracks[jj] = -1;
+  for (jj=0; jj<kMaxNumberOfTracksPerDigit; jj++) tracks[jj] = -1;
   Int_t dummyCounter=-1;
   Bool_t alreadyStored = kFALSE;
 
@@ -2077,7 +2375,7 @@ void AliTOFClusterFinderV1::FindClustersPerStrip(Int_t nSector,
     iPadZ = iPad%AliTOFGeometry::NpadZ(); //iPad%2;
     iPadX = iPad/AliTOFGeometry::NpadZ(); //iPad/2;
 
-    AliDebug(3, Form("%2i %1i %2i\n", iPad, iPadZ, iPadX));
+    AliDebug(3, Form("%2d %1d %2d\n", iPad, iPadZ, iPadX));
 
 
 
@@ -2118,25 +2416,29 @@ void AliTOFClusterFinderV1::FindClustersPerStrip(Int_t nSector,
       for (ii=0; ii<kMaxNumberOfDigitsPerVolume; ii++)
        digitsInVolumeIndices[ii] = -1;
       fTOFdigitMap->GetDigitIndex(vol, digitsInVolumeIndices);
+      digitIndexLocal=-1; // AdC
       for(Int_t digIndex=0; digIndex<kMaxNumberOfDigitsPerVolume; digIndex++) {
        if (digitsInVolumeIndices[digIndex]<0) continue;
        digitInteresting = (AliTOFdigit*)fDigits->UncheckedAt(digitsInVolumeIndices[digIndex]);
+       if (digitInteresting->GetToT()<=0) continue; // AdC
+       digitIndexLocal++; // AdC
 
-       AliDebug(1,Form(" %2i %1i %2i %1i %2i  %f %f %f %f  %5i  %5i %5i %5i",
+       AliDebug(1,Form(" %2d %1d %2d %1d %2d  %d %d %d %d  %5d  %5d %5d %5d",
                        vol[0], vol[1], vol[2] ,vol[4], vol[3],
                        digitInteresting->GetTdc(), digitInteresting->GetAdc(),
                        digitInteresting->GetToT(), digitInteresting->GetToT()*digitInteresting->GetToT(),
                        digitsInVolumeIndices[digIndex],
                        digitInteresting->GetTrack(0), digitInteresting->GetTrack(1), digitInteresting->GetTrack(2)));
+       AliDebug(1,Form("   to try   %d %d ",digIndex, interestingCounter));
 
-
-       selectedDigit[interestingCounter][digIndex] = new
+       selectedDigit[interestingCounter][digitIndexLocal] = new // AdC
          AliTOFselectedDigit(vol, digitInteresting->GetTdc(),
                              digitInteresting->GetAdc(), digitInteresting->GetToT(),
                              digitInteresting->GetToT()*digitInteresting->GetToT(),
                              digitsInVolumeIndices[digIndex],
                              digitInteresting->GetTracks());
       }
+      if (digitIndexLocal==-1) interestingCounter--; // AdC
     }
 
 
@@ -2147,25 +2449,29 @@ void AliTOFClusterFinderV1::FindClustersPerStrip(Int_t nSector,
       for (ii=0; ii<kMaxNumberOfDigitsPerVolume; ii++)
        digitsInVolumeIndices[ii] = -1;
       fTOFdigitMap->GetDigitIndex(vol, digitsInVolumeIndices);
+      digitIndexLocal=-1; // AdC
       for(Int_t digIndex=0; digIndex<kMaxNumberOfDigitsPerVolume; digIndex++) {
        if (digitsInVolumeIndices[digIndex]<0) continue;
        digitInteresting = (AliTOFdigit*)fDigits->UncheckedAt(digitsInVolumeIndices[digIndex]);
+       if (digitInteresting->GetToT()<=0) continue; // AdC
+       digitIndexLocal++; // AdC
 
-       AliDebug(1,Form(" %2i %1i %2i %1i %2i  %f %f %f %f  %5i  %5i %5i %5i",
+       AliDebug(1,Form(" %2d %1d %2d %1d %2d  %d %d %d %d  %5d  %5d %5d %5d",
                        vol[0], vol[1], vol[2] ,vol[4], vol[3],
                        digitInteresting->GetTdc(), digitInteresting->GetAdc(),
                        digitInteresting->GetToT(), digitInteresting->GetToT()*digitInteresting->GetToT(),
                        digitsInVolumeIndices[digIndex],
                        digitInteresting->GetTrack(0), digitInteresting->GetTrack(1), digitInteresting->GetTrack(2)));
+       AliDebug(1,Form("   to try   %d %d ",digIndex, interestingCounter));
 
-
-       selectedDigit[interestingCounter][digIndex] = new
+       selectedDigit[interestingCounter][digitIndexLocal] = new // AdC
          AliTOFselectedDigit(vol, digitInteresting->GetTdc(),
                              digitInteresting->GetAdc(), digitInteresting->GetToT(),
                              digitInteresting->GetToT()*digitInteresting->GetToT(),
                              digitsInVolumeIndices[digIndex],
                              digitInteresting->GetTracks());
       }
+      if (digitIndexLocal==-1) interestingCounter--; // AdC
     }
 
 
@@ -2176,25 +2482,29 @@ void AliTOFClusterFinderV1::FindClustersPerStrip(Int_t nSector,
       for (ii=0; ii<kMaxNumberOfDigitsPerVolume; ii++)
        digitsInVolumeIndices[ii] = -1;
       fTOFdigitMap->GetDigitIndex(vol, digitsInVolumeIndices);
+      digitIndexLocal=-1; // AdC
       for(Int_t digIndex=0; digIndex<kMaxNumberOfDigitsPerVolume; digIndex++) {
        if (digitsInVolumeIndices[digIndex]<0) continue;
        digitInteresting = (AliTOFdigit*)fDigits->UncheckedAt(digitsInVolumeIndices[digIndex]);
+       if (digitInteresting->GetToT()<=0) continue; // AdC
+       digitIndexLocal++; // AdC
 
-       AliDebug(1,Form(" %2i %1i %2i %1i %2i  %f %f %f %f  %5i  %5i %5i %5i",
+       AliDebug(1,Form(" %2d %1d %2d %1d %2d  %d %d %d %d  %5d  %5d %5d %5d",
                        vol[0], vol[1], vol[2] ,vol[4], vol[3],
                        digitInteresting->GetTdc(), digitInteresting->GetAdc(),
                        digitInteresting->GetToT(), digitInteresting->GetToT()*digitInteresting->GetToT(),
                        digitsInVolumeIndices[digIndex],
                        digitInteresting->GetTrack(0), digitInteresting->GetTrack(1), digitInteresting->GetTrack(2)));
+       AliDebug(1,Form("   to try   %d %d ",digIndex, interestingCounter));
 
-
-       selectedDigit[interestingCounter][digIndex] = new
+       selectedDigit[interestingCounter][digitIndexLocal] = new // AdC
          AliTOFselectedDigit(vol, digitInteresting->GetTdc(),
                              digitInteresting->GetAdc(), digitInteresting->GetToT(),
                              digitInteresting->GetToT()*digitInteresting->GetToT(),
                              digitsInVolumeIndices[digIndex],
                              digitInteresting->GetTracks());
       }
+      if (digitIndexLocal==-1) interestingCounter--; // AdC
     }
 
 
@@ -2205,44 +2515,61 @@ void AliTOFClusterFinderV1::FindClustersPerStrip(Int_t nSector,
       for (ii=0; ii<kMaxNumberOfDigitsPerVolume; ii++)
        digitsInVolumeIndices[ii] = -1;
       fTOFdigitMap->GetDigitIndex(vol, digitsInVolumeIndices);
+      digitIndexLocal=-1; // AdC
       for(Int_t digIndex=0; digIndex<kMaxNumberOfDigitsPerVolume; digIndex++) {
        if (digitsInVolumeIndices[digIndex]<0) continue;
        digitInteresting = (AliTOFdigit*)fDigits->UncheckedAt(digitsInVolumeIndices[digIndex]);
+       if (digitInteresting->GetToT()<=0) continue; // AdC
+       digitIndexLocal++; // AdC
 
-       AliDebug(1,Form(" %2i %1i %2i %1i %2i  %f %f %f %f  %5i  %5i %5i %5i",
+       AliDebug(1,Form(" %2d %1d %2d %1d %2d  %d %d %d %d  %5d  %5d %5d %5d",
                        vol[0], vol[1], vol[2] ,vol[4], vol[3],
                        digitInteresting->GetTdc(), digitInteresting->GetAdc(),
                        digitInteresting->GetToT(), digitInteresting->GetToT()*digitInteresting->GetToT(),
                        digitsInVolumeIndices[digIndex],
                        digitInteresting->GetTrack(0), digitInteresting->GetTrack(1), digitInteresting->GetTrack(2)));
+       AliDebug(1,Form("   to try   %d %d ",digIndex, interestingCounter));
 
-
-       selectedDigit[interestingCounter][digIndex] = new
+       selectedDigit[interestingCounter][digitIndexLocal] = new // AdC
          AliTOFselectedDigit(vol, digitInteresting->GetTdc(),
                              digitInteresting->GetAdc(), digitInteresting->GetToT(),
                              digitInteresting->GetToT()*digitInteresting->GetToT(),
                              digitsInVolumeIndices[digIndex],
                              digitInteresting->GetTracks());
       }
+      if (digitIndexLocal==-1) interestingCounter--; // AdC
     }
 
-    AliDebug(1,Form(" e adesso %1i", interestingCounter+1));
+    AliDebug(1,Form(" e adesso %1d", interestingCounter+1));
+
+    Int_t adesso1 = -1;
+    Int_t adesso2 = -1;
+    Int_t adesso3 = -1;
+    Int_t adesso4 = -1;
 
     switch(interestingCounter+1) {
 
     case 2:
 
-      for (Int_t adesso1=0; adesso1<interestingCounter+1; adesso1++) {
+      //for (adesso1=0; adesso1<interestingCounter+1; adesso1++) {
+      adesso1 = 0;
        for (Int_t firstIndex=0; firstIndex<kMaxNumberOfDigitsPerVolume; firstIndex++) {
          if (selectedDigit[adesso1][firstIndex]==0x0) continue;
 
-         for (Int_t adesso2=adesso1+1; adesso2<interestingCounter+1; adesso2++) {
+         //for (adesso2=adesso1+1; adesso2<interestingCounter+1; adesso2++) {
+         adesso2 = 1;
            for (Int_t secondIndex=0; secondIndex<kMaxNumberOfDigitsPerVolume; secondIndex++) {
              if (selectedDigit[adesso2][secondIndex]==0x0) continue;
 
-             if (TMath::Abs(selectedDigit[adesso1][firstIndex]->GetTDC()-selectedDigit[adesso2][secondIndex]->GetTDC())>fMaxDeltaTime) continue;
+             if (TMath::Abs(selectedDigit[adesso1][firstIndex]->GetTDC()-selectedDigit[adesso2][secondIndex]->GetTDC())>fMaxDeltaTime) {
+               AliDebug(1,Form(" selD1[%d][%d]->GetTDC()=%d selD2[%d][%d]->GetTDC()=%d -- %d ",
+                               adesso1,firstIndex,(Int_t)selectedDigit[adesso1][firstIndex]->GetTDC(),
+                               adesso2,secondIndex,(Int_t)selectedDigit[adesso2][secondIndex]->GetTDC(),
+                               fMaxDeltaTime));
+               continue;
+             }
 
-             AliDebug(1, Form(" %1i %1i (0x%x) %1i %1i (0x%x)", adesso1, firstIndex,selectedDigit[adesso1][firstIndex],
+             AliDebug(1, Form(" %1d %1d (0x%p) %1d %1d (0x%p)", adesso1, firstIndex,selectedDigit[adesso1][firstIndex],
                               adesso2, secondIndex,selectedDigit[adesso2][secondIndex]));
 
              interestingTOF[0] = selectedDigit[adesso1][firstIndex]->GetTDC();
@@ -2250,11 +2577,11 @@ void AliTOFClusterFinderV1::FindClustersPerStrip(Int_t nSector,
              interestingADC[0] = selectedDigit[adesso1][firstIndex]->GetADC();
              interestingWeight[0] = selectedDigit[adesso1][firstIndex]->GetWeight();
              Int_t vol1[5]; for(jj=0; jj<5; jj++) vol1[jj] = selectedDigit[adesso1][firstIndex]->GetDetectorIndex(jj);
-             AliDebug(1,Form(" %2i %1i %2i %1i %2i", vol1[0], vol1[1], vol1[2], vol1[4], vol1[3]));
+             AliDebug(1,Form(" %2d %1d %2d %1d %2d", vol1[0], vol1[1], vol1[2], vol1[4], vol1[3]));
              Int_t volDum = vol1[3];
              vol1[3] = vol1[4];
              vol1[4] = volDum;
-             tofGeometry->GetPosPar(vol1,pos);
+             fTOFGeometry->GetPosPar(vol1,pos);
              AliDebug(1,Form(" %f %f %f", pos[0], pos[1], pos[2]));
              interestingX[0] = pos[0];
              interestingY[0] = pos[1];
@@ -2265,11 +2592,11 @@ void AliTOFClusterFinderV1::FindClustersPerStrip(Int_t nSector,
              interestingADC[1] = selectedDigit[adesso2][secondIndex]->GetADC();
              interestingWeight[1] = selectedDigit[adesso2][secondIndex]->GetWeight();
              Int_t vol2[5]; for(jj=0; jj<5; jj++) vol2[jj] = selectedDigit[adesso2][secondIndex]->GetDetectorIndex(jj);
-             AliDebug(1,Form(" %2i %1i %2i %1i %2i", vol2[0], vol2[1], vol2[2], vol2[4], vol2[3]));
+             AliDebug(1,Form(" %2d %1d %2d %1d %2d", vol2[0], vol2[1], vol2[2], vol2[4], vol2[3]));
              volDum = vol2[3];
              vol2[3] = vol2[4];
              vol2[4] = volDum;
-             tofGeometry->GetPosPar(vol2,pos);
+             fTOFGeometry->GetPosPar(vol2,pos);
              AliDebug(1,Form(" %f %f %f", pos[0], pos[1], pos[2]));
              interestingX[1] = pos[0];
              interestingY[1] = pos[1];
@@ -2286,10 +2613,11 @@ void AliTOFClusterFinderV1::FindClustersPerStrip(Int_t nSector,
              for (jj=0; jj<3; jj++) posF[jj] = posClus[jj];
 
              AliDebug(1,Form(" %f %f %f", posF[0], posF[1], posF[2]));
-             tofGeometry->GetDetID(posF, det);
-             AliDebug(1,Form(" %2i %1i %2i %1i %2i", det[0], det[1], det[2], det[3], det[4]));
+             fTOFGeometry->GetDetID(posF, det);
+             AliDebug(1,Form(" %2d %1d %2d %1d %2d", det[0], det[1], det[2], det[3], det[4]));
 
-             volIdClus = GetClusterVolIndex(det);
+             volIdClus = fTOFGeometry->GetAliSensVolIndex(det[0],det[1],det[2]);
+             //volIdClus = GetClusterVolIndex(det);
 
              for (jj=3; jj<11; jj++) padsCluster[jj] = -1;
              padsCluster[3] = selectedDigit[adesso1][firstIndex]->GetDetectorIndex(4);
@@ -2305,8 +2633,9 @@ void AliTOFClusterFinderV1::FindClustersPerStrip(Int_t nSector,
              for (jj=0; jj<interestingCounter+1; jj++) indDet[jj][2] = nStrip;
              for (jj=0; jj<interestingCounter+1; jj++) indDet[jj][3] = padsCluster[2*jj+3];
              for (jj=0; jj<interestingCounter+1; jj++) indDet[jj][4] = padsCluster[2*jj+1+3];
-             GetClusterPars(check, interestingCounter+1, indDet, interestingWeight, posClus, covClus);
+             GetClusterPars(/*check,*/ interestingCounter+1, indDet, interestingWeight, posClus, covClus);
              for (jj=0; jj<interestingCounter+1; jj++) delete [] indDet[jj];
+             delete [] indDet;
 
              // To fill the track index array
              dummyCounter=-1;
@@ -2346,7 +2675,7 @@ void AliTOFClusterFinderV1::FindClustersPerStrip(Int_t nSector,
                                  tracks, det, parTOF, status, selectedDigit[adesso1][firstIndex]->GetIndex()); //to updated
              InsertCluster(tofCluster);
 
-             AliDebug(2, Form("       %4i  %f %f %f  %f %f %f %f %f %f  %3i %3i %3i  %2i %1i %2i %1i %2i  %4i %3i %3i %4i %4i  %1i  %4i", 
+             AliDebug(2, Form("       %4d  %f %f %f  %f %f %f %f %f %f  %3d %3d %3d  %2d %1d %2d %1d %2d  %4d %3d %3d %4d %4d  %1d  %4d", 
                               volIdClus, posClus[0], posClus[1], posClus[2],
                               covClus[0], covClus[1], covClus[2], covClus[3], covClus[4], covClus[5],
                               tracks[0], tracks[1], tracks[2],
@@ -2365,25 +2694,28 @@ void AliTOFClusterFinderV1::FindClustersPerStrip(Int_t nSector,
 
 
            } // close loop on second digit
-         } // close loop on adesso2
+           //} // close loop on adesso2
 
        } // close loop on first digit
-      } // close loop on adesso1
+         //} // close loop on adesso1
 
 
       break;
 
     case 3:
 
-      for (Int_t adesso1=0; adesso1<interestingCounter+1; adesso1++) {
+      //for (adesso1=0; adesso1<interestingCounter+1; adesso1++) {
+      adesso1 = 0;
        for (Int_t firstIndex=0; firstIndex<kMaxNumberOfDigitsPerVolume; firstIndex++) {
          if (selectedDigit[adesso1][firstIndex]==0x0) continue;
 
-         for (Int_t adesso2=adesso1+1; adesso2<interestingCounter+1; adesso2++) {
+         //for (adesso2=adesso1+1; adesso2<interestingCounter+1; adesso2++) {
+         adesso2 = 1;
            for (Int_t secondIndex=0; secondIndex<kMaxNumberOfDigitsPerVolume; secondIndex++) {
              if (selectedDigit[adesso2][secondIndex]==0x0) continue;
 
-             for (Int_t adesso3=adesso2+1; adesso3<interestingCounter+1; adesso3++) {
+             //for (adesso3=adesso2+1; adesso3<interestingCounter+1; adesso3++) {
+             adesso3 = 2;
                for (Int_t thirdIndex=0; thirdIndex<kMaxNumberOfDigitsPerVolume; thirdIndex++) {
                  if (selectedDigit[adesso3][thirdIndex]==0x0) continue;
 
@@ -2399,11 +2731,11 @@ void AliTOFClusterFinderV1::FindClustersPerStrip(Int_t nSector,
                  interestingADC[0] = selectedDigit[adesso1][firstIndex]->GetADC();
                  interestingWeight[0] = selectedDigit[adesso1][firstIndex]->GetWeight();
                  Int_t vol1[5]; for(jj=0; jj<5; jj++) vol1[jj] = selectedDigit[adesso1][firstIndex]->GetDetectorIndex(jj);
-                 AliDebug(1,Form(" %2i %1i %2i %1i %2i", vol1[0], vol1[1], vol1[2], vol1[4], vol1[3]));
+                 AliDebug(1,Form(" %2d %1d %2d %1d %2d", vol1[0], vol1[1], vol1[2], vol1[4], vol1[3]));
                  Int_t volDum = vol1[3];
                  vol1[3] = vol1[4];
                  vol1[4] = volDum;
-                 tofGeometry->GetPosPar(vol1,pos);
+                 fTOFGeometry->GetPosPar(vol1,pos);
                  interestingX[0] = pos[0];
                  interestingY[0] = pos[1];
                  interestingZ[0] = pos[2];
@@ -2413,11 +2745,11 @@ void AliTOFClusterFinderV1::FindClustersPerStrip(Int_t nSector,
                  interestingADC[1] = selectedDigit[adesso2][secondIndex]->GetADC();
                  interestingWeight[1] = selectedDigit[adesso2][secondIndex]->GetWeight();
                  Int_t vol2[5]; for(jj=0; jj<5; jj++) vol2[jj] = selectedDigit[adesso2][secondIndex]->GetDetectorIndex(jj);
-                 AliDebug(1,Form(" %2i %1i %2i %1i %2i", vol2[0], vol2[1], vol2[2], vol2[4], vol2[3]));
+                 AliDebug(1,Form(" %2d %1d %2d %1d %2d", vol2[0], vol2[1], vol2[2], vol2[4], vol2[3]));
                  volDum = vol2[3];
                  vol2[3] = vol2[4];
                  vol2[4] = volDum;
-                 tofGeometry->GetPosPar(vol2,pos);
+                 fTOFGeometry->GetPosPar(vol2,pos);
                  interestingX[1] = pos[0];
                  interestingY[1] = pos[1];
                  interestingZ[1] = pos[2];
@@ -2427,11 +2759,11 @@ void AliTOFClusterFinderV1::FindClustersPerStrip(Int_t nSector,
                  interestingADC[2] = selectedDigit[adesso3][thirdIndex]->GetADC();
                  interestingWeight[2] = selectedDigit[adesso3][thirdIndex]->GetWeight();
                  Int_t vol3[5]; for(jj=0; jj<5; jj++) vol3[jj] = selectedDigit[adesso3][thirdIndex]->GetDetectorIndex(jj);
-                 AliDebug(1,Form(" %2i %1i %2i %1i %2i", vol3[0], vol3[1], vol3[2], vol3[4], vol3[3]));
+                 AliDebug(1,Form(" %2d %1d %2d %1d %2d", vol3[0], vol3[1], vol3[2], vol3[4], vol3[3]));
                  volDum = vol3[3];
                  vol3[3] = vol3[4];
                  vol3[4] = volDum;
-                 tofGeometry->GetPosPar(vol3,pos);
+                 fTOFGeometry->GetPosPar(vol3,pos);
                  interestingX[2] = pos[0];
                  interestingY[2] = pos[1];
                  interestingZ[2] = pos[2];
@@ -2445,9 +2777,10 @@ void AliTOFClusterFinderV1::FindClustersPerStrip(Int_t nSector,
 
                  for (jj=0; jj<5; jj++) det[jj] = -1;
                  for (jj=0; jj<3; jj++) posF[jj] = posClus[jj];
-                 tofGeometry->GetDetID(posF, det);
+                 fTOFGeometry->GetDetID(posF, det);
 
-                 volIdClus = GetClusterVolIndex(det);
+                 volIdClus = fTOFGeometry->GetAliSensVolIndex(det[0],det[1],det[2]);
+                 //volIdClus = GetClusterVolIndex(det);
 
                  for (jj=3; jj<11; jj++) padsCluster[jj] = -1;
                  padsCluster[3] = selectedDigit[adesso1][firstIndex]->GetDetectorIndex(4);
@@ -2465,8 +2798,10 @@ void AliTOFClusterFinderV1::FindClustersPerStrip(Int_t nSector,
                  for (jj=0; jj<interestingCounter+1; jj++) indDet[jj][2] = nStrip;
                  for (jj=0; jj<interestingCounter+1; jj++) indDet[jj][3] = padsCluster[2*jj+3];
                  for (jj=0; jj<interestingCounter+1; jj++) indDet[jj][4] = padsCluster[2*jj+1+3];
-                 GetClusterPars(check, interestingCounter+1, indDet, interestingWeight, posClus, covClus);
+                 GetClusterPars(/*check,*/ interestingCounter+1, indDet, interestingWeight, posClus, covClus);
                  for (jj=0; jj<interestingCounter+1; jj++) delete [] indDet[jj];
+                 delete [] indDet;
+
 
                  // To fill the track index array
                  dummyCounter=-1;
@@ -2526,7 +2861,7 @@ void AliTOFClusterFinderV1::FindClustersPerStrip(Int_t nSector,
                                      tracks, det, parTOF, status, selectedDigit[adesso1][firstIndex]->GetIndex()); // to be updated
                  InsertCluster(tofCluster);
 
-                 AliDebug(2, Form("       %4i  %f %f %f  %f %f %f %f %f %f  %3i %3i %3i  %2i %1i %2i %1i %2i  %4i %3i %3i %4i %4i  %1i  %4i", 
+                 AliDebug(2, Form("       %4d  %f %f %f  %f %f %f %f %f %f  %3d %3d %3d  %2d %1d %2d %1d %2d  %4d %3d %3d %4d %4d  %1d  %4d", 
                                   volIdClus, posClus[0], posClus[1], posClus[2],
                                   covClus[0], covClus[1], covClus[2], covClus[3], covClus[4], covClus[5],
                                   tracks[0], tracks[1], tracks[2],
@@ -2549,32 +2884,32 @@ void AliTOFClusterFinderV1::FindClustersPerStrip(Int_t nSector,
 
 
                } // close loop on third digit
-             } // close loop on adesso3
+               //} // close loop on adesso3
 
            } // close loop on second digit
-         } // close loop on adesso2
+           //} // close loop on adesso2
 
        } // close loop on first digit
-      } // close loop on adesso1
+       //} // close loop on adesso1
 
 
       break;
 
     case 4:
 
-      Int_t adesso1 = 0;
+      adesso1 = 0;
       for (Int_t firstIndex=0; firstIndex<kMaxNumberOfDigitsPerVolume; firstIndex++) {
        if (selectedDigit[adesso1][firstIndex]==0x0) continue;
 
-       Int_t adesso2 = 1;
+       adesso2 = 1;
        for (Int_t secondIndex=0; secondIndex<kMaxNumberOfDigitsPerVolume; secondIndex++) {
          if (selectedDigit[adesso2][secondIndex]==0x0) continue;
 
-         Int_t adesso3 = 2;
+         adesso3 = 2;
          for (Int_t thirdIndex=0; thirdIndex<kMaxNumberOfDigitsPerVolume; thirdIndex++) {
            if (selectedDigit[adesso3][thirdIndex]==0x0) continue;
 
-           Int_t adesso4 = 3;
+           adesso4 = 3;
            for (Int_t fourthIndex=0; fourthIndex<kMaxNumberOfDigitsPerVolume; fourthIndex++) {
              if (selectedDigit[adesso4][fourthIndex]==0x0) continue;
 
@@ -2596,11 +2931,11 @@ void AliTOFClusterFinderV1::FindClustersPerStrip(Int_t nSector,
              interestingADC[0] = selectedDigit[adesso1][firstIndex]->GetADC();
              interestingWeight[0] = selectedDigit[adesso1][firstIndex]->GetWeight();
              Int_t vol1[5]; for(jj=0; jj<5; jj++) vol1[jj] = selectedDigit[adesso1][firstIndex]->GetDetectorIndex(jj);
-             AliDebug(1,Form(" %2i %1i %2i %1i %2i", vol1[0], vol1[1], vol1[2], vol1[4], vol1[3]));
+             AliDebug(1,Form(" %2d %1d %2d %1d %2d", vol1[0], vol1[1], vol1[2], vol1[4], vol1[3]));
              Int_t volDum = vol1[3];
              vol1[3] = vol1[4];
              vol1[4] = volDum;
-             tofGeometry->GetPosPar(vol1,pos);
+             fTOFGeometry->GetPosPar(vol1,pos);
              interestingX[0] = pos[0];
              interestingY[0] = pos[1];
              interestingZ[0] = pos[2];
@@ -2610,11 +2945,11 @@ void AliTOFClusterFinderV1::FindClustersPerStrip(Int_t nSector,
              interestingADC[1] = selectedDigit[adesso2][secondIndex]->GetADC();
              interestingWeight[1] = selectedDigit[adesso2][secondIndex]->GetWeight();
              Int_t vol2[5]; for(jj=0; jj<5; jj++) vol2[jj] = selectedDigit[adesso2][secondIndex]->GetDetectorIndex(jj);
-             AliDebug(1,Form(" %2i %1i %2i %1i %2i", vol2[0], vol2[1], vol2[2], vol2[4], vol2[3]));
+             AliDebug(1,Form(" %2d %1d %2d %1d %2d", vol2[0], vol2[1], vol2[2], vol2[4], vol2[3]));
              volDum = vol2[3];
              vol2[3] = vol2[4];
              vol2[4] = volDum;
-             tofGeometry->GetPosPar(vol2,pos);
+             fTOFGeometry->GetPosPar(vol2,pos);
              interestingX[1] = pos[0];
              interestingY[1] = pos[1];
              interestingZ[1] = pos[2];
@@ -2624,11 +2959,11 @@ void AliTOFClusterFinderV1::FindClustersPerStrip(Int_t nSector,
              interestingADC[2] = selectedDigit[adesso3][thirdIndex]->GetADC();
              interestingWeight[2] = selectedDigit[adesso3][thirdIndex]->GetWeight();
              Int_t vol3[5]; for(jj=0; jj<5; jj++) vol3[jj] = selectedDigit[adesso3][thirdIndex]->GetDetectorIndex(jj);
-             AliDebug(1,Form(" %2i %1i %2i %1i %2i", vol3[0], vol3[1], vol3[2], vol3[4], vol3[3]));
+             AliDebug(1,Form(" %2d %1d %2d %1d %2d", vol3[0], vol3[1], vol3[2], vol3[4], vol3[3]));
              volDum = vol3[3];
              vol3[3] = vol3[4];
              vol3[4] = volDum;
-             tofGeometry->GetPosPar(vol3,pos);
+             fTOFGeometry->GetPosPar(vol3,pos);
              interestingX[2] = pos[0];
              interestingY[2] = pos[1];
              interestingZ[2] = pos[2];
@@ -2638,11 +2973,11 @@ void AliTOFClusterFinderV1::FindClustersPerStrip(Int_t nSector,
              interestingADC[3] = selectedDigit[adesso4][fourthIndex]->GetADC();
              interestingWeight[3] = selectedDigit[adesso4][fourthIndex]->GetWeight();
              Int_t vol4[5]; for(jj=0; jj<5; jj++) vol4[jj] = selectedDigit[adesso4][fourthIndex]->GetDetectorIndex(jj);
-             AliDebug(1,Form(" %2i %1i %2i %1i %2i", vol4[0], vol4[1], vol4[2], vol4[4], vol4[3]));
+             AliDebug(1,Form(" %2d %1d %2d %1d %2d", vol4[0], vol4[1], vol4[2], vol4[4], vol4[3]));
              volDum = vol4[3];
              vol4[3] = vol4[4];
              vol4[4] = volDum;
-             tofGeometry->GetPosPar(vol4,pos);
+             fTOFGeometry->GetPosPar(vol4,pos);
              interestingX[3] = pos[0];
              interestingY[3] = pos[1];
              interestingZ[3] = pos[2];
@@ -2656,9 +2991,10 @@ void AliTOFClusterFinderV1::FindClustersPerStrip(Int_t nSector,
 
              for (jj=0; jj<5; jj++) det[jj] = -1;
              for (jj=0; jj<3; jj++) posF[jj] = posClus[jj];
-             tofGeometry->GetDetID(posF, det);
+             fTOFGeometry->GetDetID(posF, det);
 
-             volIdClus = GetClusterVolIndex(det);
+             volIdClus = fTOFGeometry->GetAliSensVolIndex(det[0],det[1],det[2]);
+             //volIdClus = GetClusterVolIndex(det);
 
              for (jj=3; jj<11; jj++) padsCluster[jj] = -1;
              padsCluster[3] = selectedDigit[adesso1][firstIndex]->GetDetectorIndex(4);
@@ -2678,8 +3014,9 @@ void AliTOFClusterFinderV1::FindClustersPerStrip(Int_t nSector,
              for (jj=0; jj<interestingCounter+1; jj++) indDet[jj][2] = nStrip;
              for (jj=0; jj<interestingCounter+1; jj++) indDet[jj][3] = padsCluster[2*jj+3];
              for (jj=0; jj<interestingCounter+1; jj++) indDet[jj][4] = padsCluster[2*jj+1+3];
-             GetClusterPars(check, interestingCounter+1, indDet, interestingWeight, posClus, covClus);
+             GetClusterPars(/*check,*/ interestingCounter+1, indDet, interestingWeight, posClus, covClus);
              for (jj=0; jj<interestingCounter+1; jj++) delete [] indDet[jj];
+             delete [] indDet;
 
              // To fill the track index array
              dummyCounter=-1;
@@ -2759,7 +3096,7 @@ void AliTOFClusterFinderV1::FindClustersPerStrip(Int_t nSector,
                                  tracks, det, parTOF, status, selectedDigit[adesso1][firstIndex]->GetIndex()); // to be updated
              InsertCluster(tofCluster);
 
-             AliDebug(2, Form("       %4i  %f %f %f  %f %f %f %f %f %f  %3i %3i %3i  %2i %1i %2i %1i %2i  %4i %3i %3i %4i %4i  %1i  %4i", 
+             AliDebug(2, Form("       %4d  %f %f %f  %f %f %f %f %f %f  %3d %3d %3d  %2d %1d %2d %1d %2d  %4d %3d %3d %4d %4d  %1d  %4d", 
                               volIdClus, posClus[0], posClus[1], posClus[2],
                               covClus[0], covClus[1], covClus[2], covClus[3], covClus[4], covClus[5],
                               tracks[0], tracks[1], tracks[2],
@@ -2803,11 +3140,16 @@ void AliTOFClusterFinderV1::FindClustersPerStrip(Int_t nSector,
 
   } // loop on iPad
 
-  for (ii=0; ii<kMaxNumberOfInterestingPads; ii++)
+  for (ii=0; ii<kMaxNumberOfInterestingPads; ii++) {
     for (jj=0; jj<kMaxNumberOfDigitsPerVolume; jj++) {
-      delete selectedDigit[ii][jj];
+      delete [] selectedDigit[ii][jj];
       selectedDigit[ii][jj] = 0x0;
     }
+    delete [] selectedDigit[ii];
+    selectedDigit[ii] = 0x0;
+  }
+  delete [] selectedDigit;
+  selectedDigit = 0x0;
 
 }
 //_____________________________________________________________________________
@@ -2882,14 +3224,14 @@ void AliTOFClusterFinderV1::ResetDigits()
 
 }
 //_____________________________________________________________________________
-
-UShort_t AliTOFClusterFinderV1::GetClusterVolIndex(Int_t *ind) const
-{
+//UShort_t AliTOFClusterFinderV1::GetClusterVolIndex(Int_t *ind) const
+//{
   //
   // Get the volume ID to retrieve the l2t transformation
   //
 
   // Detector numbering scheme
+/*
   Int_t nSector = AliTOFGeometry::NSectors();
   Int_t nPlate  = AliTOFGeometry::NPlates();
   Int_t nStripA = AliTOFGeometry::NStripA();
@@ -2934,6 +3276,7 @@ UShort_t AliTOFClusterFinderV1::GetClusterVolIndex(Int_t *ind) const
   return volIndex;
 
 }
+*/
 //_____________________________________________________________________________
 
 void AliTOFClusterFinderV1::GetClusterPars(Int_t *ind, Double_t* pos, Double_t* cov) const
@@ -2964,7 +3307,8 @@ void AliTOFClusterFinderV1::GetClusterPars(Int_t *ind, Double_t* pos, Double_t*
   AliDebug(1, Form(" %f %f %f", lpos[0], lpos[1], lpos[2]));
 
   // Volume ID
-  UShort_t volIndex = GetClusterVolIndex(ind);
+  UShort_t volIndex = fTOFGeometry->GetAliSensVolIndex(ind[0],ind[1],ind[2]);
+  //UShort_t volIndex = GetClusterVolIndex(ind);
   const TGeoHMatrix *l2t = AliGeomManager::GetTracking2LocalMatrix(volIndex);
 
   // Get the position in the track ref system
@@ -2989,6 +3333,7 @@ void AliTOFClusterFinderV1::GetClusterPars(Int_t *ind, Double_t* pos, Double_t*
                        //   + 0.5*0.160 (internl PCB)
                        //   + 1*0.055 (external red glass))
   */
+
   lcov[0] = 0.499678;//AliTOFGeometry::XPad()*AliTOFGeometry::XPad()/12.;
   lcov[8] = 0.992429;//AliTOFGeometry::ZPad()*AliTOFGeometry::ZPad()/12.;
 
@@ -3006,7 +3351,7 @@ void AliTOFClusterFinderV1::GetClusterPars(Int_t *ind, Double_t* pos, Double_t*
 }
 //_____________________________________________________________________________
 
-void AliTOFClusterFinderV1::GetClusterPars(Bool_t check, Int_t counter,
+void AliTOFClusterFinderV1::GetClusterPars(/*Bool_t check,*/ Int_t counter,
                                           Int_t **ind, Double_t *weight,
                                           Double_t *pos, Double_t *cov) const
 {
@@ -3035,18 +3380,19 @@ void AliTOFClusterFinderV1::GetClusterPars(Bool_t check, Int_t counter,
   // x <-----------------------------------------------------
 
   for (Int_t ii=0; ii<counter; ii++)
-    AliDebug(1, Form(" %2i  %2i %1i %2i %1i %2i ",
+    AliDebug(1, Form(" %2d  %2d %1d %2d %1d %2d ",
                     ii, ind[ii][0], ind[ii][1], ind[ii][2], ind[ii][3], ind[ii][4]));
 
   Float_t posF[3]; for (Int_t ii=0; ii<3; ii++) posF[ii] = (Float_t)pos[ii];
   AliDebug(1, Form(" %f %f %f", pos[0], pos[1], pos[2]));
-  AliTOFGeometry tofGeom;
+
   Int_t detClus[5] = {-1, -1, -1, -1, -1};
-  tofGeom.GetDetID(posF, detClus);
+  fTOFGeometry->GetDetID(posF, detClus);
 
   // Volume ID
-  UShort_t volIndex = GetClusterVolIndex(detClus);
-  AliDebug(1, Form(" %2i %1i %2i %1i %2i  %7i",
+  UShort_t volIndex = fTOFGeometry->GetAliSensVolIndex(detClus[0],detClus[1],detClus[2]);
+  //UShort_t volIndex = GetClusterVolIndex(detClus);
+  AliDebug(1, Form(" %2d %1d %2d %1d %2d  %7i",
                   detClus[0], detClus[1], detClus[2], detClus[3], detClus[4], volIndex));
 
   // Get the position in the TOF strip ref system
@@ -3073,7 +3419,7 @@ void AliTOFClusterFinderV1::GetClusterPars(Bool_t check, Int_t counter,
   // 0     0 sz2
 
   // Evaluation of the ovariance matrix elements
-  TOFclusterError(check, counter, ind, weight, ppos, lcov);
+  TOFclusterError(/*check,*/ counter, ind, weight, ppos, lcov);
 
   AliDebug(1, Form("lcov[0] = %f, lcov[8] = %f", lcov[0], lcov[8]));
 
@@ -3091,7 +3437,7 @@ void AliTOFClusterFinderV1::GetClusterPars(Bool_t check, Int_t counter,
 }
 //_____________________________________________________________________________
 
-void AliTOFClusterFinderV1::TOFclusterError(Bool_t check, Int_t counter,
+void AliTOFClusterFinderV1::TOFclusterError(/*Bool_t check,*/ Int_t counter,
                                            Int_t **ind, Double_t *weight,
                                            Double_t ppos[], Double_t lcov[]) const
 {
@@ -3099,7 +3445,7 @@ void AliTOFClusterFinderV1::TOFclusterError(Bool_t check, Int_t counter,
   //
   //
 
-  //lcov[4] = 0.42*0.42/3.;
+  //lcov[4] = 0.42*0.42/3.; // cm2
                        // = ( 5*0.025 (gas gaps thikness)
                        //   + 4*0.040 (internal glasses thickness)
                        //   + 0.5*0.160 (internl PCB)
@@ -3117,7 +3463,7 @@ void AliTOFClusterFinderV1::TOFclusterError(Bool_t check, Int_t counter,
       ((ind[ii][3]- 0.5)*AliTOFGeometry::ZPad() - ppos[2])*((ind[ii][3]- 0.5)*AliTOFGeometry::ZPad() - ppos[2]);
 
   for (Int_t ii=0; ii<counter; ii++)
-    AliDebug(1, Form("x[%i] = %f, z[%i] = %f, weight[%i] = %f",
+    AliDebug(1, Form("x[%d] = %f, z[%d] = %f, weight[%d] = %f",
                     ii, (ind[ii][4]-23.5)*AliTOFGeometry::XPad(),
                     ii, (ind[ii][3]- 0.5)*AliTOFGeometry::ZPad(),
                     ii, weight[ii]
@@ -3132,78 +3478,91 @@ void AliTOFClusterFinderV1::TOFclusterError(Bool_t check, Int_t counter,
 
       if (ind[0][3]==ind[1][3] && TMath::Abs(ind[0][4]-ind[1][4])==1) { //
 
-       lcov[8] = 1.02039;
-
+       lcov[8] = 1.02039; // cm2
+       lcov[0] = 0.0379409; // cm2
+       /*
        if (check)
-         lcov[0] = 0.5*0.5;
+         lcov[0] = 0.5*0.5; // cm2
        else {
          if (weight[0]==weight[1])
-           lcov[0] = 0.0379409;
+           lcov[0] = 0.0379409; // cm2
          else
-           lcov[0] = TMath::Mean(counter, delta2X, weight);
+           lcov[0] = TMath::Mean(counter, delta2X, weight); // cm2
        }
+       */
 
       }
 
       else if (ind[0][4]==ind[1][4] && TMath::Abs(ind[0][3]-ind[1][3])==1) {//
 
-       lcov[0] = 0.505499;
-
+       lcov[0] = 0.505499; // cm2
+       lcov[8] = 0.0422046; // cm2
+       /*
        if (check)
-         lcov[8] = 0.5*0.5;
+         lcov[8] = 0.5*0.5; // cm2
        else {
          if (weight[0]==weight[1])
-           lcov[8] = 0.0422046;
+           lcov[8] = 0.0422046; // cm2
          else
-           lcov[8] = TMath::Mean(counter, delta2Z, weight);
+           lcov[8] = TMath::Mean(counter, delta2Z, weight); // cm2
        }
+       */
 
       }
 
       break;
 
     case 3:
-
+      lcov[0] = 0.0290677; // cm2
+      lcov[8] = 0.0569726; // cm2
+      /*
       if (check) {
-       lcov[0] = 0.5*0.5;
-       lcov[8] = 0.5*0.5;
+       lcov[0] = 0.5*0.5; // cm2
+       lcov[8] = 0.5*0.5; // cm2
       }
       else {
-       if (weight[0]==weight[1] && weight[0]==weight[2]) {
-         lcov[0] = 0.0290677;
-         lcov[8] = 0.0569726;
-       }
+      if (weight[0]==weight[1] && weight[0]==weight[2]) {
+         lcov[0] = 0.0290677; // cm2
+         lcov[8] = 0.0569726; // cm2
+         }
        else {
-         lcov[0] = TMath::Mean(counter, delta2X, weight);
-         lcov[8] = TMath::Mean(counter, delta2Z, weight);
-       }
+         lcov[0] = TMath::Mean(counter, delta2X, weight); // cm2
+         lcov[8] = TMath::Mean(counter, delta2Z, weight); // cm2
+         }
 
-      }
+       }
+      */
 
       break;
 
     case 4:
-
+      lcov[0] = 0.0223807; // cm2
+      lcov[8] = 0.0438662; // cm2
+      /*
       if (check) {
-       lcov[0] = 0.5*0.5;
-       lcov[8] = 0.5*0.5;
+       lcov[0] = 0.5*0.5; // cm2
+       lcov[8] = 0.5*0.5; // cm2
       }
       else {
-       if (weight[0]==weight[1] && weight[0]==weight[2] && weight[0]==weight[3]) {
-         lcov[0] = 0.0223807;
-         lcov[8] = 0.0438662;
-       }
+      if (weight[0]==weight[1] && weight[0]==weight[2] && weight[0]==weight[3]) {
+         lcov[0] = 0.0223807; // cm2
+         lcov[8] = 0.0438662; // cm2
+         }
        else {
-         lcov[0] = TMath::Mean(counter, delta2X, weight);
-         lcov[8] = TMath::Mean(counter, delta2Z, weight);
-       }
+         lcov[0] = TMath::Mean(counter, delta2X, weight); // cm2
+         lcov[8] = TMath::Mean(counter, delta2Z, weight); // cm2
+         }
 
-      }
+       }
+      */
 
       break;
 
     }
 
+  delete [] delta2Z;
+  delete [] delta2X;
+
 }
 //_____________________________________________________________________________
 
@@ -3234,8 +3593,8 @@ Bool_t AliTOFClusterFinderV1::MakeSlewingCorrection(Int_t *detectorIndex,
 
   //AliInfo(" Calibrating TOF Digits: ");
   
-  AliTOFChannelOnlineArray *calDelay = fTOFcalib->GetTOFOnlineDelay();  
-  AliTOFChannelOnlineStatusArray *calStatus = fTOFcalib->GetTOFOnlineStatus();  
+  AliTOFChannelOnlineArray *calDelay = fTOFcalib->GetTOFOnlineDelay();
+  AliTOFChannelOnlineStatusArray *calStatus = fTOFcalib->GetTOFOnlineStatus();
 
   TObjArray *calTOFArrayOffline = fTOFcalib->GetTOFCalArrayOffline();
 
@@ -3248,14 +3607,17 @@ Bool_t AliTOFClusterFinderV1::MakeSlewingCorrection(Int_t *detectorIndex,
 
   //check the status, also unknown is fine!!!!!!!
 
-  AliDebug(2, Form(" Status for channel %i = %i",index, (Int_t)status));
+  AliDebug(2, Form(" Status for channel %d = %d",index, (Int_t)status));
   if((statusPulser & AliTOFChannelOnlineStatusArray::kTOFPulserBad)==(AliTOFChannelOnlineStatusArray::kTOFPulserBad)||(statusNoise & AliTOFChannelOnlineStatusArray::kTOFNoiseBad)==(AliTOFChannelOnlineStatusArray::kTOFNoiseBad)||(statusHW & AliTOFChannelOnlineStatusArray::kTOFHWBad)==(AliTOFChannelOnlineStatusArray::kTOFHWBad)){
-    AliDebug(2, Form(" Bad Status for channel %i",index));
+    AliDebug(2, Form(" Bad Status for channel %d",index));
     //fTofClusters[ii]->SetStatus(kFALSE); //odd convention, to avoid conflict with calibration objects currently in the db (temporary solution).
     output = kFALSE;
   }
   else
-    AliDebug(2, Form(" Good Status for channel %i",index));
+    AliDebug(2, Form(" Good Status for channel %d",index));
+
+
+  if (fCalibrateTOFtimes) { // AdC
 
   // Get Rough channel online equalization 
   Double_t roughDelay = (Double_t)calDelay->GetDelay(index);  // in ns
@@ -3269,7 +3631,7 @@ Bool_t AliTOFClusterFinderV1::MakeSlewingCorrection(Int_t *detectorIndex,
       par[jj] = (Double_t)calChannelOffline->GetSlewPar(jj);
 
     AliDebug(2,Form(" Calib Pars = %f, %f, %f, %f, %f, %f ",par[0],par[1],par[2],par[3],par[4],par[5]));
-    AliDebug(2,Form(" The ToT and Time, uncorr (counts) = %i , %i", tofDigitToT, tofDigitTdc));
+    AliDebug(2,Form(" The ToT and Time, uncorr (counts) = %d , %d", tofDigitToT, tofDigitTdc));
     Double_t tToT = (Double_t)(tofDigitToT*AliTOFGeometry::ToTBinWidth());    
     tToT*=1.E-3; //ToT in ns
     AliDebug(2,Form(" The ToT and Time, uncorr (ns)= %e, %e",tofDigitTdc*AliTOFGeometry::TdcBinWidth()*1.E-3,tToT));
@@ -3283,8 +3645,11 @@ Bool_t AliTOFClusterFinderV1::MakeSlewingCorrection(Int_t *detectorIndex,
   timeCorr = (Double_t)(tofDigitTdc)*AliTOFGeometry::TdcBinWidth()*1.E-3-timeCorr;//redefine the time
   timeCorr *= 1.E3;
   AliDebug(2,Form(" The channel time, corr (ps)= %e",timeCorr ));
-  tdcCorr = (Int_t)(timeCorr/AliTOFGeometry::TdcBinWidth()); //the corrected time (tdc counts)
+  //tdcCorr = (Int_t)(timeCorr/AliTOFGeometry::TdcBinWidth()); //the corrected time (tdc counts)
+  tdcCorr = TMath::Nint(timeCorr/AliTOFGeometry::TdcBinWidth()); //the corrected time (tdc counts)
   
+  } // AdC
+
   return output;
 
 }
@@ -3304,8 +3669,10 @@ void AliTOFClusterFinderV1::Digits2RecPoints(Int_t iEvent)
   AliLoader *localTOFLoader = (AliLoader*)fRunLoader->GetLoader("TOFLoader");
 
   TTree * localTreeD = (TTree*)localTOFLoader->TreeD();
-  if (localTreeD == 0x0)
+  if (localTreeD == 0x0) {
     AliFatal("Can not get TreeD");
+    return;
+  }
 
   TBranch *branch = localTreeD->GetBranch("TOF");
   if (!branch) {
@@ -3325,7 +3692,7 @@ void AliTOFClusterFinderV1::Digits2RecPoints(Int_t iEvent)
   //localTOFLoader = fRunLoader->GetLoader("TOFLoader");  
   localTOFLoader->WriteRecPoints("OVERWRITE");
 
-  AliDebug(1, Form("Execution time to read TOF digits and to write TOF clusters for the event number %i: R:%.4fs C:%.4fs",
+  AliDebug(1, Form("Execution time to read TOF digits and to write TOF clusters for the event number %d: R:%.4fs C:%.4fs",
                   iEvent, stopwatch.RealTime(),stopwatch.CpuTime()));
 
 }
@@ -3342,7 +3709,7 @@ void AliTOFClusterFinderV1::Digits2RecPoints(Int_t iEvent, AliRawReader *rawRead
 
   fRunLoader->GetEvent(iEvent);
 
-  AliDebug(2,Form(" Event number %2i ", iEvent));
+  AliDebug(2,Form(" Event number %2d ", iEvent));
 
   AliLoader *localTOFLoader = (AliLoader*)fRunLoader->GetLoader("TOFLoader");
 
@@ -3355,7 +3722,7 @@ void AliTOFClusterFinderV1::Digits2RecPoints(Int_t iEvent, AliRawReader *rawRead
 
   Digits2RecPoints(rawReader, localTreeR);
 
-  AliDebug(1, Form("Execution time to read TOF raw data and to write TOF clusters for the event number %i: R:%.4fs C:%.4fs",
+  AliDebug(1, Form("Execution time to read TOF raw data and to write TOF clusters for the event number %d: R:%.4fs C:%.4fs",
                   iEvent, stopwatch.RealTime(),stopwatch.CpuTime()));
 
 }
@@ -3373,7 +3740,7 @@ void AliTOFClusterFinderV1::Raw2Digits(Int_t iEvent, AliRawReader *rawReader)
 
   fRunLoader->GetEvent(iEvent);
 
-  AliDebug(2,Form(" Event number %2i ", iEvent));
+  AliDebug(2,Form(" Event number %2d ", iEvent));
 
   AliLoader *localTOFLoader = (AliLoader*)fRunLoader->GetLoader("TOFLoader");
 
@@ -3386,7 +3753,7 @@ void AliTOFClusterFinderV1::Raw2Digits(Int_t iEvent, AliRawReader *rawReader)
 
   Raw2Digits(rawReader, localTreeD);
 
-  AliDebug(1, Form("Execution time to read TOF raw data and to write TOF clusters for the event number %i: R:%.4fs C:%.4fs",
+  AliDebug(1, Form("Execution time to read TOF raw data and to write TOF clusters for the event number %d: R:%.4fs C:%.4fs",
                   iEvent, stopwatch.RealTime(),stopwatch.CpuTime()));
 
 }
@@ -3399,7 +3766,8 @@ void AliTOFClusterFinderV1::AverageCalculations(Int_t number, Float_t *interesti
                                                Int_t *parTOF, Double_t *posClus, Bool_t &check)
 {
   //
-  //
+  // Calculates the mean values for cluster position (x,y,z),
+  //  TOF charge and time
   //
 
   Double_t tofAverage = 0.;
@@ -3408,7 +3776,7 @@ void AliTOFClusterFinderV1::AverageCalculations(Int_t number, Float_t *interesti
 
   check = kFALSE;
   Int_t ii=-1;
-  for (ii=number-1; ii>=0; ii--) check=check||(interestingWeight[ii]==0 ||interestingWeight[ii]==-1);
+  for (ii=number-1; ii>=0; ii--) check=check||(interestingWeight[ii]==0 || interestingWeight[ii]==-1);
 
   if (check) {
                  
@@ -3432,9 +3800,11 @@ void AliTOFClusterFinderV1::AverageCalculations(Int_t number, Float_t *interesti
   }
 
   parTOF[0] = Int_t(tofAverage);
-  parTOF[1] = Int_t(adcAverage);
-  parTOF[2] = Int_t(totAverage);
-  parTOF[3] = Int_t(tofAverage);
-  parTOF[4] = Int_t(tofAverage);
+  parTOF[1] = Int_t(totAverage);
+  parTOF[2] = Int_t(adcAverage);
+  parTOF[3] = Int_t(tofAverage);//tofND
+  parTOF[4] = Int_t(tofAverage);//tofRAW
+  parTOF[5] = 0;
+  parTOF[6] = 0;
 
 }