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/SimParticle.hpp"
0014 #include "ActsExamples/EventData/Track.hpp"
0015 #include "ActsExamples/EventData/TruthMatching.hpp"
0016 #include "ActsExamples/Validation/EffPlotTool.hpp"
0017 #include "ActsExamples/Validation/ResPlotTool.hpp"
0018 #include "ActsExamples/Validation/TrackSummaryPlotTool.hpp"
0019 
0020 #include <cstddef>
0021 #include <map>
0022 #include <string>
0023 
0024 namespace ActsExamples {
0025 
0026 /// Collects track-fitter performance histograms without any file I/O.
0027 ///
0028 /// Collects residual/pull histograms, efficiency plots, and track summary
0029 /// information for track fitting performance evaluation.
0030 ///
0031 /// @note The caller must ensure exclusive access (e.g. hold a mutex) when
0032 ///       calling fill(). This class applies no locking of its own.
0033 class TrackFitterPerformanceCollector {
0034  public:
0035   struct Config {
0036     ResPlotTool::Config resPlotToolConfig;
0037     EffPlotTool::Config effPlotToolConfig;
0038     TrackSummaryPlotTool::Config trackSummaryPlotToolConfig;
0039 
0040     /// Minimum number of entries in a bin for it to be included in the
0041     /// mean/width fit.
0042     int fitMinEntries = 10;
0043     /// The range in sigma for the iterative Gaussian fit
0044     double fitSigmaRange = 3.0;
0045     /// The maximum number of iterations for the iterative Gaussian fit
0046     int fitIterations = 3;
0047   };
0048 
0049   TrackFitterPerformanceCollector(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   void fill(const Acts::GeometryContext& geoContext,
0056             const ConstTrackContainer& tracks,
0057             const SimParticleContainer& particles,
0058             const TrackParticleMatching& trackParticleMatching);
0059 
0060   /// Summary count statistics accumulated across all filled events.
0061   struct Stats {
0062     std::size_t nTotalTracks = 0;
0063     std::size_t nTotalMatchedTracks = 0;
0064     std::size_t nTotalFakeTracks = 0;
0065     std::size_t nTotalParticles = 0;
0066     std::size_t nTotalMatchedParticles = 0;
0067   };
0068 
0069   /// Return accumulated event counts.
0070   const Stats& stats() const { return m_stats; }
0071 
0072   /// Emit summary statistics via the internal logger.
0073   void logSummary() const;
0074 
0075   /// @name Accessors for the underlying plot tools
0076   /// @{
0077   const ResPlotTool& resPlotTool() const { return m_resPlotTool; }
0078   const EffPlotTool& effPlotTool() const { return m_effPlotTool; }
0079   const TrackSummaryPlotTool& trackSummaryPlotTool() const {
0080     return m_trackSummaryPlotTool;
0081   }
0082   /// @}
0083 
0084  private:
0085   const Acts::Logger& logger() const { return *m_logger; }
0086 
0087   Config m_cfg;
0088   std::unique_ptr<const Acts::Logger> m_logger;
0089 
0090   ResPlotTool m_resPlotTool;
0091   EffPlotTool m_effPlotTool;
0092   TrackSummaryPlotTool m_trackSummaryPlotTool;
0093 
0094   Stats m_stats;
0095 };
0096 
0097 }  // namespace ActsExamples