26 :
WriterT(cfg.inputTrajectories,
"TrackFitterPerformanceWriter", lvl),
27 m_cfg(std::move(cfg)),
28 m_resPlotTool(m_cfg.resPlotToolConfig, lvl),
29 m_effPlotTool(m_cfg.effPlotToolConfig, lvl),
30 m_trackSummaryPlotTool(m_cfg.trackSummaryPlotToolConfig, lvl)
35 throw std::invalid_argument(
"Missing input trajectories collection");
38 throw std::invalid_argument(
"Missing input particles collection");
41 throw std::invalid_argument(
"Missing output filename");
50 throw std::invalid_argument(
"Could not open '" + path +
"'");
60 m_resPlotTool.clear(m_resPlotCache);
61 m_effPlotTool.clear(m_effPlotCache);
62 m_trackSummaryPlotTool.clear(m_trackSummaryPlotCache);
65 m_outputFile->Close();
71 m_resPlotTool.refinement(m_resPlotCache);
75 m_resPlotTool.write(m_resPlotCache);
76 m_effPlotTool.write(m_effPlotCache);
77 m_trackSummaryPlotTool.write(m_trackSummaryPlotCache);
79 ACTS_INFO(
"Wrote performance plots to '" << m_outputFile->GetPath() <<
"'");
87 const auto& particles =
91 std::lock_guard<std::mutex> lock(m_writeMutex);
94 std::vector<ActsFatras::Barcode> reconParticleIds;
95 reconParticleIds.reserve(particles.size());
98 for (
const auto& traj : trajectories) {
100 const auto& [trackTips, mj] = traj.trajectory();
101 if (trackTips.empty()) {
108 if (trackTips.size() > 1) {
109 ACTS_ERROR(
"Track fitting should not result in multiple trajectories.");
110 return ProcessCode::ABORT;
113 auto& trackTip = trackTips.front();
116 if (not traj.hasTrackParameters(trackTip)) {
120 const auto& fittedParameters = traj.trackParameters(trackTip);
123 const auto particleHitCount = traj.identifyMajorityParticle(trackTip);
124 if (particleHitCount.empty()) {
125 ACTS_WARNING(
"No truth particle associated with this trajectory.");
129 const auto ip = particles.find(particleHitCount.front().particleId);
130 if (
ip == particles.end()) {
131 ACTS_WARNING(
"Majority particle not found in the particles collection.");
136 reconParticleIds.push_back(
ip->particleId());
139 traj.trackParameters(trackTip));
144 m_trackSummaryPlotTool.fill(m_trackSummaryPlotCache, fittedParameters,
145 trajState.nStates, trajState.nMeasurements,
146 trajState.nOutliers, trajState.nHoles);
152 for (
const auto&
particle : particles) {
153 bool isReconstructed =
false;
155 auto it = std::find(reconParticleIds.begin(), reconParticleIds.end(),
157 if (
it != reconParticleIds.end()) {
158 isReconstructed =
true;
160 m_effPlotTool.fill(m_effPlotCache,
particle, isReconstructed);