File indexing completed on 2026-07-26 08:22:20
0001
0002
0003
0004
0005
0006
0007
0008 #pragma once
0009
0010
0011 #include "../utils/helpers.hpp"
0012
0013
0014 #include "traccc/edm/particle.hpp"
0015
0016
0017 #include <string_view>
0018
0019 namespace traccc {
0020
0021
0022
0023
0024 class eff_plot_tool {
0025 public:
0026
0027 struct config {
0028 std::map<std::string, plot_helpers::binning> var_binning = {
0029 {"Eta", plot_helpers::binning("#eta", 40, -4.f, 4.f)},
0030 {"Phi", plot_helpers::binning("#phi", 100, -3.15f, 3.15f)},
0031 {"Pt", plot_helpers::binning("pT [GeV/c]", 40, 0.f, 100.f)}};
0032 };
0033
0034
0035 struct eff_plot_cache {
0036 #ifdef TRACCC_HAVE_ROOT
0037 std::unique_ptr<TEfficiency>
0038 track_eff_vs_pT;
0039 std::unique_ptr<TEfficiency>
0040 track_eff_vs_eta;
0041 std::unique_ptr<TEfficiency>
0042 track_eff_vs_phi;
0043 #endif
0044 };
0045
0046
0047
0048
0049
0050 eff_plot_tool(const config& cfg) : m_cfg(cfg) {}
0051
0052
0053
0054
0055 void book(std::string_view name, eff_plot_cache& cache) const {
0056 plot_helpers::binning b_phi = m_cfg.var_binning.at("Phi");
0057 plot_helpers::binning b_eta = m_cfg.var_binning.at("Eta");
0058 plot_helpers::binning b_pt = m_cfg.var_binning.at("Pt");
0059
0060
0061 (void)name;
0062 (void)cache;
0063
0064 #ifdef TRACCC_HAVE_ROOT
0065 std::string header;
0066
0067 if (name == "finding") {
0068 header = "Track finding efficiency";
0069 } else if (name == "seeding") {
0070 header = "Seed finding efficiency";
0071 } else {
0072 header = "Tracking efficiency";
0073 }
0074
0075
0076 cache.track_eff_vs_pT =
0077 plot_helpers::book_eff(TString(name) + "_trackeff_vs_pT",
0078 header + ";Truth pT [GeV/c];Efficiency", b_pt);
0079
0080 cache.track_eff_vs_eta =
0081 plot_helpers::book_eff(TString(name) + "_trackeff_vs_eta",
0082 header + ";Truth #eta;Efficiency", b_eta);
0083
0084 cache.track_eff_vs_phi =
0085 plot_helpers::book_eff(TString(name) + "_trackeff_vs_phi",
0086 header + ";Truth #phi;Efficiency", b_phi);
0087 #endif
0088 }
0089
0090
0091
0092
0093
0094
0095 void fill(eff_plot_cache& cache, const particle& truth_particle,
0096 bool status) const {
0097 const auto t_phi = vector::phi(truth_particle.momentum);
0098 const auto t_eta = vector::eta(truth_particle.momentum);
0099 const auto t_pT = vector::perp(
0100 vector2{truth_particle.momentum[0], truth_particle.momentum[1]});
0101
0102
0103 (void)t_phi;
0104 (void)t_eta;
0105 (void)t_pT;
0106 (void)cache;
0107 (void)status;
0108
0109 #ifdef TRACCC_HAVE_ROOT
0110 cache.track_eff_vs_pT->Fill(status, t_pT);
0111 cache.track_eff_vs_eta->Fill(status, t_eta);
0112 cache.track_eff_vs_phi->Fill(status, t_phi);
0113 #endif
0114 }
0115
0116
0117
0118
0119 void write(const eff_plot_cache& cache) const {
0120
0121 (void)cache;
0122
0123 #ifdef TRACCC_HAVE_ROOT
0124 cache.track_eff_vs_pT->Write();
0125 cache.track_eff_vs_eta->Write();
0126 cache.track_eff_vs_phi->Write();
0127 #endif
0128 }
0129
0130 private:
0131 config m_cfg;
0132 };
0133
0134 }