ATLAS Offline Software
Loading...
Searching...
No Matches
ITkPixelDecodingTool Struct Reference

#include <ITkPixelDecodingTool.h>

Inheritance diagram for ITkPixelDecodingTool:
Collaboration diagram for ITkPixelDecodingTool:

Public Member Functions

virtual StatusCode initialize () override
template<typename TStreamInfo>
StatusCode aggregateData (const EventContext &ctx, std::vector< uint64_t > &bytestream_data, TStreamInfo &streams_info, std::function< StatusCode(uint32_t, uint32_t &)> module_id_transform={}) const
template<typename TStreamInfo, typename TDecodingCallback>
StatusCode decodeData (std::vector< uint64_t > const &bytestream_data, TStreamInfo const &streams_info, TDecodingCallback &decoding_cb) const
 AthAlgTool (const std::string &type, const std::string &name, const IInterface *parent)
 Constructor with parameters:
ServiceHandle< StoreGateSvc > & evtStore ()
 The standard StoreGateSvc (event store) Returns (kind of) a pointer to the StoreGateSvc.
const ServiceHandle< StoreGateSvc > & detStore () const
 The standard StoreGateSvc/DetectorStore Returns (kind of) a pointer to the StoreGateSvc.
virtual StatusCode sysInitialize () override
 Perform system initialization for an algorithm.
virtual StatusCode sysStart () override
 Handle START transition.
virtual std::vector< Gaudi::DataHandle * > inputHandles () const override
 Return this algorithm's input handles.
virtual std::vector< Gaudi::DataHandle * > outputHandles () const override
 Return this algorithm's output handles.
Gaudi::Details::PropertyBase & declareProperty (Gaudi::Property< T, V, H > &t)
void updateVHKA (Gaudi::Details::PropertyBase &)
MsgStream & msg () const
bool msgLvl (const MSG::Level lvl) const

Protected Member Functions

void renounceArray (SG::VarHandleKeyArray &handlesArray)
 remove all handles from I/O resolution
std::enable_if_t< std::is_void_v< std::result_of_t< decltype(&T::renounce)(T)> > &&!std::is_base_of_v< SG::VarHandleKeyArray, T > &&std::is_base_of_v< Gaudi::DataHandle, T >, void > renounce (T &h)
void extraDeps_update_handler (Gaudi::Details::PropertyBase &ExtraDeps)
 Add StoreName to extra input/output deps as needed.

Private Types

typedef ServiceHandle< StoreGateSvc > StoreGateSvc_t

Private Member Functions

Gaudi::Details::PropertyBase & declareGaudiProperty (Gaudi::Property< T, V, H > &hndl, const SG::VarHandleKeyType &)
 specialization for handling Gaudi::Property<SG::VarHandleKey>

Private Attributes

ServiceHandle< IROBDataProviderSvc > m_robDataProviderSvc
SG::ReadCondHandleKey< ITkPixelCablingData > m_pixelCablingKey
Gaudi::Property< size_t > m_expectedDataSize
Gaudi::Property< bool > m_failOnDecodingError
Gaudi::Property< bool > m_roiSeeded
ToolHandle< IRegSelTool > m_regionSelector
SG::ReadHandleKey< TrigRoiDescriptorCollection > m_roiCollectionKey
StoreGateSvc_t m_evtStore
 Pointer to StoreGate (event store by default).
StoreGateSvc_t m_detStore
 Pointer to StoreGate (detector store by default).
std::vector< SG::VarHandleKeyArray * > m_vhka
bool m_varHandleArraysDeclared

Detailed Description

Definition at line 16 of file ITkPixelDecodingTool.h.

Member Typedef Documentation

◆ StoreGateSvc_t

typedef ServiceHandle<StoreGateSvc> AthCommonDataStore< AthCommonMsg< AlgTool > >::StoreGateSvc_t
privateinherited

