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 
15 public:
16 
17  enum ETLSampleMasks { kThreshMask = 0x1, kModeMask = 0x1, kColumnMask = 0x1f,
18  kRowMask = 0x3f, kToAMask = 0x7ff, kDataMask = 0xff };
20  kRowShift = 19, kToAShift = 8, kDataShift = 0 };
21 
25  ETLSample() : value_(0) { }
26  ETLSample(uint32_t value) : value_(value) { }
27  ETLSample( const ETLSample& o ) : value_(o.value_) { }
28 
32  void setThreshold(bool thr) { setWord(thr, kThreshMask, kThreshShift); }
33  void setMode(bool mode) { setWord(mode, kModeMask, kModeShift); }
34  void setColumn(uint8_t col) { setWord(col, kColumnMask, kColumnShift); }
35  void setRow(uint8_t row) { setWord(row, kRowMask, kRowShift); }
36  void setToA(uint16_t toa) { setWord(toa, kToAMask, kToAShift); }
37  void setData(uint16_t data) { setWord(data, kDataMask, kDataShift); }
38  void set(bool thr, bool mode, uint16_t toa, uint16_t data, uint8_t row, uint8_t col)
39  {
40  value_ = ( ( (uint32_t)thr & kThreshMask ) << kThreshShift |
41  ( (uint32_t)mode & kModeMask ) << kModeShift |
42  ( (uint32_t)col & kColumnMask ) << kColumnShift |
43  ( (uint32_t)row & kRowMask ) << kRowShift |
44  ( (uint32_t)toa & kToAMask ) << kToAShift |
45  ( (uint32_t)data & kDataMask ) << kDataShift );
46  }
47  void print(std::ostream &out=std::cout)
48  {
49  out << "(row,col) : (" << row() << ',' << column() << ") "
50  << "THR: " << threshold()
51  << " Mode: " << mode()
52  << " ToA: " << toa()
53  << " Data: " << data()
54  << " Raw=0x" << std::hex << raw() << std::dec << std::endl;
55  }
56 
60  uint32_t raw() const { return value_; }
61  bool threshold() const { return ( (value_ >> kThreshShift) & kThreshMask ); }
62  bool mode() const { return ( (value_ >> kModeShift) & kModeMask ); }
63  uint32_t column() const { return ( (value_ >> kColumnShift) & kColumnMask ); }
64  uint32_t row() const { return ( (value_ >> kRowShift) & kRowMask ); }
65  uint32_t toa() const { return ( (value_ >> kToAShift) & kToAMask ); }
66  uint32_t data() const { return ( (value_ >> kDataShift) & kDataMask ); }
67  uint32_t operator()() { return value_; }
68 
69 private:
70 
74  void setWord(uint32_t word, uint32_t mask, uint32_t pos)
75  {
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 
87 #endif
ETLSample(uint32_t value)
Definition: ETLSample.h:26
void print(std::ostream &out=std::cout)
Definition: ETLSample.h:47
uint32_t operator()()
Definition: ETLSample.h:67
uint32_t column() const
Definition: ETLSample.h:63
ETLSample()
CTOR.
Definition: ETLSample.h:25
bool mode() const
Definition: ETLSample.h:62
wrapper for a data word
Definition: ETLSample.h:13
bool threshold() const
Definition: ETLSample.h:61
void setToA(uint16_t toa)
Definition: ETLSample.h:36
ETLSampleShifts
Definition: ETLSample.h:19
uint32_t raw() const
getters
Definition: ETLSample.h:60
void setData(uint16_t data)
Definition: ETLSample.h:37
Definition: value.py:1
ETLSampleMasks
Definition: ETLSample.h:17
uint32_t toa() const
Definition: ETLSample.h:65
void setMode(bool mode)
Definition: ETLSample.h:33
void setColumn(uint8_t col)
Definition: ETLSample.h:34
void setThreshold(bool thr)
setters
Definition: ETLSample.h:32
void setRow(uint8_t row)
Definition: ETLSample.h:35
col
Definition: cuy.py:1010
void setWord(uint32_t word, uint32_t mask, uint32_t pos)
wrapper to reset words at a given position
Definition: ETLSample.h:74
ETLSample(const ETLSample &o)
Definition: ETLSample.h:27
uint32_t value_
Definition: ETLSample.h:83
uint32_t row() const
Definition: ETLSample.h:64
uint32_t data() const
Definition: ETLSample.h:66