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 Revision 1.4 2000/06/07 16:27:01 cblume
19 Try to remove compiler warnings on Sun and HP
21 Revision 1.3 2000/05/18 07:56:44 cblume
22 Added #include <stdlib.h>
24 Revision 1.2 2000/05/08 16:17:27 cblume
27 Revision 1.1.4.1 2000/05/08 15:13:59 cblume
28 Introduce boundary checking
30 Revision 1.1 2000/02/28 18:59:19 cblume
35 ///////////////////////////////////////////////////////////////////////////////
37 // Base class of a general container for data of a TRD detector segment. //
38 // Adapted from AliDigits (origin: M.Ivanov). //
40 ///////////////////////////////////////////////////////////////////////////////
46 #include "AliTRDsegmentID.h"
47 #include "AliTRDarrayI.h"
48 #include "AliTRDdataArray.h"
50 ClassImp(AliTRDdataArray)
52 //_____________________________________________________________________________
53 AliTRDdataArray::AliTRDdataArray()
56 // Default constructor
73 //_____________________________________________________________________________
74 AliTRDdataArray::AliTRDdataArray(Int_t nrow, Int_t ncol, Int_t ntime)
77 // Creates a AliTRDdataArray with the dimensions <nrow>, <ncol>, and <ntime>.
78 // The row- and column dimensions are compressible.
81 Allocate(nrow,ncol,ntime);
85 //_____________________________________________________________________________
86 AliTRDdataArray::AliTRDdataArray(AliTRDdataArray &d)
89 // AliTRDdataArray copy constructor
96 //_____________________________________________________________________________
97 AliTRDdataArray::~AliTRDdataArray()
100 // AliTRDdataArray destructor
103 if (fIndex) fIndex->Delete();
107 //_____________________________________________________________________________
108 void AliTRDdataArray::Copy(AliTRDdataArray &d)
121 d.fBufType = fBufType;
128 fIndex->Copy(*d.fIndex);
132 //_____________________________________________________________________________
133 void AliTRDdataArray::Allocate(Int_t nrow, Int_t ncol,Int_t ntime)
136 // Allocates memory for a AliTRDdataArray with the dimensions
137 // <nrow>, <ncol>, and <ntime>.
138 // The row- and column dimensions are compressible.
142 Error("AliTRDdataArray::Allocate","The number of rows has to be positive");
146 Error("AliTRDdataArray::Allocate","The number of columns has to be positive");
150 Error("AliTRDdataArray::Allocate","The number of timebins has to be positive");
154 // The two-dimensional array row/column gets mapped into the first
155 // dimension of the array. The second array dimension, which is not compressible,
156 // corresponds to the time direction
157 fNdim1 = nrow * ncol;
159 fNelems = fNdim1 * fNdim2;
165 if (fIndex) delete fIndex;
166 fIndex = new AliTRDarrayI;
168 for (Int_t i = 0, k = 0; i < fNdim2; i++, k += fNdim1) {
176 //_____________________________________________________________________________
177 void AliTRDdataArray::Reset()
180 // Reset the array (old content gets deleted)
183 if (fIndex) delete fIndex;
184 fIndex = new AliTRDarrayI;
199 //_____________________________________________________________________________
200 Int_t AliTRDdataArray::GetIdx1(Int_t row, Int_t col)
203 // Maps the two-dimensional row/column plane into an one-dimensional array.
207 TObject::Error("GetIdx1"
208 ,"row %d out of bounds (size: %d, this: 0x%08x)"
214 TObject::Error("GetIdx1"
215 ,"col %d out of bounds (size: %d, this: 0x%08x)"
220 return row + col * fNrow;
224 //_____________________________________________________________________________
225 Int_t AliTRDdataArray::GetIndex(Int_t row, Int_t col, Int_t time)
228 // Maps the row/column/time into one number
232 TObject::Error("GetIdx1"
233 ,"time %d out of bounds (size: %d, this: 0x%08x)"
238 return time * fNrow*fNcol + GetIdx1(row,col);