]>
Commit | Line | Data |
---|---|---|
f7336fa3 | 1 | /************************************************************************** |
2 | * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. * | |
3 | * * | |
4 | * Author: The ALICE Off-line Project. * | |
5 | * Contributors are mentioned in the code where appropriate. * | |
6 | * * | |
7 | * Permission to use, copy, modify and distribute this software and its * | |
8 | * documentation strictly for non-commercial purposes is hereby granted * | |
9 | * without fee, provided that the above copyright notice appears in all * | |
10 | * copies and that both the copyright notice and this permission notice * | |
11 | * appear in the supporting documentation. The authors make no claims * | |
12 | * about the suitability of this software for any purpose. It is * | |
13 | * provided "as is" without express or implied warranty. * | |
14 | **************************************************************************/ | |
15 | ||
16 | /* | |
17 | $Log$ | |
8230f242 | 18 | Revision 1.4 2000/06/07 16:27:01 cblume |
19 | Try to remove compiler warnings on Sun and HP | |
20 | ||
9d0b222b | 21 | Revision 1.3 2000/05/18 07:56:44 cblume |
22 | Added #include <stdlib.h> | |
23 | ||
617e4d8a | 24 | Revision 1.2 2000/05/08 16:17:27 cblume |
25 | Merge TRD-develop | |
26 | ||
6f1e466d | 27 | Revision 1.1.4.1 2000/05/08 15:13:59 cblume |
28 | Introduce boundary checking | |
29 | ||
30 | Revision 1.1 2000/02/28 18:59:19 cblume | |
31 | Add new TRD classes | |
32 | ||
f7336fa3 | 33 | */ |
34 | ||
35 | /////////////////////////////////////////////////////////////////////////////// | |
36 | // // | |
6f1e466d | 37 | // Base class of a general container for data of a TRD detector segment. // |
f7336fa3 | 38 | // Adapted from AliDigits (origin: M.Ivanov). // |
f7336fa3 | 39 | // // |
40 | /////////////////////////////////////////////////////////////////////////////// | |
41 | ||
617e4d8a | 42 | #include <stdlib.h> |
43 | ||
f7336fa3 | 44 | #include "TClass.h" |
45 | #include "TError.h" | |
46 | #include "AliTRDsegmentID.h" | |
47 | #include "AliTRDarrayI.h" | |
48 | #include "AliTRDdataArray.h" | |
49 | ||
50 | ClassImp(AliTRDdataArray) | |
51 | ||
52 | //_____________________________________________________________________________ | |
53 | AliTRDdataArray::AliTRDdataArray() | |
54 | { | |
55 | // | |
56 | // Default constructor | |
57 | // | |
58 | ||
6f1e466d | 59 | fIndex = 0; |
60 | ||
61 | fNdim1 = -1; | |
62 | fNdim2 = -1; | |
63 | fNelems = -1; | |
64 | ||
65 | fBufType = -1; | |
66 | ||
67 | fNrow = 0; | |
68 | fNcol = 0; | |
69 | fNtime = 0; | |
f7336fa3 | 70 | |
71 | } | |
72 | ||
73 | //_____________________________________________________________________________ | |
6f1e466d | 74 | AliTRDdataArray::AliTRDdataArray(Int_t nrow, Int_t ncol, Int_t ntime) |
f7336fa3 | 75 | { |
76 | // | |
6f1e466d | 77 | // Creates a AliTRDdataArray with the dimensions <nrow>, <ncol>, and <ntime>. |
78 | // The row- and column dimensions are compressible. | |
f7336fa3 | 79 | // |
80 | ||
6f1e466d | 81 | Allocate(nrow,ncol,ntime); |
f7336fa3 | 82 | |
6f1e466d | 83 | } |
f7336fa3 | 84 | |
8230f242 | 85 | //_____________________________________________________________________________ |
86 | AliTRDdataArray::AliTRDdataArray(AliTRDdataArray &d) | |
87 | { | |
88 | // | |
89 | // AliTRDdataArray copy constructor | |
90 | // | |
91 | ||
92 | d.Copy(*this); | |
93 | ||
94 | } | |
95 | ||
f7336fa3 | 96 | //_____________________________________________________________________________ |
6f1e466d | 97 | AliTRDdataArray::~AliTRDdataArray() |
98 | { | |
f7336fa3 | 99 | // |
8230f242 | 100 | // AliTRDdataArray destructor |
f7336fa3 | 101 | // |
102 | ||
6f1e466d | 103 | if (fIndex) fIndex->Delete(); |
f7336fa3 | 104 | |
f7336fa3 | 105 | } |
106 | ||
8230f242 | 107 | //_____________________________________________________________________________ |
108 | void AliTRDdataArray::Copy(AliTRDdataArray &d) | |
109 | { | |
110 | // | |
111 | // Copy function | |
112 | // | |
113 | ||
114 | d.fNrow = fNrow; | |
115 | d.fNcol = fNcol; | |
116 | d.fNtime = fNtime; | |
117 | ||
118 | d.fNdim1 = fNdim1; | |
119 | d.fNdim2 = fNdim2; | |
120 | ||
121 | d.fBufType = fBufType; | |
122 | d.fNelems = fNelems; | |
123 | ||
124 | d.fCurrentIdx1 = 0; | |
125 | d.fCurrentIdx2 = 0; | |
126 | d.fCurrentIndex = 0; | |
127 | ||
128 | fIndex->Copy(*d.fIndex); | |
129 | ||
130 | } | |
131 | ||
f7336fa3 | 132 | //_____________________________________________________________________________ |
6f1e466d | 133 | void AliTRDdataArray::Allocate(Int_t nrow, Int_t ncol,Int_t ntime) |
f7336fa3 | 134 | { |
135 | // | |
6f1e466d | 136 | // Allocates memory for a AliTRDdataArray with the dimensions |
137 | // <nrow>, <ncol>, and <ntime>. | |
138 | // The row- and column dimensions are compressible. | |
f7336fa3 | 139 | // |
140 | ||
f7336fa3 | 141 | if (nrow <= 0) { |
142 | Error("AliTRDdataArray::Allocate","The number of rows has to be positive"); | |
6f1e466d | 143 | exit(1); |
f7336fa3 | 144 | } |
145 | if (ncol <= 0) { | |
146 | Error("AliTRDdataArray::Allocate","The number of columns has to be positive"); | |
6f1e466d | 147 | exit(1); |
f7336fa3 | 148 | } |
149 | if (ntime <= 0) { | |
150 | Error("AliTRDdataArray::Allocate","The number of timebins has to be positive"); | |
6f1e466d | 151 | exit(1); |
f7336fa3 | 152 | } |
153 | ||
154 | // The two-dimensional array row/column gets mapped into the first | |
155 | // dimension of the array. The second array dimension, which is not compressible, | |
156 | // corresponds to the time direction | |
157 | fNdim1 = nrow * ncol; | |
158 | fNdim2 = ntime; | |
159 | fNelems = fNdim1 * fNdim2; | |
160 | ||
161 | fNrow = nrow; | |
162 | fNcol = ncol; | |
163 | fNtime = ntime; | |
164 | ||
6f1e466d | 165 | if (fIndex) delete fIndex; |
166 | fIndex = new AliTRDarrayI; | |
f7336fa3 | 167 | fIndex->Set(fNdim2); |
f7336fa3 | 168 | for (Int_t i = 0, k = 0; i < fNdim2; i++, k += fNdim1) { |
169 | (*fIndex)[i] = k; | |
170 | } | |
171 | ||
172 | fBufType = 0; | |
173 | ||
174 | } | |
175 | ||
176 | //_____________________________________________________________________________ | |
6f1e466d | 177 | void AliTRDdataArray::Reset() |
178 | { | |
f7336fa3 | 179 | // |
6f1e466d | 180 | // Reset the array (old content gets deleted) |
f7336fa3 | 181 | // |
182 | ||
6f1e466d | 183 | if (fIndex) delete fIndex; |
184 | fIndex = new AliTRDarrayI; | |
185 | fIndex->Set(0); | |
f7336fa3 | 186 | |
6f1e466d | 187 | fNdim1 = -1; |
188 | fNdim2 = -1; | |
189 | fNelems = -1; | |
f7336fa3 | 190 | |
6f1e466d | 191 | fBufType = -1; |
f7336fa3 | 192 | |
6f1e466d | 193 | fNrow = 0; |
194 | fNcol = 0; | |
195 | fNtime = 0; | |
f7336fa3 | 196 | |
197 | } | |
198 | ||
9d0b222b | 199 | //_____________________________________________________________________________ |
200 | Int_t AliTRDdataArray::GetIdx1(Int_t row, Int_t col) | |
201 | { | |
202 | // | |
203 | // Maps the two-dimensional row/column plane into an one-dimensional array. | |
204 | // | |
205 | ||
206 | if (row >= fNrow) { | |
207 | TObject::Error("GetIdx1" | |
208 | ,"row %d out of bounds (size: %d, this: 0x%08x)" | |
209 | ,row,fNrow,this); | |
210 | return -1; | |
211 | } | |
212 | ||
213 | if (col >= fNcol) { | |
214 | TObject::Error("GetIdx1" | |
215 | ,"col %d out of bounds (size: %d, this: 0x%08x)" | |
216 | ,col,fNcol,this); | |
217 | return -1; | |
218 | } | |
219 | ||
220 | return row + col * fNrow; | |
221 | ||
222 | } | |
223 | ||
224 | //_____________________________________________________________________________ | |
225 | Int_t AliTRDdataArray::GetIndex(Int_t row, Int_t col, Int_t time) | |
226 | { | |
227 | // | |
228 | // Maps the row/column/time into one number | |
229 | // | |
230 | ||
231 | if (time > fNtime) { | |
232 | TObject::Error("GetIdx1" | |
233 | ,"time %d out of bounds (size: %d, this: 0x%08x)" | |
234 | ,time,fNtime,this); | |
235 | return -1; | |
236 | } | |
237 | ||
238 | return time * fNrow*fNcol + GetIdx1(row,col); | |
239 | ||
240 | } | |
f7336fa3 | 241 |