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 // Base class of a general container for data of a TRD detector segment. //
21 // Adapted from AliDigits (origin: M.Ivanov). //
23 ///////////////////////////////////////////////////////////////////////////////
32 #include "AliTRDsegmentID.h"
33 #include "AliTRDarrayI.h"
34 #include "AliTRDdataArray.h"
36 ClassImp(AliTRDdataArray)
38 //_____________________________________________________________________________
39 AliTRDdataArray::AliTRDdataArray()
53 // Default constructor
58 //_____________________________________________________________________________
59 AliTRDdataArray::AliTRDdataArray(Int_t nrow, Int_t ncol, Int_t ntime)
73 // Creates a AliTRDdataArray with the dimensions <nrow>, <ncol>, and <ntime>.
74 // The row- and column dimensions are compressible.
77 Allocate(nrow,ncol,ntime);
81 //_____________________________________________________________________________
82 AliTRDdataArray::AliTRDdataArray(const AliTRDdataArray &d)
97 // AliTRDdataArray copy constructor
102 //_____________________________________________________________________________
103 AliTRDdataArray::~AliTRDdataArray()
106 // AliTRDdataArray destructor
116 //_____________________________________________________________________________
117 AliTRDdataArray &AliTRDdataArray::operator=(const AliTRDdataArray &d)
120 // Assignment operator
123 if (this != &d) ((AliTRDdataArray &) d).Copy(*this);
128 //_____________________________________________________________________________
129 void AliTRDdataArray::Copy(TObject &d) const
135 ((AliTRDdataArray &) d).fNrow = fNrow;
136 ((AliTRDdataArray &) d).fNcol = fNcol;
137 ((AliTRDdataArray &) d).fNtime = fNtime;
139 ((AliTRDdataArray &) d).fNdim1 = fNdim1;
140 ((AliTRDdataArray &) d).fNdim2 = fNdim2;
142 ((AliTRDdataArray &) d).fBufType = fBufType;
143 ((AliTRDdataArray &) d).fNelems = fNelems;
145 ((AliTRDdataArray &) d).fCurrentIdx1 = 0;
146 ((AliTRDdataArray &) d).fCurrentIdx2 = 0;
147 ((AliTRDdataArray &) d).fCurrentIndex = 0;
149 fIndex->Copy(*((AliTRDdataArray &) d).fIndex);
153 //_____________________________________________________________________________
154 void AliTRDdataArray::Allocate(Int_t nrow, Int_t ncol, Int_t ntime)
157 // Allocates memory for a AliTRDdataArray with the dimensions
158 // <nrow>, <ncol>, and <ntime>.
159 // The row- and column dimensions are compressible.
163 AliError("The number of rows has to be positive");
167 AliError("The number of columns has to be positive");
171 AliError("The number of timebins has to be positive");
175 // The two-dimensional array row/column gets mapped into the first
176 // dimension of the array. The second array dimension, which is not compressible,
177 // corresponds to the time direction
178 fNdim1 = nrow * ncol;
180 fNelems = fNdim1 * fNdim2;
186 if (fIndex) delete fIndex;
187 fIndex = new AliTRDarrayI();
189 for (Int_t i = 0, k = 0; i < fNdim2; i++, k += fNdim1) {
197 //_____________________________________________________________________________
198 Bool_t AliTRDdataArray::CheckBounds(Int_t idx1, Int_t idx2)
201 // Does the boundary checking
204 if ((idx2 >= fNdim2) ||
206 return OutOfBoundsError(idx1,idx2);
209 Int_t index = (*fIndex).At(idx2) + idx1;
212 return OutOfBoundsError(idx1,idx2);
219 //_____________________________________________________________________________
220 Bool_t AliTRDdataArray::OutOfBoundsError(Int_t idx1, Int_t idx2)
223 // Generate an out-of-bounds error. Always returns false.
226 AliError(Form("idx1 %d idx2 %d out of bounds (size: %d x %d, this: 0x%08x)"
227 ,idx1,idx2,fNdim1,fNdim2,this));
233 //_____________________________________________________________________________
234 void AliTRDdataArray::Reset()
237 // Reset the array (old content gets deleted)
244 fIndex = new AliTRDarrayI();
259 //_____________________________________________________________________________
260 Int_t AliTRDdataArray::GetIdx1(Int_t row, Int_t col) const
263 // Maps the two-dimensional row/column plane into an one-dimensional array.
267 AliError(Form("row %d out of bounds (size: %d, this: 0x%08x)",row,fNrow,this));
272 AliError(Form("col %d out of bounds (size: %d, this: 0x%08x)",col,fNcol,this));
276 return row + col * fNrow;
280 //_____________________________________________________________________________
281 Int_t AliTRDdataArray::GetIndex(Int_t row, Int_t col, Int_t time) const
284 // Maps the row/column/time into one number
288 AliError(Form("time %d out of bounds (size: %d, this: 0x%08x)",time,fNtime,this));
292 return time * fNrow*fNcol + GetIdx1(row,col);