Time performance improvements in HLT hough transform and huffman decompression of...
authorcvetan <cvetan@f7af4fe6-9843-0410-8265-dc069ae4e863>
Wed, 29 Sep 2004 12:01:18 +0000 (12:01 +0000)
committercvetan <cvetan@f7af4fe6-9843-0410-8265-dc069ae4e863>
Wed, 29 Sep 2004 12:01:18 +0000 (12:01 +0000)
22 files changed:
HLT/hough/AliL3Histogram.h
HLT/hough/AliL3Hough.cxx
HLT/hough/AliL3Hough.h
HLT/hough/AliL3HoughBaseTransformer.cxx
HLT/hough/AliL3HoughBaseTransformer.h
HLT/hough/AliL3HoughMaxFinder.cxx
HLT/hough/AliL3HoughMaxFinder.h
HLT/hough/AliL3HoughTransformerRow.cxx
HLT/hough/AliL3HoughTransformerRow.h
HLT/misc/AliL3DDLDataFileHandler.cxx
HLT/misc/AliL3DDLDataFileHandler.h
HLT/src/AliL3FileHandler.cxx
HLT/src/AliL3MemHandler.cxx
HLT/src/AliL3MemHandler.h
HLT/src/AliL3Transform.cxx
HLT/src/AliL3Transform.h
MONITOR/monitorGDC.cxx
RAW/AliTPCCompression.cxx
RAW/AliTPCCompression.h
RAW/AliTPCHNode.h
RAW/AliTPCRawStream.cxx
RAW/AliTPCRawStream.h

index b6b5f52..4381b8a 100644 (file)
@@ -65,9 +65,11 @@ class AliL3Histogram {
   Int_t GetNbinsX() const {return fNxbins;}
   Int_t GetNbinsY() const {return fNybins;}
   Int_t GetNEntries() const {return fEntries;}
+
+  Int_t *fContent; //!
+  Int_t *GetContentArray() const {return fContent;}
     
  protected:
-  Int_t *fContent; //!
   Char_t fName[100]; // Name of the histogram
   Int_t fNxbins; // Number of bins in the histogram
   Int_t fNybins; // Number of bins in the histogram
index ce26bb2..659c2de 100644 (file)
@@ -32,6 +32,8 @@
 #include "AliL3HoughTrack.h"
 #include "AliL3DDLDataFileHandler.h"
 
+#include "TThread.h"
+
 #if __GNUC__ == 3
 using namespace std;
 #endif
@@ -80,6 +82,7 @@ AliL3Hough::AliL3Hough()
   
   fNEtaSegments     = 0;
   fNPatches         = 0;
+  fLastPatch        =-1;
   fVersion          = 0;
   fCurrentSlice     = 0;
   fEvent            = 0;
@@ -100,6 +103,7 @@ AliL3Hough::AliL3Hough()
     fRunLoader = 0;
 #endif
 #endif
+  fThread = 0;
 }
 
 AliL3Hough::AliL3Hough(Char_t *path,Bool_t binary,Int_t netasegments,Bool_t bit8,Int_t tv,Char_t *infile,Char_t *ptr)
@@ -136,6 +140,7 @@ AliL3Hough::AliL3Hough(Char_t *path,Bool_t binary,Int_t netasegments,Bool_t bit8
     fRunLoader = 0;
 #endif
 #endif
+  fThread = 0;
 }
 
 AliL3Hough::~AliL3Hough()
@@ -161,6 +166,11 @@ AliL3Hough::~AliL3Hough()
   if(fGlobalTracks)
     delete fGlobalTracks;
   //cout << "Cleaned class globaltracks " << endl;
+  if(fThread) {
+    //    fThread->Delete();
+    delete fThread;
+    fThread = 0;
+  }
 }
 
 void AliL3Hough::CleanUp()
@@ -224,7 +234,6 @@ void AliL3Hough::Init(Bool_t doit, Bool_t addhists)
   fAddHistograms = addhists;
 
   fNPatches = AliL3Transform::GetNPatches();
-  
   fHoughTransformer = new AliL3HoughBaseTransformer*[fNPatches];
   fMemHandler = new AliL3MemHandler*[fNPatches];
 
@@ -233,6 +242,8 @@ void AliL3Hough::Init(Bool_t doit, Bool_t addhists)
   
   fGlobalTracks = new AliL3TrackArray("AliL3HoughTrack");
   
+  AliL3HoughBaseTransformer *lasttransformer = 0;
+
   for(Int_t i=0; i<fNPatches; i++)
     {
       switch (fVersion){ //choose Transformer
@@ -252,6 +263,8 @@ void AliL3Hough::Init(Bool_t doit, Bool_t addhists)
        fHoughTransformer[i] = new AliL3HoughTransformer(0,i,fNEtaSegments,kFALSE,kFALSE);
       }
 
+      fHoughTransformer[i]->SetLastTransformer(lasttransformer);
+      lasttransformer = fHoughTransformer[i];
       //      fHoughTransformer[i]->CreateHistograms(fNBinX[i],fLowPt[i],fNBinY[i],-fPhi[i],fPhi[i]);
       fHoughTransformer[i]->CreateHistograms(fNBinX[i],-fLowPt[i],fLowPt[i],fNBinY[i],-fPhi[i],fPhi[i]);
       //fHoughTransformer[i]->CreateHistograms(fLowPt[i],fUpperPt[i],fPtRes[i],fNBinY[i],fPhi[i]);
@@ -508,6 +521,9 @@ void AliL3Hough::ReadData(Int_t slice,Int_t eventnr)
 #endif
        }
 
+      //Set the pointer to the TPCRawStream in case of fast raw data reading
+      fHoughTransformer[i]->SetTPCRawStream(fMemHandler[i]->GetTPCRawStream());
+
       //set input data and init transformer
       fHoughTransformer[i]->SetInputData(ndigits,digits);
       fHoughTransformer[i]->Init(slice,i,fNEtaSegments);
@@ -523,17 +539,33 @@ void AliL3Hough::Transform(Int_t *rowrange)
   
   Double_t initTime,cpuTime;
   initTime = GetCpuTime();
+  Int_t patchorder[6] = {5,2,0,1,3,4}; //The order in which patches are processed
+  //  Int_t patchorder[6] = {0,1,2,3,4,5}; //The order in which patches are processed
+  //  Int_t patchorder[6] = {5,4,3,2,1,0}; //The order in which patches are processed
+  //  Int_t patchorder[6] = {5,2,4,3,1,0}; //The order in which patches are processed
+  fLastPatch=-1;
   for(Int_t i=0; i<fNPatches; i++)
     {
       // In case of Row transformer reset the arrays only once
-      if((fVersion != 4) || (i == 0)) 
-       fHoughTransformer[i]->Reset();//Reset the histograms
+      if((fVersion != 4) || (i == 0)) {
+       fBenchmark->Start("Hough Reset");
+       fHoughTransformer[0]->Reset();//Reset the histograms
+       fBenchmark->Stop("Hough Reset");
+      }
       fBenchmark->Start("Hough Transform");
-      if(!rowrange)
-       fHoughTransformer[i]->TransformCircle();
+      PrepareForNextPatch(patchorder[i]);
+      if(!rowrange) {
+       char buf[256];
+       sprintf(buf,"Patch %d",patchorder[i]);
+       fBenchmark->Start(buf);
+       fHoughTransformer[patchorder[i]]->SetLastPatch(fLastPatch);
+       fHoughTransformer[patchorder[i]]->TransformCircle();
+       fBenchmark->Stop(buf);
+      }
       else
        fHoughTransformer[i]->TransformCircleC(rowrange,1);
       fBenchmark->Stop("Hough Transform");
+      fLastPatch=patchorder[i];
     }
   cpuTime = GetCpuTime() - initTime;
   LOG(AliL3Log::kInformational,"AliL3Hough::Transform()","Timing")
@@ -690,13 +722,12 @@ void AliL3Hough::AddAllHistogramsRows()
   initTime = GetCpuTime();
   fBenchmark->Start("Add HistogramsRows");
 
-  UChar_t *tracknrows = ((AliL3HoughTransformerRow *)fHoughTransformer[0])->GetTrackNRows();
-  UChar_t *trackfirstrow = ((AliL3HoughTransformerRow *)fHoughTransformer[0])->GetTrackFirstRow();
+  UChar_t lastpatchlastrow = AliL3Transform::GetLastRowOnDDL(fLastPatch)+1;
+
   UChar_t *tracklastrow = ((AliL3HoughTransformerRow *)fHoughTransformer[0])->GetTrackLastRow();
 
   for(Int_t i=0; i<fNEtaSegments; i++)
     {
-      UChar_t *rowcount = ((AliL3HoughTransformerRow *)fHoughTransformer[0])->GetRowCount(i);
       UChar_t *gapcount = ((AliL3HoughTransformerRow *)fHoughTransformer[0])->GetGapCount(i);
       UChar_t *currentrowcount = ((AliL3HoughTransformerRow *)fHoughTransformer[0])->GetCurrentRowCount(i);
 
@@ -705,18 +736,25 @@ void AliL3Hough::AddAllHistogramsRows()
       Int_t xmax = hist->GetLastXbin();
       Int_t ymin = hist->GetFirstYbin();
       Int_t ymax = hist->GetLastYbin();
+      Int_t nxbins = hist->GetNbinsX()+2;
 
       for(Int_t ybin=ymin; ybin<=ymax; ybin++)
        {
          for(Int_t xbin=xmin; xbin<=xmax; xbin++)
            {
-             Int_t bin = hist->GetBin(xbin,ybin);
-             if(tracklastrow[bin] > (currentrowcount[bin] + 1))
-                gapcount[bin]++;
-             if(gapcount[bin] < MAX_N_GAPS)
-               if(rowcount[bin] >= MIN_TRACK_LENGTH)
-                 if(((Int_t)rowcount[bin] + (Int_t)gapcount[bin])>=((Int_t)tracknrows[bin]-MAX_MISS_ROWS))
-                   hist->AddBinContent(bin,(rowcount[bin]+trackfirstrow[bin]+159-tracklastrow[bin]));
+             Int_t bin = xbin + ybin*nxbins; //Int_t bin = hist->GetBin(xbin,ybin);
+             if(gapcount[bin] < MAX_N_GAPS) {
+               if(tracklastrow[bin] > lastpatchlastrow) {
+                 if(lastpatchlastrow > currentrowcount[bin])
+                   gapcount[bin] += (lastpatchlastrow-currentrowcount[bin]-1);
+               }
+               else {
+                 if(tracklastrow[bin] > currentrowcount[bin])
+                   gapcount[bin] += (tracklastrow[bin]-currentrowcount[bin]-1);
+               }
+               if(gapcount[bin] < MAX_N_GAPS)
+                 hist->AddBinContent(bin,(159-gapcount[bin]));
+             }
            }
        }
     }
@@ -728,6 +766,112 @@ void AliL3Hough::AddAllHistogramsRows()
     <<"Adding histograms in "<<cpuTime*1000<<" ms"<<ENDLOG;
 }
 
+void AliL3Hough::PrepareForNextPatch(Int_t nextpatch)
+{
+  char buf[256];
+  sprintf(buf,"Prepare For Patch %d",nextpatch);
+  fBenchmark->Start(buf);
+
+  UChar_t lastpatchlastrow;
+  if(fLastPatch == -1)
+    lastpatchlastrow = 0;
+  else
+    lastpatchlastrow = AliL3Transform::GetLastRowOnDDL(fLastPatch)+1;
+  UChar_t nextpatchfirstrow;
+  if(nextpatch==0)
+    nextpatchfirstrow = 0;
+  else
+    nextpatchfirstrow = AliL3Transform::GetFirstRowOnDDL(nextpatch)-1;
+
+  UChar_t *trackfirstrow = ((AliL3HoughTransformerRow *)fHoughTransformer[0])->GetTrackFirstRow();
+  UChar_t *tracklastrow = ((AliL3HoughTransformerRow *)fHoughTransformer[0])->GetTrackLastRow();
+
+  for(Int_t i=0; i<fNEtaSegments; i++)
+    {
+      UChar_t *gapcount = ((AliL3HoughTransformerRow *)fHoughTransformer[0])->GetGapCount(i);
+      UChar_t *currentrowcount = ((AliL3HoughTransformerRow *)fHoughTransformer[0])->GetCurrentRowCount(i);
+      UChar_t *prevbin = ((AliL3HoughTransformerRow *)fHoughTransformer[0])->GetPrevBin(i);
+      UChar_t *nextbin = ((AliL3HoughTransformerRow *)fHoughTransformer[0])->GetNextBin(i);
+      UChar_t *nextrow = ((AliL3HoughTransformerRow *)fHoughTransformer[0])->GetNextRow(i);
+
+      AliL3Histogram *hist = fHoughTransformer[0]->GetHistogram(i);
+      Int_t xmin = hist->GetFirstXbin();
+      Int_t xmax = hist->GetLastXbin();
+      Int_t ymin = hist->GetFirstYbin();
+      Int_t ymax = hist->GetLastYbin();
+      Int_t nxbins = hist->GetNbinsX()+2;
+
+      UChar_t lastyvalue = 0;
+      Int_t endybin = ymin - 1;
+      for(Int_t ybin=ymin; ybin<=ymax; ybin++)
+       {
+         UChar_t lastxvalue = 0;
+         UChar_t maxvalue = 0;
+         Int_t endxbin = xmin - 1;
+         for(Int_t xbin=xmin; xbin<=xmax; xbin++)
+           {
+             Int_t bin = xbin + ybin*nxbins;
+             UChar_t value = 0;
+             if(gapcount[bin] < MAX_N_GAPS) {
+               value = 1;
+               maxvalue = 1;
+               if(tracklastrow[bin] > lastpatchlastrow) {
+                 if(lastpatchlastrow > currentrowcount[bin])
+                   gapcount[bin] += (lastpatchlastrow-currentrowcount[bin]-1);
+               }
+               else {
+                 if(tracklastrow[bin] > currentrowcount[bin])
+                   gapcount[bin] += (tracklastrow[bin]-currentrowcount[bin]-1);
+               }
+               if(trackfirstrow[bin] < nextpatchfirstrow)
+                 currentrowcount[bin] = nextpatchfirstrow;
+               else
+                 currentrowcount[bin] = trackfirstrow[bin];
+             }
+             if(fLastPatch != -1) {
+               if(value > 0)
+                 {
+                   nextbin[xbin + ybin*nxbins] = (UChar_t)xbin;
+                   prevbin[xbin + ybin*nxbins] = (UChar_t)xbin;
+                   if(value > lastxvalue)
+                     {
+                       UChar_t *tempnextbin = nextbin + endxbin + 1 + ybin*nxbins;
+                       memset(tempnextbin,(UChar_t)xbin,xbin-endxbin-1);
+                     }
+                   endxbin = xbin;
+                 }
+               else
+                 {
+                   prevbin[xbin + ybin*nxbins] = (UChar_t)endxbin;
+                 }
+               lastxvalue = value;
+             }
+           }
+         if(fLastPatch != -1) {
+           UChar_t *tempnextbin = nextbin + endxbin + 1 + ybin*nxbins;
+           memset(tempnextbin,(UChar_t)(xmax+1),xmax-endxbin);
+           if(maxvalue > 0)
+             {
+               nextrow[ybin] = (UChar_t)ybin;
+               if(maxvalue > lastyvalue)
+                 {
+                   UChar_t *tempnextrow = nextrow + endybin + 1;
+                   memset(tempnextrow,(UChar_t)ybin,ybin-endybin-1);
+                 }
+               endybin = ybin;
+             }
+           lastyvalue = maxvalue;
+         }
+       }
+      if(fLastPatch != -1) {
+       UChar_t *tempnextrow = nextrow + endybin + 1;
+       memset(tempnextrow,(UChar_t)(ymax+1),ymax-endybin);
+      }
+    }
+
+  fBenchmark->Stop(buf);
+}
+
 void AliL3Hough::AddTracks()
 {
   // Add current slice slice tracks to the global list of found tracks
@@ -780,6 +924,7 @@ void AliL3Hough::FindTrackCandidatesRow()
          if(hist->GetNEntries()==0) continue;
          fPeakFinder->SetHistogram(hist);
          fPeakFinder->SetEtaSlice(j);
+         fPeakFinder->SetTrackLUTs(((AliL3HoughTransformerRow *)tr)->fTrackNRows,((AliL3HoughTransformerRow *)tr)->fTrackFirstRow,((AliL3HoughTransformerRow *)tr)->fTrackLastRow);
 #ifdef do_mc
          LOG(AliL3Log::kInformational,"AliL3Hough::FindTrackCandidates()","")
            <<"Starting "<<j<<" etaslice"<<ENDLOG;
@@ -792,7 +937,7 @@ void AliL3Hough::FindTrackCandidatesRow()
   
       for(Int_t k=0; k<fPeakFinder->GetEntries(); k++)
        {
-         //      if(fPeakFinder->GetWeight(k) < 0) continue;
+         if(fPeakFinder->GetWeight(k) < 0) continue;
          AliL3HoughTrack *track = (AliL3HoughTrack*)fTracks[i]->NextTrack();
          Float_t psi = atan((fPeakFinder->GetXPeak(k)-fPeakFinder->GetYPeak(k))/(AliL3HoughTransformerRow::GetBeta1()-AliL3HoughTransformerRow::GetBeta2()));
          Float_t kappa = 2.0*(fPeakFinder->GetXPeak(k)*cos(psi)-AliL3HoughTransformerRow::GetBeta1()*sin(psi));
@@ -814,7 +959,7 @@ void AliL3Hough::FindTrackCandidatesRow()
 #endif
        }
       LOG(AliL3Log::kInformational,"AliL3Hough::FindTrackCandidates()","")
-       <<"Found "<<fTracks[i]->GetNTracks()<<" tracks in patch "<<i<<ENDLOG;
+       <<"Found "<<fTracks[i]->GetNTracks()<<" tracks in slice "<<fCurrentSlice<<ENDLOG;
       fTracks[i]->QSort();
     }
   fBenchmark->Stop("Find Maxima");
@@ -1090,3 +1235,36 @@ Double_t AliL3Hough::GetCpuTime()
  return tv.tv_sec+(((Double_t)tv.tv_usec)/1000000.);
 }
 
+void *AliL3Hough::ProcessInThread(void *args)
+{
+  AliL3Hough *instance = (AliL3Hough *)args;
+  Int_t minslice = instance->GetMinSlice();
+  Int_t maxslice = instance->GetMaxSlice();
+  for(Int_t i=minslice; i<=maxslice; i++)
+    {
+      instance->ReadData(i,0);
+      instance->Transform();
+      instance->AddAllHistogramsRows();
+      instance->FindTrackCandidatesRow();
+      instance->AddTracks();
+    }
+  return (void *)0;
+}
+
+void AliL3Hough::StartProcessInThread(Int_t minslice,Int_t maxslice)
+{
+  if(!fThread) {
+    char buf[255];
+    sprintf(buf,"houghtrans_%d_%d",minslice,maxslice);
+    SetMinMaxSlices(minslice,maxslice);
+    //    fThread = new TThread(buf,(void (*) (void *))&ProcessInThread,(void *)this);
+    fThread = new TThread(buf,&ProcessInThread,(void *)this);
+    fThread->Run();
+  }
+  return;
+}
+
+Int_t AliL3Hough::WaitForThreadFinish()
+{
+  return TThread::Join(fThread->GetId());
+}
index 02741b8..35d7c06 100644 (file)
@@ -17,6 +17,8 @@ class AliL3HoughIntMerger;
 class AliL3HoughGlobalMerger;
 class AliL3Benchmark;
 
