Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2026-04-18 07:36:06

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/Framework/ProcessCode.hpp"
0018 #include "ActsExamples/Validation/DuplicationPlotTool.hpp"
0019 #include "ActsExamples/Validation/EffPlotTool.hpp"
0020 #include "ActsExamples/Validation/FakePlotTool.hpp"
0021 #include "ActsExamples/Validation/TrackQualityPlotTool.hpp"
0022 #include "ActsExamples/Validation/TrackSummaryPlotTool.hpp"
0023 
0024 #include <cstddef>
0025 #include <map>
0026 #include <set>
0027 #include <string>
0028 
0029 namespace ActsExamples {
0030 
0031 /// Collects track-finder performance histograms without any file I/O.
0032 ///
0033 /// Fill histograms for each event via fill(). Caller is responsible for
0034 /// thread safety — this class applies no locking of its own.
0035 class TrackFinderPerformanceCollector {
0036  public:
0037   struct Config {
0038     EffPlotTool::Config effPlotToolConfig;
0039     FakePlotTool::Config fakePlotToolConfig;
0040     DuplicationPlotTool::Config duplicationPlotToolConfig;
0041     TrackSummaryPlotTool::Config trackSummaryPlotToolConfig;
0042     TrackQualityPlotTool::Config trackQualityPlotToolConfig;
0043 
0044     /// Optional per-subdetector track summary plots, keyed by name.
0045     /// The value is the set of geometry volume IDs to include.
0046     std::map<std::string, std::set<int>> subDetectorTrackSummaryVolumes;
0047   };
0048 
0049   TrackFinderPerformanceCollector(Config cfg,
0050                                   std::unique_ptr<const Acts::Logger> logger);
0051 
0052   /// Fill histograms for one event.
0053   ///
0054   /// @note The caller must ensure exclusive access (e.g. hold a mutex).
0055   ProcessCode fill(const Acts::GeometryContext& geoContext,
0056                    const ConstTrackContainer& tracks,
0057                    const SimParticleContainer& particles,
0058                    const TrackParticleMatching& trackParticleMatching,
0059                    const ParticleTrackMatching& particleTrackMatching,
0060                    const InverseMultimap<SimBarcode>& particleMeasurementsMap);
0061 
0062   /// Summary count statistics accumulated across all filled events.
0063   struct Stats {
0064     std::size_t nTotalTracks = 0;
0065     std::size_t nTotalMatchedTracks = 0;
0066     std::size_t nTotalFakeTracks = 0;
0067     std::size_t nTotalDuplicateTracks = 0;
0068     std::size_t nTotalParticles = 0;
0069     std::size_t nTotalMatchedParticles = 0;
0070     std::size_t nTotalDuplicateParticles = 0;
0071     std::size_t nTotalFakeParticles = 0;
0072   };
0073 
0074   /// Return accumulated event counts.
0075   const Stats& stats() const { return m_stats; }
0076 
0077   /// Emit efficiency/fake/duplicate summary statistics via the internal logger.
0078   void logSummary() const;
0079 
0080   /// @name Accessors for the underlying plot tools
0081   /// @{
0082   const EffPlotTool& effPlotTool() const { return m_effPlotTool; }
0083   const FakePlotTool& fakePlotTool() const { return m_fakePlotTool; }
0084   const DuplicationPlotTool& duplicationPlotTool() const {
0085     return m_duplicationPlotTool;
0086   }
0087   const TrackSummaryPlotTool& trackSummaryPlotTool() const {
0088     return m_trackSummaryPlotTool;
0089   }
0090   const std::map<std::string, TrackSummaryPlotTool>& subDetectorSummaryTools()
0091       const {
0092     return m_subDetectorSummaryTools;
0093   }
0094   const TrackQualityPlotTool& trackQualityPlotTool() const {
0095     return m_trackQualityPlotTool;
0096   }
0097   /// @}
0098 
0099  private:
0100   const Acts::Logger& logger() const { return *m_logger; }
0101 
0102   Config m_cfg;
0103   std::unique_ptr<const Acts::Logger> m_logger;
0104 
0105   EffPlotTool m_effPlotTool;
0106   FakePlotTool m_fakePlotTool;
0107   DuplicationPlotTool m_duplicationPlotTool;
0108   TrackSummaryPlotTool m_trackSummaryPlotTool;
0109   std::map<std::string, TrackSummaryPlotTool> m_subDetectorSummaryTools;
0110   TrackQualityPlotTool m_trackQualityPlotTool;
0111 
0112   Stats m_stats;
0113 };
0114 
0115 }  // namespace ActsExamples