Loading [MathJax]/extensions/tex2jax.js
ATLAS Offline Software
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Modules Pages
Public Member Functions | Private Member Functions | Private Attributes | List of all members
FPGADataFormatTool Class Reference

#include <FPGADataFormatTool.h>

Inheritance diagram for FPGADataFormatTool:
Collaboration diagram for FPGADataFormatTool:

Public Member Functions

virtual StatusCode initialize () override
 
virtual StatusCode convertPixelHitsToFPGADataFormat (const PixelRDO_Container &pixelRDO, std::vector< uint64_t > &encodedData, const EventContext &ctx) const override
 Covert the Pixel RDOs to the test vector format as requited by FPGA EF tracking alogrithms. More...
 
virtual StatusCode convertStripHitsToFPGADataFormat (const SCT_RDO_Container &stripRDO, std::vector< uint64_t > &encodedData, const EventContext &ctx) const override
 Covert the Strip RDOs to the test vector format as requited by FPGA EF tracking alogrithms. More...
 

Private Member Functions

StatusCode convertPixelRDO (const PixelRDO_Container &pixelRDO, std::vector< uint64_t > &encodedData, const EventContext &ctx) const
 
StatusCode convertStripRDO (const SCT_RDO_Container &stripRDO, std::vector< uint64_t > &encodedData, const EventContext &ctx) const
 
StatusCode fillHeader (std::vector< uint64_t > &encodedData) const
 
StatusCode fillFooter (std::vector< uint64_t > &encodedData) const
 
StatusCode fillModuleHeader (const InDetDD::SiDetectorElement *sielement, std::vector< uint64_t > &encodedData) const
 

Private Attributes

const PixelIDm_pixelId = nullptr
 
const SCT_IDm_sctId = nullptr
 
const InDetDD::SiDetectorManagerm_PIX_mgr = nullptr
 
const InDetDD::SiDetectorManagerm_SCT_mgr = nullptr
 

Detailed Description

Definition at line 20 of file FPGADataFormatTool.h.

Member Function Documentation

◆ convertPixelHitsToFPGADataFormat()

StatusCode FPGADataFormatTool::convertPixelHitsToFPGADataFormat ( const PixelRDO_Container pixelRDO,
std::vector< uint64_t > &  encodedData,
const EventContext &  ctx 
) const
overridevirtual

Covert the Pixel RDOs to the test vector format as requited by FPGA EF tracking alogrithms.

Definition at line 20 of file FPGADataFormatTool.cxx.

23  {
24 
25  // Fill the event header
26  ATH_CHECK(fillHeader(encodedData));
27 
28  // Convert the strip RDO
29  ATH_CHECK(convertPixelRDO(pixelRDO, encodedData, ctx));
30 
31  // Fill the event footer
32  ATH_CHECK(fillFooter(encodedData));
33 
34 
35  return StatusCode::SUCCESS;
36 }

◆ convertPixelRDO()

StatusCode FPGADataFormatTool::convertPixelRDO ( const PixelRDO_Container pixelRDO,
std::vector< uint64_t > &  encodedData,
const EventContext &  ctx 
) const
private

Definition at line 57 of file FPGADataFormatTool.cxx.

61  {
62 
63  bool filledHeader = false;
64  for (const InDetRawDataCollection<PixelRDORawData>* pixel_rdoCollection : pixelRDO)
65  {
66  if (pixel_rdoCollection == nullptr) { continue; }
67 
68  // loop on all RDOs
69  for (const PixelRDORawData* pixelRawData : *pixel_rdoCollection)
70  {
71  Identifier rdoId = pixelRawData->identify();
72  // get the det element from the det element collection
73  const InDetDD::SiDetectorElement* sielement = m_PIX_mgr->getDetectorElement(rdoId);
74 
75  // Fill the module header
76  if(!filledHeader)
77  {
78  ATH_CHECK(fillModuleHeader(sielement, encodedData));
79  filledHeader = true;
80  }
81 
82  // Get the pixel word
84  (pixelRawData == pixel_rdoCollection->back()), // last
85  m_pixelId->phi_index(rdoId), // ROW
86  m_pixelId->eta_index(rdoId), // COL
87  pixelRawData->getToT(), // TOT
88  pixelRawData->getLVL1A(), // Lvl!
89  0 // Spare
90  );
91 
92  // Push the word into the vector
93  encodedData.push_back(FPGADataFormatUtilities::get_dataformat_PIXEL_EF_RDO(pixelWord));
94  //}
95  } // end for each RDO in the collection
96 
97  // reset the header
98  filledHeader = false;
99 
100  } // for each pixel RDO collection
101 
102  return StatusCode::SUCCESS;
103 }

