ATLAS Offline Software
Loading...
Searching...
No Matches
FPGADataFormatAlg.cxx
Go to the documentation of this file.
1/*
2 Copyright (C) 2002-2024 CERN for the benefit of the ATLAS collaboration
3 */
4
7#include <fstream>
8
10{
11 ATH_CHECK(m_pixelRDOKey.initialize());
12 ATH_CHECK(m_stripRDOKey.initialize());
13
15 ATH_CHECK(m_testVectorTool.retrieve());
17 ATH_CHECK(m_xAODClusterMaker.retrieve());
19
20 ATH_CHECK(m_chronoSvc.retrieve());
21
22 return StatusCode::SUCCESS;
23}
24
25StatusCode FPGADataFormatAlg::execute(const EventContext &ctx) const
26{
27 auto pixelRDOHandle = SG::makeHandle(m_pixelRDOKey, ctx);
28 auto stripRDOHandle = SG::makeHandle(m_stripRDOKey, ctx);
29
30 std::vector<uint64_t> outputData;
31
32 std::vector<IdentifierHash> listOfPixelIds;
33 std::vector<IdentifierHash> listOfStripIds;
34
35 ATH_CHECK(m_FPGADataFormatTool->convertPixelHitsToFPGADataFormat(*pixelRDOHandle, outputData, listOfPixelIds, ctx));
36
37 // Report the output
38 ATH_MSG_DEBUG("ITK pixel encoded data");
39 int line = 0;
40 for (const auto &var : outputData)
41 {
42 ATH_MSG_DEBUG("Line: " << line << " data: " << std::hex << var);
43 line++;
44 }
45
46 outputData.clear();
47
48 {
49 Athena::Chrono chrono("ConvertStripHitsToFPGADataFormat", m_chronoSvc.get());
50 ATH_CHECK(m_FPGADataFormatTool->convertStripHitsToFPGADataFormat(*stripRDOHandle, outputData, listOfStripIds, ctx));
51 }
52
53 // Report the output
54 ATH_MSG_DEBUG("ITK Strip encoded data");
55 line = 0;
56 for (const auto &var : outputData)
57 {
58 ATH_MSG_DEBUG("Line: " << line << " data: " << std::hex << var);
59 line++;
60 }
61
62 // To make the xAOD, we need the aux data
63 std::unique_ptr<EFTrackingTransient::Metadata> metadata =
64 std::make_unique<EFTrackingTransient::Metadata>();
67
68 // Starting from here validate the conversion tool
69 // First read in the test vector
70 // Check if the path is set
71 // If the path is set, read in the test vector and call the decode function
72 EFTrackingFPGAIntegration::TVHolder pixelEDMTV("PixelEDM");
73 if (m_pixelEDMRefTVPath.empty())
74 {
75 ATH_MSG_DEBUG("The path to the pixel EDM reference test vector is not set, skipping");
76 }
77 else
78 {
79 ATH_CHECK(m_testVectorTool->prepareTV(m_pixelEDMRefTVPath, pixelEDMTV.refTV));
80 {
81 Athena::Chrono chrono("DecodePixelEDM", m_chronoSvc.get());
82 ATH_CHECK(m_outputConversionTool->decodePixelEDM(pixelEDMTV.refTV, metadata.get(), pcAux));
83 }
84 }
85
86 EFTrackingFPGAIntegration::TVHolder stripEDMTV("StripEDM");
87 if (m_stripEDMRefTVPath.empty())
88 {
89 ATH_MSG_DEBUG("The path to the strip EDM reference test vector is not set, skipping");
90 }
91 else
92 {
93 ATH_CHECK(m_testVectorTool->prepareTV(m_stripEDMRefTVPath, stripEDMTV.refTV));
94 {
95 Athena::Chrono chrono("DecodeStripEDM", m_chronoSvc.get());
96 ATH_CHECK(m_outputConversionTool->decodeStripEDM(stripEDMTV.refTV, metadata.get(), scAux));
97 }
98 }
99
100 EFTrackingFPGAIntegration::TVHolder spacePointTV("SpacePoint");
101 if (m_spacePointRefTVPath.empty())
102 {
103 ATH_MSG_DEBUG("The path to the space point reference test vector is not set, skipping");
104 }
105 else
106 {
107 ATH_CHECK(m_testVectorTool->prepareTV(m_spacePointRefTVPath, spacePointTV.refTV));
108
109 {
110 Athena::Chrono chrono("DecodeSpacePoints", m_chronoSvc.get());
111 ATH_CHECK(m_outputConversionTool->decodeSpacePoints(spacePointTV.refTV, metadata.get()));
112 }
113 }
114
115 // Print event summary
116 if (msgLvl(MSG::DEBUG))
117 {
118 ATH_MSG_DEBUG("===================Event Summary====================");
119 ATH_MSG_DEBUG("Metadata: ");
120
121 ATH_MSG_DEBUG("\tnumOfPixelClusters: " << metadata->numOfPixelClusters);
122 ATH_MSG_DEBUG("\tpcRdoIndexSize: " << metadata->pcRdoIndexSize);
123 ATH_MSG_DEBUG("Pixel Cluster RDO Index: ");
124 for (unsigned int i = 0; i < metadata->pcRdoIndexSize; i++)
125 {
126 ATH_MSG_DEBUG("\tCluster [" << i << "] has " << metadata->pcRdoIndex[i] << " RDOs");
127 }
128
129 // print the pixel cluster rdo list
130 ATH_MSG_DEBUG("Pixel Cluster RDO List: ");
131 for (const auto &rdo : pcAux.rdoList)
132 {
133 ATH_MSG_DEBUG("\t" << rdo);
134 }
135
136 ATH_MSG_DEBUG("\tnumOfStripClusters: " << metadata->numOfStripClusters);
137 ATH_MSG_DEBUG("\tscRdoIndexSize: " << metadata->scRdoIndexSize);
138 ATH_MSG_DEBUG("Strip Cluster RDO Index: ");
139 for (unsigned int i = 0; i < metadata->scRdoIndexSize; i++)
140 {
141 ATH_MSG_DEBUG("\tCluster [" << i << "] has " << metadata->scRdoIndex[i] << " RDOs");
142 }
143
144 // print the strip cluster rdo list
145 ATH_MSG_DEBUG("Strip Cluster RDO List: ");
146 for (const auto &rdo : scAux.rdoList)
147 {
148 ATH_MSG_DEBUG("\t" << rdo);
149 }
150
151 // print pcAux
152 ATH_MSG_DEBUG("Pixel Cluster Aux: ");
153 for (unsigned int i = 0; i < metadata->numOfPixelClusters; i++)
154 {
155 ATH_MSG_DEBUG("===");
156 ATH_MSG_DEBUG("\tCluster [" << i << "] has id: " << pcAux.id[i]);
157 ATH_MSG_DEBUG("\tCluster [" << i << "] has idHash: " << pcAux.idHash[i]);
158 ATH_MSG_DEBUG("\tCluster [" << i << "] has localPosition x: " << pcAux.localPosition[2 * i]);
159 ATH_MSG_DEBUG("\tCluster [" << i << "] has localPosition y: " << pcAux.localPosition[2 * i + 1]);
160 ATH_MSG_DEBUG("\tCluster [" << i << "] has localCovariance xx: " << pcAux.localCovariance[2 * i]);
161 ATH_MSG_DEBUG("\tCluster [" << i << "] has localCovariance yy: " << pcAux.localCovariance[2 * i + 1]);
162 ATH_MSG_DEBUG("\tCluster [" << i << "] has globalPosition x: " << pcAux.globalPosition[3 * i]);
163 ATH_MSG_DEBUG("\tCluster [" << i << "] has globalPosition y: " << pcAux.globalPosition[3 * i + 1]);
164 ATH_MSG_DEBUG("\tCluster [" << i << "] has globalPosition z: " << pcAux.globalPosition[3 * i + 2]);
165 ATH_MSG_DEBUG("\tCluster [" << i << "] has channelsInPhi: " << pcAux.channelsInPhi[i]);
166 ATH_MSG_DEBUG("\tCluster [" << i << "] has totalToT: " << pcAux.totalToT[i]);
167 }
168
169 // print scAux
170 ATH_MSG_DEBUG("Strip Cluster Aux: ");
171 for (unsigned int i = 0; i < metadata->numOfStripClusters; i++)
172 {
173 ATH_MSG_DEBUG("===");
174 ATH_MSG_DEBUG("\tCluster [" << i << "] has id: " << scAux.id[i]);
175 ATH_MSG_DEBUG("\tCluster [" << i << "] has idHash: " << scAux.idHash[i]);
176 ATH_MSG_DEBUG("\tCluster [" << i << "] has localPosition x: " << scAux.localPosition[i]);
177 ATH_MSG_DEBUG("\tCluster [" << i << "] has localCovariance xx: " << scAux.localCovariance[i]);
178 ATH_MSG_DEBUG("\tCluster [" << i << "] has globalPosition x: " << scAux.globalPosition[3 * i]);
179 ATH_MSG_DEBUG("\tCluster [" << i << "] has globalPosition y: " << scAux.globalPosition[3 * i + 1]);
180 ATH_MSG_DEBUG("\tCluster [" << i << "] has globalPosition z: " << scAux.globalPosition[3 * i + 2]);
181 ATH_MSG_DEBUG("\tCluster [" << i << "] has channelsInPhi: " << scAux.channelsInPhi[i]);
182 }
183 ATH_MSG_DEBUG("===================End of Event Summary====================");
184 }
185
186 // Make the xAOD
187 {
188 Athena::Chrono chrono("MakePixelContainers", m_chronoSvc.get());
189 ATH_CHECK(m_xAODClusterMaker->makePixelClusterContainer(pcAux, metadata.get(), ctx));
190 }
191
192 {
193 Athena::Chrono chrono("MakeStripContainers", m_chronoSvc.get());
194 ATH_CHECK(m_xAODClusterMaker->makeStripClusterContainer(scAux, metadata.get(), ctx));
195 }
196
197 return StatusCode::SUCCESS;
198}
#define ATH_CHECK
Evaluate an expression and check for errors.
#define ATH_MSG_DEBUG(x)
Exception-safe IChronoSvc caller.
bool msgLvl(const MSG::Level lvl) const
Exception-safe IChronoSvc caller.
Definition Chrono.h:50
SG::ReadHandleKey< SCT_RDO_Container > m_stripRDOKey
SG::ReadHandleKey< PixelRDO_Container > m_pixelRDOKey
virtual StatusCode initialize() override
Gaudi::Property< std::string > m_spacePointRefTVPath
Space point reference test vector.
ToolHandle< TestVectorTool > m_testVectorTool
Gaudi::Property< std::string > m_pixelEDMRefTVPath
Pixel L2G reference test vector.
virtual StatusCode execute(const EventContext &ctx) const override
Performs the data convertsion.
ToolHandle< OutputConversionTool > m_outputConversionTool
ToolHandle< xAODSpacePointMaker > m_xAODSpacePointMaker
Gaudi::Property< std::string > m_stripEDMRefTVPath
Strip L2G reference test vector.
ServiceHandle< IChronoStatSvc > m_chronoSvc
ToolHandle< FPGADataFormatTool > m_FPGADataFormatTool
ToolHandle< xAODClusterMaker > m_xAODClusterMaker
SG::ReadCondHandle< T > makeHandle(const SG::ReadCondHandleKey< T > &key, const EventContext &ctx=Gaudi::Hive::currentContext())
The PixelClusterAuxInput struct is used to simplify the creaction of the xAOD::PixelClusterContainer.
std::vector< unsigned long long > rdoList
The StripClusterAuxInput struct is used to simplify the creaction of the xAOD::StripClusterContainer.
std::vector< unsigned long long > rdoList