 |
ATLAS Offline Software
|
Go to the documentation of this file.
4 #ifndef INDET_MODULEKEYHELPER_H
5 #define INDET_MODULEKEYHELPER_H
16 template<
unsigned int bit,
unsigned int end,
typename T=
unsigned int>
17 static consteval T createMask() {
18 if constexpr(bit>31
u) {
19 return static_cast<T
>(0
u);
21 else if constexpr(bit>=
end) {
22 return static_cast<T
>(0
u);
25 return static_cast<T
>(1u<<bit) | createMask<bit+1u,end, T>();
40 template <
typename T,
unsigned int T_ROW_BITS,
unsigned int T_COL_BITS,
unsigned int T_CHIP_BITS,
unsigned int T_TYPE_BITS=0u>
42 static constexpr
unsigned int ROW_BITS = T_ROW_BITS;
43 static constexpr
unsigned int COL_BITS = T_COL_BITS;
44 static constexpr
unsigned int CHIP_BITS = T_CHIP_BITS;
46 static constexpr
unsigned int TYPE_BITS = T_TYPE_BITS;
52 static constexpr T
ROW_MASK = MaskUtils::createMask<0, ROW_BITS>();
53 static constexpr T
COL_MASK = MaskUtils::createMask<ROW_BITS, ROW_BITS+COL_BITS>();
54 static constexpr T
CHIP_MASK = MaskUtils::createMask<ROW_BITS+COL_BITS, ROW_BITS+COL_BITS+CHIP_BITS>();
55 static constexpr T
RANGE_FLAG_MASK = MaskUtils::createMask<ROW_BITS+COL_BITS+CHIP_BITS,ROW_BITS+COL_BITS+CHIP_BITS+RANGE_FLAG_BITS>();
56 static constexpr T
TYPE_MASK = MaskUtils::createMask<TYPE_SHIFT,TYPE_SHIFT+TYPE_BITS>();
65 template <
unsigned int SHIFT, T MASK>
67 if constexpr(
MASK==0) {
71 assert (((
val << SHIFT) &
MASK) == (
val << SHIFT));
72 return (
val << SHIFT);
85 static constexpr T
makeKey(
bool is_range,
unsigned int chip,
unsigned int col,
unsigned int row=0
u) {
87 | makeKeyPart<CHIP_SHIFT,CHIP_MASK>(chip)
88 | makeKeyPart<COL_SHIFT,COL_MASK>(col)
89 | makeKeyPart<ROW_SHIFT,ROW_MASK>(
row);
static constexpr T getColumn(T key)
Get the column index from a full key.
static constexpr T getRow(T key)
Get the row index from a full key.
static constexpr std::pair< T, T > makeRangeForMask(T key, T mask)
Return a key pair marking the beginning and the end of the range for the given mask and key.
static constexpr unsigned int ROW_BITS
static constexpr T makeRangeKey(T key)
Turn a key into a range key.
static constexpr T makeDefectTypeKey(unsigned int defect_type)
Make the key component representing the an associated defect type.
static constexpr T CHIP_MASK
static constexpr T getDefectType(T key)
Get an associated defect type.
static constexpr unsigned int RANGE_FLAG_BITS
static constexpr unsigned int COL_BITS
static constexpr T RANGE_FLAG_MASK
static constexpr unsigned int TYPE_BITS
static constexpr T getLimitColumnMax()
Get the maximum row value.
@ u
Enums for curvilinear frames.
static constexpr T CHIP_SHIFT
static constexpr T getDefectTypeComponent(T key)
Get key component of an associated defect type.
static constexpr T makeBaseKey(T key)
Return the key with the range flag removed.
static constexpr T COL_SHIFT
static constexpr T ROW_MASK
static constexpr T getChip(T key)
Get the column index from a full key.
static constexpr T makeKeyPart([[maybe_unused]] T val)
Convenience method to create part of a key.
static constexpr T TYPE_MASK
static constexpr T COL_MASK
static constexpr unsigned int CHIP_BITS
static constexpr T ROW_SHIFT
static constexpr T makeKey(bool is_range, unsigned int chip, unsigned int col, unsigned int row=0u)
Create a key from mask, chip, column and row indices.
static constexpr T TYPE_SHIFT
static constexpr bool isMatchingDefect(T defect_key, T key)
Convenience method to check whether the key matches the defect.
Helper class to create keys for defects described by chip, column and row indices,...
static constexpr T RANGE_FLAG_SHIFT
static constexpr T getLimitRowMax()
Get the maximum row value.
static constexpr bool isRangeKey(T key)
Test whether a key is a range key.