]>
Commit | Line | Data |
---|---|---|
f7336fa3 | 1 | /************************************************************************** |
2 | * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. * | |
3 | * * | |
4 | * Author: The ALICE Off-line Project. * | |
5 | * Contributors are mentioned in the code where appropriate. * | |
6 | * * | |
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 | **************************************************************************/ | |
15 | ||
16 | /* | |
17 | $Log$ | |
617e4d8a | 18 | Revision 1.2 2000/05/08 16:17:27 cblume |
19 | Merge TRD-develop | |
20 | ||
6f1e466d | 21 | Revision 1.1.4.1 2000/05/08 15:13:59 cblume |
22 | Introduce boundary checking | |
23 | ||
24 | Revision 1.1 2000/02/28 18:59:19 cblume | |
25 | Add new TRD classes | |
26 | ||
f7336fa3 | 27 | */ |
28 | ||
29 | /////////////////////////////////////////////////////////////////////////////// | |
30 | // // | |
6f1e466d | 31 | // Base class of a general container for data of a TRD detector segment. // |
f7336fa3 | 32 | // Adapted from AliDigits (origin: M.Ivanov). // |
f7336fa3 | 33 | // // |
34 | /////////////////////////////////////////////////////////////////////////////// | |
35 | ||
617e4d8a | 36 | #include <stdlib.h> |
37 | ||
f7336fa3 | 38 | #include "TClass.h" |
39 | #include "TError.h" | |
40 | #include "AliTRDsegmentID.h" | |
41 | #include "AliTRDarrayI.h" | |
42 | #include "AliTRDdataArray.h" | |
43 | ||
44 | ClassImp(AliTRDdataArray) | |
45 | ||
46 | //_____________________________________________________________________________ | |
47 | AliTRDdataArray::AliTRDdataArray() | |
48 | { | |
49 | // | |
50 | // Default constructor | |
51 | // | |
52 | ||
6f1e466d | 53 | fIndex = 0; |
54 | ||
55 | fNdim1 = -1; | |
56 | fNdim2 = -1; | |
57 | fNelems = -1; | |
58 | ||
59 | fBufType = -1; | |
60 | ||
61 | fNrow = 0; | |
62 | fNcol = 0; | |
63 | fNtime = 0; | |
f7336fa3 | 64 | |
65 | } | |
66 | ||
67 | //_____________________________________________________________________________ | |
6f1e466d | 68 | AliTRDdataArray::AliTRDdataArray(Int_t nrow, Int_t ncol, Int_t ntime) |
f7336fa3 | 69 | { |
70 | // | |
6f1e466d | 71 | // Creates a AliTRDdataArray with the dimensions <nrow>, <ncol>, and <ntime>. |
72 | // The row- and column dimensions are compressible. | |
f7336fa3 | 73 | // |
74 | ||
6f1e466d | 75 | Allocate(nrow,ncol,ntime); |
f7336fa3 | 76 | |
6f1e466d | 77 | } |
f7336fa3 | 78 | |
79 | //_____________________________________________________________________________ | |
6f1e466d | 80 | AliTRDdataArray::~AliTRDdataArray() |
81 | { | |
f7336fa3 | 82 | // |
6f1e466d | 83 | // Destructor |
f7336fa3 | 84 | // |
85 | ||
6f1e466d | 86 | if (fIndex) fIndex->Delete(); |
f7336fa3 | 87 | |
f7336fa3 | 88 | } |
89 | ||
90 | //_____________________________________________________________________________ | |
6f1e466d | 91 | void AliTRDdataArray::Allocate(Int_t nrow, Int_t ncol,Int_t ntime) |
f7336fa3 | 92 | { |
93 | // | |
6f1e466d | 94 | // Allocates memory for a AliTRDdataArray with the dimensions |
95 | // <nrow>, <ncol>, and <ntime>. | |
96 | // The row- and column dimensions are compressible. | |
f7336fa3 | 97 | // |
98 | ||
f7336fa3 | 99 | if (nrow <= 0) { |
100 | Error("AliTRDdataArray::Allocate","The number of rows has to be positive"); | |
6f1e466d | 101 | exit(1); |
f7336fa3 | 102 | } |
103 | if (ncol <= 0) { | |
104 | Error("AliTRDdataArray::Allocate","The number of columns has to be positive"); | |
6f1e466d | 105 | exit(1); |
f7336fa3 | 106 | } |
107 | if (ntime <= 0) { | |
108 | Error("AliTRDdataArray::Allocate","The number of timebins has to be positive"); | |
6f1e466d | 109 | exit(1); |
f7336fa3 | 110 | } |
111 | ||
112 | // The two-dimensional array row/column gets mapped into the first | |
113 | // dimension of the array. The second array dimension, which is not compressible, | |
114 | // corresponds to the time direction | |
115 | fNdim1 = nrow * ncol; | |
116 | fNdim2 = ntime; | |
117 | fNelems = fNdim1 * fNdim2; | |
118 | ||
119 | fNrow = nrow; | |
120 | fNcol = ncol; | |
121 | fNtime = ntime; | |
122 | ||
6f1e466d | 123 | if (fIndex) delete fIndex; |
124 | fIndex = new AliTRDarrayI; | |
f7336fa3 | 125 | fIndex->Set(fNdim2); |
f7336fa3 | 126 | for (Int_t i = 0, k = 0; i < fNdim2; i++, k += fNdim1) { |
127 | (*fIndex)[i] = k; | |
128 | } | |
129 | ||
130 | fBufType = 0; | |
131 | ||
132 | } | |
133 | ||
134 | //_____________________________________________________________________________ | |
6f1e466d | 135 | void AliTRDdataArray::Reset() |
136 | { | |
f7336fa3 | 137 | // |
6f1e466d | 138 | // Reset the array (old content gets deleted) |
f7336fa3 | 139 | // |
140 | ||
6f1e466d | 141 | if (fIndex) delete fIndex; |
142 | fIndex = new AliTRDarrayI; | |
143 | fIndex->Set(0); | |
f7336fa3 | 144 | |
6f1e466d | 145 | fNdim1 = -1; |
146 | fNdim2 = -1; | |
147 | fNelems = -1; | |
f7336fa3 | 148 | |
6f1e466d | 149 | fBufType = -1; |
f7336fa3 | 150 | |
6f1e466d | 151 | fNrow = 0; |
152 | fNcol = 0; | |
153 | fNtime = 0; | |
f7336fa3 | 154 | |
155 | } | |
156 | ||
f7336fa3 | 157 |