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 "AliTRDarrayF.h"
11 #include "AliTRDsegmentID.h"
13 /////////////////////////////////////////////////////////////
14 // General container for data from TRD detector segments //
15 // Adapted from AliDigits, origin M.Ivanov //
16 /////////////////////////////////////////////////////////////
18 class AliTRDdataArray : public AliTRDsegmentID {
23 AliTRDdataArray(Int_t nrow, Int_t ncol,Int_t ntime);
26 virtual void Allocate(Int_t nrow, Int_t ncol,Int_t ntime);
29 virtual Int_t GetNRow() { return fNrow; };
30 virtual Int_t GetNCol() { return fNcol; };
31 virtual Int_t GetNtime() { return fNtime; };
33 inline Int_t GetIndex(Int_t row, Int_t col, Int_t time);
37 inline Int_t GetIdx1(Int_t row, Int_t col);
38 inline Bool_t CheckBounds(const char *where, Int_t idx1, Int_t idx2);
39 inline Bool_t OutOfBoundsError(const char *where, Int_t idx1, Int_t idx2);
41 Int_t fNrow; // Number of rows of the detector segement
42 Int_t fNcol; // Number of columns of the detector segment
43 Int_t fNtime; // Number of timebins of the detector segment
45 Int_t fNdim1; // First dimension of the array (row * column)
46 Int_t fNdim2; // Second dimension of the array (time, not compressed)
48 AliTRDarrayI *fIndex; // Index position of column
49 Int_t fBufType; // Type of the buffer - defines the compression algorithm
50 Int_t fNelems; // Total number of elements
51 Int_t fCurrentIdx1; // !Current index 1
52 Int_t fCurrentIdx2; // !Current index 2
53 Int_t fCurrentIndex; // !Current index in field
55 ClassDef(AliTRDdataArray,1) // Data container for one TRD detector segment
59 //_____________________________________________________________________________
60 inline Int_t AliTRDdataArray::GetIndex(Int_t row, Int_t col, Int_t time)
63 // Maps the row/column/time into one number
67 TObject::Error("GetIdx1"
68 ,"time %d out of bounds (size: %d, this: 0x%08x)"
73 return time * fNrow*fNcol + GetIdx1(row,col);
77 //_____________________________________________________________________________
78 inline Int_t AliTRDdataArray::GetIdx1(Int_t row, Int_t col)
81 // Maps the two-dimensional row/column plane into an one-dimensional array.
85 TObject::Error("GetIdx1"
86 ,"row %d out of bounds (size: %d, this: 0x%08x)"
92 TObject::Error("GetIdx1"
93 ,"col %d out of bounds (size: %d, this: 0x%08x)"
98 return row + col * fNrow;
102 //_____________________________________________________________________________
103 inline Bool_t AliTRDdataArray::CheckBounds(const char *where
104 , Int_t idx1, Int_t idx2)
107 // Does the boundary checking
110 if ((idx2 >= fNdim2) || (idx2 < 0))
111 return OutOfBoundsError(where,idx1,idx2);
113 Int_t index = (*fIndex).At(idx2) + idx1;
114 if ((index < 0) || (index > fNelems))
115 return OutOfBoundsError(where,idx1,idx2);
121 //_____________________________________________________________________________
122 inline Bool_t AliTRDdataArray::OutOfBoundsError(const char *where
123 , Int_t idx1, Int_t idx2)
126 // Generate an out-of-bounds error. Always returns false.
129 TObject::Error(where, "idx1 %d idx2 %d out of bounds (size: %d x %d, this: 0x%08x)"
130 ,idx1,idx2,fNdim1,fNdim2,this);