CMS 3D CMS Logo

ETLSample.h
Go to the documentation of this file.
1 #ifndef DIGIFTL_ETLSAMPLE_H
2 #define DIGIFTL_ETLSAMPLE_H
3 
4 #include <iostream>
5 #include <ostream>
6 #include <cstdint>
7 
13 class ETLSample {
14 public:
16  kThreshMask = 0x1,
17  kModeMask = 0x1,
18  kColumnMask = 0x1f,
19  kRowMask = 0x3f,
20  kToAMask = 0x7ff,
21  kDataMask = 0xff
22  };
25  kModeShift = 30,
27  kRowShift = 19,
28  kToAShift = 8,
30  };
31 
35  ETLSample() : value_(0) {}
36  ETLSample(uint32_t value) : value_(value) {}
38 
42  void setThreshold(bool thr) { setWord(thr, kThreshMask, kThreshShift); }
45  void setRow(uint8_t row) { setWord(row, kRowMask, kRowShift); }
46  void setToA(uint16_t toa) { setWord(toa, kToAMask, kToAShift); }
47  void setData(uint16_t data) { setWord(data, kDataMask, kDataShift); }
48  void set(bool thr, bool mode, uint16_t toa, uint16_t data, uint8_t row, uint8_t col) {
49  value_ = (((uint32_t)thr & kThreshMask) << kThreshShift | ((uint32_t)mode & kModeMask) << kModeShift |
50  ((uint32_t)col & kColumnMask) << kColumnShift | ((uint32_t)row & kRowMask) << kRowShift |
51  ((uint32_t)toa & kToAMask) << kToAShift | ((uint32_t)data & kDataMask) << kDataShift);
52  }
53  void print(std::ostream& out = std::cout) {
54  out << "(row,col) : (" << row() << ',' << column() << ") "
55  << "THR: " << threshold() << " Mode: " << mode() << " ToA: " << toa() << " Data: " << data() << " Raw=0x"
56  << std::hex << raw() << std::dec << std::endl;
57  }
58 
62  uint32_t raw() const { return value_; }
63  bool threshold() const { return ((value_ >> kThreshShift) & kThreshMask); }
64  bool mode() const { return ((value_ >> kModeShift) & kModeMask); }
65  uint32_t column() const { return ((value_ >> kColumnShift) & kColumnMask); }
66  uint32_t row() const { return ((value_ >> kRowShift) & kRowMask); }
67  uint32_t toa() const { return ((value_ >> kToAShift) & kToAMask); }
68  uint32_t data() const { return ((value_ >> kDataShift) & kDataMask); }
69  uint32_t operator()() { return value_; }
70 
71 private:
75  void setWord(uint32_t word, uint32_t mask, uint32_t pos) {
76  //clear required bits
77  value_ &= ~(mask << pos);
78  //now set the new value
79  value_ |= ((word & mask) << pos);
80  }
81 
82  // a 32-bit word
83  uint32_t value_;
84 };
85 
86 #endif
ETLSample(uint32_t value)
Definition: ETLSample.h:36
bool threshold() const
Definition: ETLSample.h:63
bool mode() const
Definition: ETLSample.h:64
void print(std::ostream &out=std::cout)
Definition: ETLSample.h:53
uint32_t operator()()
Definition: ETLSample.h:69
ETLSample()
CTOR.
Definition: ETLSample.h:35
wrapper for a data word
Definition: ETLSample.h:13
void setToA(uint16_t toa)
Definition: ETLSample.h:46
uint32_t toa() const
Definition: ETLSample.h:67
constexpr uint32_t mask
Definition: gpuClustering.h:24
uint64_t word
uint32_t data() const
Definition: ETLSample.h:68
ETLSampleShifts
Definition: ETLSample.h:23
void setData(uint16_t data)
Definition: ETLSample.h:47
uint32_t column() const
Definition: ETLSample.h:65
Definition: value.py:1
ETLSampleMasks
Definition: ETLSample.h:15
void setMode(bool mode)
Definition: ETLSample.h:43
void setColumn(uint8_t col)
Definition: ETLSample.h:44
void setThreshold(bool thr)
setters
Definition: ETLSample.h:42
uint32_t raw() const
getters
Definition: ETLSample.h:62
void setRow(uint8_t row)
Definition: ETLSample.h:45
col
Definition: cuy.py:1009
void setWord(uint32_t word, uint32_t mask, uint32_t pos)
wrapper to reset words at a given position
Definition: ETLSample.h:75
uint32_t row() const
Definition: ETLSample.h:66
ETLSample(const ETLSample &o)
Definition: ETLSample.h:37
uint32_t value_
Definition: ETLSample.h:83