Loading [MathJax]/extensions/tex2jax.js
 |
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>();
46 template <
typename T,
unsigned int T_ROW_BITS,
unsigned int T_COL_BITS,
unsigned int T_CHIP_BITS,
unsigned int T_MASK_
SEL_BITS,
unsigned int T_N_MASKS=3>
48 static constexpr
unsigned int ROW_BITS = T_ROW_BITS;
49 static constexpr
unsigned int COL_BITS = T_COL_BITS;
50 static constexpr
unsigned int CHIP_BITS = T_CHIP_BITS;
52 static constexpr
unsigned int N_MASKS = T_N_MASKS;
57 static constexpr T
ROW_MASK = MaskUtils::createMask<0, ROW_BITS>();
58 static constexpr T
COL_MASK = MaskUtils::createMask<ROW_BITS, ROW_BITS+COL_BITS>();
59 static constexpr T
CHIP_MASK = MaskUtils::createMask<ROW_BITS+COL_BITS, ROW_BITS+COL_BITS+CHIP_BITS>();
60 static constexpr T
MASK_SEL_MASK = MaskUtils::createMask<ROW_BITS+COL_BITS+CHIP_BITS,ROW_BITS+COL_BITS+CHIP_BITS+MASK_SEL_BITS>();
70 template <
unsigned int SHIFT, T MASK>
72 if constexpr(
MASK==0) {
76 assert (((
val << SHIFT) &
MASK) == (
val << SHIFT));
77 return (
val << SHIFT);
89 static constexpr T
makeKey(
unsigned int mask_sel,
unsigned int chip,
unsigned int col,
unsigned int row=0
u) {
90 return makeKeyPart<MASK_SEL_SHIFT,MASK_SEL_MASK>(mask_sel)
91 | makeKeyPart<CHIP_SHIFT,CHIP_MASK>(chip)
92 | makeKeyPart<COL_SHIFT,COL_MASK>(
col)
93 | makeKeyPart<ROW_SHIFT,ROW_MASK>(
row);
147 return static_cast<T
>(1
u);
160 unsigned int maskedKey([[maybe_unused]]
unsigned int mask_idx,
unsigned int chip,
unsigned int col,
unsigned int row=0
u)
const {
162 assert( mask_idx <
m_masks.size());
177 unsigned int maskedKey(
unsigned int mask_idx,
unsigned int key)
const {
179 assert( mask_idx <
m_masks.size());
198 return (key_ref &
mask) == (key_test &
mask);
201 return key_ref == key_test;
static constexpr unsigned int MASKS_SIZE
static constexpr T getChip(T key)
Get the column index from a full key.
static constexpr unsigned int ROW_BITS
static constexpr T ROW_SHIFT
static constexpr unsigned int nMasks()
Get the number of possible masks.
static constexpr T MASK_SEL_SHIFT
static constexpr unsigned int N_MASKS
static constexpr unsigned int COL_BITS
static constexpr unsigned int CHIP_BITS
requires requires()
This specialization is used for classes deriving from DataObject.
@ u
Enums for curvilinear frames.
static constexpr T CHIP_SHIFT
static constexpr T getColumn(T key)
Get the column index from a full key.
ModuleKeyHelper()=default
unsigned int maskedKey([[maybe_unused]] unsigned int mask_idx, unsigned int chip, unsigned int col, unsigned int row=0u) const
Create a key for a group defect.
static constexpr T makeKey(unsigned int mask_sel, unsigned int chip, unsigned int col, unsigned int row=0u)
Create a key from mask, chip, column and row indices.
static constexpr unsigned int MASK_SEL_BITS
static constexpr T CHIP_MASK
ModuleKeyHelper(std::array< T, N_MASKS > &&masks) requires(N_MASKS >0)
Construct this key helper.
unsigned int maskedKey(unsigned int mask_idx, unsigned int key) const
Turn a single cell (e.g.
static constexpr T getRow(T key)
Get the row index from a full key.
std::conditional<(N_MASKS >0), std::array< T, MASKS_SIZE >, Empty >::type m_masks
the masks for this helper.
static constexpr T MASK_SEL_MASK
static constexpr T ROW_MASK
bool isOverlapping(T key_ref, T key_test) const
Test whether a single cell (e.g.
static constexpr T getMaskIdx(T key)
Get the mask index from a full key.
Helper class to create keys for defects described by chip, column and row indices,...
T getMask(T key) const
Get the mask specified by the full key.
static constexpr T makeKeyPart([[maybe_unused]] T val)
Convenience method to create part of a key.
static constexpr T COL_MASK
static constexpr T COL_SHIFT