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