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 
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
hgcalPlots.ncols
ncols
Definition: hgcalPlots.py:105
SiPixelArrayBuffer::inside
bool inside(int row, int col) const
Definition: SiPixelArrayBuffer.h:60
SiPixelArrayBuffer::rows
int rows() const
Definition: SiPixelArrayBuffer.h:33
SiPixelArrayBuffer::set_adc
void set_adc(int row, int col, int adc)
Definition: SiPixelArrayBuffer.h:67
cuy.col
col
Definition: cuy.py:1010
SiPixelCluster.h
SiPixelArrayBuffer::nrows
int nrows
Definition: SiPixelArrayBuffer.h:48
ecalLiteDTU::adc
constexpr int adc(sample_type sample)
get the ADC sample (12 bits)
Definition: EcalLiteDTUSample.h:12
SiPixelArrayBuffer::columns
int columns() const
Definition: SiPixelArrayBuffer.h:34
SiPixelArrayBuffer::ncols
int ncols
Definition: SiPixelArrayBuffer.h:49
SiPixelArrayBuffer::operator()
int operator()(int row, int col) const
Definition: SiPixelArrayBuffer.h:62
SiPixelArrayBuffer::size
int size() const
Definition: SiPixelArrayBuffer.h:40
SiPixelArrayBuffer::pixel_vec
std::vector< int > pixel_vec
Definition: SiPixelArrayBuffer.h:47
SiPixelArrayBuffer::add_adc
void add_adc(int row, int col, int adc)
Definition: SiPixelArrayBuffer.h:71
SiPixelArrayBuffer::index
int index(const SiPixelCluster::PixelPos &pix) const
Definition: SiPixelArrayBuffer.h:44
SiPixelArrayBuffer::index
int index(int row, int col) const
Definition of indexing within the buffer.
Definition: SiPixelArrayBuffer.h:43
SiPixelArrayBuffer::SiPixelArrayBuffer
SiPixelArrayBuffer()
Definition: SiPixelArrayBuffer.h:28
SiPixelCluster::PixelPos::row
constexpr int row() const
Definition: SiPixelCluster.h:56
SiPixelArrayBuffer
Class to store ADC counts during clustering.
Definition: SiPixelArrayBuffer.h:25
SiPixelArrayBuffer::setSize
void setSize(int rows, int cols)
Definition: SiPixelArrayBuffer.h:54
SiPixelCluster::PixelPos
Definition: SiPixelCluster.h:52
postprocess-scan-build.rows
rows
Definition: postprocess-scan-build.py:11
SiPixelCluster::PixelPos::col
constexpr int col() const
Definition: SiPixelCluster.h:57