X-Git-Url: http://git.uio.no/git/?a=blobdiff_plain;f=TRD%2FAliTRDSignalIndex.cxx;h=e8d9d45adf9bb2f7a3847398aee5ce223b8a63a0;hb=7935dc9e5fe6a069339fd997fd8013f5319d9e9d;hp=7d7d4987688ad0bd12c88f2c4fee880b822bd929;hpb=e484a2670215afa462d103251c67192db2737667;p=u%2Fmrichter%2FAliRoot.git diff --git a/TRD/AliTRDSignalIndex.cxx b/TRD/AliTRDSignalIndex.cxx index 7d7d4987688..e8d9d45adf9 100644 --- a/TRD/AliTRDSignalIndex.cxx +++ b/TRD/AliTRDSignalIndex.cxx @@ -25,10 +25,9 @@ // // /////////////////////////////////////////////////////////////////////////////// +#include #include "TObject.h" - #include "AliLog.h" - #include "AliTRDSignalIndex.h" ClassImp(AliTRDSignalIndex) @@ -44,6 +43,7 @@ AliTRDSignalIndex::AliTRDSignalIndex() ,fSortedIndex(NULL) ,fMaxLimit(0) ,fPositionRC(0) + ,fCountRC(1) ,fSortedWasInit(kFALSE) ,fCurrRow(0) ,fCurrCol(0) @@ -51,7 +51,6 @@ AliTRDSignalIndex::AliTRDSignalIndex() ,fNrows(0) ,fNcols(0) ,fNtbins(0) - ,fHasEntry(kFALSE) { // // Default contructor @@ -72,6 +71,7 @@ AliTRDSignalIndex::AliTRDSignalIndex(Int_t nrow, Int_t ncol,Int_t ntime) ,fSortedIndex(NULL) ,fMaxLimit(0) ,fPositionRC(0) + ,fCountRC(1) ,fSortedWasInit(kFALSE) ,fCurrRow(0) ,fCurrCol(0) @@ -79,7 +79,6 @@ AliTRDSignalIndex::AliTRDSignalIndex(Int_t nrow, Int_t ncol,Int_t ntime) ,fNrows(0) ,fNcols(0) ,fNtbins(0) - ,fHasEntry(kFALSE) { // // Not the default contructor... hmmm... @@ -100,6 +99,7 @@ AliTRDSignalIndex::AliTRDSignalIndex(const AliTRDSignalIndex &a) ,fSortedIndex(NULL) ,fMaxLimit(a.fMaxLimit) ,fPositionRC(a.fPositionRC) + ,fCountRC(a.fCountRC) ,fSortedWasInit(a.fSortedWasInit) ,fCurrRow(a.fCurrRow) ,fCurrCol(a.fCurrCol) @@ -107,7 +107,6 @@ AliTRDSignalIndex::AliTRDSignalIndex(const AliTRDSignalIndex &a) ,fNrows(a.fNrows) ,fNcols(a.fNcols) ,fNtbins(a.fNtbins) - ,fHasEntry(a.fHasEntry) { // // Copy constructor @@ -116,8 +115,8 @@ AliTRDSignalIndex::AliTRDSignalIndex(const AliTRDSignalIndex &a) 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)); } //_____________________________________________________________________________ @@ -150,8 +149,9 @@ void AliTRDSignalIndex::Copy(TObject &a) const ((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; @@ -159,7 +159,6 @@ void AliTRDSignalIndex::Copy(TObject &a) const ((AliTRDSignalIndex &)a).fNrows = fNrows; ((AliTRDSignalIndex &)a).fNcols = fNcols; ((AliTRDSignalIndex &)a).fNtbins = fNtbins; - ((AliTRDSignalIndex &)a).fHasEntry = fHasEntry; if(((AliTRDSignalIndex &)a).fBoolIndex) { @@ -172,8 +171,8 @@ void AliTRDSignalIndex::Copy(TObject &a) const { 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)); } @@ -212,21 +211,24 @@ void AliTRDSignalIndex::Allocate(const Int_t nrow, const Int_t ncol, const Int_t } 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; } @@ -254,10 +256,15 @@ void AliTRDSignalIndex::ResetContent() // Reset the array but keep the size - no realloc // + fDet = -1; + fLayer = -1; + fStack = -1; + fSM = -1; + ResetArrays(); ResetCounters(); - fHasEntry = kFALSE; + fCountRC = 1; } @@ -281,7 +288,7 @@ void AliTRDSignalIndex::ResetContentConditional(const Int_t nrow, const Int_t nc else { ResetArrays(); ResetCounters(); - fHasEntry = kFALSE; + fCountRC = 1; } } @@ -314,63 +321,31 @@ void AliTRDSignalIndex::ClearAll() 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); + } } //_____________________________________________________________________________ @@ -421,15 +396,8 @@ void AliTRDSignalIndex::InitSortedIndex() // 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); + } //_____________________________________________________________________________