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()
47 ,fSortedWasInit(kFALSE)
64 //_____________________________________________________________________________
65 AliTRDSignalIndex::AliTRDSignalIndex(Int_t nrow, Int_t ncol,Int_t ntime)
75 ,fSortedWasInit(kFALSE)
85 // Not the default contructor... hmmm...
88 Allocate(nrow, ncol, ntime);
92 //_____________________________________________________________________________
93 AliTRDSignalIndex::AliTRDSignalIndex(const AliTRDSignalIndex &a)
101 ,fMaxLimit(a.fMaxLimit)
102 ,fPositionRC(a.fPositionRC)
103 ,fSortedWasInit(a.fSortedWasInit)
104 ,fCurrRow(a.fCurrRow)
105 ,fCurrCol(a.fCurrCol)
106 ,fCurrTbin(a.fCurrTbin)
110 ,fHasEntry(a.fHasEntry)
116 fBoolIndex = new Bool_t[fMaxLimit];
117 memcpy(fBoolIndex, a.fBoolIndex, fMaxLimit*sizeof(Bool_t));
119 fSortedIndex = new Short_t[2*fMaxLimit];
120 memcpy(fSortedIndex, a.fSortedIndex, 2*fMaxLimit*sizeof(Short_t));
123 //_____________________________________________________________________________
124 AliTRDSignalIndex::~AliTRDSignalIndex()
131 delete [] fBoolIndex;
136 delete [] fSortedIndex;
142 //_____________________________________________________________________________
143 void AliTRDSignalIndex::Copy(TObject &a) const
149 ((AliTRDSignalIndex &)a).fDet = fDet;
150 ((AliTRDSignalIndex &)a).fLayer = fLayer;
151 ((AliTRDSignalIndex &)a).fStack = fStack;
152 ((AliTRDSignalIndex &)a).fSM = fSM;
153 ((AliTRDSignalIndex &)a).fMaxLimit = fMaxLimit;
154 ((AliTRDSignalIndex &)a).fPositionRC = fPositionRC;
155 ((AliTRDSignalIndex &)a).fSortedWasInit = fSortedWasInit;
156 ((AliTRDSignalIndex &)a).fCurrRow = fCurrRow;
157 ((AliTRDSignalIndex &)a).fCurrCol = fCurrCol;
158 ((AliTRDSignalIndex &)a).fCurrTbin = fCurrTbin;
159 ((AliTRDSignalIndex &)a).fNrows = fNrows;
160 ((AliTRDSignalIndex &)a).fNcols = fNcols;
161 ((AliTRDSignalIndex &)a).fNtbins = fNtbins;
162 ((AliTRDSignalIndex &)a).fHasEntry = fHasEntry;
164 if(((AliTRDSignalIndex &)a).fBoolIndex)
166 delete [] ((AliTRDSignalIndex &)a).fBoolIndex;
168 ((AliTRDSignalIndex &)a).fBoolIndex = new Bool_t[fMaxLimit];
169 memcpy(((AliTRDSignalIndex &)a).fBoolIndex, fBoolIndex, fMaxLimit*sizeof(Bool_t));
171 if(((AliTRDSignalIndex &)a).fSortedIndex)
173 delete [] ((AliTRDSignalIndex &)a).fSortedIndex;
175 ((AliTRDSignalIndex &)a).fSortedIndex = new Short_t[2*fMaxLimit];
176 memcpy(((AliTRDSignalIndex &)a).fSortedIndex, fSortedIndex, 2*fMaxLimit*sizeof(Short_t));
180 //_____________________________________________________________________________
181 AliTRDSignalIndex& AliTRDSignalIndex::operator = (const AliTRDSignalIndex& a)
184 // Assignment operator
187 if (this != &a) ((AliTRDSignalIndex &) a).Copy(*this);
192 //_____________________________________________________________________________
193 void AliTRDSignalIndex::Allocate(const Int_t nrow, const Int_t ncol, const Int_t ntime)
203 fMaxLimit = nrow * ncol + 1;
206 delete [] fBoolIndex;
210 delete [] fSortedIndex;
214 fBoolIndex = new Bool_t[fMaxLimit];
215 fSortedIndex = new Short_t[2*fMaxLimit];
225 //_____________________________________________________________________________
226 void AliTRDSignalIndex::ResetArrays()
228 memset(fBoolIndex,0x00,sizeof(Bool_t)*fMaxLimit);
229 memset(fSortedIndex,0xFF,2*sizeof(Short_t)*fMaxLimit);
230 fSortedWasInit = kFALSE;
233 //_____________________________________________________________________________
234 void AliTRDSignalIndex::Reset()
237 // Reset the array but keep the size - realloc
246 Allocate(fNrows, fNcols, fNtbins);
250 //_____________________________________________________________________________
251 void AliTRDSignalIndex::ResetContent()
254 // Reset the array but keep the size - no realloc
264 //_____________________________________________________________________________
265 void AliTRDSignalIndex::ResetContentConditional(const Int_t nrow, const Int_t ncol, const Int_t ntime)
268 // Reset the array but keep the size if no need to enlarge - no realloc
276 if ((nrow > fNrows) ||
279 Allocate(nrow, ncol, ntime);
289 //_____________________________________________________________________________
290 void AliTRDSignalIndex::ClearAll()
293 // Reset the values - clear all!
306 delete [] fBoolIndex;
311 delete [] fSortedIndex;
318 fSortedWasInit = kFALSE;
323 //_____________________________________________________________________________
324 void AliTRDSignalIndex::AddIndexTBin(Int_t row, Int_t col, Int_t /*tbin*/)
327 // This function is now obsolate, it will be deleted in future.
329 // Store the index row-column-tbin as an interesting one
330 // The RC index is updated to!!!
331 // This is to be used in the TRD clusterizer!
334 AddIndexRC(row, col);
338 //_____________________________________________________________________________
339 void AliTRDSignalIndex::AddIndexRC(const Int_t row, const Int_t col)
342 // Store the index row-column as an interesting one
343 // The RC index is updated to!!!
344 // This is to be used in the TRD clusterizer!
347 if (row * col + 1 >= fMaxLimit) {
348 AliError(Form("Out-of-limits row * col %d. Limit is: %d"
354 fBoolIndex[row*fNcols+col]=kTRUE;
360 //_____________________________________________________________________________
361 Bool_t AliTRDSignalIndex::NextRCIndex(Int_t &row, Int_t &col)
364 // Returns next used RC combination
367 if(fSortedIndex[fPositionRC]>-1){
368 row = fCurrRow = fSortedIndex[fPositionRC];
370 col = fCurrCol = fSortedIndex[fPositionRC];
375 if(fSortedWasInit || !fHasEntry)
385 return NextRCIndex(row, col);
391 //_____________________________________________________________________________
392 Bool_t AliTRDSignalIndex::NextRCTbinIndex(Int_t &row, Int_t &col, Int_t &tbin)
395 // Returns the next tbin, or if there is no next time bin, it returns the
396 // next used RC combination.
399 if (NextTbinIndex(tbin)) {
405 if (NextRCIndex(row, col)) {
406 return NextRCTbinIndex(row, col, tbin);
414 //_____________________________________________________________________________
415 Bool_t AliTRDSignalIndex::NextTbinIndex(Int_t &tbin)
418 // Returns the next tbin of the current RC combination
421 if(fCurrTbin<fNtbins)
431 //_____________________________________________________________________________
432 void AliTRDSignalIndex::InitSortedIndex()
435 // Creates the SortedIndex
438 fSortedWasInit = kTRUE;
440 for(int row = 0; row < fNrows; row++)
441 for(int col = 0; col < fNcols; col++)
442 if(IsBoolIndex(row, col)){
443 fSortedIndex[pos] = row;
445 fSortedIndex[pos] = col;
450 //_____________________________________________________________________________
451 void AliTRDSignalIndex::ResetCounters()
454 // Reset the counters/iterators