Definition at line 376 of file AthCommonDataStore.h.

Member Function Documentation

◆ aggregateData()

template<typename TStreamInfo>
template StatusCode ITkPixelDecodingTool::aggregateData ( const EventContext & ctx,
std::vector< uint64_t > & bytestream_data,
TStreamInfo & streams_info,
std::function< StatusCode(uint32_t, uint32_t &)> module_id_transform = {} ) const

Definition at line 30 of file ITkPixelDecodingTool.cxx.

36{
37 // Cabling data
38 SG::ReadCondHandle<ITkPixelCablingData> cabling_handle(m_pixelCablingKey, ctx);
39 ATH_CHECK(cabling_handle.isValid());
40 const ITkPixelCablingData* cabling = *cabling_handle;
41 if (!cabling) {
42 ATH_MSG_ERROR("no cabling data");
43 return StatusCode::FAILURE;
44 }
45
46 // Get list of ROBs to decode
47 std::vector<const eformat::ROBFragment<const uint32_t*>*> robs;
48 if (!m_roiSeeded) {
49 m_robDataProviderSvc->getROBData(ctx, cabling->sourceIDs(), robs);
50 } else {
51 std::vector<uint32_t> listOfROBs;
52 SG::ReadHandle<TrigRoiDescriptorCollection> roiCollection(m_roiCollectionKey, ctx);
53 ATH_CHECK(roiCollection.isValid());
54 TrigRoiDescriptor superRoI; // Add all RoIs to a super-RoI
55 superRoI.reserve(roiCollection->size());
56 superRoI.setComposite(true);
57 superRoI.manageConstituents(false);
58 for (const TrigRoiDescriptor* roi : *roiCollection) {
59 superRoI.push_back(roi);
60 }
61 m_regionSelector->lookup(ctx)->ROBIDList(superRoI, listOfROBs);
62 m_robDataProviderSvc->getROBData(ctx, listOfROBs, robs);
63 }
64 ATH_MSG_DEBUG("retrieved " << robs.size() << " ROB fragments");
65
66 // Pre-allocate expected amount of data to avoid effect of per-ROB resizing
67 bytestream_data.reserve(m_expectedDataSize / 8);
68
69 //The ROB/ROD payload contains a chain of [FE header 0] [FE data 0] ... [FE
70 //header N] [FE data N]. We need to sort these header-data pairs in each ROB
71 //payload according to the module ID to fill each module exactly once. from
72 //the GBT fragment building algorithm documentation
73 //(https://gitlab.cern.ch/atlas-tdaq-software/swrod#gbt-fragment-building-algorithm)
74 //"size: 16-bit value that contains a total size (in 4-byte words) of the data
75 //packet including the size of the header itself." i. e. the first 16 bits of
76 //the first word allow us to identify where the next FE starts, etc. We can
77 //jump once through the payload to separate the FE data and store the
78 //moduleID, {start idx, size} map, sort according to the key and then read in
79 //that order from the underlying array without copying.
80
81 for (const auto& rob : robs) {
82 const uint32_t * const payload = rob->rod_data();
83 const uint32_t payload_length = rob->rod_ndata();
84
85 // Data from different Pixel modules might be interleaved but the decoders
86 // have to decode one module after the other. So we sort the GBT fragments
87 // by module ID. Module ID is the 24 least-significant bits of a detector
88 // resource ID.
89 auto comp = [](const uint32_t& a, const uint32_t& b){
90 uint32_t aLSB = a & 0x00FFFFFF;
91 uint32_t bLSB = b & 0x00FFFFFF;
92 if (aLSB != bLSB) return aLSB < bLSB;
93 return a < b;
94 };
95 // detector resource ID -> {GBT fragment start offset, GBT fragment length}
96 std::map<uint32_t, std::pair<size_t, uint16_t>, decltype(comp)> gbt_fragments(comp);
97
98 // total GBT data payload size in this ROB
99 size_t data_size_64bits = 0;
100 size_t idx = 0;
101 while (idx < payload_length){
102 const uint16_t gbt_fragment_size = (payload[idx] & 0xFFFF0000) >> 16;
103 const uint32_t detector_resource_id = payload[idx + 1];
104 // This is where we want to map detectorResourceID on trueDetectorResourceID
105 gbt_fragments.insert({detector_resource_id, {idx, gbt_fragment_size}});
106 idx += gbt_fragment_size;
107
108 // The frames are always 64 bits split into 32-bit words, so always
109 // divisible by 2. The first 32-bit words are the GBT header.
110 data_size_64bits += (gbt_fragment_size - 2) / 2;
111 }
112
113 // This is where we write (the current GBT fragment) in the aggregation buffer
114 size_t payload64_idx = bytestream_data.size();
115 // We need to store the start index of each stream. The first one starts here.
116 size_t payload64_start = bytestream_data.size();
117 // Make room for this ROB's data
118 bytestream_data.resize(payload64_idx + data_size_64bits);
119
120 // The GBT fragments are sorted: looping over the map gives access to data
121 // for all modules sequentially.
122 for (const auto& [detector_resource_id, start_length] : gbt_fragments) {
123 const auto [start, length] = start_length;
124
125 // Copy data to output buffer swapping 32-bit words.
126 // The 64-bit GBT header is skipped at the beginning.
127 for (uint32_t word = start + 2; word < start + length; word += 2){
128 bytestream_data[payload64_idx] =
129 (static_cast<uint64_t>(payload[word])<< 32)
130 | static_cast<uint64_t>(payload[word + 1]);
131 ++payload64_idx;
132 }
133
134 const uint16_t stream_size_64bits = (length - 2) / 2;
135 const uint32_t module_id = ITkPixelCabling::dridToModuleID(detector_resource_id);
136 uint32_t transformed_id = module_id;
137 if (module_id_transform) {
138 ATH_CHECK(module_id_transform(module_id, transformed_id));
139 }
140
141 streams_info.push_back({payload64_start, stream_size_64bits,
142 transformed_id, static_cast<uint8_t>(cabling->transformType(module_id)),
143 ITkPixelCabling::dridToChipID(detector_resource_id)});
144
145 // This will be the start index of the next stream
146 payload64_start += stream_size_64bits;
147 }
148 }
149
150 return StatusCode::SUCCESS;
151 }
#define ATH_CHECK
Evaluate an expression and check for errors.
#define ATH_MSG_DEBUG(x,...)
#define ATH_MSG_ERROR(x,...)
double length(const pvec &v)
static Double_t a
void push_back(const IRoiDescriptor *roi)
add a RoiDescriptor
bool manageConstituents() const
always manage constituents ???
void reserve(size_t s)
reserve elements in vector
void setComposite(bool b=true)
uint32_t dridToModuleID(const uint32_t &drid)
uint8_t dridToChipID(const uint32_t &drid)
setWord1 uint16_t
setEventNumber uint32_t
Gaudi::Property< bool > m_roiSeeded
SG::ReadHandleKey< TrigRoiDescriptorCollection > m_roiCollectionKey
ToolHandle< IRegSelTool > m_regionSelector
Gaudi::Property< size_t > m_expectedDataSize
SG::ReadCondHandleKey< ITkPixelCablingData > m_pixelCablingKey
ServiceHandle< IROBDataProviderSvc > m_robDataProviderSvc

