CMS 3D CMS Logo

Phase2ITPixelArrayBuffer.h
Go to the documentation of this file.
1 #ifndef RecoLocalTracker_Phase2ITPixelClusterizer_Phase2ITPixelArrayBuffer_H
2 #define RecoLocalTracker_Phase2ITPixelClusterizer_Phase2ITPixelArrayBuffer_H
3 
4 //----------------------------------------------------------------------------
17 //----------------------------------------------------------------------------
18 
19 // We use PixelPos which is an inner class of Phase2ITPixelCluster:
21 
22 #include <vector>
23 #include <iostream>
24 
25 
26 
28 {
29  public:
30  inline Phase2ITPixelArrayBuffer( int rows, int cols);
32 
33  inline void setSize( int rows, int cols);
34  inline int operator()( int row, int col) const;
35  inline int operator()( const Phase2ITPixelCluster::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 Phase2ITPixelCluster::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 Phase2ITPixelCluster::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 
61  pixel_vec.resize(rows*cols,0);
62  nrows = rows;
63  ncols = cols;
64 }
65 
66 
67 bool Phase2ITPixelArrayBuffer::inside(int row, int col) const
68 {
69  return ( row >= 0 && row < nrows && col >= 0 && col < ncols);
70 }
71 
72 
73 int Phase2ITPixelArrayBuffer::operator()(int row, int col) const { return pixel_vec[index(row,col)];}
74 
75 
77 
78 // unchecked!
79 void Phase2ITPixelArrayBuffer::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)
void setSize(int rows, int cols)
Class to store ADC counts during clustering.
int operator()(int row, int col) const
bool inside(int row, int col) const
int index(int row, int col) const
Definition of indexing within the buffer.
col
Definition: cuy.py:1008
void set_adc(int row, int col, int adc)
int index(const Phase2ITPixelCluster::PixelPos &pix) const