ATLAS Offline Software
WordDecoder.h
Go to the documentation of this file.
1 /*
2  Copyright (C) 2002-2022 CERN for the benefit of the ATLAS collaboration
3 */
4 
5 #ifndef TRIGT1CALOBYTESTREAM_WORDDECODER_H
6 #define TRIGT1CALOBYTESTREAM_WORDDECODER_H
7 
8 #include <string>
9 #include <vector>
10 #include <cstdint>
11 
12 namespace LVL1BS {
13 
14 class BitField {
15 private:
16  std::string m_name;
19 public:
20  BitField(const std::string& name, uint8_t begin, uint8_t size);
21 
22  template<typename T> T get(const uint32_t& word) const {
23  return T((word >> m_shift) & m_mask);
24  }
25 
26  template<typename T> static T get(const uint32_t& word, uint8_t offset, uint8_t size){
27  return T((word >> offset) & ((1 << size) - 1));
28  }
29 
31  return (word >> offset) & mask;
32  }
33 
34 };
35 
36 
37 class WordDecoder {
38 private:
39  std::vector<BitField> m_bitFields;
40 public:
41  WordDecoder(const std::vector<BitField>& bitFields):m_bitFields(bitFields){};
42  template<typename T> T get(const uint32_t& word, uint8_t index) const{
43  return m_bitFields[index].get<T>(word);
44  }
45 };
46 
47 }
48 
49 #endif
LVL1BS::BitField::get
static T get(const uint32_t &word, uint8_t offset, uint8_t size)
Definition: WordDecoder.h:26
xAOD::uint8_t
uint8_t
Definition: Muon_v1.cxx:557
xAOD::uint32_t
setEventNumber uint32_t
Definition: EventInfo_v1.cxx:127
index
Definition: index.py:1
PlotCalibFromCool.begin
begin
Definition: PlotCalibFromCool.py:94
LVL1BS::WordDecoder
Definition: WordDecoder.h:37
LVL1BS::BitField::BitField
BitField(const std::string &name, uint8_t begin, uint8_t size)
Definition: WordDecoder.cxx:13
python.setupRTTAlg.size
int size
Definition: setupRTTAlg.py:39
LVL1BS::BitField
Definition: WordDecoder.h:14
LVL1BS::BitField::m_shift
uint8_t m_shift
Definition: WordDecoder.h:18
LVL1BS::WordDecoder::m_bitFields
std::vector< BitField > m_bitFields
Definition: WordDecoder.h:39
LVL1BS::BitField::get
T get(const uint32_t &word) const
Definition: WordDecoder.h:22
LVL1BS::BitField::mask
static uint32_t mask(uint32_t word, uint8_t offset, uint32_t mask)
Definition: WordDecoder.h:30
LVL1BS::BitField::m_mask
uint32_t m_mask
Definition: WordDecoder.h:17
name
std::string name
Definition: Control/AthContainers/Root/debug.cxx:228
DeMoScan.index
string index
Definition: DeMoScan.py:364
LVL1BS::WordDecoder::get
T get(const uint32_t &word, uint8_t index) const
Definition: WordDecoder.h:42
LVL1BS
Definition: ZdcModifySlices.h:10
LVL1BS::WordDecoder::WordDecoder
WordDecoder(const std::vector< BitField > &bitFields)
Definition: WordDecoder.h:41
convertTimingResiduals.offset
offset
Definition: convertTimingResiduals.py:71
LVL1BS::BitField::m_name
std::string m_name
Definition: WordDecoder.h:16