ATLAS Offline Software
Loading...
Searching...
No Matches
ITkPixV2Encoder.cxx
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: 02/2024
10* Description: ITkPix* encoding
11*/
12
13#include "ITkPixV2Encoder.h"
14
16 //only called from mutex-protected function
17 m_currBlock |= (0x1ULL << 63);
19}
20
21void ITkPixV2Encoder::addToStream(const HitMap& hitMap, bool last) const {
22
23 //All operation on the class mutables (except m_words()) is done here
24 //in a serialized sequence ensuring thread safety. The individual functions
25 //called here are not accessible from the outside.
26
27 //This is a high-level interface function that can take care of
28 //adding an event into the current stream, this can be called
29 //easily from the outside, and automatically tags/ends streams
30 //and events based on internal vars only
31
32 //If this is the first event, start a new stream. Otherwise, add an
33 //internal tag
34 std::lock_guard<std::mutex> lock(m_mutex);
35
36 if (m_currEvent == 0){
37 streamTag(m_currStream);
38 m_currStream++;
39 }
40 else {
41 intTag(m_currEvent);
42 }
43
44 //Then add the actual encoded event information
45 setHitMap(hitMap);
47 m_currEvent++;
48
49 //If this is the last event in the stream or if we explicitly
50 //want to end the stream (i. e. total number of generated events
51 //is not a multiple of nEventsPerStream), end the stream
52 if (m_currEvent == m_nEventsPerStream || last){
53 endStream();
54 m_currEvent = 0;
55 }
56
57}
void pushWords32() const
void encodeEvent() const
std::mutex m_mutex
void streamTag(const uint8_t nStream) const
unsigned m_nEventsPerStream
ITkPixLayout< uint16_t > HitMap
void setHitMap(const HitMap &hitMap) const
void intTag(const uint16_t nEvt) const
void addToStream(const HitMap &hitMap, bool last=false) const
void endStream() const