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 110 of file ModuleKeyHelper.h.

110{ 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.

Definition at line 94 of file ModuleKeyHelper.h.

94{ 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 114 of file ModuleKeyHelper.h.

114 {
115 if constexpr(TYPE_BITS>0) {
116 return (key & TYPE_MASK) >> TYPE_SHIFT;
117 }
118 else {
119 return T{};
120 }
121 }
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 125 of file ModuleKeyHelper.h.

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

◆ 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 106 of file ModuleKeyHelper.h.

106{ 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 102 of file ModuleKeyHelper.h.

102{ 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 98 of file ModuleKeyHelper.h.

98{ 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 184 of file ModuleKeyHelper.h.

184 {
186 }
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 150 of file ModuleKeyHelper.h.

150 {
151 if constexpr(TYPE_MASK) {
153 }
154 else {
155 return ((key>>RANGE_FLAG_SHIFT) );
156 }
157 }
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 168 of file ModuleKeyHelper.h.

168{ 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 136 of file ModuleKeyHelper.h.

137 {
138 if constexpr(TYPE_BITS>0) {
140 return (defect_type << TYPE_SHIFT ) & TYPE_MASK;
141 }
142 else {
143 return T{};
144 }
145 }

◆ 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 175 of file ModuleKeyHelper.h.

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

◆ 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 162 of file ModuleKeyHelper.h.

162{ 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: