CMS 3D CMS Logo

All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Modules 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 
26 public:
27  inline SiPixelArrayBuffer(int rows, int cols);
28  inline SiPixelArrayBuffer() {}
29 
30  inline void setSize(int rows, int cols);
31  inline int operator()(int row, int col) const;
32  inline int operator()(const SiPixelCluster::PixelPos&) const;
33  inline int rows() const { return nrows; }
34  inline int columns() const { return ncols; }
35 
36  inline bool inside(int row, int col) const;
37  inline void set_adc(int row, int col, int adc);
38  inline void set_adc(const SiPixelCluster::PixelPos&, int adc);
39  inline void add_adc(int row, int col, int adc);
40  int size() const { return pixel_vec.size(); }
41 
43  int index(int row, int col) const { return col * nrows + row; }
44  int index(const SiPixelCluster::PixelPos& pix) const { return index(pix.row(), pix.col()); }
45 
46 private:
47  std::vector<int> pixel_vec; // TO DO: any benefit in using shorts instead?
48  int nrows;
49  int ncols;
50 };
51 
52 SiPixelArrayBuffer::SiPixelArrayBuffer(int rows, int cols) : pixel_vec(rows * cols, 0), nrows(rows), ncols(cols) {}
53 
54 void SiPixelArrayBuffer::setSize(int rows, int cols) {
55  pixel_vec.resize(rows * cols, 0);
56  nrows = rows;
57  ncols = cols;
58 }
59 
60 bool SiPixelArrayBuffer::inside(int row, int col) const { return (row >= 0 && row < nrows && col >= 0 && col < ncols); }
61 
62 int SiPixelArrayBuffer::operator()(int row, int col) const { return pixel_vec[index(row, col)]; }
63 
65 
66 // unchecked!
67 void SiPixelArrayBuffer::set_adc(int row, int col, int adc) { pixel_vec[index(row, col)] = adc; }
68 
70 
71 void SiPixelArrayBuffer::add_adc(int row, int col, int adc) { pixel_vec[index(row, col)] += adc; }
72 
73 #endif
bool inside(int row, int col) const
void set_adc(int row, int col, int adc)
int operator()(int row, int col) const
std::vector< int > pixel_vec
void add_adc(int row, int col, int adc)
int index(const SiPixelCluster::PixelPos &pix) const
int index(int row, int col) const
Definition of indexing within the buffer.
void setSize(int rows, int cols)
col
Definition: cuy.py:1009
constexpr int row() const
constexpr int col() const
rows
Definition: mysort.py:12
uint16_t *__restrict__ uint16_t const *__restrict__ adc
Class to store ADC counts during clustering.