◆ AthAlgTool()

AthAlgTool::AthAlgTool ( const std::string & type,
const std::string & name,
const IInterface * parent )

Constructor with parameters:

Definition at line 31 of file AthAlgTool.cxx.

◆ declareGaudiProperty()

Gaudi::Details::PropertyBase & AthCommonDataStore< AthCommonMsg< AlgTool > >::declareGaudiProperty ( Gaudi::Property< T, V, H > & hndl,
const SG::VarHandleKeyType &  )
inlineprivateinherited

specialization for handling Gaudi::Property<SG::VarHandleKey>

Definition at line 156 of file AthCommonDataStore.h.

158 {
160 hndl.value(),
161 hndl.documentation());
162
163 }
Gaudi::Details::PropertyBase & declareProperty(Gaudi::Property< T, V, H > &t)

◆ declareProperty()

Gaudi::Details::PropertyBase & AthCommonDataStore< AthCommonMsg< AlgTool > >::declareProperty ( Gaudi::Property< T, V, H > & t)
inlineinherited

Definition at line 145 of file AthCommonDataStore.h.

145 {
146 typedef typename SG::HandleClassifier<T>::type htype;
148 }
Gaudi::Details::PropertyBase & declareGaudiProperty(Gaudi::Property< T, V, H > &hndl, const SG::VarHandleKeyType &)
specialization for handling Gaudi::Property<SG::VarHandleKey>

