]> git.uio.no Git - u/mrichter/AliRoot.git/blobdiff - TRD/AliTRDSignalIndex.cxx
Implementation of SetFirstRunGain, SetFirstRunGainLocal, SetFirstRunVdrift (Julian)
[u/mrichter/AliRoot.git] / TRD / AliTRDSignalIndex.cxx
index 1a2da5a3a961b0dde6b7740246142b3882811a69..780361f033e302a94b2dfc2afd9223000d1870df 100644 (file)
@@ -115,8 +115,8 @@ AliTRDSignalIndex::AliTRDSignalIndex(const AliTRDSignalIndex &a)
   fBoolIndex = new Bool_t[fMaxLimit];
   memcpy(fBoolIndex, a.fBoolIndex, fMaxLimit*sizeof(Bool_t));
 
-  fSortedIndex = new RowCol[fMaxLimit];
-  memcpy(fSortedIndex, a.fSortedIndex, fMaxLimit*sizeof(RowCol));
+  fSortedIndex = new RowCol[fMaxLimit+1];
+  memcpy(fSortedIndex, a.fSortedIndex, (fMaxLimit+1)*sizeof(RowCol));
 }
 
 //_____________________________________________________________________________
@@ -171,8 +171,8 @@ void AliTRDSignalIndex::Copy(TObject &a) const
     {
       delete [] ((AliTRDSignalIndex &)a).fSortedIndex;
     }
-  ((AliTRDSignalIndex &)a).fSortedIndex = new RowCol[fMaxLimit];
-  memcpy(((AliTRDSignalIndex &)a).fSortedIndex, fSortedIndex, fMaxLimit*sizeof(RowCol));
+  ((AliTRDSignalIndex &)a).fSortedIndex = new RowCol[fMaxLimit+1];
+  memcpy(((AliTRDSignalIndex &)a).fSortedIndex, fSortedIndex, (fMaxLimit+1)*sizeof(RowCol));
 
 }
 
@@ -211,7 +211,9 @@ void AliTRDSignalIndex::Allocate(const Int_t nrow, const Int_t ncol, const Int_t
   }
 
   fBoolIndex = new Bool_t[fMaxLimit];
-  fSortedIndex = new RowCol[fMaxLimit];
+  fSortedIndex = new RowCol[fMaxLimit+1];
+
+  fCountRC = fMaxLimit+1;
 
   ResetArrays();
   ResetCounters();
@@ -224,7 +226,7 @@ void AliTRDSignalIndex::Allocate(const Int_t nrow, const Int_t ncol, const Int_t
 void AliTRDSignalIndex::ResetArrays()
 {
   memset(fBoolIndex,0x00,sizeof(Bool_t)*fMaxLimit);
-  memset(fSortedIndex,0xFF,sizeof(RowCol)*fMaxLimit); 
+  memset(fSortedIndex,0xFF,sizeof(RowCol)*fCountRC); 
   fSortedWasInit = kFALSE;
 }
 
@@ -324,33 +326,24 @@ void AliTRDSignalIndex::ClearAll()
 }
 
 //_____________________________________________________________________________
-Bool_t  AliTRDSignalIndex::NextRCIndex(Int_t &row, Int_t &col)
+Bool_t  AliTRDSignalIndex::CheckSorting(Int_t &row, Int_t &col)
 {
   //
-  // Returns next used RC combination
+  // Check whether array was read to end or it was not sorted until now
   //
 
-  if(fSortedIndex[fPositionRC].s.row>-1){
-    row = fCurrRow = fSortedIndex[fPositionRC].s.row;
-    col = fCurrCol = fSortedIndex[fPositionRC].s.col;
-    fPositionRC++;
-    return kTRUE;
-  }
-  else {
-    if(fSortedWasInit)
-      { //we already reached the end of the array
-        ResetCounters();
-       row = fCurrRow;
-       col = fCurrCol;
-       return kFALSE;
-      }
-    else
-      { //we have not created the sorted array up to now, let's do so
-       InitSortedIndex();
-       return NextRCIndex(row, col);
-      }
-  }
-
+  if(fSortedWasInit || fCountRC==1)
+    { //we already reached the end of the array
+      ResetCounters();
+      row = fCurrRow;
+      col = fCurrCol;
+      return kFALSE;
+    }
+  else
+    { //we have not sorted the array up to now, let's do so
+      InitSortedIndex();
+      return NextRCIndex(row, col);
+    }
 }
 
 //_____________________________________________________________________________