reveng tag added
[u/mrichter/AliRoot.git] / TRD / AliTRDdataArray.h
CommitLineData
8230f242 1#ifndef ALITRDDATAARRAY_H
2#define ALITRDDATAARRAY_H
f7336fa3 3
4/* Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
5 * See cxx source for full Copyright notice */
6
7/* $Id$ */
8
9#include "AliTRDarrayI.h"
6f1e466d 10#include "AliTRDarrayF.h"
f7336fa3 11#include "AliTRDsegmentID.h"
12
13/////////////////////////////////////////////////////////////
14// General container for data from TRD detector segments //
15// Adapted from AliDigits, origin M.Ivanov //
16/////////////////////////////////////////////////////////////
17
18class AliTRDdataArray : public AliTRDsegmentID {
19
20 public:
21
22 AliTRDdataArray();
6f1e466d 23 AliTRDdataArray(Int_t nrow, Int_t ncol,Int_t ntime);
8230f242 24 AliTRDdataArray(AliTRDdataArray &d);
25 virtual ~AliTRDdataArray();
f7336fa3 26
8230f242 27 virtual void Copy(AliTRDdataArray &d);
6f1e466d 28 virtual void Allocate(Int_t nrow, Int_t ncol,Int_t ntime);
29 virtual void Reset();
f7336fa3 30
f7336fa3 31 virtual Int_t GetNRow() { return fNrow; };
32 virtual Int_t GetNCol() { return fNcol; };
33 virtual Int_t GetNtime() { return fNtime; };
34
9d0b222b 35 Int_t GetIndex(Int_t row, Int_t col, Int_t time);
8230f242 36 inline AliTRDdataArray &operator=(AliTRDdataArray &d);
f7336fa3 37
38 protected:
39
9d0b222b 40 Int_t GetIdx1(Int_t row, Int_t col);
f7336fa3 41 inline Bool_t CheckBounds(const char *where, Int_t idx1, Int_t idx2);
42 inline Bool_t OutOfBoundsError(const char *where, Int_t idx1, Int_t idx2);
f7336fa3 43
44 Int_t fNrow; // Number of rows of the detector segement
45 Int_t fNcol; // Number of columns of the detector segment
46 Int_t fNtime; // Number of timebins of the detector segment
47
48 Int_t fNdim1; // First dimension of the array (row * column)
49 Int_t fNdim2; // Second dimension of the array (time, not compressed)
f7336fa3 50
f7336fa3 51 AliTRDarrayI *fIndex; // Index position of column
52 Int_t fBufType; // Type of the buffer - defines the compression algorithm
f7336fa3 53 Int_t fNelems; // Total number of elements
54 Int_t fCurrentIdx1; // !Current index 1
55 Int_t fCurrentIdx2; // !Current index 2
56 Int_t fCurrentIndex; // !Current index in field
57
58 ClassDef(AliTRDdataArray,1) // Data container for one TRD detector segment
59
60};
61
f7336fa3 62//_____________________________________________________________________________
8230f242 63Bool_t AliTRDdataArray::CheckBounds(const char *where, Int_t idx1, Int_t idx2)
f7336fa3 64{
65 //
66 // Does the boundary checking
67 //
68
69 if ((idx2 >= fNdim2) || (idx2 < 0))
70 return OutOfBoundsError(where,idx1,idx2);
71
72 Int_t index = (*fIndex).At(idx2) + idx1;
73 if ((index < 0) || (index > fNelems))
74 return OutOfBoundsError(where,idx1,idx2);
75
76 return kTRUE;
77
78}
79
80//_____________________________________________________________________________
8230f242 81Bool_t AliTRDdataArray::OutOfBoundsError(const char *where, Int_t idx1, Int_t idx2)
f7336fa3 82{
83 //
84 // Generate an out-of-bounds error. Always returns false.
85 //
86
6f1e466d 87 TObject::Error(where, "idx1 %d idx2 %d out of bounds (size: %d x %d, this: 0x%08x)"
88 ,idx1,idx2,fNdim1,fNdim2,this);
f7336fa3 89
90 return kFALSE;
91
92}
93
8230f242 94//_____________________________________________________________________________
95AliTRDdataArray &AliTRDdataArray::operator=(AliTRDdataArray &d)
96{
97 //
98 // Assignment operator
99 //
100
101 if (this != &d) d.Copy(*this);
102 return *this;
103
104}
105
f7336fa3 106#endif
107