Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-12-05 09:16:42

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/Definitions/Algebra.hpp"
0012 #include "Acts/Geometry/GeometryContext.hpp"
0013 #include "Acts/Surfaces/PerigeeSurface.hpp"
0014 #include "Acts/Utilities/Logger.hpp"
0015 #include "ActsExamples/EventData/SimParticle.hpp"
0016 #include "ActsExamples/Utilities/Helpers.hpp"
0017 
0018 #include <map>
0019 #include <memory>
0020 #include <string>
0021 
0022 class TEfficiency;
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::Uniform("#eta", 40, -3.0, 3.0)},
0035         {"Phi", PlotHelpers::Binning::Uniform("#phi", 100, -std::numbers::pi,
0036                                               std::numbers::pi)},
0037         {"Pt", PlotHelpers::Binning::Uniform("pT [GeV/c]", 40, 0, 100)},
0038         {"LogPt",
0039          PlotHelpers::Binning::Logarithmic("pT [GeV/c]", 11, 0.1, 100)},
0040         {"LowPt", PlotHelpers::Binning::Uniform("pT [GeV/c]", 40, 0, 2)},
0041         {"D0", PlotHelpers::Binning::Uniform("d_0 [mm]", 200, -200, 200)},
0042         {"Z0", PlotHelpers::Binning::Uniform("z_0 [mm]", 50, -200, 200)},
0043         {"DeltaR", PlotHelpers::Binning::Uniform("#Delta R", 100, 0, 0.3)},
0044         {"prodR", PlotHelpers::Binning::Uniform("prod_R [mm]", 100, 0, 200)}};
0045 
0046     double minTruthPt = 1.0 * Acts::UnitConstants::GeV;
0047 
0048     std::vector<std::pair<double, double>> truthPtRangesForEta = {
0049         {0.9 * Acts::UnitConstants::GeV, 1.1 * Acts::UnitConstants::GeV},
0050         {9 * Acts::UnitConstants::GeV, 11 * Acts::UnitConstants::GeV},
0051         {90 * Acts::UnitConstants::GeV, 110 * Acts::UnitConstants::GeV}};
0052 
0053     std::vector<std::pair<double, double>> truthAbsEtaRangesForPt = {
0054         {0, 0.2}, {0, 0.8}, {1, 2}, {2, 3}};
0055 
0056     /// Beamline to estimate d0 and z0
0057     std::shared_ptr<Acts::Surface> beamline =
0058         Acts::Surface::makeShared<Acts::PerigeeSurface>(Acts::Vector3::Zero());
0059   };
0060 
0061   /// @brief Nested Cache struct
0062   struct Cache {
0063     /// Tracking efficiency vs eta
0064     TEfficiency* trackEff_vs_eta{nullptr};
0065     /// Tracking efficiency vs phi
0066     TEfficiency* trackEff_vs_phi{nullptr};
0067     /// Tracking efficiency vs pT
0068     TEfficiency* trackEff_vs_pT{nullptr};
0069     /// Tracking efficiency vs log pT
0070     TEfficiency* trackEff_vs_LogPt{nullptr};
0071     /// Tracking efficiency vs low pT
0072     TEfficiency* trackEff_vs_LowPt{nullptr};
0073     /// Tracking efficiency vs d0
0074     TEfficiency* trackEff_vs_d0{nullptr};
0075     /// Tracking efficiency vs z0
0076     TEfficiency* trackEff_vs_z0{nullptr};
0077     /// Tracking efficiency vs distance to the closest truth particle
0078     TEfficiency* trackEff_vs_DeltaR{nullptr};
0079     /// Tracking efficiency vs production radius
0080     TEfficiency* trackEff_vs_prodR{nullptr};
0081 
0082     /// Tracking efficiency vs eta and phi
0083     TEfficiency* trackEff_vs_eta_phi{nullptr};
0084     /// Tracking efficiency vs eta and pT
0085     TEfficiency* trackEff_vs_eta_pt{nullptr};
0086 
0087     /// Tracking efficiency vs eta in different pT ranges
0088     std::vector<TEfficiency*> trackEff_vs_eta_inPtRanges;
0089     /// Tracking efficiency vs pT in different abs(eta) ranges
0090     std::vector<TEfficiency*> trackEff_vs_pT_inAbsEtaRanges;
0091   };
0092 
0093   /// Constructor
0094   ///
0095   /// @param cfg Configuration struct
0096   /// @param lvl Message level declaration
0097   EffPlotTool(const Config& cfg, Acts::Logging::Level lvl);
0098 
0099   /// @brief book the efficiency plots
0100   ///
0101   /// @param cache the cache for efficiency plots
0102   void book(Cache& cache) const;
0103 
0104   /// @brief fill efficiency plots
0105   ///
0106   /// @param gctx geometry context
0107   /// @param cache cache object for efficiency plots
0108   /// @param truthParticle the truth Particle
0109   /// @param deltaR the distance to the closest truth particle
0110   /// @param status the reconstruction status
0111   void fill(const Acts::GeometryContext& gctx, Cache& cache,
0112             const SimParticleState& truthParticle, double deltaR,
0113             bool status) const;
0114 
0115   /// @brief write the efficiency plots to file
0116   ///
0117   /// @param cache cache object for efficiency plots
0118   void write(const Cache& cache) const;
0119 
0120   /// @brief delete the efficiency plots
0121   ///
0122   /// @param cache cache object for efficiency plots
0123   void clear(Cache& cache) const;
0124 
0125  private:
0126   /// The Config class
0127   Config m_cfg;
0128   /// The logging instance
0129   std::unique_ptr<const Acts::Logger> m_logger;
0130 
0131   /// The logger
0132   const Acts::Logger& logger() const { return *m_logger; }
0133 };
0134 
0135 }  // namespace ActsExamples