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 ///////////////////////////////////////////////////////////////////////////////
31 #include "AliTRDSignalIndex.h"
33 ClassImp(AliTRDSignalIndex)
35 //_____________________________________________________________________________
36 AliTRDSignalIndex::AliTRDSignalIndex()
47 ,fSortedWasInit(kFALSE)
63 //_____________________________________________________________________________
64 AliTRDSignalIndex::AliTRDSignalIndex(Int_t nrow, Int_t ncol,Int_t ntime)
75 ,fSortedWasInit(kFALSE)
84 // Not the default contructor... hmmm...
87 Allocate(nrow, ncol, ntime);
91 //_____________________________________________________________________________
92 AliTRDSignalIndex::AliTRDSignalIndex(const AliTRDSignalIndex &a)
100 ,fMaxLimit(a.fMaxLimit)
101 ,fPositionRC(a.fPositionRC)
102 ,fCountRC(a.fCountRC)
103 ,fSortedWasInit(a.fSortedWasInit)
104 ,fCurrRow(a.fCurrRow)
105 ,fCurrCol(a.fCurrCol)
106 ,fCurrTbin(a.fCurrTbin)
115 fBoolIndex = new Bool_t[fMaxLimit];
116 memcpy(fBoolIndex, a.fBoolIndex, fMaxLimit*sizeof(Bool_t));
118 fSortedIndex = new RowCol[fMaxLimit+1];
119 memcpy(fSortedIndex, a.fSortedIndex, (fMaxLimit+1)*sizeof(RowCol));
122 //_____________________________________________________________________________
123 AliTRDSignalIndex::~AliTRDSignalIndex()
130 delete [] fBoolIndex;
135 delete [] fSortedIndex;
141 //_____________________________________________________________________________
142 void AliTRDSignalIndex::Copy(TObject &a) const
148 ((AliTRDSignalIndex &)a).fDet = fDet;
149 ((AliTRDSignalIndex &)a).fLayer = fLayer;
150 ((AliTRDSignalIndex &)a).fStack = fStack;
151 ((AliTRDSignalIndex &)a).fSM = fSM;
152 ((AliTRDSignalIndex &)a).fMaxLimit = fMaxLimit;
153 ((AliTRDSignalIndex &)a).fPositionRC = fPositionRC;
154 ((AliTRDSignalIndex &)a).fCountRC = fCountRC;
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;
163 if(((AliTRDSignalIndex &)a).fBoolIndex)
165 delete [] ((AliTRDSignalIndex &)a).fBoolIndex;
167 ((AliTRDSignalIndex &)a).fBoolIndex = new Bool_t[fMaxLimit];
168 memcpy(((AliTRDSignalIndex &)a).fBoolIndex, fBoolIndex, fMaxLimit*sizeof(Bool_t));
170 if(((AliTRDSignalIndex &)a).fSortedIndex)
172 delete [] ((AliTRDSignalIndex &)a).fSortedIndex;
174 ((AliTRDSignalIndex &)a).fSortedIndex = new RowCol[fMaxLimit+1];
175 memcpy(((AliTRDSignalIndex &)a).fSortedIndex, fSortedIndex, (fMaxLimit+1)*sizeof(RowCol));
179 //_____________________________________________________________________________
180 AliTRDSignalIndex& AliTRDSignalIndex::operator = (const AliTRDSignalIndex& a)
183 // Assignment operator
186 if (this != &a) ((AliTRDSignalIndex &) a).Copy(*this);
191 //_____________________________________________________________________________
192 void AliTRDSignalIndex::Allocate(const Int_t nrow, const Int_t ncol, const Int_t ntime)
202 fMaxLimit = nrow * ncol + 1;
205 delete [] fBoolIndex;
209 delete [] fSortedIndex;
213 fBoolIndex = new Bool_t[fMaxLimit];
214 fSortedIndex = new RowCol[fMaxLimit+1];
216 fCountRC = fMaxLimit+1;
225 //_____________________________________________________________________________
226 void AliTRDSignalIndex::ResetArrays()
228 memset(fBoolIndex,0x00,sizeof(Bool_t)*fMaxLimit);
229 memset(fSortedIndex,0xFF,sizeof(RowCol)*fCountRC);
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
269 //_____________________________________________________________________________
270 void AliTRDSignalIndex::ResetContentConditional(const Int_t nrow, const Int_t ncol, const Int_t ntime)
273 // Reset the array but keep the size if no need to enlarge - no realloc
281 if ((nrow > fNrows) ||
284 Allocate(nrow, ncol, ntime);
294 //_____________________________________________________________________________
295 void AliTRDSignalIndex::ClearAll()
298 // Reset the values - clear all!
311 delete [] fBoolIndex;
316 delete [] fSortedIndex;
323 fSortedWasInit = kFALSE;
328 //_____________________________________________________________________________
329 Bool_t AliTRDSignalIndex::CheckSorting(Int_t &row, Int_t &col)
332 // Check whether array was read to end or it was not sorted until now
335 if(fSortedWasInit || fCountRC==1)
336 { //we already reached the end of the array
343 { //we have not sorted the array up to now, let's do so
345 return NextRCIndex(row, col);
349 //_____________________________________________________________________________
350 Bool_t AliTRDSignalIndex::NextRCTbinIndex(Int_t &row, Int_t &col, Int_t &tbin)
353 // Returns the next tbin, or if there is no next time bin, it returns the
354 // next used RC combination.
357 if (NextTbinIndex(tbin)) {
363 if (NextRCIndex(row, col)) {
364 return NextRCTbinIndex(row, col, tbin);
372 //_____________________________________________________________________________
373 Bool_t AliTRDSignalIndex::NextTbinIndex(Int_t &tbin)
376 // Returns the next tbin of the current RC combination
379 if(fCurrTbin<fNtbins)
389 //_____________________________________________________________________________
390 void AliTRDSignalIndex::InitSortedIndex()
393 // Creates the SortedIndex
396 fSortedWasInit = kTRUE;
397 std::sort((UShort_t*)fSortedIndex, ((UShort_t*)fSortedIndex) + fCountRC);
401 //_____________________________________________________________________________
402 void AliTRDSignalIndex::ResetCounters()
405 // Reset the counters/iterators