24 return StatusCode::SUCCESS;
33 if (!clusterContainer.isValid()) {
43 if (!clusterContainer.isValid()) {
53 if (!spContainer.isValid()) {
61 if (FPGATrackSimRoads.
isValid()) {
64 else ATH_MSG_WARNING(
"Could not find FPGA Roads Collection with key " << FPGATrackSimRoads.
key());
69 if (FPGATrackSimTracks.
isValid()) {
72 else ATH_MSG_WARNING(
"Could not find FPGA Track Collection with key " << FPGATrackSimTracks.
key());
78 if (!prototrackContainer.isValid()) {
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<Acts::TrackStateFlag, std::vector<uint32_t>>{});
100 m_actsTrackStats[actsTrackContainer.key()].emplace(
101 Acts::TrackStateFlag::IsOutlier, std::vector<uint32_t>{});
102 m_actsTrackStats[actsTrackContainer.key()].emplace(
103 Acts::TrackStateFlag::IsHole, std::vector<uint32_t>{});
104 m_actsTrackStats[actsTrackContainer.key()].emplace(
105 Acts::TrackStateFlag::HasMeasurement, 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::IsOutlier].push_back(t_nOutliers);
115 m_actsTrackStats[actsTrackContainer.key()][Acts::TrackStateFlag::IsHole].push_back(t_nHoles);
116 m_actsTrackStats[actsTrackContainer.key()][Acts::TrackStateFlag::HasMeasurement].push_back(t_nMeasurements);
121 std::vector<SG::ReadHandle<ActsTrk::SeedContainer>> FPGAActsSeeds =
m_ActsSeedCollections.makeHandles(ctx);
125 if (!actsTrackContainer.isValid()) {
133 std::vector<SG::ReadHandle<ActsTrk::BoundTrackParametersContainer>> FPGAActsSeedsParam =
m_ActsSeedParamCollections.makeHandles(ctx);
137 if (!actsTrackContainer.isValid()) {
144 return StatusCode::SUCCESS;
153 std::string summaryTableFPGATracks =
"\n"
154 "Number of measurements for FPGA Tracks\n"
155 "|-----------------------------------|\n"
156 "| | min | max | Avg |\n"
157 "|-----------------------------------|\n";
159 if (not m_pixelClustersPerFPGATrack.empty()) {
160 summaryTableFPGATracks += std::format(
"| Pixels | {:>4} | {:>4} | {:>10.2f} |\n",
161 *std::min_element(m_pixelClustersPerFPGATrack.begin(), m_pixelClustersPerFPGATrack.end()),
162 *std::max_element(m_pixelClustersPerFPGATrack.begin(), m_pixelClustersPerFPGATrack.end()),
163 std::accumulate(m_pixelClustersPerFPGATrack.begin(), m_pixelClustersPerFPGATrack.end(), 0.0) / m_pixelClustersPerFPGATrack.size());
165 else summaryTableFPGATracks += std::format(
"| Pixels | ---- | ---- | inf |\n");
167 if (not m_stripClustersPerFPGATrack.empty()) {
168 summaryTableFPGATracks += std::format(
"| Strips | {:>4} | {:>4} | {:>10.2f} |\n",
169 *std::min_element(m_stripClustersPerFPGATrack.begin(), m_stripClustersPerFPGATrack.end()),
170 *std::max_element(m_stripClustersPerFPGATrack.begin(), m_stripClustersPerFPGATrack.end()),
171 std::accumulate(m_stripClustersPerFPGATrack.begin(), m_stripClustersPerFPGATrack.end(), 0.0) / m_stripClustersPerFPGATrack.size());
173 else summaryTableFPGATracks += std::format(
"| Strips | ---- | ---- | inf |\n");
175 summaryTableFPGATracks +=
"|-----------------------------------|";
180 std::string summaryTableFPGAPrototracks = std::format(
"\n"
181 "Number of measurements for FPGA Prototracks\n"
182 "|-----------------------------------|\n"
183 "| | min | max | Avg |\n"
184 "|-----------------------------------|\n");
186 if (not m_pixelClustersPerPrototrack.empty()) {
187 summaryTableFPGAPrototracks += std::format(
"| Pixels | {:>4} | {:>4} | {:>10.2f} |\n",
188 *std::min_element(m_pixelClustersPerPrototrack.begin(), m_pixelClustersPerPrototrack.end()),
189 *std::max_element(m_pixelClustersPerPrototrack.begin(), m_pixelClustersPerPrototrack.end()),
190 std::accumulate(m_pixelClustersPerPrototrack.begin(), m_pixelClustersPerPrototrack.end(), 0.0) / m_pixelClustersPerPrototrack.size());
192 else summaryTableFPGAPrototracks += std::format(
"| Pixels | ---- | ---- | inf |\n");
194 if (not m_stripClustersPerPrototrack.empty()) {
195 summaryTableFPGAPrototracks += std::format(
"| Strips | {:>4} | {:>4} | {:>10.2f} |\n",
196 *std::min_element(m_stripClustersPerPrototrack.begin(), m_stripClustersPerPrototrack.end()),
197 *std::max_element(m_stripClustersPerPrototrack.begin(), m_stripClustersPerPrototrack.end()),
198 std::accumulate(m_stripClustersPerPrototrack.begin(), m_stripClustersPerPrototrack.end(), 0.0) / m_stripClustersPerPrototrack.size());
200 else summaryTableFPGAPrototracks += std::format(
"| Strips | ---- | ---- | inf |\n");
202 summaryTableFPGAPrototracks +=
"|-----------------------------------|";
207 return StatusCode::SUCCESS;
210template <
class XAOD_CLUSTER>
216template <
class XAOD_CLUSTER>
219 std::string mainTable =
"\n"
220 "|=========================================================================================|\n"
221 "| # | Global coordinates | Hash ID | Identifier |\n"
222 "| | x | y | z | | |\n"
223 "|-----------------------------------------------------------------------------------------|\n";
224 unsigned int counter = 0;
225 for (
const auto& cluster : *clusterContainer)
228 mainTable += std::format(
"| {:>6} | {:>12} | {:>12} | {:>12} | {:>12} | {:>18} |\n",
230 cluster->globalPosition().x(),
231 cluster->globalPosition().y(),
232 cluster->globalPosition().z(),
233 cluster->identifierHash(),
234 cluster->identifier());
236 mainTable +=
"|=========================================================================================|";
237 ATH_MSG_INFO(
"Printout of xAOD clusters coming from " << clusterContainer.key() << mainTable );
243 std::string mainTable =
"\n"
244 "|===================================================================================================================================================================================|\n"
245 "| # | Global coordinates | Local coordinates | Local Covariance | Size | Hash ID | Identifier |\n"
246 "| | x | y | z | 0 | 1 | 0,0 | 1,1 | phi | eta | | |\n"
247 "|-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|\n";
248 unsigned int counter = 0;
249 std::map<int, int> counterMap;
254 mainTable += std::format(
"| {:>6} | {:>12} | {:>12} | {:>12} | {:>12} | {:>12} | {:>12} | {:>12} | {:>12} | {:>12} | {:>12} | {:#018x} |\n",
256 cluster->globalPosition().x(),
257 cluster->globalPosition().y(),
258 cluster->globalPosition().z(),
259 cluster->localPosition<2>()[0],
260 cluster->localPosition<2>()[1],
261 cluster->localCovariance<2>()(0, 0),
262 cluster->localCovariance<2>()(1, 1),
263 cluster->channelsInPhi(),
264 cluster->channelsInEta(),
265 cluster->identifierHash(),
266 cluster->identifier());
268 counterMap[cluster->identifierHash()]++;
270 mainTable +=
"|=========================================================================================|";
272 ATH_MSG_INFO(
"Printout of xAOD clusters coming from " << clusterContainer.key() << mainTable );
278 std::string mainTable =
"\n"
279 "|======================================================================================================================================|\n"
280 "| # | Global coordinates | Local | Local | Size | Hash ID | Identifier |\n"
281 "| | x | y | z | Pos | Cov | | | |\n"
282 "|--------------------------------------------------------------------------------------------------------------------------------------|\n";
283 unsigned int counter = 0;
284 std::map<int, int> counterMap;
289 mainTable += std::format(
"| {:>6} | {:>12} | {:>12} | {:>12} | {:>12} | {:>12} | {:>12} | {:>12} | {:#018x} |\n",
291 cluster->globalPosition().x(),
292 cluster->globalPosition().y(),
293 cluster->globalPosition().z(),
294 cluster->localPosition<1>()[0],
295 cluster->localCovariance<1>()(0, 0),
296 cluster->channelsInPhi(),
297 cluster->identifierHash(),
298 cluster->identifier());
300 counterMap[cluster->identifierHash()]++;
302 mainTable +=
"|=========================================================================================|";
304 ATH_MSG_INFO(
"Printout of xAOD clusters coming from " << clusterContainer.key() << mainTable );
315 std::string mainTable =
"\n"
316 "|============================================================================|\n"
317 "| # | Global coordinates | element ID list |\n"
318 "| | x | y | z | |\n"
319 "|----------------------------------------------------------------------------|\n";
320 unsigned int counter = 0;
321 for (
const auto sp : *spContainer)
324 mainTable += std::format(
"| {:>6} | {:>12} | {:>12} | {:>12} | {:>9}, {:>9} |\n",
326 sp->globalPosition().x(),
327 sp->globalPosition().y(),
328 sp->globalPosition().z(),
329 sp->elementIdList()[0],
330 sp->elementIdList().size() == 2 ?
sp->elementIdList()[1] : 0);
332 mainTable +=
"|=========================================================================================|";
333 ATH_MSG_INFO(
"Printout of xAOD space points coming from " << spContainer.key() << mainTable );
344 std::string mainTable =
"\n"
345 "|=====================================================================================|\n"
346 "| # | seed | Global coordinates | element ID list |\n"
347 "| | i | x | y | z | |\n"
348 "|-------------------------------------------------------------------------------------|\n";
349 unsigned int counter = 0;
350 for (
const auto thisTrack : *seedContainer)
352 auto spList = thisTrack.sp();
354 for(
int i = 0; i < 3; i++)
356 auto sp = spList.at(i);
357 mainTable += std::format(
"| {:>6} | {:>6} | {:>12} | {:>12} | {:>12} | {:>9}, {:>9} |\n",
360 sp->globalPosition().x(),
361 sp->globalPosition().y(),
362 sp->globalPosition().z(),
363 sp->elementIdList()[0],
364 sp->elementIdList().size() == 2 ?
sp->elementIdList()[1] : 0);
368 mainTable +=
"|=========================================================================================|";
369 ATH_MSG_INFO(
"Printout of ACTS seeds coming from " << seedContainer.
key() << mainTable );
380 std::string mainTable =
"\n"
381 "|=============================================================================================|\n"
382 "| # | QopT | Theta | Phi | d0 | z0 |\n"
383 "|---------------------------------------------------------------------------------------------|\n";
384 unsigned int counter = 0;
385 for (
const auto paramSet : *seedContainer)
388 auto parameters = paramSet->parameters();
389 mainTable += std::format(
"| {:>6} | {:>14.10f} | {:>14.10f} | {:>14.10f} | {:>14.10f} | {:>14.10f} |\n",
391 parameters[Acts::eBoundQOverP],
392 parameters[Acts::eBoundTheta],
393 parameters[Acts::eBoundPhi],
394 parameters[Acts::eBoundLoc0],
395 parameters[Acts::eBoundLoc1]);
397 mainTable +=
"|=========================================================================================|";
398 ATH_MSG_INFO(
"Printout of ACTS seeds Param coming from " << seedContainer.
key() << mainTable );
412 std::string mainTable =
"\n"
413 "|--------------------------------------------------------------------------------------------------|\n"
414 "| # | SubRegion | xBin | yBin | X | Y | RoadID | Sector |\n"
415 "|--------------------------------------------------------------------------------------------------|\n";
417 unsigned int roadCounter = 0, hitCounter = 0;
421 mainTable += std::format(
"| {:>6} | {:>11} | {:>8} | {:>8} | {:>12} | {:>12} | {:>10} | {:>8} |\n",
431 "| __________________________________________________________________________________________|\n"
432 "| | layer | ## | type | Global coordinates | isReal |\n"
433 "| | | | | x | y | z | |\n"
434 "| |.........................................................................................|\n";
435 for (
unsigned int i = 0; i < road.getNLayers(); ++i)
438 const std::vector<std::shared_ptr<const FPGATrackSimHit>>& hits = road.getHitPtrs(i);
439 for (
auto const&
hit : hits)
447 mainTable += std::format(
"| | {:>9} | {:>6} | {:>8} | {:>13} | {:>13} | {:>13} | {:>7} |\n",
448 (
hit->isMapped() ?
hit->getLayer() : 9999),
450 (
hit->isPixel() ?
"Pixel" :
hit->isStrip() ?
"Strip" :
"FAILED"),
455 }
catch (
const std::exception& e) {
456 ATH_MSG_ERROR(
"Exception while processing FPGATrackSimHit: " << e.what());
461 mainTable +=
"|--------------------------------------------------------------------------------------------------|\n";
463 ATH_MSG_INFO(
"List of FPGA roads for " << FPGARoads.
key() << mainTable);
469 for (
auto const& track : *FPGATracks)
471 const auto& hits = track.getFPGATrackSimHitPtrs();
472 uint32_t pixelHits = 0, stripHits = 0;
473 for (
const auto& hit_ptr : hits)
476 throw std::runtime_error(
"Null hit pointer in track");
478 if (hit_ptr->isPixel()) ++pixelHits;
479 if (hit_ptr->isStrip()) ++stripHits;
481 m_pixelClustersPerFPGATrack.push_back(pixelHits);
482 m_stripClustersPerFPGATrack.push_back(stripHits);
489 std::string maintable =
"\n|--------------------------------------------------------------------------------------------------|\n";
490 unsigned int trackCounter = 0;
491 for (
auto const& track : *FPGATracks)
494 maintable +=
"| # | Eta | Phi | D0 | Z0 | QOverPt | chi2/ndf |\n"
495 "|--------------------------------------------------------------------------------------------------|\n";
499 maintable += std::format(
"| {:>6} | {:>12.8f} | {:>12.8f} | {:>12.8f} | {:>12.5f} | {:>12.9f} | {:>12.8f} |\n",
506 track.getChi2ndof());
508 catch (
const std::exception& e)
510 ATH_MSG_ERROR(
"Exception while processing FPGATrackSimTrack: " << e.what());
514 maintable +=
"|__________________________________________________________________________________________________|\n"
515 "| | ## | type | layer | Global coordinates | isReal | HashID |\n"
516 "| | | | | x | y | z | | |\n"
517 "| |.........................................................................................|\n";
518 const auto& hits = track.getFPGATrackSimHitPtrs();
519 unsigned int hitCounter = 0;
520 for (
const auto& hit_ptr : hits)
523 throw std::runtime_error(
"Null hit pointer in track");
527 maintable += std::format(
"| | {:>6} | {:>8} | {:>5} | {:>9.3f} | {:>9.3f} | {:>9.3f} | {:>6} | {:>14} |\n",
529 (hit_ptr->isPixel() ?
"Pixel" : hit_ptr->isStrip() ?
"Strip" :
"FAILED"),
535 hit_ptr->getIdentifierHash());
536 }
catch (
const std::exception& e) {
537 ATH_MSG_ERROR(
"Exception while processing FPGATrackSimHits: " << e.what());
540 maintable +=
"|--------------------------------------------------------------------------------------------------|\n";
542 ATH_MSG_INFO(
"List of FPGA tracks for " << FPGATracks.
key() << maintable);
547 unsigned int nPixelMeasurements, nStripMeasurements;
548 for (
auto const& prototrack : *FPGAPrototracks)
550 nPixelMeasurements = 0, nStripMeasurements = 0;
555 m_pixelClustersPerPrototrack.push_back(nPixelMeasurements);
556 m_stripClustersPerPrototrack.push_back(nStripMeasurements);
564 std::string mainTable =
"\n";
565 if(not (*FPGAPrototracks).empty()) mainTable +=
"|---------------------------------------------------------------------------------------------|\n";
567 unsigned int prototrackCounter = 0;
568 for (
auto const& prototrack : *FPGAPrototracks)
571 const Acts::BoundTrackParameters& initialParameters = *prototrack.parameters;
572 const Acts::BoundVector& parameters = initialParameters.parameters();
574 "| # | QopT | Theta | Phi | d0 | z0 |\n"
575 "|---------------------------------------------------------------------------------------------|\n";
576 mainTable += std::format(
"| {:>6} | {:>14.10f} | {:>14.10f} | {:>14.10f} | {:>14.10f} | {:>14.10f} |\n",
578 parameters[Acts::eBoundQOverP],
579 parameters[Acts::eBoundTheta],
580 parameters[Acts::eBoundPhi],
581 parameters[Acts::eBoundLoc0],
582 parameters[Acts::eBoundLoc1]);
584 unsigned int measurementCounter = 0;
585 if (prototrack.measurements.size())
588 "| _____________________________________________________________________________________|\n"
589 "| | | type | Global coordinates | HashID | Identifier |\n"
590 "| | ## | | x | y | z | | |\n"
591 "| | |...........................................................................|\n";
596 ++measurementCounter;
599 mainTable += std::format(
"| | {:>6} | Pixel | {:>8.3f} | {:>8.3f} | {:>8.3f} | {:>7} | {:>19} |\n",
601 pixelCluster->globalPosition().cast<
double>().x(),
602 pixelCluster->globalPosition().cast<
double>().y(),
603 pixelCluster->globalPosition().cast<
double>().z(),
604 pixelCluster->identifierHash(),
605 pixelCluster->identifier());
609 mainTable += std::format(
"| | {:>6} | Strip | {:>8.3f} | {:>8.3f} | {:>8.3f} | {:>7} | {:>19} |\n",
611 stripCluster->globalPosition().cast<
double>().x(),
612 stripCluster->globalPosition().cast<
double>().y(),
613 stripCluster->globalPosition().cast<
double>().z(),
614 stripCluster->identifierHash(),
615 stripCluster->identifier());
618 mainTable +=
"|---------------------------------------------------------------------------------------------|\n";
620 ATH_MSG_INFO(
"Printing out prototracks coming from " << FPGAPrototracks.
key() << mainTable);
#define ATH_CHECK
Evaluate an expression and check for errors.
#define ATH_MSG_DEBUG(x,...)
#define ATH_MSG_ERROR(x,...)
#define ATH_MSG_WARNING(x,...)
#define ATH_MSG_INFO(x,...)
An algorithm that can be simultaneously executed in multiple threads.
SG::ReadHandleKeyArray< xAOD::StripClusterContainer > m_xAODStripClusterContainerKeys
Gaudi::Property< bool > m_printoutForEveryEvent
void processFPGASeeds(SG::ReadHandle< ActsTrk::SeedContainer > &FPGASeeds) const
SG::ReadHandleKeyArray< ActsTrk::BoundTrackParametersContainer > m_ActsSeedParamCollections
SG::ReadHandleKeyArray< ActsTrk::SeedContainer > m_ActsSeedCollections
virtual StatusCode finalize() override final
FPGATrackSimReportingAlg(const std::string &name, ISvcLocator *pSvcLocator)
void printFPGAPrototracks(SG::ReadHandle< ActsTrk::ProtoTrackCollection > &FPGAPrototracks) const
void printFPGARoads(SG::ReadHandle< FPGATrackSimRoadCollection > &FPGARoads) const
SG::ReadHandleKeyArray< xAOD::SpacePointContainer > m_xAODSpacePointContainerKeys
void printxAODClusters(SG::ReadHandle< DataVector< XAOD_CLUSTER > > &clusterContainer) const
SG::ReadHandleKeyArray< ActsTrk::ProtoTrackCollection > m_FPGAProtoTrackCollections
virtual StatusCode initialize() override final
void processFPGARoads(SG::ReadHandle< FPGATrackSimRoadCollection > &FPGARoads) const
SG::ReadHandleKey< FPGATrackSimTrackCollection > m_FPGATracksKey
virtual StatusCode execute(const EventContext &ctx) const override final
ToolHandle< FPGATrackSim::ActsTrackInspectionTool > m_ActsInspectionTool
void processFPGAPrototracks(SG::ReadHandle< ActsTrk::ProtoTrackCollection > &FPGAPrototracks) const
void printFPGASeeds(SG::ReadHandle< ActsTrk::SeedContainer > &FPGASeeds) const
void printFPGATracks(SG::ReadHandle< FPGATrackSimTrackCollection > &FPGATracks) const
void processFPGATracks(SG::ReadHandle< FPGATrackSimTrackCollection > &FPGATracks) const
void processFPGASeedsParam(SG::ReadHandle< ActsTrk::BoundTrackParametersContainer > &FPGASeedsParam) const
SG::ReadHandleKey< FPGATrackSimRoadCollection > m_FPGARoadsKey
void printFPGASeedsParam(SG::ReadHandle< ActsTrk::BoundTrackParametersContainer > &FPGASeedsParam) const
void processxAODClusters(SG::ReadHandle< DataVector< XAOD_CLUSTER > > &clusterContainer) const
SG::ReadHandleKeyArray< ActsTrk::TrackContainer > m_ActsTrackCollections
void printxAODSpacePoints(SG::ReadHandle< DataVector< xAOD::SpacePoint > > &spContainer) const
void processxAODSpacePoints(SG::ReadHandle< DataVector< xAOD::SpacePoint > > &spContainer) const
SG::ReadHandleKeyArray< xAOD::PixelClusterContainer > m_xAODPixelClusterContainerKeys
Gaudi::Property< bool > m_isDataPrep
virtual bool isValid() override final
Can the handle be successfully dereferenced?
virtual const std::string & key() const override final
Return the StoreGate ID for the referenced object.
virtual xAOD::UncalibMeasType type() const =0
Returns the type of the measurement type as a simple enumeration.
StripCluster_v1 StripCluster
Define the version of the strip cluster class.
UncalibratedMeasurement_v1 UncalibratedMeasurement
Define the version of the uncalibrated measurement class.
PixelCluster_v1 PixelCluster
Define the version of the pixel cluster class.