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)
271 if (row * col * tbin + row * col * 2 >= fMaxLimit)
273 AliError(Form("Out-of-limits fPositionCol + fNtbins %d. Limit is: %d", fPositionCol + fNtbins, fMaxLimit));
277 if (row != fLastRow || col != fLastCol)
279 // new RC combination
280 if (fResetCounters == kTRUE)
285 fResetCounters = kFALSE;
289 fPositionRow += fNtbins + 2;
290 fPositionCol += fNtbins + 2;
295 (*fIndex)[fPositionRow] = row;
296 (*fIndex)[fPositionCol] = col;
297 (*fIndex)[fPositionCol + fPositionTbin] = tbin;
298 //AliInfo(Form("x1: fPositionCol + fPositionTbin = %d", fPositionCol + fPositionTbin));
303 // same RCT combination ?
304 // if (fLastTbin == tbin)
306 // AliWarning(Form("Same RCT? %d %d %d", row, col, tbin));
309 (*fIndex)[fPositionCol + fPositionTbin] = tbin;
310 //AliInfo(Form("x2: fPositionCol + fPositionTbin = %d", fPositionCol + fPositionTbin));
321 //_____________________________________________________________________________
322 Bool_t AliTRDSignalIndex::NextRCIndex(Int_t &row, Int_t &col)
324 // return the position (index in the data array) of the next available pad
326 if (fResetCounters == kTRUE)
331 fResetCounters = kFALSE;
332 //AliDebug(2, "Reset counters");
336 fPositionRow += fNtbins + 2;
337 fPositionCol += fNtbins + 2;
340 if (fPositionRow >= fMaxLimit)
342 //AliDebug(8, "Out of index range");
346 //AliDebug(8, Form("Next RC %d", fPositionRow / (fNtbins + 2)));
350 row = (*fIndex)[fPositionRow];
351 col = (*fIndex)[fPositionCol];
353 if (row > -1 && col > -1)
359 //_____________________________________________________________________________
360 Bool_t AliTRDSignalIndex::NextRCTbinIndex(Int_t &row, Int_t &col, Int_t &tbin)
362 // return the position (index in the data array) of the next available tbin
363 // within the current pad
365 if (fPositionRow >= fMaxLimit)
367 //AliDebug(8, "Out of index range");
371 if (NextTbinIndex(tbin))
373 row = (*fIndex)[fPositionRow];
374 col = (*fIndex)[fPositionCol];
375 fResetCounters = kFALSE;
380 if (NextRCIndex(row, col))
382 return NextRCTbinIndex(row, col, tbin);
389 //_____________________________________________________________________________
390 Bool_t AliTRDSignalIndex::NextTbinIndex(Int_t &tbin)
392 // return the position (index in the data array) of the next available tbin
393 // within the current pad
395 if (fPositionCol + fPositionTbin >= fMaxLimit || fPositionTbin > fNtbins)
397 //AliDebug(8, "Out of index range");
401 tbin = (*fIndex)[fPositionCol + fPositionTbin];
412 // void AliTRDSignalIndex::Dump()
414 // AliInfo("R C T...");
417 // while ( i < fMaxLimit )
419 // if (i % (fNtbins + 2) == 0)
421 // if ((*(*fIndex))[i] > -1)
424 // printf("\n RC : ");
430 // if ((*(*fIndex))[i] > -1)
431 // printf("[%d] = %d \t", i, (*(*fIndex))[i]);
436 // //_____________________________________________________________________________
437 // void AliTRDSignalIndex::Dump()
443 // AliInfo("R C T...");
446 // while ( i < fMaxLimit )
448 // if (i % (fNtbins + 2) == 0)
450 // if ((*fIndex)[i] > -1)
453 // printf("\n RC : ");
459 // if ((*fIndex)[i] > -1)
460 // printf("[%d] = %d \t", i, (*fIndex)[i]);
465 // //_____________________________________________________________________________
466 // void AliTRDSignalIndex::Dump2()
472 // AliInfo("R C T...");
475 // while (NextRCIndex(ir, ic))
477 // printf("\nR %d C %d t : ", ir, ic);
478 // while (NextTbinIndex(it))
479 // printf("%d ", it);