◆ decodeData()

template<typename TStreamInfo, typename TDecodingCallback>
template StatusCode ITkPixelDecodingTool::decodeData ( std::vector< uint64_t > const & bytestream_data,
TStreamInfo const & streams_info,
TDecodingCallback & decoding_cb ) const

Definition at line 154 of file ITkPixelDecodingTool.cxx.

159{
160 constexpr itksw::pix::endec::intf::Options DECODING_OPTIONS{
161 .en_chip_id = true, .en_eos = false};
162 constexpr itksw::pix::endec::DataFormat DECODING_FORMAT{
163 .options = DECODING_OPTIONS};
164
166 decoding_cb.stopDecodingOnError();
167 }
168 itksw::pix::endec::DecCore<TDecodingCallback> decoder(DECODING_FORMAT, decoding_cb);
169
170 uint32_t current_module_id = 0xFFFFFFFF;
171 for (auto const & stream_info: streams_info) {
172
173 // When handling data for a new module, we need to inform the decoding callback
174 const uint32_t module_id = stream_info.m_moduleId;
175 if (module_id != current_module_id) {
176 decoding_cb.setOfflineID(stream_info.m_moduleId);
177 decoding_cb.setTransformType(ITkPixelCabling::TransformType(
178 stream_info.m_transformType));
179 }
180 decoding_cb.setChipID(stream_info.m_chipId);
181
182 decoder.initialize();
183 decoder.decode({bytestream_data.data() + stream_info.m_dataOffset,
184 stream_info.m_dataLength});
185 decoder.finalize();
186
187 if (m_failOnDecodingError && decoding_cb.getNbErrors() != 0) {
188 ATH_MSG_ERROR("stopping because of decoding errors");
189 return StatusCode::FAILURE;
190 }
191 }
192
193 return StatusCode::SUCCESS;
194}
Gaudi::Property< bool > m_failOnDecodingError

◆ detStore()

const ServiceHandle< StoreGateSvc > & AthCommonDataStore< AthCommonMsg< AlgTool > >::detStore ( ) const
inlineinherited

The standard StoreGateSvc/DetectorStore Returns (kind of) a pointer to the StoreGateSvc.

Definition at line 95 of file AthCommonDataStore.h.

◆ evtStore()

ServiceHandle< StoreGateSvc > & AthCommonDataStore< AthCommonMsg< AlgTool > >::evtStore ( )
inlineinherited

The standard StoreGateSvc (event store) Returns (kind of) a pointer to the StoreGateSvc.

Definition at line 85 of file AthCommonDataStore.h.

◆ extraDeps_update_handler()

void AthCommonDataStore< AthCommonMsg< AlgTool > >::extraDeps_update_handler ( Gaudi::Details::PropertyBase & ExtraDeps)
protectedinherited

Add StoreName to extra input/output deps as needed.

