Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-07-14 08:11:21

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