File indexing completed on 2025-12-13 09:21:56
0001
0002
0003
0004
0005
0006
0007
0008
0009 #include "ActsExamples/Validation/FakePlotTool.hpp"
0010
0011 #include "Acts/Utilities/VectorHelpers.hpp"
0012
0013 #include <TEfficiency.h>
0014 #include <TH2.h>
0015
0016 using Acts::VectorHelpers::eta;
0017 using Acts::VectorHelpers::perp;
0018 using Acts::VectorHelpers::phi;
0019 using Acts::VectorHelpers::theta;
0020
0021 namespace ActsExamples {
0022
0023 FakePlotTool::FakePlotTool(const FakePlotTool::Config& cfg,
0024 Acts::Logging::Level lvl)
0025 : m_cfg(cfg), m_logger(Acts::getDefaultLogger("FakePlotTool", lvl)) {}
0026
0027 void FakePlotTool::book(Cache& cache) const {
0028 PlotHelpers::Binning bPt = m_cfg.varBinning.at("Pt");
0029 PlotHelpers::Binning bEta = m_cfg.varBinning.at("Eta");
0030 PlotHelpers::Binning bPhi = m_cfg.varBinning.at("Phi");
0031 PlotHelpers::Binning bNum = m_cfg.varBinning.at("Num");
0032 ACTS_DEBUG("Initialize the histograms for fake ratio plots");
0033
0034
0035 cache.nReco_vs_pT = PlotHelpers::bookHisto(
0036 "nRecoTracks_vs_pT", "Number of reconstructed track candidates", bPt,
0037 bNum);
0038
0039 cache.nTruthMatched_vs_pT = PlotHelpers::bookHisto(
0040 "nTruthMatchedTracks_vs_pT", "Number of truth-matched track candidates",
0041 bPt, bNum);
0042
0043 cache.nFake_vs_pT = PlotHelpers::bookHisto(
0044 "nFakeTracks_vs_pT", "Number of fake track candidates", bPt, bNum);
0045
0046
0047 cache.nReco_vs_eta = PlotHelpers::bookHisto(
0048 "nRecoTracks_vs_eta", "Number of reconstructed track candidates", bEta,
0049 bNum);
0050
0051 cache.nTruthMatched_vs_eta = PlotHelpers::bookHisto(
0052 "nTruthMatchedTracks_vs_eta", "Number of truth-matched track candidates",
0053 bEta, bNum);
0054
0055 cache.nFake_vs_eta = PlotHelpers::bookHisto(
0056 "nFakeTracks_vs_eta", "Number of fake track candidates", bEta, bNum);
0057
0058
0059 cache.fakeRatio_vs_pT = PlotHelpers::bookEff(
0060 "fakeRatio_vs_pT", "Tracking fake ratio;pT [GeV/c];Fake ratio", bPt);
0061
0062 cache.fakeRatio_vs_eta = PlotHelpers::bookEff(
0063 "fakeRatio_vs_eta", "Tracking fake ratio;#eta;Fake ratio", bEta);
0064
0065 cache.fakeRatio_vs_phi = PlotHelpers::bookEff(
0066 "fakeRatio_vs_phi", "Tracking fake ratio;#phi;Fake ratio", bPhi);
0067 }
0068
0069 void FakePlotTool::clear(Cache& cache) const {
0070 delete cache.nReco_vs_pT;
0071 delete cache.nTruthMatched_vs_pT;
0072 delete cache.nFake_vs_pT;
0073 delete cache.nReco_vs_eta;
0074 delete cache.nTruthMatched_vs_eta;
0075 delete cache.nFake_vs_eta;
0076 delete cache.fakeRatio_vs_pT;
0077 delete cache.fakeRatio_vs_eta;
0078 delete cache.fakeRatio_vs_phi;
0079 }
0080
0081 void FakePlotTool::write(const Cache& cache) const {
0082 ACTS_DEBUG("Write the plots to output file.");
0083 cache.nReco_vs_pT->Write();
0084 cache.nTruthMatched_vs_pT->Write();
0085 cache.nFake_vs_pT->Write();
0086 cache.nReco_vs_eta->Write();
0087 cache.nTruthMatched_vs_eta->Write();
0088 cache.nFake_vs_eta->Write();
0089 cache.fakeRatio_vs_pT->Write();
0090 cache.fakeRatio_vs_eta->Write();
0091 cache.fakeRatio_vs_phi->Write();
0092 }
0093
0094 void FakePlotTool::fill(Cache& cache,
0095 const Acts::BoundTrackParameters& fittedParameters,
0096 bool status) const {
0097 const auto momentum = fittedParameters.momentum();
0098 const double fit_phi = phi(momentum);
0099 const double fit_eta = eta(momentum);
0100 const double fit_pT = perp(momentum);
0101
0102 PlotHelpers::fillEff(cache.fakeRatio_vs_pT, fit_pT, status);
0103 PlotHelpers::fillEff(cache.fakeRatio_vs_eta, fit_eta, status);
0104 PlotHelpers::fillEff(cache.fakeRatio_vs_phi, fit_phi, status);
0105 }
0106
0107 void FakePlotTool::fill(Cache& cache, const SimParticleState& truthParticle,
0108 std::size_t nTruthMatchedTracks,
0109 std::size_t nFakeTracks) const {
0110 const auto t_eta = eta(truthParticle.direction());
0111 const auto t_pT = truthParticle.transverseMomentum();
0112
0113 PlotHelpers::fillHisto(cache.nReco_vs_pT, t_pT,
0114 nTruthMatchedTracks + nFakeTracks);
0115 PlotHelpers::fillHisto(cache.nTruthMatched_vs_pT, t_pT, nTruthMatchedTracks);
0116 PlotHelpers::fillHisto(cache.nFake_vs_pT, t_pT, nFakeTracks);
0117
0118 PlotHelpers::fillHisto(cache.nReco_vs_eta, t_eta,
0119 nTruthMatchedTracks + nFakeTracks);
0120 PlotHelpers::fillHisto(cache.nTruthMatched_vs_eta, t_eta,
0121 nTruthMatchedTracks);
0122 PlotHelpers::fillHisto(cache.nFake_vs_eta, t_eta, nFakeTracks);
0123 }
0124
0125 }