use the logic of the VarHandleKey to parse the DataObjID keys supplied via the ExtraInputs and ExtraOuputs Properties to add the StoreName if it's not explicitly given

◆ initialize()

StatusCode ITkPixelDecodingTool::initialize ( )
overridevirtual

Definition at line 14 of file ITkPixelDecodingTool.cxx.

15{
17 ATH_CHECK(m_pixelCablingKey.initialize());
18
20 if (m_roiSeeded) {
21 ATH_CHECK(m_regionSelector.retrieve());
22 } else {
23 m_regionSelector.disable();
24 }
25
26 return StatusCode::SUCCESS;
27}

◆ inputHandles()

virtual std::vector< Gaudi::DataHandle * > AthCommonDataStore< AthCommonMsg< AlgTool > >::inputHandles ( ) const
overridevirtualinherited

Return this algorithm's input handles.

We override this to include handle instances from key arrays if they have not yet been declared. See comments on updateVHKA.

◆ msg()

MsgStream & AthCommonMsg< AlgTool >::msg ( ) const
inlineinherited

Definition at line 24 of file AthCommonMsg.h.

24 {
25 return this->msgStream();
26 }

◆ msgLvl()

bool AthCommonMsg< AlgTool >::msgLvl ( const MSG::Level lvl) const
inlineinherited

Definition at line 30 of file AthCommonMsg.h.

30 {
31 return this->msgLevel(lvl);
32 }

◆ outputHandles()

virtual std::vector< Gaudi::DataHandle * > AthCommonDataStore< AthCommonMsg< AlgTool > >::outputHandles ( ) const
overridevirtualinherited

Return this algorithm's output handles.

We override this to include handle instances from key arrays if they have not yet been declared. See comments on updateVHKA.

◆ renounce()

std::enable_if_t< std::is_void_v< std::result_of_t< decltype(&T::renounce)(T)> > &&!std::is_base_of_v< SG::VarHandleKeyArray, T > &&std::is_base_of_v< Gaudi::DataHandle, T >, void > AthCommonDataStore< AthCommonMsg< AlgTool > >::renounce ( T & h)
inlineprotectedinherited

Definition at line 368 of file AthCommonDataStore.h.

369 {
370 h.renounce();
372 }
std::enable_if_t< std::is_void_v< std::result_of_t< decltype(&T::renounce)(T)> > &&!std::is_base_of_v< SG::VarHandleKeyArray, T > &&std::is_base_of_v< Gaudi::DataHandle, T >, void > renounce(T &h)

◆ renounceArray()

void AthCommonDataStore< AthCommonMsg< AlgTool > >::renounceArray ( SG::VarHandleKeyArray & handlesArray)
inlineprotectedinherited

remove all handles from I/O resolution

Definition at line 352 of file AthCommonDataStore.h.

352 {
354 }

◆ sysInitialize()

virtual StatusCode AthCommonDataStore< AthCommonMsg< AlgTool > >::sysInitialize ( )
overridevirtualinherited

Perform system initialization for an algorithm.

We override this to declare all the elements of handle key arrays at the end of initialization. See comments on updateVHKA.

Reimplemented in asg::AsgMetadataTool, AthCheckedComponent< AthAlgTool >, and AthCheckedComponent<::AthAlgTool >.

◆ sysStart()

virtual StatusCode AthCommonDataStore< AthCommonMsg< AlgTool > >::sysStart ( )
overridevirtualinherited

Handle START transition.

We override this in order to make sure that conditions handle keys can cache a pointer to the conditions container.

◆ updateVHKA()

void AthCommonDataStore< AthCommonMsg< AlgTool > >::updateVHKA ( Gaudi::Details::PropertyBase & )
inlineinherited

Definition at line 298 of file AthCommonDataStore.h.

298 {
299 for (auto &a : m_vhka) {
301 for (auto k : keys) {
302 k->setOwner(this);
303 }
304 }
305 }
std::vector< SG::VarHandleKeyArray * > m_vhka

