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-2025 CERN for the benefit of the ACTS project
0004  *
0005  * Mozilla Public License Version 2.0
0006  */
0007 
0008 // Project include(s).
0009 #include "traccc/utils/prob.hpp"
0010 
0011 // Library include(s).
0012 #include "stat_plot_tool.hpp"
0013 
0014 namespace traccc {
0015 
0016 stat_plot_tool::stat_plot_tool(const stat_plot_tool_config& cfg) : m_cfg(cfg) {}
0017 
0018 void stat_plot_tool::book(stat_plot_cache& cache) const {
0019   // Avoid unused variable warnings when building the code without ROOT.
0020   (void)cache;
0021 
0022 #ifdef TRACCC_HAVE_ROOT
0023   plot_helpers::binning b_ndf = m_cfg.var_binning.at("ndf");
0024   plot_helpers::binning b_chi2 = m_cfg.var_binning.at("chi2");
0025   plot_helpers::binning b_reduced_chi2 = m_cfg.var_binning.at("reduced_chi2");
0026   plot_helpers::binning b_pval = m_cfg.var_binning.at("pval");
0027   plot_helpers::binning b_chi2_local = m_cfg.var_binning.at("chi2_local");
0028   plot_helpers::binning b_purity = m_cfg.var_binning.at("purity");
0029   plot_helpers::binning b_completeness = m_cfg.var_binning.at("completeness");
0030   cache.ndf_hist = plot_helpers::book_histo("ndf", "NDF", b_ndf);
0031   cache.chi2_hist = plot_helpers::book_histo("chi2", "Chi2", b_chi2);
0032   cache.reduced_chi2_hist =
0033       plot_helpers::book_histo("reduced_chi2", "Chi2/NDF", b_reduced_chi2);
0034   cache.pval_hist = plot_helpers::book_histo("pval", "p value", b_pval);
0035   cache.purity_hist = plot_helpers::book_histo("purity", "Ratio", b_purity);
0036   cache.completeness_hist =
0037       plot_helpers::book_histo("completeness", "Ratio", b_completeness);
0038   for (unsigned int D = 1u; D <= 2u; D++) {
0039     cache.chi2_filtered_hist[D] = plot_helpers::book_histo(
0040         Form("chi2_%dD_filtered", D),
0041         Form("chi2 of %dD filtered parameters", D), b_chi2_local);
0042     cache.chi2_smoothed_hist[D] = plot_helpers::book_histo(
0043         Form("chi2_%dD_smoothed", D),
0044         Form("chi2 of %dD smoothed parameters", D), b_chi2_local);
0045     cache.pval_filtered_hist[D] = plot_helpers::book_histo(
0046         Form("pval_%dD_filtered", D),
0047         Form("p value of %dD filtered parameters", D), b_pval);
0048     cache.pval_smoothed_hist[D] = plot_helpers::book_histo(
0049         Form("pval_%dD_smoothed", D),
0050         Form("p value of %dD smoothed parameters", D), b_pval);
0051   }
0052 #endif  // TRACCC_HAVE_ROOT
0053 }
0054 
0055 void stat_plot_tool::fill(stat_plot_cache& cache, double purity,
0056                           double completeness) const {
0057   // Avoid unused variable warnings when building the code without ROOT.
0058   (void)cache;
0059   (void)purity;
0060   (void)completeness;
0061 
0062 #ifdef TRACCC_HAVE_ROOT
0063   cache.purity_hist->Fill(purity);
0064   cache.completeness_hist->Fill(completeness);
0065 #endif  // TRACCC_HAVE_ROOT
0066 }
0067 
0068 void stat_plot_tool::write(const stat_plot_cache& cache) const {
0069   // Avoid unused variable warnings when building the code without ROOT.
0070   (void)cache;
0071 
0072 #ifdef TRACCC_HAVE_ROOT
0073   cache.ndf_hist->Write();
0074   cache.chi2_hist->Write();
0075   cache.reduced_chi2_hist->Write();
0076   cache.pval_hist->Write();
0077   cache.ndf_hist->Write();
0078   cache.chi2_hist->Write();
0079   cache.reduced_chi2_hist->Write();
0080   cache.pval_hist->Write();
0081   cache.purity_hist->Write();
0082   cache.completeness_hist->Write();
0083 
0084   for (const auto& flt : cache.chi2_filtered_hist) {
0085     flt.second->Write();
0086   }
0087   for (const auto& smt : cache.chi2_smoothed_hist) {
0088     smt.second->Write();
0089   }
0090   for (const auto& flt : cache.pval_filtered_hist) {
0091     flt.second->Write();
0092   }
0093   for (const auto& smt : cache.pval_smoothed_hist) {
0094     smt.second->Write();
0095   }
0096 
0097 #endif  // TRACCC_HAVE_ROOT
0098 }
0099 
0100 }  // namespace traccc