CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
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  int size() const { return pixel_vec.size();}
43 
45  int index( int row, int col) const {return col*nrows+row;}
46  int index( const SiPixelCluster::PixelPos& pix) const { return index(pix.row(), pix.col()); }
47 
48  private:
49  std::vector<int> pixel_vec; // TO DO: any benefit in using shorts instead?
50  int nrows;
51  int ncols;
52 };
53 
54 
55 
57  : pixel_vec(rows*cols,0), nrows(rows), ncols(cols) {}
58 
59 
60 void SiPixelArrayBuffer::setSize( int rows, int cols) {
61  pixel_vec.resize(rows*cols,0);
62  nrows = rows;
63  ncols = cols;
64 }
65 
66 
67 bool SiPixelArrayBuffer::inside(int row, int col) const
68 {
69  return ( row >= 0 && row < nrows && col >= 0 && col < ncols);
70 }
71 
72 
73 int SiPixelArrayBuffer::operator()(int row, int col) const { return pixel_vec[index(row,col)];}
74 
75 
77 
78 // unchecked!
79 void SiPixelArrayBuffer::set_adc( int row, int col, int adc)
80 {
81  pixel_vec[index(row,col)] = adc;
82 }
83 
84 
86 {
87  pixel_vec[index(pix)] = adc;
88 }
89 
90 
91 #endif
int adc(sample_type sample)
get the ADC sample (12 bits)
int operator()(int row, int col) const
void set_adc(int row, int col, int adc)
std::vector< int > pixel_vec
int index(int row, int col) const
Definition of indexing within the buffer.
int index(const SiPixelCluster::PixelPos &pix) const
constexpr int col() const
bool inside(int row, int col) const
void setSize(int rows, int cols)
int col
Definition: cuy.py:1008
constexpr int row() const
Class to store ADC counts during clustering.