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  kToTMask = 0x7ff
23  };
26  kModeShift = 30,
28  kRowShift = 19,
29  kToAShift = 8,
32  };
33 
37  ETLSample() : value_(0), valueToT_(0) {}
38  ETLSample(uint32_t value) : value_(value), valueToT_(0) {}
39  ETLSample(uint32_t value, uint32_t valueToT) : value_(value), valueToT_(valueToT) {}
41  ETLSample& operator=(const ETLSample&) = default;
42 
46  void setThreshold(bool thr) { setWord(thr, kThreshMask, kThreshShift); }
49  void setRow(uint8_t row) { setWord(row, kRowMask, kRowShift); }
50  void setToA(uint16_t toa) { setWord(toa, kToAMask, kToAShift); }
51  void setToT(uint16_t tot) { setWordToT(tot, kToTMask, kToTShift); }
52  void setData(uint16_t data) { setWord(data, kDataMask, kDataShift); }
53  void set(bool thr, bool mode, uint16_t toa, uint16_t tot, uint16_t data, uint8_t row, uint8_t col) {
54  value_ = (((uint32_t)thr & kThreshMask) << kThreshShift | ((uint32_t)mode & kModeMask) << kModeShift |
55  ((uint32_t)col & kColumnMask) << kColumnShift | ((uint32_t)row & kRowMask) << kRowShift |
56  ((uint32_t)toa & kToAMask) << kToAShift | ((uint32_t)data & kDataMask) << kDataShift);
57  valueToT_ = ((uint32_t)tot & kToTMask) << kToTShift;
58  }
59  void print(std::ostream& out = std::cout) {
60  out << "(row,col) : (" << row() << ',' << column() << ") "
61  << "THR: " << threshold() << " Mode: " << mode() << " ToA: " << toa() << " ToT: " << tot()
62  << " Data: " << data() << " Raw=0x" << std::hex << raw() << std::dec << std::endl;
63  }
64 
68  uint32_t raw() const { return value_; }
69  bool threshold() const { return ((value_ >> kThreshShift) & kThreshMask); }
70  bool mode() const { return ((value_ >> kModeShift) & kModeMask); }
71  uint32_t column() const { return ((value_ >> kColumnShift) & kColumnMask); }
72  uint32_t row() const { return ((value_ >> kRowShift) & kRowMask); }
73  uint32_t toa() const { return ((value_ >> kToAShift) & kToAMask); }
74  uint32_t tot() const { return ((valueToT_ >> kToTShift) & kToTMask); }
75  uint32_t data() const { return ((value_ >> kDataShift) & kDataMask); }
76  uint32_t operator()() { return value_; }
77 
78 private:
82  void setWord(uint32_t word, uint32_t mask, uint32_t pos) {
83  //clear required bits
84  value_ &= ~(mask << pos);
85  //now set the new value
86  value_ |= ((word & mask) << pos);
87  }
88 
89  void setWordToT(uint32_t word, uint32_t mask, uint32_t pos) {
90  //clear required bits
91  valueToT_ &= ~(mask << pos);
92  //now set the new value
93  valueToT_ |= ((word & mask) << pos);
94  }
95 
96  // a 32-bit word
97  uint32_t value_;
98  uint32_t valueToT_;
99 };
100 
101 #endif
ETLSample(uint32_t value)
Definition: ETLSample.h:38
bool threshold() const
Definition: ETLSample.h:69
bool mode() const
Definition: ETLSample.h:70
void print(std::ostream &out=std::cout)
Definition: ETLSample.h:59
uint32_t operator()()
Definition: ETLSample.h:76
ETLSample()
CTOR.
Definition: ETLSample.h:37
wrapper for a data word
Definition: ETLSample.h:13
uint32_t valueToT_
Definition: ETLSample.h:98
void setToA(uint16_t toa)
Definition: ETLSample.h:50
uint32_t toa() const
Definition: ETLSample.h:73
uint64_t word
uint32_t data() const
Definition: ETLSample.h:75
ETLSample(uint32_t value, uint32_t valueToT)
Definition: ETLSample.h:39
ETLSampleShifts
Definition: ETLSample.h:24
void setData(uint16_t data)
Definition: ETLSample.h:52
uint32_t column() const
Definition: ETLSample.h:71
ETLSample & operator=(const ETLSample &)=default
Definition: value.py:1
void setToT(uint16_t tot)
Definition: ETLSample.h:51
ETLSampleMasks
Definition: ETLSample.h:15
void setWordToT(uint32_t word, uint32_t mask, uint32_t pos)
Definition: ETLSample.h:89
void setMode(bool mode)
Definition: ETLSample.h:47
void setColumn(uint8_t col)
Definition: ETLSample.h:48
void setThreshold(bool thr)
setters
Definition: ETLSample.h:46
uint32_t raw() const
getters
Definition: ETLSample.h:68
void setRow(uint8_t row)
Definition: ETLSample.h:49
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:82
uint32_t row() const
Definition: ETLSample.h:72
ETLSample(const ETLSample &o)
Definition: ETLSample.h:40
uint32_t value_
Definition: ETLSample.h:97
uint32_t tot() const
Definition: ETLSample.h:74