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());
20 ATH_CHECK(m_ActsSeedCollections.initialize());
21 ATH_CHECK(m_ActsSeedParamCollections.initialize());
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(
"ACTS tracks in " << actsTrackContainer.key() << 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);
145 return StatusCode::SUCCESS;
152 if (!m_isDataPrep.value()) {
154 std::string summaryTableFPGATracks =
"\n"
155 "Number of measurements for FPGA Tracks\n"
156 "|-----------------------------------|\n"
157 "| | min | max | Avg |\n"
158 "|-----------------------------------|\n";
160 if (not m_pixelClustersPerFPGATrack.empty()) {
161 summaryTableFPGATracks +=
std::format(
"| Pixels | {:>4} | {:>4} | {:>10.2f} |\n",
162 *std::min_element(m_pixelClustersPerFPGATrack.begin(), m_pixelClustersPerFPGATrack.end()),
163 *std::max_element(m_pixelClustersPerFPGATrack.begin(), m_pixelClustersPerFPGATrack.end()),
164 std::accumulate(m_pixelClustersPerFPGATrack.begin(), m_pixelClustersPerFPGATrack.end(), 0.0) / m_pixelClustersPerFPGATrack.size());
166 else summaryTableFPGATracks +=
std::format(
"| Pixels | ---- | ---- | inf |\n");
168 if (not m_stripClustersPerFPGATrack.empty()) {
169 summaryTableFPGATracks +=
std::format(
"| Strips | {:>4} | {:>4} | {:>10.2f} |\n",
170 *std::min_element(m_stripClustersPerFPGATrack.begin(), m_stripClustersPerFPGATrack.end()),
171 *std::max_element(m_stripClustersPerFPGATrack.begin(), m_stripClustersPerFPGATrack.end()),
172 std::accumulate(m_stripClustersPerFPGATrack.begin(), m_stripClustersPerFPGATrack.end(), 0.0) / m_stripClustersPerFPGATrack.size());
174 else summaryTableFPGATracks +=
std::format(
"| Strips | ---- | ---- | inf |\n");
176 summaryTableFPGATracks +=
"|-----------------------------------|";
181 std::string summaryTableFPGAPrototracks =
std::format(
"\n"
182 "Number of measurements for FPGA Prototracks\n"
183 "|-----------------------------------|\n"
184 "| | min | max | Avg |\n"
185 "|-----------------------------------|\n");
187 if (not m_pixelClustersPerPrototrack.empty()) {
188 summaryTableFPGAPrototracks +=
std::format(
"| Pixels | {:>4} | {:>4} | {:>10.2f} |\n",
189 *std::min_element(m_pixelClustersPerPrototrack.begin(), m_pixelClustersPerPrototrack.end()),
190 *std::max_element(m_pixelClustersPerPrototrack.begin(), m_pixelClustersPerPrototrack.end()),
191 std::accumulate(m_pixelClustersPerPrototrack.begin(), m_pixelClustersPerPrototrack.end(), 0.0) / m_pixelClustersPerPrototrack.size());
193 else summaryTableFPGAPrototracks +=
std::format(
"| Pixels | ---- | ---- | inf |\n");
195 if (not m_stripClustersPerPrototrack.empty()) {
196 summaryTableFPGAPrototracks +=
std::format(
"| Strips | {:>4} | {:>4} | {:>10.2f} |\n",
197 *std::min_element(m_stripClustersPerPrototrack.begin(), m_stripClustersPerPrototrack.end()),
198 *std::max_element(m_stripClustersPerPrototrack.begin(), m_stripClustersPerPrototrack.end()),
199 std::accumulate(m_stripClustersPerPrototrack.begin(), m_stripClustersPerPrototrack.end(), 0.0) / m_stripClustersPerPrototrack.size());
201 else summaryTableFPGAPrototracks +=
std::format(
"| Strips | ---- | ---- | inf |\n");
203 summaryTableFPGAPrototracks +=
"|-----------------------------------|";
207 ATH_MSG_INFO(m_ActsInspectionTool->getPrintoutStatistics(m_actsTrackStats));
208 return StatusCode::SUCCESS;
211 template <
class XAOD_CLUSTER>
214 if (m_printoutForEveryEvent) printxAODClusters(clusterContainer);
217 template <
class XAOD_CLUSTER>
220 std::string mainTable =
"\n"
221 "|=========================================================================================|\n"
222 "| # | Global coordinates | Hash ID | Identifier |\n"
223 "| | x | y | z | | |\n"
224 "|-----------------------------------------------------------------------------------------|\n";
226 for (
const auto& cluster : *clusterContainer)
229 mainTable +=
std::format(
"| {:>6} | {:>12} | {:>12} | {:>12} | {:>12} | {:>18} |\n",
231 cluster->globalPosition().x(),
232 cluster->globalPosition().y(),
233 cluster->globalPosition().z(),
234 cluster->identifierHash(),
235 cluster->identifier());
237 mainTable +=
"|=========================================================================================|";
238 ATH_MSG_INFO(
"Printout of xAOD clusters coming from " << clusterContainer.key() << mainTable );
244 std::string mainTable =
"\n"
245 "|===================================================================================================================================================================================|\n"
246 "| # | Global coordinates | Local coordinates | Local Covariance | Size | Hash ID | Identifier |\n"
247 "| | x | y | z | 0 | 1 | 0,0 | 1,1 | phi | eta | | |\n"
248 "|-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|\n";
250 std::map<int, int> counterMap;
251 for (
const auto& cluster : *clusterContainer)
255 mainTable +=
std::format(
"| {:>6} | {:>12} | {:>12} | {:>12} | {:>12} | {:>12} | {:>12} | {:>12} | {:>12} | {:>12} | {:>12} | {:#018x} |\n",
257 cluster->globalPosition().x(),
258 cluster->globalPosition().y(),
259 cluster->globalPosition().z(),
260 cluster->localPosition<2>()[0],
261 cluster->localPosition<2>()[1],
262 cluster->localCovariance<2>()(0, 0),
263 cluster->localCovariance<2>()(1, 1),
264 cluster->channelsInPhi(),
265 cluster->channelsInEta(),
266 cluster->identifierHash(),
267 cluster->identifier());
269 counterMap[cluster->identifierHash()]++;
271 mainTable +=
"|=========================================================================================|";
273 ATH_MSG_INFO(
"Printout of xAOD clusters coming from " << clusterContainer.key() << mainTable );
279 std::string mainTable =
"\n"
280 "|======================================================================================================================================|\n"
281 "| # | Global coordinates | Local | Local | Size | Hash ID | Identifier |\n"
282 "| | x | y | z | Pos | Cov | | | |\n"
283 "|--------------------------------------------------------------------------------------------------------------------------------------|\n";
285 std::map<int, int> counterMap;
286 for (
const auto& cluster : *clusterContainer)
290 mainTable +=
std::format(
"| {:>6} | {:>12} | {:>12} | {:>12} | {:>12} | {:>12} | {:>12} | {:>12} | {:#018x} |\n",
292 cluster->globalPosition().x(),
293 cluster->globalPosition().y(),
294 cluster->globalPosition().z(),
295 cluster->localPosition<1>()[0],
296 cluster->localCovariance<1>()(0, 0),
297 cluster->channelsInPhi(),
298 cluster->identifierHash(),
299 cluster->identifier());
301 counterMap[cluster->identifierHash()]++;
303 mainTable +=
"|=========================================================================================|";
305 ATH_MSG_INFO(
"Printout of xAOD clusters coming from " << clusterContainer.key() << mainTable );
311 if (m_printoutForEveryEvent) printxAODSpacePoints(spContainer);
316 std::string mainTable =
"\n"
317 "|============================================================================|\n"
318 "| # | Global coordinates | element ID list |\n"
319 "| | x | y | z | |\n"
320 "|----------------------------------------------------------------------------|\n";
322 for (
const auto sp : *spContainer)
325 mainTable +=
std::format(
"| {:>6} | {:>12} | {:>12} | {:>12} | {:>9}, {:>9} |\n",
327 sp->globalPosition().x(),
328 sp->globalPosition().y(),
329 sp->globalPosition().z(),
330 sp->elementIdList()[0],
331 sp->elementIdList().size() == 2 ? sp->elementIdList()[1] : 0);
333 mainTable +=
"|=========================================================================================|";
334 ATH_MSG_INFO(
"Printout of xAOD space points coming from " << spContainer.key() << mainTable );
340 if (m_printoutForEveryEvent) printFPGASeeds(spContainer);
345 std::string mainTable =
"\n"
346 "|=====================================================================================|\n"
347 "| # | seed | Global coordinates | element ID list |\n"
348 "| | i | x | y | z | |\n"
349 "|-------------------------------------------------------------------------------------|\n";
351 for (
const auto thisTrack : *seedContainer)
353 auto spList = thisTrack.sp();
355 for(
int i = 0;
i < 3;
i++)
357 auto sp = spList.at(
i);
358 mainTable +=
std::format(
"| {:>6} | {:>6} | {:>12} | {:>12} | {:>12} | {:>9}, {:>9} |\n",
361 sp->globalPosition().x(),
362 sp->globalPosition().y(),
363 sp->globalPosition().z(),
364 sp->elementIdList()[0],
365 sp->elementIdList().size() == 2 ? sp->elementIdList()[1] : 0);
369 mainTable +=
"|=========================================================================================|";
370 ATH_MSG_INFO(
"Printout of ACTS seeds coming from " << seedContainer.key() << mainTable );
376 if (m_printoutForEveryEvent) printFPGASeedsParam(spContainer);
381 std::string mainTable =
"\n"
382 "|=============================================================================================|\n"
383 "| # | QopT | Theta | Phi | d0 | z0 |\n"
384 "|---------------------------------------------------------------------------------------------|\n";
386 for (
const auto paramSet : *seedContainer)
390 mainTable +=
std::format(
"| {:>6} | {:>14.10f} | {:>14.10f} | {:>14.10f} | {:>14.10f} | {:>14.10f} |\n",
398 mainTable +=
"|=========================================================================================|";
399 ATH_MSG_INFO(
"Printout of ACTS seeds Param coming from " << seedContainer.key() << mainTable );
408 if (m_printoutForEveryEvent) printFPGARoads(FPGARoads);
413 std::string mainTable =
"\n"
414 "|--------------------------------------------------------------------------------------------------|\n"
415 "| # | SubRegion | xBin | yBin | X | Y | RoadID | Sector |\n"
416 "|--------------------------------------------------------------------------------------------------|\n";
418 unsigned int roadCounter = 0, hitCounter = 0;
422 mainTable +=
std::format(
"| {:>6} | {:>11} | {:>8} | {:>8} | {:>12} | {:>12} | {:>10} | {:>8} |\n",
432 "| __________________________________________________________________________________________|\n"
433 "| | layer | ## | type | Global coordinates | isReal |\n"
434 "| | | | | x | y | z | |\n"
435 "| |.........................................................................................|\n";
436 for (
unsigned int i = 0;
i < road.getNLayers(); ++
i)
439 const std::vector<std::shared_ptr<const FPGATrackSimHit>>&
hits = road.getHits(
i);
440 for (
auto const& hit :
hits)
448 mainTable +=
std::format(
"| | {:>9} | {:>6} | {:>8} | {:>13} | {:>13} | {:>13} | {:>7} |\n",
449 (hit->isMapped() ? hit->getLayer() : 9999),
451 (hit->isPixel() ?
"Pixel" : hit->isStrip() ?
"Strip" :
"FAILED"),
457 ATH_MSG_ERROR(
"Exception while processing FPGATrackSimHit: " <<
e.what());
462 mainTable +=
"|--------------------------------------------------------------------------------------------------|\n";
464 ATH_MSG_INFO(
"List of FPGA roads for " << FPGARoads.key() << mainTable);
470 for (
auto const&
track : *FPGATracks)
472 const std::vector <FPGATrackSimHit>&
hits =
track.getFPGATrackSimHits();
473 uint32_t pixelHits = 0, stripHits = 0;
476 if (hit.isPixel()) ++pixelHits;
477 if (hit.isStrip()) ++stripHits;
479 m_pixelClustersPerFPGATrack.push_back(pixelHits);
480 m_stripClustersPerFPGATrack.push_back(stripHits);
482 if (m_printoutForEveryEvent) printFPGATracks(FPGATracks);
487 std::string maintable =
"\n|--------------------------------------------------------------------------------------------------|\n";
488 unsigned int trackCounter = 0;
489 for (
auto const&
track : *FPGATracks)
492 maintable +=
"| # | Eta | Phi | D0 | Z0 | QOverPt | chi2/ndf |\n"
493 "|--------------------------------------------------------------------------------------------------|\n";
497 maintable +=
std::format(
"| {:>6} | {:>12.8f} | {:>12.8f} | {:>12.8f} | {:>12.5f} | {:>12.9f} | {:>12.8f} |\n",
504 track.getChi2ndof());
508 ATH_MSG_ERROR(
"Exception while processing FPGATrackSimTrack: " <<
e.what());
512 maintable +=
"|__________________________________________________________________________________________________|\n"
513 "| | ## | type | layer | Global coordinates | isReal | HashID |\n"
514 "| | | | | x | y | z | | |\n"
515 "| |.........................................................................................|\n";
516 const std::vector <FPGATrackSimHit>&
hits =
track.getFPGATrackSimHits();
517 unsigned int hitCounter = 0;
518 for (
auto const& hit :
hits)
522 maintable +=
std::format(
"| | {:>6} | {:>8} | {:>5} | {:>9.3f} | {:>9.3f} | {:>9.3f} | {:>6} | {:>14} |\n",
524 (hit.isPixel() ?
"Pixel" : hit.isStrip() ?
"Strip" :
"FAILED"),
530 hit.getIdentifierHash());
532 ATH_MSG_ERROR(
"Exception while processing FPGATrackSimHits: " <<
e.what());
535 maintable +=
"|--------------------------------------------------------------------------------------------------|\n";
537 ATH_MSG_INFO(
"List of FPGA tracks for " << FPGATracks.key() << maintable);
542 unsigned int nPixelMeasurements, nStripMeasurements;
543 for (
auto const& prototrack : *FPGAPrototracks)
545 nPixelMeasurements = 0, nStripMeasurements = 0;
546 const std::vector<ActsTrk::ATLASUncalibSourceLink>* measurements = &prototrack.measurements;
553 m_pixelClustersPerPrototrack.push_back(nPixelMeasurements);
554 m_stripClustersPerPrototrack.push_back(nStripMeasurements);
557 if (m_printoutForEveryEvent) printFPGAPrototracks(FPGAPrototracks);
562 std::string mainTable =
"\n";
563 if(not (*FPGAPrototracks).empty()) mainTable +=
"|---------------------------------------------------------------------------------------------|\n";
565 unsigned int prototrackCounter = 0;
566 for (
auto const& prototrack : *FPGAPrototracks)
569 const Acts::BoundTrackParameters& initialParameters = *prototrack.parameters;
570 const Acts::BoundVector&
parameters = initialParameters.parameters();
572 "| # | QopT | Theta | Phi | d0 | z0 |\n"
573 "|---------------------------------------------------------------------------------------------|\n";
574 mainTable +=
std::format(
"| {:>6} | {:>14.10f} | {:>14.10f} | {:>14.10f} | {:>14.10f} | {:>14.10f} |\n",
582 const std::vector<ActsTrk::ATLASUncalibSourceLink>* measurements = &prototrack.measurements;
583 unsigned int measurementCounter = 0;
584 if (measurements->size())
587 "| _____________________________________________________________________________________|\n"
588 "| | | type | Global coordinates | HashID | Identifier |\n"
589 "| | ## | | x | y | z | | |\n"
590 "| | |...........................................................................|\n";
595 ++measurementCounter;
599 mainTable +=
std::format(
"| | {:>6} | Pixel | {:>8.3f} | {:>8.3f} | {:>8.3f} | {:>7} | {:>19} |\n",
609 mainTable +=
std::format(
"| | {:>6} | Strip | {:>8.3f} | {:>8.3f} | {:>8.3f} | {:>7} | {:>19} |\n",
618 mainTable +=
"|---------------------------------------------------------------------------------------------|\n";
620 ATH_MSG_INFO(
"Printing out prototracks coming from " << FPGAPrototracks.key() << mainTable);