Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-05-14 07:56:52

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/EventData/TrackParameters.hpp"
0012 #include "Acts/Utilities/Logger.hpp"
0013 #include "ActsExamples/EventData/SimParticle.hpp"
0014 #include "ActsExamples/Utilities/Helpers.hpp"
0015 
0016 #include <cstddef>
0017 #include <map>
0018 #include <memory>
0019 #include <string>
0020 
0021 class TEfficiency;
0022 class TH2F;
0023 
0024 namespace ActsExamples {
0025 
0026 /// Tools to make fake ratio plots.
0027 ///
0028 /// The fake ratio (formerly called fake rate) is evaluated on all reco tracks.
0029 /// A track is 'fake' if it's not matched with truth.
0030 class FakePlotTool {
0031  public:
0032   /// @brief The nested configuration struct
0033   struct Config {
0034     std::map<std::string, PlotHelpers::Binning> varBinning = {
0035         {"Eta", PlotHelpers::Binning("#eta", 40, -4, 4)},
0036         {"Phi", PlotHelpers::Binning("#phi", 100, -3.15, 3.15)},
0037         {"Pt", PlotHelpers::Binning("pT [GeV/c]", 40, 0, 100)},
0038         {"Num", PlotHelpers::Binning("N", 30, -0.5, 29.5)}};
0039   };
0040 
0041   /// @brief Nested Cache struct
0042   struct Cache {
0043     /// Number of reco tracks vs pT scatter plot
0044     TH2F* nReco_vs_pT;
0045     /// Number of truth-matched reco tracks vs pT scatter plot
0046     TH2F* nTruthMatched_vs_pT;
0047     /// Number of fake (truth-unmatched) tracks vs pT scatter plot
0048     TH2F* nFake_vs_pT;
0049     /// Number of reco tracks vs eta scatter plot
0050     TH2F* nReco_vs_eta;
0051     /// Number of truth-matched reco tracks vs eta scatter plot
0052     TH2F* nTruthMatched_vs_eta;
0053     /// Number of fake (truth-unmatched) tracks vs eta scatter plot
0054     TH2F* nFake_vs_eta;
0055     /// Tracking fake ratio vs pT
0056     TEfficiency* fakeRatio_vs_pT;
0057     /// Tracking fake ratio vs eta
0058     TEfficiency* fakeRatio_vs_eta;
0059     /// Tracking fake ratio vs phi
0060     TEfficiency* fakeRatio_vs_phi;
0061   };
0062 
0063   /// Constructor
0064   ///
0065   /// @param cfg Configuration struct
0066   /// @param lvl Message level declaration
0067   FakePlotTool(const Config& cfg, Acts::Logging::Level lvl);
0068 
0069   /// @brief book the fake ratio plots
0070   ///
0071   /// @param cache the cache for fake ratio plots
0072   void book(Cache& cache) const;
0073 
0074   /// @brief fill fake ratio w.r.t. fitted track parameters
0075   ///
0076   /// @param cache cache object for fake ratio plots
0077   /// @param fittedParameters fitted track parameters of this track
0078   /// @param status the reconstructed track is fake or not
0079   void fill(Cache& cache, const Acts::BoundTrackParameters& fittedParameters,
0080             bool status) const;
0081 
0082   /// @brief fill number of reco/truth-matched/fake tracks for a truth particle
0083   /// seed
0084   ///
0085   /// @param cache cache object for fake ratio plots
0086   /// @param truthParticle the truth Particle
0087   /// @param nTruthMatchedTracks the number of truth-matched tracks
0088   /// @param nFakeTracks the number of fake tracks
0089   void fill(Cache& cache, const SimParticleState& truthParticle,
0090             std::size_t nTruthMatchedTracks, std::size_t nFakeTracks) const;
0091 
0092   /// @brief write the fake ratio plots to file
0093   ///
0094   /// @param cache cache object for fake ratio plots
0095   void write(const Cache& cache) const;
0096 
0097   /// @brief delete the fake ratio plots
0098   ///
0099   /// @param cache cache object for fake ratio plots
0100   void clear(Cache& cache) const;
0101 
0102  private:
0103   /// The Config class
0104   Config m_cfg;
0105   /// The logging instance
0106   std::unique_ptr<const Acts::Logger> m_logger;
0107 
0108   /// The logger
0109   const Acts::Logger& logger() const { return *m_logger; }
0110 };
0111 
0112 }  // namespace ActsExamples