Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-01-18 09:11:47

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/Utilities/Logger.hpp"
0012 #include "ActsExamples/EventData/SimParticle.hpp"
0013 #include "ActsExamples/Utilities/Helpers.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         {"Z0", PlotHelpers::Binning("z_0 [mm]", 50, -200, 200)},
0038         {"DeltaR", PlotHelpers::Binning("#Delta R", 100, 0, 0.3)}};
0039   };
0040 
0041   /// @brief Nested Cache struct
0042   struct EffPlotCache {
0043     TEfficiency* trackEff_vs_pT{nullptr};   ///< Tracking efficiency vs pT
0044     TEfficiency* trackEff_vs_eta{nullptr};  ///< Tracking efficiency vs eta
0045     TEfficiency* trackEff_vs_phi{nullptr};  ///< Tracking efficiency vs phi
0046     TEfficiency* trackEff_vs_z0{nullptr};   ///< Tracking efficiency vs z0
0047     TEfficiency* trackEff_vs_DeltaR{
0048         nullptr};  ///< Tracking efficiency vs distance to the closest truth
0049                    ///< particle
0050   };
0051 
0052   /// Constructor
0053   ///
0054   /// @param cfg Configuration struct
0055   /// @param lvl Message level declaration
0056   EffPlotTool(const Config& cfg, Acts::Logging::Level lvl);
0057 
0058   /// @brief book the efficiency plots
0059   ///
0060   /// @param effPlotCache the cache for efficiency plots
0061   void book(EffPlotCache& effPlotCache) const;
0062 
0063   /// @brief fill efficiency plots
0064   ///
0065   /// @param effPlotCache cache object for efficiency plots
0066   /// @param truthParticle the truth Particle
0067   /// @param deltaR the distance to the closest truth particle
0068   /// @param status the reconstruction status
0069   void fill(EffPlotCache& effPlotCache, const SimParticleState& truthParticle,
0070             double deltaR, bool status) const;
0071 
0072   /// @brief write the efficiency plots to file
0073   ///
0074   /// @param effPlotCache cache object for efficiency plots
0075   void write(const EffPlotCache& effPlotCache) const;
0076 
0077   /// @brief delete the efficiency plots
0078   ///
0079   /// @param effPlotCache cache object for efficiency plots
0080   void clear(EffPlotCache& effPlotCache) const;
0081 
0082  private:
0083   Config m_cfg;                                  ///< The Config class
0084   std::unique_ptr<const Acts::Logger> m_logger;  ///< The logging instance
0085 
0086   /// The logger
0087   const Acts::Logger& logger() const { return *m_logger; }
0088 };
0089 
0090 }  // namespace ActsExamples