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
0020
0021
0022 namespace traccc {
0023
0024
0025
0026
0027 class fake_tracks_plot_tool {
0028 public:
0029
0030 struct config {
0031 std::map<std::string, plot_helpers::binning> var_binning = {
0032 {"Eta", plot_helpers::binning("#eta", 40, -4.f, 4.f)},
0033 {"Phi", plot_helpers::binning("#phi", 100, -3.15f, 3.15f)},
0034 {"Pt", plot_helpers::binning("pT [GeV/c]", 40, 0.f, 100.f)},
0035 {"Num", plot_helpers::binning("N", 30, -0.5f, 29.5f)}};
0036 };
0037
0038
0039 struct fake_tracks_plot_cache {
0040 #ifdef TRACCC_HAVE_ROOT
0041 std::unique_ptr<TProfile> n_fake_vs_pT;
0042 std::unique_ptr<TProfile> n_fake_vs_eta;
0043 std::unique_ptr<TProfile> n_fake_vs_phi;
0044 std::unique_ptr<TEfficiency>
0045 fake_rate_vs_pT;
0046 std::unique_ptr<TEfficiency>
0047 fake_rate_vs_eta;
0048 std::unique_ptr<TEfficiency>
0049 fake_rate_vs_phi;
0050 #endif
0051 };
0052
0053
0054
0055
0056 fake_tracks_plot_tool(const config& cfg) : m_cfg(cfg) {}
0057
0058
0059
0060
0061 void book(std::string_view name, fake_tracks_plot_cache& cache) const {
0062 plot_helpers::binning b_pt = m_cfg.var_binning.at("Pt");
0063 plot_helpers::binning b_eta = m_cfg.var_binning.at("Eta");
0064 plot_helpers::binning b_phi = m_cfg.var_binning.at("Phi");
0065 plot_helpers::binning b_num = m_cfg.var_binning.at("Num");
0066
0067
0068 (void)name;
0069 (void)cache;
0070
0071 #ifdef TRACCC_HAVE_ROOT
0072
0073 cache.fake_rate_vs_pT = plot_helpers::book_eff(
0074 TString(name) + "_fakeTracksRate_vs_pT",
0075 "Fake tracks rate;pT [GeV/c];Fake tracks rate", b_pt);
0076
0077 cache.fake_rate_vs_eta =
0078 plot_helpers::book_eff(TString(name) + "_fakeTracksRate_vs_eta",
0079 "Fake tracks rate;#eta;Fake tracks rate", b_eta);
0080
0081 cache.fake_rate_vs_phi =
0082 plot_helpers::book_eff(TString(name) + "_fakeTracksRate_vs_phi",
0083 "Fake tracks rate;#phi;Fake tracks rate", b_phi);
0084
0085
0086 cache.n_fake_vs_pT = plot_helpers::book_prof(
0087 TString(name) + "_nFakeTracks_vs_pT",
0088 "Averaged number of fake tracks per particle", b_pt, b_num);
0089
0090 cache.n_fake_vs_eta = plot_helpers::book_prof(
0091 TString(name) + "_nFakeTracks_vs_eta",
0092 "Averaged number of fake tracks per particle", b_eta, b_num);
0093
0094 cache.n_fake_vs_phi = plot_helpers::book_prof(
0095 TString(name) + "_nFakeTracks_vs_phi",
0096 "Averaged number of fake tracks per particle", b_phi, b_num);
0097 #endif
0098 }
0099
0100
0101
0102
0103
0104
0105 void fill(fake_tracks_plot_cache& cache, const particle& truth_particle,
0106 size_t n_fake_tracks) const {
0107 const auto t_phi = vector::phi(truth_particle.momentum);
0108 const auto t_eta = vector::eta(truth_particle.momentum);
0109 const auto t_pT = vector::perp(
0110 vector2{truth_particle.momentum[0], truth_particle.momentum[1]});
0111
0112
0113 (void)t_phi;
0114 (void)t_eta;
0115 (void)t_pT;
0116 (void)cache;
0117 (void)n_fake_tracks;
0118
0119 #ifdef TRACCC_HAVE_ROOT
0120 cache.n_fake_vs_pT->Fill(t_pT, static_cast<double>(n_fake_tracks));
0121 cache.n_fake_vs_eta->Fill(t_eta, static_cast<double>(n_fake_tracks));
0122 cache.n_fake_vs_phi->Fill(t_phi, static_cast<double>(n_fake_tracks));
0123 #endif
0124 }
0125
0126
0127
0128
0129 void write(const fake_tracks_plot_cache& cache) const {
0130
0131 (void)cache;
0132
0133 #ifdef TRACCC_HAVE_ROOT
0134 cache.fake_rate_vs_pT->Write();
0135 cache.fake_rate_vs_eta->Write();
0136 cache.fake_rate_vs_phi->Write();
0137 cache.n_fake_vs_pT->Write();
0138 cache.n_fake_vs_eta->Write();
0139 cache.n_fake_vs_phi->Write();
0140 #endif
0141 }
0142
0143 private:
0144 config m_cfg;
0145 };
0146
0147 }