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()
133 //_____________________________________________________________________________
134 void AliTRDSignalIndex::Copy(TObject &a) const
140 ((AliTRDSignalIndex &)a).fDet = fDet;
141 ((AliTRDSignalIndex &)a).fLayer = fLayer;
142 ((AliTRDSignalIndex &)a).fStack = fStack;
143 ((AliTRDSignalIndex &)a).fSM = fSM;
144 ((AliTRDSignalIndex &)a).fIndex = fIndex;
145 ((AliTRDSignalIndex &)a).fPositionRow = fPositionRow;
146 ((AliTRDSignalIndex &)a).fPositionTbin = fPositionTbin;
147 ((AliTRDSignalIndex &)a).fLastRow = fLastRow;
148 ((AliTRDSignalIndex &)a).fLastCol = fLastCol;
149 ((AliTRDSignalIndex &)a).fLastTbin = fLastTbin;
150 ((AliTRDSignalIndex &)a).fNrows = fNrows;
151 ((AliTRDSignalIndex &)a).fNcols = fNcols;
152 ((AliTRDSignalIndex &)a).fNtbins = fNtbins;
153 ((AliTRDSignalIndex &)a).fMaxLimit = fMaxLimit;
154 ((AliTRDSignalIndex &)a).fResetCounters = fResetCounters;
155 ((AliTRDSignalIndex &)a).fHasEntry = fHasEntry;
159 //_____________________________________________________________________________
160 AliTRDSignalIndex& AliTRDSignalIndex::operator = (const AliTRDSignalIndex& a)
163 // Assignment operator
166 if (this != &a) ((AliTRDSignalIndex &) a).Copy(*this);
171 //_____________________________________________________________________________
172 void AliTRDSignalIndex::Allocate(Int_t nrow, Int_t ncol,Int_t ntime)
182 fMaxLimit = nrow * ncol * ntime + nrow * ncol * 2;
188 fIndex = new TArrayI(fMaxLimit);
197 //_____________________________________________________________________________
198 void AliTRDSignalIndex::Reset()
201 // Reset the array but keep the size - realloc
210 Allocate(fNrows, fNcols, fNtbins);
214 //_____________________________________________________________________________
215 void AliTRDSignalIndex::ResetContent()
218 // Reset the array but keep the size - no realloc
228 //_____________________________________________________________________________
229 void AliTRDSignalIndex::ResetContentConditional(Int_t nrow, Int_t ncol,Int_t ntime)
232 // Reset the array but keep the size if no need to enlarge - no realloc
240 if ((nrow > fNrows) ||
243 Allocate(nrow, ncol, ntime);
253 //_____________________________________________________________________________
254 void AliTRDSignalIndex::ClearAll()
257 // Reset the values - clear all!
273 fIndex = new TArrayI();
280 //_____________________________________________________________________________
281 void AliTRDSignalIndex::AddIndexTBin(Int_t row, Int_t col, Int_t tbin)
284 // Store the index row-column-tbin as an interesting one
285 // The RC index is updated to!!!
286 // This is to be used in the TRD clusterizer!
289 if (row * col * tbin + row * col * 2 >= fMaxLimit) {
290 AliError(Form("Out-of-limits fPositionCol + fNtbins %d. Limit is: %d"
291 ,fPositionCol + fNtbins
296 if ((row != fLastRow) ||
299 // New RC combination
300 if (fResetCounters == kTRUE) {
303 fResetCounters = kFALSE;
306 fPositionRow += fNtbins + 2;
307 fPositionCol += fNtbins + 2;
312 (*fIndex)[fPositionRow] = row;
313 (*fIndex)[fPositionCol] = col;
314 (*fIndex)[fPositionCol + fPositionTbin] = tbin;
320 // Same RCT combination ?
322 (*fIndex)[fPositionCol + fPositionTbin] = tbin;
335 //_____________________________________________________________________________
336 Bool_t AliTRDSignalIndex::NextRCIndex(Int_t &row, Int_t &col)
339 // Return the position (index in the data array) of the next available pad
342 if (fResetCounters == kTRUE) {
345 fResetCounters = kFALSE;
348 fPositionRow += fNtbins + 2;
349 fPositionCol += fNtbins + 2;
352 if (fPositionRow >= fMaxLimit) {
358 row = (*fIndex)[fPositionRow];
359 col = (*fIndex)[fPositionCol];
370 //_____________________________________________________________________________
371 Bool_t AliTRDSignalIndex::NextRCTbinIndex(Int_t &row, Int_t &col, Int_t &tbin)
374 // Return the position (index in the data array) of the next available tbin
375 // within the current pad
378 if (fPositionRow >= fMaxLimit) {
382 if (NextTbinIndex(tbin)) {
383 row = (*fIndex)[fPositionRow];
384 col = (*fIndex)[fPositionCol];
385 fResetCounters = kFALSE;
389 if (NextRCIndex(row, col)) {
390 return NextRCTbinIndex(row, col, tbin);
398 //_____________________________________________________________________________
399 Bool_t AliTRDSignalIndex::NextTbinIndex(Int_t &tbin)
402 // Return the position (index in the data array) of the next available tbin
403 // within the current pad
406 if ((fPositionCol + fPositionTbin >= fMaxLimit) ||
407 (fPositionTbin > fNtbins )) {
411 tbin = (*fIndex)[fPositionCol + fPositionTbin];
422 //_____________________________________________________________________________
423 void AliTRDSignalIndex::ResetCounters()
426 // Reset the counters/iterators
430 fPositionCol = fPositionRow + 1;
435 fResetCounters = kTRUE;