]> git.uio.no Git - u/mrichter/AliRoot.git/commitdiff
Added more comments.
authorvestbo <vestbo@f7af4fe6-9843-0410-8265-dc069ae4e863>
Wed, 17 Apr 2002 14:29:53 +0000 (14:29 +0000)
committervestbo <vestbo@f7af4fe6-9843-0410-8265-dc069ae4e863>
Wed, 17 Apr 2002 14:29:53 +0000 (14:29 +0000)
HLT/src/AliL3MemHandler.cxx

index c29199ca5d368df7a5194ffcf43db798c4d081df..aabb2ebc75eca4b2f3aac09214d03b6e1d9adb38 100644 (file)
 //
 // The L3 Binary File handler 
 //
-
+/**
+  This class does all the memory I/O handling on raw binary files.
+  For the moment the compressed binary files are run-length encoded, using
+  10 bit digits.
+  
+  Examples:
+  
+  1) Reading a binary file:
+  
+  AliL3MemHandler file;
+  file.SetBinaryInput(filename);
+  
+  UInt_t ndigits;
+  AliL3DigitRowData *data = file.CompBinary2Memory(ndigits);
+  
+  for(int i=0; i<NumberOfRowsInPatch; i++) 
+    {
+    
+    AliL3DigitData *dataPt = (AliL3DigitData*)data->fDigitData;
+    for(int j=0; j<data->fNDigit; j++) 
+      {
+      pad = dataPt[j].fPad;
+      time = dataPt[j].fTime;
+      charge = dataPt[j].fCharge;
+      }
+      
+    file.UpdateRowPointer(data);
+  
+    }
+  file.CloseBinaryInput();
+  ________________________
+  
+  2) Writing a binary file:
+  
+  //First of all you need to store the data in memory,
+  //and have a pointer to it of type AliL3DigitRowData.
+  //E.g. if you just want to write the data you read in example 1)
+  //into a new file, you can do the following:
+  
+  AliL3MemHandler newfile;
+  newfile.SetBinaryOutput(newfilename);
+  newfile.Memory2CompBinary((UInt_t)NumberOfRowsInPatch,(AliL3DigitRowData*)data);
+  newfile.CloseBinaryOutput();
+  
+  
+*/
 ClassImp(AliL3MemHandler)
 
