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));
20 ATH_CHECK(m_ActsSeedCollections.initialize(!m_isDataPrep));
21 ATH_CHECK(m_ActsSeedParamCollections.initialize(!m_isDataPrep));
23 ATH_CHECK(m_ActsInspectionTool.retrieve());
24 return StatusCode::SUCCESS;
30 std::vector<SG::ReadHandle<xAOD::PixelClusterContainer>> xAODPixelClusterContainers = m_xAODPixelClusterContainerKeys.makeHandles(ctx);
33 if (!clusterContainer.isValid()) {
37 processxAODClusters<xAOD::PixelCluster>(clusterContainer);
40 std::vector<SG::ReadHandle<xAOD::StripClusterContainer>> xAODStripClusterContainers = m_xAODStripClusterContainerKeys.makeHandles(ctx);
43 if (!clusterContainer.isValid()) {
47 processxAODClusters<xAOD::StripCluster>(clusterContainer);
50 std::vector<SG::ReadHandle<xAOD::SpacePointContainer>> xAODSpacePointContainers = m_xAODSpacePointContainerKeys.makeHandles(ctx);
53 if (!spContainer.isValid()) {
56 else {processxAODSpacePoints(spContainer);}
58 if (!m_isDataPrep.value()) {
61 if (FPGATrackSimRoads.
isValid()) {
62 processFPGARoads(FPGATrackSimRoads);
64 else ATH_MSG_WARNING(
"Could not find FPGA Roads Collection with key " << FPGATrackSimRoads.
key());
69 if (FPGATrackSimTracks.
isValid()) {
70 processFPGATracks(FPGATrackSimTracks);
72 else ATH_MSG_WARNING(
"Could not find FPGA Track Collection with key " << FPGATrackSimTracks.
key());
75 std::vector<SG::ReadHandle<ActsTrk::ProtoTrackCollection>> FPGATrackSimProtoTracks = m_FPGAProtoTrackCollections.makeHandles(ctx);
78 if (!prototrackContainer.isValid()) {
82 processFPGAPrototracks(prototrackContainer);
86 std::vector<SG::ReadHandle<ActsTrk::TrackContainer>> FPGAActsTracks = m_ActsTrackCollections.makeHandles(ctx);
89 if (actsTrackContainer.cptr())
ATH_MSG_DEBUG(
"Proccessing " << actsTrackContainer.key());
92 m_allActsTracks.try_emplace(actsTrackContainer.key(), std::vector<FPGATrackSimActsEventTracks>{});
95 m_allActsTracks[actsTrackContainer.key()].push_back(m_ActsInspectionTool->getActsTracks(*(actsTrackContainer.cptr())));
98 m_actsTrackStats.try_emplace(actsTrackContainer.key(), std::map<
uint32_t, std::vector<uint32_t>>{});
100 m_actsTrackStats[actsTrackContainer.key()].emplace(
101 Acts::TrackStateFlag::OutlierFlag, std::vector<uint32_t>{});
102 m_actsTrackStats[actsTrackContainer.key()].emplace(
103 Acts::TrackStateFlag::HoleFlag, std::vector<uint32_t>{});
104 m_actsTrackStats[actsTrackContainer.key()].emplace(
105 Acts::TrackStateFlag::MeasurementFlag, std::vector<uint32_t>{});
107 for (
const auto&
track : m_allActsTracks[actsTrackContainer.key()].back()) {
108 uint32_t t_nOutliers = 0, t_nMeasurements = 0, t_nHoles = 0;
109 for (
const auto& measurement :
track->trackMeasurements)
111 if (measurement->outlierFlag) ++t_nOutliers;
112 if (measurement->measurementFlag) ++t_nMeasurements;
113 if (measurement->holeFlag) ++t_nHoles;
115 m_actsTrackStats[actsTrackContainer.key()][Acts::TrackStateFlag::OutlierFlag].push_back(t_nOutliers);
116 m_actsTrackStats[actsTrackContainer.key()][Acts::TrackStateFlag::HoleFlag].push_back(t_nHoles);
117 m_actsTrackStats[actsTrackContainer.key()][Acts::TrackStateFlag::MeasurementFlag].push_back(t_nMeasurements);
119 if (m_printoutForEveryEvent)
ATH_MSG_INFO(m_ActsInspectionTool->getPrintoutActsEventTracks(m_allActsTracks[actsTrackContainer.key()].back()));
122 std::vector<SG::ReadHandle<ActsTrk::SeedContainer>> FPGAActsSeeds = m_ActsSeedCollections.makeHandles(ctx);
126 if (!actsTrackContainer.isValid()) {
130 processFPGASeeds(actsTrackContainer);
134 std::vector<SG::ReadHandle<ActsTrk::BoundTrackParametersContainer>> FPGAActsSeedsParam = m_ActsSeedParamCollections.makeHandles(ctx);
138 if (!actsTrackContainer.isValid()) {
142 processFPGASeedsParam(actsTrackContainer);
146 return StatusCode::SUCCESS;
153 if (!m_isDataPrep.value()) {
155 std::string summaryTableFPGATracks =
"\n"
156 "Number of measurements for FPGA Tracks\n"
157 "|-----------------------------------|\n"
158 "| | min | max | Avg |\n"
159 "|-----------------------------------|\n";
161 if (not m_pixelClustersPerFPGATrack.empty()) {
162 summaryTableFPGATracks +=
std::format(
"| Pixels | {:>4} | {:>4} | {:>10.2f} |\n",
163 *std::min_element(m_pixelClustersPerFPGATrack.begin(), m_pixelClustersPerFPGATrack.end()),
164 *std::max_element(m_pixelClustersPerFPGATrack.begin(), m_pixelClustersPerFPGATrack.end()),
165 std::accumulate(m_pixelClustersPerFPGATrack.begin(), m_pixelClustersPerFPGATrack.end(), 0.0) / m_pixelClustersPerFPGATrack.size());
167 else summaryTableFPGATracks +=
std::format(
"| Pixels | ---- | ---- | inf |\n");
169 if (not m_stripClustersPerFPGATrack.empty()) {
170 summaryTableFPGATracks +=
std::format(
"| Strips | {:>4} | {:>4} | {:>10.2f} |\n",
171 *std::min_element(m_stripClustersPerFPGATrack.begin(), m_stripClustersPerFPGATrack.end()),
172 *std::max_element(m_stripClustersPerFPGATrack.begin(), m_stripClustersPerFPGATrack.end()),
173 std::accumulate(m_stripClustersPerFPGATrack.begin(), m_stripClustersPerFPGATrack.end(), 0.0) / m_stripClustersPerFPGATrack.size());
175 else summaryTableFPGATracks +=
std::format(
"| Strips | ---- | ---- | inf |\n");
177 summaryTableFPGATracks +=
"|-----------------------------------|";
182 std::string summaryTableFPGAPrototracks =
std::format(
"\n"
183 "Number of measurements for FPGA Prototracks\n"
184 "|-----------------------------------|\n"
185 "| | min | max | Avg |\n"
186 "|-----------------------------------|\n");
188 if (not m_pixelClustersPerPrototrack.empty()) {
189 summaryTableFPGAPrototracks +=
std::format(
"| Pixels | {:>4} | {:>4} | {:>10.2f} |\n",
190 *std::min_element(m_pixelClustersPerPrototrack.begin(), m_pixelClustersPerPrototrack.end()),
191 *std::max_element(m_pixelClustersPerPrototrack.begin(), m_pixelClustersPerPrototrack.end()),
192 std::accumulate(m_pixelClustersPerPrototrack.begin(), m_pixelClustersPerPrototrack.end(), 0.0) / m_pixelClustersPerPrototrack.size());
194 else summaryTableFPGAPrototracks +=
std::format(
"| Pixels | ---- | ---- | inf |\n");
196 if (not m_stripClustersPerPrototrack.empty()) {
197 summaryTableFPGAPrototracks +=
std::format(
"| Strips | {:>4} | {:>4} | {:>10.2f} |\n",
198 *std::min_element(m_stripClustersPerPrototrack.begin(), m_stripClustersPerPrototrack.end()),
199 *std::max_element(m_stripClustersPerPrototrack.begin(), m_stripClustersPerPrototrack.end()),
200 std::accumulate(m_stripClustersPerPrototrack.begin(), m_stripClustersPerPrototrack.end(), 0.0) / m_stripClustersPerPrototrack.size());
202 else summaryTableFPGAPrototracks +=
std::format(
"| Strips | ---- | ---- | inf |\n");
204 summaryTableFPGAPrototracks +=
"|-----------------------------------|";
208 ATH_MSG_INFO(m_ActsInspectionTool->getPrintoutStatistics(m_actsTrackStats));
209 return StatusCode::SUCCESS;
212 template <
class XAOD_CLUSTER>
215 if (m_printoutForEveryEvent) printxAODClusters(clusterContainer);
218 template <
class XAOD_CLUSTER>
221 std::string mainTable =
"\n"
222 "|=========================================================================================|\n"
223 "| # | Global coordinates | Hash ID | Identifier |\n"
224 "| | x | y | z | | |\n"
225 "|-----------------------------------------------------------------------------------------|\n";
227 for (
const auto& cluster : *clusterContainer)
230 mainTable +=
std::format(
"| {:>6} | {:>12} | {:>12} | {:>12} | {:>12} | {:>18} |\n",
232 cluster->globalPosition().x(),
233 cluster->globalPosition().y(),
234 cluster->globalPosition().z(),
235 cluster->identifierHash(),
236 cluster->identifier());
238 mainTable +=
"|=========================================================================================|";
239 ATH_MSG_INFO(
"Printout of xAOD clusters coming from " << clusterContainer.key() << mainTable );
245 if (m_printoutForEveryEvent) printxAODSpacePoints(spContainer);
250 std::string mainTable =
"\n"
251 "|============================================================================|\n"
252 "| # | Global coordinates | element ID list |\n"
253 "| | x | y | z | |\n"
254 "|----------------------------------------------------------------------------|\n";
256 for (
const auto sp : *spContainer)
259 mainTable +=
std::format(
"| {:>6} | {:>12} | {:>12} | {:>12} | {:>9}, {:>9} |\n",
261 sp->globalPosition().x(),
262 sp->globalPosition().y(),
263 sp->globalPosition().z(),
264 sp->elementIdList()[0],
265 sp->elementIdList().size() == 2 ? sp->elementIdList()[1] : 0);
267 mainTable +=
"|=========================================================================================|";
268 ATH_MSG_INFO(
"Printout of xAOD space points coming from " << spContainer.key() << mainTable );
274 if (m_printoutForEveryEvent) printFPGASeeds(spContainer);
279 std::string mainTable =
"\n"
280 "|=====================================================================================|\n"
281 "| # | seed | Global coordinates | element ID list |\n"
282 "| | i | x | y | z | |\n"
283 "|-------------------------------------------------------------------------------------|\n";
285 for (
const auto thisTrack : *seedContainer)
287 auto spList = thisTrack->sp();
289 for(
int i = 0;
i < 3;
i++)
291 auto sp = spList.at(
i);
292 mainTable +=
std::format(
"| {:>6} | {:>6} | {:>12} | {:>12} | {:>12} | {:>9}, {:>9} |\n",
295 sp->globalPosition().x(),
296 sp->globalPosition().y(),
297 sp->globalPosition().z(),
298 sp->elementIdList()[0],
299 sp->elementIdList().size() == 2 ? sp->elementIdList()[1] : 0);
303 mainTable +=
"|=========================================================================================|";
304 ATH_MSG_INFO(
"Printout of ACTS seeds coming from " << seedContainer.key() << mainTable );
310 if (m_printoutForEveryEvent) printFPGASeedsParam(spContainer);
315 std::string mainTable =
"\n"
316 "|=============================================================================================|\n"
317 "| # | QopT | Theta | Phi | d0 | z0 |\n"
318 "|---------------------------------------------------------------------------------------------|\n";
320 for (
const auto paramSet : *seedContainer)
324 mainTable +=
std::format(
"| {:>6} | {:>14.10f} | {:>14.10f} | {:>14.10f} | {:>14.10f} | {:>14.10f} |\n",
332 mainTable +=
"|=========================================================================================|";
333 ATH_MSG_INFO(
"Printout of ACTS seeds Param coming from " << seedContainer.key() << mainTable );
342 if (m_printoutForEveryEvent) printFPGARoads(FPGARoads);
347 std::string mainTable =
"\n"
348 "|--------------------------------------------------------------------------------------------------|\n"
349 "| # | SubRegion | xBin | yBin | X | Y | RoadID | Sector |\n"
350 "|--------------------------------------------------------------------------------------------------|\n";
352 unsigned int roadCounter = 0, hitCounter = 0;
356 mainTable +=
std::format(
"| {:>6} | {:>11} | {:>8} | {:>8} | {:>12} | {:>12} | {:>10} | {:>8} |\n",
366 "| __________________________________________________________________________________________|\n"
367 "| | layer | ## | type | Global coordinates | isReal |\n"
368 "| | | | | x | y | z | |\n"
369 "| |.........................................................................................|\n";
370 for (
unsigned int i = 0;
i < road.getNLayers(); ++
i)
373 const std::vector<std::shared_ptr<const FPGATrackSimHit>>&
hits = road.getHits(
i);
374 for (
auto const& hit :
hits)
382 mainTable +=
std::format(
"| | {:>9} | {:>6} | {:>8} | {:>13} | {:>13} | {:>13} | {:>7} |\n",
383 (hit->isMapped() ? hit->getLayer() : 9999),
385 (hit->isPixel() ?
"Pixel" : hit->isStrip() ?
"Strip" :
"FAILED"),
391 ATH_MSG_ERROR(
"Exception while processing FPGATrackSimHit: " <<
e.what());
396 mainTable +=
"|--------------------------------------------------------------------------------------------------|\n";
398 ATH_MSG_INFO(
"List of FPGA roads for " << FPGARoads.key() << mainTable);
404 for (
auto const&
track : *FPGATracks)
406 const std::vector <FPGATrackSimHit>&
hits =
track.getFPGATrackSimHits();
407 uint32_t pixelHits = 0, stripHits = 0;
410 if (hit.isPixel()) ++pixelHits;
411 if (hit.isStrip()) ++stripHits;
413 m_pixelClustersPerFPGATrack.push_back(pixelHits);
414 m_stripClustersPerFPGATrack.push_back(stripHits);
416 if (m_printoutForEveryEvent) printFPGATracks(FPGATracks);
421 std::string maintable =
"\n|--------------------------------------------------------------------------------------------------|\n";
422 unsigned int trackCounter = 0;
423 for (
auto const&
track : *FPGATracks)
426 maintable +=
"| # | Eta | Phi | D0 | Z0 | QOverPt | chi2/ndf |\n"
427 "|--------------------------------------------------------------------------------------------------|\n";
431 maintable +=
std::format(
"| {:>6} | {:>12.8f} | {:>12.8f} | {:>12.8f} | {:>12.5f} | {:>12.9f} | {:>12.8f} |\n",
438 track.getChi2ndof());
442 ATH_MSG_ERROR(
"Exception while processing FPGATrackSimTrack: " <<
e.what());
446 maintable +=
"|__________________________________________________________________________________________________|\n"
447 "| | ## | type | layer | Global coordinates | isReal | HashID |\n"
448 "| | | | | x | y | z | | |\n"
449 "| |.........................................................................................|\n";
450 const std::vector <FPGATrackSimHit>&
hits =
track.getFPGATrackSimHits();
451 unsigned int hitCounter = 0;
452 for (
auto const& hit :
hits)
456 maintable +=
std::format(
"| | {:>6} | {:>8} | {:>5} | {:>9.3f} | {:>9.3f} | {:>9.3f} | {:>6} | {:>14} |\n",
458 (hit.isPixel() ?
"Pixel" : hit.isStrip() ?
"Strip" :
"FAILED"),
464 hit.getIdentifierHash());
466 ATH_MSG_ERROR(
"Exception while processing FPGATrackSimHits: " <<
e.what());
469 maintable +=
"|--------------------------------------------------------------------------------------------------|\n";
471 ATH_MSG_INFO(
"List of FPGA tracks for " << FPGATracks.key() << maintable);
476 unsigned int nPixelMeasurements, nStripMeasurements;
477 for (
auto const& prototrack : *FPGAPrototracks)
479 nPixelMeasurements = 0, nStripMeasurements = 0;
480 const std::vector<ActsTrk::ATLASUncalibSourceLink>* measurements = &prototrack.measurements;
487 m_pixelClustersPerPrototrack.push_back(nPixelMeasurements);
488 m_stripClustersPerPrototrack.push_back(nStripMeasurements);
491 if (m_printoutForEveryEvent) printFPGAPrototracks(FPGAPrototracks);
496 std::string mainTable =
"\n";
497 if(not (*FPGAPrototracks).empty()) mainTable +=
"|---------------------------------------------------------------------------------------------|\n";
499 unsigned int prototrackCounter = 0;
500 for (
auto const& prototrack : *FPGAPrototracks)
503 const Acts::BoundTrackParameters& initialParameters = *prototrack.parameters;
504 const Acts::BoundVector&
parameters = initialParameters.parameters();
506 "| # | QopT | Theta | Phi | d0 | z0 |\n"
507 "|---------------------------------------------------------------------------------------------|\n";
508 mainTable +=
std::format(
"| {:>6} | {:>14.10f} | {:>14.10f} | {:>14.10f} | {:>14.10f} | {:>14.10f} |\n",
516 const std::vector<ActsTrk::ATLASUncalibSourceLink>* measurements = &prototrack.measurements;
517 unsigned int measurementCounter = 0;
518 if (measurements->size())
521 "| _____________________________________________________________________________________|\n"
522 "| | | type | Global coordinates | HashID | Identifier |\n"
523 "| | ## | | x | y | z | | |\n"
524 "| | |...........................................................................|\n";
529 ++measurementCounter;
533 mainTable +=
std::format(
"| | {:>6} | Pixel | {:>8.3f} | {:>8.3f} | {:>8.3f} | {:>7} | {:>19} |\n",
543 mainTable +=
std::format(
"| | {:>6} | Strip | {:>8.3f} | {:>8.3f} | {:>8.3f} | {:>7} | {:>19} |\n",
552 mainTable +=
"|---------------------------------------------------------------------------------------------|\n";
554 ATH_MSG_INFO(
"Printing out prototracks coming from " << FPGAPrototracks.key() << mainTable);