Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-01-18 09:28:02

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