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 //
24 // Mateusz Ploskon (ploskon@ikf.uni-frankfurt.de) //
26 ///////////////////////////////////////////////////////////////////////////////
32 #include "AliTRDSignalIndex.h"
34 ClassImp(AliTRDSignalIndex)
36 //_____________________________________________________________________________
37 AliTRDSignalIndex::AliTRDSignalIndex()
54 ,fResetCounters(kTRUE)
65 //_____________________________________________________________________________
66 AliTRDSignalIndex::AliTRDSignalIndex(Int_t nrow, Int_t ncol,Int_t ntime)
83 ,fResetCounters(kTRUE)
87 // Not the default contructor... hmmm...
90 Allocate(nrow, ncol, ntime);
94 //_____________________________________________________________________________
95 AliTRDSignalIndex::AliTRDSignalIndex(const AliTRDSignalIndex &a)
102 ,fPositionRow(a.fPositionRow)
103 ,fPositionCol(a.fPositionCol)
104 ,fPositionTbin(a.fPositionTbin)
105 ,fLastRow(a.fLastRow)
106 ,fLastCol(a.fLastCol)
107 ,fLastTbin(a.fLastTbin)
111 ,fMaxLimit(a.fMaxLimit)
112 ,fResetCounters(a.fResetCounters)
113 ,fHasEntry(a.fHasEntry)
121 //_____________________________________________________________________________
122 AliTRDSignalIndex::~AliTRDSignalIndex()
135 //_____________________________________________________________________________
136 void AliTRDSignalIndex::Copy(TObject &a) const
142 ((AliTRDSignalIndex &)a).fDet = fDet;
143 ((AliTRDSignalIndex &)a).fLayer = fLayer;
144 ((AliTRDSignalIndex &)a).fStack = fStack;
145 ((AliTRDSignalIndex &)a).fSM = fSM;
146 ((AliTRDSignalIndex &)a).fIndex = fIndex;
147 ((AliTRDSignalIndex &)a).fPositionRow = fPositionRow;
148 ((AliTRDSignalIndex &)a).fPositionTbin = fPositionTbin;
149 ((AliTRDSignalIndex &)a).fLastRow = fLastRow;
150 ((AliTRDSignalIndex &)a).fLastCol = fLastCol;
151 ((AliTRDSignalIndex &)a).fLastTbin = fLastTbin;
152 ((AliTRDSignalIndex &)a).fNrows = fNrows;
153 ((AliTRDSignalIndex &)a).fNcols = fNcols;
154 ((AliTRDSignalIndex &)a).fNtbins = fNtbins;
155 ((AliTRDSignalIndex &)a).fMaxLimit = fMaxLimit;
156 ((AliTRDSignalIndex &)a).fResetCounters = fResetCounters;
157 ((AliTRDSignalIndex &)a).fHasEntry = fHasEntry;
161 //_____________________________________________________________________________
162 AliTRDSignalIndex& AliTRDSignalIndex::operator = (const AliTRDSignalIndex& a)
165 // Assignment operator
168 if (this != &a) ((AliTRDSignalIndex &) a).Copy(*this);
173 //_____________________________________________________________________________
174 void AliTRDSignalIndex::Allocate(Int_t nrow, Int_t ncol,Int_t ntime)
184 fMaxLimit = nrow * ncol * ntime + nrow * ncol * 2;
190 fIndex = new TArrayI(fMaxLimit);
199 //_____________________________________________________________________________
200 void AliTRDSignalIndex::Reset()
203 // Reset the array but keep the size - realloc
212 Allocate(fNrows, fNcols, fNtbins);
216 //_____________________________________________________________________________
217 void AliTRDSignalIndex::ResetContent()
220 // Reset the array but keep the size - no realloc
230 //_____________________________________________________________________________
231 void AliTRDSignalIndex::ResetContentConditional(Int_t nrow, Int_t ncol,Int_t ntime)
234 // Reset the array but keep the size if no need to enlarge - no realloc
242 if ((nrow > fNrows) ||
245 Allocate(nrow, ncol, ntime);
255 //_____________________________________________________________________________
256 void AliTRDSignalIndex::ClearAll()
259 // Reset the values - clear all!
275 fIndex = new TArrayI();
282 //_____________________________________________________________________________
283 void AliTRDSignalIndex::AddIndexTBin(Int_t row, Int_t col, Int_t tbin)
286 // Store the index row-column-tbin as an interesting one
287 // The RC index is updated to!!!
288 // This is to be used in the TRD clusterizer!
291 if (row * col * tbin + row * col * 2 >= fMaxLimit) {
292 AliError(Form("Out-of-limits fPositionCol + fNtbins %d. Limit is: %d"
293 ,fPositionCol + fNtbins
298 if ((row != fLastRow) ||
301 // New RC combination
302 if (fResetCounters == kTRUE) {
305 fResetCounters = kFALSE;
308 fPositionRow += fNtbins + 2;
309 fPositionCol += fNtbins + 2;
314 (*fIndex)[fPositionRow] = row;
315 (*fIndex)[fPositionCol] = col;
316 (*fIndex)[fPositionCol + fPositionTbin] = tbin;
322 // Same RCT combination ?
324 (*fIndex)[fPositionCol + fPositionTbin] = tbin;
337 //_____________________________________________________________________________
338 Bool_t AliTRDSignalIndex::NextRCIndex(Int_t &row, Int_t &col)
341 // Return the position (index in the data array) of the next available pad
344 if (fResetCounters == kTRUE) {
347 fResetCounters = kFALSE;
350 fPositionRow += fNtbins + 2;
351 fPositionCol += fNtbins + 2;
354 if (fPositionRow >= fMaxLimit) {
360 row = (*fIndex)[fPositionRow];
361 col = (*fIndex)[fPositionCol];
372 //_____________________________________________________________________________
373 Bool_t AliTRDSignalIndex::NextRCTbinIndex(Int_t &row, Int_t &col, Int_t &tbin)
376 // Return the position (index in the data array) of the next available tbin
377 // within the current pad
380 if (fPositionRow >= fMaxLimit) {
384 if (NextTbinIndex(tbin)) {
385 row = (*fIndex)[fPositionRow];
386 col = (*fIndex)[fPositionCol];
387 fResetCounters = kFALSE;
391 if (NextRCIndex(row, col)) {
392 return NextRCTbinIndex(row, col, tbin);
400 //_____________________________________________________________________________
401 Bool_t AliTRDSignalIndex::NextTbinIndex(Int_t &tbin)
404 // Return the position (index in the data array) of the next available tbin
405 // within the current pad
408 if ((fPositionCol + fPositionTbin >= fMaxLimit) ||
409 (fPositionTbin > fNtbins )) {
413 tbin = (*fIndex)[fPositionCol + fPositionTbin];
424 //_____________________________________________________________________________
425 void AliTRDSignalIndex::ResetCounters()
428 // Reset the counters/iterators
432 fPositionCol = fPositionRow + 1;
437 fResetCounters = kTRUE;