]> git.uio.no Git - u/mrichter/AliRoot.git/blob - TRD/AliTRDdataArray.cxx
Added #include <stdlib.h>
[u/mrichter/AliRoot.git] / TRD / AliTRDdataArray.cxx
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$
18 Revision 1.2  2000/05/08 16:17:27  cblume
19 Merge TRD-develop
20
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
27 */
28
29 ///////////////////////////////////////////////////////////////////////////////
30 //                                                                           //
31 //  Base class of a general container for data of a TRD detector segment.    //
32 //  Adapted from AliDigits (origin: M.Ivanov).                               //
33 //                                                                           //
34 ///////////////////////////////////////////////////////////////////////////////
35
36 #include <stdlib.h> 
37
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
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;
64
65 }
66
67 //_____________________________________________________________________________
68 AliTRDdataArray::AliTRDdataArray(Int_t nrow, Int_t ncol, Int_t ntime)
69 {
70   //
71   // Creates a AliTRDdataArray with the dimensions <nrow>, <ncol>, and <ntime>.
72   // The row- and column dimensions are compressible.
73   //
74
75   Allocate(nrow,ncol,ntime);
76
77 }
78
79 //_____________________________________________________________________________
80 AliTRDdataArray::~AliTRDdataArray()
81 {
82   //
83   // Destructor
84   //
85
86   if (fIndex) fIndex->Delete();
87   
88 }
89
90 //_____________________________________________________________________________
91 void AliTRDdataArray::Allocate(Int_t nrow, Int_t ncol,Int_t ntime)
92 {
93   //
94   // Allocates memory for a AliTRDdataArray with the dimensions 
95   // <nrow>, <ncol>, and <ntime>.
96   // The row- and column dimensions are compressible.
97   //
98
99   if (nrow  <= 0) {
100     Error("AliTRDdataArray::Allocate","The number of rows has to be positive");
101     exit(1);
102   }
103   if (ncol  <= 0) {
104     Error("AliTRDdataArray::Allocate","The number of columns has to be positive");
105     exit(1);
106   }
107   if (ntime <= 0) {
108     Error("AliTRDdataArray::Allocate","The number of timebins has to be positive");
109     exit(1);
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
123   if (fIndex) delete fIndex;
124   fIndex = new AliTRDarrayI;
125   fIndex->Set(fNdim2);
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 //_____________________________________________________________________________
135 void AliTRDdataArray::Reset() 
136
137   //
138   // Reset the array (old content gets deleted)
139   //
140
141   if (fIndex) delete fIndex;
142   fIndex = new AliTRDarrayI;
143   fIndex->Set(0); 
144
145   fNdim1   = -1;
146   fNdim2   = -1;
147   fNelems  = -1; 
148
149   fBufType = -1;
150
151   fNrow    =  0;
152   fNcol    =  0;
153   fNtime   =  0;
154
155 }
156
157