+#include "TThread.h"
+//class TThread;
 #ifdef use_newio
 #include <AliRunLoader.h>
 #endif
@@ -48,6 +50,7 @@ class AliL3Hough {
   void FindTrackCandidatesRow();
   void AddAllHistograms();
   void AddAllHistogramsRows();
+  void PrepareForNextPatch(Int_t nextpatch);
   Int_t Evaluate(Int_t roadwidth=1,Int_t nrowstomiss=1);
   void EvaluatePatch(Int_t i,Int_t roadwidth,Int_t nrowstomiss);
   void WriteTracks(Int_t slice,Char_t *path="./");
@@ -81,6 +84,14 @@ class AliL3Hough {
   AliL3HoughIntMerger *GetInterMerger() {if(!fInterMerger) return 0; return fInterMerger;}
   AliL3MemHandler *GetMemHandler(Int_t i) {if(!fMemHandler[i]) return 0; return fMemHandler[i];}
   AliL3HoughMaxFinder *GetMaxFinder() {return fPeakFinder;}
+
+  //Special methods for executing Hough Transform as a thread
+  static void *ProcessInThread(void *args);
+  void StartProcessInThread(Int_t minslice,Int_t maxslice);
+  Int_t WaitForThreadFinish();
+  void SetMinMaxSlices(Int_t minslice,Int_t maxslice) {fMinSlice = minslice; fMaxSlice = maxslice;} 
+  Int_t GetMinSlice() {return fMinSlice;}
+  Int_t GetMaxSlice() {return fMaxSlice;}
   
  private:
   Char_t *fInputFile;//!
@@ -93,8 +104,9 @@ class AliL3Hough {
   Bool_t fUse8bits; // Use 8 bits or not
   Int_t fNEtaSegments; // Number of eta slices
   Int_t fNPatches; // Number of patches
+  Int_t fLastPatch; //The index of the last processed patch
   Int_t fVersion; //which HoughTransformer to use
-  Int_t fCurrentSlice; // Current eta slice
+  Int_t fCurrentSlice; // Current TPC slice (sector)
   Int_t fEvent; // Current event number
 
   Int_t fPeakThreshold[6]; // Threshold for the peak finder
@@ -113,6 +125,9 @@ class AliL3Hough {
 
   Float_t fZVertex; // Z position of the primary vertex
 
+  Int_t fMinSlice;
+  Int_t fMaxSlice;
+
   AliL3MemHandler **fMemHandler; //!
   AliL3HoughBaseTransformer **fHoughTransformer; //!
   AliL3HoughEval **fEval; //!
@@ -131,6 +146,8 @@ class AliL3Hough {
   void CleanUp();
   Double_t GetCpuTime();
 
+  TThread *fThread;
+
   ClassDef(AliL3Hough,1) //Hough transform base class
 };
 
index d4b8060..c296560 100644 (file)
@@ -33,6 +33,8 @@ AliL3HoughBaseTransformer::AliL3HoughBaseTransformer()
 
   fSlice = 0;
   fPatch = 0;
+  fLastPatch = -1;
+  fLastTransformer = 0;
   fNEtaSegments =0;
   fEtaMin = 0;
   fEtaMax = 0;
@@ -48,6 +50,7 @@ AliL3HoughBaseTransformer::AliL3HoughBaseTransformer(Int_t slice,Int_t patch,Int
 
   fSlice = 0;
   fPatch = 0;
+  fLastPatch = -1;
   fNEtaSegments =0;
   fEtaMin = 0;
   fEtaMax = 0;
@@ -68,6 +71,7 @@ void AliL3HoughBaseTransformer::Init(Int_t slice,Int_t patch,Int_t netasegments,
   //Transformer init
   fSlice = slice;
   fPatch = patch;
+  fLastPatch = -1;
   fNEtaSegments = netasegments;
   fEtaMin = 0;
   fEtaMax = fSlice < 18 ? 1. : -1.;
index 2413c07..c36d1d5 100644 (file)
@@ -18,6 +18,8 @@ typedef struct AliL3TrackIndex AliL3TrackIndex;
 class AliL3DigitRowData;
 class AliL3Histogram;
 
+#include "../RAW/AliTPCRawStream.h"
+
 class AliL3HoughBaseTransformer {
 
  public:
@@ -50,6 +52,8 @@ class AliL3HoughBaseTransformer {
   //Getters
   Int_t GetSlice() const {return fSlice;}
   Int_t GetPatch() const {return fPatch;}
+  Int_t GetLastPatch() const {return fLastPatch;}
+  AliL3HoughBaseTransformer *GetLastTransfromer() const {return fLastTransformer;}
   Int_t GetNEtaSegments() const {return fNEtaSegments;}
   Int_t GetLowerThreshold() const {return fLowerThreshold;}
   Int_t GetUpperThreshold() const {return fUpperThreshold;}
@@ -74,13 +78,22 @@ class AliL3HoughBaseTransformer {
   virtual void Init(Int_t slice=0,Int_t patch=0,Int_t netasegments=100,Int_t nsegs=-1);
   void SetLowerThreshold(Int_t i) {fLowerThreshold = i;}
   void SetUpperThreshold(Int_t i) {fUpperThreshold = i;}
+  void SetLastPatch(Int_t i) {fLastPatch = i;}
+  void SetLastTransformer(AliL3HoughBaseTransformer *transformer) {fLastTransformer = transformer;}
+
+  virtual void SetTPCRawStream(AliTPCRawStream */*rawstream*/){};
 
   virtual void Print(){};
+
+ protected:
+
+  AliL3HoughBaseTransformer *fLastTransformer;//Pointer to the previous hough transformer
   
  private:
 
   Int_t fSlice;//Index of the current slice being processed
   Int_t fPatch;//Index of the current patch being processed
+  Int_t fLastPatch;//Index of the last processed patch
   Int_t fNEtaSegments;//Number of eta slices
   Double_t fEtaMin;//Minimum allowed eta
   Double_t fEtaMax;//Maximum allowed eta
index 64b4d1a..56277f4 100644 (file)
@@ -707,7 +707,9 @@ void AliL3HoughMaxFinder::FindAdaptedRowPeaks(Int_t kappawindow,Int_t xsize,Int_
   Int_t xmax = hist->GetLastXbin();
   Int_t ymin = hist->GetFirstYbin();
   Int_t ymax = hist->GetLastYbin();
-  
+  Int_t nxbins = hist->GetNbinsX()+2;
+  Int_t *content = hist->GetContentArray();
+
   //Start by looking for pre-peaks:
   
   AliL3PreYPeak **localmaxima = new AliL3PreYPeak*[hist->GetNbinsY()];
@@ -716,13 +718,13 @@ void AliL3HoughMaxFinder::FindAdaptedRowPeaks(Int_t kappawindow,Int_t xsize,Int_
   Int_t lastvalue=0,value=0;
   for(Int_t ybin=ymin; ybin<=ymax; ybin++)
     {
-      localmaxima[ybin-ymin] = new AliL3PreYPeak[hist->GetNbinsX()];
+      localmaxima[ybin-ymin] = new AliL3PreYPeak[nxbins-2];
       nmaxs[ybin-ymin] = 0;
       lastvalue = 0;
       Bool_t found = 0;
       for(Int_t xbin=xmin; xbin<=xmax; xbin++)
        {
-         value = hist->GetBinContent(hist->GetBin(xbin,ybin));
+         value = content[xbin + nxbins*ybin]; //value = hist->GetBinContent(xbin + nxbins*ybin); //value = hist->GetBinContent(hist->GetBin(xbin,ybin));
          if(value > 0)
            {
              if((value - lastvalue) > 1)
@@ -862,7 +864,6 @@ void AliL3HoughMaxFinder::FindAdaptedRowPeaks(Int_t kappawindow,Int_t xsize,Int_
     }
 
   //remove fake tracks
-  Int_t nxbins = hist->GetNbinsX()+2;
   
   for(Int_t i = 0; i < (nmaxima - 1); i++)
     {
@@ -891,10 +892,10 @@ void AliL3HoughMaxFinder::FindAdaptedRowPeaks(Int_t kappawindow,Int_t xsize,Int_
              }
            }
          }
-         Int_t firstrow1 = AliL3HoughTransformerRow::GetTrackFirstRow()[xtrack1 + nxbins*ytrack1];
-         Int_t lastrow1 = AliL3HoughTransformerRow::GetTrackLastRow()[xtrack1 + nxbins*ytrack1];
-         Int_t firstrow2 = AliL3HoughTransformerRow::GetTrackFirstRow()[xtrack1 + nxbins*ytrack1];
-         Int_t lastrow2 = AliL3HoughTransformerRow::GetTrackLastRow()[xtrack1 + nxbins*ytrack1];
+         Int_t firstrow1 = fTrackFirstRow[xtrack1 + nxbins*ytrack1];
+         Int_t lastrow1 = fTrackLastRow[xtrack1 + nxbins*ytrack1];
+         Int_t firstrow2 = fTrackFirstRow[xtrack1 + nxbins*ytrack1];
+         Int_t lastrow2 = fTrackLastRow[xtrack1 + nxbins*ytrack1];
          Int_t firstrow,lastrow;
          if(firstrow1 < firstrow2)
            firstrow = firstrow2;
@@ -1005,7 +1006,7 @@ void AliL3HoughMaxFinder::FindAdaptedRowPeaks(Int_t kappawindow,Int_t xsize,Int_
   fN2PeaksPrevEtaSlice = fNPeaks;
 
   for(Int_t i=0; i<hist->GetNbinsY(); i++)
-    delete [] localmaxima[i];
+    delete localmaxima[i];
 
   delete [] localmaxima;
   delete [] nmaxs;
index 64ec6cf..9b5a562 100644 (file)
@@ -47,6 +47,7 @@ class AliL3HoughMaxFinder {
   void SetGradient(Float_t x,Float_t y) {fGradX=x; fGradY=y;}
   void SetThreshold(Int_t f) {fThreshold = f;}
   void SetHistogram(AliL3Histogram *hist) {fCurrentHisto = hist;}
+  void SetTrackLUTs(UChar_t *tracknrows, UChar_t *trackfirstrow, UChar_t *tracklastrow) {fTrackNRows = tracknrows; fTrackFirstRow = trackfirstrow; fTrackLastRow = tracklastrow;}
   void SetEtaSlice(Int_t etaslice) {fCurrentEtaSlice = etaslice;}
   
   //Getters:
@@ -64,6 +65,10 @@ class AliL3HoughMaxFinder {
   Int_t fThreshold; // Threshold for Peak Finder
   Int_t fCurrentEtaSlice; // Current eta slice being processed
   AliL3Histogram *fCurrentHisto;  //!
+
+  UChar_t *fTrackNRows; //!
+  UChar_t *fTrackFirstRow; //!
+  UChar_t *fTrackLastRow; //!
   
   Float_t fGradX; // Gradient threshold inside Peak Finder 
   Float_t fGradY; // Gradient threshold inside Peak Finder 
index 43faf71..b43f3cd 100644 (file)
@@ -26,124 +26,211 @@ using namespace std;
 
 ClassImp(AliL3HoughTransformerRow)
 
-UChar_t **AliL3HoughTransformerRow::fgRowCount = 0;
-UChar_t **AliL3HoughTransformerRow::fgGapCount = 0;
-UChar_t **AliL3HoughTransformerRow::fgCurrentRowCount = 0;
-#ifdef do_mc
-AliL3TrackIndex **AliL3HoughTransformerRow::fgTrackID = 0;
-#endif
-UChar_t *AliL3HoughTransformerRow::fgTrackNRows = 0;
-UChar_t *AliL3HoughTransformerRow::fgTrackFirstRow = 0;
-UChar_t *AliL3HoughTransformerRow::fgTrackLastRow = 0;
-
-Float_t AliL3HoughTransformerRow::fgBeta1 = AliL3Transform::Row2X(79)/pow(AliL3Transform::Row2X(79),2);
-Float_t AliL3HoughTransformerRow::fgBeta2 = (AliL3Transform::Row2X(158)+6.0)/pow((AliL3Transform::Row2X(158)+6.0),2);
+Float_t AliL3HoughTransformerRow::fgBeta1 = 1.0/AliL3Transform::Row2X(79);
+Float_t AliL3HoughTransformerRow::fgBeta2 = 1.0/(AliL3Transform::Row2X(158)*(1.0+tan(AliL3Transform::Pi()*10/180)*tan(AliL3Transform::Pi()*10/180)));
 
 AliL3HoughTransformerRow::AliL3HoughTransformerRow()
 {
   //Default constructor
   fParamSpace = 0;
-  fDoMC = kFALSE;;
 
-  fLUTforwardZ=0;
-  fLUTforwardZ2=0;
-  fLUTbackwardZ=0;
-  fLUTbackwardZ2=0;
+  fGapCount = 0;
+  fCurrentRowCount = 0;
+#ifdef do_mc
+  fTrackID = 0;
+#endif
+  fTrackNRows = 0;
+  fTrackFirstRow = 0;
+  fTrackLastRow = 0;
+  fInitialGapCount = 0;
+
+  fPrevBin = 0;
+  fNextBin = 0;
+  fNextRow = 0;
+
+  fStartPadParams = 0;
+  fEndPadParams = 0;
+  fLUTr2 = 0;
+  fLUTforwardZ = 0;
+  fLUTforwardZ2 = 0;
+  fLUTbackwardZ = 0;
+  fLUTbackwardZ2 = 0;
+
 }
 
 AliL3HoughTransformerRow::AliL3HoughTransformerRow(Int_t slice,Int_t patch,Int_t netasegments,Bool_t /*DoMC*/,Float_t zvertex) : AliL3HoughBaseTransformer(slice,patch,netasegments,zvertex)
 {
   //Normal constructor
   fParamSpace = 0;
-  fDoMC = kFALSE;
-  fDoMC=kFALSE;
+
+  fGapCount = 0;
+  fCurrentRowCount = 0;
 #ifdef do_mc
-  fDoMC = kTRUE;
+  fTrackID = 0;
 #endif
 
-  fLUTforwardZ=0;
-  fLUTforwardZ2=0;
-  fLUTbackwardZ=0;
-  fLUTbackwardZ2=0;
+  fTrackNRows = 0;
+  fTrackFirstRow = 0;
+  fTrackLastRow = 0;
+  fInitialGapCount = 0;
+
+  fPrevBin = 0;
+  fNextBin = 0;
+  fNextRow = 0;
+
+  fStartPadParams = 0;
+  fEndPadParams = 0;
+  fLUTr2 = 0;
+  fLUTforwardZ = 0;
+  fLUTforwardZ2 = 0;
+  fLUTbackwardZ = 0;
+  fLUTbackwardZ2 = 0;
+
 }
 
 AliL3HoughTransformerRow::~AliL3HoughTransformerRow()
 {
   //Destructor
   DeleteHistograms();
+  if(fLastTransformer) return;
 #ifdef do_mc
-  if(fgTrackID)
+  if(fTrackID)
     {
       for(Int_t i=0; i<GetNEtaSegments(); i++)
        {
-         if(!fgTrackID[i]) continue;
-         delete [] fgTrackID[i];
+         if(!fTrackID[i]) continue;
+         delete fTrackID[i];
        }
-      delete [] fgTrackID;
-      fgTrackID = 0;
+      delete [] fTrackID;
+      fTrackID = 0;
     }
 #endif
 
-  if(fgRowCount)
+  if(fGapCount)
     {
       for(Int_t i=0; i<GetNEtaSegments(); i++)
        {
-         if(!fgRowCount[i]) continue;
-         delete [] fgRowCount[i];
+         if(!fGapCount[i]) continue;
+         delete [] fGapCount[i];
        }
-      delete [] fgRowCount;
-      fgRowCount = 0;
+      delete [] fGapCount;
+      fGapCount = 0;
     }
-  if(fgGapCount)
+  if(fCurrentRowCount)
     {
       for(Int_t i=0; i<GetNEtaSegments(); i++)
        {
-         if(!fgGapCount[i]) continue;
-         delete [] fgGapCount[i];
+         if(fCurrentRowCount[i])
+           delete [] fCurrentRowCount[i];
        }
-      delete [] fgGapCount;
-      fgGapCount = 0;
+      delete [] fCurrentRowCount;
+      fCurrentRowCount = 0;
+    }
+  if(fTrackNRows)
+    {
+      delete [] fTrackNRows;
+      fTrackNRows = 0;
+    }
+  if(fTrackFirstRow)
+    {
+      delete [] fTrackFirstRow;
+      fTrackFirstRow = 0;
+    }
+  if(fTrackLastRow)
+    {
+      delete [] fTrackLastRow;
+      fTrackLastRow = 0;
+    }
+  if(fInitialGapCount)
+    {
+      delete [] fInitialGapCount;
+      fInitialGapCount = 0;
     }
-  if(fgCurrentRowCount)
+  if(fPrevBin)
     {
       for(Int_t i=0; i<GetNEtaSegments(); i++)
        {
-         if(fgCurrentRowCount[i])
-           delete [] fgCurrentRowCount[i];
+         if(!fPrevBin[i]) continue;
+         delete [] fPrevBin[i];
+       }
+      delete [] fPrevBin;
+      fPrevBin = 0;
+    }
+  if(fNextBin)
+    {
+      for(Int_t i=0; i<GetNEtaSegments(); i++)
+       {
+         if(!fNextBin[i]) continue;
+         delete [] fNextBin[i];
+       }
+      delete [] fNextBin;
+      fNextBin = 0;
+    }
+  if(fNextRow)
+    {
+      for(Int_t i=0; i<GetNEtaSegments(); i++)
+       {
+         if(!fNextRow[i]) continue;
+         delete [] fNextRow[i];
+       }
+      delete [] fNextRow;
+      fNextRow = 0;
+    }
+  if(fStartPadParams)
+    {
+      for(Int_t i = AliL3Transform::GetFirstRow(0); i<=AliL3Transform::GetLastRow(5); i++)
+       {
+         if(!fStartPadParams[i]) continue;
+         delete [] fStartPadParams[i];
+       }
+      delete [] fStartPadParams;
+      fStartPadParams = 0;
+    }
+  if(fEndPadParams)
+    {
+      for(Int_t i = AliL3Transform::GetFirstRow(0); i<=AliL3Transform::GetLastRow(5); i++)
+       {
+         if(!fEndPadParams[i]) continue;
+         delete [] fEndPadParams[i];
+       }
+      delete [] fEndPadParams;
+      fEndPadParams = 0;
+    }
+  if(fLUTr2)
+    {
+      for(Int_t i = AliL3Transform::GetFirstRow(0); i<=AliL3Transform::GetLastRow(5); i++)
+       {
+         if(!fLUTr2[i]) continue;
+         delete [] fLUTr2[i];
        }
-      delete [] fgCurrentRowCount;
-      fgCurrentRowCount = 0;
+      delete [] fLUTr2;
+      fLUTr2 = 0;
     }
-  if(fgTrackNRows)
+  if(fLUTforwardZ)
     {
-      delete [] fgTrackNRows;
-      fgTrackNRows = 0;
+      delete[] fLUTforwardZ;
+      fLUTforwardZ=0;
     }
-  if(fgTrackFirstRow)
+  if(fLUTforwardZ2)
     {
-      delete [] fgTrackFirstRow;
-      fgTrackFirstRow = 0;
+      delete[] fLUTforwardZ2;
+      fLUTforwardZ2=0;
     }
-  if(fgTrackLastRow)
+  if(fLUTbackwardZ)
     {
-      delete [] fgTrackLastRow;
-      fgTrackLastRow = 0;
+      delete[] fLUTbackwardZ;
+      fLUTbackwardZ=0;
+    }
+  if(fLUTbackwardZ2)
+    {
+      delete[] fLUTbackwardZ2;
+      fLUTbackwardZ2=0;
     }
 }
 
 void AliL3HoughTransformerRow::DeleteHistograms()
 {
   // Clean up
-  delete[] fLUTforwardZ;
-  delete[] fLUTforwardZ2;
-  delete[] fLUTbackwardZ;
-  delete[] fLUTbackwardZ2;
-
-  fLUTforwardZ=0;
-  fLUTforwardZ2=0;
-  fLUTbackwardZ=0;
-  fLUTbackwardZ2=0;
-
   if(!fParamSpace)
     return;
   for(Int_t i=0; i<GetNEtaSegments(); i++)
@@ -154,6 +241,13 @@ void AliL3HoughTransformerRow::DeleteHistograms()
   delete [] fParamSpace;
 }
 
+struct AliL3TrackLength {
+  Bool_t fIsFilled;
+  UInt_t fFirstRow;
+  UInt_t fLastRow;
+  Float_t fTrackPt;
+};
+
 void AliL3HoughTransformerRow::CreateHistograms(Int_t nxbin,Float_t xmin,Float_t xmax,
                                                Int_t nybin,Float_t ymin,Float_t ymax)
 {
@@ -169,145 +263,372 @@ void AliL3HoughTransformerRow::CreateHistograms(Int_t nxbin,Float_t xmin,Float_t
       sprintf(histname,"paramspace_%d",i);
       fParamSpace[i] = new AliL3Histogram(histname,"",nxbin,xmin,xmax,nybin,ymin,ymax);
     }
-  
+
+  if(fLastTransformer) {
+
+    fGapCount = ((AliL3HoughTransformerRow *)fLastTransformer)->fGapCount;
+    fCurrentRowCount = ((AliL3HoughTransformerRow *)fLastTransformer)->fCurrentRowCount;
 #ifdef do_mc
-  if(fDoMC)
-    {
-      AliL3Histogram *hist = fParamSpace[0];
-      Int_t ncellsx = (hist->GetNbinsX()+3)/2;
-      Int_t ncellsy = (hist->GetNbinsY()+3)/2;
-      Int_t ncells = ncellsx*ncellsy;
-      if(!fgTrackID)
-       {
-         LOG(AliL3Log::kInformational,"AliL3HoughTransformerRow::CreateHistograms()","")
-           <<"Transformer: Allocating "<<GetNEtaSegments()*ncells*sizeof(AliL3TrackIndex)<<" bytes to fgTrackID"<<ENDLOG;
-         fgTrackID = new AliL3TrackIndex*[GetNEtaSegments()];
-         for(Int_t i=0; i<GetNEtaSegments(); i++)
-           fgTrackID[i] = new AliL3TrackIndex[ncells];
-       }
-    }
+    fTrackID = ((AliL3HoughTransformerRow *)fLastTransformer)->fTrackID;
+#endif
+    fTrackNRows = ((AliL3HoughTransformerRow *)fLastTransformer)->fTrackNRows;
+    fTrackFirstRow = ((AliL3HoughTransformerRow *)fLastTransformer)->fTrackFirstRow;
+    fTrackLastRow = ((AliL3HoughTransformerRow *)fLastTransformer)->fTrackLastRow;
+    fInitialGapCount = ((AliL3HoughTransformerRow *)fLastTransformer)->fInitialGapCount;
+
+    fPrevBin = ((AliL3HoughTransformerRow *)fLastTransformer)->fPrevBin;
+    fNextBin = ((AliL3HoughTransformerRow *)fLastTransformer)->fNextBin;
+    fNextRow = ((AliL3HoughTransformerRow *)fLastTransformer)->fNextRow;
+
+    fStartPadParams = ((AliL3HoughTransformerRow *)fLastTransformer)->fStartPadParams;
+    fEndPadParams = ((AliL3HoughTransformerRow *)fLastTransformer)->fEndPadParams;
+    fLUTr2 = ((AliL3HoughTransformerRow *)fLastTransformer)->fLUTr2;
+    fLUTforwardZ = ((AliL3HoughTransformerRow *)fLastTransformer)->fLUTforwardZ;
+    fLUTforwardZ2 = ((AliL3HoughTransformerRow *)fLastTransformer)->fLUTforwardZ2;
+    fLUTbackwardZ = ((AliL3HoughTransformerRow *)fLastTransformer)->fLUTbackwardZ;
+    fLUTbackwardZ2 = ((AliL3HoughTransformerRow *)fLastTransformer)->fLUTbackwardZ2;
+
+    return;
+  }
+#ifdef do_mc
+  {
+    AliL3Histogram *hist = fParamSpace[0];
+    Int_t ncellsx = (hist->GetNbinsX()+3)/2;
+    Int_t ncellsy = (hist->GetNbinsY()+3)/2;
+    Int_t ncells = ncellsx*ncellsy;
+    if(!fTrackID)
+      {
+       LOG(AliL3Log::kInformational,"AliL3HoughTransformerRow::CreateHistograms()","")
+         <<"Transformer: Allocating "<<GetNEtaSegments()*ncells*sizeof(AliL3TrackIndex)<<" bytes to fTrackID"<<ENDLOG;
+       fTrackID = new AliL3TrackIndex*[GetNEtaSegments()];
+       for(Int_t i=0; i<GetNEtaSegments(); i++)
+         fTrackID[i] = new AliL3TrackIndex[ncells];
+      }
+  }
 #endif
   AliL3Histogram *hist = fParamSpace[0];
   Int_t ncells = (hist->GetNbinsX()+2)*(hist->GetNbinsY()+2);
-  if(!fgRowCount)
+  if(!fGapCount)
     {
       LOG(AliL3Log::kInformational,"AliL3HoughTransformerRow::CreateHistograms()","")
-       <<"Transformer: Allocating "<<GetNEtaSegments()*ncells*sizeof(UChar_t)<<" bytes to fgRowCount"<<ENDLOG;
-      fgRowCount = new UChar_t*[GetNEtaSegments()];
+       <<"Transformer: Allocating "<<GetNEtaSegments()*ncells*sizeof(UChar_t)<<" bytes to fGapCount"<<ENDLOG;
+      fGapCount = new UChar_t*[GetNEtaSegments()];
       for(Int_t i=0; i<GetNEtaSegments(); i++)
-       fgRowCount[i] = new UChar_t[ncells];
+       fGapCount[i] = new UChar_t[ncells];
     }
-  if(!fgGapCount)
+  if(!fCurrentRowCount)
     {
       LOG(AliL3Log::kInformational,"AliL3HoughTransformerRow::CreateHistograms()","")
-       <<"Transformer: Allocating "<<GetNEtaSegments()*ncells*sizeof(UChar_t)<<" bytes to fgGapCount"<<ENDLOG;
-      fgGapCount = new UChar_t*[GetNEtaSegments()];
+       <<"Transformer: Allocating "<<GetNEtaSegments()*ncells*sizeof(UChar_t)<<" bytes to fCurrentRowCount"<<ENDLOG;
+      fCurrentRowCount = new UChar_t*[GetNEtaSegments()];
       for(Int_t i=0; i<GetNEtaSegments(); i++)
-       fgGapCount[i] = new UChar_t[ncells];
+       fCurrentRowCount[i] = new UChar_t[ncells];
     }
-  if(!fgCurrentRowCount)
+  if(!fPrevBin)
     {
       LOG(AliL3Log::kInformational,"AliL3HoughTransformerRow::CreateHistograms()","")
-       <<"Transformer: Allocating "<<GetNEtaSegments()*ncells*sizeof(UChar_t)<<" bytes to fgCurrentRowCount"<<ENDLOG;
-      fgCurrentRowCount = new UChar_t*[GetNEtaSegments()];
+       <<"Transformer: Allocating "<<GetNEtaSegments()*ncells*sizeof(UChar_t)<<" bytes to fPrevBin"<<ENDLOG;
+      fPrevBin = new UChar_t*[GetNEtaSegments()];
       for(Int_t i=0; i<GetNEtaSegments(); i++)
-       fgCurrentRowCount[i] = new UChar_t[ncells];
+       fPrevBin[i] = new UChar_t[ncells];
+    }
+  if(!fNextBin)
+    {
+      LOG(AliL3Log::kInformational,"AliL3HoughTransformerRow::CreateHistograms()","")
+       <<"Transformer: Allocating "<<GetNEtaSegments()*ncells*sizeof(UChar_t)<<" bytes to fNextBin"<<ENDLOG;
+      fNextBin = new UChar_t*[GetNEtaSegments()];
+      for(Int_t i=0; i<GetNEtaSegments(); i++)
+       fNextBin[i] = new UChar_t[ncells];
+    }
+  Int_t ncellsy = hist->GetNbinsY()+2;
+  if(!fNextRow)
+    {
+      LOG(AliL3Log::kInformational,"AliL3HoughTransformerRow::CreateHistograms()","")
+       <<"Transformer: Allocating "<<GetNEtaSegments()*ncellsy*sizeof(UChar_t)<<" bytes to fNextRow"<<ENDLOG;
+      fNextRow = new UChar_t*[GetNEtaSegments()];
+      for(Int_t i=0; i<GetNEtaSegments(); i++)
+       fNextRow[i] = new UChar_t[ncellsy];
     }
 
-  if(!fgTrackNRows)
+  if(!fTrackNRows)
     {
       LOG(AliL3Log::kInformational,"AliL3HoughTransformerRow::CreateHistograms()","")
-       <<"Transformer: Allocating "<<ncells*sizeof(UChar_t)<<" bytes to fgTrackNRows"<<ENDLOG;
-      fgTrackNRows = new UChar_t[ncells];
+       <<"Transformer: Allocating "<<ncells*sizeof(UChar_t)<<" bytes to fTrackNRows"<<ENDLOG;
+      fTrackNRows = new UChar_t[ncells];
+      LOG(AliL3Log::kInformational,"AliL3HoughTransformerRow::CreateHistograms()","")
+       <<"Transformer: Allocating "<<ncells*sizeof(UChar_t)<<" bytes to fTrackFirstRow"<<ENDLOG;
+      fTrackFirstRow = new UChar_t[ncells];
       LOG(AliL3Log::kInformational,"AliL3HoughTransformerRow::CreateHistograms()","")
-       <<"Transformer: Allocating "<<ncells*sizeof(UChar_t)<<" bytes to fgTrackFirstRow"<<ENDLOG;
-      fgTrackFirstRow = new UChar_t[ncells];
+       <<"Transformer: Allocating "<<ncells*sizeof(UChar_t)<<" bytes to fTrackLastRow"<<ENDLOG;
+      fTrackLastRow = new UChar_t[ncells];
       LOG(AliL3Log::kInformational,"AliL3HoughTransformerRow::CreateHistograms()","")
-       <<"Transformer: Allocating "<<ncells*sizeof(UChar_t)<<" bytes to fgTrackLastRow"<<ENDLOG;
-      fgTrackLastRow = new UChar_t[ncells];
+       <<"Transformer: Allocating "<<ncells*sizeof(UChar_t)<<" bytes to fInitialGapCount"<<ENDLOG;
+      fInitialGapCount = new UChar_t[ncells];
+
 
       AliL3HoughTrack track;
       Int_t xmin = hist->GetFirstXbin();
       Int_t xmax = hist->GetLastXbin();
+      Int_t xmiddle = (hist->GetNbinsX()+1)/2;
       Int_t ymin = hist->GetFirstYbin();
       Int_t ymax = hist->GetLastYbin();
       Int_t nxbins = hist->GetNbinsX()+2;
+      Int_t nxgrid = (hist->GetNbinsX()+3)/2+1;
+      Int_t nygrid = hist->GetNbinsY()+3;
+
+      AliL3TrackLength *tracklength = new AliL3TrackLength[nxgrid*nygrid];
+      memset(tracklength,0,nxgrid*nygrid*sizeof(AliL3TrackLength));
+
       for(Int_t ybin=ymin-1; ybin<=(ymax+1); ybin++)
        {
-         for(Int_t xbin=xmin-1; xbin<=(xmax+1); xbin++)
+         for(Int_t xbin=xmin-1; xbin<=xmiddle; xbin++)
            {
-             //cvetan: we get strange warning on gcc-2.95
-             //warning: large integer implicitly truncated to unsigned type
-             fgTrackNRows[xbin + ybin*nxbins] = 99999;
-             for(Int_t deltay = -1; deltay <= 1; deltay += 2) {
-               for(Int_t deltax = -1; deltax <= 1; deltax += 2) {
-               
-                 Float_t xtrack = hist->GetPreciseBinCenterX((Float_t)xbin+0.5*(Float_t)deltax);
-                 Float_t ytrack = hist->GetPreciseBinCenterY((Float_t)ybin+0.5*(Float_t)deltay);
-
-                 Float_t psi = atan((xtrack-ytrack)/(fgBeta1-fgBeta2));
-                 Float_t kappa = 2.0*(xtrack*cos(psi)-fgBeta1*sin(psi));
-                 track.SetTrackParameters(kappa,psi,1);
-                 Bool_t firstrow = kFALSE;
+             fTrackNRows[xbin + ybin*nxbins] = 255;
+             for(Int_t deltay = 0; deltay <= 1; deltay++) {
+               for(Int_t deltax = 0; deltax <= 1; deltax++) {
+
+                 AliL3TrackLength *curtracklength = &tracklength[(xbin + deltax) + (ybin + deltay)*nxgrid];
                  UInt_t maxfirstrow = 0;
                  UInt_t maxlastrow = 0;
-                 UInt_t curfirstrow = 0;
-                 UInt_t curlastrow = 0;
-                 for(Int_t j=AliL3Transform::GetFirstRow(0); j<=AliL3Transform::GetLastRow(5); j++)
-                   {
-                     Float_t hit[3];
-                     if(!track.GetCrossingPoint(j,hit)) continue;
-                     AliL3Transform::LocHLT2Raw(hit,0,j);
-                     if(hit[1]>=0 && hit[1]<AliL3Transform::GetNPads(j))
-                       {
-                         if(!firstrow) {
-                           curfirstrow = j;
-                           firstrow = kTRUE;
+                 Float_t maxtrackpt = 0;
+                 if(curtracklength->fIsFilled) {
+                   maxfirstrow = curtracklength->fFirstRow;
+                   maxlastrow = curtracklength->fLastRow;
+                   maxtrackpt = curtracklength->fTrackPt;
+                 }
+                 else {
+                   Float_t xtrack = hist->GetPreciseBinCenterX((Float_t)xbin+0.5*(Float_t)(2*deltax-1));
+                   Float_t ytrack = hist->GetPreciseBinCenterY((Float_t)ybin+0.5*(Float_t)(2*deltay-1));
+
+                   Float_t psi = atan((xtrack-ytrack)/(fgBeta1-fgBeta2));
+                   Float_t kappa = 2.0*(xtrack*cos(psi)-fgBeta1*sin(psi));
+                   track.SetTrackParameters(kappa,psi,1);
+                   Bool_t firstrow = kFALSE;
+                   UInt_t curfirstrow = 0;
+                   UInt_t curlastrow = 0;
+
+                   Double_t centerx = track.GetCenterX();
+                   Double_t centery = track.GetCenterY();
+                   Double_t radius = track.GetRadius();
+
+                   for(Int_t j=AliL3Transform::GetFirstRow(0); j<=AliL3Transform::GetLastRow(5); j++)
+                     {
+                       Float_t hit[3];
+                       //                    if(!track.GetCrossingPoint(j,hit)) continue;
+                       hit[0] = AliL3Transform::Row2X(j);
+                       Double_t aa = (hit[0] - centerx)*(hit[0] - centerx);
+                       Double_t r2 = radius*radius;
+                       if(aa > r2)
+                         continue;
+
+                       Double_t aa2 = sqrt(r2 - aa);
+                       Double_t y1 = centery + aa2;
+                       Double_t y2 = centery - aa2;
+                       hit[1] = y1;
+                       if(fabs(y2) < fabs(y1)) hit[1] = y2;
+                       hit[2] = 0;
+                       
+                       AliL3Transform::LocHLT2Raw(hit,0,j);
+                       hit[1] += 0.5;
+                       if(hit[1]>=0 && hit[1]<AliL3Transform::GetNPads(j))
+                         {
+                           if(!firstrow) {
+                             curfirstrow = j;
+                             firstrow = kTRUE;
+                           }
+                           curlastrow = j;
                          }
-                         curlastrow = j;
-                       }
-                     else {
-                       if(firstrow) {
-                         firstrow = kFALSE;
-                         if((curlastrow-curfirstrow) >= (maxlastrow-maxfirstrow)) {
-                           maxfirstrow = curfirstrow;
-                           maxlastrow = curlastrow;
+                       else {
+                         if(firstrow) {
+                           firstrow = kFALSE;
+                           if((curlastrow-curfirstrow) >= (maxlastrow-maxfirstrow)) {
+                             maxfirstrow = curfirstrow;
+                             maxlastrow = curlastrow;
+                           }
                          }
                        }
                      }
+                   if((curlastrow-curfirstrow) >= (maxlastrow-maxfirstrow)) {
+                     maxfirstrow = curfirstrow;
+                     maxlastrow = curlastrow;
                    }
-                 if((curlastrow-curfirstrow) >= (maxlastrow-maxfirstrow)) {
-                   maxfirstrow = curfirstrow;
-                   maxlastrow = curlastrow;
+
+                   maxtrackpt = track.GetPt();
+
+                   curtracklength->fIsFilled = kTRUE;
+                   curtracklength->fFirstRow = maxfirstrow;
+                   curtracklength->fLastRow = maxlastrow;
+                   curtracklength->fTrackPt = maxtrackpt;
+                   
                  }
-                 if((maxlastrow-maxfirstrow) < fgTrackNRows[xbin + ybin*nxbins]) {
-                   fgTrackNRows[xbin + ybin*nxbins] = maxlastrow-maxfirstrow;
-                   fgTrackFirstRow[xbin + ybin*nxbins] = maxfirstrow;
-                   fgTrackLastRow[xbin + ybin*nxbins] = maxlastrow;
+                 if((maxlastrow-maxfirstrow) < fTrackNRows[xbin + ybin*nxbins]) {
+                   fTrackNRows[xbin + ybin*nxbins] = maxlastrow-maxfirstrow;
+                   fInitialGapCount[xbin + ybin*nxbins] = 1;
+                    if((maxlastrow-maxfirstrow+1)<MIN_TRACK_LENGTH)
+                      fInitialGapCount[xbin + ybin*nxbins] = MAX_N_GAPS+1;
+                   if(maxtrackpt < 0.9*0.1*AliL3Transform::GetSolenoidField())
+                     fInitialGapCount[xbin + ybin*nxbins] = MAX_N_GAPS;
+                   fTrackFirstRow[xbin + ybin*nxbins] = maxfirstrow;
+                   fTrackLastRow[xbin + ybin*nxbins] = maxlastrow;
+
+                   Int_t xmirror = xmax - xbin + 1;
+                   Int_t ymirror = ymax - ybin + 1;
+                   fTrackNRows[xmirror + ymirror*nxbins] = fTrackNRows[xbin + ybin*nxbins];
+                   fInitialGapCount[xmirror + ymirror*nxbins] = fInitialGapCount[xbin + ybin*nxbins];
+                   fTrackFirstRow[xmirror + ymirror*nxbins] = fTrackFirstRow[xbin + ybin*nxbins];
+                   fTrackLastRow[xmirror + ymirror*nxbins] = fTrackLastRow[xbin + ybin*nxbins];
                  }
                }
              }
-             //              cout<<" fgTrackNRows "<<xbin<<" "<<ybin<<" "<<(Int_t)fgTrackNRows[xbin + ybin*nxbins]<<" "<<endl;
+             //              cout<<" fTrackNRows "<<(Int_t)fInitialGapCount[xbin + ybin*nxbins]<<" "<<xbin<<" "<<ybin<<" "<<(Int_t)fTrackNRows[xbin + ybin*nxbins]<<" "<<(Int_t)fTrackFirstRow[xbin + ybin*nxbins]<<" "<<(Int_t)fTrackLastRow[xbin + ybin*nxbins]<<" "<<endl;
            }
        }
+      delete tracklength;
     }
 
+  if(!fStartPadParams)
+    {
+      Int_t nrows = AliL3Transform::GetLastRow(5) - AliL3Transform::GetFirstRow(0) + 1;
+      LOG(AliL3Log::kInformational,"AliL3HoughTransformerRow::CreateHistograms()","")
+       <<"Transformer: Allocating about "<<nrows*100*sizeof(AliL3PadHoughParams)<<" bytes to fStartPadParams"<<ENDLOG;
+      fStartPadParams = new AliL3PadHoughParams*[nrows];
+      LOG(AliL3Log::kInformational,"AliL3HoughTransformerRow::CreateHistograms()","")
+       <<"Transformer: Allocating about "<<nrows*100*sizeof(AliL3PadHoughParams)<<" bytes to fEndPadParams"<<ENDLOG;
+      fEndPadParams = new AliL3PadHoughParams*[nrows];
+      LOG(AliL3Log::kInformational,"AliL3HoughTransformerRow::CreateHistograms()","")
+       <<"Transformer: Allocating about "<<nrows*100*sizeof(Float_t)<<" bytes to fLUTr2"<<ENDLOG;
+      fLUTr2 = new Float_t*[nrows];
+
+      Float_t beta1 = fgBeta1;
+      Float_t beta2 = fgBeta2;
+      Float_t beta1minusbeta2 = fgBeta1 - fgBeta2;
+      Float_t ymin = hist->GetYmin();
+      Float_t histbin = hist->GetBinWidthY();
+      Float_t xmin = hist->GetXmin();
+      Float_t xmax = hist->GetXmax();
+      Float_t xbin = (xmax-xmin)/hist->GetNbinsX();
+      Int_t firstbinx = hist->GetFirstXbin();
+      Int_t lastbinx = hist->GetLastXbin();
+      Int_t nbinx = hist->GetNbinsX()+2;
+      Int_t firstbin = hist->GetFirstYbin();
+      Int_t lastbin = hist->GetLastYbin();
+      for(Int_t i=AliL3Transform::GetFirstRow(0); i<=AliL3Transform::GetLastRow(5); i++)
+       {
+         Int_t npads = AliL3Transform::GetNPads(i);
+         Int_t ipatch = AliL3Transform::GetPatch(i);
+         Double_t padpitch = AliL3Transform::GetPadPitchWidth(ipatch);
+         Float_t x = AliL3Transform::Row2X(i);
+         Float_t x2 = x*x;
+
+         fStartPadParams[i] = new AliL3PadHoughParams[npads];
+         fEndPadParams[i] = new AliL3PadHoughParams[npads];
+         fLUTr2[i] = new Float_t[npads];
+         for(Int_t pad=0; pad<npads; pad++)
+           {
+             Float_t y = (pad-0.5*(npads-1))*padpitch;
+             fLUTr2[i][pad] = x2 + y*y;
+             Float_t starty = (pad-0.5*npads)*padpitch;
+             Float_t r1 = x2 + starty*starty;
+             Float_t xoverr1 = x/r1;
+             Float_t startyoverr1 = starty/r1;
+             Float_t endy = (pad-0.5*(npads-2))*padpitch;
+             Float_t r2 = x2 + endy*endy; 
+             Float_t xoverr2 = x/r2;
+             Float_t endyoverr2 = endy/r2;
+             Float_t a1 = beta1minusbeta2/(xoverr1-beta2);
+             Float_t b1 = (xoverr1-beta1)/(xoverr1-beta2);
+             Float_t a2 = beta1minusbeta2/(xoverr2-beta2);
+             Float_t b2 = (xoverr2-beta1)/(xoverr2-beta2);
+
+             Float_t alpha1 = (a1*startyoverr1+b1*ymin-xmin)/xbin;
+             Float_t deltaalpha1 = b1*histbin/xbin;
+             if(b1<0)
+               alpha1 += deltaalpha1;
+             Float_t alpha2 = (a2*endyoverr2+b2*ymin-xmin)/xbin;
+             Float_t deltaalpha2 = b2*histbin/xbin;
+             if(b2>=0)
+               alpha2 += deltaalpha2;
+
+             fStartPadParams[i][pad].fAlpha = alpha1;
+             fStartPadParams[i][pad].fDeltaAlpha = deltaalpha1;
+             fEndPadParams[i][pad].fAlpha = alpha2;
+             fEndPadParams[i][pad].fDeltaAlpha = deltaalpha2;
+
+             //Find the first and last bin rows to be filled
+             Bool_t binfound1 = kFALSE;
+             Bool_t binfound2 = kFALSE;
+             Int_t firstbin1 = lastbin;
+             Int_t firstbin2 = lastbin;
+             Int_t lastbin1 = firstbin;
+             Int_t lastbin2 = firstbin;
+             for(Int_t b=firstbin; b<=lastbin; b++, alpha1 += deltaalpha1, alpha2 += deltaalpha2)
+               {
+                 Int_t binx1 = 1 + (Int_t)alpha1;
+                 if(binx1<=lastbinx) {
+                   UChar_t initialgapcount; 
+                   if(binx1>=firstbinx)
+                     initialgapcount = fInitialGapCount[binx1 + b*nbinx];
+                   else
+                     initialgapcount = fInitialGapCount[firstbinx + b*nbinx];
+                   if(initialgapcount != MAX_N_GAPS) {
+                     if(!binfound1) {
+                       firstbin1 = b;
+                       binfound1 = kTRUE;
+                     }
+                     lastbin1 = b;
+                   }
+                 }
+                 Int_t binx2 = 1 + (Int_t)alpha2;
+                 if(binx2>=firstbin) {
+                   UChar_t initialgapcount; 
+                   if(binx2<=lastbinx)
+                     initialgapcount = fInitialGapCount[binx2 + b*nbinx];
+                   else
+                     initialgapcount = fInitialGapCount[lastbinx + b*nbinx];
+                   if(initialgapcount != MAX_N_GAPS) {
+                     if(!binfound2) {
+                       firstbin2 = b;
+                       binfound2 = kTRUE;
+                     }
+                     lastbin2 = b;
+                   }
+                 }
+               }
+             fStartPadParams[i][pad].fFirstBin=firstbin1;
+             fStartPadParams[i][pad].fLastBin=lastbin1;
+             fEndPadParams[i][pad].fFirstBin=firstbin2;
+             fEndPadParams[i][pad].fLastBin=lastbin2;
+           }
+       }
+    }
   //create lookup table for z of the digits
-  Int_t ntimebins = AliL3Transform::GetNTimeBins();
-  fLUTforwardZ = new Float_t[ntimebins];
-  fLUTforwardZ2 = new Float_t[ntimebins];
-  fLUTbackwardZ = new Float_t[ntimebins];
-  fLUTbackwardZ2 = new Float_t[ntimebins];
-  for(Int_t i=0; i<ntimebins; i++){
-    Float_t z;
-    z=AliL3Transform::GetZFast(0,i,GetZVertex());
-    fLUTforwardZ[i]=z;
-    fLUTforwardZ2[i]=z*z;
-    z=AliL3Transform::GetZFast(18,i,GetZVertex());
-    fLUTbackwardZ[i]=z;
-    fLUTbackwardZ2[i]=z*z;
-  }
-
+  if(!fLUTforwardZ)
+    {
+      Int_t ntimebins = AliL3Transform::GetNTimeBins();
+      LOG(AliL3Log::kInformational,"AliL3HoughTransformerRow::CreateHistograms()","")
+       <<"Transformer: Allocating "<<ntimebins*sizeof(Float_t)<<" bytes to fLUTforwardZ"<<ENDLOG;
+      fLUTforwardZ = new Float_t[ntimebins];
+      LOG(AliL3Log::kInformational,"AliL3HoughTransformerRow::CreateHistograms()","")
+       <<"Transformer: Allocating "<<ntimebins*sizeof(Float_t)<<" bytes to fLUTforwardZ2"<<ENDLOG;
+      fLUTforwardZ2 = new Float_t[ntimebins];
+      LOG(AliL3Log::kInformational,"AliL3HoughTransformerRow::CreateHistograms()","")
+       <<"Transformer: Allocating "<<ntimebins*sizeof(Float_t)<<" bytes to fLUTbackwardZ"<<ENDLOG;
+      fLUTbackwardZ = new Float_t[ntimebins];
+      LOG(AliL3Log::kInformational,"AliL3HoughTransformerRow::CreateHistograms()","")
+       <<"Transformer: Allocating "<<ntimebins*sizeof(Float_t)<<" bytes to fLUTbackwardZ2"<<ENDLOG;
+      fLUTbackwardZ2 = new Float_t[ntimebins];
+      for(Int_t i=0; i<ntimebins; i++){
+       Float_t z;
+       z=AliL3Transform::GetZFast(0,i,GetZVertex());
+       fLUTforwardZ[i]=z;
+       fLUTforwardZ2[i]=z*z;
+       z=AliL3Transform::GetZFast(18,i,GetZVertex());
+       fLUTbackwardZ[i]=z;
+       fLUTbackwardZ2[i]=z*z;
+      }
+    }
 }
 
 void AliL3HoughTransformerRow::Reset()
@@ -325,24 +646,21 @@ void AliL3HoughTransformerRow::Reset()
     fParamSpace[i]->Reset();
   
 #ifdef do_mc
-  if(fDoMC)
-    {
-      AliL3Histogram *hist = fParamSpace[0];
-      Int_t ncellsx = (hist->GetNbinsX()+3)/2;
-      Int_t ncellsy = (hist->GetNbinsY()+3)/2;
-      Int_t ncells = ncellsx*ncellsy;
-      for(Int_t i=0; i<GetNEtaSegments(); i++)
-       memset(fgTrackID[i],0,ncells*sizeof(AliL3TrackIndex));
-    }
+  {
+    AliL3Histogram *hist = fParamSpace[0];
+    Int_t ncellsx = (hist->GetNbinsX()+3)/2;
+    Int_t ncellsy = (hist->GetNbinsY()+3)/2;
+    Int_t ncells = ncellsx*ncellsy;
+    for(Int_t i=0; i<GetNEtaSegments(); i++)
+      memset(fTrackID[i],0,ncells*sizeof(AliL3TrackIndex));
+  }
 #endif
   AliL3Histogram *hist = fParamSpace[0];
   Int_t ncells = (hist->GetNbinsX()+2)*(hist->GetNbinsY()+2);
   for(Int_t i=0; i<GetNEtaSegments(); i++)
     {
-      memset(fgRowCount[i],0,ncells*sizeof(UChar_t));
-      memset(fgGapCount[i],1,ncells*sizeof(UChar_t));
-      //      memset(fgCurrentRowCount[i],160,ncells*sizeof(UChar_t));
-      memcpy(fgCurrentRowCount[i],fgTrackFirstRow,ncells*sizeof(UChar_t));
+      memcpy(fGapCount[i],fInitialGapCount,ncells*sizeof(UChar_t));
+      memcpy(fCurrentRowCount[i],fTrackFirstRow,ncells*sizeof(UChar_t));
     }
 }
 
@@ -374,22 +692,16 @@ Double_t AliL3HoughTransformerRow::GetEta(Int_t etaindex,Int_t /*slice*/) const
   return eta;
 }
 
-struct AliL3EtaRow {
-  UChar_t fStartPad; //First pad in the cluster
-  UChar_t fEndPad; //Last pad in the cluster
-  Bool_t fIsFound; //Is the cluster already found
-  Float_t fStartY; //Y position of the first pad in the cluster
-#ifdef do_mc
-  Int_t fMcLabels[MaxTrack]; //Array to store mc labels inside cluster
-#endif
-};
-
 void AliL3HoughTransformerRow::TransformCircle()
 {
+  if(GetDataPointer())
+    TransformCircleFromDigitArray();
+  else if(fTPCRawStream)
+    TransformCircleFromRawStream();
+}
+void AliL3HoughTransformerRow::TransformCircleFromDigitArray()
+{
   //Do the Hough Transform
-  Float_t beta1 = fgBeta1;
-  Float_t beta2 = fgBeta2;
-  Float_t beta1minusbeta2 = fgBeta1 - fgBeta2;
 
   Int_t netasegments = GetNEtaSegments();
   Double_t etamin = GetEtaMin();
@@ -399,16 +711,9 @@ void AliL3HoughTransformerRow::TransformCircle()
 
   //Assumes that all the etaslice histos are the same!
   AliL3Histogram *h = fParamSpace[0];
-  Float_t ymin = h->GetYmin();
-  //Float_t y_max = h->GetYmax();
-  Float_t histbin = h->GetBinWidthY();
-  Int_t firstbin = h->GetFirstYbin();
-  Int_t lastbin = h->GetLastYbin();
-  Float_t xmin = h->GetXmin();
-  Float_t xmax = h->GetXmax();
-  Float_t xbin = (xmax-xmin)/h->GetNbinsX();
-  Int_t firstbinx = h->GetFirstXbin()-1;
-  Int_t lastbinx = h->GetLastXbin()+1;
+  Int_t firstbiny = h->GetFirstYbin();
+  Int_t firstbinx = h->GetFirstXbin();
+  Int_t lastbinx = h->GetLastXbin();
   Int_t nbinx = h->GetNbinsX()+2;
 
   UChar_t lastpad;
@@ -424,31 +729,29 @@ void AliL3HoughTransformerRow::TransformCircle()
     }
 
   Int_t ipatch = GetPatch();
-  Double_t padpitch = AliL3Transform::GetPadPitchWidth(ipatch);
+  Int_t ilastpatch = GetLastPatch();
   Int_t islice = GetSlice();
-  Float_t *fLUTz;
-  Float_t *fLUTz2;
+  Float_t *lutz;
+  Float_t *lutz2;
   if(islice < 18) {
-    fLUTz = fLUTforwardZ;
-    fLUTz2 = fLUTforwardZ2;
+    lutz = fLUTforwardZ;
+    lutz2 = fLUTforwardZ2;
   }
   else {
-    fLUTz = fLUTbackwardZ;
-    fLUTz2 = fLUTbackwardZ2;
+    lutz = fLUTbackwardZ;
+    lutz2 = fLUTbackwardZ2;
   }
 
   //Loop over the padrows:
   for(UChar_t i=AliL3Transform::GetFirstRow(ipatch); i<=AliL3Transform::GetLastRow(ipatch); i++)
     {
-      Int_t npads = AliL3Transform::GetNPads((Int_t)i)-1;
-
       lastpad = 255;
       //Flush eta clusters array
       memset(etaclust,0,netasegments*sizeof(AliL3EtaRow));  
 
       Float_t x = AliL3Transform::Row2X((Int_t)i);
       Float_t x2 = x*x;
-      Float_t y=0,r2=0;
+      Float_t radius2=0;
 
       //Get the data on this padrow:
       AliL3DigitData *digPt = tempPt->fDigitData;
@@ -470,17 +773,18 @@ void AliL3HoughTransformerRow::TransformCircle()
 
          if(pad != lastpad)
            {
-             y = (pad-0.5*npads)*padpitch;
-             Float_t y2 = y*y;
-             r2 = x2 + y2;
+             radius2 = fLUTr2[(Int_t)i][(Int_t)pad];
              lastetaindex = -1;
            }
 
          //Transform data to local cartesian coordinates:
-         Float_t z = fLUTz[(Int_t)time];
-         Float_t z2 = fLUTz2[(Int_t)time];
+         Float_t z = lutz[(Int_t)time];
+         Float_t z2 = lutz2[(Int_t)time];
+         // Acceptance cut : to be verified
+         //      if(radius2<0.72406166*z2) continue;
+         if(x2<0.8464*z2) continue;
          //Calculate the eta:
-         Double_t r = sqrt(r2+z2);
+         Double_t r = sqrt(radius2+z2);
          Double_t eta = 0.5 * log((r+z)/(r-z));
          //Get the corresponding index, which determines which histogram to fill:
          Int_t etaindex = (Int_t)((eta-etamin)/etaslice);
@@ -497,23 +801,9 @@ void AliL3HoughTransformerRow::TransformCircle()
            {
              etaclust[etaindex].fStartPad = pad;
              etaclust[etaindex].fEndPad = pad;
-             etaclust[etaindex].fStartY = y - padpitch/2.0;
              etaclust[etaindex].fIsFound = 1;
 #ifdef do_mc
-             if(fDoMC)
-               {
-                 for(Int_t t=0; t<3; t++)
-                   {
-                     Int_t label = digPt[j].fTrackID[t];
-                     if(label < 0) break;
-                     UInt_t c;
-                     for(c=0; c<(MaxTrack-1); c++)
-                       if(etaclust[etaindex].fMcLabels[c] == label || etaclust[etaindex].fMcLabels[c] == 0)
-                         break;
-                     //                      if(c == MaxTrack-1) cerr<<"AliL3HoughTransformer::TransformCircle : Cluster array reached maximum!! "<<c<<endl;
-                     etaclust[etaindex].fMcLabels[c] = label;
-                   }
-               }
+             FillClusterMCLabels(digPt[j],etaclust[etaindex]);
 #endif
              continue;
            }
@@ -523,141 +813,19 @@ void AliL3HoughTransformerRow::TransformCircle()
                {
                  etaclust[etaindex].fEndPad = pad;
 #ifdef do_mc
-                 if(fDoMC)
-                   {
-                     for(Int_t t=0; t<3; t++)
-                       {
-                         Int_t label = digPt[j].fTrackID[t];
-                         if(label < 0) break;
-                         UInt_t c;
-                         for(c=0; c<(MaxTrack-1); c++)
-                           if(etaclust[etaindex].fMcLabels[c] == label || etaclust[etaindex].fMcLabels[c] == 0)
-                             break;
-                         //                      if(c == MaxTrack-1) cerr<<"AliL3HoughTransformer::TransformCircle : Cluster array reached maximum!! "<<c<<endl;
-                         etaclust[etaindex].fMcLabels[c] = label;
-                       }
-                   }
+                 FillClusterMCLabels(digPt[j],etaclust[etaindex]);
 #endif
                }
              else
                {
-                 Bool_t fillcluster = kTRUE;
-                 if(fillcluster) {
-
-                 UChar_t *nrows = fgRowCount[etaindex];
-                 UChar_t *ngaps = fgGapCount[etaindex];
-                 UChar_t *currentrow = fgCurrentRowCount[etaindex];
-                 UChar_t *lastrow = fgTrackLastRow;
-
-                 //Do the transformation:
-                 Float_t starty = etaclust[etaindex].fStartY;
-                 if(etaclust[etaindex].fStartPad == 0)
-                   starty -= 0.0*padpitch;
-                 Float_t r1 = x2 + starty*starty;
-                 Float_t xoverr1 = x/r1;
-                 Float_t startyoverr1 = starty/r1;
-                 Float_t endy = (etaclust[etaindex].fEndPad-0.5*(npads-1))*padpitch;
-                 if(etaclust[etaindex].fEndPad == npads)
-                   endy += 0.0*padpitch;
-                 Float_t r2 = x2 + endy*endy; 
-                 Float_t xoverr2 = x/r2;
-                 Float_t endyoverr2 = endy/r2;
-                 Float_t a1 = beta1minusbeta2/(xoverr1-beta2);
-                 Float_t b1 = (xoverr1-beta1)/(xoverr1-beta2);
-                 Float_t a2 = beta1minusbeta2/(xoverr2-beta2);
-                 Float_t b2 = (xoverr2-beta1)/(xoverr2-beta2);
-
-                 Float_t alpha1 = (a1*startyoverr1+b1*ymin-xmin)/xbin;
-                 Float_t deltaalpha1 = b1*histbin/xbin;
-                 if(b1<0)
-                   alpha1 += deltaalpha1;
-                 Float_t alpha2 = (a2*endyoverr2+b2*ymin-xmin)/xbin;
-                 Float_t deltaalpha2 = b2*histbin/xbin;
-                 if(b2>=0)
-                   alpha2 += deltaalpha2;
-
-                 //Fill the histogram along the phirange
-                 for(Int_t b=firstbin; b<=lastbin; b++, alpha1 += deltaalpha1, alpha2 += deltaalpha2)
-                   {
-                     Int_t binx1 = 1 + (Int_t)alpha1;
-                     if(binx1>lastbinx) continue;
-                     if(binx1<firstbinx) binx1 = firstbinx;
-                     Int_t binx2 = 1 + (Int_t)alpha2;
-                     if(binx2<firstbinx) continue;
-                     if(binx2>lastbinx) binx2 = lastbinx;
-#ifdef do_mc
-                     if(binx2<binx1) {
-                       LOG(AliL3Log::kWarning,"AliL3HoughTransformerRow::TransformCircle()","")
-                         <<"Wrong filling "<<binx1<<" "<<binx2<<" "<<i<<" "<<x<<" "<<starty<<" "<<endy<<ENDLOG;
-                     }
-#endif
-                     Int_t tempbin = b*nbinx;
-                     UChar_t *nrows2 = nrows + tempbin;
-                     UChar_t *ngaps2 = ngaps + tempbin;
-                     UChar_t *currentrow2 = currentrow + tempbin;
-                     UChar_t *lastrow2 = lastrow + tempbin;
-                     for(Int_t bin=binx1;bin<=binx2;bin++)
-                       {
-                         if(ngaps2[bin] < MAX_N_GAPS) {
-                           if(i > (currentrow2[bin] + MAX_GAP_SIZE) && i < lastrow2[bin]) {
-                             ngaps2[bin] = MAX_N_GAPS;
-                             continue;
-                           }
-                           if(i > currentrow2[bin] && i < lastrow2[bin])
-                             {
-                               nrows2[bin]++;
-                               if(i > (currentrow2[bin] + 1))
-                                 ngaps2[bin]++;
-                               currentrow2[bin]=i;
-                             }
-#ifdef do_mc
-                           if(fDoMC)
-                             {
-                               for(UInt_t t=0;t<(MaxTrack-1); t++)
-                                 {
-                                   Int_t label = etaclust[etaindex].fMcLabels[t];
-                                   if(label == 0) break;
-                                   UInt_t c;
-                                   Int_t tempbin2 = ((Int_t)(b/2))*((Int_t)((nbinx+1)/2)) + (Int_t)(bin/2);
-                                   for(c=0; c<(MaxTrack-1); c++)
-                                     if(fgTrackID[etaindex][tempbin2].fLabel[c] == label || fgTrackID[etaindex][tempbin2].fNHits[c] == 0)
-                                       break;
-                                   //                              if(c == MaxTrack-1) cerr<<"AliL3HoughTransformer::TransformCircle : Array reached maximum!! "<<c<<endl;
-                                   fgTrackID[etaindex][tempbin2].fLabel[c] = label;
-                                   if(fgTrackID[etaindex][tempbin2].fCurrentRow[c] != i) {
-                                     fgTrackID[etaindex][tempbin2].fNHits[c]++;
-                                     fgTrackID[etaindex][tempbin2].fCurrentRow[c] = i;
-                                   }
-                                 }
-                             }
-#endif
-                         }
-                       }
-                   }
-                 //End of the transformation
-
-                 }
+                 FillCluster(i,etaindex,etaclust,ilastpatch,firstbinx,lastbinx,nbinx,firstbiny);
 
                  etaclust[etaindex].fStartPad = pad;
                  etaclust[etaindex].fEndPad = pad;
-                 etaclust[etaindex].fStartY = y - padpitch/2.0;
 
 #ifdef do_mc
-                 if(fDoMC)
-                   {
-                     memset(etaclust[etaindex].fMcLabels,0,MaxTrack);
-                     for(Int_t t=0; t<3; t++)
-                       {
-                         Int_t label = digPt[j].fTrackID[t];
-                         if(label < 0) break;
-                         UInt_t c;
-                         for(c=0; c<(MaxTrack-1); c++)
-                           if(etaclust[etaindex].fMcLabels[c] == label || etaclust[etaindex].fMcLabels[c] == 0)
-                             break;
-                         //                      if(c == MaxTrack-1) cerr<<"AliL3HoughTransformer::TransformCircle : Cluster array reached maximum!! "<<c<<endl;
-                         etaclust[etaindex].fMcLabels[c] = label;
-                       }
-                   }
+                 memset(etaclust[etaindex].fMcLabels,0,MaxTrack);
+                 FillClusterMCLabels(digPt[j],etaclust[etaindex]);
 #endif
                }
            }
@@ -670,98 +838,7 @@ void AliL3HoughTransformerRow::TransformCircle()
          //Check for empty row
          if((etaclust[etaindex].fStartPad == 0) && (etaclust[etaindex].fEndPad == 0)) continue;
 
-         UChar_t *nrows = fgRowCount[etaindex];
-         UChar_t *ngaps = fgGapCount[etaindex];
-         UChar_t *currentrow = fgCurrentRowCount[etaindex];
-         UChar_t *lastrow = fgTrackLastRow;
-
-         //Do the transformation:
-         Float_t starty = etaclust[etaindex].fStartY;
-         if(etaclust[etaindex].fStartPad == 0)
-           starty -= 0.0*padpitch;
-         Float_t r1 = x2 + starty*starty; 
-         Float_t xoverr1 = x/r1;
-         Float_t startyoverr1 = starty/r1;
-         Float_t endy = (etaclust[etaindex].fEndPad-0.5*(npads-1))*padpitch;
-         if(etaclust[etaindex].fEndPad == npads)
-           endy += 0.0*padpitch;
-         Float_t r2 = x2 + endy*endy; 
-         Float_t xoverr2 = x/r2;
-         Float_t endyoverr2 = endy/r2;
-         Float_t a1 = beta1minusbeta2/(xoverr1-beta2);
-         Float_t b1 = (xoverr1-beta1)/(xoverr1-beta2);
-         Float_t a2 = beta1minusbeta2/(xoverr2-beta2);
-         Float_t b2 = (xoverr2-beta1)/(xoverr2-beta2);
-
-         Float_t alpha1 = (a1*startyoverr1+b1*ymin-xmin)/xbin;
-         Float_t deltaalpha1 = b1*histbin/xbin;
-         if(b1<0)
-           alpha1 += deltaalpha1;
-         Float_t alpha2 = (a2*endyoverr2+b2*ymin-xmin)/xbin;
-         Float_t deltaalpha2 = b2*histbin/xbin;
-         if(b2>=0)
-           alpha2 += deltaalpha2;
-
-         //Fill the histogram along the phirange
-         for(Int_t b=firstbin; b<=lastbin; b++, alpha1 += deltaalpha1, alpha2 += deltaalpha2)
-           {
-             Int_t binx1 = 1 + (Int_t)alpha1;
-             if(binx1>lastbinx) continue;
-             if(binx1<firstbinx) binx1 = firstbinx;
-             Int_t binx2 = 1 + (Int_t)alpha2;
-             if(binx2<firstbinx) continue;
-             if(binx2>lastbinx) binx2 = lastbinx;
-#ifdef do_mc
-             if(binx2<binx1) {
-               LOG(AliL3Log::kWarning,"AliL3HoughTransformerRow::TransformCircle()","")
-                 <<"Wrong filling "<<binx1<<" "<<binx2<<" "<<i<<" "<<x<<" "<<starty<<" "<<endy<<ENDLOG;
-             }
-#endif
-             Int_t tempbin = b*nbinx;
-             UChar_t *nrows2 = nrows + tempbin;
-             UChar_t *ngaps2 = ngaps + tempbin;
-             UChar_t *currentrow2 = currentrow + tempbin;
-             UChar_t *lastrow2 = lastrow + tempbin;
-             for(Int_t bin=binx1;bin<=binx2;bin++)
-               {
-                 if(ngaps2[bin] < MAX_N_GAPS) {
-                   if(i > (currentrow2[bin] + MAX_GAP_SIZE) && i < lastrow2[bin]) {
-                     ngaps2[bin] = MAX_N_GAPS;
-                     continue;
-                   }
-                   if(i > currentrow2[bin] && i < lastrow2[bin])
-                     {
-                       nrows2[bin]++;
-                       if(i > (currentrow2[bin] + 1))
-                         ngaps2[bin]++;
-                       currentrow2[bin]=i;
-                     }
-#ifdef do_mc
-                   if(fDoMC)
-                     {
-                       for(UInt_t t=0;t<(MaxTrack-1); t++)
-                         {
-                           Int_t label = etaclust[etaindex].fMcLabels[t];
-                           if(label == 0) break;
-                           UInt_t c;
-                           Int_t tempbin2 = ((Int_t)(b/2))*((Int_t)((nbinx+1)/2)) + (Int_t)(bin/2);
-                           for(c=0; c<(MaxTrack-1); c++)
-                             if(fgTrackID[etaindex][tempbin2].fLabel[c] == label || fgTrackID[etaindex][tempbin2].fNHits[c] == 0)
-                               break;
-                           //                      if(c == MaxTrack-1) cout<<"AliL3HoughTransformer::TransformCircle : Array reached maximum!! "<<c<<endl;
-                           fgTrackID[etaindex][tempbin2].fLabel[c] = label;
-                           if(fgTrackID[etaindex][tempbin2].fCurrentRow[c] != i) {
-                             fgTrackID[etaindex][tempbin2].fNHits[c]++;
-                             fgTrackID[etaindex][tempbin2].fCurrentRow[c] = i;
-                           }
-                         }
-                     }
-#endif
-                 }
-               }
-           }
-         //End of the transformation
-
+         FillCluster(i,etaindex,etaclust,ilastpatch,firstbinx,lastbinx,nbinx,firstbiny);
        }
 
       //Move the data pointer to the next padrow:
@@ -771,17 +848,191 @@ void AliL3HoughTransformerRow::TransformCircle()
   delete [] etaclust;
 }
 
-Int_t AliL3HoughTransformerRow::GetTrackID(Int_t etaindex,Double_t alpha1,Double_t alpha2) const
+void AliL3HoughTransformerRow::TransformCircleFromRawStream()
 {
-  // Returns the MC label for a given peak found in the Hough space
-  if(!fDoMC)
+  //Do the Hough Transform
+
+  Int_t netasegments = GetNEtaSegments();
+  Double_t etamin = GetEtaMin();
+  Double_t etaslice = (GetEtaMax() - etamin)/netasegments;
+
+  Int_t lowerthreshold = GetLowerThreshold();
+
+  //Assumes that all the etaslice histos are the same!
+  AliL3Histogram *h = fParamSpace[0];
+  Int_t firstbiny = h->GetFirstYbin();
+  Int_t firstbinx = h->GetFirstXbin();
+  Int_t lastbinx = h->GetLastXbin();
+  Int_t nbinx = h->GetNbinsX()+2;
+
+  Int_t lastetaindex;
+  AliL3EtaRow *etaclust = new AliL3EtaRow[netasegments];
+
+  if(!fTPCRawStream)
     {
-      LOG(AliL3Log::kWarning,"AliL3HoughTransformerRow::GetTrackID","Data")
-       <<"Flag switched off"<<ENDLOG;
-      return -1;
+      LOG(AliL3Log::kError,"AliL3HoughTransformer::TransformCircle","Data")
+       <<"No input data "<<ENDLOG;
+      return;
+    }
+
+  Int_t ipatch = GetPatch();
+  UChar_t rowmin = AliL3Transform::GetFirstRowOnDDL(ipatch);
+  UChar_t rowmax = AliL3Transform::GetLastRowOnDDL(ipatch);
+  //  Int_t ntimebins = AliL3Transform::GetNTimeBins();
+  Int_t ilastpatch = GetLastPatch();
+  Int_t islice = GetSlice();
+  Float_t *lutz;
+  Float_t *lutz2;
+  if(islice < 18) {
+    lutz = fLUTforwardZ;
+    lutz2 = fLUTforwardZ2;
+  }
+  else {
+    lutz = fLUTbackwardZ;
+    lutz2 = fLUTbackwardZ2;
+  }
+
+  //Flush eta clusters array
+  memset(etaclust,0,netasegments*sizeof(AliL3EtaRow));  
+
+  UChar_t i=0;
+  Int_t npads=0;
+  Float_t x=0;
+  Float_t x2=0;
+  Float_t radius2=0;
+  UChar_t pad=0;
+
+  //Loop over the rawdata:
+  while (fTPCRawStream->Next()) {
+    
+    if(fTPCRawStream->IsNewSector() || fTPCRawStream->IsNewRow()) {
+
+      //Write remaining clusters
+      for(Int_t etaindex = 0;etaindex < netasegments;etaindex++)
+       {
+         //Check for empty row
+         if((etaclust[etaindex].fStartPad == 0) && (etaclust[etaindex].fEndPad == 0)) continue;
+      
+         FillCluster(i,etaindex,etaclust,ilastpatch,firstbinx,lastbinx,nbinx,firstbiny);
+       }
+
+      Int_t sector=fTPCRawStream->GetSector();
+      Int_t row=fTPCRawStream->GetRow();
+      Int_t slice,srow;
+      AliL3Transform::Sector2Slice(slice,srow,sector,row);
+      if(slice!=islice){
+       LOG(AliL3Log::kError,"AliL3DDLDataFileHandler::DDLDigits2Memory","Slice")
+         <<AliL3Log::kDec<<"Found slice "<<slice<<", expected "<<islice<<ENDLOG;
+       continue;
+      }
+    
+      i=(UChar_t)srow;
+      npads = AliL3Transform::GetNPads(srow)-1;
+
+      //Flush eta clusters array
+      memset(etaclust,0,netasegments*sizeof(AliL3EtaRow));  
+
+      x = AliL3Transform::Row2X((Int_t)i);
+      x2 = x*x;
+      radius2=0;
+
+    }
+
+    if((i<rowmin)||(i>rowmax))continue;
+
+    //    cout<<" Starting row "<<(UInt_t)i<<endl;
+    //Loop over the data on this padrow:
+    if(fTPCRawStream->IsNewRow() || fTPCRawStream->IsNewPad()) {
+      pad=fTPCRawStream->GetPad();
+      /*
+      if((pad<0)||(pad>=(npads+1))){
+       LOG(AliL3Log::kError,"AliL3DDLDataFileHandler::DDLDigits2Memory","Pad")
+         <<AliL3Log::kDec<<"Pad value out of bounds "<<pad<<" "
+         <<npads+1<<ENDLOG;
+       continue;
+      }
+      */
+      radius2 = fLUTr2[(Int_t)i][(Int_t)pad];
+      lastetaindex = -1;
+    } 
+
+    UShort_t time=fTPCRawStream->GetTime();
+    /*
+    if((time<0)||(time>=ntimebins)){
+      LOG(AliL3Log::kError,"AliL3DDLDataFileHandler::DDLDigits2Memory","Time")
+       <<AliL3Log::kDec<<"Time out of bounds "<<time<<" "
+       <<AliL3Transform::GetNTimeBins()<<ENDLOG;
+      continue;
+    }
+    */
+
+    if(fTPCRawStream->GetSignal() <= lowerthreshold)
+      continue;
+
+    //Transform data to local cartesian coordinates:
+    Float_t z = lutz[(Int_t)time];
+    Float_t z2 = lutz2[(Int_t)time];
+    //    if(radius2<0.72406166*z2) continue;
+    if(x2<0.8464*z2) continue;
+    //Calculate the eta:
+    Double_t r = sqrt(radius2+z2);
+    Double_t eta = 0.5 * log((r+z)/(r-z));
+    //Get the corresponding index, which determines which histogram to fill:
+    Int_t etaindex = (Int_t)((eta-etamin)/etaslice);
+
+#ifndef do_mc
+    if(etaindex == lastetaindex) continue;
+#endif
+    //   cout<<" Digit at patch "<<ipatch<<" row "<<i<<" pad "<<(Int_t)pad<<" time "<<time<<" etaslice "<<etaindex<<endl;
+         
+    if(etaindex < 0 || etaindex >= netasegments)
+      continue;
+    
+    if(!etaclust[etaindex].fIsFound)
+      {
+       etaclust[etaindex].fStartPad = pad;
+       etaclust[etaindex].fEndPad = pad;
+       etaclust[etaindex].fIsFound = 1;
+       continue;
+      }
+    else
+      {
+       if(pad <= (etaclust[etaindex].fEndPad + 1))
+         {
+           etaclust[etaindex].fEndPad = pad;
+         }
+       else
+         {
+           FillCluster(i,etaindex,etaclust,ilastpatch,firstbinx,lastbinx,nbinx,firstbiny);
+           
+           etaclust[etaindex].fStartPad = pad;
+           etaclust[etaindex].fEndPad = pad;
+           
+         }
+      }
+    lastetaindex = etaindex;
+  }
+
+  //Write remaining clusters
+  for(Int_t etaindex = 0;etaindex < netasegments;etaindex++)
+    {
+      //Check for empty row
+      if((etaclust[etaindex].fStartPad == 0) && (etaclust[etaindex].fEndPad == 0)) continue;
+      
+      FillCluster(i,etaindex,etaclust,ilastpatch,firstbinx,lastbinx,nbinx,firstbiny);
     }
   
-#ifdef do_mc
+  delete [] etaclust;
+}
+
+Int_t AliL3HoughTransformerRow::GetTrackID(Int_t etaindex,Double_t alpha1,Double_t alpha2) const
+{
+  // Returns the MC label for a given peak found in the Hough space
+#ifndef do_mc
+  LOG(AliL3Log::kWarning,"AliL3HoughTransformerRow::GetTrackID","Data")
+    <<"Flag switched off"<<ENDLOG;
+  return -1;
+#else
   if(etaindex < 0 || etaindex > GetNEtaSegments())
     {
       LOG(AliL3Log::kWarning,"AliL3HoughTransformerRow::GetTrackID","Data")
@@ -799,31 +1050,31 @@ Int_t AliL3HoughTransformerRow::GetTrackID(Int_t etaindex,Double_t alpha1,Double
   Int_t max=0;
   for(UInt_t i=0; i<(MaxTrack-1); i++)
     {
-      Int_t nhits=fgTrackID[etaindex][bin].fNHits[i];
+      Int_t nhits=fTrackID[etaindex][bin].fNHits[i];
       if(nhits == 0) break;
       if(nhits > max)
        {
          max = nhits;
-         label = fgTrackID[etaindex][bin].fLabel[i];
+         label = fTrackID[etaindex][bin].fLabel[i];
        }
     }
   Int_t label2=-1;
   Int_t max2=0;
   for(UInt_t i=0; i<(MaxTrack-1); i++)
     {
-      Int_t nhits=fgTrackID[etaindex][bin].fNHits[i];
+      Int_t nhits=fTrackID[etaindex][bin].fNHits[i];
       if(nhits == 0) break;
       if(nhits > max2)
        {
-         if(fgTrackID[etaindex][bin].fLabel[i]!=label) {
+         if(fTrackID[etaindex][bin].fLabel[i]!=label) {
            max2 = nhits;
-           label2 = fgTrackID[etaindex][bin].fLabel[i];
+           label2 = fTrackID[etaindex][bin].fLabel[i];
          }
        }
     }
   if(max2 !=0 ) {
     LOG(AliL3Log::kDebug,"AliL3HoughTransformerRow::GetTrackID()","")
-      <<" TrackID"<<" label "<<label<<" max "<<max<<" label2 "<<label2<<" max2 "<<max2<<" "<<(Float_t)max2/(Float_t)max<<" "<<fgTrackID[etaindex][bin].fLabel[MaxTrack-1]<<" "<<(Int_t)fgTrackID[etaindex][bin].fNHits[MaxTrack-1]<<ENDLOG;
+      <<" TrackID"<<" label "<<label<<" max "<<max<<" label2 "<<label2<<" max2 "<<max2<<" "<<(Float_t)max2/(Float_t)max<<" "<<fTrackID[etaindex][bin].fLabel[MaxTrack-1]<<" "<<(Int_t)fTrackID[etaindex][bin].fNHits[MaxTrack-1]<<ENDLOG;
   }
   return label;
 #endif
@@ -832,33 +1083,204 @@ Int_t AliL3HoughTransformerRow::GetTrackID(Int_t etaindex,Double_t alpha1,Double
   return -1;
 }
 
-UChar_t *AliL3HoughTransformerRow::GetRowCount(Int_t etaindex)
-{
-  return fgRowCount[etaindex];
-}
-
 UChar_t *AliL3HoughTransformerRow::GetGapCount(Int_t etaindex)
 {
-  return fgGapCount[etaindex];
+  return fGapCount[etaindex];
 }
 
 UChar_t *AliL3HoughTransformerRow::GetCurrentRowCount(Int_t etaindex)
 {
-  return fgCurrentRowCount[etaindex];
+  return fCurrentRowCount[etaindex];
 }
 
 UChar_t *AliL3HoughTransformerRow::GetTrackNRows()
 {
-  return fgTrackNRows;
+  return fTrackNRows;
 }
 
 
 UChar_t *AliL3HoughTransformerRow::GetTrackFirstRow()
 {
-  return fgTrackFirstRow;
+  return fTrackFirstRow;
 }
 
 UChar_t *AliL3HoughTransformerRow::GetTrackLastRow()
 {
-  return fgTrackLastRow;
+  return fTrackLastRow;
+}
+
+UChar_t *AliL3HoughTransformerRow::GetPrevBin(Int_t etaindex)
+{
+  return fPrevBin[etaindex];
+}
+
+UChar_t *AliL3HoughTransformerRow::GetNextBin(Int_t etaindex)
+{
+  return fNextBin[etaindex];
+}
+
+UChar_t *AliL3HoughTransformerRow::GetNextRow(Int_t etaindex)
+{
+  return fNextRow[etaindex];
+}
+
+inline void AliL3HoughTransformerRow::FillClusterRow(UChar_t i,Int_t binx1,Int_t binx2,UChar_t *ngaps2,UChar_t *currentrow2,UChar_t *lastrow2
+#ifdef do_mc
+                          ,AliL3EtaRow etaclust,AliL3TrackIndex *trackid
+#endif
+                          )
+{
+  for(Int_t bin=binx1;bin<=binx2;bin++)
+    {
+      if(ngaps2[bin] < MAX_N_GAPS) {
+       if(i < lastrow2[bin] && i > currentrow2[bin]) {
+         ngaps2[bin] += (i-currentrow2[bin]-1);
+         currentrow2[bin]=i;
+       }
+#ifdef do_mc
+       if(i < lastrow2[bin] && i >= currentrow2[bin]) {
+         for(UInt_t t=0;t<(MaxTrack-1); t++)
+           {
+             Int_t label = etaclust.fMcLabels[t];
+             if(label == 0) break;
+             UInt_t c;
+             Int_t tempbin2 = (Int_t)(bin/2);
+             for(c=0; c<(MaxTrack-1); c++)
+               if(trackid[tempbin2].fLabel[c] == label || trackid[tempbin2].fNHits[c] == 0)
+                 break;
+             trackid[tempbin2].fLabel[c] = label;
+             if(trackid[tempbin2].fCurrentRow[c] != i) {
+               trackid[tempbin2].fNHits[c]++;
+               trackid[tempbin2].fCurrentRow[c] = i;
+             }
+           }
+       }
+#endif
+      }
+    }
+
+}
+
+inline void AliL3HoughTransformerRow::FillCluster(UChar_t i,Int_t etaindex,AliL3EtaRow *etaclust,Int_t ilastpatch,Int_t firstbinx,Int_t lastbinx,Int_t nbinx,Int_t firstbiny)
+{
+  UChar_t *ngaps = fGapCount[etaindex];
+  UChar_t *currentrow = fCurrentRowCount[etaindex];
+  UChar_t *lastrow = fTrackLastRow;
+  UChar_t *prevbin = fPrevBin[etaindex];
+  UChar_t *nextbin = fNextBin[etaindex];
+  UChar_t *nextrow = fNextRow[etaindex];
+#ifdef do_mc
+  AliL3TrackIndex *trackid = fTrackID[etaindex];
+#endif
+
+  //Do the transformation:
+  AliL3PadHoughParams *startparams = &fStartPadParams[(Int_t)i][etaclust[etaindex].fStartPad]; 
+  AliL3PadHoughParams *endparams = &fEndPadParams[(Int_t)i][etaclust[etaindex].fEndPad];
+  Float_t alpha1 = startparams->fAlpha;
+  Float_t deltaalpha1 = startparams->fDeltaAlpha;
+  Float_t alpha2 = endparams->fAlpha;
+  Float_t deltaalpha2 = endparams->fDeltaAlpha;
+
+  Int_t firstbin1 = startparams->fFirstBin;
+  Int_t firstbin2 = endparams->fFirstBin;
+  Int_t firstbin = firstbin1;
+  if(firstbin>firstbin2) firstbin = firstbin2;
+
+  Int_t lastbin1 = startparams->fLastBin;
+  Int_t lastbin2 = endparams->fLastBin;
+  Int_t lastbin = lastbin1;
+  if(lastbin<lastbin2) lastbin = lastbin2;
+  
+  alpha1 += (firstbin-firstbiny)*deltaalpha1;
+  alpha2 += (firstbin-firstbiny)*deltaalpha2;
+
+  //Fill the histogram along the alpha2 range
+  if(ilastpatch == -1) {
+    for(Int_t b=firstbin; b<=lastbin; b++, alpha1 += deltaalpha1, alpha2 += deltaalpha2)
+      {
+       Int_t binx1 = 1 + (Int_t)alpha1;
+       if(binx1>lastbinx) continue;
+       if(binx1<firstbinx) binx1 = firstbinx;
+       Int_t binx2 = 1 + (Int_t)alpha2;
+       if(binx2<firstbinx) continue;
+       if(binx2>lastbinx) binx2 = lastbinx;
+#ifdef do_mc
+       if(binx2<binx1) {
+         LOG(AliL3Log::kWarning,"AliL3HoughTransformerRow::TransformCircle()","")
+           <<"Wrong filling "<<binx1<<" "<<binx2<<" "<<i<<" "<<etaclust[etaindex].fStartPad<<" "<<etaclust[etaindex].fEndPad<<ENDLOG;
+       }
+#endif
+       Int_t tempbin = b*nbinx;
+       UChar_t *ngaps2 = ngaps + tempbin;
+       UChar_t *currentrow2 = currentrow + tempbin;
+       UChar_t *lastrow2 = lastrow + tempbin;
+#ifdef do_mc
+       Int_t tempbin2 = ((Int_t)(b/2))*((Int_t)((nbinx+1)/2));
+       AliL3TrackIndex *trackid2 = trackid + tempbin2;
+#endif
+       FillClusterRow(i,binx1,binx2,ngaps2,currentrow2,lastrow2
+#ifdef do_mc
+                      ,etaclust[etaindex],trackid2
+#endif
+                      );
+      }
+  }
+  else {
+    for(Int_t b=firstbin; b<=lastbin; b++, alpha1 += deltaalpha1, alpha2 += deltaalpha2)
+      {
+       Int_t binx1 = 1 + (Int_t)alpha1;
+       if(binx1>lastbinx) continue;
+       if(binx1<firstbinx) binx1 = firstbinx;
+       Int_t binx2 = 1 + (Int_t)alpha2;
+       if(binx2<firstbinx) continue;
+       if(binx2>lastbinx) binx2 = lastbinx;
+#ifdef do_mc
+       if(binx2<binx1) {
+         LOG(AliL3Log::kWarning,"AliL3HoughTransformerRow::TransformCircle()","")
+           <<"Wrong filling "<<binx1<<" "<<binx2<<" "<<i<<" "<<etaclust[etaindex].fStartPad<<" "<<etaclust[etaindex].fEndPad<<ENDLOG;
+       }
+#endif
+       if(nextrow[b] > (b + 1)) {
+         Int_t deltab = (nextrow[b] - b - 1);
+         b += deltab;
+         alpha1 += deltaalpha1*deltab;
+         alpha2 += deltaalpha2*deltab;
+         continue;
+       }
+       Int_t tempbin = b*nbinx;
+       binx1 = (UInt_t)nextbin[binx1 + tempbin];
+       binx2 = (UInt_t)prevbin[binx2 + tempbin];
+       if(binx2<binx1) continue;
+       UChar_t *ngaps2 = ngaps + tempbin;
+       UChar_t *currentrow2 = currentrow + tempbin;
+       UChar_t *lastrow2 = lastrow + tempbin;
+#ifdef do_mc
+       Int_t tempbin2 = ((Int_t)(b/2))*((Int_t)((nbinx+1)/2));
+       AliL3TrackIndex *trackid2 = trackid + tempbin2;
+#endif
+       FillClusterRow(i,binx1,binx2,ngaps2,currentrow2,lastrow2
+#ifdef do_mc
+                      ,etaclust[etaindex],trackid2
+#endif
+                      );
+      }
+  }
+}
+
+#ifdef do_mc
+inline void AliL3HoughTransformerRow::FillClusterMCLabels(AliL3DigitData digpt,AliL3EtaRow etaclust)
+{
+  for(Int_t t=0; t<3; t++)
+    {
+      Int_t label = digpt.fTrackID[t];
+      if(label < 0) break;
+      UInt_t c;
+      for(c=0; c<(MaxTrack-1); c++)
+       if(etaclust.fMcLabels[c] == label || etaclust.fMcLabels[c] == 0)
+         break;
+
+      etaclust.fMcLabels[c] = label;
+    }
 }
+#endif
index 3c5eeee..1331274 100644 (file)
@@ -6,11 +6,29 @@
 #include "AliL3RootTypes.h"
 #include "AliL3HoughBaseTransformer.h"
 
-#define MAX_N_GAPS 4
+#define MAX_N_GAPS 5
 #define MAX_GAP_SIZE 4
 #define MIN_TRACK_LENGTH 70
 #define MAX_MISS_ROWS 2
 
+struct AliL3EtaRow {
+  UChar_t fStartPad; //First pad in the cluster
+  UChar_t fEndPad; //Last pad in the cluster
+  Bool_t fIsFound; //Is the cluster already found
+  Float_t fStartY; //Y position of the first pad in the cluster
+#ifdef do_mc
+  Int_t fMcLabels[MaxTrack]; //Array to store mc labels inside cluster
+#endif
+};
+
+struct AliL3PadHoughParams {
+  Float_t fAlpha;
+  Float_t fDeltaAlpha;
+  Int_t fFirstBin;
+  Int_t fLastBin;
+};
+
+class AliL3DigitData;
 class AliL3Histogram;
 
 class AliL3HoughTransformerRow : public AliL3HoughBaseTransformer {
@@ -32,41 +50,66 @@ class AliL3HoughTransformerRow : public AliL3HoughBaseTransformer {
   AliL3Histogram *GetHistogram(Int_t etaindex);
   Double_t GetEta(Int_t etaindex,Int_t slice) const;
   Int_t GetTrackID(Int_t etaindex,Double_t alpha1,Double_t alpha2) const;
-  UChar_t *GetRowCount(Int_t etaindex);
   UChar_t *GetGapCount(Int_t etaindex);
   UChar_t *GetCurrentRowCount(Int_t etaindex);
-  static UChar_t *GetTrackNRows();
-  static UChar_t *GetTrackFirstRow();
-  static UChar_t *GetTrackLastRow();
+  UChar_t *GetPrevBin(Int_t etaindex);
+  UChar_t *GetNextBin(Int_t etaindex);
+  UChar_t *GetNextRow(Int_t etaindex);
+  UChar_t *GetTrackNRows();
+  UChar_t *GetTrackFirstRow();
+  UChar_t *GetTrackLastRow();
   static Float_t GetBeta1() {return fgBeta1;}
   static Float_t GetBeta2() {return fgBeta2;}
 
- private:
-  
-  AliL3Histogram **fParamSpace; //!
+  void SetTPCRawStream(AliTPCRawStream *rawstream) {fTPCRawStream=rawstream;}
 
+  UChar_t **fGapCount; //!
+  UChar_t **fCurrentRowCount; //!
 #ifdef do_mc
-  static AliL3TrackIndex **fgTrackID; //!
+  AliL3TrackIndex **fTrackID; //!
 #endif
-  Bool_t fDoMC; // Do MC labels or not
 
-  void DeleteHistograms(); //Method to clean up the histograms containing Hough space
+  UChar_t *fTrackNRows; //!
+  UChar_t *fTrackFirstRow; //!
+  UChar_t *fTrackLastRow; //!
+  UChar_t *fInitialGapCount; //!
 
-  static UChar_t **fgRowCount; //!
-  static UChar_t **fgGapCount; //!
-  static UChar_t **fgCurrentRowCount; //!
+  UChar_t **fPrevBin; //!
+  UChar_t **fNextBin; //!
+  UChar_t **fNextRow; //!
 
-  static UChar_t *fgTrackNRows; //!
-  static UChar_t *fgTrackFirstRow; //!
-  static UChar_t *fgTrackLastRow; //!
+  AliL3PadHoughParams **fStartPadParams; //!
+  AliL3PadHoughParams **fEndPadParams; //!
+  Float_t **fLUTr2; //!
 
   Float_t *fLUTforwardZ; //!
   Float_t *fLUTforwardZ2; //!
   Float_t *fLUTbackwardZ; //!
   Float_t *fLUTbackwardZ2; //!
 
+ private:
+  
+  AliL3Histogram **fParamSpace; //!
+
+  void TransformCircleFromDigitArray();
+  void TransformCircleFromRawStream();
+
+  void DeleteHistograms(); //Method to clean up the histograms containing Hough space
+
+  inline void FillClusterRow(UChar_t i,Int_t binx1,Int_t binx2,UChar_t *ngaps2,UChar_t *currentrow2,UChar_t *lastrow2
+#ifdef do_mc
+                            ,AliL3EtaRow etaclust,AliL3TrackIndex *trackid
+#endif
+                            );
+  inline void FillCluster(UChar_t i,Int_t etaindex,AliL3EtaRow *etaclust,Int_t ilastpatch,Int_t firstbinx,Int_t lastbinx,Int_t nbinx,Int_t firstbiny);
+#ifdef do_mc
+  inline void FillClusterMCLabels(AliL3DigitData digpt,AliL3EtaRow etaclust);
+#endif
+
   static Float_t fgBeta1,fgBeta2; // Two curves which define the Hough space
 
+  AliTPCRawStream *fTPCRawStream;
+
   ClassDef(AliL3HoughTransformerRow,1) //TPC Rows Hough transformation class
 
 };
index ed3c73d..f6b2fcb 100644 (file)
@@ -74,7 +74,7 @@ Bool_t AliL3DDLDataFileHandler::SetReaderInput(Char_t *name,Int_t event)
     fReader=new AliRawReaderRoot(name,event);
   } else {
     fFilename="";
-    fReader=new AliRawReaderDate(name);
+    fReader=new AliRawReaderDate((void *)name);
   }
   fTPCStream=new AliTPCRawStream(fReader);
 
@@ -135,6 +135,7 @@ Bool_t AliL3DDLDataFileHandler::IsDigit(Int_t /*i*/) const
 }
 #endif
 
+#ifndef fast_raw
 AliL3DigitRowData * AliL3DDLDataFileHandler::DDLData2Memory(UInt_t &nrow,Int_t event)
 {
   // transfers the DDL data to the memory
@@ -168,7 +169,7 @@ AliL3DigitRowData * AliL3DDLDataFileHandler::DDLData2Memory(UInt_t &nrow,Int_t e
       for(Int_t j=0;j<AliL3Transform::GetNTimeBins();j++) charges[lrow][k][j]=0;
     }
   }
-  
+
   Int_t ddlsToSearch=0;
   Int_t ddls[9]={-1,-1,-1,-1,-1,-1,-1,-1,-1};
   Int_t ddlid=-1,lddlid=-1;
@@ -188,6 +189,7 @@ AliL3DigitRowData * AliL3DDLDataFileHandler::DDLData2Memory(UInt_t &nrow,Int_t e
       ddls[ddlsToSearch++]=ddlid-1;    
       lddlid=ddlid-1;
     }
+
     if((lddlid==-1)||(ddlid!=lddlid)){
       ddls[ddlsToSearch++]=ddlid;
       lddlid=ddlid;
@@ -197,56 +199,54 @@ AliL3DigitRowData * AliL3DDLDataFileHandler::DDLData2Memory(UInt_t &nrow,Int_t e
       lddlid=ddlid+1;
     }
   }
-  //for(Int_t i=0;i<ddlsToSearch;i++) cout << ddls[i] <<endl;
 
-  for(Int_t i=0;i<ddlsToSearch;i++){
+  //  for(Int_t i=0;i<ddlsToSearch;i++) cout << ddls[i] <<endl;
+
+  if(ddls[0]>ddls[ddlsToSearch-1]) {
+    Int_t tempddl = ddls[0];
+    ddls[0] = ddls[ddlsToSearch-1];
+    ddls[ddlsToSearch-1] = tempddl;
+  }
 #ifdef use_newio
     fReader->Reset();
-    fReader->Select(0,ddls[i],ddls[i]+1);
+    fReader->Select(0,ddls[0],ddls[ddlsToSearch-1]);
+    fTPCStream->Reset();
 #else
     fTPCStream->SetDDLID(ddls[i]); //ddl to read out
 #endif
+    Int_t zerosup = AliL3Transform::GetZeroSup();
+    Int_t adcsat = AliL3Transform::GetADCSat();
+    Int_t slice,srow;
+    Int_t lrow;
 
     while (fTPCStream->Next()){
-  
-      UShort_t dig=fTPCStream->GetSignal();
-      if(dig <= AliL3Transform::GetZeroSup()) continue;
-      if(dig >= AliL3Transform::GetADCSat())
-       dig = AliL3Transform::GetADCSat();
 
-      Int_t time=fTPCStream->GetTime();
-      Int_t pad=fTPCStream->GetPad();
-      Int_t sector=fTPCStream->GetSector();
-      Int_t row=fTPCStream->GetRow();
-      Int_t slice,srow;
+      if(fTPCStream->IsNewSector() || fTPCStream->IsNewRow()) {
+       Int_t sector=fTPCStream->GetSector();
+       Int_t row=fTPCStream->GetRow();
+       AliL3Transform::Sector2Slice(slice,srow,sector,row);
+       if(slice!=fSlice){
+         LOG(AliL3Log::kError,"AliL3DDLDataFileHandler::DDLDigits2Memory","Slice")
+           <<AliL3Log::kDec<<"Found slice "<<slice<<", expected "<<fSlice<<ENDLOG;
+         continue;
+       }
+       lrow=srow-fRowMin;
+      }
 
       //test row criteria (patch boundaries)
-      AliL3Transform::Sector2Slice(slice,srow,sector,row);
       if((srow<fRowMin)||(srow>fRowMax))continue;
-      if(slice!=fSlice){
-       LOG(AliL3Log::kError,"AliL3DDLDataFileHandler::DDLDigits2Memory","Slice")
-         <<AliL3Log::kDec<<"Found slice "<<slice<<", expected "<<fSlice<<ENDLOG;
-       continue;
-      }
-
-      //cut out the inner cone
-      Float_t xyz[3];
-      AliL3Transform::Raw2Local(xyz,sector,row,pad,time);
-      if(AliL3Transform::Row2X(srow)<230./250.*fabs(xyz[2]))
-       continue; // why 230???
 
-      Int_t lrow=srow-fRowMin;
-      if((lrow<0)||lrow>=nrows){
-       LOG(AliL3Log::kError,"AliL3DDLDataFileHandler::DDLDigits2Memory","Row")
-         <<AliL3Log::kDec<<"Row value out of bounds "<<lrow<<" "<<nrows<<ENDLOG;
-       continue;
-      }
-      if((pad<0)||(pad>=AliL3Transform::GetNPads(srow))){
-       LOG(AliL3Log::kError,"AliL3DDLDataFileHandler::DDLDigits2Memory","Pad")
-         <<AliL3Log::kDec<<"Pad value out of bounds "<<pad<<" "
-         <<AliL3Transform::GetNPads(srow)<<ENDLOG;
-       continue;
+      Int_t pad=fTPCStream->GetPad();
+      if(fTPCStream->IsNewPad()) {
+       if((pad<0)||(pad>=AliL3Transform::GetNPads(srow))){
+         LOG(AliL3Log::kError,"AliL3DDLDataFileHandler::DDLDigits2Memory","Pad")
+           <<AliL3Log::kDec<<"Pad value out of bounds "<<pad<<" "
+           <<AliL3Transform::GetNPads(srow)<<ENDLOG;
+         continue;
+       }
       }
+
+      Int_t time=fTPCStream->GetTime();
       if((time<0)||(time>=AliL3Transform::GetNTimeBins())){
        LOG(AliL3Log::kError,"AliL3DDLDataFileHandler::DDLDigits2Memory","Time")
          <<AliL3Log::kDec<<"Time out of bounds "<<time<<" "
@@ -255,13 +255,16 @@ AliL3DigitRowData * AliL3DDLDataFileHandler::DDLData2Memory(UInt_t &nrow,Int_t e
       }
 
       //store digit
+      UShort_t dig=fTPCStream->GetSignal();
+      if(dig <= zerosup) continue;
+      if(dig >= adcsat) dig = adcsat;
+
       ndigits[lrow]++; //for this row only
       ndigitcount++;   //total number of digits to be published
 
       charges[lrow][pad][time]=dig;
     }
-  }
-  
+
   Int_t size = sizeof(AliL3DigitData)*ndigitcount
     + nrows*sizeof(AliL3DigitRowData);
 
@@ -326,7 +329,65 @@ AliL3DigitRowData * AliL3DDLDataFileHandler::DDLData2Memory(UInt_t &nrow,Int_t e
 
   return data;
 }
+#else
+AliL3DigitRowData * AliL3DDLDataFileHandler::DDLData2Memory(UInt_t &nrow,Int_t event)
+{
+  // transfers the DDL data to the memory
+#ifdef use_newio
+  if((fEvent>=0)&&(event!=fEvent)){
+    fEvent=event;
+    if(fReader) delete fReader;
+    if(fTPCStream) delete fTPCStream;
+    fReader=new AliRawReaderRoot(fFilename,event);
+    fTPCStream=new AliTPCRawStream(fReader);
+  }
+#endif
+  AliL3DigitRowData *data = 0;
+  nrow=0;
 
+  if(!fReader){
+    LOG(AliL3Log::kWarning,"AliL3DDLDataFileHandler::DDLData2Memory","File")
+    <<"No Input avalible: no object AliL3DDLRawReaderFile"<<ENDLOG;
+    return 0; 
+  }
+  
+  Int_t nrows=fRowMax-fRowMin+1;
+
+  Int_t ddlsToSearch=0;
+  Int_t ddls[9]={-1,-1,-1,-1,-1,-1,-1,-1,-1};
+  Int_t ddlid=-1,lddlid=-1;
+  for(Int_t r=fRowMin;r<=fRowMax;r++){
+
+    Int_t patch=AliL3Transform::GetPatch(r);
+    Int_t sector,row;
+    AliL3Transform::Slice2Sector(fSlice,r,sector,row);
+
+    if(sector<36) //taken from AliTPCBuffer160.cxx
+      ddlid=sector*2+patch;
+    else
+      ddlid=70+(sector-36)*4+patch;
+
+    if((lddlid==-1)||(ddlid!=lddlid)){
+      ddls[ddlsToSearch++]=ddlid;
+      lddlid=ddlid;
+    }
+  }
+
+  //  for(Int_t i=0;i<ddlsToSearch;i++) cout << ddls[i] <<endl;
+
+#ifdef use_newio
+  fReader->Reset();
+  fReader->Select(0,ddls[0],ddls[ddlsToSearch-1]);
+  fTPCStream->Reset();
+#else
+  fTPCStream->SetDDLID(ddls[i]); //ddl to read out
+#endif
+
+  nrow = (UInt_t)nrows;
+
+  return data;
+}
+#endif
 
 Bool_t AliL3DDLDataFileHandler::DDLData2CompBinary(Int_t event)
 {
index 490f38f..843c241 100644 (file)
@@ -35,6 +35,8 @@ class AliL3DDLDataFileHandler:public AliL3MemHandler{
    AliL3DigitRowData* DDLData2Memory(UInt_t &nrow,Int_t event=-1);
    Bool_t DDLData2CompBinary(Int_t event=-1);
 
+   AliTPCRawStream* GetTPCRawStream(){return fTPCStream;}
+
   private:
 #ifdef use_newio
    TString          fFilename; // IO file name
index 846331c..c1acea1 100644 (file)
@@ -530,8 +530,8 @@ AliL3DigitRowData * AliL3FileHandler::AliDigits2Memory(UInt_t & nrow,Int_t event
          dig = AliL3Transform::GetADCSat();
       
        AliL3Transform::Raw2Local(xyz,sector,row,pad,time);
-       if(fParam->GetPadRowRadii(sector,row)<230./250.*fabs(xyz[2]))
-         continue; // why 230???
+       //      if(fParam->GetPadRowRadii(sector,row)<230./250.*fabs(xyz[2]))
+       //        continue; // why 230???
 
        ndigits[lrow]++; //for this row only
        ndigitcount++;   //total number of digits to be published
@@ -581,8 +581,8 @@ AliL3DigitRowData * AliL3FileHandler::AliDigits2Memory(UInt_t & nrow,Int_t event
 
        //Exclude data outside cone:
        AliL3Transform::Raw2Local(xyz,sector,row,pad,time);
-       if(fParam->GetPadRowRadii(sector,row)<230./250.*fabs(xyz[2]))
-         continue; // why 230???
+       //      if(fParam->GetPadRowRadii(sector,row)<230./250.*fabs(xyz[2]))
+       //        continue; // why 230???
 
        if(localcount >= ndigits[lrow])
          LOG(AliL3Log::kFatal,"AliL3FileHandler::AliDigits2Binary","Memory")
@@ -792,8 +792,8 @@ AliL3DigitRowData * AliL3FileHandler::AliAltroDigits2Memory(UInt_t & nrow,Int_t
            }
 
          AliL3Transform::Raw2Local(xyz,sector,row,pad,time);
-         if(fParam->GetPadRowRadii(sector,row)<230./250.*fabs(xyz[2]))
-         continue; 
+         //      if(fParam->GetPadRowRadii(sector,row)<230./250.*fabs(xyz[2]))
+         //      continue; 
              
          ndigits[lrow]++; //for this row only
          ndigitcount++;   //total number of digits to be published
@@ -930,8 +930,8 @@ AliL3DigitRowData * AliL3FileHandler::AliAltroDigits2Memory(UInt_t & nrow,Int_t
            }
        
          AliL3Transform::Raw2Local(xyz,sector,row,pad,time);
-         if(fParam->GetPadRowRadii(sector,row)<230./250.*fabs(xyz[2]))
-           continue;
+         //      if(fParam->GetPadRowRadii(sector,row)<230./250.*fabs(xyz[2]))
+         //        continue;
          
          if(localcount >= ndigits[lrow])
            LOG(AliL3Log::kFatal,"AliL3FileHandler::AliAltroDigits2Binary","Memory")
index 4f7194e..9b65568 100644 (file)
@@ -183,7 +183,7 @@ void AliL3MemHandler::SetROI(Float_t *eta,Int_t */*slice*/)
   
 }
 
-Bool_t AliL3MemHandler::SetBinaryInput(Char_t *name)
+Bool_t AliL3MemHandler::SetBinaryInput(char *name)
 {
   //Set the input binary file.
   fInBinary = fopen(name,"r");
@@ -219,7 +219,7 @@ void AliL3MemHandler::CloseBinaryInput()
   fInBinary =0;
 }
 
-Bool_t AliL3MemHandler::SetBinaryOutput(Char_t *name)
+Bool_t AliL3MemHandler::SetBinaryOutput(char *name)
 {
   //Set the binary output file.
     fOutBinary = fopen(name,"w");
@@ -306,8 +306,8 @@ void AliL3MemHandler::Free()
 {
   //Clear the memory, if allocated.
   if(!fPt){
-    LOG(AliL3Log::kInformational,"AliL3MemHandler::Free","Memory")
-      <<"No Memory allocated - can't Free"<<ENDLOG;
+    //    LOG(AliL3Log::kInformational,"AliL3MemHandler::Free","Memory")
+    //      <<"No Memory allocated - can't Free"<<ENDLOG;
     return;
   }  
   delete[] fPt;
index e423ee1..de2cfbd 100644 (file)
@@ -1,7 +1,7 @@
 // @(#) $Id$
 
-#ifndef ALIL3MEMHANDLER_H
-#define ALIL3MEMHANDLER_H
+#ifndef ALIL3_MEMHANDLER_H
+#define ALIL3_MEMHANDLER_H
 
 //_____________________________________________________________
 // AliL3MemHandler
@@ -26,21 +26,25 @@ class AliL3RandomDigitData;
 #ifdef use_newio
 class AliRunLoader;
 #endif
+class AliTPCRawStream;
 
 class AliL3MemHandler { 
 
  public:
   AliL3MemHandler();
   virtual ~AliL3MemHandler();
+  AliL3MemHandler(const AliL3MemHandler& /*m*/){};
+  AliL3MemHandler& operator=(const AliL3MemHandler& /*&m*/)
+    {return (*this);}
    
   void Reset(){CloseBinaryInput();CloseBinaryOutput();Free();}  
   void Init(Int_t s,Int_t p, Int_t *r=0);
 
-  Bool_t SetBinaryInput(Char_t *name);
+  Bool_t SetBinaryInput(char *name);
   Bool_t SetBinaryInput(FILE *file);
   void CloseBinaryInput();
   
-  Bool_t SetBinaryOutput(Char_t *name);
+  Bool_t SetBinaryOutput(char *name);
   Bool_t SetBinaryOutput(FILE *file);
   void CloseBinaryOutput();
 
@@ -107,13 +111,13 @@ class AliL3MemHandler {
   
   //virtual functions:
   virtual void FreeDigitsTree() {fDummy=0; return;}
-  virtual Bool_t SetAliInput(Char_t */*name*/){fDummy=0; return 0;}
+  virtual Bool_t SetAliInput(char */*name*/){fDummy=0; return 0;}
 #ifdef use_newio
   virtual Bool_t SetAliInput(AliRunLoader */*runloader*/){fDummy=0; return 0;}
 #endif
   virtual void CloseAliInput(){fDummy=0; return;} 
   virtual Bool_t IsDigit(Int_t /*i*/=0){fDummy=0; return 0;}
-  virtual Bool_t SetMCOutput(Char_t */*name*/){fDummy=0; return 0;}
+  virtual Bool_t SetMCOutput(char */*name*/){fDummy=0; return 0;}
   virtual Bool_t SetMCOutput(FILE */*file*/){fDummy=0; return 0;}
   virtual void CloseMCOutput(){fDummy=0; return;}
   virtual Bool_t AliDigits2Binary(Int_t /*event*/=0,Bool_t /*altro*/=kFALSE){fDummy=0; return 0;}
@@ -160,6 +164,8 @@ class AliL3MemHandler {
   virtual AliL3DigitRowData* DDLData2Memory(UInt_t &/*nrow*/,Int_t /*event*/=-1){fDummy=0; return 0;}
   virtual Bool_t DDLData2CompBinary(Int_t /*event*/=-1){fDummy=0; return 0;}
 
+  virtual AliTPCRawStream* GetTPCRawStream(){fDummy=0; return 0;}
+
  protected:
   Int_t fRowMin; //min row
   Int_t fRowMax; //max row
@@ -173,9 +179,6 @@ class AliL3MemHandler {
   FILE *fOutBinary;//!
 
  private:
-  AliL3MemHandler(const AliL3MemHandler& /*m*/){};
-  AliL3MemHandler& operator=(const AliL3MemHandler& /*&m*/)
-    {return (*this);}
   
   Byte_t *fPt;//!
   UInt_t fSize; //size of allocated data structure
index 888096e..d60b2b4 100644 (file)
@@ -1314,6 +1314,43 @@ Int_t AliL3Transform::GetLastRow(Int_t patch)
     return fgRows[patch][1];
 }
 
+Int_t AliL3Transform::GetFirstRowOnDDL(Int_t patch)
+{
+  //get first row per patch
+
+  if(patch==-1)
+    return 0;
+  else if(patch < -1 || patch >= 6)
+    {
+      LOG(AliL3Log::kError,"AliL3Transform::GetFirstRow","Patch")
+       <<AliL3Log::kDec<<"Wrong patch "<<patch<<ENDLOG;
+      return 0;
+    }
+  else
+    {
+      if(patch==1) return fgRows[patch][0]+1;
+      return fgRows[patch][0];
+    }
+}
+
+Int_t AliL3Transform::GetLastRowOnDDL(Int_t patch)
+{
+  //get last row per patch
+  if(patch==-1)
+    return fgRows[5][1];
+  else if(patch < -1 || patch >= 6)
+    {
+      LOG(AliL3Log::kError,"AliL3Transform::GetLastRow","Patch")
+       <<AliL3Log::kDec<<"Wrong patch "<<patch<<ENDLOG;
+      return 0;
+    }
+  else
+    {
+      if(patch==2 || patch==4) return fgRows[patch][1]-1;
+      return fgRows[patch][1];
+    }
+}
+
 Int_t AliL3Transform::GetNRows(Int_t patch)
 {
   //get number of rows per patch
index 8dbf562..232a298 100644 (file)
@@ -152,6 +152,8 @@ class AliL3Transform {
 
   static Int_t GetFirstRow(Int_t patch);
   static Int_t GetLastRow(Int_t patch);
+  static Int_t GetFirstRowOnDDL(Int_t patch);
+  static Int_t GetLastRowOnDDL(Int_t patch);
   static Int_t GetNRows(Int_t patch);
   static Int_t GetPatch(Int_t padrow);
   static Int_t GetNRows() {return fgNRow;}
index db8d3e5..3173489 100644 (file)
 #include "AliRawReaderDate.h"
 #include "event.h"
 #include "monitor.h"
-#include <AliLevel3.h>
+#include <AliL3StandardIncludes.h>
 #include <AliL3Transform.h>
 #include <AliL3MemHandler.h>
 #include <AliL3TrackArray.h>
+#include <AliL3HoughMaxFinder.h>
+#include <AliL3HoughBaseTransformer.h>
+#include <AliL3Hough.h>
+#include <AliL3Benchmark.h>
 #endif
 
 
@@ -68,6 +72,7 @@ int main(int argc, char** argv)
 
   // open a log file
   FILE* file = fopen("monitorGDC.log", "w");
+
   TDatime time;
 
   // get data from a file or online from this node
@@ -111,21 +116,11 @@ int main(int argc, char** argv)
       continue;
     }
 
-    // read run, event, detector, DDL numbers and data size
     AliRawReaderDate rawReader(ptr);
-    time.Set();
-    printf("\n%s\n", time.AsString());
-    printf("run: %d  event: %d %d\n", rawReader.GetRunNumber(), 
-          rawReader.GetEventId()[0], rawReader.GetEventId()[1]);
-    while (rawReader.ReadHeader()) {
-      printf(" detector: %d   DDL: %d  size: %d\n", 
-            rawReader.GetDetectorID(), rawReader.GetDDLID(), 
-            rawReader.GetDataSize());
-    }
-
-    if ((rawReader.GetAttributes()[0] & 0x02) != 0) {
+    //    if ((rawReader.GetAttributes()[0] & 0x02) != 0) {
 
-      Int_t errorCode = rawReader.CheckData();
+    //      Int_t errorCode = rawReader.CheckData();
+    Int_t errorCode = 0;
       if (errorCode && (errorCode != AliRawReader::kErrSize)) {
        time.Set();
        if (file) fprintf(file, "%s\n", time.AsString());
@@ -137,38 +132,68 @@ int main(int argc, char** argv)
 
       } else {
 
-       // run the HLT tracker
-       AliLevel3* hlt = new AliLevel3((Char_t*)ptr);
-       hlt->Init("./", AliLevel3::kDate, 1);
-
-       hlt->SetClusterFinderParam(-1, -1, kTRUE);
-  
-       Int_t phiSegments = 50;
-       Int_t etaSegments = 100;
-       Int_t trackletlength = 3;
-       Int_t tracklength = 20;//40 or 5
-       Int_t rowscopetracklet = 2;
-       Int_t rowscopetrack = 10;
-       Double_t minPtFit = 0;
-       Double_t maxangle = 0.1745;
-       Double_t goodDist = 5;
-       Double_t maxphi = 0.1;
-       Double_t maxeta = 0.1;
-       Double_t hitChi2Cut = 15;//100 or 15
-       Double_t goodHitChi2 = 5;//20 or 5
-       Double_t trackChi2Cut = 10;//50 or 10
-       hlt->SetTrackerParam(phiSegments, etaSegments, 
-                            trackletlength, tracklength,
-                            rowscopetracklet, rowscopetrack,
-                            minPtFit, maxangle, goodDist, hitChi2Cut,
-                            goodHitChi2, trackChi2Cut, 50, maxphi, maxeta, 
-                            kTRUE);
-  
-       gSystem->Exec("rm -rf hlt");
-       gSystem->MakeDirectory("hlt");
-       hlt->WriteFiles("./hlt/");
-       hlt->ProcessEvent(0, 35, 0);
-
+       AliL3Benchmark *fBenchmark = new AliL3Benchmark();
+       fBenchmark->Start("Overall timing");
+
+       // Run the Hough Transformer
+       fBenchmark->Start("Init");
+       AliL3Hough *hough1 = new AliL3Hough();
+
+       hough1->SetThreshold(4);
+       hough1->SetTransformerParams(76,140,0.4,-1);
+       hough1->SetPeakThreshold(70,-1);
+       //      printf("Pointer is %x\n",ptr);
+       hough1->Init("./", kFALSE, 100, kFALSE,4,0,(Char_t*)ptr,3.82147);
+       hough1->SetAddHistograms();
+       fBenchmark->Stop("Init");
+
+       fBenchmark->Start("Init");
+       AliL3Hough *hough2 = new AliL3Hough();
+
+       hough2->SetThreshold(4);
+       hough2->SetTransformerParams(76,140,0.4,-1);
+       hough2->SetPeakThreshold(70,-1);
+       //      printf("Pointer is %x\n",ptr);
+       hough2->Init("./", kFALSE, 100, kFALSE,4,0,(Char_t*)ptr,3.82147);
+       hough2->SetAddHistograms();
+       fBenchmark->Stop("Init");
+
+       Int_t n_global_tracks = 0;
+       hough1->StartProcessInThread(0,17);
+       hough2->StartProcessInThread(18,35);
+
+       //      gSystem->Sleep(20000);
+       if(hough1->WaitForThreadFinish())
+         ::Fatal("AliL3Hough::WaitForThreadFinish"," Can not join the required thread! ");
+       if(hough2->WaitForThreadFinish())
+         ::Fatal("AliL3Hough::WaitForThreadFinish"," Can not join the required thread! ");
+
+       gSystem->MakeDirectory("hough1");
+       hough1->WriteTracks("./hough1");
+       gSystem->MakeDirectory("hough2");
+       hough2->WriteTracks("./hough2");
+
+       /*
+       for(int slice=0; slice<=35; slice++)
+       {
+         //      cout<<"Processing slice "<<slice<<endl;
+         fBenchmark->Start("ReadData");
+         hough->ReadData(slice,0);
+         fBenchmark->Stop("ReadData");
+         fBenchmark->Start("Transform");
+         hough->Transform();
+         fBenchmark->Stop("Transform");
+         hough->AddAllHistogramsRows();
+         hough->FindTrackCandidatesRow();
+         fBenchmark->Start("AddTracks");
+         hough->AddTracks();
+         fBenchmark->Stop("AddTracks");
+
+         AliL3TrackArray* tracks = (AliL3TrackArray*)hough->GetTracks(0);
+         n_global_tracks += tracks->GetNTracks();
+       }
+       */
+       fBenchmark->Stop("Overall timing");
        time.Set();
        if (file) fprintf(file, "%s\n", time.AsString());
        if (file) fprintf(file, "run: %d  event: %d %d\n", 
@@ -177,39 +202,66 @@ int main(int argc, char** argv)
                          rawReader.GetEventId()[1]);
        if (errorCode) fprintf(file, "ERROR: %d\n", errorCode);
 
-       AliL3MemHandler memHandler;
-       if (!memHandler.SetBinaryInput("hlt/tracks_0.raw")) {
-         if (file) fprintf(file, "no HLT tracks\n");
-         continue;
-       }
-       AliL3TrackArray* tracks = new AliL3TrackArray;
-       memHandler.Binary2TrackArray(tracks);
-       if (file) fprintf(file, "HLT found %d tracks\n", tracks->GetNTracks());
-       delete tracks;
-       memHandler.CloseBinaryInput();
+       if (file) fprintf(file, "Hough Transformer found %d tracks\n",n_global_tracks);
 
-       hlt->DoBench("hlt");
+       hough1->DoBench("hough1");
+       hough2->DoBench("hough2");
+       fBenchmark->Analyze("overall");
+       if (file) {
+         FILE* bench = fopen("hough1.dat", "r");
+         while (bench && !feof(bench)) {
+           char buffer[256];
+           if (!fgets(buffer, 256, bench)) break;
+           fprintf(file, "%s", buffer);
+         }
+         fclose(bench);
+       }
        if (file) {
-         FILE* bench = fopen("hlt.dat", "r");
+         FILE* bench = fopen("hough2.dat", "r");
          while (bench && !feof(bench)) {
            char buffer[256];
            if (!fgets(buffer, 256, bench)) break;
            fprintf(file, "%s", buffer);
          }
          fclose(bench);
-         fprintf(file, "\n");
+       }
+       if (file) {
+         FILE* bench = fopen("overall.dat", "r");
+         while (bench && !feof(bench)) {
+           char buffer[256];
+           if (!fgets(buffer, 256, bench)) break;
+           fprintf(file, "%s", buffer);
+         }
+         fclose(bench);
+         fprintf(file, "\n\n");
        }
 
-       gSystem->Exec("rm -rf hlt");
-       delete hlt;
+       delete hough1;
+       delete hough2;
       }
+    //    }
+
+    /*
+    // read run, event, detector, DDL numbers and data size
+    AliRawReaderDate rawReader(ptr);
+    time.Set();
+    printf("\n%s\n", time.AsString());
+    printf("run: %d  event: %d %d\n", rawReader.GetRunNumber(), 
+          rawReader.GetEventId()[0], rawReader.GetEventId()[1]);
+    while (rawReader.ReadMiniHeader()) {
+      printf(" detector: %d   DDL: %d  size: %d\n", 
+            rawReader.GetDetectorID(), rawReader.GetDDLID(), 
+            rawReader.GetDataSize());
     }
 
+    */
+
     gSystem->Sleep(100);   // sleep for 0.1 second
     free(ptr);
 
     gSystem->ProcessEvents();
     if (file) fflush(file);
+
   }
 
   gSystem->RemoveSignalHandler(handler);
index e994a13..d127128 100644 (file)
@@ -892,8 +892,9 @@ UInt_t AliTPCCompression::ReadWord(Int_t NumberOfBit){
       f.read((char*)(&fBuffer),sizeof(UInt_t));
       fReadBits=0;
     }//end if
-    UInt_t mask=0;
-    mask=(UInt_t)TMath::Power(2,fReadBits);
+    //    UInt_t mask=0;
+    //    mask=(UInt_t)TMath::Power(2,fReadBits);
+    UInt_t mask=(UInt_t)(1<<fReadBits);
     bit=fBuffer&mask;
     bit=bit>>fReadBits;
     fReadBits++;
@@ -909,34 +910,40 @@ UInt_t AliTPCCompression::ReadWordBuffer(Int_t NumberOfBit){
   UInt_t bit=0;
   for (Int_t i=0;i<NumberOfBit;i++){
     if (fReadBits==32){
-      fPointBuffer-=8;
-      fBuffer=0;
-      for(Int_t i=0;i<4;i++){
-       UInt_t val=0;
-       val=*fPointBuffer;
-       val&=0xFF;
-       fPointBuffer++;
-       val<<=8*i;
-       fBuffer=fBuffer|val;
-      }//end for
+      fPointBuffer--;
+      fBuffer=*fPointBuffer;
       fReadBits=0;
     }//end if
-    UInt_t mask=0;
-    mask=(UInt_t)TMath::Power(2,fReadBits);
-    bit=fBuffer&mask;
-    bit=bit>>fReadBits;
-    fReadBits++;
+    bit=fBuffer&0x1;
     bit=bit<<i;
     result=result|bit;
+    fReadBits++;
+    fBuffer=fBuffer>>1;
   }//end for
   return result;
 }
 
 //////////////////////////////////////////////////////////////////////////////////////////////////
+inline UInt_t AliTPCCompression::ReadBitFromWordBuffer(){
+  //This method retrieves a word of a specific number of bits from the file through the buffer 
+  UInt_t result=0;
+
+  if (fReadBits==32){
+    fPointBuffer--;
+    fBuffer=*fPointBuffer;
+    fReadBits=0;
+  }//end if
+  result=fBuffer&0x1;
+  fReadBits++;
+  fBuffer=fBuffer>>1;
+  return result;
+}
+
+//////////////////////////////////////////////////////////////////////////////////////////////////
 void AliTPCCompression::ReadTrailer(Int_t &WordsNumber,Int_t &PadNumber,Int_t &RowNumber,Int_t &SecNumber,Bool_t Memory){
   //It retrieves a trailer 
   if(Memory){
-    ReadWordBuffer(1);
+    ReadBitFromWordBuffer();
     SecNumber=ReadWordBuffer(9);
     RowNumber=ReadWordBuffer(10);
     PadNumber=ReadWordBuffer(10);
@@ -952,17 +959,34 @@ void AliTPCCompression::ReadTrailer(Int_t &WordsNumber,Int_t &PadNumber,Int_t &R
   return;
 }
 //////////////////////////////////////////////////////////////////////////////////////////////////
-UInt_t AliTPCCompression::GetDecodedWord(AliTPCHNode* root,Bool_t Memory){
+inline UInt_t AliTPCCompression::GetDecodedWordBuffer(AliTPCHNode* root){
   //This method retrieves a decoded word.
   AliTPCHNode *node=root;
   UInt_t symbol=0;
   Bool_t decoded=0;
+
   while(!decoded){
-    UInt_t bit=0;
-    if(Memory)
-      bit=ReadWordBuffer(1);
+    UInt_t bit=ReadBitFromWordBuffer();
+    if(bit)
+      node=node->GetRight();
     else
-      bit=ReadWord(1);
+      node=node->GetLeft();
+    if (!(node->GetLeft())){
+      symbol=node->GetSymbol();
+      decoded=1;
+    }
+  }//end while
+  return symbol;
+}
+
+inline UInt_t AliTPCCompression::GetDecodedWord(AliTPCHNode* root){
+  //This method retrieves a decoded word.
+  AliTPCHNode *node=root;
+  UInt_t symbol=0;
+  Bool_t decoded=0;
+
+  while(!decoded){
+    UInt_t bit=ReadWord(1);
     if(bit)
       node=node->GetRight();
     else
@@ -972,6 +996,7 @@ UInt_t AliTPCCompression::GetDecodedWord(AliTPCHNode* root,Bool_t Memory){
       decoded=1;
     }
   }//end while
+
   return symbol;
 }
 //////////////////////////////////////////////////////////////////////////////////////////////////
@@ -1036,7 +1061,7 @@ Int_t AliTPCCompression::DecompressDataOptTables(Int_t NumTables,const char* fna
     Int_t bunchLen=0;
     Int_t count=0;
     for(Int_t i=0;i<numWords;i++){
-      UInt_t symbol=GetDecodedWord(rootNode[nextTableType],kFALSE);
+      UInt_t symbol=GetDecodedWord(rootNode[nextTableType]);
       wordsRead++;
       //Time reconstruction
       if (nextTableType==1){
@@ -1073,23 +1098,16 @@ Int_t AliTPCCompression::DecompressDataOptTables(Int_t NumTables,const char* fna
 Int_t AliTPCCompression::Decompress(AliTPCHNode *RootNode[],Int_t /*NumTables*/,char* PointBuffer,UInt_t BufferSize,UShort_t out[],UInt_t &dim){
   //This method decompress a file using separate Huffman tables
 
-  fPointBuffer=PointBuffer+BufferSize-4;
+  //  fPointBuffer=((UInt_t *)PointBuffer)+(UInt_t)(BufferSize/4)-1;
+  fPointBuffer=(UInt_t *)(PointBuffer+BufferSize-4);
   fReadBits=0;
   fBuffer=0;
   
-  for(Int_t i=0;i<4;i++){
-    UInt_t val=0;
-    val=*fPointBuffer;
-    val&=0xFF;
-    fPointBuffer++;
-    val<<=8*i;
-    fBuffer=fBuffer|val;
-  }//end for
+  fBuffer=*fPointBuffer;
   Int_t bit=0;
-  UInt_t mask=0x1;
   while(!bit){
-    bit=fBuffer&mask;
-    mask=mask<<1;
+    bit=fBuffer&0x1;
+    fBuffer=fBuffer>>1;
     fReadBits++;
   }//end while
   UInt_t packetNumber=ReadWordBuffer(sizeof(UInt_t)*8); //32 bits
@@ -1121,7 +1139,7 @@ Int_t AliTPCCompression::Decompress(AliTPCHNode *RootNode[],Int_t /*NumTables*/,
     Int_t count=0;
     Int_t timeDigit=0;
     for(Int_t i=0;i<numWords;i++){
-      UInt_t symbol=GetDecodedWord(RootNode[nextTableType],kTRUE);
+      UInt_t symbol=GetDecodedWordBuffer(RootNode[nextTableType]);
       wordsRead++;
       //Time reconstruction
       if (nextTableType==1){
index bf0d1f1..05e6814 100644 (file)
@@ -79,9 +79,12 @@ class AliTPCCompression:public TObject{
   //this method is used to read a specified number of bits from the compressed file
   UInt_t  ReadWordBuffer(Int_t NumberOfBit);
   //this method is used to read a specified number of bits from the compressed memory buffer
+  inline UInt_t ReadBitFromWordBuffer();
   void    ReadTrailer(Int_t &WordsNumber,Int_t &PadNumber,Int_t &RowNumber,Int_t &SecNumberr,Bool_t Memory);
   //This method is used to read the trailer 
-  UInt_t GetDecodedWord(AliTPCHNode* root,Bool_t Memory);
+  inline UInt_t GetDecodedWordBuffer(AliTPCHNode* root);
+  //This method is used to get a decoded word from the compressed file
+  inline UInt_t GetDecodedWord(AliTPCHNode* root);
   //This method is used to get a decoded word from the compressed file
 
   fstream f;                  // f is the logical name for the compressed and uncompressed file
@@ -93,7 +96,7 @@ class AliTPCCompression:public TObject{
   UInt_t  fPos;               // current file position
   Int_t   fVerbose;           // verbose level (0 silent, !=0 output messages)
   UInt_t  fFillWords;         // Number of hexadecimally words (2AA pattern) inside a pad data block 
-  char*   fPointBuffer;       //pointer to the compressed raw data
+  UInt_t* fPointBuffer;       //pointer to the compressed raw data
   ClassDef(AliTPCCompression,1)
 };
 #endif
index 9d6ee8a..24f84e6 100644 (file)
@@ -23,12 +23,12 @@ class AliTPCHNode: public TObject  {
   Int_t   Compare(const TObject *obj) const;
   void    SetLeft(AliTPCHNode* point){fLeft=point;}
   void    SetRight(AliTPCHNode* point){fRight=point;}
-  AliTPCHNode* GetRight()const{return fRight;}
-  AliTPCHNode* GetLeft()const{return fLeft;}
+  inline AliTPCHNode* GetRight()const{return fRight;}
+  inline AliTPCHNode* GetLeft()const{return fLeft;}
   void     SetSymbol(Int_t sym){fSymbol=sym;}
   void     SetFrequency(Double_t freq){fFrequency=freq;}
   Double_t GetFrequency()const{return fFrequency;}
-  Int_t    GetSymbol()const{return fSymbol;}
+  inline Int_t    GetSymbol()const{return fSymbol;}
 
  private:
   Int_t         fSymbol;       // Symbols
index 2598d6f..5d6f27b 100644 (file)
@@ -74,6 +74,15 @@ AliTPCRawStream::~AliTPCRawStream()
   delete[] fData;
 }
 
+void AliTPCRawStream::Reset()
+{
+// reset tpc raw stream params
+
+  fDataSize = fPosition = 0;
+  fCount = fBunchLength = 0;
+
+  fSector = fPrevSector = fRow = fPrevRow = fPad = fPrevPad = fTime = fSignal = -1;
+}
 
 Bool_t AliTPCRawStream::Next()
 {
index 4226c46..098a871 100644 (file)
@@ -23,20 +23,21 @@ class AliTPCRawStream: public TObject {
     AliTPCRawStream(const AliTPCRawStream& stream);
     AliTPCRawStream& operator = (const AliTPCRawStream& stream);
     virtual ~AliTPCRawStream();
+    void Reset();
 
     virtual Bool_t   Next();
 
-    Int_t            GetSector() const {return fSector;};
-    Int_t            GetPrevSector() const {return fPrevSector;};
-    Bool_t           IsNewSector() const {return fSector != fPrevSector;};
-    Int_t            GetRow() const {return fRow;};
-    Int_t            GetPrevRow() const {return fPrevRow;};
-    Bool_t           IsNewRow() const {return (fRow != fPrevRow) || IsNewSector();};
-    Int_t            GetPad() const {return fPad;};
-    Int_t            GetPrevPad() const {return fPrevPad;};
-    Bool_t           IsNewPad() const {return (fPad != fPrevPad) || IsNewRow();};
-    Int_t            GetTime() const {return fTime;};
-    Int_t            GetSignal() const {return fSignal;};
+    inline Int_t            GetSector() const {return fSector;};
+    inline Int_t            GetPrevSector() const {return fPrevSector;};
+    inline Bool_t           IsNewSector() const {return fSector != fPrevSector;};
+    inline Int_t            GetRow() const {return fRow;};
+    inline Int_t            GetPrevRow() const {return fPrevRow;};
+    inline Bool_t           IsNewRow() const {return (fRow != fPrevRow) || IsNewSector();};
+    inline Int_t            GetPad() const {return fPad;};
+    inline Int_t            GetPrevPad() const {return fPrevPad;};
+    inline Bool_t           IsNewPad() const {return (fPad != fPrevPad) || IsNewRow();};
+    inline Int_t            GetTime() const {return fTime;};
+    inline Int_t            GetSignal() const {return fSignal;};
 
   protected :
     UShort_t         Get10BitWord(UChar_t* buffer, Int_t position) const;