]> git.uio.no Git - u/mrichter/AliRoot.git/blame - TPC/AliDigits.h
Speedup the code
[u/mrichter/AliRoot.git] / TPC / AliDigits.h
CommitLineData
a46e9031 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
e756ece8 13#include <TArrayI.h>
14#include <TArrayS.h>
a46e9031 15#include "AliSegmentID.h"
16class AliH2F;
17
18class AliDigits: public AliSegmentID{
19public:
20 AliDigits();
21 AliDigits(const AliDigits &digits); //copy constructor
22 AliDigits &operator = (const AliDigits & digits); //assignment operator
23 virtual ~AliDigits();
51a4705b 24 Short_t * GetDigits(){return fElements->GetArray();} //return row pointer to the array digits
a46e9031 25 Short_t GetDigitFast(Int_t row, Int_t column); //return value at given row and collumn
d06e80ef 26 Short_t GetDigitUnchecked(Int_t row, Int_t column); //return value at given row and collumn
a46e9031 27 void SetDigitFast(Short_t value,Int_t row, Int_t column); //set value at given row and collumn
28 Bool_t BoundsOK(const char *where, Int_t row, Int_t col) ; //Check If Bound Ok
29 Bool_t OutOfBoundsError(const char *where, Int_t row, Int_t column);
30 virtual void Allocate(Int_t rows, Int_t columns); //construct empty buffer fDigits with size rows x columns
31 virtual Short_t GetDigit(Int_t row, Int_t column);
32 virtual void ExpandBuffer(); //expand buffer to twodimensional array
33 virtual void CompresBuffer(Int_t bufferType,Int_t threshold); //compres buffer according buffertype algorithm
34 virtual Bool_t First(); //adjust first valid current digit
35 virtual Bool_t Next(); //addjust next valid current digit
36 void SetThreshold(Int_t th) {fThreshold = th;} //set threshold
37 Int_t GetThreshold() {return fThreshold;} //return threshold
38 Int_t GetNRows(){return fNrows;}
39 Int_t GetNCols(){return fNcols;}
40 Int_t CurrentRow(){ return fCurrentRow;} //return current row
41 Int_t CurrentColumn(){ return fCurrentCol;} //return current column
42 Int_t CurrentDigit() {return fElements->At(fCurrentIndex);} //return degit for current row and column
43 void AcceptHisto(AliH2F * his); //update buffer for - it will content histogram values
44 AliH2F * GenerHisto(); //generate 2 dimensional histogram with digits
45 AliH2F *DrawDigits( const char *option=0,Float_t x1=-1, Float_t x2=-1, Float_t y1=-1, Float_t y2=-1); //draw digits
46
47 Int_t GetSize();//return total size of object in bytes
48 Int_t GetDigitSize(); //return total size of pure digits
49 Int_t GetOverTh(Float_t threshold,Float_t x1=-1, Float_t x2=-1, Float_t y1=-1, Float_t y2=-1); //return number of digits over threshold
50protected:
51 virtual void Invalidate();
52 void ExpandBuffer1(); //expand buffer of type to twodimensional array
53 void CompresBuffer1(); //compres buffer according algorithm 1
54 Bool_t First0(); //first for the buffer type 0
55 Bool_t Next0(); //next for the buffer type 0
56 Bool_t First1(); //first for the buffer type 1
57 Bool_t Next1();//next for the buffer type 1
58 Short_t GetDigit1(Int_t row, Int_t column); //return digit for given row and column
59
60 Int_t fNrows; //number of rows in Segment
61 Int_t fNcols; //number of collumns in Segment
62private:
e756ece8 63 TArrayS *fElements; //buffer of 2 bytes integers for digits
64 TArrayI *fIndex; //index position of column
a46e9031 65 Int_t fBufType; //type of the buffer - define compression algorithm
66 Int_t fThreshold; //treshold for zero suppresion
67 Int_t fNelems; //total number of elements
68 Int_t fCurrentRow; //!current row iteration
69 Int_t fCurrentCol; //!current column iteration
70 Int_t fCurrentIndex; //!current index in field
71
e756ece8 72 ClassDef(AliDigits,2)
a46e9031 73};
74
75
76
77inline Bool_t AliDigits::BoundsOK(const char *where, Int_t row, Int_t col)
78{
79 //Check If Bound Ok
80 if ( (col>=fNcols) || (col<0) ) return OutOfBoundsError(where,row,col);
81 Int_t index =(*fIndex).At(col)+row;
82 if ( (index<0) || (index>fNelems)) return OutOfBoundsError(where,row,col);
83 return kTRUE;
84}
85
86inline Short_t AliDigits::GetDigitFast(Int_t row, Int_t column)
87{
88 //
89 //return digit from fDigits array
90 //if out of range return dummy value ( value at row = 0, collumn = 0)
91 //
92 return fElements->At(fIndex->At(column)+row);
93}
94
d06e80ef 95inline Short_t AliDigits::GetDigitUnchecked(Int_t row, Int_t column)
96{
97 //
98 //return digit from fDigits array
99 //if out of range return dummy value ( value at row = 0, collumn = 0)
100 //
101 return fElements->fArray[fIndex->fArray[column]+row];
102}
103
a46e9031 104inline void AliDigits::SetDigitFast(Short_t value, Int_t row, Int_t column)
105{
106 //
107 //set digit
108 //
51a4705b 109 if ( (row<0) || (row>=fNrows) || (column<0) || (column>=fNcols) )
a46e9031 110 Error("AliDigits::SetDigitFast", "row %d col %d out of bounds (size: %d x %d, this: 0x%08x)",
111 row, column, fNrows, fNcols, this);
112 (*fElements)[fIndex->At(column)+row]=value;
113}
114
115#endif
116