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