Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2026-05-02 07:49:48

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/EventData/TrackParameters.hpp"
0012 #include "Acts/Utilities/Logger.hpp"
0013 #include "ActsExamples/EventData/SimParticle.hpp"
0014 #include "ActsExamples/Utilities/Helpers.hpp"
0015 
0016 #include <cstddef>
0017 #include <map>
0018 #include <memory>
0019 #include <string>
0020 
0021 class TEfficiency;
0022 class TProfile;
0023 
0024 namespace ActsExamples {
0025 
0026 /// Tools to make duplication ratio (formerly called duplication rate) and
0027 /// duplication number plots to show tracking duplication.
0028 ///
0029 /// The duplication ratio is evaluated on truth-matched reco tracks. If there
0030 /// is more than one track matched to the same truth particle, the reco track
0031 /// with the highest matching probability is tagged as 'real' and the others are
0032 /// 'duplicated'.
0033 class DuplicationPlotTool {
0034  public:
0035   /// @brief The nested configuration struct
0036   struct Config {
0037     std::map<std::string, PlotHelpers::Binning> varBinning = {
0038         {"Eta", PlotHelpers::Binning::Uniform("#eta", 40, -4, 4)},
0039         {"Phi", PlotHelpers::Binning::Uniform("#phi", 100, -3.15, 3.15)},
0040         {"Pt", PlotHelpers::Binning::Uniform("pT [GeV/c]", 40, 0, 100)},
0041         {"Num", PlotHelpers::Binning::Uniform("N", 30, -0.5, 29.5)}};
0042   };
0043 
0044   /// @brief Nested Cache struct
0045   struct Cache {
0046     /// Number of duplicated tracks vs pT
0047     TProfile* nDuplicated_vs_pT;
0048     /// Number of duplicated tracks vs eta
0049     TProfile* nDuplicated_vs_eta;
0050     /// Number of duplicated tracks vs phi
0051     TProfile* nDuplicated_vs_phi;
0052     /// Tracking duplication ratio vs pT
0053     TEfficiency* duplicationRatio_vs_pT;
0054     /// Tracking duplication ratio vs eta
0055     TEfficiency* duplicationRatio_vs_eta;
0056     /// Tracking duplication ratio vs phi
0057     TEfficiency* duplicationRatio_vs_phi;
0058   };
0059 
0060   /// Constructor
0061   ///
0062   /// @param cfg Configuration struct
0063   /// @param lvl Message level declaration
0064   DuplicationPlotTool(const Config& cfg, Acts::Logging::Level lvl);
0065 
0066   /// @brief book the duplication plots
0067   ///
0068   /// @param cache the cache for duplication plots
0069   void book(Cache& cache) const;
0070 
0071   /// @brief fill duplication ratio w.r.t. fitted track parameters
0072   ///
0073   /// @param cache cache object for duplication plots
0074   /// @param fittedParameters fitted track parameters of this track
0075   /// @param status the (truth-matched) reconstructed track is duplicated or not
0076   void fill(Cache& cache, const Acts::BoundTrackParameters& fittedParameters,
0077             bool status) const;
0078 
0079   /// @brief fill number of duplicated tracks for a truth particle seed
0080   ///
0081   /// @param cache cache object for duplication plots
0082   /// @param truthParticle the truth Particle
0083   /// @param nDuplicatedTracks the number of duplicated tracks
0084   void fill(Cache& cache, const SimParticleState& truthParticle,
0085             std::size_t nDuplicatedTracks) const;
0086 
0087   /// @brief write the duplication plots to file
0088   ///
0089   /// @param cache cache object for duplication plots
0090   void write(const Cache& cache) const;
0091 
0092   /// @brief delete the duplication plots
0093   ///
0094   /// @param cache cache object for duplication plots
0095   void clear(Cache& cache) const;
0096 
0097  private:
0098   /// The Config class
0099   Config m_cfg;
0100   /// The logging instance
0101   std::unique_ptr<const Acts::Logger> m_logger;
0102 
0103   /// The logger
0104   const Acts::Logger& logger() const { return *m_logger; }
0105 };
0106 
0107 }  // namespace ActsExamples