Pottu
Tagger.hpp
1 /*
2  *
3  */
4 
5 
6 #ifndef H_POTTU_TAGGER
7 #define H_POTTU_TAGGER
8 
9 #include <vector>
10 #include <deque>
11 #include <cstdint>
12 #include <cstdlib>
13 
14 
15 namespace pottu {
16 
20  template <class EVENT, uint16_t NX, uint16_t NY>
21  class Tagger {
22  public:
23  using queue_type = std::deque<EVENT>;
24 
25 
28  void clear() noexcept {
29  for( auto &q : data )
30  q.clear();
31  }
32 
35  bool isValidPixel( uint16_t x, uint16_t y ) const noexcept {
36  return x < NX && y < NY;
37  }
38 
43  queue_type &get( uint16_t x, uint16_t y ) noexcept {
44  if( x >= NX || y >= NY )
45  exit(1);
46  return data[y*NX+x];
47  }
48 
49  const std::vector<queue_type> &getAllQueues() const noexcept {
50  return data;
51  }
52 
53  std::vector<queue_type> &getAllQueues() noexcept {
54  return data;
55  }
56 
57  std::vector<queue_type> data{NX*NY};
58  };
59 
60 
61 }
62 
63 #endif
Super simple 2D array for pixel detector event history.
Definition: Tagger.hpp:21
void clear() noexcept
Clears the whole tagger for all stored events.
Definition: Tagger.hpp:28
queue_type & get(uint16_t x, uint16_t y) noexcept
Returns queue of events in the given pixel.
Definition: Tagger.hpp:43
bool isValidPixel(uint16_t x, uint16_t y) const noexcept
Checks if the given x,y pixel is valid.
Definition: Tagger.hpp:35
Definition: mainpage.dox:6