CMS 3D CMS Logo

BTLSample.h
Go to the documentation of this file.
1 #ifndef DIGIFTL_BTLSAMPLE_H
2 #define DIGIFTL_BTLSAMPLE_H
3 
4 #include <iostream>
5 #include <ostream>
6 #include <cstdint>
7 
13 class BTLSample {
14 public:
15  enum BTLSampleDataMasks { kToA2Mask = 0x3ff, kToAMask = 0x3ff, kDataMask = 0x3ff };
17 
18  enum BTLSampleFlagMasks { kThreshMask = 0x1, kModeMask = 0x1 };
20 
24  BTLSample() : value_(0), flag_(0), row_(0), col_(0) {}
25  BTLSample(uint32_t value, uint16_t flag, uint8_t row, uint8_t col)
26  : value_(value), flag_(flag), row_(row), col_(col) {}
28 
32  void setThreshold(bool thr) { setFlagWord(thr, kThreshMask, kThreshShift); }
34  void setToA(uint16_t toa) { setDataWord(toa, kToAMask, kToAShift); }
37  void set(bool thr, bool mode, uint16_t toa2, uint16_t toa, uint16_t data, uint8_t row, uint8_t col) {
38  flag_ = (((uint16_t)thr & kThreshMask) << kThreshShift | ((uint16_t)mode & kModeMask) << kModeShift);
39 
40  value_ = (((uint32_t)toa2 & kToA2Mask) << kToA2Shift | ((uint32_t)toa & kToAMask) << kToAShift |
41  ((uint32_t)data & kDataMask) << kDataShift);
42  row_ = row;
43  col_ = col;
44  }
45  void print(std::ostream& out = std::cout) {
46  out << "THR: " << threshold() << " Mode: " << mode() << " ToA2: " << toa2() << " ToA: " << toa()
47  << " Data: " << data() << " Row: " << (uint32_t)row() << " Column: " << (uint32_t)column() << " Raw Flag=0x"
48  << std::hex << raw_flag() << std::dec << " Raw Data=0x" << std::hex << raw_data() << std::dec << std::endl;
49  }
50 
54  uint32_t raw_data() const { return value_; }
55  uint16_t raw_flag() const { return flag_; }
56  bool threshold() const { return ((flag_ >> kThreshShift) & kThreshMask); }
57  bool mode() const { return ((flag_ >> kModeShift) & kModeMask); }
58  uint32_t toa() const { return ((value_ >> kToAShift) & kToAMask); }
59  uint32_t toa2() const { return ((value_ >> kToA2Shift) & kToA2Mask); }
60  uint32_t data() const { return ((value_ >> kDataShift) & kDataMask); }
61  uint8_t row() const { return row_; }
62  uint8_t column() const { return col_; }
63 
64 private:
68  void setDataWord(uint32_t word, uint32_t mask, uint32_t pos) {
69  //clear required bits
70  value_ &= ~(mask << pos);
71  //now set the new value
72  value_ |= ((word & mask) << pos);
73  }
74  void setFlagWord(uint16_t word, uint16_t mask, uint16_t pos) {
75  //clear required bits
76  flag_ &= ~(mask << pos);
77  //now set the new value
78  flag_ |= ((word & mask) << pos);
79  }
80 
81  // bit-words for data and flags
82  uint32_t value_;
83  uint16_t flag_;
84  uint8_t row_, col_;
85 };
86 
87 #endif
BTLSample::set
void set(bool thr, bool mode, uint16_t toa2, uint16_t toa, uint16_t data, uint8_t row, uint8_t col)
Definition: BTLSample.h:37
BTLSample::kToA2Mask
Definition: BTLSample.h:15
BTLSample::kModeMask
Definition: BTLSample.h:18
BTLSample::raw_flag
uint16_t raw_flag() const
Definition: BTLSample.h:55
BTLSample::BTLSample
BTLSample(const BTLSample &o)
Definition: BTLSample.h:27
BTLSample::BTLSample
BTLSample()
CTOR.
Definition: BTLSample.h:24
BTLSample::kToAMask
Definition: BTLSample.h:15
cuy.col
col
Definition: cuy.py:1010
gather_cfg.cout
cout
Definition: gather_cfg.py:144
pos
Definition: PixelAliasList.h:18
BTLSample::kToA2Shift
Definition: BTLSample.h:16
BTLSample::BTLSampleDataMasks
BTLSampleDataMasks
Definition: BTLSample.h:15
BTLSample::mode
bool mode() const
Definition: BTLSample.h:57
BTLSample::kModeShift
Definition: BTLSample.h:19
BTLSample::BTLSampleFlagShifts
BTLSampleFlagShifts
Definition: BTLSample.h:19
BTLSample::toa
uint32_t toa() const
Definition: BTLSample.h:58
BTLSample::kToAShift
Definition: BTLSample.h:16
BTLSample::row_
uint8_t row_
Definition: BTLSample.h:84
BTLSample::col_
uint8_t col_
Definition: BTLSample.h:84
EcalTangentSkim_cfg.o
o
Definition: EcalTangentSkim_cfg.py:42
BTLSample::BTLSample
BTLSample(uint32_t value, uint16_t flag, uint8_t row, uint8_t col)
Definition: BTLSample.h:25
word
uint64_t word
Definition: CTPPSTotemDataFormatter.cc:29
BTLSample::setThreshold
void setThreshold(bool thr)
setters
Definition: BTLSample.h:32
BTLSample::setToA2
void setToA2(uint16_t toa2)
Definition: BTLSample.h:35
BTLSample::raw_data
uint32_t raw_data() const
getters
Definition: BTLSample.h:54
BTLSample
wrapper for a data word
Definition: BTLSample.h:13
BTLSample::kDataMask
Definition: BTLSample.h:15
BTLSample::setDataWord
void setDataWord(uint32_t word, uint32_t mask, uint32_t pos)
wrapper to reset words at a given position
Definition: BTLSample.h:68
BTLSample::BTLSampleFlagMasks
BTLSampleFlagMasks
Definition: BTLSample.h:18
BTLSample::setMode
void setMode(bool mode)
Definition: BTLSample.h:33
BTLSample::kThreshShift
Definition: BTLSample.h:19
BTLSample::toa2
uint32_t toa2() const
Definition: BTLSample.h:59
value
Definition: value.py:1
BTLSample::column
uint8_t column() const
Definition: BTLSample.h:62
BTLSample::kDataShift
Definition: BTLSample.h:16
BTLSample::flag_
uint16_t flag_
Definition: BTLSample.h:83
BTLSample::setData
void setData(uint16_t data)
Definition: BTLSample.h:36
BTLSample::print
void print(std::ostream &out=std::cout)
Definition: BTLSample.h:45
BTLSample::setFlagWord
void setFlagWord(uint16_t word, uint16_t mask, uint16_t pos)
Definition: BTLSample.h:74
BTLSample::data
uint32_t data() const
Definition: BTLSample.h:60
BTLSample::value_
uint32_t value_
Definition: BTLSample.h:82
BTLSample::row
uint8_t row() const
Definition: BTLSample.h:61
BTLSample::threshold
bool threshold() const
Definition: BTLSample.h:56
BTLSample::setToA
void setToA(uint16_t toa)
Definition: BTLSample.h:34
MillePedeFileConverter_cfg.out
out
Definition: MillePedeFileConverter_cfg.py:31
BTLSample::BTLSampleDataShifts
BTLSampleDataShifts
Definition: BTLSample.h:16
TauDecayModes.dec
dec
Definition: TauDecayModes.py:143
RemoveAddSevLevel.flag
flag
Definition: RemoveAddSevLevel.py:116
BTLSample::kThreshMask
Definition: BTLSample.h:18