CMS 3D CMS Logo

MTDArrayBuffer.h
Go to the documentation of this file.
1 #ifndef RecoLocalTracker_FTLClusterizer_MTDArrayBuffer_H
2 #define RecoLocalTracker_FTLClusterizer_MTDArrayBuffer_H
3 
4 //----------------------------------------------------------------------------
8 //----------------------------------------------------------------------------
9 
10 // We use FTLHitPos which is an inner class of FTLCluster:
12 
13 #include <vector>
14 #include <iostream>
15 
17 public:
18  typedef unsigned int uint;
19 
20  inline MTDArrayBuffer(uint rows, uint cols);
21  inline MTDArrayBuffer() {}
22 
23  inline void setSize(uint rows, uint cols);
24 
25  inline float energy(uint row, uint col) const;
26  inline float energy(const FTLCluster::FTLHitPos&) const;
27  inline float time(uint row, uint col) const;
28  inline float time(const FTLCluster::FTLHitPos&) const;
29  inline float time_error(uint row, uint col) const;
30  inline float time_error(const FTLCluster::FTLHitPos&) const;
31 
32  inline uint rows() const { return nrows; }
33  inline uint columns() const { return ncols; }
34 
35  inline bool inside(uint row, uint col) const;
36 
37  inline void clear(uint row, uint col) {
38  set_energy(row, col, 0.);
39  set_time(row, col, 0.);
40  set_time_error(row, col, 0.);
41  }
42  inline void clear(const FTLCluster::FTLHitPos& pos) { clear(pos.row(), pos.col()); }
43 
44  inline void set(uint row, uint col, float energy, float time, float time_error);
45  inline void set(const FTLCluster::FTLHitPos&, float energy, float time, float time_error);
46 
47  inline void set_energy(uint row, uint col, float energy);
48  inline void set_energy(const FTLCluster::FTLHitPos&, float energy);
49  inline void add_energy(uint row, uint col, float energy);
50 
51  inline void set_time(uint row, uint col, float time);
52  inline void set_time(const FTLCluster::FTLHitPos&, float time);
53 
54  inline void set_time_error(uint row, uint col, float time_error);
55  inline void set_time_error(const FTLCluster::FTLHitPos&, float time_error);
56 
57  uint size() const { return hitEnergy_vec.size(); }
58 
60  uint index(uint row, uint col) const { return col * nrows + row; }
61  uint index(const FTLCluster::FTLHitPos& pix) const { return index(pix.row(), pix.col()); }
62 
63 private:
64  std::vector<float> hitEnergy_vec;
65  std::vector<float> hitTime_vec;
66  std::vector<float> hitTimeError_vec;
67  uint nrows;
68  uint ncols;
69 };
70 
72  : hitEnergy_vec(rows * cols, 0),
73  hitTime_vec(rows * cols, 0),
74  hitTimeError_vec(rows * cols, 0),
75  nrows(rows),
76  ncols(cols) {}
77 
79  hitEnergy_vec.resize(rows * cols, 0);
80  hitTime_vec.resize(rows * cols, 0);
81  hitTimeError_vec.resize(rows * cols, 0);
82  nrows = rows;
83  ncols = cols;
84 }
85 
86 bool MTDArrayBuffer::inside(uint row, uint col) const { return (row < nrows && col < ncols); }
87 
88 float MTDArrayBuffer::energy(uint row, uint col) const { return hitEnergy_vec[index(row, col)]; }
89 float MTDArrayBuffer::energy(const FTLCluster::FTLHitPos& pix) const { return hitEnergy_vec[index(pix)]; }
90 
91 float MTDArrayBuffer::time(uint row, uint col) const { return hitTime_vec[index(row, col)]; }
92 float MTDArrayBuffer::time(const FTLCluster::FTLHitPos& pix) const { return hitTime_vec[index(pix)]; }
93 
94 float MTDArrayBuffer::time_error(uint row, uint col) const { return hitTimeError_vec[index(row, col)]; }
96 
97 void MTDArrayBuffer::set(uint row, uint col, float energy, float time, float time_error) {
98  hitEnergy_vec[index(row, col)] = energy;
99  hitTime_vec[index(row, col)] = time;
100  hitTimeError_vec[index(row, col)] = time_error;
101 }
102 void MTDArrayBuffer::set(const FTLCluster::FTLHitPos& pix, float energy, float time, float time_error) {
103  set(pix.row(), pix.col(), energy, time, time_error);
104 }
105 
109 
110 void MTDArrayBuffer::set_time(uint row, uint col, float time) { hitTime_vec[index(row, col)] = time; }
112 
114  hitTimeError_vec[index(row, col)] = time_error;
115 }
118 }
119 
120 #endif
float time_error(uint row, uint col) const
void set_energy(uint row, uint col, float energy)
uint rows() const
std::vector< float > hitEnergy_vec
Class to store ADC counts and times during clustering.
uint columns() const
float time(uint row, uint col) const
bool inside(uint row, uint col) const
void set_time(uint row, uint col, float time)
void clear(const FTLCluster::FTLHitPos &pos)
uint index(const FTLCluster::FTLHitPos &pix) const
constexpr int row() const
Definition: FTLCluster.h:62
float energy(uint row, uint col) const
std::vector< float > hitTime_vec
uint index(uint row, uint col) const
Definition of indexing within the buffer.
unsigned int uint
uint size() const
void set(uint row, uint col, float energy, float time, float time_error)
col
Definition: cuy.py:1010
constexpr int col() const
Definition: FTLCluster.h:63
void clear(uint row, uint col)
std::vector< float > hitTimeError_vec
void add_energy(uint row, uint col, float energy)
void set_time_error(uint row, uint col, float time_error)
void setSize(uint rows, uint cols)