Member Data Documentation

◆ m_detStore

StoreGateSvc_t AthCommonDataStore< AthCommonMsg< AlgTool > >::m_detStore
privateinherited

Pointer to StoreGate (detector store by default).

Definition at line 381 of file AthCommonDataStore.h.

◆ m_evtStore

StoreGateSvc_t AthCommonDataStore< AthCommonMsg< AlgTool > >::m_evtStore
privateinherited

Pointer to StoreGate (event store by default).

Definition at line 378 of file AthCommonDataStore.h.

◆ m_expectedDataSize

Gaudi::Property<size_t> ITkPixelDecodingTool::m_expectedDataSize
private
Initial value:
{this,
"ExpectedDataSize", 2000000,
"Expected amount of data [B] to decode per event, used to pre-allocate"}

Definition at line 69 of file ITkPixelDecodingTool.h.

69 {this,
70 "ExpectedDataSize", 2000000,
71 "Expected amount of data [B] to decode per event, used to pre-allocate"};

◆ m_failOnDecodingError

Gaudi::Property<bool> ITkPixelDecodingTool::m_failOnDecodingError
private
Initial value:
{this,
"FailOnDecodingError", false,
"Whether the algortihm should fail on decoding error"}

Definition at line 72 of file ITkPixelDecodingTool.h.

72 {this,
73 "FailOnDecodingError", false,
74 "Whether the algortihm should fail on decoding error"};

◆ m_pixelCablingKey

SG::ReadCondHandleKey<ITkPixelCablingData> ITkPixelDecodingTool::m_pixelCablingKey
private
Initial value:
{this,
"PixelCablingKey", "ITkPixelCablingData", "Pixel Cabling"}

Definition at line 66 of file ITkPixelDecodingTool.h.

66 {this,
67 "PixelCablingKey", "ITkPixelCablingData", "Pixel Cabling"};

◆ m_regionSelector

ToolHandle<IRegSelTool> ITkPixelDecodingTool::m_regionSelector
private
Initial value:
{this,
"RegSelTool", "RegSelTool/RegSel_ITkPixel"}

Definition at line 78 of file ITkPixelDecodingTool.h.

78 {this,
79 "RegSelTool", "RegSelTool/RegSel_ITkPixel"};

◆ m_robDataProviderSvc

ServiceHandle<IROBDataProviderSvc> ITkPixelDecodingTool::m_robDataProviderSvc
private
Initial value:
{this,
"ROBDataProvider", "ROBDataProviderSvc"}

Definition at line 64 of file ITkPixelDecodingTool.h.

64 {this,
65 "ROBDataProvider", "ROBDataProviderSvc"};

◆ m_roiCollectionKey

SG::ReadHandleKey<TrigRoiDescriptorCollection> ITkPixelDecodingTool::m_roiCollectionKey
private
Initial value:
{this,
"RoIs", "", "RoIs to read in"}

Definition at line 80 of file ITkPixelDecodingTool.h.

80 {this,
81 "RoIs", "", "RoIs to read in"};

◆ m_roiSeeded

Gaudi::Property<bool> ITkPixelDecodingTool::m_roiSeeded
private
Initial value:
{this,
"isRoI_Seeded", false, "Use RoI"}

Definition at line 76 of file ITkPixelDecodingTool.h.

76 {this,
77 "isRoI_Seeded", false, "Use RoI"};

◆ m_varHandleArraysDeclared

bool AthCommonDataStore< AthCommonMsg< AlgTool > >::m_varHandleArraysDeclared
privateinherited

Definition at line 387 of file AthCommonDataStore.h.

◆ m_vhka

std::vector<SG::VarHandleKeyArray*> AthCommonDataStore< AthCommonMsg< AlgTool > >::m_vhka
privateinherited

Definition at line 386 of file AthCommonDataStore.h.


The documentation for this struct was generated from the following files: