Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2026-08-05 08:23:19

0001 // This file is part of the ACTS project.
0002 //
0003 // Copyright (C) 2016 CERN for the benefit of the ACTS project
0004 //
0005 // This Source Code Form is subject to the terms of the Mozilla Public
0006 // License, v. 2.0. If a copy of the MPL was not distributed with this
0007 // file, You can obtain one at https://mozilla.org/MPL/2.0/.
0008 
0009 #pragma once
0010 
0011 #include "Acts/Geometry/GeometryContext.hpp"
0012 #include "Acts/Utilities/Logger.hpp"
0013 #include "ActsExamples/EventData/Index.hpp"
0014 #include "ActsExamples/EventData/SimParticle.hpp"
0015 #include "ActsExamples/EventData/Track.hpp"
0016 #include "ActsExamples/EventData/TruthMatching.hpp"
0017 #include "ActsExamples/Validation/DuplicationPlotTool.hpp"
0018 #include "ActsExamples/Validation/EffPlotTool.hpp"
0019 #include "ActsExamples/Validation/FakePlotTool.hpp"
0020 #include "ActsExamples/Validation/TrackQualityPlotTool.hpp"
0021 #include "ActsExamples/Validation/TrackSummaryPlotTool.hpp"
0022 
0023 #include <cstddef>
0024 #include <map>
0025 #include <set>
0026 #include <string>
0027 
0028 namespace ActsExamples {
0029 
0030 /// Collects pattern-finder performance histograms without any file I/O.
0031 ///
0032 /// Fill histograms for each event via fill(). Caller is responsible for
0033 /// thread safety — this class applies no locking of its own.
0034 class PatternRecognitionPerformanceCollector {
0035  public:
0036   struct Config {
0037     /// Label used to customize histogram titles and names
0038     std::string label = "track";
0039     EffPlotTool::Config effPlotToolConfig;
0040     FakePlotTool::Config fakePlotToolConfig;
0041     DuplicationPlotTool::Config duplicationPlotToolConfig;
0042     TrackSummaryPlotTool::Config trackSummaryPlotToolConfig;
0043     TrackQualityPlotTool::Config trackQualityPlotToolConfig;
0044 
0045     /// Optional per-subdetector track summary plots, keyed by name.
0046     /// The value is the set of geometry volume IDs to include.
0047     std::map<std::string, std::set<int>> subDetectorTrackSummaryVolumes;
0048   };
0049 
0050   PatternRecognitionPerformanceCollector(
0051       Config cfg, std::unique_ptr<const Acts::Logger> logger);
0052 
0053   /// Fill histograms for one event.
0054   ///
0055   /// @note The caller must ensure exclusive access (e.g. hold a mutex).
0056   void fill(const Acts::GeometryContext& geoContext,
0057             const ConstTrackContainer& tracks,
0058             const SimParticleContainer& particles,
0059             const TrackParticleMatching& trackParticleMatching,
0060             const ParticleTrackMatching& particleTrackMatching,
0061             const InverseMultimap<SimBarcode>& particleMeasurementsMap);
0062 
0063   /// Summary count statistics accumulated across all filled events.
0064   struct Stats {
0065     std::size_t nTotalTracks = 0;
0066     std::size_t nTotalMatchedTracks = 0;
0067     std::size_t nTotalFakeTracks = 0;
0068     std::size_t nTotalDuplicateTracks = 0;
0069     std::size_t nTotalParticles = 0;
0070     std::size_t nTotalMatchedParticles = 0;
0071     std::size_t nTotalDuplicateParticles = 0;
0072     std::size_t nTotalFakeParticles = 0;
0073   };
0074 
0075   /// Return accumulated event counts.
0076   const Stats& stats() const { return m_stats; }
0077 
0078   /// Emit efficiency/fake/duplicate summary statistics via the internal logger.
0079   void logSummary() const;
0080 
0081   /// @name Accessors for the underlying plot tools
0082   /// @{
0083   const EffPlotTool& effPlotTool() const { return m_effPlotTool; }
0084   const FakePlotTool& fakePlotTool() const { return m_fakePlotTool; }
0085   const DuplicationPlotTool& duplicationPlotTool() const {
0086     return m_duplicationPlotTool;
0087   }
0088   const TrackSummaryPlotTool& trackSummaryPlotTool() const {
0089     return m_trackSummaryPlotTool;
0090   }
0091   const std::map<std::string, TrackSummaryPlotTool>& subDetectorSummaryTools()
0092       const {
0093     return m_subDetectorSummaryTools;
0094   }
0095   const TrackQualityPlotTool& trackQualityPlotTool() const {
0096     return m_trackQualityPlotTool;
0097   }
0098   /// @}
0099 
0100  private:
0101   const Acts::Logger& logger() const { return *m_logger; }
0102 
0103   Config m_cfg;
0104   std::unique_ptr<const Acts::Logger> m_logger;
0105 
0106   EffPlotTool m_effPlotTool;
0107   FakePlotTool m_fakePlotTool;
0108   DuplicationPlotTool m_duplicationPlotTool;
0109   TrackSummaryPlotTool m_trackSummaryPlotTool;
0110   std::map<std::string, TrackSummaryPlotTool> m_subDetectorSummaryTools;
0111   TrackQualityPlotTool m_trackQualityPlotTool;
0112 
0113   Stats m_stats;
0114 };
0115 
0116 }  // namespace ActsExamples