ATLAS Offline Software
Loading...
Searching...
No Matches
InDet::ModuleKeyHelper< T, T_ROW_BITS, T_COL_BITS, T_CHIP_BITS, T_TYPE_BITS > Struct Template Reference

Helper class to create keys for defects described by chip, column and row indices, and a mask. More...

#include <ModuleKeyHelper.h>

Collaboration diagram for InDet::ModuleKeyHelper< T, T_ROW_BITS, T_COL_BITS, T_CHIP_BITS, T_TYPE_BITS >:

Public Types

using KEY_TYPE = T

Static Public Member Functions

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 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 T getLimitRowMax ()
 Get the maximum row value.
static constexpr T getLimitColumnMax ()
 Get the maximum row value.
static constexpr T getChip (T key)
 Get the column index from a full key.
static constexpr T getDefectType (T key)
 Get an associated defect type.
static constexpr T getDefectTypeComponent (T key)
 Get key component of an associated defect type.
static constexpr T makeDefectTypeKey (unsigned int defect_type)
 Make the key component representing the an associated defect type.
static constexpr bool isRangeKey (T key)
 Test whether a key is a range key.
static constexpr T makeRangeKey (T key)
 Turn a key into a range key.
static constexpr T makeBaseKey (T key)
 Return the key with the range flag removed.
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 bool isMatchingDefect (T defect_key, T key)
 Convenience method to check whether the key matches the defect.

Static Public Attributes

static constexpr unsigned int ROW_BITS = T_ROW_BITS
static constexpr unsigned int COL_BITS = T_COL_BITS
static constexpr unsigned int CHIP_BITS = T_CHIP_BITS
static constexpr unsigned int RANGE_FLAG_BITS = 1u
static constexpr unsigned int TYPE_BITS = T_TYPE_BITS
static constexpr T ROW_SHIFT = 0u
static constexpr T COL_SHIFT = ROW_BITS
static constexpr T CHIP_SHIFT = ROW_BITS + COL_BITS
static constexpr T RANGE_FLAG_SHIFT = ROW_BITS + COL_BITS + CHIP_BITS
static constexpr T TYPE_SHIFT = RANGE_FLAG_SHIFT + RANGE_FLAG_BITS
static constexpr T ROW_MASK = MaskUtils::createMask<0, ROW_BITS>()
static constexpr T COL_MASK = MaskUtils::createMask<ROW_BITS, ROW_BITS+COL_BITS>()
static constexpr T CHIP_MASK = MaskUtils::createMask<ROW_BITS+COL_BITS, ROW_BITS+COL_BITS+CHIP_BITS>()
static constexpr T RANGE_FLAG_MASK = MaskUtils::createMask<ROW_BITS+COL_BITS+CHIP_BITS,ROW_BITS+COL_BITS+CHIP_BITS+RANGE_FLAG_BITS>()
static constexpr T TYPE_MASK = MaskUtils::createMask<TYPE_SHIFT,TYPE_SHIFT+TYPE_BITS>()

Static Protected Member Functions

template<unsigned int SHIFT, T MASK>
static constexpr T makeKeyPart (T val)
 Convenience method to create part of a key.

Detailed Description

template<typename T, unsigned int T_ROW_BITS, unsigned int T_COL_BITS, unsigned int T_CHIP_BITS, unsigned int T_TYPE_BITS = 0u>
struct InDet::ModuleKeyHelper< T, T_ROW_BITS, T_COL_BITS, T_CHIP_BITS, T_TYPE_BITS >

Helper class to create keys for defects described by chip, column and row indices, and a mask.

Template Parameters
T_ROW_BITSnumber of bits to store the row index of a defect.
T_COL_BITSnumber of bits to store the column index of a defect.
T_CHIP_BITSnumber of bits to store the chip index of a defect.

The key assumes a hierarchical ordering of the indices where the chip index ranks highest and the row index lowest. The range bits indicate that a key marks the beginning of an inclusive range till the previous key (previous because of the reverse order).

