Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2026-07-26 08:22:21

0001 /** TRACCC library, part of the ACTS project (R&D line)
0002  *
0003  * (c) 2023-2026 CERN for the benefit of the ACTS project
0004  *
0005  * Mozilla Public License Version 2.0
0006  */
0007 
0008 #pragma once
0009 
0010 // Library include(s).
0011 #include "../utils/helpers.hpp"
0012 #include "traccc/resolution/stat_plot_tool_config.hpp"
0013 
0014 // Project include(s).
0015 #include "traccc/edm/measurement_collection.hpp"
0016 #include "traccc/edm/track_collection.hpp"
0017 #include "traccc/edm/track_state_collection.hpp"
0018 
0019 namespace traccc {
0020 
0021 class stat_plot_tool {
0022  public:
0023   /// @brief Nested Cache struct
0024   struct stat_plot_cache {
0025 #ifdef TRACCC_HAVE_ROOT
0026     // Histogram for the number of DoFs
0027     std::unique_ptr<TH1> ndf_hist;
0028     // Histogram for the chi sqaure
0029     std::unique_ptr<TH1> chi2_hist;
0030     // Histogram for the chi2/ndf
0031     std::unique_ptr<TH1> reduced_chi2_hist;
0032     // Histogram for the pvalue
0033     std::unique_ptr<TH1> pval_hist;
0034     // Histogram for the purity
0035     std::unique_ptr<TH1> purity_hist;
0036     // Histogram for the completeness
0037     std::unique_ptr<TH1> completeness_hist;
0038     // Histogram for chi2 of filtered states
0039     std::map<unsigned int, std::unique_ptr<TH1>> chi2_filtered_hist;
0040     // Histogram for chi2 of smoothed states
0041     std::map<unsigned int, std::unique_ptr<TH1>> chi2_smoothed_hist;
0042     // Histogram for p-value of filtered states
0043     std::map<unsigned int, std::unique_ptr<TH1>> pval_filtered_hist;
0044     // Histogram for p-value of smoothed states
0045     std::map<unsigned int, std::unique_ptr<TH1>> pval_smoothed_hist;
0046 #endif  // TRACCC_HAVE_ROOT
0047   };
0048 
0049   /// Constructor
0050   ///
0051   /// @param cfg Configuration struct
0052   stat_plot_tool(const stat_plot_tool_config& cfg);
0053 
0054   /// @brief book the statistics plots
0055   ///
0056   /// @param cache the cache for statistics plots
0057   void book(stat_plot_cache& cache) const;
0058 
0059   /// @brief fill the cache
0060   ///
0061   /// @tparam track_backend_t the backend type for @c fit_res
0062   ///
0063   /// @param cache the cache for statistics plots
0064   /// @param fit_res fitting information that contains statistics
0065   template <typename track_backend_t>
0066   void fill(stat_plot_cache& cache,
0067             const edm::track<track_backend_t>& fit_res) const;
0068 
0069   /// @brief fill the cache
0070   ///
0071   /// @tparam track_state_backend_t the backend type for @c trk_state
0072   ///
0073   /// @param cache the cache for statistics plots
0074   /// @param trk_state track state at local measurements
0075   template <typename track_state_backend_t>
0076   void fill(stat_plot_cache& cache,
0077             const edm::track_state<track_state_backend_t>& trk_state,
0078             const edm::measurement_collection::host& measurements) const;
0079 
0080   /// @brief fill the cache
0081   /// @param cache the cache for statistics plots
0082   /// @param purity the track purity
0083   /// @param completeness the track completeness
0084   void fill(stat_plot_cache& cache, double purity, double completeness) const;
0085 
0086   /// @brief write the statistics plots into ROOT
0087   ///
0088   /// @param cache the cache for statistics plots
0089   void write(const stat_plot_cache& cache) const;
0090 
0091  private:
0092   stat_plot_tool_config m_cfg;  ///< The Config class
0093 };
0094 
0095 }  // namespace traccc
0096 
0097 // Include the implementation.
0098 #include "stat_plot_tool.ipp"