X-Git-Url: http://git.uio.no/git/?a=blobdiff_plain;f=TRD%2FAliTRDSignalIndex.h;h=b564b464bd6fa33833ae04401c452677605d4d77;hb=2f2cf8077dc1e9e9b3b8dfdbd1a2a8e1b631ee53;hp=5af2f40e2dd50667d5aa8cb4bd55e110e4ff4028;hpb=064d808ddc1fca8e6167c1a98d341ac62e85f258;p=u%2Fmrichter%2FAliRoot.git diff --git a/TRD/AliTRDSignalIndex.h b/TRD/AliTRDSignalIndex.h index 5af2f40e2dd..b564b464bd6 100644 --- a/TRD/AliTRDSignalIndex.h +++ b/TRD/AliTRDSignalIndex.h @@ -1,5 +1,5 @@ -#ifndef AliTRDSIGNALINDEX_H -#define AliTRDSIGNALINDEX_H +#ifndef ALITRDSIGNALINDEX_H +#define ALITRDSIGNALINDEX_H /* Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. * * See cxx source for full Copyright notice */ @@ -20,8 +20,17 @@ class AliTRDSignalIndex : public TObject { +protected: - public: + union RowCol{ + Short_t rc; + struct{ + UChar_t col; + Char_t row; + }s; + }; + +public: AliTRDSignalIndex(); AliTRDSignalIndex(Int_t nrow, Int_t ncol,Int_t ntime); @@ -29,57 +38,59 @@ class AliTRDSignalIndex : public TObject virtual ~AliTRDSignalIndex(); AliTRDSignalIndex &operator=(const AliTRDSignalIndex &d); - virtual void Copy(TObject &d) const; - virtual void Allocate(const Int_t nrow, const Int_t ncol, const Int_t ntime); - - virtual void Reset(); - virtual void ResetContentConditional(const Int_t nrow, const Int_t ncol, const Int_t ntime); - virtual void ResetContent(); - virtual void ResetCounters(); - virtual void ResetTbinCounter() { } - - void ResetArrays(); - - virtual void AddIndexTBin(Int_t row, Int_t col, Int_t tbin); - void AddIndexRC(const Int_t row, const Int_t col); - - // Get the next pad (row and column) and return kTRUE on success - Bool_t NextRCIndex(Int_t &row, Int_t &col); - // Get the next timebin of a pad (row and column) and return kTRUE on success - Bool_t NextRCTbinIndex(Int_t &row, Int_t &col, Int_t &tbin); - // Get the next active timebin and return kTRUE on success - Bool_t NextTbinIndex(Int_t &tbin); - - Int_t GetCurrentRow() const { return fCurrRow; } - Int_t GetCurrentCol() const { return fCurrCol; } - Int_t GetCurrentTbin() const { return fCurrTbin; } - - Bool_t IsBoolIndex(Int_t row, Int_t col) const {return fBoolIndex[row*fNcols+col];}; - void InitSortedIndex(); - - // Clear the array, actually destroy and recreate w/o allocating - void ClearAll(); - // Return kTRUE if array allocated and there is no need to call allocate - Bool_t IsAllocated() const { if (!fBoolIndex) return kFALSE; - if (fMaxLimit <= 0) return kFALSE; - else return kTRUE;} - - void SetSM(const Int_t ix) { fSM = ix; } - void SetStack(const Int_t ix) { fStack = ix; } - void SetLayer(const Int_t ix) { fLayer = ix; } - void SetDetNumber(const Int_t ix) { fDet = ix; } + void Copy(TObject &d) const; + void Allocate(const Int_t nrow, const Int_t ncol, const Int_t ntime); + + void Reset(); + void ResetContentConditional(const Int_t nrow, const Int_t ncol, const Int_t ntime); + void ResetContent(); + void ResetCounters(); + void ResetTbinCounter() const { }; + + void ResetArrays(); + + // Store the index row-column as an interesting one + inline void AddIndexRC(const Int_t row, const Int_t col); + // Get the next pad (row and column) and return kTRUE on success + inline Bool_t NextRCIndex(Int_t &row, Int_t &col); + // Get the next timebin of a pad (row and column) and return kTRUE on success + Bool_t NextRCTbinIndex(Int_t &row, Int_t &col, Int_t &tbin); + // Get the next active timebin and return kTRUE on success + Bool_t NextTbinIndex(Int_t &tbin); + + Bool_t CheckSorting(Int_t &row, Int_t &col); + + Int_t GetCurrentRow() const { return fCurrRow; } + Int_t GetCurrentCol() const { return fCurrCol; } + Int_t GetCurrentTbin() const { return fCurrTbin; } + + Bool_t IsBoolIndex(Int_t row, Int_t col) const {return fBoolIndex[row*fNcols+col];}; + void InitSortedIndex(); + + // Clear the array, actually destroy and recreate w/o allocating + void ClearAll(); + // Return kTRUE if array allocated and there is no need to call allocate + Bool_t IsAllocated() const { if (!fBoolIndex) return kFALSE; + if (fMaxLimit <= 0) return kFALSE; + else return kTRUE;} + + void SetSM(const Int_t ix) { fSM = ix; } + void SetStack(const Int_t ix) { fStack = ix; } + void SetLayer(const Int_t ix) { fLayer = ix; } + void SetDetNumber(const Int_t ix) { fDet = ix; } - virtual Int_t GetDetNumber() const { return fDet; } // Get Det number - virtual Int_t GetLayer() const { return fLayer; } // Layer position of the chamber in TRD - virtual Int_t GetStack() const { return fStack; } // Stack position of the chamber in TRD - virtual Int_t GetSM() const { return fSM; } // Super module of the TRD - Short_t *GetArray() const { return fSortedIndex; } // Get the array pointer for god knows what reason + Int_t GetDetNumber() const { return fDet; } // Get Det number + Int_t GetLayer() const { return fLayer; } // Layer position of the chamber in TRD + Int_t GetStack() const { return fStack; } // Stack position of the chamber in TRD + Int_t GetSM() const { return fSM; } // Super module of the TRD + Short_t *GetArray() const { return (Short_t*)fSortedIndex; } // Get the array pointer for god knows what reason + Int_t GetNoOfIndexes() const { return fCountRC-1; } - virtual Bool_t HasEntry() const { return fHasEntry; } // Return status if has an entry + Bool_t HasEntry() const { return fCountRC > 1 ? kTRUE : kFALSE; } // Return status if has an entry - virtual Int_t GetNrow() const { return fNrows; } // Get Nrows - virtual Int_t GetNcol() const { return fNcols; } // Get Ncols - virtual Int_t GetNtime() const { return fNtbins; } // Get Ntbins + Int_t GetNrow() const { return fNrows; } // Get Nrows + Int_t GetNcol() const { return fNcols; } // Get Ncols + Int_t GetNtime() const { return fNtbins; } // Get Ntbins private: @@ -88,10 +99,11 @@ class AliTRDSignalIndex : public TObject Int_t fStack; // Stack position in the full TRD Int_t fSM; // Super module - position in the full TRD - Bool_t *fBoolIndex; // - Short_t *fSortedIndex; // + Bool_t *fBoolIndex; // Indices + RowCol *fSortedIndex; // Sorted indices Int_t fMaxLimit; // Max number of things in the array Int_t fPositionRC; // Position in the SortedIndex + Int_t fCountRC; // the number of added rc combinations Bool_t fSortedWasInit; // Was SortedIndex initialized? Int_t fCurrRow; // Last Row read out of SortedIndex @@ -100,13 +112,45 @@ class AliTRDSignalIndex : public TObject Int_t fNrows; // Number of rows in the chamber Int_t fNcols; // Number of cols in the chamber - Int_t fNtbins; // Number of tbins in the chamber - - Bool_t fHasEntry; // kTRUE flag if we have an entry + Int_t fNtbins; // Number of tbins in the chamber ClassDef(AliTRDSignalIndex,2) // Data container for one TRD detector segment }; + +void AliTRDSignalIndex::AddIndexRC(const Int_t row, const Int_t col) +{ + // + // Adds RC combination to array + // + + const Int_t num=row*fNcols+col; + if(fBoolIndex[num])return; + fBoolIndex[num]=kTRUE; + fSortedIndex[fCountRC].s.col=col; + fSortedIndex[fCountRC].s.row=row; + fCountRC++; +} + +Bool_t AliTRDSignalIndex::NextRCIndex(Int_t &row, Int_t &col) +{ + // + // Returns next used RC combination + // + + if (!IsAllocated()) + return kFALSE; + + if(fSortedIndex[fPositionRC].rc>-1){ + row = fCurrRow = fSortedIndex[fPositionRC].s.row; + col = fCurrCol = fSortedIndex[fPositionRC].s.col; + fPositionRC++; + return kTRUE; + } + else + return CheckSorting(row, col); +} + #endif /*