ATLAS Offline Software
FPGATrackSimActsTrackInspectionTool.cxx
Go to the documentation of this file.
1 // Copyright (C) 2002-2024 CERN for the benefit of the ATLAS collaboration
2 
6 #include <format>
7 
9  const std::string& name, const IInterface* ifc)
10  : AthAlgTool(algname, name, ifc) {
11 }
12 
14  return StatusCode::SUCCESS;
15 }
16 
18 {
19  FPGATrackSimActsEventTracks t_actsTracks;
20  for (const ActsTrk::TrackContainer::ConstTrackProxy tp : tracksContainer)
21  {
22  std::deque<std::unique_ptr<FpgaActsTrack::Measurement>> t_TrackMeasurements;
23  const Acts::BoundVector& parameters = tp.parameters();
24  tracksContainer.trackStateContainer().visitBackwards(tp.tipIndex(), [&t_TrackMeasurements](const typename ActsTrk::TrackStateBackend::ConstTrackStateProxy& state) -> void
25  {
26  if (state.hasUncalibratedSourceLink()) {
27  try {
28  std::reference_wrapper<const xAOD::UncalibratedMeasurement> measurementRef =
29  std::cref(ActsTrk::getUncalibratedMeasurement(state.getUncalibratedSourceLink().get<ActsTrk::ATLASUncalibSourceLink>()));
30  const xAOD::UncalibratedMeasurement& measurement = measurementRef.get();
31  assert(static_cast<unsigned int>(measurement.type() < xAOD::UncalibMeasType::nTypes));
32 
33  if (measurement.type() == xAOD::UncalibMeasType::PixelClusterType) {
34  const xAOD::PixelCluster* pixelCluster = static_cast<const xAOD::PixelCluster*>(&measurement);
35  t_TrackMeasurements.emplace_front(std::make_unique<FpgaActsTrack::Measurement>(FpgaActsTrack::Measurement{
36  pixelCluster->identifier(),
37  "Pixel",
38  { pixelCluster->globalPosition().x(),
39  pixelCluster->globalPosition().y(),
40  pixelCluster->globalPosition().z() },
41  state.typeFlags().test(Acts::TrackStateFlag::MeasurementFlag),
42  state.typeFlags().test(Acts::TrackStateFlag::OutlierFlag),
43  state.typeFlags().test(Acts::TrackStateFlag::HoleFlag),
44  state.typeFlags().test(Acts::TrackStateFlag::MaterialFlag),
45  state.typeFlags().test(Acts::TrackStateFlag::SharedHitFlag) }));
46  }
47  else if (measurement.type() == xAOD::UncalibMeasType::StripClusterType) {
48  const xAOD::StripCluster* stripCluster = static_cast<const xAOD::StripCluster*>(&measurement);
49  t_TrackMeasurements.emplace_front(std::make_unique<FpgaActsTrack::Measurement>(FpgaActsTrack::Measurement{
50  stripCluster->identifier(),
51  "Strip",
52  { stripCluster->globalPosition().x(),
53  stripCluster->globalPosition().y(),
54  stripCluster->globalPosition().z()},
55  state.typeFlags().test(Acts::TrackStateFlag::MeasurementFlag),
56  state.typeFlags().test(Acts::TrackStateFlag::OutlierFlag),
57  state.typeFlags().test(Acts::TrackStateFlag::HoleFlag),
58  state.typeFlags().test(Acts::TrackStateFlag::MaterialFlag),
59  state.typeFlags().test(Acts::TrackStateFlag::SharedHitFlag) }));
60  }
61 
62  }
63  catch (const std::bad_any_cast&) {
64  }
65  }
66  });
67  t_actsTracks.emplace_back(std::make_unique<FpgaActsTrack>(FpgaActsTrack{ parameters, std::move(t_TrackMeasurements) }));
68  }
69 
70  return t_actsTracks;
71 }
72 
73 
75  const fpgaActsEventTracks& tracks) const
76 {
77  std::ostringstream printoutTable;
78  unsigned int t_trackCoutner = 0, t_measCounter = 0;
79  printoutTable << "\n|----------------------------------------------------------------------------------------------------|\n";
80  for (const auto& track : tracks)
81  {
82  ++t_trackCoutner;
83  printoutTable << "| # | QopT | Theta | Phi | d0 | z0 |\n"
84  << "|----------------------------------------------------------------------------------------------------|\n"
85  << std::format("| {:>5} | {:>16.10f} | {:>15.10f} | {:>15.10f} | {:>16.10f} | {:>16.10f} |\n",
86  t_trackCoutner,
87  track->parameters[Acts::eBoundQOverP] / 1000.,
88  track->parameters[Acts::eBoundTheta],
89  track->parameters[Acts::eBoundPhi],
90  track->parameters[Acts::eBoundLoc0],
91  track->parameters[Acts::eBoundLoc1]);
92  t_measCounter = 0;
93  printoutTable << "| |____________________________________________________________________________________________|\n"
94  << "| | ## | type | x | y | z | outlier | meas | hole | Identifier |\n"
95  << "| |--------------------------------------------------------------------------------------------|\n";
96  for (const auto& measurement : track->trackMeasurements)
97  {
98  ++t_measCounter;
99  printoutTable << std::format("| | {:>2} | {} | {:>8.3f} | {:>8.3f} | {:>8.3f} | {:>7} | {:>5} | {:6>5} | {:>18} |\n",
100  t_measCounter,
101  measurement->type.c_str(),
102  measurement->coordinates.x,
103  measurement->coordinates.y,
104  measurement->coordinates.z,
105  measurement->outlierFlag,
106  measurement->measurementFlag,
107  measurement->holeFlag,
108  measurement->identifier);
109  }
110  printoutTable << "|----------------------------------------------------------------------------------------------------|\n";
111  }
112 
113  return printoutTable.str();
114 }
115 
116 
118  const std::map<std::string, std::map<uint32_t, std::vector<uint32_t>> >& tracksForAllEvents) const
119 {
120  std::ostringstream printoutTable;
121  printoutTable << "Printing out ACTS statistics";
122  printoutTable << "\n|---------------------------------------------------------------------------------------|"
123  << "\n| Collection Name | Outliers (avg) | Measurements (avg) | Holes (avg) |"
124  << "\n|---------------------------------------------------------------------------------------|";
125  for (const auto& collection : tracksForAllEvents)
126  {
127  printoutTable << std::format("\n| {:>33} | {:>14.2f} | {:>18.2f} | {:>11.2f} |",
128  collection.first,
129  collection.second.at(Acts::TrackStateFlag::OutlierFlag).size() ?
130  std::accumulate(collection.second.at(Acts::TrackStateFlag::OutlierFlag).begin(),
131  collection.second.at(Acts::TrackStateFlag::OutlierFlag).end(), 0.0)
132  / collection.second.at(Acts::TrackStateFlag::OutlierFlag).size() : 0,
133 
134  collection.second.at(Acts::TrackStateFlag::MeasurementFlag).size() ? std::accumulate(collection.second.at(Acts::TrackStateFlag::MeasurementFlag).begin(), collection.second.at(Acts::TrackStateFlag::MeasurementFlag).end(), 0.0) / collection.second.at(Acts::TrackStateFlag::MeasurementFlag).size() : 0,
135 
136  collection.second.at(Acts::TrackStateFlag::HoleFlag).size() ? std::accumulate(collection.second.at(Acts::TrackStateFlag::HoleFlag).begin(), collection.second.at(Acts::TrackStateFlag::HoleFlag).end(), 0.0) / collection.second.at(Acts::TrackStateFlag::HoleFlag).size() : 0);
137  }
138  printoutTable << "\n|---------------------------------------------------------------------------------------|";
139  return printoutTable.str();
140 }
FPGATrackSim::ActsTrackInspectionTool::initialize
virtual StatusCode initialize() override
Definition: FPGATrackSimActsTrackInspectionTool.cxx:13
getMenu.algname
algname
Definition: getMenu.py:54
ActsTrk::TrackContainer
Definition: TrackContainer.h:31
vtune_athena.format
format
Definition: vtune_athena.py:14
xAOD::uint32_t
setEventNumber uint32_t
Definition: EventInfo_v1.cxx:127
accumulate
bool accumulate(AccumulateMap &map, std::vector< module_t > const &modules, FPGATrackSimMatrixAccumulator const &acc)
Accumulates an accumulator (e.g.
Definition: FPGATrackSimMatrixAccumulator.cxx:22
ParticleTest.tp
tp
Definition: ParticleTest.py:25
FPGATrackSim::ActsTrackInspectionTool::getActsTracks
fpgaActsEventTracks getActsTracks(const ActsTrk::TrackContainer &tracksContainer) const
Definition: FPGATrackSimActsTrackInspectionTool.cxx:17
FPGATrackSim::ActsTrackInspectionTool::ActsTrackInspectionTool
ActsTrackInspectionTool(const std::string &, const std::string &, const IInterface *)
Definition: FPGATrackSimActsTrackInspectionTool.cxx:8
FPGATrackSim::ActsTrackInspectionTool::getPrintoutActsEventTracks
std::string getPrintoutActsEventTracks(const fpgaActsEventTracks &tracks) const
Definition: FPGATrackSimActsTrackInspectionTool.cxx:74
FPGATrackSimActsTrackInspectionTool.h
EL::StatusCode
::StatusCode StatusCode
StatusCode definition for legacy code.
Definition: PhysicsAnalysis/D3PDTools/EventLoop/EventLoop/StatusCode.h:22
PixelClusterContainer.h
FPGATrackSim::ActsTrackInspectionTool::FpgaActsTrack
Definition: FPGATrackSimActsTrackInspectionTool.h:25
FPGATrackSim::ActsTrackInspectionTool::fpgaActsEventTracks
std::vector< std::unique_ptr< FpgaActsTrack > > fpgaActsEventTracks
Definition: FPGATrackSimActsTrackInspectionTool.h:46
name
std::string name
Definition: Control/AthContainers/Root/debug.cxx:228
StripClusterContainer.h
FPGATrackSim::ActsTrackInspectionTool::getPrintoutStatistics
std::string getPrintoutStatistics(const std::map< std::string, std::map< uint32_t, std::vector< uint32_t >> > &tracksForAllEvents) const
Definition: FPGATrackSimActsTrackInspectionTool.cxx:117
physics_parameters.parameters
parameters
Definition: physics_parameters.py:144
xAOD::track
@ track
Definition: TrackingPrimitives.h:512
AthAlgTool
Definition: AthAlgTool.h:26
FPGATrackSimActsEventTracks
FPGATrackSim::ActsTrackInspectionTool::fpgaActsEventTracks FPGATrackSimActsEventTracks
Definition: FPGATrackSimActsTrackInspectionTool.h:57