]> git.uio.no Git - u/mrichter/AliRoot.git/blame - TRD/AliTRDSignalIndex.cxx
Adding libSTEERBase to the list of libs needed to build the static DA executable
[u/mrichter/AliRoot.git] / TRD / AliTRDSignalIndex.cxx
CommitLineData
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
32ClassImp(AliTRDSignalIndex)
33
34//_____________________________________________________________________________
35AliTRDSignalIndex::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//_____________________________________________________________________________
62AliTRDSignalIndex::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//_____________________________________________________________________________
87AliTRDSignalIndex::~AliTRDSignalIndex()
88{
89 //
90 // Destructor
91 //
92
93 delete fIndex;
94 fIndex = NULL;
95}
96
97//_____________________________________________________________________________
98AliTRDSignalIndex::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//_____________________________________________________________________________
124void 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//_____________________________________________________________________________
149AliTRDSignalIndex& 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//_____________________________________________________________________________
160void 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//_____________________________________________________________________________
185void 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//_____________________________________________________________________________
201void 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//_____________________________________________________________________________
213void 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//_____________________________________________________________________________
238void 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//_____________________________________________________________________________
264void 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
270 if (fPositionCol + fNtbins >= fMaxLimit)
271 {
272 AliError(Form("Out-of-limits fPositionCol + fNtbins %d. Limit is: %d", fPositionCol + fNtbins, fMaxLimit));
273 return;
274 }
275
276 if (row != fLastRow || col != fLastCol)
277 {
278 // new RC combination
279 if (fResetCounters == kTRUE)
280 {
281 fPositionRow = 0;
282 fPositionCol = 1;
283
284 fResetCounters = kFALSE;
285 }
286 else
287 {
288 fPositionRow += fNtbins + 2;
289 fPositionCol += fNtbins + 2;
290 }
291
292 fPositionTbin = 1;
293
294 (*fIndex)[fPositionRow] = row;
295 (*fIndex)[fPositionCol] = col;
296 (*fIndex)[fPositionCol + fPositionTbin] = tbin;
297
298 ++fPositionTbin;
299 //AliDebug(3, Form("fNRCindexed=%d", fNRCindexed));
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;
310 ++fPositionTbin;
311 }
312
313 fLastRow = row;
314 fLastCol = col;
315 fLastTbin = tbin;
316
317 fHasEntry = kTRUE;
318}
319
320//_____________________________________________________________________________
321Bool_t AliTRDSignalIndex::NextRCIndex(Int_t &row, Int_t &col)
322{
323 // return the position (index in the data array) of the next available pad
324
325 if (fPositionCol + fNtbins >= fMaxLimit)
326 {
327 //AliDebug(8, "Out of index range");
328 return kFALSE;
329 }
330
331 if (fResetCounters == kTRUE)
332 {
333 fPositionRow = 0;
334 fPositionCol = 1;
335
336 fResetCounters = kFALSE;
337 AliDebug(2, "Reset counters");
338 }
339 else
340 {
341 fPositionRow += fNtbins + 2;
342 fPositionCol += fNtbins + 2;
343 }
344
345 //AliDebug(8, Form("Next RC %d", fPositionRow / (fNtbins + 2)));
346
347 fPositionTbin = 1;
348
349 row = (*fIndex)[fPositionRow];
350 col = (*fIndex)[fPositionCol];
351
352 if (row > -1 && col > -1)
353 return kTRUE;
354
355 return kFALSE;
356}
357
358//_____________________________________________________________________________
359Bool_t AliTRDSignalIndex::NextRCTbinIndex(Int_t &row, Int_t &col, Int_t &tbin)
360{
361 // return the position (index in the data array) of the next available tbin
362 // within the current pad
363
364// if (fNRCcounter >= fNRCindexed)
365// return kFALSE;
366
367 if (fPositionCol + fNtbins >= fMaxLimit)
368 {
369 return kFALSE;
370 }
371
372 if (NextTbinIndex(tbin))
373 {
374 row = (*fIndex)[fPositionRow];
375 col = (*fIndex)[fPositionCol];
376 fResetCounters = kFALSE;
377 return kTRUE;
378 }
379 else
380 {
381 if (NextRCIndex(row, col))
382 {
383 //return NextTbinIndex(tbin);
384 return NextRCTbinIndex(row, col, tbin);
385 }
386 }
387
388 return kFALSE;
389}
390
391//_____________________________________________________________________________
392Bool_t AliTRDSignalIndex::NextTbinIndex(Int_t &tbin)
393{
394 // return the position (index in the data array) of the next available tbin
395 // within the current pad
396
397// if (fNRCcounter >= fNRCindexed)
398// return kFALSE;
399
400 if (fPositionCol + fNtbins >= fMaxLimit || fPositionTbin > fNtbins)
401 {
402 return kFALSE;
403 }
404
405 tbin = (*fIndex)[fPositionCol + fPositionTbin];
406
407 if (tbin > -1)
408 {
409 ++fPositionTbin;
410 return kTRUE;
411 }
412
413 return kFALSE;
414}
415
416// void AliTRDSignalIndex::Dump()
417// {
418// AliInfo("R C T...");
419// Int_t i = 0;
420// Int_t rcok = 0;
421// while ( i < fMaxLimit )
422// {
423// if (i % (fNtbins + 2) == 0)
424// {
425// if ((*(*fIndex))[i] > -1)
426// {
427// rcok = 1;
428// printf("\n RC : ");
429// }
430// else
431// rcok = 0;
432// }
433// if (rcok)
434// if ((*(*fIndex))[i] > -1)
435// printf("[%d] = %d \t", i, (*(*fIndex))[i]);
436// i++;
437// }
438// }
439
440// //_____________________________________________________________________________
441// void AliTRDSignalIndex::Dump()
442// {
443// //
444// // Dump the data
445// //
446
447// AliInfo("R C T...");
448// Int_t i = 0;
449// Int_t rcok = 0;
450// while ( i < fMaxLimit )
451// {
452// if (i % (fNtbins + 2) == 0)
453// {
454// if ((*fIndex)[i] > -1)
455// {
456// rcok = 1;
457// printf("\n RC : ");
458// }
459// else
460// rcok = 0;
461// }
462// if (rcok)
463// if ((*fIndex)[i] > -1)
464// printf("[%d] = %d \t", i, (*fIndex)[i]);
465// i++;
466// }
467// }
468
469// //_____________________________________________________________________________
470// void AliTRDSignalIndex::Dump2()
471// {
472// //
473// // Dump the data
474// //
475
476// AliInfo("R C T...");
477// Int_t ir, ic, it;
478// ResetCounters();
479// while (NextRCIndex(ir, ic))
480// {
481// printf("\nR %d C %d t : ", ir, ic);
482// while (NextTbinIndex(it))
483// printf("%d ", it);
484// }
485// printf("\n");
486// }