]> git.uio.no Git - u/mrichter/AliRoot.git/blame - TRD/AliTRDdataArray.h
Resolved merge conflict
[u/mrichter/AliRoot.git] / TRD / AliTRDdataArray.h
CommitLineData
f7336fa3 1#ifndef TRDdataArray_H
2#define TRDdataArray_H
3
4/* Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
5 * See cxx source for full Copyright notice */
6
7/* $Id$ */
8
9#include "AliTRDarrayI.h"
10#include "AliTRDsegmentID.h"
11
12/////////////////////////////////////////////////////////////
13// General container for data from TRD detector segments //
14// Adapted from AliDigits, origin M.Ivanov //
15/////////////////////////////////////////////////////////////
16
17class AliTRDdataArray : public AliTRDsegmentID {
18
19 public:
20
21 AliTRDdataArray();
22 ~AliTRDdataArray();
23
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();
28 virtual void Reset();
29 virtual Bool_t First();
30 virtual Bool_t Next();
31
32 virtual void SetData(Int_t row, Int_t col, Int_t time, Int_t value);
33
34 virtual void SetThreshold(Int_t threshold) { fThreshold = threshold; };
35
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; };
40
41 virtual Int_t GetSize();
42 virtual Int_t GetDataSize();
43 virtual Int_t GetOverThreshold(Float_t threshold);
44
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);
47
48 protected:
49
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);
55
56 Int_t GetData1(Int_t idx1, Int_t idx2);
57 void Expand1();
58 void Compress1();
59 void Expand2();
60 void Compress2();
61 Bool_t First0();
62 Bool_t Next0();
63 Bool_t First1();
64 Bool_t Next1();
65
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
69
70 Int_t fNdim1; // First dimension of the array (row * column)
71 Int_t fNdim2; // Second dimension of the array (time, not compressed)
72
73 private:
74
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
83
84 ClassDef(AliTRDdataArray,1) // Data container for one TRD detector segment
85
86};
87
88//_____________________________________________________________________________
89inline Int_t AliTRDdataArray::GetIndex(Int_t row, Int_t col, Int_t time)
90{
91 //
92 // Maps the row/column/time into one number
93 //
94
95 return time * fNrow*fNcol + GetIdx1(row,col);
96
97}
98
99//_____________________________________________________________________________
100inline Int_t AliTRDdataArray::GetIdx1(Int_t row, Int_t col)
101{
102 //
103 // Maps the two-dimensional row/column plane into an one-dimensional array.
104 //
105
106 return row * fNrow + col;
107
108}
109
110//_____________________________________________________________________________
111inline Bool_t AliTRDdataArray::CheckBounds(const char *where
112 , Int_t idx1, Int_t idx2)
113{
114 //
115 // Does the boundary checking
116 //
117
118 if ((idx2 >= fNdim2) || (idx2 < 0))
119 return OutOfBoundsError(where,idx1,idx2);
120
121 Int_t index = (*fIndex).At(idx2) + idx1;
122 if ((index < 0) || (index > fNelems))
123 return OutOfBoundsError(where,idx1,idx2);
124
125 return kTRUE;
126
127}
128
129//_____________________________________________________________________________
130inline Bool_t AliTRDdataArray::OutOfBoundsError(const char *where
131 , Int_t idx1, Int_t idx2)
132{
133 //
134 // Generate an out-of-bounds error. Always returns false.
135 //
136
137 ::Error(where, "idx1 %d idx2 %d out of bounds (size: %d x %d, this: 0x%08x)"
138 ,idx1,idx2,fNdim1,fNdim2,this);
139
140 return kFALSE;
141
142}
143
144//_____________________________________________________________________________
145inline Int_t AliTRDdataArray::GetDataFast(Int_t idx1, Int_t idx2)
146{
147 //
148 // Returns the value at a given position in the array
149 //
150
151 return fElements->At(fIndex->At(idx2) + idx1);
152
153}
154
155//_____________________________________________________________________________
156inline void AliTRDdataArray::SetDataFast(Int_t idx1, Int_t idx2, Int_t value)
157{
158 //
159 // Set the value at a given position in the array
160 //
161
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);
167 }
168
169 (*fElements)[fIndex->fArray[idx2] + idx1] = value;
170
171}
172
173#endif
174