]>
Commit | Line | Data |
---|---|---|
ca21baaa | 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 | // // | |
c8ab4518 | 23 | // Author: // |
24 | // Mateusz Ploskon (ploskon@ikf.uni-frankfurt.de) // | |
ca21baaa | 25 | // // |
26 | /////////////////////////////////////////////////////////////////////////////// | |
27 | ||
ca21baaa | 28 | #include "TArrayI.h" |
c8ab4518 | 29 | |
ca21baaa | 30 | #include "AliLog.h" |
31 | ||
c8ab4518 | 32 | #include "AliTRDSignalIndex.h" |
33 | ||
ca21baaa | 34 | ClassImp(AliTRDSignalIndex) |
35 | ||
36 | //_____________________________________________________________________________ | |
37 | AliTRDSignalIndex::AliTRDSignalIndex() | |
c8ab4518 | 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) | |
ca21baaa | 56 | { |
57 | // | |
c8ab4518 | 58 | // Default contructor |
ca21baaa | 59 | // |
c8ab4518 | 60 | |
ca21baaa | 61 | ResetCounters(); |
c8ab4518 | 62 | |
ca21baaa | 63 | } |
64 | ||
65 | //_____________________________________________________________________________ | |
66 | AliTRDSignalIndex::AliTRDSignalIndex(Int_t nrow, Int_t ncol,Int_t ntime) | |
c8ab4518 | 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) | |
ca21baaa | 85 | { |
c8ab4518 | 86 | // |
87 | // Not the default contructor... hmmm... | |
88 | // | |
89 | ||
ca21baaa | 90 | Allocate(nrow, ncol, ntime); |
c8ab4518 | 91 | |
ca21baaa | 92 | } |
93 | ||
94 | //_____________________________________________________________________________ | |
c8ab4518 | 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) | |
ca21baaa | 114 | { |
115 | // | |
c8ab4518 | 116 | // Copy constructor |
ca21baaa | 117 | // |
118 | ||
ca21baaa | 119 | } |
120 | ||
121 | //_____________________________________________________________________________ | |
c8ab4518 | 122 | AliTRDSignalIndex::~AliTRDSignalIndex() |
ca21baaa | 123 | { |
124 | // | |
c8ab4518 | 125 | // Destructor |
ca21baaa | 126 | // |
c8ab4518 | 127 | |
128 | delete fIndex; | |
129 | fIndex = NULL; | |
130 | ||
ca21baaa | 131 | } |
132 | ||
133 | //_____________________________________________________________________________ | |
134 | void AliTRDSignalIndex::Copy(TObject &a) const | |
135 | { | |
136 | // | |
137 | // Copy function | |
138 | // | |
139 | ||
c8ab4518 | 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; | |
ca21baaa | 154 | ((AliTRDSignalIndex &)a).fResetCounters = fResetCounters; |
c8ab4518 | 155 | ((AliTRDSignalIndex &)a).fHasEntry = fHasEntry; |
156 | ||
ca21baaa | 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 | } | |
c8ab4518 | 170 | |
ca21baaa | 171 | //_____________________________________________________________________________ |
172 | void AliTRDSignalIndex::Allocate(Int_t nrow, Int_t ncol,Int_t ntime) | |
173 | { | |
174 | // | |
c8ab4518 | 175 | // Create the arrays |
ca21baaa | 176 | // |
177 | ||
178 | fNrows = nrow; | |
179 | fNcols = ncol; | |
180 | fNtbins = ntime; | |
181 | ||
182 | fMaxLimit = nrow * ncol * ntime + nrow * ncol * 2; | |
c8ab4518 | 183 | if (fIndex) { |
184 | delete fIndex; | |
185 | fIndex = NULL; | |
186 | } | |
ca21baaa | 187 | |
188 | fIndex = new TArrayI(fMaxLimit); | |
ca21baaa | 189 | fIndex->Reset(-1); |
c8ab4518 | 190 | |
ca21baaa | 191 | ResetCounters(); |
c8ab4518 | 192 | |
ca21baaa | 193 | fHasEntry = kFALSE; |
c8ab4518 | 194 | |
ca21baaa | 195 | } |
196 | ||
197 | //_____________________________________________________________________________ | |
198 | void AliTRDSignalIndex::Reset() | |
199 | { | |
200 | // | |
201 | // Reset the array but keep the size - realloc | |
202 | // | |
203 | ||
c8ab4518 | 204 | fDet = -1; |
ca21baaa | 205 | fLayer = -1; |
206 | fStack = -1; | |
c8ab4518 | 207 | fSM = -1; |
ca21baaa | 208 | |
c8ab4518 | 209 | // All will be lost |
ca21baaa | 210 | Allocate(fNrows, fNcols, fNtbins); |
c8ab4518 | 211 | |
ca21baaa | 212 | } |
213 | ||
001be664 | 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(); | |
c8ab4518 | 223 | |
001be664 | 224 | fHasEntry = kFALSE; |
c8ab4518 | 225 | |
001be664 | 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 | ||
c8ab4518 | 235 | fDet = -1; |
001be664 | 236 | fLayer = -1; |
237 | fStack = -1; | |
c8ab4518 | 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 | } | |
001be664 | 250 | |
001be664 | 251 | } |
252 | ||
ca21baaa | 253 | //_____________________________________________________________________________ |
254 | void AliTRDSignalIndex::ClearAll() | |
255 | { | |
256 | // | |
257 | // Reset the values - clear all! | |
258 | // | |
259 | ||
c8ab4518 | 260 | fDet = -1; |
261 | fLayer = -1; | |
262 | fStack = -1; | |
263 | fSM = -1; | |
ca21baaa | 264 | |
c8ab4518 | 265 | fNrows = -1; |
266 | fNcols = -1; | |
ca21baaa | 267 | fNtbins = -1; |
268 | ||
c8ab4518 | 269 | if (fIndex) { |
270 | delete fIndex; | |
271 | fIndex = NULL; | |
272 | } | |
ca21baaa | 273 | fIndex = new TArrayI(); |
274 | ResetCounters(); | |
c8ab4518 | 275 | |
ca21baaa | 276 | fHasEntry = kFALSE; |
c8ab4518 | 277 | |
ca21baaa | 278 | } |
279 | ||
280 | //_____________________________________________________________________________ | |
281 | void AliTRDSignalIndex::AddIndexTBin(Int_t row, Int_t col, Int_t tbin) | |
282 | { | |
c8ab4518 | 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)) { | |
ca21baaa | 298 | |
c8ab4518 | 299 | // New RC combination |
300 | if (fResetCounters == kTRUE) { | |
301 | fPositionRow = 0; | |
302 | fPositionCol = 1; | |
303 | fResetCounters = kFALSE; | |
ca21baaa | 304 | } |
c8ab4518 | 305 | else { |
306 | fPositionRow += fNtbins + 2; | |
307 | fPositionCol += fNtbins + 2; | |
ca21baaa | 308 | } |
c8ab4518 | 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 | } | |
ca21baaa | 326 | |
327 | fLastRow = row; | |
328 | fLastCol = col; | |
329 | fLastTbin = tbin; | |
330 | ||
331 | fHasEntry = kTRUE; | |
c8ab4518 | 332 | |
ca21baaa | 333 | } |
334 | ||
335 | //_____________________________________________________________________________ | |
336 | Bool_t AliTRDSignalIndex::NextRCIndex(Int_t &row, Int_t &col) | |
337 | { | |
c8ab4518 | 338 | // |
339 | // Return the position (index in the data array) of the next available pad | |
340 | // | |
ca21baaa | 341 | |
c8ab4518 | 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 | } | |
ecf39416 | 351 | |
c8ab4518 | 352 | if (fPositionRow >= fMaxLimit) { |
353 | return kFALSE; | |
354 | } | |
ca21baaa | 355 | |
356 | fPositionTbin = 1; | |
357 | ||
358 | row = (*fIndex)[fPositionRow]; | |
359 | col = (*fIndex)[fPositionCol]; | |
360 | ||
c8ab4518 | 361 | if ((row > -1) && |
362 | (col > -1)) { | |
ca21baaa | 363 | return kTRUE; |
c8ab4518 | 364 | } |
ca21baaa | 365 | |
366 | return kFALSE; | |
c8ab4518 | 367 | |
ca21baaa | 368 | } |
369 | ||
370 | //_____________________________________________________________________________ | |
c8ab4518 | 371 | Bool_t AliTRDSignalIndex::NextRCTbinIndex(Int_t &row, Int_t &col, Int_t &tbin) |
ca21baaa | 372 | { |
c8ab4518 | 373 | // |
374 | // Return the position (index in the data array) of the next available tbin | |
ca21baaa | 375 | // within the current pad |
c8ab4518 | 376 | // |
ca21baaa | 377 | |
c8ab4518 | 378 | if (fPositionRow >= fMaxLimit) { |
379 | return kFALSE; | |
380 | } | |
ca21baaa | 381 | |
c8ab4518 | 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); | |
ca21baaa | 391 | } |
c8ab4518 | 392 | } |
ca21baaa | 393 | |
394 | return kFALSE; | |
c8ab4518 | 395 | |
ca21baaa | 396 | } |
397 | ||
398 | //_____________________________________________________________________________ | |
c8ab4518 | 399 | Bool_t AliTRDSignalIndex::NextTbinIndex(Int_t &tbin) |
ca21baaa | 400 | { |
c8ab4518 | 401 | // |
402 | // Return the position (index in the data array) of the next available tbin | |
ca21baaa | 403 | // within the current pad |
c8ab4518 | 404 | // |
ca21baaa | 405 | |
c8ab4518 | 406 | if ((fPositionCol + fPositionTbin >= fMaxLimit) || |
407 | (fPositionTbin > fNtbins )) { | |
408 | return kFALSE; | |
409 | } | |
ca21baaa | 410 | |
411 | tbin = (*fIndex)[fPositionCol + fPositionTbin]; | |
412 | ||
c8ab4518 | 413 | if (tbin > -1) { |
414 | ++fPositionTbin; | |
415 | return kTRUE; | |
416 | } | |
ca21baaa | 417 | |
418 | return kFALSE; | |
c8ab4518 | 419 | |
ca21baaa | 420 | } |
421 | ||
c8ab4518 | 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 | } |