1 /**************************************************************************
2 * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
4 * Author: The ALICE Off-line Project. *
5 * Contributors are mentioned in the code where appropriate. *
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 **************************************************************************/
18 ///////////////////////////////////////////////////////////////////////////////
20 // General container for data from TRD detector segments //
21 // Adapted from AliDigits, origin M.Ivanov //
23 // Author: M. Ploskon (ploskon@ikf.uni-frankfurt.de) //
25 ///////////////////////////////////////////////////////////////////////////////
27 #include "AliTRDSignalIndex.h"
32 ClassImp(AliTRDSignalIndex)
34 //_____________________________________________________________________________
35 AliTRDSignalIndex::AliTRDSignalIndex()
52 , fResetCounters(kTRUE)
61 //_____________________________________________________________________________
62 AliTRDSignalIndex::AliTRDSignalIndex(Int_t nrow, Int_t ncol,Int_t ntime)
79 , fResetCounters(kTRUE)
82 // not the default contructor... hmmm...
83 Allocate(nrow, ncol, ntime);
86 //_____________________________________________________________________________
87 AliTRDSignalIndex::~AliTRDSignalIndex()
97 //_____________________________________________________________________________
98 AliTRDSignalIndex::AliTRDSignalIndex(const AliTRDSignalIndex &a)
105 , fPositionRow(a.fPositionRow)
106 , fPositionCol(a.fPositionCol)
107 , fPositionTbin(a.fPositionTbin)
108 , fLastRow(a.fLastRow)
109 , fLastCol(a.fLastCol)
110 , fLastTbin(a.fLastTbin)
114 , fMaxLimit(a.fMaxLimit)
115 , fResetCounters(a.fResetCounters)
116 , fHasEntry(a.fHasEntry)
123 //_____________________________________________________________________________
124 void AliTRDSignalIndex::Copy(TObject &a) const
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;
148 //_____________________________________________________________________________
149 AliTRDSignalIndex& AliTRDSignalIndex::operator = (const AliTRDSignalIndex& a)
152 // Assignment operator
155 if (this != &a) ((AliTRDSignalIndex &) a).Copy(*this);
159 //_____________________________________________________________________________
160 void AliTRDSignalIndex::Allocate(Int_t nrow, Int_t ncol,Int_t ntime)
170 fMaxLimit = nrow * ncol * ntime + nrow * ncol * 2;
177 fIndex = new TArrayI(fMaxLimit);
178 //fIndex->Set(fMaxLimit);
184 //_____________________________________________________________________________
185 void AliTRDSignalIndex::Reset()
188 // Reset the array but keep the size - realloc
197 Allocate(fNrows, fNcols, fNtbins);
200 //_____________________________________________________________________________
201 void AliTRDSignalIndex::ResetContent()
204 // Reset the array but keep the size - no realloc
212 //_____________________________________________________________________________
213 void AliTRDSignalIndex::ResetContentConditional(Int_t nrow, Int_t ncol,Int_t ntime)
216 // Reset the array but keep the size if no need to enlarge - no realloc
224 if (nrow > fNrows || ncol > fNcols || ntime > fNtbins)
226 Allocate(nrow, ncol, ntime);
237 //_____________________________________________________________________________
238 void AliTRDSignalIndex::ClearAll()
241 // Reset the values - clear all!
258 fIndex = new TArrayI();
263 //_____________________________________________________________________________
264 void AliTRDSignalIndex::AddIndexTBin(Int_t row, Int_t col, Int_t tbin)
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!
270 if (fPositionCol + fNtbins >= fMaxLimit)
272 AliError(Form("Out-of-limits fPositionCol + fNtbins %d. Limit is: %d", fPositionCol + fNtbins, fMaxLimit));
276 if (row != fLastRow || col != fLastCol)
278 // new RC combination
279 if (fResetCounters == kTRUE)
284 fResetCounters = kFALSE;
288 fPositionRow += fNtbins + 2;
289 fPositionCol += fNtbins + 2;
294 (*fIndex)[fPositionRow] = row;
295 (*fIndex)[fPositionCol] = col;
296 (*fIndex)[fPositionCol + fPositionTbin] = tbin;
299 //AliDebug(3, Form("fNRCindexed=%d", fNRCindexed));
303 // same RCT combination ?
304 // if (fLastTbin == tbin)
306 // AliWarning(Form("Same RCT? %d %d %d", row, col, tbin));
309 (*fIndex)[fPositionCol + fPositionTbin] = tbin;
320 //_____________________________________________________________________________
321 Bool_t AliTRDSignalIndex::NextRCIndex(Int_t &row, Int_t &col)
323 // return the position (index in the data array) of the next available pad
325 if (fPositionCol + fNtbins >= fMaxLimit)
327 //AliDebug(8, "Out of index range");
331 if (fResetCounters == kTRUE)
336 fResetCounters = kFALSE;
337 AliDebug(2, "Reset counters");
341 fPositionRow += fNtbins + 2;
342 fPositionCol += fNtbins + 2;
345 //AliDebug(8, Form("Next RC %d", fPositionRow / (fNtbins + 2)));
349 row = (*fIndex)[fPositionRow];
350 col = (*fIndex)[fPositionCol];
352 if (row > -1 && col > -1)
358 //_____________________________________________________________________________
359 Bool_t AliTRDSignalIndex::NextRCTbinIndex(Int_t &row, Int_t &col, Int_t &tbin)
361 // return the position (index in the data array) of the next available tbin
362 // within the current pad
364 // if (fNRCcounter >= fNRCindexed)
367 if (fPositionCol + fNtbins >= fMaxLimit)
372 if (NextTbinIndex(tbin))
374 row = (*fIndex)[fPositionRow];
375 col = (*fIndex)[fPositionCol];
376 fResetCounters = kFALSE;
381 if (NextRCIndex(row, col))
383 //return NextTbinIndex(tbin);
384 return NextRCTbinIndex(row, col, tbin);
391 //_____________________________________________________________________________
392 Bool_t AliTRDSignalIndex::NextTbinIndex(Int_t &tbin)
394 // return the position (index in the data array) of the next available tbin
395 // within the current pad
397 // if (fNRCcounter >= fNRCindexed)
400 if (fPositionCol + fNtbins >= fMaxLimit || fPositionTbin > fNtbins)
405 tbin = (*fIndex)[fPositionCol + fPositionTbin];
416 // void AliTRDSignalIndex::Dump()
418 // AliInfo("R C T...");
421 // while ( i < fMaxLimit )
423 // if (i % (fNtbins + 2) == 0)
425 // if ((*(*fIndex))[i] > -1)
428 // printf("\n RC : ");
434 // if ((*(*fIndex))[i] > -1)
435 // printf("[%d] = %d \t", i, (*(*fIndex))[i]);
440 // //_____________________________________________________________________________
441 // void AliTRDSignalIndex::Dump()
447 // AliInfo("R C T...");
450 // while ( i < fMaxLimit )
452 // if (i % (fNtbins + 2) == 0)
454 // if ((*fIndex)[i] > -1)
457 // printf("\n RC : ");
463 // if ((*fIndex)[i] > -1)
464 // printf("[%d] = %d \t", i, (*fIndex)[i]);
469 // //_____________________________________________________________________________
470 // void AliTRDSignalIndex::Dump2()
476 // AliInfo("R C T...");
479 // while (NextRCIndex(ir, ic))
481 // printf("\nR %d C %d t : ", ir, ic);
482 // while (NextTbinIndex(it))
483 // printf("%d ", it);