Skip to content

Commit

Permalink
refactor: Add tracking performance as function of DeltaR (#2692)
Browse files Browse the repository at this point in the history
This PR add an extra histogram to the performance monitoring showing the tracking efficiency as function of the distance to the closest nearby different truth particle (as used in the Track ML paper : https://doi.org/10.1007/s41781-023-00094-w)
  • Loading branch information
Corentin-Allaire authored Nov 22, 2023
1 parent 34fde98 commit d6b8266
Show file tree
Hide file tree
Showing 20 changed files with 79 additions and 7 deletions.
Binary file modified CI/physmon/reference/performance_ambi_orthogonal.root
Binary file not shown.
Binary file modified CI/physmon/reference/performance_ambi_seeded.root
Binary file not shown.
Binary file modified CI/physmon/reference/performance_ambi_ttbar.root
Binary file not shown.
Binary file modified CI/physmon/reference/performance_ckf_orthogonal.root
Binary file not shown.
Binary file modified CI/physmon/reference/performance_ckf_seeded.root
Binary file not shown.
Binary file modified CI/physmon/reference/performance_ckf_truth_estimated.root
Binary file not shown.
Binary file modified CI/physmon/reference/performance_ckf_truth_smeared.root
Binary file not shown.
Binary file modified CI/physmon/reference/performance_ckf_ttbar.root
Binary file not shown.
Binary file modified CI/physmon/reference/performance_gsf.root
Binary file not shown.
Binary file modified CI/physmon/reference/performance_seeding_orthogonal.root
Binary file not shown.
Binary file modified CI/physmon/reference/performance_seeding_seeded.root
Binary file not shown.
Binary file modified CI/physmon/reference/performance_seeding_truth_estimated.root
Binary file not shown.
Binary file modified CI/physmon/reference/performance_seeding_ttbar.root
Binary file not shown.
Binary file modified CI/physmon/reference/performance_truth_tracking.root
Binary file not shown.
Original file line number Diff line number Diff line change
Expand Up @@ -33,14 +33,18 @@ class EffPlotTool {
std::map<std::string, PlotHelpers::Binning> varBinning = {
{"Eta", PlotHelpers::Binning("#eta", 40, -4, 4)},
{"Phi", PlotHelpers::Binning("#phi", 100, -3.15, 3.15)},
{"Pt", PlotHelpers::Binning("pT [GeV/c]", 40, 0, 100)}};
{"Pt", PlotHelpers::Binning("pT [GeV/c]", 40, 0, 100)},
{"DeltaR", PlotHelpers::Binning("#Delta R", 100, 0, 0.3)}};
};

/// @brief Nested Cache struct
struct EffPlotCache {
TEfficiency* trackEff_vs_pT{nullptr}; ///< Tracking efficiency vs pT
TEfficiency* trackEff_vs_eta{nullptr}; ///< Tracking efficiency vs eta
TEfficiency* trackEff_vs_phi{nullptr}; ///< Tracking efficiency vs phi
TEfficiency* trackEff_vs_DeltaR{
nullptr}; ///< Tracking efficiency vs distance to the closest truth
///< particle
};

/// Constructor
Expand All @@ -58,9 +62,11 @@ class EffPlotTool {
///
/// @param effPlotCache cache object for efficiency plots
/// @param truthParticle the truth Particle
/// @param deltaR the distance to the closest truth particle
/// @param status the reconstruction status
void fill(EffPlotCache& effPlotCache,
const ActsFatras::Particle& truthParticle, bool status) const;
const ActsFatras::Particle& truthParticle, double deltaR,
bool status) const;

/// @brief write the efficiency plots to file
///
Expand Down
11 changes: 10 additions & 1 deletion Examples/Framework/src/Validation/EffPlotTool.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ void ActsExamples::EffPlotTool::book(
PlotHelpers::Binning bPhi = m_cfg.varBinning.at("Phi");
PlotHelpers::Binning bEta = m_cfg.varBinning.at("Eta");
PlotHelpers::Binning bPt = m_cfg.varBinning.at("Pt");
PlotHelpers::Binning bDeltaR = m_cfg.varBinning.at("DeltaR");
ACTS_DEBUG("Initialize the histograms for efficiency plots");
// efficiency vs pT
effPlotCache.trackEff_vs_pT = PlotHelpers::bookEff(
Expand All @@ -36,12 +37,17 @@ void ActsExamples::EffPlotTool::book(
// efficiency vs phi
effPlotCache.trackEff_vs_phi = PlotHelpers::bookEff(
"trackeff_vs_phi", "Tracking efficiency;Truth #phi;Efficiency", bPhi);
// efficiancy vs distance to the closest truth particle
effPlotCache.trackEff_vs_DeltaR = PlotHelpers::bookEff(
"trackeff_vs_DeltaR",
"Tracking efficiency;Closest track #Delta R;Efficiency", bDeltaR);
}

void ActsExamples::EffPlotTool::clear(EffPlotCache& effPlotCache) const {
delete effPlotCache.trackEff_vs_pT;
delete effPlotCache.trackEff_vs_eta;
delete effPlotCache.trackEff_vs_phi;
delete effPlotCache.trackEff_vs_DeltaR;
}

void ActsExamples::EffPlotTool::write(
Expand All @@ -50,16 +56,19 @@ void ActsExamples::EffPlotTool::write(
effPlotCache.trackEff_vs_pT->Write();
effPlotCache.trackEff_vs_eta->Write();
effPlotCache.trackEff_vs_phi->Write();
effPlotCache.trackEff_vs_DeltaR->Write();
}

void ActsExamples::EffPlotTool::fill(EffPlotTool::EffPlotCache& effPlotCache,
const ActsFatras::Particle& truthParticle,
bool status) const {
double deltaR, bool status) const {
const auto t_phi = phi(truthParticle.direction());
const auto t_eta = eta(truthParticle.direction());
const auto t_pT = truthParticle.transverseMomentum();
const auto t_deltaR = deltaR;

PlotHelpers::fillEff(effPlotCache.trackEff_vs_pT, t_pT, status);
PlotHelpers::fillEff(effPlotCache.trackEff_vs_eta, t_eta, status);
PlotHelpers::fillEff(effPlotCache.trackEff_vs_phi, t_phi, status);
PlotHelpers::fillEff(effPlotCache.trackEff_vs_DeltaR, t_deltaR, status);
}
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
#include "Acts/EventData/VectorMultiTrajectory.hpp"
#include "Acts/Utilities/Helpers.hpp"
#include "Acts/Utilities/MultiIndex.hpp"
#include "Acts/Utilities/VectorHelpers.hpp"
#include "ActsExamples/Validation/TrackClassification.hpp"
#include "ActsFatras/EventData/Barcode.hpp"
#include "ActsFatras/EventData/Particle.hpp"
Expand All @@ -29,6 +30,9 @@
#include <TVectorFfwd.h>
#include <TVectorT.h>

using Acts::VectorHelpers::eta;
using Acts::VectorHelpers::phi;

namespace ActsExamples {
struct AlgorithmContext;
} // namespace ActsExamples
Expand Down Expand Up @@ -282,8 +286,24 @@ ActsExamples::ProcessCode ActsExamples::CKFPerformanceWriter::writeT(
}
isReconstructed = true;
}
// Loop over all the other truth particle and find the distance to the
// closest one
double minDeltaR = -1;
for (const auto& closeParticle : particles) {
if (closeParticle.particleId() == particleId) {
continue;
}
double p_phi = phi(particle.direction());
double p_eta = eta(particle.direction());
double c_phi = phi(closeParticle.direction());
double c_eta = eta(closeParticle.direction());
double distance = sqrt(pow(p_phi - c_phi, 2) + pow(p_eta - c_eta, 2));
if (minDeltaR == -1 || distance < minDeltaR) {
minDeltaR = distance;
}
}
// Fill efficiency plots
m_effPlotTool.fill(m_effPlotCache, particle, isReconstructed);
m_effPlotTool.fill(m_effPlotCache, particle, minDeltaR, isReconstructed);
// Fill number of duplicated tracks for this particle
m_duplicationPlotTool.fill(m_duplicationPlotCache, particle,
nMatchedTracks - 1);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
#include "SeedingPerformanceWriter.hpp"

#include "Acts/Utilities/MultiIndex.hpp"
#include "Acts/Utilities/VectorHelpers.hpp"
#include "ActsExamples/Utilities/EventDataTransforms.hpp"
#include "ActsExamples/Validation/TrackClassification.hpp"
#include "ActsFatras/EventData/Barcode.hpp"
Expand All @@ -23,6 +24,9 @@

#include <TFile.h>

using Acts::VectorHelpers::eta;
using Acts::VectorHelpers::phi;

namespace ActsExamples {
struct AlgorithmContext;
} // namespace ActsExamples
Expand Down Expand Up @@ -144,7 +148,23 @@ ActsExamples::ProcessCode ActsExamples::SeedingPerformanceWriter::writeT(
nDuplicatedParticles++;
}
}
m_effPlotTool.fill(m_effPlotCache, particle, isMatched);
// Loop over all the other truth particle and find the distance to the
// closest one
double minDeltaR = -1;
for (const auto& closeParticle : particles) {
if (closeParticle.particleId() == particle.particleId()) {
continue;
}
double p_phi = phi(particle.direction());
double p_eta = eta(particle.direction());
double c_phi = phi(closeParticle.direction());
double c_eta = eta(closeParticle.direction());
double distance = sqrt(pow(p_phi - c_phi, 2) + pow(p_eta - c_eta, 2));
if (minDeltaR == -1 || distance < minDeltaR) {
minDeltaR = distance;
}
}
m_effPlotTool.fill(m_effPlotCache, particle, minDeltaR, isMatched);
m_duplicationPlotTool.fill(m_duplicationPlotCache, particle,
nMatchedSeedsForParticle - 1);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
#include <TFile.h>

using Acts::VectorHelpers::eta;
using Acts::VectorHelpers::phi;

ActsExamples::TrackFitterPerformanceWriter::TrackFitterPerformanceWriter(
ActsExamples::TrackFitterPerformanceWriter::Config config,
Expand Down Expand Up @@ -154,7 +155,23 @@ ActsExamples::ProcessCode ActsExamples::TrackFitterPerformanceWriter::writeT(
if (it != reconParticleIds.end()) {
isReconstructed = true;
}
m_effPlotTool.fill(m_effPlotCache, particle, isReconstructed);
// Loop over all the other truth particle and find the distance to the
// closest one
double minDeltaR = -1;
for (const auto& closeParticle : particles) {
if (closeParticle.particleId() == particle.particleId()) {
continue;
}
double p_phi = phi(particle.direction());
double p_eta = eta(particle.direction());
double c_phi = phi(closeParticle.direction());
double c_eta = eta(closeParticle.direction());
double distance = sqrt(pow(p_phi - c_phi, 2) + pow(p_eta - c_eta, 2));
if (minDeltaR == -1 || distance < minDeltaR) {
minDeltaR = distance;
}
}
m_effPlotTool.fill(m_effPlotCache, particle, minDeltaR, isReconstructed);
}

return ProcessCode::SUCCESS;
Expand Down
2 changes: 1 addition & 1 deletion Examples/Python/tests/root_file_hashes.txt
Original file line number Diff line number Diff line change
Expand Up @@ -89,4 +89,4 @@ test_root_clusters_writer[kwargsConstructor]__clusters.root: 8938d494bc39245c355
test_exatrkx[cpu-torch]__performance_track_finding.root: 26dc706b23b693eaf9986d0a6966b38da923cf57e2d99327060090537db27a7b
test_exatrkx[gpu-onnx]__performance_track_finding.root: f2c4065008ed1ae5c022800bfdeed5fdfa5f8e23126f4ccb68846556f58ed407
test_exatrkx[gpu-torch]__performance_track_finding.root: 26dc706b23b693eaf9986d0a6966b38da923cf57e2d99327060090537db27a7b
test_ML_Ambiguity_Solver__performance_ambiML.root: 080e183e758b8593a9c233e2d1b4d213f28fdcb18d82acefdac7c9a5a5763bfc
test_ML_Ambiguity_Solver__performance_ambiML.root: 284ff5c3a08c0b810938e4ac2f8ba8fe2babb17d4c202b624ed69fff731a9006

0 comments on commit d6b8266

Please sign in to comment.