]> git.uio.no Git - u/mrichter/AliRoot.git/blobdiff - TOF/AliTOFClusterFinderV1.cxx
bugfix: corrected calculation of slice and partition from track point Id
[u/mrichter/AliRoot.git] / TOF / AliTOFClusterFinderV1.cxx
index 57af8711f0b613ae83fb0b8c891f1bc8982e86c1..78aff2c9094febe34ee698ec1dbb065f7708006c 100644 (file)
@@ -44,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"
 
@@ -63,6 +64,7 @@ ClassImp(AliTOFClusterFinderV1)
 
 //_____________________________________________________________________________
 AliTOFClusterFinderV1::AliTOFClusterFinderV1(AliTOFcalib *calib):
+  TTask("AliTOFClusterFinderV1",""),
   fRunLoader(0),
   fDigits(new TClonesArray("AliTOFdigit", 4000)),
   fRecPoints(new TClonesArray("AliTOFcluster", 4000)),
@@ -83,6 +85,8 @@ AliTOFClusterFinderV1::AliTOFClusterFinderV1(AliTOFcalib *calib):
 // Constructor
 //
 
+  for (Int_t ii=0; ii<kTofMaxCluster; ii++) fTofClusters[ii]=0x0;
+
   if (AliTOFReconstructor::GetRecoParam()) {
     fkRecoParam = AliTOFReconstructor::GetRecoParam();
     fMaxDeltaTime = fkRecoParam->GetMaxDeltaTime();
@@ -101,6 +105,7 @@ AliTOFClusterFinderV1::AliTOFClusterFinderV1(AliTOFcalib *calib):
 
 //_____________________________________________________________________________
 AliTOFClusterFinderV1::AliTOFClusterFinderV1(AliRunLoader* runLoader, AliTOFcalib *calib):
+  TTask("AliTOFClusterFinderV1",""),
   fRunLoader(runLoader),
   fDigits(new TClonesArray("AliTOFdigit", 4000)),
   fRecPoints(new TClonesArray("AliTOFcluster", 4000)),
@@ -121,6 +126,8 @@ AliTOFClusterFinderV1::AliTOFClusterFinderV1(AliRunLoader* runLoader, AliTOFcali
 // Constructor
 //
 
+  for (Int_t ii=0; ii<kTofMaxCluster; ii++) fTofClusters[ii]=0x0;
+
   if (AliTOFReconstructor::GetRecoParam()) {
     fkRecoParam = AliTOFReconstructor::GetRecoParam();
     fMaxDeltaTime = fkRecoParam->GetMaxDeltaTime();
@@ -139,7 +146,7 @@ AliTOFClusterFinderV1::AliTOFClusterFinderV1(AliRunLoader* runLoader, AliTOFcali
 //_____________________________________________________________________________
 
 AliTOFClusterFinderV1::AliTOFClusterFinderV1(const AliTOFClusterFinderV1 &source)
-  :TObject(source),
+  :TTask(source),
    fRunLoader(0),
    fDigits(source.fDigits),
    fRecPoints(source.fRecPoints),
@@ -158,6 +165,8 @@ AliTOFClusterFinderV1::AliTOFClusterFinderV1(const AliTOFClusterFinderV1 &source
 {
   // copy constructor
 
+  for (Int_t ii=0; ii<kTofMaxCluster; ii++) fTofClusters[ii]=source.fTofClusters[ii];
+
   if (AliTOFReconstructor::GetRecoParam()) {
     fkRecoParam = AliTOFReconstructor::GetRecoParam();
     fMaxDeltaTime = fkRecoParam->GetMaxDeltaTime();
@@ -176,6 +185,7 @@ AliTOFClusterFinderV1& AliTOFClusterFinderV1::operator=(const AliTOFClusterFinde
     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;
@@ -217,6 +227,13 @@ AliTOFClusterFinderV1::~AliTOFClusterFinderV1()
 
   delete fTOFdigits;
 
+  //if (fTofClusters || fNumberOfTofClusters) {
+  if (fNumberOfTofClusters) {
+    for (Int_t ii=0; ii<fNumberOfTofClusters; ii++)
+      if (fTofClusters[ii]) fTofClusters[ii]->Delete();
+    fNumberOfTofClusters = 0;
+  }
+
 }
 //_____________________________________________________________________________
 
@@ -231,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) {
@@ -552,73 +572,92 @@ void AliTOFClusterFinderV1::FillRecPoint()
       for (Int_t iSector=0; iSector<AliTOFGeometry::NSectors(); iSector++) {
 
 
-       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))
+         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;
        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;
+         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 = %5", dummy4, fNumberOfTofClusters));
+         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;
+         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 = %5", dummy3, fNumberOfTofClusters));
+         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;
+         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 =%5", dummy2, fNumberOfTofClusters));
+         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;
+         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;
+         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;
+         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->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): number of clusters = %5d (remaining digit %2d), -%2d %1d %2d-",
-                          fNumberOfTofClusters, fTOFdigitMap->DigitInStrip(iSector,iPlate,iStrip),
-                          iSector, iPlate, iStrip));
 
       }
     }
@@ -631,8 +670,8 @@ void AliTOFClusterFinderV1::FillRecPoint()
 
   Int_t detectorIndex[5];
   for (jj=0; jj<5; jj++) detectorIndex[jj] = -1;
-  Int_t parTOF[5];
-  for (jj=0; jj<5; jj++) parTOF[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;
@@ -655,6 +694,8 @@ void AliTOFClusterFinderV1::FillRecPoint()
     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();
@@ -731,13 +772,13 @@ 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;
 
@@ -778,6 +819,8 @@ void AliTOFClusterFinderV1::FindOnePadClusterPerStrip(Int_t nSector,
        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);
@@ -852,12 +895,12 @@ void AliTOFClusterFinderV1::FindClustersWithoutTOT(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;
 
@@ -899,6 +942,8 @@ void AliTOFClusterFinderV1::FindClustersWithoutTOT(Int_t nSector,
        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);
@@ -1006,8 +1051,8 @@ void AliTOFClusterFinderV1::FindClusters34(Int_t nSector,
   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];
@@ -1020,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;
 
@@ -1086,7 +1131,7 @@ void AliTOFClusterFinderV1::FindClusters34(Int_t nSector,
        if (digitInteresting->GetToT()<=0) continue; // AdC
        digitIndexLocal++; // AdC
 
-       AliDebug(1,Form(" %2d %1d %2d %1d %2d  %f %f %f %f  %5d  %5d %5d %5d",
+       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(),
@@ -1119,7 +1164,7 @@ void AliTOFClusterFinderV1::FindClusters34(Int_t nSector,
        if (digitInteresting->GetToT()<=0) continue; // AdC
        digitIndexLocal++; // AdC
 
-       AliDebug(1,Form(" %2d %1d %2d %1d %2d  %f %f %f %f  %5d  %5d %5d %5d",
+       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(),
@@ -1152,7 +1197,7 @@ void AliTOFClusterFinderV1::FindClusters34(Int_t nSector,
        if (digitInteresting->GetToT()<=0) continue; // AdC
        digitIndexLocal++; // AdC
 
-       AliDebug(1,Form(" %2d %1d %2d %1d %2d  %f %f %f %f  %5d  %5d %5d %5d",
+       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(),
@@ -1185,7 +1230,7 @@ void AliTOFClusterFinderV1::FindClusters34(Int_t nSector,
        if (digitInteresting->GetToT()<=0) continue; // AdC
        digitIndexLocal++; // AdC
 
-       AliDebug(1,Form(" %2d %1d %2d %1d %2d  %f %f %f %f  %5d  %5d %5d %5d",
+       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(),
@@ -1297,6 +1342,7 @@ void AliTOFClusterFinderV1::FindClusters34(Int_t nSector,
                for (jj=0; jj<3; jj++) indDet[jj][4] = padsCluster[2*jj+1+3];
                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;
@@ -1394,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;
 
 }
 //_____________________________________________________________________________
@@ -1467,8 +1517,8 @@ void AliTOFClusterFinderV1::FindClusters23(Int_t nSector,
   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];
@@ -1480,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;
 
@@ -1546,7 +1596,7 @@ void AliTOFClusterFinderV1::FindClusters23(Int_t nSector,
        if (digitInteresting->GetToT()<=0) continue; // AdC
        digitIndexLocal++; // AdC
 
-       AliDebug(1,Form(" %2d %1d %2d %1d %2d  %f %f %f %f  %5d  %5d %5d %5d",
+       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(),
@@ -1578,7 +1628,7 @@ void AliTOFClusterFinderV1::FindClusters23(Int_t nSector,
        if (digitInteresting->GetToT()<=0) continue; // AdC
        digitIndexLocal++; // AdC
 
-       AliDebug(1,Form(" %2d %1d %2d %1d %2d  %f %f %f %f  %5d  %5d %5d %5d",
+       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(),
@@ -1610,7 +1660,7 @@ void AliTOFClusterFinderV1::FindClusters23(Int_t nSector,
        if (digitInteresting->GetToT()<=0) continue; // AdC
        digitIndexLocal++; // AdC
 
-       AliDebug(1,Form(" %2d %1d %2d %1d %2d  %f %f %f %f  %5d  %5d %5d %5d",
+       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(),
@@ -1642,7 +1692,7 @@ void AliTOFClusterFinderV1::FindClusters23(Int_t nSector,
        if (digitInteresting->GetToT()<=0) continue; // AdC
        digitIndexLocal++; // AdC
 
-       AliDebug(1,Form(" %2d %1d %2d %1d %2d  %f %f %f %f  %5d  %5d %5d %5d",
+       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(),
@@ -1727,6 +1777,7 @@ void AliTOFClusterFinderV1::FindClusters23(Int_t nSector,
            for (jj=0; jj<2; jj++) indDet[jj][4] = padsCluster[2*jj+1+3];
            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;
@@ -1796,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;
 
 }
 //_____________________________________________________________________________
@@ -1869,8 +1924,8 @@ void AliTOFClusterFinderV1::FindClusters24(Int_t nSector,
   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];
@@ -1882,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;
 
@@ -1948,7 +2003,7 @@ void AliTOFClusterFinderV1::FindClusters24(Int_t nSector,
        if (digitInteresting->GetToT()<=0) continue; // AdC
        digitIndexLocal++; // AdC
 
-       AliDebug(1,Form(" %2d %1d %2d %1d %2d  %f %f %f %f  %5d  %5d %5d %5d",
+       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(),
@@ -1980,7 +2035,7 @@ void AliTOFClusterFinderV1::FindClusters24(Int_t nSector,
        if (digitInteresting->GetToT()<=0) continue; // AdC
        digitIndexLocal++; // AdC
 
-       AliDebug(1,Form(" %2d %1d %2d %1d %2d  %f %f %f %f  %5d  %5d %5d %5d",
+       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(),
@@ -2012,7 +2067,7 @@ void AliTOFClusterFinderV1::FindClusters24(Int_t nSector,
        if (digitInteresting->GetToT()<=0) continue; // AdC
        digitIndexLocal++; // AdC
 
-       AliDebug(1,Form(" %2d %1d %2d %1d %2d  %f %f %f %f  %5d  %5d %5d %5d",
+       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(),
@@ -2044,7 +2099,7 @@ void AliTOFClusterFinderV1::FindClusters24(Int_t nSector,
        if (digitInteresting->GetToT()<=0) continue; // AdC
        digitIndexLocal++; // AdC
 
-       AliDebug(1,Form(" %2d %1d %2d %1d %2d  %f %f %f %f  %5d  %5d %5d %5d",
+       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(),
@@ -2130,6 +2185,7 @@ void AliTOFClusterFinderV1::FindClusters24(Int_t nSector,
            for (jj=0; jj<2; jj++) indDet[jj][4] = padsCluster[2*jj+1+3];
            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;
@@ -2199,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;
 
 }
 //_____________________________________________________________________________
@@ -2282,8 +2342,8 @@ void AliTOFClusterFinderV1::FindClustersPerStrip(Int_t nSector,
   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];
@@ -2295,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;
 
@@ -2503,13 +2563,13 @@ void AliTOFClusterFinderV1::FindClustersPerStrip(Int_t nSector,
 
              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,selectedDigit[adesso1][firstIndex]->GetTDC(),
-                               adesso2,secondIndex,selectedDigit[adesso2][secondIndex]->GetTDC(),
+                               adesso1,firstIndex,(Int_t)selectedDigit[adesso1][firstIndex]->GetTDC(),
+                               adesso2,secondIndex,(Int_t)selectedDigit[adesso2][secondIndex]->GetTDC(),
                                fMaxDeltaTime));
                continue;
              }
 
-             AliDebug(1, Form(" %1d %1d (0x%x) %1d %1d (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();
@@ -2575,6 +2635,7 @@ void AliTOFClusterFinderV1::FindClustersPerStrip(Int_t nSector,
              for (jj=0; jj<interestingCounter+1; jj++) indDet[jj][4] = padsCluster[2*jj+1+3];
              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;
@@ -2739,6 +2800,8 @@ void AliTOFClusterFinderV1::FindClustersPerStrip(Int_t nSector,
                  for (jj=0; jj<interestingCounter+1; jj++) indDet[jj][4] = padsCluster[2*jj+1+3];
                  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;
@@ -2953,6 +3016,7 @@ void AliTOFClusterFinderV1::FindClustersPerStrip(Int_t nSector,
              for (jj=0; jj<interestingCounter+1; jj++) indDet[jj][4] = padsCluster[2*jj+1+3];
              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;
@@ -3076,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;
 
 }
 //_____________________________________________________________________________
@@ -3576,7 +3645,8 @@ 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
 
@@ -3599,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) {
@@ -3732,5 +3804,7 @@ void AliTOFClusterFinderV1::AverageCalculations(Int_t number, Float_t *interesti
   parTOF[2] = Int_t(adcAverage);
   parTOF[3] = Int_t(tofAverage);//tofND
   parTOF[4] = Int_t(tofAverage);//tofRAW
+  parTOF[5] = 0;
+  parTOF[6] = 0;
 
 }