File indexing completed on 2025-07-05 08:11:54
0001
0002
0003
0004
0005
0006
0007
0008
0009 #include "ActsExamples/Validation/EffPlotTool.hpp"
0010
0011 #include "Acts/Utilities/VectorHelpers.hpp"
0012 #include "ActsExamples/EventData/SimParticle.hpp"
0013
0014 #include <TEfficiency.h>
0015
0016 using Acts::VectorHelpers::eta;
0017 using Acts::VectorHelpers::perp;
0018 using Acts::VectorHelpers::phi;
0019
0020 namespace ActsExamples {
0021
0022 EffPlotTool::EffPlotTool(const EffPlotTool::Config& cfg,
0023 Acts::Logging::Level lvl)
0024 : m_cfg(cfg), m_logger(Acts::getDefaultLogger("EffPlotTool", lvl)) {}
0025
0026 void EffPlotTool::book(Cache& cache) const {
0027 PlotHelpers::Binning bPhi = m_cfg.varBinning.at("Phi");
0028 PlotHelpers::Binning bEta = m_cfg.varBinning.at("Eta");
0029 PlotHelpers::Binning bPt = m_cfg.varBinning.at("Pt");
0030 PlotHelpers::Binning bDeltaR = m_cfg.varBinning.at("DeltaR");
0031 PlotHelpers::Binning bZ0 = m_cfg.varBinning.at("Z0");
0032 PlotHelpers::Binning bProdR = m_cfg.varBinning.at("prodR");
0033 ACTS_DEBUG("Initialize the histograms for efficiency plots");
0034
0035 cache.trackEff_vs_pT = PlotHelpers::bookEff(
0036 "trackeff_vs_pT", "Tracking efficiency;Truth pT [GeV/c];Efficiency", bPt);
0037
0038 cache.trackEff_vs_eta = PlotHelpers::bookEff(
0039 "trackeff_vs_eta", "Tracking efficiency;Truth #eta;Efficiency", bEta);
0040
0041 cache.trackEff_vs_phi = PlotHelpers::bookEff(
0042 "trackeff_vs_phi", "Tracking efficiency;Truth #phi;Efficiency", bPhi);
0043
0044 cache.trackEff_vs_z0 = PlotHelpers::bookEff(
0045 "trackeff_vs_z0", "Tracking efficiency;Truth z_0 [mm];Efficiency", bZ0);
0046
0047 cache.trackEff_vs_DeltaR = PlotHelpers::bookEff(
0048 "trackeff_vs_DeltaR",
0049 "Tracking efficiency;Closest track #Delta R;Efficiency", bDeltaR);
0050 cache.trackEff_vs_prodR = PlotHelpers::bookEff(
0051 "trackeff_vs_prodR",
0052 "Tracking efficiency;Production radius [mm];Efficiency", bProdR);
0053 }
0054
0055 void EffPlotTool::clear(Cache& cache) const {
0056 delete cache.trackEff_vs_pT;
0057 delete cache.trackEff_vs_eta;
0058 delete cache.trackEff_vs_phi;
0059 delete cache.trackEff_vs_z0;
0060 delete cache.trackEff_vs_DeltaR;
0061 delete cache.trackEff_vs_prodR;
0062 }
0063
0064 void EffPlotTool::write(const Cache& cache) const {
0065 ACTS_DEBUG("Write the plots to output file.");
0066 cache.trackEff_vs_pT->Write();
0067 cache.trackEff_vs_eta->Write();
0068 cache.trackEff_vs_phi->Write();
0069 cache.trackEff_vs_z0->Write();
0070 cache.trackEff_vs_DeltaR->Write();
0071 cache.trackEff_vs_prodR->Write();
0072 }
0073
0074 void EffPlotTool::fill(Cache& cache, const SimParticleState& truthParticle,
0075 double deltaR, bool status) const {
0076 const auto t_phi = phi(truthParticle.direction());
0077 const auto t_eta = eta(truthParticle.direction());
0078 const auto t_pT = truthParticle.transverseMomentum();
0079 const auto t_z0 = truthParticle.position().z();
0080 const auto t_deltaR = deltaR;
0081 const auto t_prodR =
0082 std::sqrt(truthParticle.position().x() * truthParticle.position().x() +
0083 truthParticle.position().y() * truthParticle.position().y());
0084
0085 PlotHelpers::fillEff(cache.trackEff_vs_pT, t_pT, status);
0086 PlotHelpers::fillEff(cache.trackEff_vs_eta, t_eta, status);
0087 PlotHelpers::fillEff(cache.trackEff_vs_phi, t_phi, status);
0088 PlotHelpers::fillEff(cache.trackEff_vs_z0, t_z0, status);
0089 PlotHelpers::fillEff(cache.trackEff_vs_DeltaR, t_deltaR, status);
0090 PlotHelpers::fillEff(cache.trackEff_vs_prodR, t_prodR, status);
0091 }
0092
0093 }