CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
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 public:
9  inline Phase2TrackerClusterizerArray(unsigned int, unsigned int);
10  // inline void setSize(unsigned int, unsigned int);
11  inline int operator()(unsigned int, unsigned int) const;
12  inline unsigned int rows() const;
13  inline unsigned int columns() const;
14  inline bool inside(unsigned int, unsigned int) const;
15  inline void set(unsigned int, unsigned int, bool, bool);
16  inline unsigned int size() const;
17  inline unsigned int index(unsigned int, unsigned int) const;
18 
19 private:
20  unsigned int nrows_, ncols_;
21  std::vector<bool> matrix_;
22  std::vector<bool> hipmatrix_;
23 };
24 
25 /*
26  * Create a new Array of hits
27  */
28 
30 
31 Phase2TrackerClusterizerArray::Phase2TrackerClusterizerArray(unsigned int nrows, unsigned int ncols)
32  : nrows_(nrows), ncols_(ncols), matrix_(nrows * ncols, false), hipmatrix_(nrows * ncols, false) {}
33 
34 /*
35  * Return the value of an element in the Array
36  */
37 
38 int Phase2TrackerClusterizerArray::operator()(unsigned int row, unsigned int col) const {
39  if (!inside(row, col))
40  return 0; // FIXME this should go outside: avoid it
41  return matrix_[index(row, col)] ? (hipmatrix_[index(row, col)] ? 2 : 1) : 0;
42 }
43 
44 /*
45  * Return the number of rows
46  */
47 
48 unsigned int Phase2TrackerClusterizerArray::rows() const { return nrows_; }
49 
50 /*
51  * Return the number of columns
52  */
53 
54 unsigned int Phase2TrackerClusterizerArray::columns() const { return ncols_; }
55 
56 /*
57  * Tell if an element is inside the array or not
58  */
59 
60 bool Phase2TrackerClusterizerArray::inside(unsigned int row, unsigned int col) const {
61  return ((row < nrows_) & (col < ncols_));
62 }
63 
64 /*
65  * Change the value of an element of the Array
66  */
67 
68 void Phase2TrackerClusterizerArray::set(unsigned int row, unsigned int col, bool state, bool hip) {
69  matrix_[index(row, col)] = state;
70  hipmatrix_[index(row, col)] = hip;
71 }
72 
73 /*
74  * Return the size of the array
75  */
76 
77 unsigned int Phase2TrackerClusterizerArray::size() const { return matrix_.size(); }
78 
79 /*
80  * Get the poisiton of an element of the Array in the vector that holds the data
81  */
82 
83 unsigned int Phase2TrackerClusterizerArray::index(unsigned int row, unsigned int col) const {
84  return col * nrows_ + row;
85 }
86 
87 #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
int col
Definition: cuy.py:1009