]> git.uio.no Git - u/mrichter/AliRoot.git/blobdiff - TOF/AliTOFClusterFinderV1.cxx
Add option to run on some local files with test mode using the alien plugin
[u/mrichter/AliRoot.git] / TOF / AliTOFClusterFinderV1.cxx
index d3036a279792c0add31c152702f85814a455adb7..285a7230cef1d911b89d33679aac9ca4a73cfd5d 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"
 
@@ -59,6 +60,10 @@ Revision 0.01  2008/05/10 A. De Caro
 #include "AliTOFReconstructor.h"
 #include "AliTOFRecoParam.h"
 
+using std::endl;
+using std::cout;
+using std::ofstream;
+using std::ios;
 ClassImp(AliTOFClusterFinderV1)
 
 //_____________________________________________________________________________
@@ -69,6 +74,7 @@ AliTOFClusterFinderV1::AliTOFClusterFinderV1(AliTOFcalib *calib):
   fRecPoints(new TClonesArray("AliTOFcluster", 4000)),
   fNumberOfTofClusters(0),
   fNumberOfTofDigits(0),
+  fNumberOfTofTrgPads(0),
   fkRecoParam(0),//AliTOFReconstructor::GetRecoParam()),
   fMaxDeltaTime(0),//fkRecoParam->GetMaxDeltaTime()),
   fVerbose(0),