-AliL3MemHandler::AliL3MemHandler(){
-  // Default constructor
+AliL3MemHandler::AliL3MemHandler()
+{
+  ///Constructor
+  
   fPt = 0;
   fSize =0;
   fInBinary = 0;
@@ -46,67 +93,85 @@ AliL3MemHandler::AliL3MemHandler(){
 }
 
 
-AliL3MemHandler::~AliL3MemHandler(){
-  //Destructor
+AliL3MemHandler::~AliL3MemHandler()
+{
+  ///Destructor
   if(fPt) delete[] fPt;
   if(fDigits) delete [] fDigits;
   if(fDPt) delete [] fDPt;
 }
 
-void AliL3MemHandler::ResetROI(){
-    for(Int_t i=fRowMin; i<=fRowMax; i++)
-      {
+void AliL3MemHandler::ResetROI()
+{
+  //*Resets the Look-up table for Region of Interest mode.
+  
+  for(Int_t i=fRowMin; i<=fRowMax; i++)
+    {
       fEtaMinTimeBin[i] = 0;
       fEtaMaxTimeBin[i] = 445;
-      }
+    }
 }
 
 
-void AliL3MemHandler::SetROI(Float_t *eta,Int_t *slice){
- if(eta[1]==0)
-     {
-     LOG(AliL3Log::kWarning,"AliL3MemHandler::SetROI","Eta Values")
-        <<"Bad ROI parameters. IDIOT! "<<ENDLOG;
-     for(Int_t i=fRowMin; i<=fRowMax; i++)
-        {
-        fEtaMinTimeBin[i]=0;
-        fEtaMaxTimeBin[i]=0;
-        }
-     return;
-     }
- for(Int_t i=fRowMin; i<=fRowMax; i++)
-     {
-     Int_t sector,row;
-     Float_t xyz[3];
-     
-     Float_t thetamax = 2*atan(exp(-1.*eta[1]));
-     
-     xyz[0] = fTransformer->Row2X(i);
-     xyz[1]=0;
-     xyz[2] = xyz[0]/tan(thetamax);
-     fTransformer->Slice2Sector(fSlice,i,sector,row);
-     fTransformer->Local2Raw(xyz,sector,row);
-     
-     fEtaMinTimeBin[i] = (Int_t)xyz[2];
-     
-     if(eta[0]==0)
-        fEtaMaxTimeBin[i] = 445;
-     else
-        {
-        Float_t thetamin = 2*atan(exp(-1.*eta[0]));
-        xyz[0] = fTransformer->Row2X(i);
-        xyz[1] = fTransformer->GetMaxY(i);
-        Float_t radii = sqrt(pow(xyz[0],2) + pow(xyz[1],2));
-        xyz[2] = radii/tan(thetamin);
-        fTransformer->Local2Raw(xyz,sector,row);
-        fEtaMaxTimeBin[i] = (Int_t)xyz[2];
-        }
-     }
+void AliL3MemHandler::SetROI(Float_t *eta,Int_t *slice)
+{
+  /**
+     Init the Look-up table for the Region of Interest mode.
+     Here you can specify a certain etaregion, - all data
+     outside this region will be discarded:
+     eta[0] = mimium eta
+     eta[1] = maximum eta
+     slice[0] = mimumum slice
+     slice[1] = maximum slice
+  */
+  if(eta[1]==0)
+    {
+      LOG(AliL3Log::kWarning,"AliL3MemHandler::SetROI","Eta Values")
+       <<"Bad ROI parameters. IDIOT! "<<ENDLOG;
+      for(Int_t i=fRowMin; i<=fRowMax; i++)
+       {
+         fEtaMinTimeBin[i]=0;
+         fEtaMaxTimeBin[i]=0;
+       }
+      return;
+    }
+  
+  for(Int_t i=fRowMin; i<=fRowMax; i++)
+    {
+      Int_t sector,row;
+      Float_t xyz[3];
+      
+      Float_t thetamax = 2*atan(exp(-1.*eta[1]));
+      
+      xyz[0] = fTransformer->Row2X(i);
+      xyz[1]=0;
+      xyz[2] = xyz[0]/tan(thetamax);
+      fTransformer->Slice2Sector(fSlice,i,sector,row);
+      fTransformer->Local2Raw(xyz,sector,row);
+      
+      fEtaMinTimeBin[i] = (Int_t)xyz[2];
+      
+      if(eta[0]==0)
+       fEtaMaxTimeBin[i] = 445;
+      else
+       {
+         Float_t thetamin = 2*atan(exp(-1.*eta[0]));
+         xyz[0] = fTransformer->Row2X(i);
+         xyz[1] = fTransformer->GetMaxY(i);
+         Float_t radii = sqrt(pow(xyz[0],2) + pow(xyz[1],2));
+         xyz[2] = radii/tan(thetamin);
+         fTransformer->Local2Raw(xyz,sector,row);
+         fEtaMaxTimeBin[i] = (Int_t)xyz[2];
+       }
+    }
+  
 }
 
-Bool_t AliL3MemHandler::SetBinaryInput(char *name){
+Bool_t AliL3MemHandler::SetBinaryInput(char *name)
+{
+  /**
+     Set the input binary file.
+   */
   fInBinary = fopen(name,"r");
   if(!fInBinary){
     LOG(AliL3Log::kWarning,"AliL3MemHandler::SetBinaryInput","File Open")
@@ -116,7 +181,11 @@ Bool_t AliL3MemHandler::SetBinaryInput(char *name){
   return kTRUE;
 }
 
-Bool_t AliL3MemHandler::SetBinaryInput(FILE *file){
+Bool_t AliL3MemHandler::SetBinaryInput(FILE *file)
+{
+  /**
+     Set the input binary file.
+   */
   fInBinary = file;
   if(!fInBinary){
     LOG(AliL3Log::kWarning,"AliL3MemHandler::SetBinaryInput","File Open")
@@ -126,40 +195,53 @@ Bool_t AliL3MemHandler::SetBinaryInput(FILE *file){
   return kTRUE;
 }
 
-void AliL3MemHandler::CloseBinaryInput(){
+void AliL3MemHandler::CloseBinaryInput()
+{
+  /**
+     Close the input file.
+   */
   if(!fInBinary){
     LOG(AliL3Log::kWarning,"AliL3MemHandler::CloseBinaryInput","File Close")
-    <<"Nothing to Close"<<ENDLOG;
+      <<"Nothing to Close"<<ENDLOG;
     return;
   }
   fclose(fInBinary);
   fInBinary =0;
 }
 
-Bool_t AliL3MemHandler::SetBinaryOutput(char *name){
+Bool_t AliL3MemHandler::SetBinaryOutput(char *name)
+{
+  /**
+     Set the binary output file.
+  */
   fOutBinary = fopen(name,"w");
   if(!fOutBinary){
     LOG(AliL3Log::kWarning,"AliL3MemHandler::SetBinaryOutput","File Open")
-    <<"Pointer to File = 0x0 "<<ENDLOG;
+      <<"Pointer to File = 0x0 "<<ENDLOG;
     return kFALSE;
   }
   return kTRUE;
 }
 
-Bool_t AliL3MemHandler::SetBinaryOutput(FILE *file){
+Bool_t AliL3MemHandler::SetBinaryOutput(FILE *file)
+{
+  /**
+     Set the binary output file.
+  */
   fOutBinary = file;
   if(!fOutBinary){
     LOG(AliL3Log::kWarning,"AliL3MemHandler::SetBinaryOutput","File Open")
-    <<"Pointer to File = 0x0 "<<ENDLOG;
+      <<"Pointer to File = 0x0 "<<ENDLOG;
     return kFALSE;
   }
   return kTRUE;
 }
 
-void AliL3MemHandler::CloseBinaryOutput(){
+void AliL3MemHandler::CloseBinaryOutput()
+{
   if(!fOutBinary){
     LOG(AliL3Log::kWarning,"AliL3MemHandler::CloseBinaryOutPut","File Close")
-    <<"Nothing to Close"<<ENDLOG;
+      <<"Nothing to Close"<<ENDLOG;
     return;
   }
   fclose(fOutBinary);
@@ -167,10 +249,14 @@ void AliL3MemHandler::CloseBinaryOutput(){
 }
 
 
-UInt_t AliL3MemHandler::GetFileSize(){
+UInt_t AliL3MemHandler::GetFileSize()
+{
+  /**
+     Returns the file size in bytes of the input file.
+   */
   if(!fInBinary){
     LOG(AliL3Log::kWarning,"AliL3MemHandler::GetFileSize","File")
-    <<"No Input File"<<ENDLOG;
+      <<"No Input File"<<ENDLOG;
     return 0;
   }
   fseek(fInBinary,0,SEEK_END);
@@ -179,23 +265,32 @@ UInt_t AliL3MemHandler::GetFileSize(){
   return size; 
 }
 
-Byte_t *AliL3MemHandler::Allocate(){
+Byte_t *AliL3MemHandler::Allocate()
+{
   return Allocate(GetFileSize()); 
 }
 
-Byte_t *AliL3MemHandler::Allocate(AliL3TrackArray *array){
+Byte_t *AliL3MemHandler::Allocate(AliL3TrackArray *array)
+{
+  /**
+     Allocate memory for tracks in memory. Used by TrackArray2Binary()
+  */
   if(!array){
     LOG(AliL3Log::kWarning,"AliL3MemHandler::Allocate","Memory")
-    <<"Pointer to AliL3TrackArray = 0x0 "<<ENDLOG;
+      <<"Pointer to AliL3TrackArray = 0x0 "<<ENDLOG;
     return 0;
   }
   return Allocate(array->GetOutSize()); 
 }
 
-Byte_t *AliL3MemHandler::Allocate(UInt_t size){
+Byte_t *AliL3MemHandler::Allocate(UInt_t size)
+{
+  /**
+     Allocate memory of size in bytes.
+  */
   if(fPt){
     LOG(AliL3Log::kWarning,"AliL3MemHandler::Allocate","Memory")
-    <<"Delete Memory"<<ENDLOG;
+      <<"Delete Memory"<<ENDLOG;
     Free();
   } 
   fPt = new Byte_t[size];
@@ -206,10 +301,14 @@ Byte_t *AliL3MemHandler::Allocate(UInt_t size){
   return fPt;
 }
 
-void AliL3MemHandler::Free(){
+void AliL3MemHandler::Free()
+{
+  /**
+     Clear the memory, if allocated.
+   */
   if(!fPt){
     LOG(AliL3Log::kWarning,"AliL3MemHandler::Free","Memory")
-    <<"No Memory allocated - can't Free"<<ENDLOG;
+      <<"No Memory allocated - can't Free"<<ENDLOG;
     return;
   }  
   delete[] fPt;
@@ -218,12 +317,20 @@ void AliL3MemHandler::Free(){
 }
 
 ///////////////////////////////////////// Random
-void AliL3MemHandler::SetRandomSeed(){
+void AliL3MemHandler::SetRandomSeed()
+{
+  /**
+     If you are adding random data to the original data.
+   */
   time_t *tp=0;
   SetRandomSeed(time(tp));
 }
 
-void AliL3MemHandler::SetRandomCluster(Int_t maxnumber){
+void AliL3MemHandler::SetRandomCluster(Int_t maxnumber)
+{
+  /**
+     If you are adding random data to the original data.
+   */
   IsRandom = kTRUE;
   fNRandom = maxnumber;
   fNDigits = 0;
@@ -233,49 +340,51 @@ void AliL3MemHandler::SetRandomCluster(Int_t maxnumber){
   fDPt = new AliL3RandomDigitData *[fNRandom*9];
 }
 
-void AliL3MemHandler::QSort(AliL3RandomDigitData **a, Int_t first, Int_t last){
-
-   // Sort array of AliL3RandomDigitData pointers using a quicksort algorithm.
-   // Uses CompareDigits() to compare objects.
-   // Thanks to Root!
-
-   static AliL3RandomDigitData *tmp;
-   static int i;           // "static" to save stack space
-   int j;
-
-   while (last - first > 1) {
-      i = first;
-      j = last;
-      for (;;) {
-         while (++i < last && CompareDigits(a[i], a[first]) < 0)
-            ;
-         while (--j > first && CompareDigits(a[j], a[first]) > 0)
-            ;
-         if (i >= j)
-            break;
-
-         tmp  = a[i];
-         a[i] = a[j];
-         a[j] = tmp;
-      }
-      if (j == first) {
-         ++first;
-         continue;
-      }
-      tmp = a[first];
-      a[first] = a[j];
+void AliL3MemHandler::QSort(AliL3RandomDigitData **a, Int_t first, Int_t last)
+{
+  
+  //* Sort array of AliL3RandomDigitData pointers using a quicksort algorithm.
+  //* Uses CompareDigits() to compare objects.
+  //* Thanks to Root!
+  
+  static AliL3RandomDigitData *tmp;
+  static int i;           // "static" to save stack space
+  int j;
+  
+  while (last - first > 1) {
+    i = first;
+    j = last;
+    for (;;) {
+      while (++i < last && CompareDigits(a[i], a[first]) < 0)
+       ;
+      while (--j > first && CompareDigits(a[j], a[first]) > 0)
+       ;
+      if (i >= j)
+       break;
+      
+      tmp  = a[i];
+      a[i] = a[j];
       a[j] = tmp;
-      if (j - first < last - (j + 1)) {
-         QSort(a, first, j);
-         first = j + 1;   // QSort(j + 1, last);
-      } else {
-         QSort(a, j + 1, last);
-         last = j;        // QSort(first, j);
-      }
-   }
+    }
+    if (j == first) {
+      ++first;
+      continue;
+    }
+    tmp = a[first];
+    a[first] = a[j];
+    a[j] = tmp;
+    if (j - first < last - (j + 1)) {
+      QSort(a, first, j);
+      first = j + 1;   // QSort(j + 1, last);
+    } else {
+      QSort(a, j + 1, last);
+      last = j;        // QSort(first, j);
+    }
+  }
 }
 
-UInt_t AliL3MemHandler::GetRandomSize(){
+UInt_t AliL3MemHandler::GetRandomSize()
+{
   Int_t nrandom = 0;
   for(Int_t r=fRowMin;r<=fRowMax;r++){
     Int_t npad=fTransformer->GetNPads(r);
@@ -284,15 +393,19 @@ UInt_t AliL3MemHandler::GetRandomSize(){
   return 9 * nrandom * sizeof(AliL3DigitData);
 }
 
-void AliL3MemHandler::Generate(Int_t row){
+void AliL3MemHandler::Generate(Int_t row)
+{
+  /**
+     Generate random data on row, if you didn't ask for this, nothing happens here.
+   */
   if(!IsRandom) return;
   ResetRandom();
   fNDigits = 0;
   Int_t npad=fTransformer->GetNPads(row);
   Int_t ntime = fEtaMaxTimeBin[row] - fEtaMinTimeBin[row];
   Int_t nrandom  = Int_t (fNGenerate * ((Double_t) npad/141.) * 
-                   (Double_t) ntime/(Double_t) fTransformer->GetNTimeBins() );
+                         (Double_t) ntime/(Double_t) fTransformer->GetNTimeBins() );
+  
   for(Int_t n=0;n<nrandom;n++){
     Int_t pad = (int)((float)rand()/RAND_MAX*npad);
     Int_t time =(int)((float)rand()/RAND_MAX*ntime+fEtaMinTimeBin[row] );
@@ -300,14 +413,18 @@ void AliL3MemHandler::Generate(Int_t row){
     DigitizePoint(row,pad,time,charge);
   }
   QSort(fDPt,0,fNDigits);
-//  for(Int_t d=0;d<fNDigits;d++)
-//    fprintf(stderr,"%d %d %d %d\n",fDPt[d]->fRow,fDPt[d]->fPad,
-//                             fDPt[d]->fTime,fDPt[d]->fCharge);
+  //  for(Int_t d=0;d<fNDigits;d++)
+  //    fprintf(stderr,"%d %d %d %d\n",fDPt[d]->fRow,fDPt[d]->fPad,
+  //                             fDPt[d]->fTime,fDPt[d]->fCharge);
 }
 
 
 void AliL3MemHandler::DigitizePoint(Int_t row, Int_t pad, 
-                                       Int_t time,Int_t charge){
+                                   Int_t time,Int_t charge)
+{
+  /**
+     Making one single random cluster.
+   */
   for(Int_t j=-1;j<2;j++){
     for(Int_t k=-1;k<2;k++){
       Int_t dcharge = charge;
@@ -316,10 +433,10 @@ void AliL3MemHandler::DigitizePoint(Int_t row, Int_t pad,
       if(dcharge<10) continue;
       Int_t dpad  = j + pad;
       Int_t dtime = k + time;
-
+      
       if(dpad<0||dpad>=fTransformer->GetNPads(row))  continue;
       if(dtime<0||dtime>=fTransformer->GetNTimeBins()) continue;
-
+      
       fDigits[fNDigits].fCharge = dcharge;
       fDigits[fNDigits].fRow = row;
       fDigits[fNDigits].fPad = dpad;
@@ -331,23 +448,28 @@ void AliL3MemHandler::DigitizePoint(Int_t row, Int_t pad,
 }
 
 ///////////////////////////////////////// Digit IO  
-Bool_t AliL3MemHandler::Memory2Binary(UInt_t nrow,AliL3DigitRowData *data){
+Bool_t AliL3MemHandler::Memory2Binary(UInt_t nrow,AliL3DigitRowData *data)
+{
+  /**
+     Write data to the outputfile as is. No run-length encoding is done.
+  
+   */
   if(!fOutBinary){
     LOG(AliL3Log::kWarning,"AliL3MemHandler::Memory2Binary","File")
-    <<"No Output File"<<ENDLOG;
+      <<"No Output File"<<ENDLOG;
     return kFALSE;
   }
   if(!data){
     LOG(AliL3Log::kWarning,"AliL3MemHandler::Memory2Binary","Memory")
-    <<"Pointer to AliL3DigitRowData = 0x0 "<<ENDLOG;
+      <<"Pointer to AliL3DigitRowData = 0x0 "<<ENDLOG;
     return kFALSE;
   }
-
+  
   AliL3DigitRowData *row_pt = data; 
   Int_t outsize = 0;
   for(UInt_t i=0;i<nrow;i++){
     Int_t size = sizeof(AliL3DigitData) * row_pt->fNDigit 
-                                       + sizeof(AliL3DigitRowData);
+      + sizeof(AliL3DigitRowData);
     outsize += size;
     fwrite(row_pt,size,1,fOutBinary);
     Byte_t  *byte_pt =(Byte_t *) row_pt;
@@ -355,20 +477,25 @@ Bool_t AliL3MemHandler::Memory2Binary(UInt_t nrow,AliL3DigitRowData *data){
     row_pt = (AliL3DigitRowData *) byte_pt;
   }
   LOG(AliL3Log::kDebug,"AliL3MemHandler::Memory2Binary","Memory")
-  <<AliL3Log::kDec<<"Wrote "<<outsize<<" Bytes to Memory ("
-  <<nrow<<" Rows)"<<ENDLOG;
+    <<AliL3Log::kDec<<"Wrote "<<outsize<<" Bytes to Memory ("
+    <<nrow<<" Rows)"<<ENDLOG;
   return kTRUE;
 }
 
-Bool_t AliL3MemHandler::Binary2Memory(UInt_t & nrow,AliL3DigitRowData *data){
+Bool_t AliL3MemHandler::Binary2Memory(UInt_t & nrow,AliL3DigitRowData *data)
+{
+  /**
+     Read inputfile into memory as is, and store it in data. No run-length encoding
+     is assumed.
+   */
   if(!fInBinary){
     LOG(AliL3Log::kWarning,"AliL3MemHandler::Binary2Memory","File")
-    <<"No Input File"<<ENDLOG;
+      <<"No Input File"<<ENDLOG;
     return kFALSE;
   }
   if(!data){
     LOG(AliL3Log::kWarning,"AliL3MemHandler::Binary2Memory","Memory")
-    <<"Pointer to AliL3DigitRowData = 0x0 "<<ENDLOG;
+      <<"Pointer to AliL3DigitRowData = 0x0 "<<ENDLOG;
     return kFALSE;
   }
   rewind(fInBinary);
@@ -399,14 +526,16 @@ Bool_t AliL3MemHandler::Binary2Memory(UInt_t & nrow,AliL3DigitRowData *data){
 }
 
 void AliL3MemHandler::AddData(AliL3DigitData *data,UInt_t & ndata,
-                   UInt_t row,UShort_t pad,UShort_t time,UShort_t charge){
+                             UInt_t row,UShort_t pad,UShort_t time,UShort_t charge)
+{
   data[ndata].fPad = pad;
   data[ndata].fTime = time;
   data[ndata].fCharge = charge;
   ndata++;
 }
 
-void AliL3MemHandler::AddRandom(AliL3DigitData *data, UInt_t & ndata){
+void AliL3MemHandler::AddRandom(AliL3DigitData *data, UInt_t & ndata)
+{
   data[ndata].fPad = fDPt[fNUsed]->fPad;
   data[ndata].fTime = fDPt[fNUsed]->fTime;
   data[ndata].fCharge = fDPt[fNUsed]->fCharge;
@@ -415,8 +544,8 @@ void AliL3MemHandler::AddRandom(AliL3DigitData *data, UInt_t & ndata){
 }
 
 void AliL3MemHandler::MergeDataRandom(AliL3DigitData *data, UInt_t & ndata,
-                   UInt_t row, UShort_t pad, UShort_t time, UShort_t charge){
-//  AddData(data,ndata,row,pad,time,charge);
+                                     UInt_t row, UShort_t pad, UShort_t time, UShort_t charge)
+{
   data[ndata].fPad = pad;
   data[ndata].fTime = time;
   data[ndata].fCharge = charge;
@@ -430,7 +559,8 @@ void AliL3MemHandler::MergeDataRandom(AliL3DigitData *data, UInt_t & ndata,
 }
 
 void AliL3MemHandler::AddDataRandom(AliL3DigitData *data, UInt_t & ndata,
-                   UInt_t row, UShort_t pad, UShort_t time, UShort_t charge){
+                   UInt_t row, UShort_t pad, UShort_t time, UShort_t charge)
+{
   Int_t action;
   while((action=ComparePoints(row,pad,time))==1){
     AddRandom(data,ndata);
@@ -444,7 +574,8 @@ void AliL3MemHandler::AddDataRandom(AliL3DigitData *data, UInt_t & ndata,
 }
 
 void AliL3MemHandler::Write(UInt_t *comp, UInt_t & index, 
-                                    UInt_t & subindex, UShort_t value){
+                           UInt_t & subindex, UShort_t value)
+{
   UInt_t shift[3] = {0,10,20};
   if(subindex==0) comp[index] =0; //clean up memory
   comp[index] |= (value&0x03ff)<<shift[subindex];
@@ -455,7 +586,8 @@ void AliL3MemHandler::Write(UInt_t *comp, UInt_t & index,
   else subindex++;
 }
 
-UShort_t AliL3MemHandler::Read(UInt_t *comp, UInt_t & index, UInt_t & subindex){
+UShort_t AliL3MemHandler::Read(UInt_t *comp, UInt_t & index, UInt_t & subindex)
+{
   UInt_t shift[3] = {0,10,20};
   UShort_t value = (comp[index]>>shift[subindex])&0x03ff;
   if(subindex == 2){
@@ -468,21 +600,27 @@ UShort_t AliL3MemHandler::Read(UInt_t *comp, UInt_t & index, UInt_t & subindex){
 }
 
 UShort_t AliL3MemHandler::Test(UInt_t *comp, 
-                         UInt_t index, UInt_t  subindex){
+                              UInt_t index, UInt_t  subindex)
+{
   UInt_t shift[3] = {0,10,20};
   return (comp[index]>>shift[subindex])&0x03ff;
 }
 
 Int_t AliL3MemHandler::Memory2CompMemory(UInt_t nrow,
-                                  AliL3DigitRowData *data,UInt_t *comp){
+                                        AliL3DigitRowData *data,UInt_t *comp)
+{
+  /**
+     Performs run-length encoding on data stored in memory pointed to by data.
+     The compressed data is written to comp.
+   */
   if(!comp){
     LOG(AliL3Log::kWarning,"AliL3MemHandler::Memory2CompMemory","Memory")
-    <<"Pointer to compressed data = 0x0 "<<ENDLOG;
+      <<"Pointer to compressed data = 0x0 "<<ENDLOG;
     return 0;
   }
   if(!data){
     LOG(AliL3Log::kWarning,"AliL3MemHandler::Memory2CompMemory","Memory")
-    <<"Pointer to AliL3DigitRowData = 0x0 "<<ENDLOG;
+      <<"Pointer to AliL3DigitRowData = 0x0 "<<ENDLOG;
     return 0;
   }
   AliL3DigitRowData *row_pt = data;
@@ -553,23 +691,28 @@ Int_t AliL3MemHandler::Memory2CompMemory(UInt_t nrow,
 }
 
 Int_t AliL3MemHandler::CompMemory2Memory(UInt_t  nrow,
-                                   AliL3DigitRowData *data,UInt_t *comp){
+                                        AliL3DigitRowData *data,UInt_t *comp)
+{
+  /**
+     Uncompress the run-length encoded data in memory pointed to by comp, and
+     store it in data.
+   */
   if(!comp){
     LOG(AliL3Log::kWarning,"AliL3MemHandler::CompMemory2Memory","Memory")
-    <<"Pointer to compressed data = 0x0 "<<ENDLOG;
+      <<"Pointer to compressed data = 0x0 "<<ENDLOG;
     return 0;
   }
   if(!data){
     LOG(AliL3Log::kWarning,"AliL3MemHandler::CompMemory2Memory","Memory")
-    <<"Pointer to AliL3DigitRowData = 0x0 "<<ENDLOG;
+      <<"Pointer to AliL3DigitRowData = 0x0 "<<ENDLOG;
     return 0;
   }
   Int_t outsize=0;
-
+  
   AliL3DigitRowData *row_pt = data;
   UInt_t index=0;
   UInt_t subindex=0;
-
+  
   for(UInt_t i=0;i<nrow;i++){
     UInt_t ndigit=0;
     UInt_t row =Read(comp,index,subindex);
@@ -589,7 +732,7 @@ Int_t AliL3MemHandler::CompMemory2Memory(UInt_t  nrow,
       for(;;){
         while( (charge=Read(comp,index,subindex)) != 0){
           if(time>=fEtaMinTimeBin[row]&&time<=fEtaMaxTimeBin[row])
-//          AddData(row_pt->fDigitData,ndigit,row,pad,time,charge);
+           //          AddData(row_pt->fDigitData,ndigit,row,pad,time,charge);
             AddDataRandom(row_pt->fDigitData,ndigit,row,pad,time,charge);
           time++;
         }
@@ -600,7 +743,7 @@ Int_t AliL3MemHandler::CompMemory2Memory(UInt_t  nrow,
     }
     row_pt->fNDigit = ndigit;
     Int_t size = sizeof(AliL3DigitData) * row_pt->fNDigit+
-                                        sizeof(AliL3DigitRowData);
+      sizeof(AliL3DigitRowData);
     Byte_t  *byte_pt =(Byte_t *) row_pt;
     byte_pt += size;
     outsize += size;
@@ -609,10 +752,14 @@ Int_t AliL3MemHandler::CompMemory2Memory(UInt_t  nrow,
   return outsize;
 }
 
-UInt_t AliL3MemHandler::GetCompMemorySize(UInt_t nrow,AliL3DigitRowData *data){
+UInt_t AliL3MemHandler::GetCompMemorySize(UInt_t nrow,AliL3DigitRowData *data)
+{
+  /**
+     Return the size of RLE data, after compressing data.
+   */
   if(!data){
     LOG(AliL3Log::kWarning,"AliL3MemHandler::GetCompMemorySize","Memory")
-    <<"Pointer to AliL3DigitRowData = 0x0 "<<ENDLOG;
+      <<"Pointer to AliL3DigitRowData = 0x0 "<<ENDLOG;
     return 0;
   }
   AliL3DigitRowData *row_pt = data;
@@ -641,7 +788,7 @@ UInt_t AliL3MemHandler::GetCompMemorySize(UInt_t nrow,AliL3DigitRowData *data){
       if(digit>=row_pt->fNDigit || row_pt->fDigitData[digit].fPad !=  pad)
         continue;
       index++;
-//    write zero if time != 0
+      //    write zero if time != 0
       if(digit<row_pt->fNDigit && row_pt->fDigitData[digit].fPad == pad){
         if(row_pt->fDigitData[digit].fTime>0){
           index++;
@@ -708,10 +855,11 @@ UInt_t AliL3MemHandler::GetMemorySize(UInt_t nrow,UInt_t *comp){
   return outsize;
 }
 
-UInt_t AliL3MemHandler::GetNRow(UInt_t *comp,UInt_t size){
+UInt_t AliL3MemHandler::GetNRow(UInt_t *comp,UInt_t size)
+{
   if(!comp){
     LOG(AliL3Log::kWarning,"AliL3MemHandler::GetNRow","Memory")
-    <<"Pointer to compressed data = 0x0 "<<ENDLOG;
+      <<"Pointer to compressed data = 0x0 "<<ENDLOG;
     return 0;
   }
   size = size /4;
@@ -744,7 +892,13 @@ UInt_t AliL3MemHandler::GetNRow(UInt_t *comp,UInt_t size){
 }
 
 Bool_t AliL3MemHandler::CompMemory2CompBinary(UInt_t nrow,UInt_t *comp,
-                                                               UInt_t size){
+                                             UInt_t size)
+{
+  /**
+     Write the RLE data in comp to the output file.
+     
+  */
+  
   if(!fOutBinary){
     LOG(AliL3Log::kWarning,"AliL3MemHandler::CompMemory2CompBinary","File")
     <<"No Output File"<<ENDLOG;
@@ -768,15 +922,19 @@ Bool_t AliL3MemHandler::CompMemory2CompBinary(UInt_t nrow,UInt_t *comp,
   return kTRUE;
 }
 
-Bool_t AliL3MemHandler::CompBinary2CompMemory(UInt_t & nrow,UInt_t *comp){
+Bool_t AliL3MemHandler::CompBinary2CompMemory(UInt_t & nrow,UInt_t *comp)
+{
+  /**
+     Read the RLE data from file, and store it in comp. No unpacking yet.
+   */
   if(!fInBinary){
     LOG(AliL3Log::kWarning,"AliL3MemHandler::CompBinary2CompMemory","File")
-    <<"No Output File"<<ENDLOG;
+      <<"No Output File"<<ENDLOG;
     return kFALSE;
   }
   if(!comp){
     LOG(AliL3Log::kWarning,"AliL3MemHandler::CompBinary2CompMemory","Memory")
-    <<"Pointer to compressed data = 0x0 "<<ENDLOG;
+      <<"Pointer to compressed data = 0x0 "<<ENDLOG;
     return kFALSE;
   }
   rewind(fInBinary);
@@ -789,7 +947,12 @@ Bool_t AliL3MemHandler::CompBinary2CompMemory(UInt_t & nrow,UInt_t *comp){
   return kTRUE;
 }
 
-AliL3DigitRowData *AliL3MemHandler::CompBinary2Memory(UInt_t & nrow){
+AliL3DigitRowData *AliL3MemHandler::CompBinary2Memory(UInt_t & nrow)
+{
+  /**
+     Read the RLE inputfile, unpack it and return the pointer to it.
+     
+   */
   AliL3MemHandler * handler = new AliL3MemHandler();
   handler->SetBinaryInput(fInBinary);
   UInt_t *comp =(UInt_t *)handler->Allocate();
@@ -802,7 +965,11 @@ AliL3DigitRowData *AliL3MemHandler::CompBinary2Memory(UInt_t & nrow){
   return data;  
 }
 
-Bool_t AliL3MemHandler::Memory2CompBinary(UInt_t nrow,AliL3DigitRowData *data){
+Bool_t AliL3MemHandler::Memory2CompBinary(UInt_t nrow,AliL3DigitRowData *data)
+{
+  /**
+     Perform RLE on the data, and write it to the output file.
+   */
   Bool_t out = kTRUE;
   AliL3MemHandler * handler = new AliL3MemHandler();
   UInt_t size = GetCompMemorySize(nrow,data);
@@ -816,25 +983,34 @@ Bool_t AliL3MemHandler::Memory2CompBinary(UInt_t nrow,AliL3DigitRowData *data){
 
 
 ///////////////////////////////////////// Point IO  
-Bool_t AliL3MemHandler::Memory2Binary(UInt_t npoint,AliL3SpacePointData *data){
+Bool_t AliL3MemHandler::Memory2Binary(UInt_t npoint,AliL3SpacePointData *data)
+{
+  /**
+     Writing spacepoints stored in data to the outputfile.
+   */
   if(!fOutBinary){
     LOG(AliL3Log::kWarning,"AliL3MemHandler::Memory2Binary","File")
-    <<"No Output File"<<ENDLOG;
+      <<"No Output File"<<ENDLOG;
     return kFALSE;
   }
   if(!data){
     LOG(AliL3Log::kWarning,"AliL3MemHandler::Memory2Binary","Memory")
-    <<"Pointer to AliL3SpacePointData = 0x0 "<<ENDLOG;
+      <<"Pointer to AliL3SpacePointData = 0x0 "<<ENDLOG;
     return kFALSE;
   }
   UInt_t size = npoint*sizeof(AliL3SpacePointData);
   fwrite(data,size,1,fOutBinary);
-
+  
   return kTRUE;
 }
 
 Bool_t AliL3MemHandler::Transform(UInt_t npoint,AliL3SpacePointData *data,
-                                 Int_t slice, AliL3Transform* trans){
+                                 Int_t slice, AliL3Transform* trans)
+{
+  /**
+     Transform the space points in data, to global coordinates in slice.
+     
+   */
   if(!data){
     LOG(AliL3Log::kWarning,"AliL3MemHandler::Transform","Memory")
     <<"Pointer to AliL3SpacePointData = 0x0 "<<ENDLOG;
@@ -858,7 +1034,11 @@ Bool_t AliL3MemHandler::Transform(UInt_t npoint,AliL3SpacePointData *data,
   return kTRUE;
 }
 
-Bool_t AliL3MemHandler::Binary2Memory(UInt_t & npoint,AliL3SpacePointData *data){
+Bool_t AliL3MemHandler::Binary2Memory(UInt_t & npoint,AliL3SpacePointData *data)
+{
+  /**
+     Read the space points in inputfile, and store it in data.
+   */
   if(!fInBinary){
     LOG(AliL3Log::kWarning,"AliL3MemHandler::Binary2Memory","File")
     <<"No Input File"<<ENDLOG;
@@ -923,7 +1103,11 @@ Bool_t AliL3MemHandler::Binary2Memory(UInt_t & npoint,AliL3SpacePointData *data)
 }
 
 ///////////////////////////////////////// Track IO  
-Bool_t AliL3MemHandler::Memory2Binary(UInt_t ntrack,AliL3TrackSegmentData *data){
+Bool_t AliL3MemHandler::Memory2Binary(UInt_t ntrack,AliL3TrackSegmentData *data)
+{
+  /**
+     Write the tracks stored in data, to outputfile.
+   */
   if(!fOutBinary){
     LOG(AliL3Log::kWarning,"AliL3MemHandler::Memory2Binary","File")
     <<"No Output File"<<ENDLOG;
@@ -948,7 +1132,11 @@ Bool_t AliL3MemHandler::Memory2Binary(UInt_t ntrack,AliL3TrackSegmentData *data)
   return kTRUE;
 }
 
-Bool_t AliL3MemHandler::Binary2Memory(UInt_t & ntrack,AliL3TrackSegmentData *data){
+Bool_t AliL3MemHandler::Binary2Memory(UInt_t & ntrack,AliL3TrackSegmentData *data)
+{
+  /**
+     Read the tracks in inputfile, and store it in data.
+   */
   if(!fInBinary){
     LOG(AliL3Log::kWarning,"AliL3MemHandler::Binary2Memory","File")
     <<"No Input File"<<ENDLOG;
@@ -1012,7 +1200,11 @@ Bool_t AliL3MemHandler::Binary2Memory(UInt_t & ntrack,AliL3TrackSegmentData *dat
   return kTRUE;
 }
 
-Bool_t AliL3MemHandler::TrackArray2Binary(AliL3TrackArray *array){
+Bool_t AliL3MemHandler::TrackArray2Binary(AliL3TrackArray *array)
+{
+  /**
+     Write the trackarray to the outputfile.
+   */
   if(!fOutBinary){
     LOG(AliL3Log::kWarning,"AliL3MemHandler::TrackArray2Binary","File")
     <<"No Output File"<<ENDLOG;
@@ -1031,7 +1223,12 @@ Bool_t AliL3MemHandler::TrackArray2Binary(AliL3TrackArray *array){
   return kTRUE;
 }
 
-Bool_t AliL3MemHandler::Binary2TrackArray(AliL3TrackArray *array){
+Bool_t AliL3MemHandler::Binary2TrackArray(AliL3TrackArray *array)
+{
+  /**
+     Read the tracks in inputfile, and fill it in trackarray. 
+     array should already be constructed.
+   */
   if(!fInBinary){
     LOG(AliL3Log::kWarning,"AliL3MemHandler::Binary2TrackArray","File")
     <<"No Input File"<<ENDLOG;
@@ -1050,7 +1247,11 @@ Bool_t AliL3MemHandler::Binary2TrackArray(AliL3TrackArray *array){
   return kTRUE;
 }
 
-Bool_t AliL3MemHandler::TrackArray2Memory(UInt_t & ntrack,AliL3TrackSegmentData *data,AliL3TrackArray *array){
+Bool_t AliL3MemHandler::TrackArray2Memory(UInt_t & ntrack,AliL3TrackSegmentData *data,AliL3TrackArray *array)
+{
+  /**
+     Fill the trackarray into the AliTrackSegmentData structures before writing to outputfile.
+   */
   if(!data){
     LOG(AliL3Log::kWarning,"AliL3MemHandler::TrackArray2Memory","Memory")
     <<"Pointer to AliL3TrackSegmentData = 0x0 "<<ENDLOG;
@@ -1065,7 +1266,11 @@ Bool_t AliL3MemHandler::TrackArray2Memory(UInt_t & ntrack,AliL3TrackSegmentData
   return kTRUE;
 }
 
-Bool_t AliL3MemHandler::Memory2TrackArray(UInt_t ntrack,AliL3TrackSegmentData *data,AliL3TrackArray *array){
+Bool_t AliL3MemHandler::Memory2TrackArray(UInt_t ntrack,AliL3TrackSegmentData *data,AliL3TrackArray *array)
+{
+  /**
+     Fill the tracks in data into trackarray.
+   */
   if(!data){
     LOG(AliL3Log::kWarning,"AliL3MemHandler::Memory2TrackArray","Memory")
     <<"Pointer to AliL3TrackSegmentData = 0x0 "<<ENDLOG;
@@ -1080,7 +1285,12 @@ Bool_t AliL3MemHandler::Memory2TrackArray(UInt_t ntrack,AliL3TrackSegmentData *d
   return kTRUE;
 }
 
-Bool_t AliL3MemHandler::Memory2TrackArray(UInt_t ntrack,AliL3TrackSegmentData *data,AliL3TrackArray *array,Int_t slice, AliL3Transform* trans){
+Bool_t AliL3MemHandler::Memory2TrackArray(UInt_t ntrack,AliL3TrackSegmentData *data,AliL3TrackArray *array,Int_t slice,
+                                         AliL3Transform* trans)
+{
+  /**
+     Fill the tracks in data into trackarray, and rotate the tracks to global coordinates.
+   */
   if(!data){
     LOG(AliL3Log::kWarning,"AliL3MemHandler::Memory2TrackArray","Memory")
     <<"Pointer to AliL3TrackSegmentData = 0x0 "<<ENDLOG;
@@ -1102,7 +1312,7 @@ Bool_t AliL3MemHandler::Memory2TrackArray(UInt_t ntrack,AliL3TrackSegmentData *d
 
 void AliL3MemHandler::UpdateRowPointer(AliL3DigitRowData *&tempPt)
 {
-  //Update the data pointer to the next padrow
+  //Update the data pointer to the next padrow in memory.
   
   Byte_t *tmp = (Byte_t*)tempPt;
   Int_t size = sizeof(AliL3DigitRowData) + tempPt->fNDigit*sizeof(AliL3DigitData);