|
ATLAS Offline Software
|
Go to the documentation of this file.
4 #ifndef MUONNSWCOMMONDECODE_NSWDECODEHELPER_H
5 #define MUONNSWCOMMONDECODE_NSWDECODEHELPER_H
45 std::size_t
pos =
str.find(
"{}");
46 if (
pos == std::string::npos) {
55 template<
typename T,
typename...
Args>
58 std::size_t
pos =
str.find(
"{}");
59 if (
pos == std::string::npos) {
79 template <
typename Target,
typename Source>
83 const auto wordSize =
sizeof(
Source) * 8;
85 const auto n =
end / wordSize;
86 const auto m =
start / wordSize;
89 throw std::runtime_error(
format(
"End must be larger than start ({} vs {})",
start,
end));
95 throw std::runtime_error(
format(
"Target type (size {}) too small to fit result of bit_slice given start {} and end {} and source size {}",
sizeof(
Target),
start,
end,
sizeof(
Source)));
98 for (
auto i =
m;
i <=
n; ++
i) {
101 s >>= (
n + 1) * wordSize - (
end + 1);
118 template <
typename Target,
typename Source>
136 template <
typename Target,
typename Source>
156 if (
number == 0)
return -1;
162 return CxxUtils::ones<Out> (num_bits) << first_bit;
170 return (word >> position) &
mask;
178 #endif // not MUONNSWCOMMONDECODE_NSWDECODEHELPER_H
constexpr int8_t min_bit(const T number)
Returns the most right hand bit which is set in a number.
constexpr Target decode_and_advance(const std::span< const Source > words, std::size_t &start, const std::size_t size)
Decode bits from data of words and advance the read pointer.
This class provides conversion from CSC RDO data to CSC Digits.
constexpr Out fill_bitmask(const uint8_t first_bit, const uint8_t num_bits)
@ OFFLINE_CHANNEL_TYPE_PAD
uint32_t get_bits(uint32_t word, uint32_t mask, uint8_t position)
std::pair< std::vector< unsigned int >, bool > res
@ OFFLINE_CHANNEL_TYPE_WIRE
std::string format(const std::string &str, const T &arg)
constexpr unsigned count_trailing_zeros(unsigned x)
Count number of trailing zeros.
constexpr int maxSetBit(const T x)
Returns the position (counting from least-significant-bit=0) of the most significant set bit.
Target bit_slice(const std::span< const Source > words, const std::size_t start, const std::size_t end)
Decode bits from data of words.
@ OFFLINE_CHANNEL_TYPE_STRIP
constexpr int8_t max_bit(const T number)
Returns the most left hand bit which is set in a number.
constexpr Target decode_at_loc(const std::span< const Source > words, std::size_t &start, const int offset, const std::size_t size)
Decode bits from data of words at read pointer + offset and NOT advance the read pointer.