test
CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
Phase2TrackerClusterizerArray.cc
Go to the documentation of this file.
2 
3 /*
4  * Create a new Array of hits
5  */
6 
8 
9 Phase2TrackerClusterizerArray::Phase2TrackerClusterizerArray(unsigned int nrows, unsigned int ncols) {
10  setSize(nrows, ncols);
11 }
12 
13 /*
14  * Resize the Array and clear the values
15  */
16 
17 void Phase2TrackerClusterizerArray::setSize(unsigned int nrows, unsigned int ncols) {
18  nrows_ = nrows;
19  ncols_ = ncols;
20  matrix_.resize(nrows * ncols);
21  for (std::vector< bool >::iterator it(matrix_.begin()); it != matrix_.end(); ++it) *it = false;
22 }
23 
24 /*
25  * Return the value of an element in the Array
26  */
27 
28 bool Phase2TrackerClusterizerArray::operator()(unsigned int row, unsigned int col) const {
29  if (inside(row, col)) return matrix_[index(row, col)];
30  else return false;
31 }
32 
33 /*
34  * Return the number of rows
35  */
36 
37 unsigned int Phase2TrackerClusterizerArray::rows() const {
38  return nrows_;
39 }
40 
41 /*
42  * Return the number of columns
43  */
44 
46  return ncols_;
47 }
48 
49 /*
50  * Tell if an element is inside the array or not
51  */
52 
53 bool Phase2TrackerClusterizerArray::inside(unsigned int row, unsigned int col) const {
54  return (row < nrows_ && col < ncols_);
55 }
56 
57 /*
58  * Change the value of an element of the Array
59  */
60 
61 void Phase2TrackerClusterizerArray::set(unsigned int row, unsigned int col, bool state) {
62  matrix_[index(row, col)] = state;
63 }
64 
65 /*
66  * Return the size of the array
67  */
68 
69 unsigned int Phase2TrackerClusterizerArray::size() const {
70  return matrix_.size();
71 }
72 
73 /*
74  * Get the poisiton of an element of the Array in the vector that holds the data
75  */
76 
77 unsigned int Phase2TrackerClusterizerArray::index(unsigned int row, unsigned int col) const {
78  return col * nrows_ + row;
79 }
80 
bool operator()(unsigned int, unsigned int) const
void set(unsigned int, unsigned int, bool)
unsigned int index(unsigned int, unsigned int) const
void setSize(unsigned int, unsigned int)
bool inside(unsigned int, unsigned int) const
int col
Definition: cuy.py:1008