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 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 
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
Phase2TrackerClusterizerArray::rows
unsigned int rows() const
Definition: Phase2TrackerClusterizerArray.h:48
hgcalPlots.ncols
ncols
Definition: hgcalPlots.py:105
Phase2TrackerClusterizerArray::ncols_
unsigned int ncols_
Definition: Phase2TrackerClusterizerArray.h:20
funct::false
false
Definition: Factorize.h:34
Phase2TrackerClusterizerArray::index
unsigned int index(unsigned int, unsigned int) const
Definition: Phase2TrackerClusterizerArray.h:83
Phase2TrackerClusterizerArray::columns
unsigned int columns() const
Definition: Phase2TrackerClusterizerArray.h:54
Phase2TrackerClusterizerArray::inside
bool inside(unsigned int, unsigned int) const
Definition: Phase2TrackerClusterizerArray.h:60
cuy.col
col
Definition: cuy.py:1010
Phase2TrackerClusterizerArray::Phase2TrackerClusterizerArray
Phase2TrackerClusterizerArray()
Definition: Phase2TrackerClusterizerArray.h:29
Phase2TrackerClusterizerArray::operator()
int operator()(unsigned int, unsigned int) const
Definition: Phase2TrackerClusterizerArray.h:38
Phase2TrackerClusterizerArray::hipmatrix_
std::vector< bool > hipmatrix_
Definition: Phase2TrackerClusterizerArray.h:22
Phase2TrackerClusterizerArray::set
void set(unsigned int, unsigned int, bool, bool)
Definition: Phase2TrackerClusterizerArray.h:68
Phase2TrackerClusterizerArray
Definition: Phase2TrackerClusterizerArray.h:6
Phase2TrackerClusterizerArray::size
unsigned int size() const
Definition: Phase2TrackerClusterizerArray.h:77
Phase2TrackerClusterizerArray::matrix_
std::vector< bool > matrix_
Definition: Phase2TrackerClusterizerArray.h:21
Phase2TrackerClusterizerArray::nrows_
unsigned int nrows_
Definition: Phase2TrackerClusterizerArray.h:20