13 ATH_CHECK(m_xAODPixelClusterContainerKeys.initialize());
14 ATH_CHECK(m_xAODStripClusterContainerKeys.initialize());
15 ATH_CHECK(m_xAODSpacePointContainerKeys.initialize());
16 ATH_CHECK(m_FPGARoadsKey.initialize(!m_isDataPrep));
17 ATH_CHECK(m_FPGAProtoTrackCollections.initialize(!m_isDataPrep));
18 ATH_CHECK(m_FPGATracksKey.initialize(!m_isDataPrep));
19 ATH_CHECK(m_ActsTrackCollections.initialize(!m_isDataPrep));
21 ATH_CHECK(m_ActsInspectionTool.retrieve());
22 return StatusCode::SUCCESS;
28 std::vector<SG::ReadHandle<xAOD::PixelClusterContainer>> xAODPixelClusterContainers = m_xAODPixelClusterContainerKeys.makeHandles(ctx);
31 if (!clusterContainer.isValid()) {
33 return StatusCode::FAILURE;
35 processxAODClusters<xAOD::PixelCluster>(clusterContainer);
38 std::vector<SG::ReadHandle<xAOD::StripClusterContainer>> xAODStripClusterContainers = m_xAODStripClusterContainerKeys.makeHandles(ctx);
41 if (!clusterContainer.isValid()) {
43 return StatusCode::FAILURE;
45 processxAODClusters<xAOD::StripCluster>(clusterContainer);
48 std::vector<SG::ReadHandle<xAOD::SpacePointContainer>> xAODSpacePointContainers = m_xAODSpacePointContainerKeys.makeHandles(ctx);
51 if (!spContainer.isValid()) {
54 else {processxAODSpacePoints(spContainer);}
56 if (!m_isDataPrep.value()) {
59 if (!FPGATrackSimRoads.
isValid()) {
60 ATH_MSG_ERROR(
"Could not find FPGA Roads Collection with key " << FPGATrackSimRoads.
key());
61 return StatusCode::FAILURE;
63 processFPGARoads(FPGATrackSimRoads);
67 if (!FPGATrackSimTracks.
isValid()) {
68 ATH_MSG_ERROR(
"Could not find FPGA Track Collection with key " << FPGATrackSimTracks.
key());
69 return StatusCode::FAILURE;
71 processFPGATracks(FPGATrackSimTracks);
74 std::vector<SG::ReadHandle<ActsTrk::ProtoTrackCollection>> FPGATrackSimProtoTracks = m_FPGAProtoTrackCollections.makeHandles(ctx);
77 if (!prototrackContainer.isValid()) {
78 ATH_MSG_ERROR(
"Invalid SG key " << prototrackContainer.key());
79 return StatusCode::FAILURE;
81 processFPGAPrototracks(prototrackContainer);
85 std::vector<SG::ReadHandle<ActsTrk::TrackContainer>> FPGAActsTracks = m_ActsTrackCollections.makeHandles(ctx);
88 if (actsTrackContainer.cptr())
ATH_MSG_DEBUG(
"Proccessing " << actsTrackContainer.key());
91 m_allActsTracks.try_emplace(actsTrackContainer.key(), std::vector<FPGATrackSimActsEventTracks>{});
94 m_allActsTracks[actsTrackContainer.key()].push_back(m_ActsInspectionTool->getActsTracks(*(actsTrackContainer.cptr())));
97 m_actsTrackStats.try_emplace(actsTrackContainer.key(), std::map<
uint32_t, std::vector<uint32_t>>{});
99 m_actsTrackStats[actsTrackContainer.key()].emplace(
100 Acts::TrackStateFlag::OutlierFlag, std::vector<uint32_t>{});
101 m_actsTrackStats[actsTrackContainer.key()].emplace(
102 Acts::TrackStateFlag::HoleFlag, std::vector<uint32_t>{});
103 m_actsTrackStats[actsTrackContainer.key()].emplace(
104 Acts::TrackStateFlag::MeasurementFlag, std::vector<uint32_t>{});
106 for (
const auto&
track : m_allActsTracks[actsTrackContainer.key()].back()) {
107 uint32_t t_nOutliers = 0, t_nMeasurements = 0, t_nHoles = 0;
108 for (
const auto& measurement :
track->trackMeasurements)
110 if (measurement->outlierFlag) ++t_nOutliers;
111 if (measurement->measurementFlag) ++t_nMeasurements;
112 if (measurement->holeFlag) ++t_nHoles;
114 m_actsTrackStats[actsTrackContainer.key()][Acts::TrackStateFlag::OutlierFlag].push_back(t_nOutliers);
115 m_actsTrackStats[actsTrackContainer.key()][Acts::TrackStateFlag::HoleFlag].push_back(t_nHoles);
116 m_actsTrackStats[actsTrackContainer.key()][Acts::TrackStateFlag::MeasurementFlag].push_back(t_nMeasurements);
118 if (m_printoutForEveryEvent)
ATH_MSG_INFO(m_ActsInspectionTool->getPrintoutActsEventTracks(m_allActsTracks[actsTrackContainer.key()].back()));
121 return StatusCode::SUCCESS;
128 if (!m_isDataPrep.value()) {
130 std::string summaryTableFPGATracks =
"\n"
131 "Number of measurements for FPGA Tracks\n"
132 "|-----------------------------------|\n"
133 "| | min | max | Avg |\n"
134 "|-----------------------------------|\n";
136 if (not m_pixelClustersPerFPGATrack.empty()) {
137 summaryTableFPGATracks +=
std::format(
"| Pixels | {:>4} | {:>4} | {:>10.2f} |\n",
138 *std::min_element(m_pixelClustersPerFPGATrack.begin(), m_pixelClustersPerFPGATrack.end()),
139 *std::max_element(m_pixelClustersPerFPGATrack.begin(), m_pixelClustersPerFPGATrack.end()),
140 std::accumulate(m_pixelClustersPerFPGATrack.begin(), m_pixelClustersPerFPGATrack.end(), 0.0) / m_pixelClustersPerFPGATrack.size());
142 else summaryTableFPGATracks +=
std::format(
"| Pixels | ---- | ---- | inf |\n");
144 if (not m_stripClustersPerFPGATrack.empty()) {
145 summaryTableFPGATracks +=
std::format(
"| Strips | {:>4} | {:>4} | {:>10.2f} |\n",
146 *std::min_element(m_stripClustersPerFPGATrack.begin(), m_stripClustersPerFPGATrack.end()),
147 *std::max_element(m_stripClustersPerFPGATrack.begin(), m_stripClustersPerFPGATrack.end()),
148 std::accumulate(m_stripClustersPerFPGATrack.begin(), m_stripClustersPerFPGATrack.end(), 0.0) / m_stripClustersPerFPGATrack.size());
150 else summaryTableFPGATracks +=
std::format(
"| Strips | ---- | ---- | inf |\n");
152 summaryTableFPGATracks +=
"|-----------------------------------|";
157 std::string summaryTableFPGAPrototracks =
std::format(
"\n"
158 "Number of measurements for FPGA Prototracks\n"
159 "|-----------------------------------|\n"
160 "| | min | max | Avg |\n"
161 "|-----------------------------------|\n");
163 if (not m_pixelClustersPerPrototrack.empty()) {
164 summaryTableFPGAPrototracks +=
std::format(
"| Pixels | {:>4} | {:>4} | {:>10.2f} |\n",
165 *std::min_element(m_pixelClustersPerPrototrack.begin(), m_pixelClustersPerPrototrack.end()),
166 *std::max_element(m_pixelClustersPerPrototrack.begin(), m_pixelClustersPerPrototrack.end()),
167 std::accumulate(m_pixelClustersPerPrototrack.begin(), m_pixelClustersPerPrototrack.end(), 0.0) / m_pixelClustersPerPrototrack.size());
169 else summaryTableFPGAPrototracks +=
std::format(
"| Pixels | ---- | ---- | inf |\n");
171 if (not m_stripClustersPerPrototrack.empty()) {
172 summaryTableFPGAPrototracks +=
std::format(
"| Strips | {:>4} | {:>4} | {:>10.2f} |\n",
173 *std::min_element(m_stripClustersPerPrototrack.begin(), m_stripClustersPerPrototrack.end()),
174 *std::max_element(m_stripClustersPerPrototrack.begin(), m_stripClustersPerPrototrack.end()),
175 std::accumulate(m_stripClustersPerPrototrack.begin(), m_stripClustersPerPrototrack.end(), 0.0) / m_stripClustersPerPrototrack.size());
177 else summaryTableFPGAPrototracks +=
std::format(
"| Strips | ---- | ---- | inf |\n");
179 summaryTableFPGAPrototracks +=
"|-----------------------------------|";
183 ATH_MSG_INFO(m_ActsInspectionTool->getPrintoutStatistics(m_actsTrackStats));
184 return StatusCode::SUCCESS;
187 template <
class XAOD_CLUSTER>
190 if (m_printoutForEveryEvent) printxAODClusters(clusterContainer);
193 template <
class XAOD_CLUSTER>
196 std::string mainTable =
"\n"
197 "|=========================================================================================|\n"
198 "| # | Global coordinates | Hash ID | Identifier |\n"
199 "| | x | y | z | | |\n"
200 "|-----------------------------------------------------------------------------------------|\n";
202 for (
const auto& cluster : *clusterContainer)
205 mainTable +=
std::format(
"| {:>6} | {:>12} | {:>12} | {:>12} | {:>12} | {:>18} |\n",
207 cluster->globalPosition().x(),
208 cluster->globalPosition().y(),
209 cluster->globalPosition().z(),
210 cluster->identifierHash(),
211 cluster->identifier());
213 mainTable +=
"|=========================================================================================|";
214 ATH_MSG_INFO(
"Printout of xAOD clusters coming from " << clusterContainer.key() << mainTable );
220 if (m_printoutForEveryEvent) printxAODSpacePoints(spContainer);
225 std::string mainTable =
"\n"
226 "|============================================================================|\n"
227 "| # | Global coordinates | element ID list |\n"
228 "| | x | y | z | |\n"
229 "|----------------------------------------------------------------------------|\n";
231 for (
const auto& sp : *spContainer)
234 mainTable +=
std::format(
"| {:>6} | {:>12} | {:>12} | {:>12} | {:>9}, {:>9} |\n",
236 sp->globalPosition().x(),
237 sp->globalPosition().y(),
238 sp->globalPosition().z(),
239 sp->elementIdList()[0],
240 sp->elementIdList().size() == 2 ? sp->elementIdList()[1] : 0);
242 mainTable +=
"|=========================================================================================|";
243 ATH_MSG_INFO(
"Printout of xAOD space points coming from " << spContainer.key() << mainTable );
249 if (m_printoutForEveryEvent) printFPGARoads(FPGARoads);
254 std::string mainTable =
"\n"
255 "|--------------------------------------------------------------------------------------------------|\n"
256 "| # | SubRegion | xBin | yBin | X | Y | RoadID |\n"
257 "|--------------------------------------------------------------------------------------------------|\n";
259 unsigned int roadCounter = 0, hitCounter = 0;
263 mainTable +=
std::format(
"| {:>6} | {:>11} | {:>10} | {:>10} | {:>12} | {:>12} | {:>12} |\n",
272 "| __________________________________________________________________________________________|\n"
273 "| | layer | ## | type | Global coordinates | isReal |\n"
274 "| | | | | x | y | z | |\n"
275 "| |.........................................................................................|\n";
276 for (
unsigned int i = 0;
i < road.getNLayers(); ++
i)
279 const std::vector<std::shared_ptr<const FPGATrackSimHit>>&
hits = road.getHits(
i);
280 for (
auto const& hit :
hits)
288 mainTable +=
std::format(
"| | {:>9} | {:>6} | {:>8} | {:>13} | {:>13} | {:>13} | {:>7} |\n",
289 (hit->isMapped() ? hit->getLayer() : 9999),
291 (hit->isPixel() ?
"Pixel" : hit->isStrip() ?
"Strip" :
"FAILED"),
297 ATH_MSG_ERROR(
"Exception while processing FPGATrackSimHit: " <<
e.what());
302 mainTable +=
"|--------------------------------------------------------------------------------------------------|\n";
304 ATH_MSG_INFO(
"List of FPGA roads for " << FPGARoads.key() << mainTable);
310 for (
auto const&
track : *FPGATracks)
312 const std::vector <FPGATrackSimHit>&
hits =
track.getFPGATrackSimHits();
313 uint32_t pixelHits = 0, stripHits = 0;
316 if (hit.isPixel()) ++pixelHits;
317 if (hit.isStrip()) ++stripHits;
319 m_pixelClustersPerFPGATrack.push_back(pixelHits);
320 m_stripClustersPerFPGATrack.push_back(stripHits);
322 if (m_printoutForEveryEvent) printFPGATracks(FPGATracks);
327 std::string maintable =
"\n|--------------------------------------------------------------------------------------------------|\n";
328 unsigned int trackCounter = 0;
329 for (
auto const&
track : *FPGATracks)
332 maintable +=
"| # | Eta | Phi | D0 | Z0 | QOverPt | chi2/ndf |\n"
333 "|--------------------------------------------------------------------------------------------------|\n";
337 maintable +=
std::format(
"| {:>6} | {:>12.8f} | {:>12.8f} | {:>12.8f} | {:>12.5f} | {:>12.9f} | {:>12.8f} |\n",
344 track.getChi2ndof());
348 ATH_MSG_ERROR(
"Exception while processing FPGATrackSimTrack: " <<
e.what());
352 maintable +=
"|__________________________________________________________________________________________________|\n"
353 "| | ## | type | layer | Global coordinates | isReal | HashID |\n"
354 "| | | | | x | y | z | | |\n"
355 "| |.........................................................................................|\n";
356 const std::vector <FPGATrackSimHit>&
hits =
track.getFPGATrackSimHits();
357 unsigned int hitCounter = 0;
358 for (
auto const& hit :
hits)
362 maintable +=
std::format(
"| | {:>6} | {:>8} | {:>5} | {:>9.3f} | {:>9.3f} | {:>9.3f} | {:>6} | {:>14} |\n",
364 (hit.isPixel() ?
"Pixel" : hit.isStrip() ?
"Strip" :
"FAILED"),
370 hit.getIdentifierHash());
372 ATH_MSG_ERROR(
"Exception while processing FPGATrackSimHits: " <<
e.what());
375 maintable +=
"|--------------------------------------------------------------------------------------------------|\n";
377 ATH_MSG_INFO(
"List of FPGA tracks for " << FPGATracks.key() << maintable);
382 unsigned int nPixelMeasurements, nStripMeasurements;
383 for (
auto const& prototrack : *FPGAPrototracks)
385 nPixelMeasurements = 0, nStripMeasurements = 0;
386 const std::vector<ActsTrk::ATLASUncalibSourceLink>* measurements = &prototrack.measurements;
393 m_pixelClustersPerPrototrack.push_back(nPixelMeasurements);
394 m_stripClustersPerPrototrack.push_back(nStripMeasurements);
397 if (m_printoutForEveryEvent) printFPGAPrototracks(FPGAPrototracks);
402 std::string mainTable =
"\n";
403 if(not (*FPGAPrototracks).empty()) mainTable +=
"|---------------------------------------------------------------------------------------------|\n";
405 unsigned int prototrackCounter = 0;
406 for (
auto const& prototrack : *FPGAPrototracks)
409 const Acts::BoundTrackParameters& initialParameters = *prototrack.parameters;
410 const Acts::BoundVector&
parameters = initialParameters.parameters();
412 "| # | QopT | Theta | Phi | d0 | z0 |\n"
413 "|---------------------------------------------------------------------------------------------|\n";
414 mainTable +=
std::format(
"| {:>6} | {:>14.10f} | {:>14.10f} | {:>14.10f} | {:>14.10f} | {:>14.10f} |\n",
422 const std::vector<ActsTrk::ATLASUncalibSourceLink>* measurements = &prototrack.measurements;
423 unsigned int measurementCounter = 0;
424 if (measurements->size())
427 "| _____________________________________________________________________________________|\n"
428 "| | | type | Global coordinates | HashID | Identifier |\n"
429 "| | ## | | x | y | z | | |\n"
430 "| | |...........................................................................|\n";
435 ++measurementCounter;
439 mainTable +=
std::format(
"| | {:>6} | Pixel | {:>8.3f} | {:>8.3f} | {:>8.3f} | {:>7} | {:>19} |\n",
449 mainTable +=
std::format(
"| | {:>6} | Strip | {:>8.3f} | {:>8.3f} | {:>8.3f} | {:>7} | {:>19} |\n",
458 mainTable +=
"|---------------------------------------------------------------------------------------------|\n";
460 ATH_MSG_INFO(
"Printing out prototracks coming from " << FPGAPrototracks.key() << mainTable);