◆ convertStripHitsToFPGADataFormat()

StatusCode FPGADataFormatTool::convertStripHitsToFPGADataFormat ( const SCT_RDO_Container stripRDO,
std::vector< uint64_t > &  encodedData,
const EventContext &  ctx 
) const
overridevirtual

Covert the Strip RDOs to the test vector format as requited by FPGA EF tracking alogrithms.

Definition at line 38 of file FPGADataFormatTool.cxx.

41  {
42 
43  // Fill the event header
44  ATH_CHECK(fillHeader(encodedData));
45 
46  // Convert the strip RDO
47  ATH_CHECK(convertStripRDO(stripRDO, encodedData, ctx));
48 
49  // Fill the event footer
50  ATH_CHECK(fillFooter(encodedData));
51 
52  return StatusCode::SUCCESS;
53 }

◆ convertStripRDO()

StatusCode FPGADataFormatTool::convertStripRDO ( const SCT_RDO_Container stripRDO,
std::vector< uint64_t > &  encodedData,
const EventContext &  ctx 
) const
private

Definition at line 105 of file FPGADataFormatTool.cxx.

109  {
110  constexpr int MaxChannelinStripRow = 128;
111  long unsigned int stripNumber = 0;
112  bool filledHeader = false;
113 
114  uint64_t packedWord = 0;
115  bool firstClusterFilled = false;
116 
117  for (const InDetRawDataCollection<SCT_RDORawData>* SCT_Collection : stripRDO) {
118  if (SCT_Collection == nullptr) { continue; }
119 
120  std::map<int, bool> firedStrips;
121  std::map<int, const SCT_RDORawData*> firedStripsToRDO;
122 
123  // Preprocess the SCT collection hits to get information for encoding strip in ITK format
124  // All fired strips are stored in a map to get an overview of the full module that should be
125  // used to encode the data into the ITk format.
126  for (const SCT_RDORawData* sctRawData : *SCT_Collection) {
127  const Identifier rdoId = sctRawData->identify();
128  const int baseLineStrip{m_sctId->strip(rdoId)};
129  for (int i = 0; i < sctRawData->getGroupSize(); i++) {
130  firedStrips[baseLineStrip + i] = true;
131  firedStripsToRDO[baseLineStrip + i] = sctRawData;
132  }
133  }
134  // Loop over the fired hits and encode them in the ITk strips hit map
135  // Finds unique hits in the list that can be encoded and don't overlap
136  std::map<int, int> stripEncodingForITK;
137  std::map<int, const SCT_RDORawData* > stripEncodingForITKToRDO;
138  for (const auto& [stripID, fired] : firedStrips) {
139  // Skip strips that have already been used in a cluster
140  if (!fired) continue;
141 
142  // Check the next 3 hits if they exist and have a hit in them
143  std::bitset<3> hitMap;
144  int currChipID = stripID / MaxChannelinStripRow;
145  int maxStripIDForCurrChip = (currChipID + 1) * MaxChannelinStripRow;
146 
147  for (int i = 0; i < 3; i++) {
148  // Do not cluster strips that are outside the range of this chip
149  if ((stripID + 1 + i) >= maxStripIDForCurrChip) continue;
150  if (firedStrips.find(stripID + 1 + i) != firedStrips.end()) {
151  if (firedStrips.at(stripID + 1 + i)) {
152  hitMap[2 - i] = 1;
153  firedStrips[stripID + 1 + i] = false;
154  } else {
155  hitMap[2 - i] = 0;
156  }
157  }
158  }
159 
160  // Encode the hit map into an integer
161  stripEncodingForITK[stripID] = static_cast<int>(hitMap.to_ulong());
162  stripEncodingForITKToRDO[stripID] = firedStripsToRDO[stripID];
163  }
164 
165  stripNumber = 0;
166  firstClusterFilled = false;
167 
168  // Process each fired strip and encode it
169  for (const auto& [stripID, encoding] : stripEncodingForITK) {
170  const SCT_RDORawData* sctRawData = stripEncodingForITKToRDO[stripID];
171  const Identifier rdoId = sctRawData->identify();
172  const InDetDD::SiDetectorElement* sielement = m_SCT_mgr->getDetectorElement(rdoId);
173 
174  // Fill the module header if not already filled
175  if (!filledHeader) {
176  if (!fillModuleHeader(sielement, encodedData)) return StatusCode::FAILURE;
177  filledHeader = true;
178  }
179 
180  // Compute chip ID and ITk strip ID
181  int chipID = stripID / MaxChannelinStripRow;
182  int ITkStripID = stripID % MaxChannelinStripRow;
183 
184  // Adjust for row offset based on the eta module index
185  int offset = m_sctId->eta_module(rdoId) % 2;
186  if (m_sctId->barrel_ec(rdoId) == 0) {
187  offset = (std::abs(m_sctId->eta_module(rdoId)) - 1) % 2;
188  }
189  ITkStripID += offset * MaxChannelinStripRow;
190  stripNumber++;
191  // Determine if this is the last cluster in the module
192  bool lastBit = (stripNumber == stripEncodingForITK.size());
193 
194  // Create the encoded strip word
196  lastBit, // last bit indicating module boundary
197  chipID, // chip ID
198  ITkStripID, // cluster number
199  stripEncodingForITK.at(stripID), // cluster map
200  0 // spare bits
201  );
202 
204 
205  // **Pack two clusters into a single 64-bit word**
206  if (!firstClusterFilled) {
207  packedWord = (static_cast<uint64_t>(encodedCluster) << 32); // Store first cluster in upper 32 bits
208  firstClusterFilled = true;
209  } else {
210  packedWord |= static_cast<uint64_t>(encodedCluster); // Store second cluster in lower 32 bits
211  encodedData.push_back(packedWord); // Push the full packed word
212  firstClusterFilled = false; // Reset flag
213  packedWord = 0; // Clear for the next pair
214  }
215 
216  // If this is the last cluster in the module and a single cluster is left, push it
217  if (lastBit && firstClusterFilled) {
218  encodedData.push_back(packedWord);
219  }
220 
221  }
222  // Reset the header flag for the next module
223  filledHeader = false;
224  } // end for each RDO in the strip collection
225 
226  return StatusCode::SUCCESS;
227 }

