ATLAS Offline Software
Loading...
Searching...
No Matches
ITkPixEncoder.h
Go to the documentation of this file.
1/*
2Copyright (C) 2002-2024 CERN for the benefit of the ATLAS collaboration
3*/
4
5/*EXTERNAL CODE PORTED FROM YARR MINIMALLY ADAPTED FOR ATHENA*/
6
7/*
8* Author: Ondra Kovanda, ondrej.kovanda at cern.ch
9* Date: 03/2024
10* Description: ITkPix* encoding base class
11*/
12
13#ifndef ITKPIXENCODER_H
14#define ITKPIXENCODER_H
15
16
17#include "ITkPixLayout.h"
19#include <vector>
20#include <cstdint>
21#include <mutex>
22
24 public:
26
27 ITkPixEncoder(const bool enableChipID = true, const unsigned nCol = 400, const unsigned nRow = 384,
28 const unsigned nColInCCol = 8, const unsigned nRowInQRow = 2,
29 const unsigned nEventsPerStream = 16, const bool plainHitMap = false,
30 const bool dropToT = false);
31
32 std::vector<uint32_t>& getWords(){return m_words;}
33
34 void addBits64(const uint64_t value, const uint8_t length) const;
35
36 void setHitMap(const HitMap& hitMap) const {m_hitMap = hitMap;}
37
38 void setEventsPerStream(const unsigned nEventsPerStream = 16){m_nEventsPerStream = nEventsPerStream;}
39
40 void setChipID(const uint8_t& chipID);
41
42 void clear() const;
43
44 protected:
45
46 void pushWords32() const;
47
48 void encodeQCore(const unsigned nCCol, const unsigned nQRow) const;
49
50 void encodeEvent() const;
51
52 void streamTag(const uint8_t nStream) const;
53
54 void intTag(const uint16_t nEvt) const;
55
56 void scanHitMap() const;
57
58 bool hitInQCore(const unsigned CCol, const unsigned QRow) const;
59
60 //Access to all mutables is always mutex-protected
61 // Chip geometry
62 unsigned m_nCol{400}, m_nRow{384}, m_nCCol{50}, m_nQRow{192}, m_nColInCCol{8}, m_nRowInQRow{2};
63
64 // Output
65 mutable std::vector<uint32_t> m_words ATLAS_THREAD_SAFE; //only accessed in mutex-protected function
67 mutable unsigned m_currCCol ATLAS_THREAD_SAFE {}, m_currQRow ATLAS_THREAD_SAFE {}, m_currEvent ATLAS_THREAD_SAFE {};//
68 mutable uint8_t m_currStream ATLAS_THREAD_SAFE {};
69
70 // Encoding machinery
71 mutable uint64_t m_currBlock ATLAS_THREAD_SAFE {};
72 mutable uint8_t m_currBit ATLAS_THREAD_SAFE {};
73 mutable std::vector<std::vector<bool>> m_hitQCores ATLAS_THREAD_SAFE; //only accessed in mutex-protected function
74 mutable std::vector<unsigned> m_lastQRow ATLAS_THREAD_SAFE; //only accessed in mutex-protected function
75
76 //Globals - could be replace with compile-time conditioning instead of run-time if performance is critical
79 uint8_t m_chipID = 0b00;
80
81 // Input
82 mutable HitMap m_hitMap ATLAS_THREAD_SAFE; //only accessed in mutex-protected function
83
84 mutable std::mutex m_mutex;
85
86
87};
88
89
90#endif
double length(const pvec &v)
Define macros for attributes used to control the static checker.
#define ATLAS_THREAD_SAFE
void pushWords32() const
unsigned m_nCol
size_t m_bitsPerWord
void encodeQCore(const unsigned nCCol, const unsigned nQRow) const
unsigned m_nRowInQRow
void setEventsPerStream(const unsigned nEventsPerStream=16)
std::vector< uint32_t > m_words ATLAS_THREAD_SAFE
void scanHitMap() const
void encodeEvent() const
bool hitInQCore(const unsigned CCol, const unsigned QRow) const
unsigned m_nQRow
unsigned m_nCCol
void addBits64(const uint64_t value, const uint8_t length) const
std::mutex m_mutex
unsigned m_nColInCCol
void streamTag(const uint8_t nStream) const
unsigned m_nEventsPerStream
ITkPixLayout< uint16_t > HitMap
void setChipID(const uint8_t &chipID)
void clear() const
unsigned m_nRow
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)
std::vector< uint32_t > & getWords()
void setHitMap(const HitMap &hitMap) const
void intTag(const uint16_t nEvt) const