ATLAS Offline Software
ITkPixV2Encoder.cxx
Go to the documentation of this file.
1 /*
2 Copyright (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);
18  pushWords32();
19 }
20 
21 void 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);
46  encodeEvent();
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 }
ITkPixEncoder::intTag
void intTag(const uint16_t nEvt) const
Definition: ITkPixEncoder.cxx:214
python.RatesEmulationExample.lock
lock
Definition: RatesEmulationExample.py:148
ITkPixV2Encoder::addToStream
void addToStream(const HitMap &hitMap, bool last=false) const
Definition: ITkPixV2Encoder.cxx:21
ITkPixEncoder::setHitMap
void setHitMap(const HitMap &hitMap) const
Definition: ITkPixEncoder.h:36
ITkPixEncoder::m_nEventsPerStream
unsigned m_nEventsPerStream
Definition: ITkPixEncoder.h:64
ITkPixEncoder::pushWords32
void pushWords32() const
Definition: ITkPixEncoder.cxx:73
ITkPixEncoder::encodeEvent
void encodeEvent() const
Definition: ITkPixEncoder.cxx:166
ITkPixEncoder::m_mutex
std::mutex m_mutex
Definition: ITkPixEncoder.h:80
ITkPixV2Encoder.h
ITkPixLayout
Definition: ITkPixLayout.h:18
ITkPixEncoder::streamTag
void streamTag(const uint8_t nStream) const
Definition: ITkPixEncoder.cxx:206
ITkPixV2Encoder::endStream
void endStream() const
Definition: ITkPixV2Encoder.cxx:15