]>
Commit | Line | Data |
---|---|---|
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 | /* $Id$ */ | |
17 | ||
18 | /////////////////////////////////////////////////////////////////////////////// | |
19 | // // | |
20 | // General container for data from TRD detector segments // | |
21 | // Adapted from AliDigits, origin M.Ivanov // | |
22 | // // | |
23 | // Author: // | |
24 | // Mateusz Ploskon (ploskon@ikf.uni-frankfurt.de) // | |
25 | // // | |
26 | /////////////////////////////////////////////////////////////////////////////// | |
27 | ||
28 | #include "TArrayI.h" | |
29 | ||
30 | #include "AliLog.h" | |
31 | ||
32 | #include "AliTRDSignalIndex.h" | |
33 | ||
34 | ClassImp(AliTRDSignalIndex) | |
35 | ||
36 | //_____________________________________________________________________________ | |
37 | AliTRDSignalIndex::AliTRDSignalIndex() | |
38 | :TObject() | |
39 | ,fDet(-1) | |
40 | ,fLayer(-1) | |
41 | ,fStack(-1) | |
42 | ,fSM(-1) | |
43 | ,fIndex(NULL) | |
44 | ,fPositionRow(0) | |
45 | ,fPositionCol(0) | |
46 | ,fPositionTbin(0) | |
47 | ,fLastRow(0) | |
48 | ,fLastCol(0) | |
49 | ,fLastTbin(0) | |
50 | ,fNrows(0) | |
51 | ,fNcols(0) | |
52 | ,fNtbins(0) | |
53 | ,fMaxLimit(0) | |
54 | ,fResetCounters(kTRUE) | |
55 | ,fHasEntry(kFALSE) | |
56 | { | |
57 | // | |
58 | // Default contructor | |
59 | // | |
60 | ||
61 | ResetCounters(); | |
62 | ||
63 | } | |
64 | ||
65 | //_____________________________________________________________________________ | |
66 | AliTRDSignalIndex::AliTRDSignalIndex(Int_t nrow, Int_t ncol,Int_t ntime) | |
67 | :TObject() | |
68 | ,fDet(-1) | |
69 | ,fLayer(-1) | |
70 | ,fStack(-1) | |
71 | ,fSM(-1) | |
72 | ,fIndex(NULL) | |
73 | ,fPositionRow(0) | |
74 | ,fPositionCol(0) | |
75 | ,fPositionTbin(0) | |
76 | ,fLastRow(0) | |
77 | ,fLastCol(0) | |
78 | ,fLastTbin(0) | |
79 | ,fNrows(0) | |
80 | ,fNcols(0) | |
81 | ,fNtbins(0) | |
82 | ,fMaxLimit(0) | |
83 | ,fResetCounters(kTRUE) | |
84 | ,fHasEntry(kFALSE) | |
85 | { | |
86 | // | |
87 | // Not the default contructor... hmmm... | |
88 | // | |
89 | ||
90 | Allocate(nrow, ncol, ntime); | |
91 | ||
92 | } | |
93 | ||
94 | //_____________________________________________________________________________ | |
95 | AliTRDSignalIndex::AliTRDSignalIndex(const AliTRDSignalIndex &a) | |
96 | :TObject(a) | |
97 | ,fDet(a.fDet) | |
98 | ,fLayer(a.fLayer) | |
99 | ,fStack(a.fStack) | |
100 | ,fSM(a.fSM) | |
101 | ,fIndex(a.fIndex) | |
102 | ,fPositionRow(a.fPositionRow) | |
103 | ,fPositionCol(a.fPositionCol) | |
104 | ,fPositionTbin(a.fPositionTbin) | |
105 | ,fLastRow(a.fLastRow) | |
106 | ,fLastCol(a.fLastCol) | |
107 | ,fLastTbin(a.fLastTbin) | |
108 | ,fNrows(a.fNrows) | |
109 | ,fNcols(a.fNcols) | |
110 | ,fNtbins(a.fNtbins) | |
111 | ,fMaxLimit(a.fMaxLimit) | |
112 | ,fResetCounters(a.fResetCounters) | |
113 | ,fHasEntry(a.fHasEntry) | |
114 | { | |
115 | // | |
116 | // Copy constructor | |
117 | // | |
118 | ||
119 | } | |
120 | ||
121 | //_____________________________________________________________________________ | |
122 | AliTRDSignalIndex::~AliTRDSignalIndex() | |
123 | { | |
124 | // | |
125 | // Destructor | |
126 | // | |
127 | ||
128 | delete fIndex; | |
129 | fIndex = NULL; | |
130 | ||
131 | } | |
132 | ||
133 | //_____________________________________________________________________________ | |
134 | void AliTRDSignalIndex::Copy(TObject &a) const | |
135 | { | |
136 | // | |
137 | // Copy function | |
138 | // | |
139 | ||
140 | ((AliTRDSignalIndex &)a).fDet = fDet; | |
141 | ((AliTRDSignalIndex &)a).fLayer = fLayer; | |
142 | ((AliTRDSignalIndex &)a).fStack = fStack; | |
143 | ((AliTRDSignalIndex &)a).fSM = fSM; | |
144 | ((AliTRDSignalIndex &)a).fIndex = fIndex; | |
145 | ((AliTRDSignalIndex &)a).fPositionRow = fPositionRow; | |
146 | ((AliTRDSignalIndex &)a).fPositionTbin = fPositionTbin; | |
147 | ((AliTRDSignalIndex &)a).fLastRow = fLastRow; | |
148 | ((AliTRDSignalIndex &)a).fLastCol = fLastCol; | |
149 | ((AliTRDSignalIndex &)a).fLastTbin = fLastTbin; | |
150 | ((AliTRDSignalIndex &)a).fNrows = fNrows; | |
151 | ((AliTRDSignalIndex &)a).fNcols = fNcols; | |
152 | ((AliTRDSignalIndex &)a).fNtbins = fNtbins; | |
153 | ((AliTRDSignalIndex &)a).fMaxLimit = fMaxLimit; | |
154 | ((AliTRDSignalIndex &)a).fResetCounters = fResetCounters; | |
155 | ((AliTRDSignalIndex &)a).fHasEntry = fHasEntry; | |
156 | ||
157 | } | |
158 | ||
159 | //_____________________________________________________________________________ | |
160 | AliTRDSignalIndex& AliTRDSignalIndex::operator = (const AliTRDSignalIndex& a) | |
161 | { | |
162 | // | |
163 | // Assignment operator | |
164 | // | |
165 | ||
166 | if (this != &a) ((AliTRDSignalIndex &) a).Copy(*this); | |
167 | return *this; | |
168 | ||
169 | } | |
170 | ||
171 | //_____________________________________________________________________________ | |
172 | void AliTRDSignalIndex::Allocate(Int_t nrow, Int_t ncol,Int_t ntime) | |
173 | { | |
174 | // | |
175 | // Create the arrays | |
176 | // | |
177 | ||
178 | fNrows = nrow; | |
179 | fNcols = ncol; | |
180 | fNtbins = ntime; | |
181 | ||
182 | fMaxLimit = nrow * ncol * ntime + nrow * ncol * 2; | |
183 | if (fIndex) { | |
184 | delete fIndex; | |
185 | fIndex = NULL; | |
186 | } | |
187 | ||
188 | fIndex = new TArrayI(fMaxLimit); | |
189 | fIndex->Reset(-1); | |
190 | ||
191 | ResetCounters(); | |
192 | ||
193 | fHasEntry = kFALSE; | |
194 | ||
195 | } | |
196 | ||
197 | //_____________________________________________________________________________ | |
198 | void AliTRDSignalIndex::Reset() | |
199 | { | |
200 | // | |
201 | // Reset the array but keep the size - realloc | |
202 | // | |
203 | ||
204 | fDet = -1; | |
205 | fLayer = -1; | |
206 | fStack = -1; | |
207 | fSM = -1; | |
208 | ||
209 | // All will be lost | |
210 | Allocate(fNrows, fNcols, fNtbins); | |
211 | ||
212 | } | |
213 | ||
214 | //_____________________________________________________________________________ | |
215 | void AliTRDSignalIndex::ResetContent() | |
216 | { | |
217 | // | |
218 | // Reset the array but keep the size - no realloc | |
219 | // | |
220 | ||
221 | fIndex->Reset(-1); | |
222 | ResetCounters(); | |
223 | ||
224 | fHasEntry = kFALSE; | |
225 | ||
226 | } | |
227 | ||
228 | //_____________________________________________________________________________ | |
229 | void AliTRDSignalIndex::ResetContentConditional(Int_t nrow, Int_t ncol,Int_t ntime) | |
230 | { | |
231 | // | |
232 | // Reset the array but keep the size if no need to enlarge - no realloc | |
233 | // | |
234 | ||
235 | fDet = -1; | |
236 | fLayer = -1; | |
237 | fStack = -1; | |
238 | fSM = -1; | |
239 | ||
240 | if ((nrow > fNrows) || | |
241 | (ncol > fNcols) || | |
242 | (ntime > fNtbins)) { | |
243 | Allocate(nrow, ncol, ntime); | |
244 | } | |
245 | else { | |
246 | fIndex->Reset(-1); | |
247 | ResetCounters(); | |
248 | fHasEntry = kFALSE; | |
249 | } | |
250 | ||
251 | } | |
252 | ||
253 | //_____________________________________________________________________________ | |
254 | void AliTRDSignalIndex::ClearAll() | |
255 | { | |
256 | // | |
257 | // Reset the values - clear all! | |
258 | // | |
259 | ||
260 | fDet = -1; | |
261 | fLayer = -1; | |
262 | fStack = -1; | |
263 | fSM = -1; | |
264 | ||
265 | fNrows = -1; | |
266 | fNcols = -1; | |
267 | fNtbins = -1; | |
268 | ||
269 | if (fIndex) { | |
270 | delete fIndex; | |
271 | fIndex = NULL; | |
272 | } | |
273 | fIndex = new TArrayI(); | |
274 | ResetCounters(); | |
275 | ||
276 | fHasEntry = kFALSE; | |
277 | ||
278 | } | |
279 | ||
280 | //_____________________________________________________________________________ | |
281 | void AliTRDSignalIndex::AddIndexTBin(Int_t row, Int_t col, Int_t tbin) | |
282 | { | |
283 | // | |
284 | // Store the index row-column-tbin as an interesting one | |
285 | // The RC index is updated to!!! | |
286 | // This is to be used in the TRD clusterizer! | |
287 | // | |
288 | ||
289 | if (row * col * tbin + row * col * 2 >= fMaxLimit) { | |
290 | AliError(Form("Out-of-limits fPositionCol + fNtbins %d. Limit is: %d" | |
291 | ,fPositionCol + fNtbins | |
292 | ,fMaxLimit)); | |
293 | return; | |
294 | } | |
295 | ||
296 | if ((row != fLastRow) || | |
297 | (col != fLastCol)) { | |
298 | ||
299 | // New RC combination | |
300 | if (fResetCounters == kTRUE) { | |
301 | fPositionRow = 0; | |
302 | fPositionCol = 1; | |
303 | fResetCounters = kFALSE; | |
304 | } | |
305 | else { | |
306 | fPositionRow += fNtbins + 2; | |
307 | fPositionCol += fNtbins + 2; | |
308 | } | |
309 | ||
310 | fPositionTbin = 1; | |
311 | ||
312 | (*fIndex)[fPositionRow] = row; | |
313 | (*fIndex)[fPositionCol] = col; | |
314 | (*fIndex)[fPositionCol + fPositionTbin] = tbin; | |
315 | ++fPositionTbin; | |
316 | ||
317 | } | |
318 | else { | |
319 | ||
320 | // Same RCT combination ? | |
321 | ||
322 | (*fIndex)[fPositionCol + fPositionTbin] = tbin; | |
323 | ++fPositionTbin; | |
324 | ||
325 | } | |
326 | ||
327 | fLastRow = row; | |
328 | fLastCol = col; | |
329 | fLastTbin = tbin; | |
330 | ||
331 | fHasEntry = kTRUE; | |
332 | ||
333 | } | |
334 | ||
335 | //_____________________________________________________________________________ | |
336 | Bool_t AliTRDSignalIndex::NextRCIndex(Int_t &row, Int_t &col) | |
337 | { | |
338 | // | |
339 | // Return the position (index in the data array) of the next available pad | |
340 | // | |
341 | ||
342 | if (fResetCounters == kTRUE) { | |
343 | fPositionRow = 0; | |
344 | fPositionCol = 1; | |
345 | fResetCounters = kFALSE; | |
346 | } | |
347 | else { | |
348 | fPositionRow += fNtbins + 2; | |
349 | fPositionCol += fNtbins + 2; | |
350 | } | |
351 | ||
352 | if (fPositionRow >= fMaxLimit) { | |
353 | return kFALSE; | |
354 | } | |
355 | ||
356 | fPositionTbin = 1; | |
357 | ||
358 | row = (*fIndex)[fPositionRow]; | |
359 | col = (*fIndex)[fPositionCol]; | |
360 | ||
361 | if ((row > -1) && | |
362 | (col > -1)) { | |
363 | return kTRUE; | |
364 | } | |
365 | ||
366 | return kFALSE; | |
367 | ||
368 | } | |
369 | ||
370 | //_____________________________________________________________________________ | |
371 | Bool_t AliTRDSignalIndex::NextRCTbinIndex(Int_t &row, Int_t &col, Int_t &tbin) | |
372 | { | |
373 | // | |
374 | // Return the position (index in the data array) of the next available tbin | |
375 | // within the current pad | |
376 | // | |
377 | ||
378 | if (fPositionRow >= fMaxLimit) { | |
379 | return kFALSE; | |
380 | } | |
381 | ||
382 | if (NextTbinIndex(tbin)) { | |
383 | row = (*fIndex)[fPositionRow]; | |
384 | col = (*fIndex)[fPositionCol]; | |
385 | fResetCounters = kFALSE; | |
386 | return kTRUE; | |
387 | } | |
388 | else { | |
389 | if (NextRCIndex(row, col)) { | |
390 | return NextRCTbinIndex(row, col, tbin); | |
391 | } | |
392 | } | |
393 | ||
394 | return kFALSE; | |
395 | ||
396 | } | |
397 | ||
398 | //_____________________________________________________________________________ | |
399 | Bool_t AliTRDSignalIndex::NextTbinIndex(Int_t &tbin) | |
400 | { | |
401 | // | |
402 | // Return the position (index in the data array) of the next available tbin | |
403 | // within the current pad | |
404 | // | |
405 | ||
406 | if ((fPositionCol + fPositionTbin >= fMaxLimit) || | |
407 | (fPositionTbin > fNtbins )) { | |
408 | return kFALSE; | |
409 | } | |
410 | ||
411 | tbin = (*fIndex)[fPositionCol + fPositionTbin]; | |
412 | ||
413 | if (tbin > -1) { | |
414 | ++fPositionTbin; | |
415 | return kTRUE; | |
416 | } | |
417 | ||
418 | return kFALSE; | |
419 | ||
420 | } | |
421 | ||
422 | //_____________________________________________________________________________ | |
423 | void AliTRDSignalIndex::ResetCounters() | |
424 | { | |
425 | // | |
426 | // Reset the counters/iterators | |
427 | // | |
428 | ||
429 | fPositionRow = 0; | |
430 | fPositionCol = fPositionRow + 1; | |
431 | fPositionTbin = 1; | |
432 | fLastRow = -1; | |
433 | fLastCol = -1; | |
434 | fLastTbin = -1; | |
435 | fResetCounters = kTRUE; | |
436 | ||
437 | } |