]> git.uio.no Git - u/mrichter/AliRoot.git/blob - TRD/AliTRDdataArrayF.h
93740e7090ce985a174f926c8cab14b2b713fcef
[u/mrichter/AliRoot.git] / TRD / AliTRDdataArrayF.h
1 #ifndef ALITRDDATAARRAYF_H
2 #define ALITRDDATAARRAYF_H
3
4 /* Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
5  * See cxx source for full Copyright notice                               */
6
7 /* $Id: AliTRDdataArrayF.h,v */
8  
9 #include   "AliTRDdataArray.h"
10
11 /////////////////////////////////////////////////////////////
12 //                                                         //
13 //  General container for float data from TRD detector     //
14 //  segments.                                              //
15 //  Adapted from AliDigits, origin M.Ivanov                //
16 //                                                         //
17 /////////////////////////////////////////////////////////////
18
19 class AliTRDdataArrayF : public AliTRDdataArray {
20
21  public:
22
23   AliTRDdataArrayF();
24   AliTRDdataArrayF(Int_t nrow, Int_t ncol,Int_t ntime);
25   AliTRDdataArrayF(AliTRDdataArrayF &a);
26   virtual ~AliTRDdataArrayF();
27
28   virtual void    Allocate(Int_t nrow, Int_t ncol,Int_t ntime);
29   virtual void    Copy(AliTRDdataArrayF &a);
30   virtual void    Compress(Int_t bufferType, Float_t threshold);
31   virtual void    Compress(Int_t bufferType); 
32   virtual void    Expand();
33   virtual Bool_t  First();
34   virtual Bool_t  Next(); 
35   virtual void    Reset();
36
37   inline  void    SetData(Int_t row, Int_t col, Int_t time, Float_t value);
38   virtual void    SetThreshold(Float_t threshold) { fThreshold = threshold; };
39
40   virtual Float_t GetData(Int_t row, Int_t col, Int_t time);
41   virtual Float_t GetThreshold()                  { return fThreshold;  };
42
43   virtual Int_t   GetSize();
44   virtual Int_t   GetDataSize(); 
45   virtual Int_t   GetOverThreshold(Float_t threshold);  
46
47   inline  AliTRDdataArrayF &operator=(AliTRDdataArrayF &a);
48
49  protected:
50
51   inline  void    SetDataFast(Int_t idx1, Int_t idx2, Float_t value); 
52   inline  Float_t GetDataFast(Int_t idx1, Int_t idx2); 
53
54   Float_t         GetData1(Int_t idx1, Int_t idx2); 
55   void            Expand1(); 
56   void            Compress1(); 
57   void            Expand2();
58   void            Compress2();
59   Bool_t          First0();
60   Bool_t          Next0(); 
61   Bool_t          First1();
62   Bool_t          Next1();
63
64   AliTRDarrayF  *fElements;        // Buffer of 4 bytes floats for the array content
65   Float_t        fThreshold;       // Threshold for zero suppression
66  
67   ClassDef(AliTRDdataArrayF,1)     // Container for float data of one TRD detector segment
68
69 };
70  
71 //____________________________________________________________________________
72 Float_t AliTRDdataArrayF::GetDataFast(Int_t idx1, Int_t idx2)
73 {
74   //
75   // Returns the value at a given position in the array
76   //
77
78   return fElements->At(fIndex->At(idx2) + idx1); 
79
80 }
81
82 //_____________________________________________________________________________
83 void AliTRDdataArrayF::SetData(Int_t row, Int_t col, Int_t time, Float_t value)
84 {
85   //
86   // Sets the data value at a given position of the array
87   // Includes boundary checking
88   //
89
90   if ((row >= 0) && (col >= 0) && (time >= 0)) {
91     Int_t idx1 = GetIdx1(row,col);
92     if ((idx1 >= 0) && (time < fNdim2)) {
93       SetDataFast(idx1,time,value);
94     }
95     else {
96       if (idx1 >= 0) {
97         TObject::Error("SetData"
98                       ,"time %d out of bounds (size: %d, this: 0x%08x)"
99                       ,time,fNdim2,this);
100       }
101     }
102   }
103
104 }
105
106 //_____________________________________________________________________________
107 void  AliTRDdataArrayF::SetDataFast(Int_t idx1, Int_t idx2, Float_t value)
108 {
109   //
110   // Set the value at a given position in the array
111   //
112
113   if ((idx1 < 0) || (idx1 >= fNdim1) || 
114       (idx2 < 0) || (idx2 >= fNdim2)) { 
115     TObject::Error("SetDataFast"
116                   ,"idx1 %d  idx2 %d out of bounds (size: %d x %d, this: 0x%08x)"
117                   ,idx1,idx2,fNdim1,fNdim2,this);
118   }
119
120   (*fElements)[fIndex->fArray[idx2] + idx1] = value; 
121
122 }
123
124 //_____________________________________________________________________________
125 AliTRDdataArrayF &AliTRDdataArrayF::operator=(AliTRDdataArrayF &a)
126 {
127   //
128   // Assignment operator
129   //
130
131   if (this != &a) a.Copy(*this);
132   return *this;
133
134 }
135
136 #endif
137