Definition at line 41 of file ModuleKeyHelper.h.

Member Typedef Documentation

◆ KEY_TYPE

template<typename T, unsigned int T_ROW_BITS, unsigned int T_COL_BITS, unsigned int T_CHIP_BITS, unsigned int T_TYPE_BITS = 0u>
using InDet::ModuleKeyHelper< T, T_ROW_BITS, T_COL_BITS, T_CHIP_BITS, T_TYPE_BITS >::KEY_TYPE = T

Definition at line 57 of file ModuleKeyHelper.h.

Member Function Documentation

◆ getChip()

template<typename T, unsigned int T_ROW_BITS, unsigned int T_COL_BITS, unsigned int T_CHIP_BITS, unsigned int T_TYPE_BITS = 0u>
constexpr T InDet::ModuleKeyHelper< T, T_ROW_BITS, T_COL_BITS, T_CHIP_BITS, T_TYPE_BITS >::getChip ( T key)
inlinestaticconstexpr

Get the column index from a full key.

Definition at line 112 of file ModuleKeyHelper.h.

112{ return (key & CHIP_MASK) >> CHIP_SHIFT; }
Helper class to create keys for defects described by chip, column and row indices,...
static constexpr T CHIP_MASK
static constexpr T CHIP_SHIFT

◆ getColumn()

template<typename T, unsigned int T_ROW_BITS, unsigned int T_COL_BITS, unsigned int T_CHIP_BITS, unsigned int T_TYPE_BITS = 0u>
constexpr T InDet::ModuleKeyHelper< T, T_ROW_BITS, T_COL_BITS, T_CHIP_BITS, T_TYPE_BITS >::getColumn ( T key)
inlinestaticconstexpr

Get the column index from a full key.

This is always zero if COL_MASK is zero.

Definition at line 95 of file ModuleKeyHelper.h.

95{ return (key & COL_MASK) >> COL_SHIFT; }
static constexpr T COL_SHIFT
static constexpr T COL_MASK

◆ getDefectType()

template<typename T, unsigned int T_ROW_BITS, unsigned int T_COL_BITS, unsigned int T_CHIP_BITS, unsigned int T_TYPE_BITS = 0u>
constexpr T InDet::ModuleKeyHelper< T, T_ROW_BITS, T_COL_BITS, T_CHIP_BITS, T_TYPE_BITS >::getDefectType ( T key)
inlinestaticconstexpr

Get an associated defect type.

Definition at line 116 of file ModuleKeyHelper.h.

116 {
117 if constexpr(TYPE_BITS>0) {
118 return (key & TYPE_MASK) >> TYPE_SHIFT;
119 }
120 else {
121 return T{};
122 }
123 }
static constexpr unsigned int TYPE_BITS
static constexpr T TYPE_MASK
static constexpr T TYPE_SHIFT

◆ getDefectTypeComponent()

template<typename T, unsigned int T_ROW_BITS, unsigned int T_COL_BITS, unsigned int T_CHIP_BITS, unsigned int T_TYPE_BITS = 0u>
constexpr T InDet::ModuleKeyHelper< T, T_ROW_BITS, T_COL_BITS, T_CHIP_BITS, T_TYPE_BITS >::getDefectTypeComponent ( T key)
inlinestaticconstexpr

Get key component of an associated defect type.

Definition at line 127 of file ModuleKeyHelper.h.

127 {
128 if constexpr(TYPE_BITS>0) {
129 return key & TYPE_MASK;
130 }
131 else {
132 return T{};
133 }
134 }

◆ getLimitColumnMax()

template<typename T, unsigned int T_ROW_BITS, unsigned int T_COL_BITS, unsigned int T_CHIP_BITS, unsigned int T_TYPE_BITS = 0u>
constexpr T InDet::ModuleKeyHelper< T, T_ROW_BITS, T_COL_BITS, T_CHIP_BITS, T_TYPE_BITS >::getLimitColumnMax ( )
inlinestaticconstexpr

Get the maximum row value.

Definition at line 107 of file ModuleKeyHelper.h.

