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 {
18  public:
19  typedef unsigned int uint;
20 
21  inline MTDArrayBuffer( uint rows, uint cols);
22  inline MTDArrayBuffer( ){}
23 
24  inline void setSize( uint rows, uint cols);
25 
26  inline float energy( uint row, uint col) const;
27  inline float energy( const FTLCluster::FTLHitPos&) const;
28  inline float time( uint row, uint col) const;
29  inline float time( const FTLCluster::FTLHitPos&) const;
30  inline float time_error( uint row, uint col) const;
31  inline float time_error( const FTLCluster::FTLHitPos&) const;
32 
33  inline uint rows() const { return nrows;}
34  inline uint columns() const { return ncols;}
35 
36  inline bool inside(uint row, uint col) const;
37 
38  inline void clear(uint row, uint col)
39  {
40  set_energy( row, col, 0.);
41  set_time( row, col, 0.);
42  set_time_error( row, col, 0.);
43  }
44  inline void clear(const FTLCluster::FTLHitPos& pos)
45  {
46  clear(pos.row(),pos.col());
47  }
48 
49  inline void set( uint row, uint col, float energy, float time, float time_error);
50  inline void set( const FTLCluster::FTLHitPos&, float energy, float time, float time_error);
51 
52  inline void set_energy( uint row, uint col, float energy);
53  inline void set_energy( const FTLCluster::FTLHitPos&, float energy);
54  inline void add_energy( uint row, uint col, float energy);
55 
56  inline void set_time( uint row, uint col, float time);
57  inline void set_time( const FTLCluster::FTLHitPos&, float time);
58 
59  inline void set_time_error( uint row, uint col, float time_error);
60  inline void set_time_error( const FTLCluster::FTLHitPos&, float time_error);
61 
62  uint size() const { return hitEnergy_vec.size();}
63 
65  uint index( uint row, uint col) const {return col*nrows+row;}
66  uint index( const FTLCluster::FTLHitPos& pix) const { return index(pix.row(), pix.col()); }
67 
68  private:
69  std::vector<float> hitEnergy_vec;
70  std::vector<float> hitTime_vec;
71  std::vector<float> hitTimeError_vec;
72  uint nrows;
73  uint ncols;
74 };
75 
77  : hitEnergy_vec(rows*cols,0), hitTime_vec(rows*cols,0), hitTimeError_vec(rows*cols,0), nrows(rows), ncols(cols) {}
78 
80  hitEnergy_vec.resize(rows*cols,0);
81  hitTime_vec.resize(rows*cols,0);
82  hitTimeError_vec.resize(rows*cols,0);
83  nrows = rows;
84  ncols = cols;
85 }
86 
88 {
89  return ( row < nrows && col < ncols);
90 }
91 
92 float MTDArrayBuffer::energy(uint row, uint col) const { return hitEnergy_vec[index(row,col)];}
93 float MTDArrayBuffer::energy(const FTLCluster::FTLHitPos& pix) const {return hitEnergy_vec[index(pix)];}
94 
95 float MTDArrayBuffer::time(uint row, uint col) const { return hitTime_vec[index(row,col)];}
96 float MTDArrayBuffer::time(const FTLCluster::FTLHitPos& pix) const {return hitTime_vec[index(pix)];}
97 
98 float MTDArrayBuffer::time_error(uint row, uint col) const { return hitTimeError_vec[index(row,col)];}
100 
101 void MTDArrayBuffer::set( uint row, uint col, float energy, float time, float time_error)
102 {
103  hitEnergy_vec[index(row,col)] = energy;
104  hitTime_vec[index(row,col)] = time;
105  hitTimeError_vec[index(row,col)] = time_error;
106 }
107 void MTDArrayBuffer::set( const FTLCluster::FTLHitPos& pix, float energy, float time, float time_error)
108 {
109  set( pix.row(), pix.col(), energy, time, time_error);
110 }
111 
113 {
114  hitEnergy_vec[index(row,col)] = energy;
115 }
117 {
118  hitEnergy_vec[index(pix)] = energy;
119 }
121 {
122  hitEnergy_vec[index(row,col)] += energy;
123 }
124 
126 {
127  hitTime_vec[index(row,col)] = time;
128 }
130 {
131  hitTime_vec[index(pix)] = time;
132 }
133 
135 {
136  hitTimeError_vec[index(row,col)] = time_error;
137 }
139 {
141 }
142 
143 #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:61
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:62
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)