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