@@ -84,6 +90,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();
@@ -108,6 +116,7 @@ AliTOFClusterFinderV1::AliTOFClusterFinderV1(AliRunLoader* runLoader, AliTOFcali
   fRecPoints(new TClonesArray("AliTOFcluster", 4000)),
   fNumberOfTofClusters(0),
   fNumberOfTofDigits(0),
+  fNumberOfTofTrgPads(0),
   fkRecoParam(0),//AliTOFReconstructor::GetRecoParam()),
   fMaxDeltaTime(0),//fkRecoParam->GetMaxDeltaTime()),
   fVerbose(0),
@@ -123,6 +132,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();
@@ -147,6 +158,7 @@ AliTOFClusterFinderV1::AliTOFClusterFinderV1(const AliTOFClusterFinderV1 &source
    fRecPoints(source.fRecPoints),
    fNumberOfTofClusters(0),
    fNumberOfTofDigits(0),
+   fNumberOfTofTrgPads(0),
    fkRecoParam(0),//AliTOFReconstructor::GetRecoParam()),
    fMaxDeltaTime(0),//fkRecoParam->GetMaxDeltaTime()),
    fVerbose(0),
@@ -160,6 +172,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();
@@ -178,8 +192,12 @@ 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;
+  fNumberOfTofClusters=source.fNumberOfTofClusters;
+  fNumberOfTofTrgPads=source.fNumberOfTofTrgPads;
+  fNumberOfTofDigits=source.fNumberOfTofDigits;
   fVerbose=source.fVerbose;
   fDecoderVersion=source.fDecoderVersion;
   fTOFcalib=source.fTOFcalib;
@@ -219,7 +237,8 @@ AliTOFClusterFinderV1::~AliTOFClusterFinderV1()
 
   delete fTOFdigits;
 
-  if (fTofClusters || fNumberOfTofClusters) {
+  //if (fTofClusters || fNumberOfTofClusters) {
+  if (fNumberOfTofClusters) {
     for (Int_t ii=0; ii<fNumberOfTofClusters; ii++)
       if (fTofClusters[ii]) fTofClusters[ii]->Delete();
     fNumberOfTofClusters = 0;
@@ -239,11 +258,15 @@ void AliTOFClusterFinderV1::Digits2RecPoints(TTree* digitsTree, TTree* clusterTr
 
   Int_t inholes = 0;
 
+  ResetRecpoint();
+
   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) {
@@ -333,7 +356,7 @@ void AliTOFClusterFinderV1::Digits2RecPoints(TTree* digitsTree, TTree* clusterTr
 
   AliDebug(1,Form("Number of found clusters: %d", fNumberOfTofClusters));
 
-  ResetRecpoint();
+//  ResetRecpoint();
 
   fTOFdigitMap->Clear();
 
@@ -356,6 +379,7 @@ void AliTOFClusterFinderV1::Digits2RecPoints(AliRawReader *rawReader, TTree *clu
   TStopwatch stopwatch;
   stopwatch.Start();
 
+  ResetRecpoint();
 
   AliDebug(2, "TreeD re-creation");
   //TTree *digitsTree = new TTree();
@@ -374,7 +398,7 @@ void AliTOFClusterFinderV1::Digits2RecPoints(AliRawReader *rawReader, TTree *clu
 
   AliDebug(1,Form("Number of found clusters: %d", fNumberOfTofClusters));
 
-  ResetRecpoint();
+//  ResetRecpoint();
 
   fTOFdigitMap->Clear();
 
@@ -470,6 +494,18 @@ void AliTOFClusterFinderV1::Raw2Digits(AliRawReader *rawReader, TTree* digitsTre
       digit[2] = tofRawDatum->GetTOT();
       digit[3] = -1;//tofRawDatum->GetTOF(); //tofND
 
+      // noferini
+      Float_t pos[3];
+      AliTOFGeometry::GetPosPar(detectorIndex, pos);
+      Float_t length = 0.;
+      for (Int_t ic = 0; ic < 3; ic++) length += pos[ic] * pos[ic];
+      length = TMath::Sqrt(length);
+      Float_t timealligned = tdcCorr*24.4 - length * 0.0333564095198152043; // subtract the minimal time in
+      
+      if(status &&  timealligned > -1000 && timealligned < 24000){
+       fNumberOfTofTrgPads++;
+      }
+
       dummy = detectorIndex[3];
       detectorIndex[3] = detectorIndex[4];//padx
       detectorIndex[4] = dummy;//padz
@@ -488,6 +524,7 @@ void AliTOFClusterFinderV1::Raw2Digits(AliRawReader *rawReader, TTree* digitsTre
       last = fDigits->GetEntriesFast();
       new (aDigits[last]) AliTOFdigit(tracks, detectorIndex, digit);
       if (status) fTOFdigitMap->AddDigit(detectorIndex, last);
+      
 
       if (fVerbose==2) {
        if (indexDDL<10) ftxt << "  " << indexDDL;
@@ -578,7 +615,7 @@ void AliTOFClusterFinderV1::FillRecPoint()
          dummy4 = fNumberOfTofClusters;
          FindClustersPerStrip(iSector, iPlate, iStrip, 4); // 4 pads clusters
          if (fNumberOfTofClusters!=dummy4)
-           AliDebug(2, Form(" (4): n1= %5d, n2 = %5", dummy4, fNumberOfTofClusters));
+           AliDebug(2, Form(" (4): n1= %5d, n2 = %5d", dummy4, fNumberOfTofClusters));
 
 
          if (!(fTOFdigitMap->StripDigitCheck(iSector,iPlate,iStrip))) continue;
@@ -588,7 +625,7 @@ void AliTOFClusterFinderV1::FillRecPoint()
          dummy3 = fNumberOfTofClusters;
          FindClustersPerStrip(iSector, iPlate, iStrip, 3); // 3 pads clusters
          if (fNumberOfTofClusters!=dummy3)
-           AliDebug(2, Form(" (3): n1= %5d, n2 = %5", dummy3, fNumberOfTofClusters));
+           AliDebug(2, Form(" (3): n1= %5d, n2 = %5d", dummy3, fNumberOfTofClusters));
 
 
          if (!(fTOFdigitMap->StripDigitCheck(iSector,iPlate,iStrip))) continue;
@@ -598,7 +635,7 @@ void AliTOFClusterFinderV1::FillRecPoint()
          dummy2 = fNumberOfTofClusters;
          FindClustersPerStrip(iSector, iPlate, iStrip, 2); // 2 pads clusters
          if (fNumberOfTofClusters!=dummy2)
-           AliDebug(2, Form(" (2): n1= %5d, n2 =%5", dummy2, fNumberOfTofClusters));
+           AliDebug(2, Form(" (2): n1= %5d, n2 =%5d", dummy2, fNumberOfTofClusters));
 
 
          if (!(fTOFdigitMap->StripDigitCheck(iSector,iPlate,iStrip))) continue;
@@ -659,8 +696,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;
@@ -683,6 +720,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();
@@ -759,8 +798,8 @@ 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...
 
@@ -806,6 +845,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);
@@ -880,8 +921,8 @@ 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];
@@ -927,6 +968,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);
@@ -1034,8 +1077,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];
@@ -1114,7 +1157,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(),
@@ -1147,7 +1190,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(),
@@ -1180,7 +1223,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(),
@@ -1213,7 +1256,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(),
@@ -1325,6 +1368,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;
@@ -1499,8 +1543,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];
@@ -1578,7 +1622,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 +1654,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 +1686,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(),
@@ -1674,7 +1718,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(),
@@ -1759,6 +1803,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;
@@ -1905,8 +1950,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];
@@ -1984,7 +2029,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(),
@@ -2016,7 +2061,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(),
@@ -2048,7 +2093,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(),
@@ -2080,7 +2125,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(),
@@ -2166,6 +2211,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;
@@ -2322,8 +2368,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];
@@ -2549,7 +2595,7 @@ void AliTOFClusterFinderV1::FindClustersPerStrip(Int_t nSector,
                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();
@@ -2615,6 +2661,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;
@@ -2779,6 +2826,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;
@@ -2993,6 +3042,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;
@@ -3184,6 +3234,7 @@ void AliTOFClusterFinderV1::ResetRecpoint()
   //
 
   fNumberOfTofClusters = 0;
+  fNumberOfTofTrgPads = 0;
   if (fRecPoints) fRecPoints->Clear();
 
 }
@@ -3196,6 +3247,7 @@ void AliTOFClusterFinderV1::ResetDigits()
   //
 
   fNumberOfTofDigits = 0;
+  fNumberOfTofTrgPads = 0;
   if (fDigits) fDigits->Clear();
 
 }
@@ -3645,8 +3697,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) {
@@ -3778,5 +3832,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;
 
 }