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  int nrows;
50  int ncols;
51  std::vector<int> pixel_vec; // TO DO: any benefit in using shorts instead?
52 };
53 
54 
55 
57  : nrows(rows), ncols(cols)
58 {
59  pixel_vec.resize(rows*cols);
60 
61  // TO DO: check this now:
62  // Some STL implementations have problems with default values
63  // so a initialization loop is used instead
64  std::vector<int>::iterator i=pixel_vec.begin(), iend=pixel_vec.end();
65  for ( ; i!=iend; ++i) {
66  *i = 0;
67  }
68 }
69 
70 
71 void SiPixelArrayBuffer::setSize( int rows, int cols)
72 {
73  nrows = rows;
74  ncols = cols;
75  pixel_vec.resize(rows*cols);
76  //std::cout << " Resize the clusterize pixel buffer " << (rows*cols)
77  // << std::endl;
78 
79  // TO DO: check this now:
80  // Some STL implementations have problems with default values
81  // so a initialization loop is used instead
82  std::vector<int>::iterator i=pixel_vec.begin(), iend=pixel_vec.end();
83  for ( ; i!=iend; ++i) {
84  *i = 0;
85  }
86 }
87 
88 
89 bool SiPixelArrayBuffer::inside(int row, int col) const
90 {
91  return ( row >= 0 && row < nrows && col >= 0 && col < ncols);
92 }
93 
94 
95 int SiPixelArrayBuffer::operator()(int row, int col) const { return pixel_vec[index(row,col)];}
96 
97 
99 
100 // unchecked!
101 void SiPixelArrayBuffer::set_adc( int row, int col, int adc)
102 {
103  pixel_vec[index(row,col)] = adc;
104 }
105 
106 
108 {
109  pixel_vec[index(pix)] = adc;
110 }
111 
112 
113 #endif
int adc(sample_type sample)
get the ADC sample (12 bits)
int i
Definition: DBlmapReader.cc:9
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
bool inside(int row, int col) const
void setSize(int rows, int cols)
int col
Definition: cuy.py:1008
Class to store ADC counts during clustering.