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