◆ fillFooter()

StatusCode FPGADataFormatTool::fillFooter ( std::vector< uint64_t > &  encodedData) const
private

Definition at line 247 of file FPGADataFormatTool.cxx.

248 {
249  // Fill the event header
251  encodedData.push_back(FPGADataFormatUtilities::get_dataformat_EVT_FTR_w1(footer_w1));
252 
253  // Fill the event header
254  auto footer_w2 = FPGADataFormatUtilities::fill_EVT_FTR_w2 (0);
255  encodedData.push_back(FPGADataFormatUtilities::get_dataformat_EVT_FTR_w2(footer_w2));
256 
257  // Fill the event header
258  auto footer_w3 = FPGADataFormatUtilities::fill_EVT_FTR_w3 (encodedData.size(), 44939973);
259  encodedData.push_back(FPGADataFormatUtilities::get_dataformat_EVT_FTR_w3(footer_w3));
260 
261  return StatusCode::SUCCESS;
262 }

◆ fillHeader()

StatusCode FPGADataFormatTool::fillHeader ( std::vector< uint64_t > &  encodedData) const
private

Definition at line 230 of file FPGADataFormatTool.cxx.

231 {
232  // Fill the event header
234  encodedData.push_back(FPGADataFormatUtilities::get_dataformat_EVT_HDR_w1(header_w1));
235 
236  // Fill the event header
237  auto header_w2 = FPGADataFormatUtilities::fill_EVT_HDR_w2 (242000, 0);
238  encodedData.push_back(FPGADataFormatUtilities::get_dataformat_EVT_HDR_w2(header_w2));
239 
240  // Fill the event header
241  auto header_w3 = FPGADataFormatUtilities::fill_EVT_HDR_w3 (0, 0);
242  encodedData.push_back(FPGADataFormatUtilities::get_dataformat_EVT_HDR_w3(header_w3));
243 
244  return StatusCode::SUCCESS;
245 }

