// //
///////////////////////////////////////////////////////////////////////////////
+#include <algorithm>
#include "TObject.h"
-
#include "AliLog.h"
-
#include "AliTRDSignalIndex.h"
ClassImp(AliTRDSignalIndex)
,fSortedIndex(NULL)
,fMaxLimit(0)
,fPositionRC(0)
+ ,fCountRC(1)
,fSortedWasInit(kFALSE)
,fCurrRow(0)
,fCurrCol(0)
,fNrows(0)
,fNcols(0)
,fNtbins(0)
- ,fHasEntry(kFALSE)
{
//
// Default contructor
,fSortedIndex(NULL)
,fMaxLimit(0)
,fPositionRC(0)
+ ,fCountRC(1)
,fSortedWasInit(kFALSE)
,fCurrRow(0)
,fCurrCol(0)
,fNrows(0)
,fNcols(0)
,fNtbins(0)
- ,fHasEntry(kFALSE)
{
//
// Not the default contructor... hmmm...
,fSortedIndex(NULL)
,fMaxLimit(a.fMaxLimit)
,fPositionRC(a.fPositionRC)
+ ,fCountRC(a.fCountRC)
,fSortedWasInit(a.fSortedWasInit)
,fCurrRow(a.fCurrRow)
,fCurrCol(a.fCurrCol)
,fNrows(a.fNrows)
,fNcols(a.fNcols)
,fNtbins(a.fNtbins)
- ,fHasEntry(a.fHasEntry)
{
//
// Copy constructor
fBoolIndex = new Bool_t[fMaxLimit];
memcpy(fBoolIndex, a.fBoolIndex, fMaxLimit*sizeof(Bool_t));
- fSortedIndex = new Short_t[2*fMaxLimit];
- memcpy(fSortedIndex, a.fSortedIndex, 2*fMaxLimit*sizeof(Short_t));
+ fSortedIndex = new RowCol[fMaxLimit+1];
+ memcpy(fSortedIndex, a.fSortedIndex, (fMaxLimit+1)*sizeof(RowCol));
}
//_____________________________________________________________________________
((AliTRDSignalIndex &)a).fLayer = fLayer;
((AliTRDSignalIndex &)a).fStack = fStack;
((AliTRDSignalIndex &)a).fSM = fSM;
- ((AliTRDSignalIndex &)a).fMaxLimit = fMaxLimit;
+ ((AliTRDSignalIndex &)a).fMaxLimit = fMaxLimit;
((AliTRDSignalIndex &)a).fPositionRC = fPositionRC;
+ ((AliTRDSignalIndex &)a).fCountRC = fCountRC;
((AliTRDSignalIndex &)a).fSortedWasInit = fSortedWasInit;
((AliTRDSignalIndex &)a).fCurrRow = fCurrRow;
((AliTRDSignalIndex &)a).fCurrCol = fCurrCol;
((AliTRDSignalIndex &)a).fNrows = fNrows;
((AliTRDSignalIndex &)a).fNcols = fNcols;
((AliTRDSignalIndex &)a).fNtbins = fNtbins;
- ((AliTRDSignalIndex &)a).fHasEntry = fHasEntry;
if(((AliTRDSignalIndex &)a).fBoolIndex)
{
{
delete [] ((AliTRDSignalIndex &)a).fSortedIndex;
}
- ((AliTRDSignalIndex &)a).fSortedIndex = new Short_t[2*fMaxLimit];
- memcpy(((AliTRDSignalIndex &)a).fSortedIndex, fSortedIndex, 2*fMaxLimit*sizeof(Short_t));
+ ((AliTRDSignalIndex &)a).fSortedIndex = new RowCol[fMaxLimit+1];
+ memcpy(((AliTRDSignalIndex &)a).fSortedIndex, fSortedIndex, (fMaxLimit+1)*sizeof(RowCol));
}
}
fBoolIndex = new Bool_t[fMaxLimit];
- fSortedIndex = new Short_t[2*fMaxLimit];
+ fSortedIndex = new RowCol[fMaxLimit+1];
+
+ fCountRC = fMaxLimit+1;
ResetArrays();
-
ResetCounters();
- fHasEntry = kFALSE;
+ fCountRC = 1;
}
//_____________________________________________________________________________
void AliTRDSignalIndex::ResetArrays()
{
+ if (!IsAllocated())
+ return;
memset(fBoolIndex,0x00,sizeof(Bool_t)*fMaxLimit);
- memset(fSortedIndex,0xFF,2*sizeof(Short_t)*fMaxLimit);
+ memset(fSortedIndex,0xFF,sizeof(RowCol)*fCountRC);
fSortedWasInit = kFALSE;
}
// Reset the array but keep the size - no realloc
//
+ fDet = -1;
+ fLayer = -1;
+ fStack = -1;
+ fSM = -1;
+
ResetArrays();
ResetCounters();
- fHasEntry = kFALSE;
+ fCountRC = 1;
}
else {
ResetArrays();
ResetCounters();
- fHasEntry = kFALSE;
+ fCountRC = 1;
}
}
ResetCounters();
- fHasEntry = kFALSE;
+ fCountRC = 1;
fSortedWasInit = kFALSE;
fMaxLimit = 0;
}
//_____________________________________________________________________________
-void AliTRDSignalIndex::AddIndexRC(const Int_t row, const Int_t col)
-{
- //
- // Store the index row-column as an interesting one
- // The RC index is updated to!!!
- // This is to be used in the TRD clusterizer!
- //
-
- if (row * col + 1 >= fMaxLimit) {
- AliError(Form("Out-of-limits row * col %d. Limit is: %d"
- ,row * col
- ,fMaxLimit));
- return;
- }
-
- fBoolIndex[row*fNcols+col]=kTRUE;
-
- fHasEntry = kTRUE;
-
-}
-
-//_____________________________________________________________________________
-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]>-1){
- row = fCurrRow = fSortedIndex[fPositionRC];
- fPositionRC++;
- col = fCurrCol = fSortedIndex[fPositionRC];
- fPositionRC++;
- return kTRUE;
- }
- else {
- if(fSortedWasInit || !fHasEntry)
- { //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);
+ }
}
//_____________________________________________________________________________
//
fSortedWasInit = kTRUE;
- int pos=0;
- for(int row = 0; row < fNrows; row++)
- for(int col = 0; col < fNcols; col++)
- if(IsBoolIndex(row, col)){
- fSortedIndex[pos] = row;
- pos++;
- fSortedIndex[pos] = col;
- pos++;
- }
+ std::sort((UShort_t*)fSortedIndex, ((UShort_t*)fSortedIndex) + fCountRC);
+
}
//_____________________________________________________________________________