21 const unsigned nRowInQRow,
const unsigned nEventsPerStream,
const bool plainHitMap,
22 const bool dropToT):
m_nCol(nCol/nColInCCol),
m_nRow(nRow/nRowInQRow),
57 m_currBlock |= ((value >> (
length - remainingBits)));
64 uint8_t leftoverBits =
length - remainingBits;
70 addBits64((value & (0xFFFFFFFFFFFFFFFF >> (64 - leftoverBits))), leftoverBits);
82 m_currBlock |= ((0x0ULL |
m_chipID) << 61);
84 uint32_t word1 = m_currBlock >> 32;
85 uint32_t word2 = m_currBlock & 0xFFFFFFFF;
86 m_words.push_back(word1);
87 m_words.push_back(word2);
103 uint16_t lutIndex = 0x0000;
104 std::vector<uint16_t> tots;
107 for (
unsigned pixRow = row; pixRow < row +
m_nRowInQRow; pixRow++){
108 for (
unsigned pixCol = col; pixCol < col +
m_nColInCCol; pixCol++){
109 if (m_hitMap(pixCol, pixRow)){
110 lutIndex |= 0x1 <<
pix;
111 tots.push_back(m_hitMap(pixCol, pixRow) - 1);
127 for (
auto& tot : tots){
138 for (
unsigned pixRow = row; pixRow < row +
m_nRowInQRow; pixRow++){
139 for (
unsigned pixCol = col; pixCol < col +
m_nColInCCol; pixCol++){
140 if (m_hitMap(pixCol, pixRow))
return true;
152 m_hitQCores = std::vector<std::vector<bool>>(
m_nCCol, std::vector<bool>(
m_nQRow,
false));
153 m_lastQRow = std::vector<unsigned> (
m_nCCol, 0);
155 for (
unsigned CCol = 0; CCol <
m_nCCol; CCol++){
156 for (
unsigned QRow = 0; QRow <
m_nQRow; QRow++){
158 m_hitQCores[CCol][QRow] =
hitInQCore(CCol, QRow);
164 if (m_hitQCores[CCol][QRow]) m_lastQRow[CCol] = QRow + 1;
178 for (
unsigned CCol = 0; CCol <
m_nCCol; CCol++){
180 if (m_lastQRow[CCol] == 0)
continue;
184 unsigned previousQRow = std::numeric_limits<unsigned>::max();
185 for (
unsigned QRow = 0; QRow <
m_nQRow; QRow++){
187 if (!m_hitQCores[CCol][QRow])
continue;
193 if (previousQRow != std::numeric_limits<unsigned>::max() && QRow == 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