CMS 3D CMS Logo

SiPixelArrayBuffer.h
Go to the documentation of this file.
1 #ifndef RecoLocalTracker_SiPixelClusterizer_SiPixelArrayBuffer_H
2 #define RecoLocalTracker_SiPixelClusterizer_SiPixelArrayBuffer_H
3 
4 //----------------------------------------------------------------------------
17 //----------------------------------------------------------------------------
18 
19 // We use PixelPos which is an inner class of SiPixelCluster:
21 
22 #include <vector>
23 #include <iostream>
24 
25 
26 
28 {
29  public:
30  inline SiPixelArrayBuffer( int rows, int cols);
31  inline SiPixelArrayBuffer( ){}
32 
33  inline void setSize( int rows, int cols);
34  inline int operator()( int row, int col) const;
35  inline int operator()( const SiPixelCluster::PixelPos&) const;
36  inline int rows() const { return nrows;}
37  inline int columns() const { return ncols;}
38 
39  inline bool inside(int row, int col) const;
40  inline void set_adc( int row, int col, int adc);
41  inline void set_adc( const SiPixelCluster::PixelPos&, int adc);
42  inline void add_adc( int row, int col, int adc);
43  int size() const { return pixel_vec.size();}
44 
46  int index( int row, int col) const {return col*nrows+row;}
47  int index( const SiPixelCluster::PixelPos& pix) const { return index(pix.row(), pix.col()); }
48 
49  private:
50  std::vector<int> pixel_vec; // TO DO: any benefit in using shorts instead?
51  int nrows;
52  int ncols;
53 };
54 
55 
56 
58  : pixel_vec(rows*cols,0), nrows(rows), ncols(cols) {}
59 
60 
61 void SiPixelArrayBuffer::setSize( int rows, int cols) {
62  pixel_vec.resize(rows*cols,0);
63  nrows = rows;
64  ncols = cols;
65 }
66 
67 
68 bool SiPixelArrayBuffer::inside(int row, int col) const
69 {
70  return ( row >= 0 && row < nrows && col >= 0 && col < ncols);
71 }
72 
73 
74 int SiPixelArrayBuffer::operator()(int row, int col) const { return pixel_vec[index(row,col)];}
75 
76 
78 
79 // unchecked!
80 void SiPixelArrayBuffer::set_adc( int row, int col, int adc)
81 {
82  pixel_vec[index(row,col)] = adc;
83 }
84 
85 
87 {
88  pixel_vec[index(pix)] = adc;
89 }
90 
91 void SiPixelArrayBuffer::add_adc( int row, int col, int adc)
92 {
93  pixel_vec[index(row,col)] += adc;
94 }
95 
96 #endif
int operator()(int row, int col) const
void set_adc(int row, int col, int adc)
std::vector< int > pixel_vec
void add_adc(int row, int col, int adc)
int index(int row, int col) const
Definition of indexing within the buffer.
constexpr int adc(sample_type sample)
get the ADC sample (12 bits)
int index(const SiPixelCluster::PixelPos &pix) const
constexpr int col() const
bool inside(int row, int col) const
void setSize(int rows, int cols)
col
Definition: cuy.py:1010
constexpr int row() const
Class to store ADC counts during clustering.