107{ return COL_MASK; }

◆ getLimitRowMax()

template<typename T, unsigned int T_ROW_BITS, unsigned int T_COL_BITS, unsigned int T_CHIP_BITS, unsigned int T_TYPE_BITS = 0u>
constexpr T InDet::ModuleKeyHelper< T, T_ROW_BITS, T_COL_BITS, T_CHIP_BITS, T_TYPE_BITS >::getLimitRowMax ( )
inlinestaticconstexpr

Get the maximum row value.

Definition at line 103 of file ModuleKeyHelper.h.

103{ return ROW_MASK; }
static constexpr T ROW_MASK

◆ getRow()

template<typename T, unsigned int T_ROW_BITS, unsigned int T_COL_BITS, unsigned int T_CHIP_BITS, unsigned int T_TYPE_BITS = 0u>
constexpr T InDet::ModuleKeyHelper< T, T_ROW_BITS, T_COL_BITS, T_CHIP_BITS, T_TYPE_BITS >::getRow ( T key)
inlinestaticconstexpr

Get the row index from a full key.

Definition at line 99 of file ModuleKeyHelper.h.

99{ return (key & ROW_MASK) >> ROW_SHIFT; }
static constexpr T ROW_SHIFT

◆ isMatchingDefect()

template<typename T, unsigned int T_ROW_BITS, unsigned int T_COL_BITS, unsigned int T_CHIP_BITS, unsigned int T_TYPE_BITS = 0u>
constexpr bool InDet::ModuleKeyHelper< T, T_ROW_BITS, T_COL_BITS, T_CHIP_BITS, T_TYPE_BITS >::isMatchingDefect ( T defect_key,
T key )
inlinestaticconstexpr

Convenience method to check whether the key matches the defect.

Parameters
defect_keythe key of the defect returned by lower_bound of the emulated defects.
keythe key to test
Returns
true if key overlaps with the defect range or defect.

Definition at line 186 of file ModuleKeyHelper.h.

186 {
188 }
static constexpr T makeBaseKey(T key)
Return the key with the range flag removed.
static constexpr bool isRangeKey(T key)
Test whether a key is a range key.

◆ isRangeKey()

template<typename T, unsigned int T_ROW_BITS, unsigned int T_COL_BITS, unsigned int T_CHIP_BITS, unsigned int T_TYPE_BITS = 0u>
constexpr bool InDet::ModuleKeyHelper< T, T_ROW_BITS, T_COL_BITS, T_CHIP_BITS, T_TYPE_BITS >::isRangeKey ( T key)
inlinestaticconstexpr

Test whether a key is a range key.

Range keys mark the beginning of inclusive range.

Definition at line 152 of file ModuleKeyHelper.h.

152 {
153 if constexpr(TYPE_MASK) {
155 }
156 else {
157 return ((key>>RANGE_FLAG_SHIFT) );
158 }
159 }
static constexpr T RANGE_FLAG_SHIFT
static constexpr T RANGE_FLAG_MASK

◆ makeBaseKey()

template<typename T, unsigned int T_ROW_BITS, unsigned int T_COL_BITS, unsigned int T_CHIP_BITS, unsigned int T_TYPE_BITS = 0u>
constexpr T InDet::ModuleKeyHelper< T, T_ROW_BITS, T_COL_BITS, T_CHIP_BITS, T_TYPE_BITS >::makeBaseKey ( T key)
inlinestaticconstexpr

Return the key with the range flag removed.

If the key is a range key return the key without the range flag otherwise return the the same key.

Definition at line 170 of file ModuleKeyHelper.h.

170{ return key & (~(RANGE_FLAG_MASK|TYPE_MASK)); }

◆ makeDefectTypeKey()

template<typename T, unsigned int T_ROW_BITS, unsigned int T_COL_BITS, unsigned int T_CHIP_BITS, unsigned int T_TYPE_BITS = 0u>
constexpr T InDet::ModuleKeyHelper< T, T_ROW_BITS, T_COL_BITS, T_CHIP_BITS, T_TYPE_BITS >::makeDefectTypeKey ( unsigned int defect_type)
inlinestaticconstexpr

