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;
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;
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 
112 
113 void MTDArrayBuffer::set_time_error(uint row, uint col, float time_error) {
115 }
116 void MTDArrayBuffer::set_time_error(const FTLCluster::FTLHitPos& pix, float time_error) {
118 }
119 
120 #endif
hgcalPlots.ncols
ncols
Definition: hgcalPlots.py:105
MTDArrayBuffer::set_time
void set_time(uint row, uint col, float time)
Definition: MTDArrayBuffer.h:110
MTDArrayBuffer::clear
void clear(const FTLCluster::FTLHitPos &pos)
Definition: MTDArrayBuffer.h:42
MTDArrayBuffer::columns
uint columns() const
Definition: MTDArrayBuffer.h:33
MTDArrayBuffer::set
void set(uint row, uint col, float energy, float time, float time_error)
Definition: MTDArrayBuffer.h:97
cuy.col
col
Definition: cuy.py:1010
pos
Definition: PixelAliasList.h:18
MTDArrayBuffer::rows
uint rows() const
Definition: MTDArrayBuffer.h:32
MTDArrayBuffer::ncols
uint ncols
Definition: MTDArrayBuffer.h:68
FTLCluster::FTLHitPos
Definition: FTLCluster.h:58
MTDArrayBuffer::MTDArrayBuffer
MTDArrayBuffer()
Definition: MTDArrayBuffer.h:21
MTDArrayBuffer::add_energy
void add_energy(uint row, uint col, float energy)
Definition: MTDArrayBuffer.h:108
MTDArrayBuffer::hitEnergy_vec
std::vector< float > hitEnergy_vec
Definition: MTDArrayBuffer.h:64
HCALHighEnergyHPDFilter_cfi.energy
energy
Definition: HCALHighEnergyHPDFilter_cfi.py:5
MTDArrayBuffer::hitTimeError_vec
std::vector< float > hitTimeError_vec
Definition: MTDArrayBuffer.h:66
FTLCluster::FTLHitPos::row
constexpr int row() const
Definition: FTLCluster.h:62
MTDArrayBuffer::time
float time(uint row, uint col) const
Definition: MTDArrayBuffer.h:91
MTDArrayBuffer::clear
void clear(uint row, uint col)
Definition: MTDArrayBuffer.h:37
MTDArrayBuffer::inside
bool inside(uint row, uint col) const
Definition: MTDArrayBuffer.h:86
MTDArrayBuffer::energy
float energy(uint row, uint col) const
Definition: MTDArrayBuffer.h:88
MTDArrayBuffer::index
uint index(uint row, uint col) const
Definition of indexing within the buffer.
Definition: MTDArrayBuffer.h:60
MTDArrayBuffer::set_energy
void set_energy(uint row, uint col, float energy)
Definition: MTDArrayBuffer.h:106
MTDArrayBuffer::setSize
void setSize(uint rows, uint cols)
Definition: MTDArrayBuffer.h:78
MTDArrayBuffer::index
uint index(const FTLCluster::FTLHitPos &pix) const
Definition: MTDArrayBuffer.h:61
FTLCluster.h
MTDArrayBuffer
Class to store ADC counts and times during clustering.
Definition: MTDArrayBuffer.h:16
MTDArrayBuffer::set_time_error
void set_time_error(uint row, uint col, float time_error)
Definition: MTDArrayBuffer.h:113
MTDArrayBuffer::nrows
uint nrows
Definition: MTDArrayBuffer.h:67
ntuplemaker.time
time
Definition: ntuplemaker.py:310
postprocess-scan-build.rows
rows
Definition: postprocess-scan-build.py:11
MTDArrayBuffer::time_error
float time_error(uint row, uint col) const
Definition: MTDArrayBuffer.h:94
FTLCluster::FTLHitPos::col
constexpr int col() const
Definition: FTLCluster.h:63
MTDArrayBuffer::size
uint size() const
Definition: MTDArrayBuffer.h:57
MTDArrayBuffer::hitTime_vec
std::vector< float > hitTime_vec
Definition: MTDArrayBuffer.h:65
MTDArrayBuffer::uint
unsigned int uint
Definition: MTDArrayBuffer.h:18