]>
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 | ||
200 | //_____________________________________________________________________________ | |
201 | void AliTRDSignalIndex::ClearAll() | |
202 | { | |
203 | // | |
204 | // Reset the values - clear all! | |
205 | // | |
206 | ||
207 | fDet = -1; | |
208 | fLayer = -1; | |
209 | fStack = -1; | |
210 | fSM = -1; | |
211 | ||
212 | fNrows = -1; | |
213 | fNcols = -1; | |
214 | fNtbins = -1; | |
215 | ||
216 | if (fIndex) | |
217 | { | |
218 | delete fIndex; | |
219 | fIndex = NULL; | |
220 | } | |
221 | fIndex = new TArrayI(); | |
222 | ResetCounters(); | |
223 | fHasEntry = kFALSE; | |
224 | } | |
225 | ||
226 | //_____________________________________________________________________________ | |
227 | void AliTRDSignalIndex::AddIndexTBin(Int_t row, Int_t col, Int_t tbin) | |
228 | { | |
229 | // store the index row-column-tbin as an interesting one | |
230 | // the RC index is updated to!!! | |
231 | // this is to be used in the TRD clusterizer! | |
232 | ||
233 | if (fPositionCol + fNtbins >= fMaxLimit) | |
234 | { | |
235 | AliError(Form("Out-of-limits fPositionCol + fNtbins %d. Limit is: %d", fPositionCol + fNtbins, fMaxLimit)); | |
236 | return; | |
237 | } | |
238 | ||
239 | if (row != fLastRow || col != fLastCol) | |
240 | { | |
241 | // new RC combination | |
242 | if (fResetCounters == kTRUE) | |
243 | { | |
244 | fPositionRow = 0; | |
245 | fPositionCol = 1; | |
246 | ||
247 | fResetCounters = kFALSE; | |
248 | } | |
249 | else | |
250 | { | |
251 | fPositionRow += fNtbins + 2; | |
252 | fPositionCol += fNtbins + 2; | |
253 | } | |
254 | ||
255 | fPositionTbin = 1; | |
256 | ||
257 | (*fIndex)[fPositionRow] = row; | |
258 | (*fIndex)[fPositionCol] = col; | |
259 | (*fIndex)[fPositionCol + fPositionTbin] = tbin; | |
260 | ||
261 | ++fPositionTbin; | |
262 | //AliDebug(3, Form("fNRCindexed=%d", fNRCindexed)); | |
263 | } | |
264 | else | |
265 | { | |
266 | // same RCT combination ? | |
267 | // if (fLastTbin == tbin) | |
268 | // { | |
269 | // AliWarning(Form("Same RCT? %d %d %d", row, col, tbin)); | |
270 | // } | |
271 | ||
272 | (*fIndex)[fPositionCol + fPositionTbin] = tbin; | |
273 | ++fPositionTbin; | |
274 | } | |
275 | ||
276 | fLastRow = row; | |
277 | fLastCol = col; | |
278 | fLastTbin = tbin; | |
279 | ||
280 | fHasEntry = kTRUE; | |
281 | } | |
282 | ||
283 | //_____________________________________________________________________________ | |
284 | Bool_t AliTRDSignalIndex::NextRCIndex(Int_t &row, Int_t &col) | |
285 | { | |
286 | // return the position (index in the data array) of the next available pad | |
287 | ||
288 | if (fPositionCol + fNtbins >= fMaxLimit) | |
289 | { | |
290 | //AliDebug(8, "Out of index range"); | |
291 | return kFALSE; | |
292 | } | |
293 | ||
294 | if (fResetCounters == kTRUE) | |
295 | { | |
296 | fPositionRow = 0; | |
297 | fPositionCol = 1; | |
298 | ||
299 | fResetCounters = kFALSE; | |
300 | AliDebug(2, "Reset counters"); | |
301 | } | |
302 | else | |
303 | { | |
304 | fPositionRow += fNtbins + 2; | |
305 | fPositionCol += fNtbins + 2; | |
306 | } | |
307 | ||
308 | //AliDebug(8, Form("Next RC %d", fPositionRow / (fNtbins + 2))); | |
309 | ||
310 | fPositionTbin = 1; | |
311 | ||
312 | row = (*fIndex)[fPositionRow]; | |
313 | col = (*fIndex)[fPositionCol]; | |
314 | ||
315 | if (row > -1 && col > -1) | |
316 | return kTRUE; | |
317 | ||
318 | return kFALSE; | |
319 | } | |
320 | ||
321 | //_____________________________________________________________________________ | |
322 | Bool_t AliTRDSignalIndex::NextRCTbinIndex(Int_t &row, Int_t &col, Int_t &tbin) | |
323 | { | |
324 | // return the position (index in the data array) of the next available tbin | |
325 | // within the current pad | |
326 | ||
327 | // if (fNRCcounter >= fNRCindexed) | |
328 | // return kFALSE; | |
329 | ||
330 | if (fPositionCol + fNtbins >= fMaxLimit) | |
331 | { | |
332 | return kFALSE; | |
333 | } | |
334 | ||
335 | if (NextTbinIndex(tbin)) | |
336 | { | |
337 | row = (*fIndex)[fPositionRow]; | |
338 | col = (*fIndex)[fPositionCol]; | |
339 | fResetCounters = kFALSE; | |
340 | return kTRUE; | |
341 | } | |
342 | else | |
343 | { | |
344 | if (NextRCIndex(row, col)) | |
345 | { | |
346 | //return NextTbinIndex(tbin); | |
347 | return NextRCTbinIndex(row, col, tbin); | |
348 | } | |
349 | } | |
350 | ||
351 | return kFALSE; | |
352 | } | |
353 | ||
354 | //_____________________________________________________________________________ | |
355 | Bool_t AliTRDSignalIndex::NextTbinIndex(Int_t &tbin) | |
356 | { | |
357 | // return the position (index in the data array) of the next available tbin | |
358 | // within the current pad | |
359 | ||
360 | // if (fNRCcounter >= fNRCindexed) | |
361 | // return kFALSE; | |
362 | ||
363 | if (fPositionCol + fNtbins >= fMaxLimit || fPositionTbin > fNtbins) | |
364 | { | |
365 | return kFALSE; | |
366 | } | |
367 | ||
368 | tbin = (*fIndex)[fPositionCol + fPositionTbin]; | |
369 | ||
370 | if (tbin > -1) | |
371 | { | |
372 | ++fPositionTbin; | |
373 | return kTRUE; | |
374 | } | |
375 | ||
376 | return kFALSE; | |
377 | } | |
378 | ||
379 | // void AliTRDSignalIndex::Dump() | |
380 | // { | |
381 | // AliInfo("R C T..."); | |
382 | // Int_t i = 0; | |
383 | // Int_t rcok = 0; | |
384 | // while ( i < fMaxLimit ) | |
385 | // { | |
386 | // if (i % (fNtbins + 2) == 0) | |
387 | // { | |
388 | // if ((*(*fIndex))[i] > -1) | |
389 | // { | |
390 | // rcok = 1; | |
391 | // printf("\n RC : "); | |
392 | // } | |
393 | // else | |
394 | // rcok = 0; | |
395 | // } | |
396 | // if (rcok) | |
397 | // if ((*(*fIndex))[i] > -1) | |
398 | // printf("[%d] = %d \t", i, (*(*fIndex))[i]); | |
399 | // i++; | |
400 | // } | |
401 | // } | |
402 | ||
403 | // //_____________________________________________________________________________ | |
404 | // void AliTRDSignalIndex::Dump() | |
405 | // { | |
406 | // // | |
407 | // // Dump the data | |
408 | // // | |
409 | ||
410 | // AliInfo("R C T..."); | |
411 | // Int_t i = 0; | |
412 | // Int_t rcok = 0; | |
413 | // while ( i < fMaxLimit ) | |
414 | // { | |
415 | // if (i % (fNtbins + 2) == 0) | |
416 | // { | |
417 | // if ((*fIndex)[i] > -1) | |
418 | // { | |
419 | // rcok = 1; | |
420 | // printf("\n RC : "); | |
421 | // } | |
422 | // else | |
423 | // rcok = 0; | |
424 | // } | |
425 | // if (rcok) | |
426 | // if ((*fIndex)[i] > -1) | |
427 | // printf("[%d] = %d \t", i, (*fIndex)[i]); | |
428 | // i++; | |
429 | // } | |
430 | // } | |
431 | ||
432 | // //_____________________________________________________________________________ | |
433 | // void AliTRDSignalIndex::Dump2() | |
434 | // { | |
435 | // // | |
436 | // // Dump the data | |
437 | // // | |
438 | ||
439 | // AliInfo("R C T..."); | |
440 | // Int_t ir, ic, it; | |
441 | // ResetCounters(); | |
442 | // while (NextRCIndex(ir, ic)) | |
443 | // { | |
444 | // printf("\nR %d C %d t : ", ir, ic); | |
445 | // while (NextTbinIndex(it)) | |
446 | // printf("%d ", it); | |
447 | // } | |
448 | // printf("\n"); | |
449 | // } |