Make the key component representing the an associated defect type.

Definition at line 138 of file ModuleKeyHelper.h.

139 {
140 if constexpr(TYPE_BITS>0) {
142 return (defect_type << TYPE_SHIFT ) & TYPE_MASK;
143 }
144 else {
145 return T{};
146 }
147 }

◆ makeKey()

template<typename T, unsigned int T_ROW_BITS, unsigned int T_COL_BITS, unsigned int T_CHIP_BITS, unsigned int T_TYPE_BITS = 0u>
constexpr T InDet::ModuleKeyHelper< T, T_ROW_BITS, T_COL_BITS, T_CHIP_BITS, T_TYPE_BITS >::makeKey ( bool is_range,
unsigned int chip,
unsigned int col,
unsigned int row = 0u )
inlinestaticconstexpr

Create a key from mask, chip, column and row indices.

Parameters
is_rangeif true the key marks the beginning of an inclusive range
chipthe index of a chip starting from zero
colthe index of a column starting from zero
rowthe index of a row starting from zero

The indices must be representable by the number of reserved bits.

Definition at line 85 of file ModuleKeyHelper.h.

85 {
86 return static_cast<T>(is_range) << RANGE_FLAG_SHIFT
90 }
static constexpr T makeKeyPart(T val)
Convenience method to create part of a key.

◆ makeKeyPart()

template<typename T, unsigned int T_ROW_BITS, unsigned int T_COL_BITS, unsigned int T_CHIP_BITS, unsigned int T_TYPE_BITS = 0u>
template<unsigned int SHIFT, T MASK>
constexpr T InDet::ModuleKeyHelper< T, T_ROW_BITS, T_COL_BITS, T_CHIP_BITS, T_TYPE_BITS >::makeKeyPart ( T val)
inlinestaticconstexprprotected

Convenience method to create part of a key.

Template Parameters
SHIFTthe given value will be shifted by this ammount
MASKthe shifted value must not overflow this mask.
Parameters
valthe value to be stored in the key part

Definition at line 66 of file ModuleKeyHelper.h.

66 {
67 if constexpr(MASK==0) {
68 return T{};
69 }
70 else {
71 assert (((val << SHIFT) & MASK) == (val << SHIFT));
72 return (val << SHIFT);
73 }
74 }

◆ makeRangeForMask()

template<typename T, unsigned int T_ROW_BITS, unsigned int T_COL_BITS, unsigned int T_CHIP_BITS, unsigned int T_TYPE_BITS = 0u>
constexpr std::pair< T, T > InDet::ModuleKeyHelper< T, T_ROW_BITS, T_COL_BITS, T_CHIP_BITS, T_TYPE_BITS >::makeRangeForMask ( T key,
T mask )
inlinestaticconstexpr

Return a key pair marking the beginning and the end of the range for the given mask and key.

Parameters
keya key which marks a point in the range
maska mask which defines the range @preturn a pair containing the start key and end key of the range

Definition at line 177 of file ModuleKeyHelper.h.

177 {
178 return std::make_pair( key & mask, (key | ((~mask) & (CHIP_MASK|COL_MASK|ROW_MASK))) );
179 }

◆ makeRangeKey()

template<typename T, unsigned int T_ROW_BITS, unsigned int T_COL_BITS, unsigned int T_CHIP_BITS, unsigned int T_TYPE_BITS = 0u>
constexpr T InDet::ModuleKeyHelper< T, T_ROW_BITS, T_COL_BITS, T_CHIP_BITS, T_TYPE_BITS >::makeRangeKey ( T key)
inlinestaticconstexpr

Turn a key into a range key.

Such keys mark the beginning of an inclusive range.

Definition at line 164 of file ModuleKeyHelper.h.

164{ return key | RANGE_FLAG_MASK; }

Member Data Documentation

◆ CHIP_BITS

