4 /* Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
5 * See cxx source for full Copyright notice */
9 #include "AliTRDarrayI.h"
10 #include "AliTRDsegmentID.h"
12 /////////////////////////////////////////////////////////////
13 // General container for data from TRD detector segments //
14 // Adapted from AliDigits, origin M.Ivanov //
15 /////////////////////////////////////////////////////////////
17 class AliTRDdataArray : public AliTRDsegmentID {
24 virtual void Allocate(Int_t nrow, Int_t ncol,Int_t ntime);
25 virtual void Compress(Int_t bufferType, Int_t threshold);
26 virtual void Compress(Int_t bufferType);
27 virtual void Expand();
29 virtual Bool_t First();
30 virtual Bool_t Next();
32 virtual void SetData(Int_t row, Int_t col, Int_t time, Int_t value);
34 virtual void SetThreshold(Int_t threshold) { fThreshold = threshold; };
36 virtual Int_t GetThreshold() { return fThreshold; };
37 virtual Int_t GetNRow() { return fNrow; };
38 virtual Int_t GetNCol() { return fNcol; };
39 virtual Int_t GetNtime() { return fNtime; };
41 virtual Int_t GetSize();
42 virtual Int_t GetDataSize();
43 virtual Int_t GetOverThreshold(Float_t threshold);
45 virtual Int_t GetData(Int_t row, Int_t col, Int_t time);
46 inline Int_t GetIndex(Int_t row, Int_t col, Int_t time);
50 inline Int_t GetIdx1(Int_t row, Int_t col);
51 inline Bool_t CheckBounds(const char *where, Int_t idx1, Int_t idx2);
52 inline Bool_t OutOfBoundsError(const char *where, Int_t idx1, Int_t idx2);
53 inline void SetDataFast(Int_t idx1, Int_t idx2, Int_t value);
54 inline Int_t GetDataFast(Int_t idx1, Int_t idx2);
56 Int_t GetData1(Int_t idx1, Int_t idx2);
66 Int_t fNrow; // Number of rows of the detector segement
67 Int_t fNcol; // Number of columns of the detector segment
68 Int_t fNtime; // Number of timebins of the detector segment
70 Int_t fNdim1; // First dimension of the array (row * column)
71 Int_t fNdim2; // Second dimension of the array (time, not compressed)
75 AliTRDarrayI *fElements; // Buffer of 4 bytes integers for the array content
76 AliTRDarrayI *fIndex; // Index position of column
77 Int_t fBufType; // Type of the buffer - defines the compression algorithm
78 Int_t fThreshold; // Treshold for zero suppression
79 Int_t fNelems; // Total number of elements
80 Int_t fCurrentIdx1; // !Current index 1
81 Int_t fCurrentIdx2; // !Current index 2
82 Int_t fCurrentIndex; // !Current index in field
84 ClassDef(AliTRDdataArray,1) // Data container for one TRD detector segment
88 //_____________________________________________________________________________
89 inline Int_t AliTRDdataArray::GetIndex(Int_t row, Int_t col, Int_t time)
92 // Maps the row/column/time into one number
95 return time * fNrow*fNcol + GetIdx1(row,col);
99 //_____________________________________________________________________________
100 inline Int_t AliTRDdataArray::GetIdx1(Int_t row, Int_t col)
103 // Maps the two-dimensional row/column plane into an one-dimensional array.
106 return row * fNrow + col;
110 //_____________________________________________________________________________
111 inline Bool_t AliTRDdataArray::CheckBounds(const char *where
112 , Int_t idx1, Int_t idx2)
115 // Does the boundary checking
118 if ((idx2 >= fNdim2) || (idx2 < 0))
119 return OutOfBoundsError(where,idx1,idx2);
121 Int_t index = (*fIndex).At(idx2) + idx1;
122 if ((index < 0) || (index > fNelems))
123 return OutOfBoundsError(where,idx1,idx2);
129 //_____________________________________________________________________________
130 inline Bool_t AliTRDdataArray::OutOfBoundsError(const char *where
131 , Int_t idx1, Int_t idx2)
134 // Generate an out-of-bounds error. Always returns false.
137 ::Error(where, "idx1 %d idx2 %d out of bounds (size: %d x %d, this: 0x%08x)"
138 ,idx1,idx2,fNdim1,fNdim2,this);
144 //_____________________________________________________________________________
145 inline Int_t AliTRDdataArray::GetDataFast(Int_t idx1, Int_t idx2)
148 // Returns the value at a given position in the array
151 return fElements->At(fIndex->At(idx2) + idx1);
155 //_____________________________________________________________________________
156 inline void AliTRDdataArray::SetDataFast(Int_t idx1, Int_t idx2, Int_t value)
159 // Set the value at a given position in the array
162 if ((idx1 < 0) || (idx1 >= fNdim1) ||
163 (idx2 < 0) || (idx2 >= fNdim2)) {
164 ::Error("AliTRDdataArray::SetDataFast"
165 ,"idx1 %d idx2 %d out of bounds (size: %d x %d, this: 0x%08x)"
166 ,idx1,idx2,fNdim1,fNdim2,this);
169 (*fElements)[fIndex->fArray[idx2] + idx1] = value;