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
0025
0026
0027
0028 class duplication_plot_tool {
0029 public:
0030
0031 struct config {
0032 std::map<std::string, plot_helpers::binning> var_binning = {
0033 {"Eta", plot_helpers::binning("#eta", 40, -4.f, 4.f)},
0034 {"Phi", plot_helpers::binning("#phi", 100, -3.15f, 3.15f)},
0035 {"Pt", plot_helpers::binning("pT [GeV/c]", 40, 0.f, 100.f)},
0036 {"Num", plot_helpers::binning("N", 30, -0.5f, 29.5f)}};
0037 };
0038
0039
0040 struct duplication_plot_cache {
0041 #ifdef TRACCC_HAVE_ROOT
0042 std::unique_ptr<TProfile>
0043 n_duplicated_vs_pT;
0044 std::unique_ptr<TProfile>
0045 n_duplicated_vs_eta;
0046 std::unique_ptr<TProfile>
0047 n_duplicated_vs_phi;
0048 std::unique_ptr<TEfficiency>
0049 duplication_rate_vs_pT;
0050 std::unique_ptr<TEfficiency>
0051 duplication_rate_vs_eta;
0052 std::unique_ptr<TEfficiency>
0053 duplication_rate_vs_phi;
0054 #endif
0055 };
0056
0057
0058
0059
0060 duplication_plot_tool(const config& cfg) : m_cfg(cfg) {}
0061
0062
0063
0064
0065 void book(std::string_view name, duplication_plot_cache& cache) const {
0066 plot_helpers::binning b_pt = m_cfg.var_binning.at("Pt");
0067 plot_helpers::binning b_eta = m_cfg.var_binning.at("Eta");
0068 plot_helpers::binning b_phi = m_cfg.var_binning.at("Phi");
0069 plot_helpers::binning b_num = m_cfg.var_binning.at("Num");
0070
0071
0072 (void)name;
0073 (void)cache;
0074
0075 #ifdef TRACCC_HAVE_ROOT
0076
0077 cache.duplication_rate_vs_pT = plot_helpers::book_eff(
0078 TString(name) + "_duplicationRate_vs_pT",
0079 "Duplication rate;pT [GeV/c];Duplication rate", b_pt);
0080
0081 cache.duplication_rate_vs_eta =
0082 plot_helpers::book_eff(TString(name) + "_duplicationRate_vs_eta",
0083 "Duplication rate;#eta;Duplication rate", b_eta);
0084
0085 cache.duplication_rate_vs_phi =
0086 plot_helpers::book_eff(TString(name) + "_duplicationRate_vs_phi",
0087 "Duplication rate;#phi;Duplication rate", b_phi);
0088
0089
0090 cache.n_duplicated_vs_pT = plot_helpers::book_prof(
0091 TString(name) + "_nDuplicated_vs_pT",
0092 "Number of duplicated track candidates", b_pt, b_num);
0093
0094 cache.n_duplicated_vs_eta = plot_helpers::book_prof(
0095 TString(name) + "_nDuplicated_vs_eta",
0096 "Number of duplicated track candidates", b_eta, b_num);
0097
0098 cache.n_duplicated_vs_phi = plot_helpers::book_prof(
0099 TString(name) + "_nDuplicated_vs_phi",
0100 "Number of duplicated track candidates", b_phi, b_num);
0101 #endif
0102 }
0103
0104
0105
0106
0107
0108
0109 void fill(duplication_plot_cache& cache, const particle& truth_particle,
0110 size_t n_duplicated_tracks) const {
0111 const auto t_phi = vector::phi(truth_particle.momentum);
0112 const auto t_eta = vector::eta(truth_particle.momentum);
0113 const auto t_pT = vector::perp(
0114 vector2{truth_particle.momentum[0], truth_particle.momentum[1]});
0115
0116
0117 (void)t_phi;
0118 (void)t_eta;
0119 (void)t_pT;
0120 (void)cache;
0121 (void)n_duplicated_tracks;
0122
0123 #ifdef TRACCC_HAVE_ROOT
0124 cache.n_duplicated_vs_pT->Fill(t_pT,
0125 static_cast<double>(n_duplicated_tracks));
0126 cache.n_duplicated_vs_eta->Fill(t_eta,
0127 static_cast<double>(n_duplicated_tracks));
0128 cache.n_duplicated_vs_phi->Fill(t_phi,
0129 static_cast<double>(n_duplicated_tracks));
0130 #endif
0131 }
0132
0133
0134
0135
0136 void write(const duplication_plot_cache& cache) const {
0137
0138 (void)cache;
0139
0140 #ifdef TRACCC_HAVE_ROOT
0141 cache.duplication_rate_vs_pT->Write();
0142 cache.duplication_rate_vs_eta->Write();
0143 cache.duplication_rate_vs_phi->Write();
0144 cache.n_duplicated_vs_pT->Write();
0145 cache.n_duplicated_vs_eta->Write();
0146 cache.n_duplicated_vs_phi->Write();
0147 #endif
0148 }
0149
0150 private:
0151 config m_cfg;
0152 };
0153
0154 }