File indexing completed on 2025-01-18 09:11:49
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 ActsExamples::EffPlotTool::EffPlotTool(
0021 const ActsExamples::EffPlotTool::Config& cfg, Acts::Logging::Level lvl)
0022 : m_cfg(cfg), m_logger(Acts::getDefaultLogger("EffPlotTool", lvl)) {}
0023
0024 void ActsExamples::EffPlotTool::book(
0025 EffPlotTool::EffPlotCache& effPlotCache) const {
0026 PlotHelpers::Binning bPhi = m_cfg.varBinning.at("Phi");
0027 PlotHelpers::Binning bEta = m_cfg.varBinning.at("Eta");
0028 PlotHelpers::Binning bPt = m_cfg.varBinning.at("Pt");
0029 PlotHelpers::Binning bDeltaR = m_cfg.varBinning.at("DeltaR");
0030 PlotHelpers::Binning bZ0 = m_cfg.varBinning.at("Z0");
0031 ACTS_DEBUG("Initialize the histograms for efficiency plots");
0032
0033 effPlotCache.trackEff_vs_pT = PlotHelpers::bookEff(
0034 "trackeff_vs_pT", "Tracking efficiency;Truth pT [GeV/c];Efficiency", bPt);
0035
0036 effPlotCache.trackEff_vs_eta = PlotHelpers::bookEff(
0037 "trackeff_vs_eta", "Tracking efficiency;Truth #eta;Efficiency", bEta);
0038
0039 effPlotCache.trackEff_vs_phi = PlotHelpers::bookEff(
0040 "trackeff_vs_phi", "Tracking efficiency;Truth #phi;Efficiency", bPhi);
0041
0042 effPlotCache.trackEff_vs_z0 = PlotHelpers::bookEff(
0043 "trackeff_vs_z0", "Tracking efficiency;Truth z_0 [mm];Efficiency", bZ0);
0044
0045 effPlotCache.trackEff_vs_DeltaR = PlotHelpers::bookEff(
0046 "trackeff_vs_DeltaR",
0047 "Tracking efficiency;Closest track #Delta R;Efficiency", bDeltaR);
0048 }
0049
0050 void ActsExamples::EffPlotTool::clear(EffPlotCache& effPlotCache) const {
0051 delete effPlotCache.trackEff_vs_pT;
0052 delete effPlotCache.trackEff_vs_eta;
0053 delete effPlotCache.trackEff_vs_phi;
0054 delete effPlotCache.trackEff_vs_z0;
0055 delete effPlotCache.trackEff_vs_DeltaR;
0056 }
0057
0058 void ActsExamples::EffPlotTool::write(
0059 const EffPlotTool::EffPlotCache& effPlotCache) const {
0060 ACTS_DEBUG("Write the plots to output file.");
0061 effPlotCache.trackEff_vs_pT->Write();
0062 effPlotCache.trackEff_vs_eta->Write();
0063 effPlotCache.trackEff_vs_phi->Write();
0064 effPlotCache.trackEff_vs_z0->Write();
0065 effPlotCache.trackEff_vs_DeltaR->Write();
0066 }
0067
0068 void ActsExamples::EffPlotTool::fill(EffPlotTool::EffPlotCache& effPlotCache,
0069 const SimParticleState& truthParticle,
0070 double deltaR, bool status) const {
0071 const auto t_phi = phi(truthParticle.direction());
0072 const auto t_eta = eta(truthParticle.direction());
0073 const auto t_pT = truthParticle.transverseMomentum();
0074 const auto t_z0 = truthParticle.position().z();
0075 const auto t_deltaR = deltaR;
0076
0077 PlotHelpers::fillEff(effPlotCache.trackEff_vs_pT, t_pT, status);
0078 PlotHelpers::fillEff(effPlotCache.trackEff_vs_eta, t_eta, status);
0079 PlotHelpers::fillEff(effPlotCache.trackEff_vs_phi, t_phi, status);
0080 PlotHelpers::fillEff(effPlotCache.trackEff_vs_z0, t_z0, status);
0081 PlotHelpers::fillEff(effPlotCache.trackEff_vs_DeltaR, t_deltaR, status);
0082 }