ATLAS Offline Software
Loading...
Searching...
No Matches
F100DataEncodingAlg.cxx
Go to the documentation of this file.
1/*
2 Copyright (C) 2002-2025 CERN for the benefit of the ATLAS collaboration
3 */
4
7
9{
11 {
12 ATH_MSG_INFO("Running on the FPGA accelerator");
13
14 ATH_CHECK(m_pixelRDOKey.initialize());
15 ATH_CHECK(m_stripRDOKey.initialize());
16 ATH_CHECK(m_FPGAPixelRDO.initialize());
17 ATH_CHECK(m_FPGAStripRDO.initialize());
18
19 ATH_CHECK(m_FPGAPixelRDOSize.initialize());
20 ATH_CHECK(m_FPGAStripRDOSize.initialize());
21
23
25 ATH_CHECK(m_regionPixelSelector.retrieve(EnableTool{m_roiSeeded}));
26 ATH_CHECK(m_regionStripSelector.retrieve(EnableTool{m_roiSeeded}));
27 ATH_MSG_DEBUG("Running in ROI mode: "<<m_roiSeeded);
28
29
30 return StatusCode::SUCCESS;
31 }
32
33 StatusCode F100DataEncodingAlg::execute(const EventContext &ctx) const
34 {
35 ATH_MSG_DEBUG("Executing F100DataEncodingAlg");
36
37 // Get the RDOs from the SG
38 auto pixelRDOHandle = SG::makeHandle(m_pixelRDOKey, ctx);
39 auto stripRDOHandle = SG::makeHandle(m_stripRDOKey, ctx);
40 ATH_CHECK(pixelRDOHandle.isValid());
41 ATH_CHECK(stripRDOHandle.isValid());
42
43
44
45 // Encode RDO into byte stream
47 ATH_CHECK(FPGAPixelRDO.record(std::make_unique<std::vector<uint64_t> >()));
48
50 ATH_CHECK(FPGAStripRDO.record(std::make_unique<std::vector<uint64_t> >()));
51
52 std::vector<IdentifierHash> listOfPixelIds;
53 std::vector<IdentifierHash> listOfStripIds;
54
55 if (m_roiSeeded) {//enter RoI-seeded mode
57 ATH_CHECK(roiCollection.isValid());
58
59
60 for (const auto* roi : *roiCollection) {
61 m_regionPixelSelector->lookup(ctx)->HashIDList( *roi, listOfPixelIds );
62 m_regionStripSelector->lookup(ctx)->HashIDList( *roi, listOfStripIds );
63 }
64 }
65
66
67 // Encode RDOs into byte stream
68 ATH_CHECK(m_FPGADataFormatTool->convertPixelHitsToFPGADataFormat(*pixelRDOHandle, *FPGAPixelRDO, listOfPixelIds, ctx));
69 ATH_CHECK(m_FPGADataFormatTool->convertStripHitsToFPGADataFormat(*stripRDOHandle, *FPGAStripRDO, listOfStripIds, ctx));
70
71 // Store the size
72 SG::WriteHandle<int> FPGAPixelRDOSize(m_FPGAPixelRDOSize, ctx);
73 ATH_CHECK(FPGAPixelRDOSize.record(std::make_unique<int>(FPGAPixelRDO->size())));
74
75 SG::WriteHandle<int> FPGAStripRDOSize(m_FPGAStripRDOSize, ctx);
76 ATH_CHECK(FPGAStripRDOSize.record(std::make_unique<int>(FPGAStripRDO->size())));
77
78 int pixelPadLength = 8;
79 auto pixRemainder = FPGAPixelRDO->size() % pixelPadLength;
80 if (pixRemainder != 0) {
81 size_t to_add = pixelPadLength - pixRemainder;
82 FPGAPixelRDO->insert(FPGAPixelRDO->end(), to_add, 0); // append zeros
83 }
84
85 int stripPadLength = 8;
86 size_t stripRemainder = FPGAStripRDO->size() % stripPadLength;
87 if (stripRemainder != 0) {
88 size_t to_add = stripPadLength - stripRemainder;
89 FPGAStripRDO->insert(FPGAStripRDO->end(), to_add, 0); // append zeros
90 }
91
92 if (msgLvl(MSG::DEBUG)){
93 for (unsigned int i = 0; i < FPGAPixelRDO->size(); i++)
94 {
95 ATH_MSG_DEBUG("Pixel RDO[" << i << "]: " << std::hex << FPGAPixelRDO->at(i) << std::dec);
96 }
97 for (unsigned int i = 0; i < FPGAStripRDO->size(); i++)
98 {
99 ATH_MSG_DEBUG("Strip RDO[" << i << "]: " << std::hex << FPGAStripRDO->at(i) << std::dec);
100 }
101 }
102 ATH_MSG_DEBUG("Done F100DataEncodingAlg");
103
104
105
106 return StatusCode::SUCCESS;
107 }
108
109} // namespace EFTrackingFPGAIntegration
#define ATH_CHECK
Evaluate an expression and check for errors.
#define ATH_MSG_INFO(x)
#define ATH_MSG_DEBUG(x)
Exception-safe IChronoSvc caller.
bool msgLvl(const MSG::Level lvl) const
SG::WriteHandleKey< std::vector< uint64_t > > m_FPGAStripRDO
virtual StatusCode execute(const EventContext &ctx) const
SG::WriteHandleKey< std::vector< uint64_t > > m_FPGAPixelRDO
SG::ReadHandleKey< TrigRoiDescriptorCollection > m_roiCollectionKey
SG::ReadHandleKey< SCT_RDO_Container > m_stripRDOKey
SG::ReadHandleKey< PixelRDO_Container > m_pixelRDOKey
ToolHandle< FPGADataFormatTool > m_FPGADataFormatTool
Tool for formatting FPGA data.
virtual bool isValid() override final
Can the handle be successfully dereferenced?
StatusCode record(std::unique_ptr< T > data)
Record a const object to the store.
The class for enconding RDO to FPGA format.
SG::ReadCondHandle< T > makeHandle(const SG::ReadCondHandleKey< T > &key, const EventContext &ctx=Gaudi::Hive::currentContext())