template<typename T, unsigned int T_ROW_BITS, unsigned int T_COL_BITS, unsigned int T_CHIP_BITS, unsigned int T_TYPE_BITS = 0u>
unsigned int InDet::ModuleKeyHelper< T, T_ROW_BITS, T_COL_BITS, T_CHIP_BITS, T_TYPE_BITS >::CHIP_BITS = T_CHIP_BITS
staticconstexpr

Definition at line 44 of file ModuleKeyHelper.h.

◆ CHIP_MASK

template<typename T, unsigned int T_ROW_BITS, unsigned int T_COL_BITS, unsigned int T_CHIP_BITS, unsigned int T_TYPE_BITS = 0u>
T InDet::ModuleKeyHelper< T, T_ROW_BITS, T_COL_BITS, T_CHIP_BITS, T_TYPE_BITS >::CHIP_MASK = MaskUtils::createMask<ROW_BITS+COL_BITS, ROW_BITS+COL_BITS+CHIP_BITS>()
staticconstexpr

Definition at line 54 of file ModuleKeyHelper.h.

◆ CHIP_SHIFT

template<typename T, unsigned int T_ROW_BITS, unsigned int T_COL_BITS, unsigned int T_CHIP_BITS, unsigned int T_TYPE_BITS = 0u>
T InDet::ModuleKeyHelper< T, T_ROW_BITS, T_COL_BITS, T_CHIP_BITS, T_TYPE_BITS >::CHIP_SHIFT = ROW_BITS + COL_BITS
staticconstexpr

Definition at line 49 of file ModuleKeyHelper.h.

◆ COL_BITS

template<typename T, unsigned int T_ROW_BITS, unsigned int T_COL_BITS, unsigned int T_CHIP_BITS, unsigned int T_TYPE_BITS = 0u>
unsigned int InDet::ModuleKeyHelper< T, T_ROW_BITS, T_COL_BITS, T_CHIP_BITS, T_TYPE_BITS >::COL_BITS = T_COL_BITS
staticconstexpr

Definition at line 43 of file ModuleKeyHelper.h.

◆ COL_MASK

template<typename T, unsigned int T_ROW_BITS, unsigned int T_COL_BITS, unsigned int T_CHIP_BITS, unsigned int T_TYPE_BITS = 0u>
T InDet::ModuleKeyHelper< T, T_ROW_BITS, T_COL_BITS, T_CHIP_BITS, T_TYPE_BITS >::COL_MASK = MaskUtils::createMask<ROW_BITS, ROW_BITS+COL_BITS>()
staticconstexpr

Definition at line 53 of file ModuleKeyHelper.h.

◆ COL_SHIFT

template<typename T, unsigned int T_ROW_BITS, unsigned int T_COL_BITS, unsigned int T_CHIP_BITS, unsigned int T_TYPE_BITS = 0u>
T InDet::ModuleKeyHelper< T, T_ROW_BITS, T_COL_BITS, T_CHIP_BITS, T_TYPE_BITS >::COL_SHIFT = ROW_BITS
staticconstexpr

Definition at line 48 of file ModuleKeyHelper.h.

◆ RANGE_FLAG_BITS

template<typename T, unsigned int T_ROW_BITS, unsigned int T_COL_BITS, unsigned int T_CHIP_BITS, unsigned int T_TYPE_BITS = 0u>
unsigned int InDet::ModuleKeyHelper< T, T_ROW_BITS, T_COL_BITS, T_CHIP_BITS, T_TYPE_BITS >::RANGE_FLAG_BITS = 1u
staticconstexpr

Definition at line 45 of file ModuleKeyHelper.h.

◆ RANGE_FLAG_MASK

template<typename T, unsigned int T_ROW_BITS, unsigned int T_COL_BITS, unsigned int T_CHIP_BITS, unsigned int T_TYPE_BITS = 0u>
T InDet::ModuleKeyHelper< T, T_ROW_BITS, T_COL_BITS, T_CHIP_BITS, T_TYPE_BITS >::RANGE_FLAG_MASK = MaskUtils::createMask<ROW_BITS+COL_BITS+CHIP_BITS,ROW_BITS+COL_BITS+CHIP_BITS+RANGE_FLAG_BITS>()
staticconstexpr

Definition at line 55 of file ModuleKeyHelper.h.

◆ RANGE_FLAG_SHIFT

template<typename T, unsigned int T_ROW_BITS, unsigned int T_COL_BITS, unsigned int T_CHIP_BITS, unsigned int T_TYPE_BITS = 0u>
T InDet::ModuleKeyHelper< T, T_ROW_BITS, T_COL_BITS, T_CHIP_BITS, T_TYPE_BITS >::RANGE_FLAG_SHIFT = ROW_BITS + COL_BITS + CHIP_BITS
staticconstexpr

Definition at line 50 of file ModuleKeyHelper.h.

◆ ROW_BITS

template<typename T, unsigned int T_ROW_BITS, unsigned int T_COL_BITS, unsigned int T_CHIP_BITS, unsigned int T_TYPE_BITS = 0u>
unsigned int InDet::ModuleKeyHelper< T, T_ROW_BITS, T_COL_BITS, T_CHIP_BITS, T_TYPE_BITS >::ROW_BITS = T_ROW_BITS
staticconstexpr

Definition at line 42 of file ModuleKeyHelper.h.

◆ ROW_MASK

template<typename T, unsigned int T_ROW_BITS, unsigned int T_COL_BITS, unsigned int T_CHIP_BITS, unsigned int T_TYPE_BITS = 0u>
T InDet::ModuleKeyHelper< T, T_ROW_BITS, T_COL_BITS, T_CHIP_BITS, T_TYPE_BITS >::ROW_MASK = MaskUtils::createMask<0, ROW_BITS>()
staticconstexpr

Definition at line 52 of file ModuleKeyHelper.h.

◆ ROW_SHIFT

template<typename T, unsigned int T_ROW_BITS, unsigned int T_COL_BITS, unsigned int T_CHIP_BITS, unsigned int T_TYPE_BITS = 0u>
T InDet::ModuleKeyHelper< T, T_ROW_BITS, T_COL_BITS, T_CHIP_BITS, T_TYPE_BITS >::ROW_SHIFT = 0u
staticconstexpr

Definition at line 47 of file ModuleKeyHelper.h.

◆ TYPE_BITS

template<typename T, unsigned int T_ROW_BITS, unsigned int T_COL_BITS, unsigned int T_CHIP_BITS, unsigned int T_TYPE_BITS = 0u>
unsigned int InDet::ModuleKeyHelper< T, T_ROW_BITS, T_COL_BITS, T_CHIP_BITS, T_TYPE_BITS >::TYPE_BITS = T_TYPE_BITS
staticconstexpr

Definition at line 46 of file ModuleKeyHelper.h.

◆ TYPE_MASK

template<typename T, unsigned int T_ROW_BITS, unsigned int T_COL_BITS, unsigned int T_CHIP_BITS, unsigned int T_TYPE_BITS = 0u>
T InDet::ModuleKeyHelper< T, T_ROW_BITS, T_COL_BITS, T_CHIP_BITS, T_TYPE_BITS >::TYPE_MASK = MaskUtils::createMask<TYPE_SHIFT,TYPE_SHIFT+TYPE_BITS>()
staticconstexpr

Definition at line 56 of file ModuleKeyHelper.h.

◆ TYPE_SHIFT

template<typename T, unsigned int T_ROW_BITS, unsigned int T_COL_BITS, unsigned int T_CHIP_BITS, unsigned int T_TYPE_BITS = 0u>
T InDet::ModuleKeyHelper< T, T_ROW_BITS, T_COL_BITS, T_CHIP_BITS, T_TYPE_BITS >::TYPE_SHIFT = RANGE_FLAG_SHIFT + RANGE_FLAG_BITS
staticconstexpr

Definition at line 51 of file ModuleKeyHelper.h.


The documentation for this struct was generated from the following file: