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/Utilities/Helpers.hpp"
0014 
0015 #include <cstddef>
0016 #include <map>
0017 #include <memory>
0018 #include <string>
0019 
0020 class TProfile;
0021 
0022 namespace ActsExamples {
0023 
0024 /// Tools to make track quality plots.
0025 class TrackQualityPlotTool {
0026  public:
0027   /// @brief The nested configuration struct
0028   struct Config {
0029     std::map<std::string, PlotHelpers::Binning> varBinning = {
0030         {"Eta", PlotHelpers::Binning("#eta", 40, -4, 4)},
0031         {"Phi", PlotHelpers::Binning("#phi", 100, -3.15, 3.15)},
0032         {"Pt", PlotHelpers::Binning("pT [GeV/c]", 40, 0, 100)},
0033         {"Num", PlotHelpers::Binning("N", 30, -0.5, 29.5)}};
0034   };
0035 
0036   /// @brief Nested Cache struct
0037   struct Cache {
0038     TProfile* completeness_vs_pT;
0039     TProfile* completeness_vs_eta;
0040     TProfile* completeness_vs_phi;
0041     TProfile* purity_vs_pT;
0042     TProfile* purity_vs_eta;
0043     TProfile* purity_vs_phi;
0044   };
0045 
0046   /// Constructor
0047   ///
0048   /// @param cfg Configuration struct
0049   /// @param lvl Message level declaration
0050   TrackQualityPlotTool(const Config& cfg, Acts::Logging::Level lvl);
0051 
0052   /// @brief book the track quality plots
0053   ///
0054   /// @param cache the cache for track quality plots
0055   void book(Cache& cache) const;
0056 
0057   /// @brief fill track quality w.r.t. fitted track parameters
0058   ///
0059   /// @param cache cache object for track quality plots
0060   /// @param fittedParameters fitted track parameters of this track
0061   /// @param completeness completeness of the track
0062   /// @param purity purity of the track
0063   void fill(Cache& cache, const Acts::BoundTrackParameters& fittedParameters,
0064             double completeness, double purity) const;
0065 
0066   /// @brief write the track quality plots to file
0067   ///
0068   /// @param cache cache object for track quality plots
0069   void write(const Cache& cache) const;
0070 
0071   /// @brief delete the track quality plots
0072   ///
0073   /// @param cache cache object for track quality plots
0074   void clear(Cache& cache) const;
0075 
0076  private:
0077   /// The Config class
0078   Config m_cfg;
0079   /// The logging instance
0080   std::unique_ptr<const Acts::Logger> m_logger;
0081 
0082   /// The logger
0083   const Acts::Logger& logger() const { return *m_logger; }
0084 };
0085 
0086 }  // namespace ActsExamples