File indexing completed on 2023-03-17 11:19:31
0001 #ifndef RecoLocalTracker_SiPhase2Clusterizer_Phase2TrackerClusterizerArray_h
0002 #define RecoLocalTracker_SiPhase2Clusterizer_Phase2TrackerClusterizerArray_h
0003
0004 #include <vector>
0005
0006 class Phase2TrackerClusterizerArray {
0007 public:
0008 inline Phase2TrackerClusterizerArray();
0009 inline Phase2TrackerClusterizerArray(unsigned int, unsigned int);
0010
0011 inline int operator()(unsigned int, unsigned int) const;
0012 inline unsigned int rows() const;
0013 inline unsigned int columns() const;
0014 inline bool inside(unsigned int, unsigned int) const;
0015 inline void set(unsigned int, unsigned int, bool, bool);
0016 inline unsigned int size() const;
0017 inline unsigned int index(unsigned int, unsigned int) const;
0018
0019 private:
0020 unsigned int nrows_, ncols_;
0021 std::vector<bool> matrix_;
0022 std::vector<bool> hipmatrix_;
0023 };
0024
0025
0026
0027
0028
0029 Phase2TrackerClusterizerArray::Phase2TrackerClusterizerArray() : nrows_(0), ncols_(0) {}
0030
0031 Phase2TrackerClusterizerArray::Phase2TrackerClusterizerArray(unsigned int nrows, unsigned int ncols)
0032 : nrows_(nrows), ncols_(ncols), matrix_(nrows * ncols, false), hipmatrix_(nrows * ncols, false) {}
0033
0034
0035
0036
0037
0038 int Phase2TrackerClusterizerArray::operator()(unsigned int row, unsigned int col) const {
0039 if (!inside(row, col))
0040 return 0;
0041 return matrix_[index(row, col)] ? (hipmatrix_[index(row, col)] ? 2 : 1) : 0;
0042 }
0043
0044
0045
0046
0047
0048 unsigned int Phase2TrackerClusterizerArray::rows() const { return nrows_; }
0049
0050
0051
0052
0053
0054 unsigned int Phase2TrackerClusterizerArray::columns() const { return ncols_; }
0055
0056
0057
0058
0059
0060 bool Phase2TrackerClusterizerArray::inside(unsigned int row, unsigned int col) const {
0061 return ((row < nrows_) & (col < ncols_));
0062 }
0063
0064
0065
0066
0067
0068 void Phase2TrackerClusterizerArray::set(unsigned int row, unsigned int col, bool state, bool hip) {
0069 matrix_[index(row, col)] = state;
0070 hipmatrix_[index(row, col)] = hip;
0071 }
0072
0073
0074
0075
0076
0077 unsigned int Phase2TrackerClusterizerArray::size() const { return matrix_.size(); }
0078
0079
0080
0081
0082
0083 unsigned int Phase2TrackerClusterizerArray::index(unsigned int row, unsigned int col) const {
0084 return col * nrows_ + row;
0085 }
0086
0087 #endif