ATLAS Offline Software
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 
6 #include "AthenaKernel/Chrono.h"
7 
9 {
11  {
12  ATH_MSG_INFO("Running on the FPGA accelerator");
13 
18 
21 
22  ATH_CHECK(m_FPGADataFormatTool.retrieve());
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
EFTrackingFPGAIntegration::F100DataEncodingAlg::m_FPGAStripRDOSize
SG::WriteHandleKey< int > m_FPGAStripRDOSize
Definition: F100DataEncodingAlg.h:54
EFTrackingFPGAIntegration::F100DataEncodingAlg::m_regionStripSelector
ToolHandle< IRegSelTool > m_regionStripSelector
Definition: F100DataEncodingAlg.h:45
ATH_MSG_INFO
#define ATH_MSG_INFO(x)
Definition: AthMsgStreamMacros.h:31
EFTrackingFPGAIntegration::F100DataEncodingAlg::m_roiCollectionKey
SG::ReadHandleKey< TrigRoiDescriptorCollection > m_roiCollectionKey
Definition: F100DataEncodingAlg.h:47
EFTrackingFPGAIntegration::F100DataEncodingAlg::initialize
virtual StatusCode initialize() override
Definition: F100DataEncodingAlg.cxx:10
SG::ReadHandle
Definition: StoreGate/StoreGate/ReadHandle.h:67
AthCommonMsg< Gaudi::Algorithm >::msgLvl
bool msgLvl(const MSG::Level lvl) const
Definition: AthCommonMsg.h:30
Chrono.h
Exception-safe IChronoSvc caller.
EFTrackingFPGAIntegration::F100DataEncodingAlg::execute
virtual StatusCode execute(const EventContext &ctx) const
Definition: F100DataEncodingAlg.cxx:33
SG::makeHandle
SG::ReadCondHandle< T > makeHandle(const SG::ReadCondHandleKey< T > &key, const EventContext &ctx=Gaudi::Hive::currentContext())
Definition: ReadCondHandle.h:270
F100DataEncodingAlg.h
EFTrackingFPGAIntegration::F100DataEncodingAlg::m_FPGAPixelRDO
SG::WriteHandleKey< std::vector< uint64_t > > m_FPGAPixelRDO
Definition: F100DataEncodingAlg.h:50
lumiFormat.i
int i
Definition: lumiFormat.py:85
EL::StatusCode
::StatusCode StatusCode
StatusCode definition for legacy code.
Definition: PhysicsAnalysis/D3PDTools/EventLoop/EventLoop/StatusCode.h:22
ATH_MSG_DEBUG
#define ATH_MSG_DEBUG(x)
Definition: AthMsgStreamMacros.h:29
EFTrackingFPGAIntegration::F100DataEncodingAlg::m_roiSeeded
Gaudi::Property< bool > m_roiSeeded
Definition: F100DataEncodingAlg.h:48
ATH_CHECK
#define ATH_CHECK
Definition: AthCheckMacros.h:40
EFTrackingFPGAIntegration::F100DataEncodingAlg::m_regionPixelSelector
ToolHandle< IRegSelTool > m_regionPixelSelector
Definition: F100DataEncodingAlg.h:44
SG::VarHandleKey::initialize
StatusCode initialize(bool used=true)
If this object is used as a property, then this should be called during the initialize phase.
Definition: AthToolSupport/AsgDataHandles/Root/VarHandleKey.cxx:103
EFTrackingFPGAIntegration
The class for enconding RDO to FPGA format.
Definition: F100DataEncodingAlg.h:27
EFTrackingFPGAIntegration::F100DataEncodingAlg::m_FPGADataFormatTool
ToolHandle< FPGADataFormatTool > m_FPGADataFormatTool
Tool for formatting FPGA data.
Definition: F100DataEncodingAlg.h:39
SG::ReadHandle::isValid
virtual bool isValid() override final
Can the handle be successfully dereferenced?
EFTrackingFPGAIntegration::F100DataEncodingAlg::m_FPGAPixelRDOSize
SG::WriteHandleKey< int > m_FPGAPixelRDOSize
Definition: F100DataEncodingAlg.h:53
EFTrackingFPGAIntegration::F100DataEncodingAlg::m_stripRDOKey
SG::ReadHandleKey< SCT_RDO_Container > m_stripRDOKey
Definition: F100DataEncodingAlg.h:41
EFTrackingFPGAIntegration::F100DataEncodingAlg::m_pixelRDOKey
SG::ReadHandleKey< PixelRDO_Container > m_pixelRDOKey
Definition: F100DataEncodingAlg.h:40
SG::WriteHandle
Definition: StoreGate/StoreGate/WriteHandle.h:73
SG::WriteHandle::record
StatusCode record(std::unique_ptr< T > data)
Record a const object to the store.
DEBUG
#define DEBUG
Definition: page_access.h:11
EFTrackingFPGAIntegration::F100DataEncodingAlg::m_FPGAStripRDO
SG::WriteHandleKey< std::vector< uint64_t > > m_FPGAStripRDO
Definition: F100DataEncodingAlg.h:51