◆ fillModuleHeader()

StatusCode FPGADataFormatTool::fillModuleHeader ( const InDetDD::SiDetectorElement sielement,
std::vector< uint64_t > &  encodedData 
) const
private

Definition at line 264 of file FPGADataFormatTool.cxx.

265 {
267  sielement->identifyHash().value(), 0);
268  encodedData.push_back(FPGADataFormatUtilities::get_dataformat_M_HDR_w1(mod_w1));
269 
270  return StatusCode::SUCCESS;
271 }

◆ initialize()

StatusCode FPGADataFormatTool::initialize ( )
overridevirtual

Definition at line 9 of file FPGADataFormatTool.cxx.

9  {
10  ATH_MSG_INFO("Initializing IEFTrackingFPGADataFormatTool tool");
11 
12  ATH_CHECK(detStore()->retrieve(m_PIX_mgr, "ITkPixel"));
13  ATH_CHECK(detStore()->retrieve(m_pixelId, "PixelID"));
14  ATH_CHECK(detStore()->retrieve(m_SCT_mgr, "ITkStrip"));
15  ATH_CHECK(detStore()->retrieve(m_sctId, "SCT_ID"));
16 
17  return StatusCode::SUCCESS;
18 }

Member Data Documentation

◆ m_PIX_mgr

const InDetDD::SiDetectorManager* FPGADataFormatTool::m_PIX_mgr = nullptr
private

Definition at line 46 of file FPGADataFormatTool.h.

◆ m_pixelId

const PixelID* FPGADataFormatTool::m_pixelId = nullptr
private

Definition at line 43 of file FPGADataFormatTool.h.

◆ m_SCT_mgr

const InDetDD::SiDetectorManager* FPGADataFormatTool::m_SCT_mgr = nullptr
private

Definition at line 47 of file FPGADataFormatTool.h.

◆ m_sctId

const SCT_ID* FPGADataFormatTool::m_sctId = nullptr
private

Definition at line 44 of file FPGADataFormatTool.h.


