ATLAS Offline Software
Loading...
Searching...
No Matches
ITkPixelCnvTool.cxx
Go to the documentation of this file.
1/*
2Copyright (C) 2002-2025 CERN for the benefit of the ATLAS collaboration
3*/
4
5/*
6* Author: Ondra Kovanda, ondrej.kovanda at cern.ch
7* Date: 03/2025
8* Description: Top-level tool to be called from BS converter or algorithm
9*/
10
11#include "ITkPixelCnvTool.h"
15
16
17
18
19ITkPixelCnvTool::ITkPixelCnvTool(const std::string& type,const std::string& name,const IInterface* parent)
20 : AthAlgTool(type, name, parent)
21{}
22
27
28 //Initialize the sub-tools
29 ATH_CHECK(m_hitSortingTool.retrieve());
30
31 ATH_CHECK(m_encodingTool.retrieve());
32
33 ATH_CHECK(m_pixelCablingKey.initialize());
34
35 if (not m_dataRateMonTool.empty())
36 ATH_CHECK(m_dataRateMonTool.retrieve());
37
38 return StatusCode::SUCCESS;
39
40}
41
46template<class ContainerType>
47StatusCode ITkPixelCnvTool::convertToByteStream(const ContainerType* cont) const {
48
49 //Get the cabling
51 const ITkPixelCablingData* cabling = *cablingData;
52
53 //Get the full event assembler from ByteStreamCnvSvcBase
54 //SrcIdMap translates lower lvl IDs into higher lvl, e. g. ROD -> ROB, ROB -> ROS, ROS -> Det
56 ATH_CHECK(m_byteStreamCnvSvc->getFullEventAssembler(fea, "ITkPixelRawCont"));
57
58 fea->setDetEvtType(0x0);
59 fea->setLvl1TriggerType(0x0);
60
61 //Expose the buffer to be filled with the encoded data
62 //Other BS converters use FullEventAssembler<SrcIdMap>::RODDATA,
63 //which is just a typedef for std::vector<uint32_t>. Why the extra
64 //layer of renaming?
65 std::vector<uint32_t>* rod;
66
67 //sort the RDO hits based on the FE
68 const std::map<ITkPixelOnlineId, ITkPixLayout<uint16_t>> EventHitMaps = m_hitSortingTool->sortRDOHits(cont, cabling);
69
70 for (const auto& [onlineID, hitMap] : EventHitMaps){
71
72 //make a copy of the onlineID
73 uint64_t onID = (uint64_t)onlineID;
74
75 //Encode the FE hits
76 std::vector<uint32_t> encodedStream = m_encodingTool->encodeFE(hitMap, onID & 0x3000000000000000);
77
78 //Build the ROD payload header. First word is size of the packet in 32bit words
79 //including the header (16b), felix status (8b), swrod status (8b),
80 //second is the DetectorResourceID
81 uint32_t chipPayloadHeader_1 = (static_cast<uint16_t>(encodedStream.size()) + 2) << 16;
82 uint32_t chipPayloadHeader_2 = onlineID.detectorResourceID();
83
84 // passing information to the monitoring tool if initialised
85 if (not m_dataRateMonTool.empty()) {
86 m_dataRateMonTool->fill(onlineID.offlineModuleID(), encodedStream, hitMap);
87 }
88
89 //The ROD identifier, the sourceID, is defined in the cabling
90 //and passed here from the ITkPixelHitSortingTool as part of
91 //the online ID
92
93 //Create ROD and insert the payload
94 rod = fea->getRodData(onlineID.sourceID());
95 rod->insert(rod->end(), {chipPayloadHeader_1, chipPayloadHeader_2});
96 rod->insert(rod->end(), encodedStream.begin(), encodedStream.end());
97
98 }
99
100 return StatusCode::SUCCESS;
101}
102
#define ATH_CHECK
Evaluate an expression and check for errors.
InDetRawDataContainer< InDetRawDataCollection< ITkPixelRDORawData > > ITkPixelRDO_Container
InDetRawDataContainer< InDetRawDataCollection< PixelRDORawData > > PixelRDO_Container
AthAlgTool(const std::string &type, const std::string &name, const IInterface *parent)
Constructor with parameters:
Template class for assembling a full atlas raw event from subfragments.
void setLvl1TriggerType(uint8_t m)
change LVL1 Trigger Type
void setDetEvtType(uint32_t m)
change Detector Event Type
RODDATA * getRodData(uint32_t id)
get a block of ROD data
ITkPixelCnvTool(const std::string &type, const std::string &name, const IInterface *parent)
SG::ReadCondHandleKey< ITkPixelCablingData > m_pixelCablingKey
StatusCode convertToByteStream(const ContainerType *cont) const
Take ITkPixelRDO_Container or PixelRDO_Container and translate it to bytestream.
virtual StatusCode initialize() override
Retrieve helper tools.
ServiceHandle< IByteStreamCnvSvc > m_byteStreamCnvSvc
ToolHandle< ITkPixelEncodingTool > m_encodingTool
ToolHandle< ITkPixelHitSortingTool > m_hitSortingTool
ToolHandle< ITkPixelDataRateMonTool > m_dataRateMonTool