// //
///////////////////////////////////////////////////////////////////////////////
+#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).fSM = fSM;
((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];
ResetArrays();
-
ResetCounters();
- fHasEntry = kFALSE;
+ fCountRC = 1;
}
void AliTRDSignalIndex::ResetArrays()
{
memset(fBoolIndex,0x00,sizeof(Bool_t)*fMaxLimit);
- memset(fSortedIndex,0xFF,2*sizeof(Short_t)*fMaxLimit);
+ memset(fSortedIndex,0xFF,sizeof(RowCol)*(fMaxLimit+1));
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)
{
// Returns next used RC combination
//
- if(fSortedIndex[fPositionRC]>-1){
- row = fCurrRow = fSortedIndex[fPositionRC];
- fPositionRC++;
- col = fCurrCol = fSortedIndex[fPositionRC];
+ if(fSortedIndex[fPositionRC].rc>-1){
+ row = fCurrRow = fSortedIndex[fPositionRC].s.row;
+ col = fCurrCol = fSortedIndex[fPositionRC].s.col;
fPositionRC++;
return kTRUE;
}
else {
- if(fSortedWasInit || !fHasEntry)
+ if(fSortedWasInit)
{ //we already reached the end of the array
ResetCounters();
row = fCurrRow;
//
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);
+
}
//_____________________________________________________________________________