20 const unsigned nRowInQRow,
const unsigned nEventsPerStream,
const bool plainHitMap,
21 const bool dropToT):
m_nCol(nCol/nColInCCol),
m_nRow(nRow/nRowInQRow),
56 m_currBlock |= ((value >> (
length - remainingBits)));
63 uint8_t leftoverBits =
length - remainingBits;
69 addBits64((value & (0xFFFFFFFFFFFFFFFF >> (64 - leftoverBits))), leftoverBits);
81 m_currBlock |= ((0x0ULL |
m_chipID) << 61);
83 uint32_t word1 = m_currBlock >> 32;
84 uint32_t word2 = m_currBlock & 0xFFFFFFFF;
85 m_words.push_back(word1);
86 m_words.push_back(word2);
102 uint16_t lutIndex = 0x0000;
103 std::vector<uint16_t> tots;
106 for (
unsigned pixRow = row; pixRow < row +
m_nRowInQRow; pixRow++){
107 for (
unsigned pixCol = col; pixCol < col +
m_nColInCCol; pixCol++){
108 if (m_hitMap(pixCol, pixRow)){
109 lutIndex |= 0x1 <<
pix;
110 tots.push_back(m_hitMap(pixCol, pixRow) - 1);
126 for (
auto& tot : tots){
137 for (
unsigned pixRow = row; pixRow < row +
m_nRowInQRow; pixRow++){
138 for (
unsigned pixCol = col; pixCol < col +
m_nColInCCol; pixCol++){
139 if (m_hitMap(pixCol, pixRow))
return true;
151 m_hitQCores = std::vector<std::vector<bool>>(
m_nCCol, std::vector<bool>(
m_nQRow,
false));
152 m_lastQRow = std::vector<unsigned> (
m_nCCol, 0);
154 for (
unsigned CCol = 0; CCol <
m_nCCol; CCol++){
155 for (
unsigned QRow = 0; QRow <
m_nQRow; QRow++){
157 m_hitQCores[CCol][QRow] =
hitInQCore(CCol, QRow);
163 if (m_hitQCores[CCol][QRow]) m_lastQRow[CCol] = QRow + 1;
177 for (
unsigned CCol = 0; CCol <
m_nCCol; CCol++){
179 if (m_lastQRow[CCol] == 0)
continue;
183 int previousQRow = -666;
184 for (
unsigned QRow = 0; QRow <
m_nQRow; QRow++){
186 if (!m_hitQCores[CCol][QRow])
continue;
192 if (QRow == (
uint)previousQRow + 1){
223 uint16_t tag = nEvt | (0b111 << 8);
232 std::lock_guard<std::mutex> lock(
m_mutex);
void encodeQCore(const unsigned nCCol, const unsigned nQRow) const
bool hitInQCore(const unsigned CCol, const unsigned QRow) const
void addBits64(const uint64_t value, const uint8_t length) const
void streamTag(const uint8_t nStream) const
unsigned m_nEventsPerStream
void setChipID(const uint8_t &chipID)
ITkPixEncoder(const bool enableChipID=true, const unsigned nCol=400, const unsigned nRow=384, const unsigned nColInCCol=8, const unsigned nRowInQRow=2, const unsigned nEventsPerStream=16, const bool plainHitMap=false, const bool dropToT=false)
void intTag(const uint16_t nEvt) const
constexpr std::array< uint32_t, LookUpTableSize > ITkPixV2QCoreEncodingLUT_Length
constexpr std::array< uint32_t, LookUpTableSize > ITkPixV2QCoreEncodingLUT_Tree