CMS 3D CMS Logo

Phase2TrackerClusterizerArray.h
Go to the documentation of this file.
1 #ifndef RecoLocalTracker_SiPhase2Clusterizer_Phase2TrackerClusterizerArray_h
2 #define RecoLocalTracker_SiPhase2Clusterizer_Phase2TrackerClusterizerArray_h
3 
4 #include <vector>
5 
7 
8  public:
9 
11  inline Phase2TrackerClusterizerArray(unsigned int, unsigned int);
12 // inline void setSize(unsigned int, unsigned int);
13  inline int operator()(unsigned int, unsigned int) const;
14  inline unsigned int rows() const;
15  inline unsigned int columns() const;
16  inline bool inside(unsigned int, unsigned int) const;
17  inline void set(unsigned int, unsigned int, bool, bool);
18  inline unsigned int size() const;
19  inline unsigned int index(unsigned int, unsigned int) const;
20 
21  private:
22 
23  unsigned int nrows_, ncols_;
24  std::vector< bool > matrix_;
25  std::vector< bool > hipmatrix_;
26 
27 };
28 
29 
30 /*
31  * Create a new Array of hits
32  */
33 
35 
37  nrows_(nrows),
38  ncols_(ncols),
39  matrix_(nrows * ncols,false),
40  hipmatrix_(nrows * ncols,false){}
41 
42 
43 /*
44  * Return the value of an element in the Array
45  */
46 
47 int Phase2TrackerClusterizerArray::operator()(unsigned int row, unsigned int col) const {
48  if (!inside(row, col)) return 0; // FIXME this should go outside: avoid it
49  return matrix_[index(row, col)] ?
50  ( hipmatrix_[index(row, col)] ? 2 : 1 ) : 0;
51 }
52 
53 /*
54  * Return the number of rows
55  */
56 
57 unsigned int Phase2TrackerClusterizerArray::rows() const {
58  return nrows_;
59 }
60 
61 /*
62  * Return the number of columns
63  */
64 
66  return ncols_;
67 }
68 
69 /*
70  * Tell if an element is inside the array or not
71  */
72 
73 bool Phase2TrackerClusterizerArray::inside(unsigned int row, unsigned int col) const {
74  return ( (row < nrows_) & (col < ncols_) );
75 }
76 
77 /*
78  * Change the value of an element of the Array
79  */
80 
81 void Phase2TrackerClusterizerArray::set(unsigned int row, unsigned int col, bool state, bool hip) {
82  matrix_[index(row, col)] = state;
83  hipmatrix_[index(row, col)] = hip;
84 }
85 
86 /*
87  * Return the size of the array
88  */
89 
90 unsigned int Phase2TrackerClusterizerArray::size() const {
91  return matrix_.size();
92 }
93 
94 /*
95  * Get the poisiton of an element of the Array in the vector that holds the data
96  */
97 
98 unsigned int Phase2TrackerClusterizerArray::index(unsigned int row, unsigned int col) const {
99  return col * nrows_ + row;
100 }
101 
102 #endif
void set(unsigned int, unsigned int, bool, bool)
unsigned int index(unsigned int, unsigned int) const
int operator()(unsigned int, unsigned int) const
bool inside(unsigned int, unsigned int) const
col
Definition: cuy.py:1010