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/Utilities/Logger.hpp"
0012 #include "ActsExamples/Utilities/Helpers.hpp"
0013 #include "ActsFatras/EventData/Particle.hpp"
0014 
0015 #include <map>
0016 #include <memory>
0017 #include <string>
0018 
0019 class TEfficiency;
0020 namespace ActsFatras {
0021 class Particle;
0022 }  // namespace ActsFatras
0023 
0024 namespace ActsExamples {
0025 
0026 // Tools to make efficiency plots to show tracking efficiency.
0027 // For the moment, the efficiency is taken as the fraction of successfully
0028 // smoothed track over all tracks
0029 class EffPlotTool {
0030  public:
0031   /// @brief The nested configuration struct
0032   struct Config {
0033     std::map<std::string, PlotHelpers::Binning> varBinning = {
0034         {"Eta", PlotHelpers::Binning("#eta", 40, -4, 4)},
0035         {"Phi", PlotHelpers::Binning("#phi", 100, -3.15, 3.15)},
0036         {"Pt", PlotHelpers::Binning("pT [GeV/c]", 40, 0, 100)},
0037         {"DeltaR", PlotHelpers::Binning("#Delta R", 100, 0, 0.3)}};
0038   };
0039 
0040   /// @brief Nested Cache struct
0041   struct EffPlotCache {
0042     TEfficiency* trackEff_vs_pT{nullptr};   ///< Tracking efficiency vs pT
0043     TEfficiency* trackEff_vs_eta{nullptr};  ///< Tracking efficiency vs eta
0044     TEfficiency* trackEff_vs_phi{nullptr};  ///< Tracking efficiency vs phi
0045     TEfficiency* trackEff_vs_DeltaR{
0046         nullptr};  ///< Tracking efficiency vs distance to the closest truth
0047                    ///< particle
0048   };
0049 
0050   /// Constructor
0051   ///
0052   /// @param cfg Configuration struct
0053   /// @param lvl Message level declaration
0054   EffPlotTool(const Config& cfg, Acts::Logging::Level lvl);
0055 
0056   /// @brief book the efficiency plots
0057   ///
0058   /// @param effPlotCache the cache for efficiency plots
0059   void book(EffPlotCache& effPlotCache) const;
0060 
0061   /// @brief fill efficiency plots
0062   ///
0063   /// @param effPlotCache cache object for efficiency plots
0064   /// @param truthParticle the truth Particle
0065   /// @param deltaR the distance to the closest truth particle
0066   /// @param status the reconstruction status
0067   void fill(EffPlotCache& effPlotCache,
0068             const ActsFatras::Particle& truthParticle, double deltaR,
0069             bool status) const;
0070 
0071   /// @brief write the efficiency plots to file
0072   ///
0073   /// @param effPlotCache cache object for efficiency plots
0074   void write(const EffPlotCache& effPlotCache) const;
0075 
0076   /// @brief delete the efficiency plots
0077   ///
0078   /// @param effPlotCache cache object for efficiency plots
0079   void clear(EffPlotCache& effPlotCache) const;
0080 
0081  private:
0082   Config m_cfg;                                  ///< The Config class
0083   std::unique_ptr<const Acts::Logger> m_logger;  ///< The logging instance
0084 
0085   /// The logger
0086   const Acts::Logger& logger() const { return *m_logger; }
0087 };
0088 
0089 }  // namespace ActsExamples