File indexing completed on 2025-08-05 08:09:55
0001
0002
0003
0004
0005
0006
0007
0008
0009 #include "ActsExamples/Validation/DuplicationPlotTool.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 <TProfile.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::DuplicationPlotTool::DuplicationPlotTool(
0024 const ActsExamples::DuplicationPlotTool::Config& cfg,
0025 Acts::Logging::Level lvl)
0026 : m_cfg(cfg),
0027 m_logger(Acts::getDefaultLogger("DuplicationPlotTool", lvl)) {}
0028
0029 void ActsExamples::DuplicationPlotTool::book(
0030 DuplicationPlotTool::DuplicationPlotCache& duplicationPlotCache) const {
0031 PlotHelpers::Binning bPt = m_cfg.varBinning.at("Pt");
0032 PlotHelpers::Binning bEta = m_cfg.varBinning.at("Eta");
0033 PlotHelpers::Binning bPhi = m_cfg.varBinning.at("Phi");
0034 PlotHelpers::Binning bNum = m_cfg.varBinning.at("Num");
0035 ACTS_DEBUG("Initialize the histograms for duplication rate plots");
0036
0037
0038 duplicationPlotCache.duplicationRate_vs_pT =
0039 PlotHelpers::bookEff("duplicationRate_vs_pT",
0040 "Duplication rate;pT [GeV/c];Duplication rate", bPt);
0041
0042 duplicationPlotCache.duplicationRate_vs_eta = PlotHelpers::bookEff(
0043 "duplicationRate_vs_eta", "Duplication rate;#eta;Duplication rate", bEta);
0044
0045 duplicationPlotCache.duplicationRate_vs_phi = PlotHelpers::bookEff(
0046 "duplicationRate_vs_phi", "Duplication rate;#phi;Duplication rate", bPhi);
0047
0048
0049 duplicationPlotCache.nDuplicated_vs_pT = PlotHelpers::bookProf(
0050 "nDuplicated_vs_pT", "Number of duplicated track candidates", bPt, bNum);
0051
0052 duplicationPlotCache.nDuplicated_vs_eta = PlotHelpers::bookProf(
0053 "nDuplicated_vs_eta", "Number of duplicated track candidates", bEta,
0054 bNum);
0055
0056 duplicationPlotCache.nDuplicated_vs_phi = PlotHelpers::bookProf(
0057 "nDuplicated_vs_phi", "Number of duplicated track candidates", bPhi,
0058 bNum);
0059 }
0060
0061 void ActsExamples::DuplicationPlotTool::clear(
0062 DuplicationPlotCache& duplicationPlotCache) const {
0063 delete duplicationPlotCache.duplicationRate_vs_pT;
0064 delete duplicationPlotCache.duplicationRate_vs_eta;
0065 delete duplicationPlotCache.duplicationRate_vs_phi;
0066 delete duplicationPlotCache.nDuplicated_vs_pT;
0067 delete duplicationPlotCache.nDuplicated_vs_eta;
0068 delete duplicationPlotCache.nDuplicated_vs_phi;
0069 }
0070
0071 void ActsExamples::DuplicationPlotTool::write(
0072 const DuplicationPlotTool::DuplicationPlotCache& duplicationPlotCache)
0073 const {
0074 ACTS_DEBUG("Write the plots to output file.");
0075 duplicationPlotCache.duplicationRate_vs_pT->Write();
0076 duplicationPlotCache.duplicationRate_vs_eta->Write();
0077 duplicationPlotCache.duplicationRate_vs_phi->Write();
0078 duplicationPlotCache.nDuplicated_vs_pT->Write();
0079 duplicationPlotCache.nDuplicated_vs_eta->Write();
0080 duplicationPlotCache.nDuplicated_vs_phi->Write();
0081 }
0082
0083 void ActsExamples::DuplicationPlotTool::fill(
0084 DuplicationPlotTool::DuplicationPlotCache& duplicationPlotCache,
0085 const Acts::BoundTrackParameters& fittedParameters, bool status) const {
0086 const auto momentum = fittedParameters.momentum();
0087 const double fit_phi = phi(momentum);
0088 const double fit_eta = eta(momentum);
0089 const double fit_pT = perp(momentum);
0090
0091 PlotHelpers::fillEff(duplicationPlotCache.duplicationRate_vs_pT, fit_pT,
0092 status);
0093 PlotHelpers::fillEff(duplicationPlotCache.duplicationRate_vs_eta, fit_eta,
0094 status);
0095 PlotHelpers::fillEff(duplicationPlotCache.duplicationRate_vs_phi, fit_phi,
0096 status);
0097 }
0098
0099 void ActsExamples::DuplicationPlotTool::fill(
0100 DuplicationPlotTool::DuplicationPlotCache& duplicationPlotCache,
0101 const ActsFatras::Particle& truthParticle,
0102 std::size_t nDuplicatedTracks) const {
0103 const auto t_phi = phi(truthParticle.direction());
0104 const auto t_eta = eta(truthParticle.direction());
0105 const auto t_pT = truthParticle.transverseMomentum();
0106
0107 PlotHelpers::fillProf(duplicationPlotCache.nDuplicated_vs_pT, t_pT,
0108 nDuplicatedTracks);
0109 PlotHelpers::fillProf(duplicationPlotCache.nDuplicated_vs_eta, t_eta,
0110 nDuplicatedTracks);
0111 PlotHelpers::fillProf(duplicationPlotCache.nDuplicated_vs_phi, t_phi,
0112 nDuplicatedTracks);
0113 }