The documentation for this class was generated from the following files:
python.PyKernel.retrieve
def retrieve(aClass, aKey=None)
Definition: PyKernel.py:110
FPGADataFormatTool::fillFooter
StatusCode fillFooter(std::vector< uint64_t > &encodedData) const
Definition: FPGADataFormatTool.cxx:247
PixelID::phi_index
int phi_index(const Identifier &id) const
Definition: PixelID.h:658
FPGADataFormatTool::fillHeader
StatusCode fillHeader(std::vector< uint64_t > &encodedData) const
Definition: FPGADataFormatTool.cxx:230
InDetDD::SiDetectorManager::getDetectorElement
virtual SiDetectorElement * getDetectorElement(const Identifier &id) const =0
access to individual elements using Identifier or IdentiferHash
FPGADataFormatTool::convertPixelRDO
StatusCode convertPixelRDO(const PixelRDO_Container &pixelRDO, std::vector< uint64_t > &encodedData, const EventContext &ctx) const
Definition: FPGADataFormatTool.cxx:57
FPGADataFormatUtilities::get_dataformat_EVT_HDR_w3
uint64_t get_dataformat_EVT_HDR_w3(const EVT_HDR_w3 &in)
Definition: FPGADataFormatUtilities.h:113
FPGADataFormatUtilities::get_dataformat_EVT_FTR_w2
uint64_t get_dataformat_EVT_FTR_w2(const EVT_FTR_w2 &in)
Definition: FPGADataFormatUtilities.h:249
ATH_MSG_INFO
#define ATH_MSG_INFO(x)
Definition: AthMsgStreamMacros.h:31
IdentifierHash::value
unsigned int value() const
xAOD::uint32_t
setEventNumber uint32_t
Definition: EventInfo_v1.cxx:127
FPGADataFormatUtilities::EVT_HDR_FLAG
const int EVT_HDR_FLAG
Definition: FPGADataFormatUtilities.h:20
FPGADataFormatUtilities::fill_STRIP_EF_RDO
STRIP_EF_RDO fill_STRIP_EF_RDO(const uint64_t &last, const uint64_t &chipid, const uint64_t &strip_num, const uint64_t &cluster_map, const uint64_t &spare)
Definition: FPGADataFormatUtilities.h:2309
Identifier::get_identifier32
Identifier32 get_identifier32() const
Get the 32-bit version Identifier, will be invalid if >32 bits needed.
FPGADataFormatUtilities::get_dataformat_M_HDR_w1
uint64_t get_dataformat_M_HDR_w1(const M_HDR_w1 &in)
Definition: FPGADataFormatUtilities.h:343
SCT_RDORawData
Definition: SCT_RDORawData.h:24
SCT_ID::barrel_ec
int barrel_ec(const Identifier &id) const
Values of different levels (failure returns 0)
Definition: SCT_ID.h:728
FPGADataFormatTool::m_PIX_mgr
const InDetDD::SiDetectorManager * m_PIX_mgr
Definition: FPGADataFormatTool.h:46
FPGADataFormatUtilities::fill_EVT_HDR_w2
EVT_HDR_w2 fill_EVT_HDR_w2(const uint64_t &runnumber, const uint64_t &time)
Definition: FPGADataFormatUtilities.h:129
FPGADataFormatUtilities::fill_EVT_FTR_w3
EVT_FTR_w3 fill_EVT_FTR_w3(const uint64_t &word_count, const uint64_t &crc)
Definition: FPGADataFormatUtilities.h:276
Identifier32::get_compact
value_type get_compact() const
Get the compact id.
Definition: Identifier32.h:44
InDetDD::SolidStateDetectorElementBase::identifyHash
virtual IdentifierHash identifyHash() const override final
identifier hash (inline)
FPGADataFormatUtilities::fill_EVT_HDR_w1
EVT_HDR_w1 fill_EVT_HDR_w1(const uint64_t &flag, const uint64_t &l0id, const uint64_t &bcid, const uint64_t &spare)
Definition: FPGADataFormatUtilities.h:120
FPGADataFormatUtilities::M_HDR_FLAG
const int M_HDR_FLAG
Definition: FPGADataFormatUtilities.h:308
FPGADataFormatTool::convertStripRDO
StatusCode convertStripRDO(const SCT_RDO_Container &stripRDO, std::vector< uint64_t > &encodedData, const EventContext &ctx) const
Definition: FPGADataFormatTool.cxx:105
FPGADataFormatUtilities::get_dataformat_PIXEL_EF_RDO
uint64_t get_dataformat_PIXEL_EF_RDO(const PIXEL_EF_RDO &in)
Definition: FPGADataFormatUtilities.h:2201
FPGADataFormatUtilities::get_dataformat_EVT_HDR_w2
uint64_t get_dataformat_EVT_HDR_w2(const EVT_HDR_w2 &in)
Definition: FPGADataFormatUtilities.h:106
FPGADataFormatUtilities::get_dataformat_EVT_FTR_w3
uint64_t get_dataformat_EVT_FTR_w3(const EVT_FTR_w3 &in)
Definition: FPGADataFormatUtilities.h:255
FPGADataFormatUtilities::EVT_FTR_FLAG
const int EVT_FTR_FLAG
Definition: FPGADataFormatUtilities.h:176
lumiFormat.i
int i
Definition: lumiFormat.py:85
generateReferenceFile.encoding
encoding
Definition: generateReferenceFile.py:15
FPGADataFormatUtilities::get_dataformat_STRIP_EF_RDO
uint64_t get_dataformat_STRIP_EF_RDO(const STRIP_EF_RDO &in)
Definition: FPGADataFormatUtilities.h:2294
InDetRawDataCollection
Definition: InDetRawDataCollection.h:31
FPGADataFormatTool::fillModuleHeader
StatusCode fillModuleHeader(const InDetDD::SiDetectorElement *sielement, std::vector< uint64_t > &encodedData) const
Definition: FPGADataFormatTool.cxx:264
PixelID::eta_index
int eta_index(const Identifier &id) const
Definition: PixelID.h:664
xAOD::uint64_t
uint64_t
Definition: EventInfo_v1.cxx:123
ATH_CHECK
#define ATH_CHECK
Definition: AthCheckMacros.h:40
FPGADataFormatUtilities::fill_EVT_HDR_w3
EVT_HDR_w3 fill_EVT_HDR_w3(const uint64_t &status, const uint64_t &crc)
Definition: FPGADataFormatUtilities.h:136
python.PyKernel.detStore
detStore
Definition: PyKernel.py:41
FPGADataFormatTool::m_pixelId
const PixelID * m_pixelId
Definition: FPGADataFormatTool.h:43
InDetDD::SiDetectorElement
Definition: SiDetectorElement.h:109
FPGADataFormatTool::m_sctId
const SCT_ID * m_sctId
Definition: FPGADataFormatTool.h:44
FPGADataFormatUtilities::get_dataformat_EVT_FTR_w1
uint64_t get_dataformat_EVT_FTR_w1(const EVT_FTR_w1 &in)
Definition: FPGADataFormatUtilities.h:241
FPGADataFormatUtilities::fill_PIXEL_EF_RDO
PIXEL_EF_RDO fill_PIXEL_EF_RDO(const uint64_t &last, const uint64_t &row, const uint64_t &col, const uint64_t &tot, const uint64_t &lvl1, const uint64_t &spare)
Definition: FPGADataFormatUtilities.h:2212
SCT_ID::strip
int strip(const Identifier &id) const
Definition: SCT_ID.h:764
SCT_ID::eta_module
int eta_module(const Identifier &id) const
Definition: SCT_ID.h:746
convertTimingResiduals.offset
offset
Definition: convertTimingResiduals.py:71
PixelRDORawData
Definition: PixelRDORawData.h:23
InDetRawData::identify
virtual Identifier identify() const override final
Definition: InDetRawData.h:41
FPGADataFormatTool::m_SCT_mgr
const InDetDD::SiDetectorManager * m_SCT_mgr
Definition: FPGADataFormatTool.h:47
FPGADataFormatUtilities::fill_EVT_FTR_w2
EVT_FTR_w2 fill_EVT_FTR_w2(const uint64_t &error_flags)
Definition: FPGADataFormatUtilities.h:270
FPGADataFormatUtilities::fill_EVT_FTR_w1
EVT_FTR_w1 fill_EVT_FTR_w1(const uint64_t &flag, const uint64_t &spare, const uint64_t &hdr_crc)
Definition: FPGADataFormatUtilities.h:262
FPGADataFormatUtilities::get_dataformat_EVT_HDR_w1
uint64_t get_dataformat_EVT_HDR_w1(const EVT_HDR_w1 &in)
Definition: FPGADataFormatUtilities.h:97
InDetDD::SolidStateDetectorElementBase::identify
virtual Identifier identify() const override final
identifier of this detector element (inline)
FPGADataFormatUtilities::fill_M_HDR_w1
M_HDR_w1 fill_M_HDR_w1(const uint64_t &flag, const uint64_t &modid, const uint64_t &modhash, const uint64_t &spare)
Definition: FPGADataFormatUtilities.h:352
Identifier
Definition: IdentifierFieldParser.cxx:14