From 6da96839bf0d62c1dfc0c173c806435d6d2971ae Mon Sep 17 00:00:00 2001 From: Andreas Stefl Date: Tue, 12 Nov 2024 22:21:58 +0100 Subject: [PATCH] fix: Make `SeedingPerformanceWriter` thread-safe (#3850) Not sure if the lock got lost by accident at some point or if it was never there. But the lock is definitely necessary to make the performance writer thread-safe. --- Examples/Io/Root/src/SeedingPerformanceWriter.cpp | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/Examples/Io/Root/src/SeedingPerformanceWriter.cpp b/Examples/Io/Root/src/SeedingPerformanceWriter.cpp index d11de8bc018..e37f115093d 100644 --- a/Examples/Io/Root/src/SeedingPerformanceWriter.cpp +++ b/Examples/Io/Root/src/SeedingPerformanceWriter.cpp @@ -13,7 +13,6 @@ #include "ActsExamples/Utilities/EventDataTransforms.hpp" #include "ActsExamples/Validation/TrackClassification.hpp" #include "ActsFatras/EventData/Barcode.hpp" -#include "ActsFatras/EventData/Particle.hpp" #include #include @@ -28,10 +27,6 @@ using Acts::VectorHelpers::eta; using Acts::VectorHelpers::phi; -namespace ActsExamples { -struct AlgorithmContext; -} // namespace ActsExamples - ActsExamples::SeedingPerformanceWriter::SeedingPerformanceWriter( ActsExamples::SeedingPerformanceWriter::Config config, Acts::Logging::Level level) @@ -127,6 +122,9 @@ ActsExamples::ProcessCode ActsExamples::SeedingPerformanceWriter::writeT( const auto& particles = m_inputParticles(ctx); const auto& hitParticlesMap = m_inputMeasurementParticlesMap(ctx); + // Exclusive access to the tree while writing + std::lock_guard lock(m_writeMutex); + std::size_t nSeeds = seeds.size(); std::size_t nMatchedSeeds = 0; // Map from particles to how many times they were successfully found by a seed