ATLAS Offline Software
FPGATrackSimReportingAlg.cxx
Go to the documentation of this file.
1 /*
2  Copyright (C) 2002-2025 CERN for the benefit of the ATLAS collaboration
3 */
5 
6 #include <format>
7 
8 FPGATrackSim::FPGATrackSimReportingAlg::FPGATrackSimReportingAlg(const std::string& name, ISvcLocator* pSvcLocator) : AthReentrantAlgorithm(name, pSvcLocator) {
9 }
10 
12 {
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());
22 
23  ATH_CHECK(m_ActsInspectionTool.retrieve());
24  return StatusCode::SUCCESS;
25 }
26 
28 {
29  // Process xAOD Pixel Clusters
30  std::vector<SG::ReadHandle<xAOD::PixelClusterContainer>> xAODPixelClusterContainers = m_xAODPixelClusterContainerKeys.makeHandles(ctx);
31  for (SG::ReadHandle<xAOD::PixelClusterContainer>& clusterContainer : xAODPixelClusterContainers)
32  {
33  if (!clusterContainer.isValid()) {
34  ATH_MSG_WARNING("SG key not available " << clusterContainer.key());
35  continue;
36  }
37  processxAODClusters<xAOD::PixelCluster>(clusterContainer);
38  }
39  // Process xAOD Strip Clusters
40  std::vector<SG::ReadHandle<xAOD::StripClusterContainer>> xAODStripClusterContainers = m_xAODStripClusterContainerKeys.makeHandles(ctx);
41  for (SG::ReadHandle<xAOD::StripClusterContainer>& clusterContainer : xAODStripClusterContainers)
42  {
43  if (!clusterContainer.isValid()) {
44  ATH_MSG_WARNING("SG key not available " << clusterContainer.key());
45  continue;
46  }
47  processxAODClusters<xAOD::StripCluster>(clusterContainer);
48  }
49  // Process xAOD SpacePoints
50  std::vector<SG::ReadHandle<xAOD::SpacePointContainer>> xAODSpacePointContainers = m_xAODSpacePointContainerKeys.makeHandles(ctx);
51  for (SG::ReadHandle<xAOD::SpacePointContainer>& spContainer : xAODSpacePointContainers)
52  {
53  if (!spContainer.isValid()) {
54  ATH_MSG_WARNING("SG key not available " << spContainer.key());
55  }
56  else {processxAODSpacePoints(spContainer);}
57  }
58  if (!m_isDataPrep.value()) {
59  // Process FPGATrackSim Roads
60  SG::ReadHandle<FPGATrackSimRoadCollection> FPGATrackSimRoads(m_FPGARoadsKey, ctx);
61  if (FPGATrackSimRoads.isValid()) {
62  processFPGARoads(FPGATrackSimRoads);
63  }
64  else ATH_MSG_WARNING("Could not find FPGA Roads Collection with key " << FPGATrackSimRoads.key());
65 
66 
67  // Process FPGATrackSim Tracks
68  SG::ReadHandle<FPGATrackSimTrackCollection> FPGATrackSimTracks(m_FPGATracksKey, ctx);
69  if (FPGATrackSimTracks.isValid()) {
70  processFPGATracks(FPGATrackSimTracks);
71  }
72  else ATH_MSG_WARNING("Could not find FPGA Track Collection with key " << FPGATrackSimTracks.key());
73 
74  // Process FPGATrackSim Prototracks
75  std::vector<SG::ReadHandle<ActsTrk::ProtoTrackCollection>> FPGATrackSimProtoTracks = m_FPGAProtoTrackCollections.makeHandles(ctx);
76  for (SG::ReadHandle<ActsTrk::ProtoTrackCollection>& prototrackContainer : FPGATrackSimProtoTracks)
77  {
78  if (!prototrackContainer.isValid()) {
79  ATH_MSG_WARNING("SG key not available " << prototrackContainer.key());
80  continue;
81  }
82  processFPGAPrototracks(prototrackContainer);
83  }
84  } // if it's not the data preparation chain
85  // Process Acts tracks
86  std::vector<SG::ReadHandle<ActsTrk::TrackContainer>> FPGAActsTracks = m_ActsTrackCollections.makeHandles(ctx);
87  for (SG::ReadHandle<ActsTrk::TrackContainer>& actsTrackContainer : FPGAActsTracks)
88  {
89  if (actsTrackContainer.cptr()) ATH_MSG_DEBUG("Proccessing " << actsTrackContainer.key());
90  else continue;
91  // initialize the ReadHandle pair if necessarys
92  m_allActsTracks.try_emplace(actsTrackContainer.key(), std::vector<FPGATrackSimActsEventTracks>{});
93 
94  // fetch acts tracks
95  m_allActsTracks[actsTrackContainer.key()].push_back(m_ActsInspectionTool->getActsTracks(*(actsTrackContainer.cptr())));
96 
97  // initialize ReadHandle stats map for all tracks if necessary
98  m_actsTrackStats.try_emplace(actsTrackContainer.key(), std::map<uint32_t, std::vector<uint32_t>>{});
99 
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>{});
106 
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)
110  {
111  if (measurement->outlierFlag) ++t_nOutliers;
112  if (measurement->measurementFlag) ++t_nMeasurements;
113  if (measurement->holeFlag) ++t_nHoles;
114  }
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);
118  }
119  if (m_printoutForEveryEvent) ATH_MSG_INFO("ACTS tracks in " << actsTrackContainer.key() << m_ActsInspectionTool->getPrintoutActsEventTracks(m_allActsTracks[actsTrackContainer.key()].back()));
120  }
121 
122  std::vector<SG::ReadHandle<ActsTrk::SeedContainer>> FPGAActsSeeds = m_ActsSeedCollections.makeHandles(ctx);
123 
124  for (SG::ReadHandle<ActsTrk::SeedContainer>& actsTrackContainer : FPGAActsSeeds)
125  {
126  if (!actsTrackContainer.isValid()) {
127  ATH_MSG_WARNING("SG key not available " << actsTrackContainer.key());
128  continue;
129  }
130  processFPGASeeds(actsTrackContainer);
131  }
132 
133 
134  std::vector<SG::ReadHandle<ActsTrk::BoundTrackParametersContainer>> FPGAActsSeedsParam = m_ActsSeedParamCollections.makeHandles(ctx);
135 
136  for (SG::ReadHandle<ActsTrk::BoundTrackParametersContainer>& actsTrackContainer : FPGAActsSeedsParam)
137  {
138  if (!actsTrackContainer.isValid()) {
139  ATH_MSG_WARNING("SG key not available " << actsTrackContainer.key());
140  continue;
141  }
142  processFPGASeedsParam(actsTrackContainer);
143  }
144 
145  return StatusCode::SUCCESS;
146 }
147 
149 {
150  ATH_MSG_INFO("Printing statistics for FPGA objects");
151 
152  if (!m_isDataPrep.value()) {
153  // Printing summary for clusters/FPGATracks
154  std::string summaryTableFPGATracks = "\n"
155  "Number of measurements for FPGA Tracks\n"
156  "|-----------------------------------|\n"
157  "| | min | max | Avg |\n"
158  "|-----------------------------------|\n";
159 
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());
165  }
166  else summaryTableFPGATracks += std::format("| Pixels | ---- | ---- | inf |\n");
167 
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());
173  }
174  else summaryTableFPGATracks += std::format("| Strips | ---- | ---- | inf |\n");
175 
176  summaryTableFPGATracks += "|-----------------------------------|";
177  ATH_MSG_INFO( summaryTableFPGATracks );
178 
179 
180  // Printing summary for clusters/prototracks
181  std::string summaryTableFPGAPrototracks = std::format("\n"
182  "Number of measurements for FPGA Prototracks\n"
183  "|-----------------------------------|\n"
184  "| | min | max | Avg |\n"
185  "|-----------------------------------|\n");
186 
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());
192  }
193  else summaryTableFPGAPrototracks += std::format("| Pixels | ---- | ---- | inf |\n");
194 
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());
200  }
201  else summaryTableFPGAPrototracks += std::format("| Strips | ---- | ---- | inf |\n");
202 
203  summaryTableFPGAPrototracks += "|-----------------------------------|";
204  ATH_MSG_INFO( summaryTableFPGAPrototracks );
205  }
206 
207  ATH_MSG_INFO(m_ActsInspectionTool->getPrintoutStatistics(m_actsTrackStats));
208  return StatusCode::SUCCESS;
209 }
210 
211 template <class XAOD_CLUSTER>
213 {
214  if (m_printoutForEveryEvent) printxAODClusters(clusterContainer);
215 }
216 
217 template <class XAOD_CLUSTER>
219 {
220  std::string mainTable = "\n"
221  "|=========================================================================================|\n"
222  "| # | Global coordinates | Hash ID | Identifier |\n"
223  "| | x | y | z | | |\n"
224  "|-----------------------------------------------------------------------------------------|\n";
225  unsigned int counter = 0;
226  for (const auto& cluster : *clusterContainer)
227  {
228  ++counter;
229  mainTable += std::format("| {:>6} | {:>12} | {:>12} | {:>12} | {:>12} | {:>18} |\n",
230  counter,
231  cluster->globalPosition().x(),
232  cluster->globalPosition().y(),
233  cluster->globalPosition().z(),
234  cluster->identifierHash(),
235  cluster->identifier());
236  }
237  mainTable += "|=========================================================================================|";
238  ATH_MSG_INFO("Printout of xAOD clusters coming from " << clusterContainer.key() << mainTable );
239 }
240 
241 template <>
243 {
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";
249  unsigned int counter = 0;
250  std::map<int, int> counterMap;
251  for (const auto& cluster : *clusterContainer)
252  {
253  ++counter;
254 
255  mainTable += std::format("| {:>6} | {:>12} | {:>12} | {:>12} | {:>12} | {:>12} | {:>12} | {:>12} | {:>12} | {:>12} | {:>12} | {:#018x} |\n",
256  counter,
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());
268 
269  counterMap[cluster->identifierHash()]++;
270  }
271  mainTable += "|=========================================================================================|";
272 
273  ATH_MSG_INFO("Printout of xAOD clusters coming from " << clusterContainer.key() << mainTable );
274 }
275 
276 template <>
278 {
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";
284  unsigned int counter = 0;
285  std::map<int, int> counterMap;
286  for (const auto& cluster : *clusterContainer)
287  {
288  ++counter;
289 
290  mainTable += std::format("| {:>6} | {:>12} | {:>12} | {:>12} | {:>12} | {:>12} | {:>12} | {:>12} | {:#018x} |\n",
291  counter,
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());
300 
301  counterMap[cluster->identifierHash()]++;
302  }
303  mainTable += "|=========================================================================================|";
304 
305  ATH_MSG_INFO("Printout of xAOD clusters coming from " << clusterContainer.key() << mainTable );
306 }
307 
308 
310 {
311  if (m_printoutForEveryEvent) printxAODSpacePoints(spContainer);
312 }
313 
315 {
316  std::string mainTable = "\n"
317  "|============================================================================|\n"
318  "| # | Global coordinates | element ID list |\n"
319  "| | x | y | z | |\n"
320  "|----------------------------------------------------------------------------|\n";
321  unsigned int counter = 0;
322  for (const auto sp : *spContainer)
323  {
324  ++counter;
325  mainTable += std::format("| {:>6} | {:>12} | {:>12} | {:>12} | {:>9}, {:>9} |\n",
326  counter,
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);
332  }
333  mainTable += "|=========================================================================================|";
334  ATH_MSG_INFO("Printout of xAOD space points coming from " << spContainer.key() << mainTable );
335 }
336 
337 
339 {
340  if (m_printoutForEveryEvent) printFPGASeeds(spContainer);
341 }
342 
344 {
345  std::string mainTable = "\n"
346  "|=====================================================================================|\n"
347  "| # | seed | Global coordinates | element ID list |\n"
348  "| | i | x | y | z | |\n"
349  "|-------------------------------------------------------------------------------------|\n";
350  unsigned int counter = 0;
351  for (const auto thisTrack : *seedContainer)
352  {
353  auto spList = thisTrack.sp();
354  ++counter;
355  for(int i = 0; i < 3; i++)
356  {
357  auto sp = spList.at(i);
358  mainTable += std::format("| {:>6} | {:>6} | {:>12} | {:>12} | {:>12} | {:>9}, {:>9} |\n",
359  counter,
360  i,
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);
366  }
367 
368  }
369  mainTable += "|=========================================================================================|";
370  ATH_MSG_INFO("Printout of ACTS seeds coming from " << seedContainer.key() << mainTable );
371 }
372 
373 
375 {
376  if (m_printoutForEveryEvent) printFPGASeedsParam(spContainer);
377 }
378 
380 {
381  std::string mainTable = "\n"
382  "|=============================================================================================|\n"
383  "| # | QopT | Theta | Phi | d0 | z0 |\n"
384  "|---------------------------------------------------------------------------------------------|\n";
385  unsigned int counter = 0;
386  for (const auto paramSet : *seedContainer)
387  {
388  ++counter;
389  auto parameters = paramSet->parameters();
390  mainTable += std::format("| {:>6} | {:>14.10f} | {:>14.10f} | {:>14.10f} | {:>14.10f} | {:>14.10f} |\n",
391  counter,
392  parameters[Acts::eBoundQOverP],
393  parameters[Acts::eBoundTheta],
394  parameters[Acts::eBoundPhi],
395  parameters[Acts::eBoundLoc0],
396  parameters[Acts::eBoundLoc1]);
397  }
398  mainTable += "|=========================================================================================|";
399  ATH_MSG_INFO("Printout of ACTS seeds Param coming from " << seedContainer.key() << mainTable );
400 }
401 
402 
403 
404 
405 
407 {
408  if (m_printoutForEveryEvent) printFPGARoads(FPGARoads);
409 }
410 
412 {
413  std::string mainTable = "\n"
414  "|--------------------------------------------------------------------------------------------------|\n"
415  "| # | SubRegion | xBin | yBin | X | Y | RoadID | Sector |\n"
416  "|--------------------------------------------------------------------------------------------------|\n";
417 
418  unsigned int roadCounter = 0, hitCounter = 0;
419  for (const FPGATrackSimRoad& road : *FPGARoads)
420  {
421  ++roadCounter;
422  mainTable += std::format("| {:>6} | {:>11} | {:>8} | {:>8} | {:>12} | {:>12} | {:>10} | {:>8} |\n",
423  roadCounter,
424  road.getSubRegion(),
425  road.getXBin(),
426  road.getYBin(),
427  road.getX(),
428  road.getY(),
429  road.getRoadID(),
430  road.getSector());
431  mainTable +=
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)
437  {
438  hitCounter = 0;
439  const std::vector<std::shared_ptr<const FPGATrackSimHit>>& hits = road.getHits(i);
440  for (auto const& hit : hits)
441  {
442  if (!hit) {
443  ATH_MSG_WARNING("Null pointer for FPGATrackSimHit");
444  continue;
445  }
446  try {
447  ++hitCounter;
448  mainTable += std::format("| | {:>9} | {:>6} | {:>8} | {:>13} | {:>13} | {:>13} | {:>7} |\n",
449  (hit->isMapped() ? hit->getLayer() : 9999),
450  hitCounter,
451  (hit->isPixel() ? "Pixel" : hit->isStrip() ? "Strip" : "FAILED"),
452  hit->getX(),
453  hit->getY(),
454  hit->getZ(),
455  hit->isReal());
456  } catch (const std::exception& e) {
457  ATH_MSG_ERROR("Exception while processing FPGATrackSimHit: " << e.what());
458  }
459 
460  }
461  }
462  mainTable += "|--------------------------------------------------------------------------------------------------|\n";
463  }
464  ATH_MSG_INFO("List of FPGA roads for " << FPGARoads.key() << mainTable);
465 }
466 
467 
469 {
470  for (auto const& track : *FPGATracks)
471  {
472  const std::vector <FPGATrackSimHit>& hits = track.getFPGATrackSimHits();
473  uint32_t pixelHits = 0, stripHits = 0;
474  for (const FPGATrackSimHit& hit : hits)
475  {
476  if (hit.isPixel()) ++pixelHits;
477  if (hit.isStrip()) ++stripHits;
478  }
479  m_pixelClustersPerFPGATrack.push_back(pixelHits);
480  m_stripClustersPerFPGATrack.push_back(stripHits);
481  }
482  if (m_printoutForEveryEvent) printFPGATracks(FPGATracks);
483 }
484 
486 {
487  std::string maintable = "\n|--------------------------------------------------------------------------------------------------|\n";
488  unsigned int trackCounter = 0;
489  for (auto const& track : *FPGATracks)
490  {
491  ++trackCounter;
492  maintable += "| # | Eta | Phi | D0 | Z0 | QOverPt | chi2/ndf |\n"
493  "|--------------------------------------------------------------------------------------------------|\n";
494 
495  try
496  {
497  maintable += std::format("| {:>6} | {:>12.8f} | {:>12.8f} | {:>12.8f} | {:>12.5f} | {:>12.9f} | {:>12.8f} |\n",
498  trackCounter,
499  track.getEta(),
500  track.getPhi(),
501  track.getD0(),
502  track.getZ0(),
503  track.getQOverPt(),
504  track.getChi2ndof());
505  }
506  catch (const std::exception& e)
507  {
508  ATH_MSG_ERROR("Exception while processing FPGATrackSimTrack: " << e.what());
509  continue;
510  }
511 
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)
519  {
520  try {
521  ++hitCounter;
522  maintable += std::format("| | {:>6} | {:>8} | {:>5} | {:>9.3f} | {:>9.3f} | {:>9.3f} | {:>6} | {:>14} |\n",
523  hitCounter,
524  (hit.isPixel() ? "Pixel" : hit.isStrip() ? "Strip" : "FAILED"),
525  hit.getLayer(),
526  hit.getX(),
527  hit.getY(),
528  hit.getZ(),
529  hit.isReal(),
530  hit.getIdentifierHash());
531  } catch (const std::exception& e) {
532  ATH_MSG_ERROR("Exception while processing FPGATrackSimHits: " << e.what());
533  }
534  }
535  maintable += "|--------------------------------------------------------------------------------------------------|\n";
536  }
537  ATH_MSG_INFO("List of FPGA tracks for " << FPGATracks.key() << maintable);
538 }
539 
541 {
542  unsigned int nPixelMeasurements, nStripMeasurements;
543  for (auto const& prototrack : *FPGAPrototracks)
544  {
545  nPixelMeasurements = 0, nStripMeasurements = 0;
546  const std::vector<ActsTrk::ATLASUncalibSourceLink>* measurements = &prototrack.measurements;
547  for (const ActsTrk::ATLASUncalibSourceLink& measurementLink : *measurements)
548  {
549  const xAOD::UncalibratedMeasurement& measurement = ActsTrk::getUncalibratedMeasurement(measurementLink);
550  if (measurement.type() == xAOD::UncalibMeasType::PixelClusterType) ++nPixelMeasurements;
551  else if (measurement.type() == xAOD::UncalibMeasType::StripClusterType) ++nStripMeasurements;
552  }
553  m_pixelClustersPerPrototrack.push_back(nPixelMeasurements);
554  m_stripClustersPerPrototrack.push_back(nStripMeasurements);
555 
556  }
557  if (m_printoutForEveryEvent) printFPGAPrototracks(FPGAPrototracks);
558 }
559 
561 {
562  std::string mainTable = "\n";
563  if(not (*FPGAPrototracks).empty()) mainTable += "|---------------------------------------------------------------------------------------------|\n";
564 
565  unsigned int prototrackCounter = 0;
566  for (auto const& prototrack : *FPGAPrototracks)
567  {
568  ++prototrackCounter;
569  const Acts::BoundTrackParameters& initialParameters = *prototrack.parameters;
570  const Acts::BoundVector& parameters = initialParameters.parameters();
571  mainTable +=
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",
575  prototrackCounter,
576  parameters[Acts::eBoundQOverP],
577  parameters[Acts::eBoundTheta],
578  parameters[Acts::eBoundPhi],
579  parameters[Acts::eBoundLoc0],
580  parameters[Acts::eBoundLoc1]);
581 
582  const std::vector<ActsTrk::ATLASUncalibSourceLink>* measurements = &prototrack.measurements;
583  unsigned int measurementCounter = 0;
584  if (measurements->size())
585  {
586  mainTable +=
587  "| _____________________________________________________________________________________|\n"
588  "| | | type | Global coordinates | HashID | Identifier |\n"
589  "| | ## | | x | y | z | | |\n"
590  "| | |...........................................................................|\n";
591 
592  }
593  for (const ActsTrk::ATLASUncalibSourceLink& measurementLink : *measurements)
594  {
595  ++measurementCounter;
596  const xAOD::UncalibratedMeasurement& measurement = ActsTrk::getUncalibratedMeasurement(measurementLink);
597  if (measurement.type() == xAOD::UncalibMeasType::PixelClusterType) {
598  const xAOD::PixelCluster* pixelCluster = dynamic_cast<const xAOD::PixelCluster*>(&measurement);
599  mainTable += std::format("| | {:>6} | Pixel | {:>8.3f} | {:>8.3f} | {:>8.3f} | {:>7} | {:>19} |\n",
600  measurementCounter,
601  pixelCluster->globalPosition().cast<double>().x(),
602  pixelCluster->globalPosition().cast<double>().y(),
603  pixelCluster->globalPosition().cast<double>().z(),
604  pixelCluster->identifierHash(),
605  pixelCluster->identifier());
606  }
607  else if (measurement.type() == xAOD::UncalibMeasType::StripClusterType) {
608  const xAOD::StripCluster* stripCluster = dynamic_cast<const xAOD::StripCluster*>(&measurement);
609  mainTable += std::format("| | {:>6} | Strip | {:>8.3f} | {:>8.3f} | {:>8.3f} | {:>7} | {:>19} |\n",
610  measurementCounter,
611  stripCluster->globalPosition().cast<double>().x(),
612  stripCluster->globalPosition().cast<double>().y(),
613  stripCluster->globalPosition().cast<double>().z(),
614  stripCluster->identifierHash(),
615  stripCluster->identifier());
616  }
617  }
618  mainTable += "|---------------------------------------------------------------------------------------------|\n";
619  }
620  ATH_MSG_INFO("Printing out prototracks coming from " << FPGAPrototracks.key() << mainTable);
621 }
AllowedVariables::e
e
Definition: AsgElectronSelectorTool.cxx:37
FPGATrackSim::FPGATrackSimReportingAlg::processxAODClusters
void processxAODClusters(SG::ReadHandle< DataVector< XAOD_CLUSTER >> &clusterContainer) const
Definition: FPGATrackSimReportingAlg.cxx:212
TRTCalib_Extractor.hits
hits
Definition: TRTCalib_Extractor.py:35
FPGATrackSim::FPGATrackSimReportingAlg::printxAODSpacePoints
void printxAODSpacePoints(SG::ReadHandle< DataVector< xAOD::SpacePoint >> &spContainer) const
Definition: FPGATrackSimReportingAlg.cxx:314
vtune_athena.format
format
Definition: vtune_athena.py:14
ATH_MSG_INFO
#define ATH_MSG_INFO(x)
Definition: AthMsgStreamMacros.h:31
FPGATrackSim::FPGATrackSimReportingAlg::execute
virtual StatusCode execute(const EventContext &ctx) const override final
Definition: FPGATrackSimReportingAlg.cxx:27
xAOD::uint32_t
setEventNumber uint32_t
Definition: EventInfo_v1.cxx:127
SG::ReadHandle
Definition: StoreGate/StoreGate/ReadHandle.h:67
xAOD::UncalibMeasType::StripClusterType
@ StripClusterType
runITkAlign.accumulate
accumulate
Update flags based on parser line args.
Definition: runITkAlign.py:62
FPGATrackSim::FPGATrackSimReportingAlg::printFPGASeeds
void printFPGASeeds(SG::ReadHandle< ActsTrk::SeedContainer > &FPGASeeds) const
Definition: FPGATrackSimReportingAlg.cxx:343
Trk::stripCluster
@ stripCluster
Definition: MeasurementType.h:23
FPGATrackSimHit
Definition: FPGATrackSimHit.h:41
AthReentrantAlgorithm
An algorithm that can be simultaneously executed in multiple threads.
Definition: AthReentrantAlgorithm.h:74
FPGATrackSim::FPGATrackSimReportingAlg::printFPGATracks
void printFPGATracks(SG::ReadHandle< FPGATrackSimTrackCollection > &FPGATracks) const
Definition: FPGATrackSimReportingAlg.cxx:485
FPGATrackSim::FPGATrackSimReportingAlg::printFPGAPrototracks
void printFPGAPrototracks(SG::ReadHandle< ActsTrk::ProtoTrackCollection > &FPGAPrototracks) const
Definition: FPGATrackSimReportingAlg.cxx:560
xAOD::UncalibratedMeasurement_v1
Definition: UncalibratedMeasurement_v1.h:13
ATH_MSG_ERROR
#define ATH_MSG_ERROR(x)
Definition: AthMsgStreamMacros.h:33
xAOD::UncalibratedMeasurement_v1::type
virtual xAOD::UncalibMeasType type() const =0
Returns the type of the measurement type as a simple enumeration.
lumiFormat.i
int i
Definition: lumiFormat.py:85
EL::StatusCode
::StatusCode StatusCode
StatusCode definition for legacy code.
Definition: PhysicsAnalysis/D3PDTools/EventLoop/EventLoop/StatusCode.h:22
ATH_MSG_DEBUG
#define ATH_MSG_DEBUG(x)
Definition: AthMsgStreamMacros.h:29
FPGATrackSim::FPGATrackSimReportingAlg::initialize
virtual StatusCode initialize() override final
Definition: FPGATrackSimReportingAlg.cxx:11
calibdata.exception
exception
Definition: calibdata.py:495
xAOD::StripCluster_v1
Definition: StripCluster_v1.h:17
ATH_CHECK
#define ATH_CHECK
Definition: AthCheckMacros.h:40
DataVector
Derived DataVector<T>.
Definition: DataVector.h:795
SG::ReadHandle::isValid
virtual bool isValid() override final
Can the handle be successfully dereferenced?
name
std::string name
Definition: Control/AthContainers/Root/debug.cxx:240
FPGATrackSim::FPGATrackSimReportingAlg::printFPGARoads
void printFPGARoads(SG::ReadHandle< FPGATrackSimRoadCollection > &FPGARoads) const
Definition: FPGATrackSimReportingAlg.cxx:411
FPGATrackSim::FPGATrackSimReportingAlg::processFPGASeedsParam
void processFPGASeedsParam(SG::ReadHandle< ActsTrk::BoundTrackParametersContainer > &FPGASeedsParam) const
Definition: FPGATrackSimReportingAlg.cxx:374
ActsTrk::getUncalibratedMeasurement
const xAOD::UncalibratedMeasurement & getUncalibratedMeasurement(const ATLASUncalibSourceLink &source_link)
Definition: ATLASSourceLink.h:26
SG::VarHandleBase::key
virtual const std::string & key() const override final
Return the StoreGate ID for the referenced object.
Definition: AthToolSupport/AsgDataHandles/Root/VarHandleBase.cxx:64
FPGATrackSim::FPGATrackSimReportingAlg::processFPGARoads
void processFPGARoads(SG::ReadHandle< FPGATrackSimRoadCollection > &FPGARoads) const
Definition: FPGATrackSimReportingAlg.cxx:406
FPGATrackSim::FPGATrackSimReportingAlg::processFPGATracks
void processFPGATracks(SG::ReadHandle< FPGATrackSimTrackCollection > &FPGATracks) const
Definition: FPGATrackSimReportingAlg.cxx:468
Trk::pixelCluster
@ pixelCluster
Definition: MeasurementType.h:22
FPGATrackSim::FPGATrackSimReportingAlg::processFPGASeeds
void processFPGASeeds(SG::ReadHandle< ActsTrk::SeedContainer > &FPGASeeds) const
Definition: FPGATrackSimReportingAlg.cxx:338
xAOD::PixelCluster_v1
Definition: PixelCluster_v1.h:17
ATH_MSG_WARNING
#define ATH_MSG_WARNING(x)
Definition: AthMsgStreamMacros.h:32
FPGATrackSim::FPGATrackSimReportingAlg::finalize
virtual StatusCode finalize() override final
Definition: FPGATrackSimReportingAlg.cxx:148
physics_parameters.parameters
parameters
Definition: physics_parameters.py:144
FPGATrackSimReportingAlg.h
xAOD::track
@ track
Definition: TrackingPrimitives.h:513
FPGATrackSim::FPGATrackSimReportingAlg::processxAODSpacePoints
void processxAODSpacePoints(SG::ReadHandle< DataVector< xAOD::SpacePoint >> &spContainer) const
Definition: FPGATrackSimReportingAlg.cxx:309
FPGATrackSim::FPGATrackSimReportingAlg::processFPGAPrototracks
void processFPGAPrototracks(SG::ReadHandle< ActsTrk::ProtoTrackCollection > &FPGAPrototracks) const
Definition: FPGATrackSimReportingAlg.cxx:540
test_pyathena.counter
counter
Definition: test_pyathena.py:15
FPGATrackSim::FPGATrackSimReportingAlg::FPGATrackSimReportingAlg
FPGATrackSimReportingAlg(const std::string &name, ISvcLocator *pSvcLocator)
Definition: FPGATrackSimReportingAlg.cxx:8
FPGATrackSim::FPGATrackSimReportingAlg::printFPGASeedsParam
void printFPGASeedsParam(SG::ReadHandle< ActsTrk::BoundTrackParametersContainer > &FPGASeedsParam) const
Definition: FPGATrackSimReportingAlg.cxx:379
FPGATrackSimRoad
Definition: FPGATrackSimRoad.h:31
xAOD::UncalibMeasType::PixelClusterType
@ PixelClusterType
FPGATrackSim::FPGATrackSimReportingAlg::printxAODClusters
void printxAODClusters(SG::ReadHandle< DataVector< XAOD_CLUSTER >> &clusterContainer) const
Definition: FPGATrackSimReportingAlg.cxx:218