]> git.uio.no Git - u/mrichter/AliRoot.git/blob - TPC/AliDigits.h
NodeName array dimension enlarged
[u/mrichter/AliRoot.git] / TPC / AliDigits.h
1 #ifndef ALIDIGITS_H
2 #define ALIDIGITS_H
3 /* Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
4  * See cxx source for full Copyright notice                               */
5
6 /* $Id$ */
7
8 ////////////////////////////////////////////////
9 //  Manager class generaol Alice segment digits
10 //  segment is for example one pad row in TPC //
11 ////////////////////////////////////////////////
12
13 #include   "AliArrayI.h"
14 #include   "AliArrayS.h"
15 #include   "AliSegmentID.h"
16 class AliH2F;
17
18 class AliDigits: public AliSegmentID{ 
19 public:
20   AliDigits();
21   ~AliDigits();
22   inline Short_t GetDigitFast(Int_t row, Int_t column);  //return value at given row and collumn
23   inline void  SetDigitFast(Short_t value,Int_t row, Int_t column);  //set value at given row and collumn
24   inline Bool_t BoundsOK(const char *where, Int_t row, Int_t col) ;  //Check If Bound Ok
25   Bool_t OutOfBoundsError(const char *where, Int_t row, Int_t column);
26   virtual void Allocate(Int_t rows, Int_t columns);  //construct empty buffer fDigits with size rows x columns
27   virtual Short_t GetDigit(Int_t row, Int_t column);
28   virtual void ExpandBuffer();  //expand buffer to twodimensional array
29   virtual void CompresBuffer(Int_t bufferType,Int_t threshold); //compres buffer according buffertype algorithm   
30   virtual Bool_t First(); //adjust  first valid current digit
31   virtual Bool_t Next();  //addjust next valid current digit
32   void SetThreshold(Int_t th) {fThreshold = th;}
33   Int_t  GetThreshold() {return fThreshold;}
34   Int_t CurrentRow(){ return fCurrentRow;}  //return current row
35   Int_t CurrentColumn(){ return fCurrentCol;} //return current column
36   Int_t CurrentDigit() {return fElements->At(fCurrentIndex);} //return degit for current row and column
37   void AcceptHisto(AliH2F * his);  //update buffer for - it will content histogram values
38   AliH2F * GenerHisto();           //generate 2 dimensional histogram with digits
39   AliH2F *  Draw( const char *option=0,Float_t x1=-1, Float_t x2=-1, Float_t y1=-1, Float_t y2=-1); //draw digits
40   Int_t GetSize() {return fNelems;} //return main buffer size
41 protected:
42   virtual  void Invalidate();  
43   void ExpandBuffer1(); //expand buffer of type to twodimensional array
44   void CompresBuffer1(); //compres buffer according  algorithm 1
45   Bool_t First0();  //first for the buffer type 0
46   Bool_t Next0();  //next for the buffer type 0
47   Bool_t First1(); //first for the buffer type 1
48   Bool_t Next1();//next for the buffer type 1
49   Short_t  GetDigit1(Int_t row, Int_t column); //return digit for given row and column
50  
51   Int_t     fNrows;   //number of rows in Segment
52   Int_t     fNcols; //number of collumns in Segment 
53 private:
54   AliArrayS *fElements;  //buffer of 2 bytes integers for digits
55   AliArrayI *fIndex;  //index position of column
56   Int_t     fBufType; //type of the buffer - define compression algorithm  
57   Int_t     fThreshold; //treshold for zero suppresion
58   Int_t     fNelems;  //total number of elements 
59   Int_t fCurrentRow;   //!current row  iteration
60   Int_t fCurrentCol;   //!current column iteration
61   Int_t fCurrentIndex; //!current index in field
62  
63   ClassDef(AliDigits,1) 
64 };
65  
66
67
68 inline Bool_t AliDigits::BoundsOK(const char *where, Int_t row, Int_t col) 
69 {
70   //Check If Bound Ok
71   if ( (col>=fNcols) || (col<0) ) return OutOfBoundsError(where,row,col);
72   Int_t index =(*fIndex).At(col)+row;
73   if ( (index<0) || (index>fNelems)) return OutOfBoundsError(where,row,col);
74   return kTRUE;  
75 }
76
77 Short_t AliDigits::GetDigitFast(Int_t row, Int_t column)
78 {
79   //
80   //return digit from  fDigits array
81   //if out of range return dummy value  ( value at row = 0, collumn = 0)
82   //
83   return fElements->At(fIndex->At(column)+row); 
84 }
85
86 void  AliDigits::SetDigitFast(Short_t value, Int_t row, Int_t column)
87 {
88   //
89   //set  digit 
90   //
91   if ( (row<0) || (row>=fNrows)  || (column<0) || (column>=fNrows) ) 
92        ::Error("AliDigits::SetDigitFast", "row %d  col %d out of bounds (size: %d x %d, this: 0x%08x)", 
93            row, column, fNrows, fNcols, this);
94   (*fElements)[fIndex->At(column)+row]=value; 
95 }
96
97 #endif
98