Skip to content

Commit

Permalink
refactor: Rename CKFPerformanceWriter in Examples (#3763)
Browse files Browse the repository at this point in the history
Followup of #3737

I usually expect some accumulated plots in the performance writers we can directly look at. At the same time the `CKFPerformanceWriter` is generic enough to write the performance for any finder.

Therefore I propose to
- Rename `TrackFinderPerformanceWriter` to `TrackFinderNTupleWriter` (#3737)
- Rename `CKFPerformanceWriter` to `TrackFinderPerformanceWriter` (this pr)

blocked by 
- #3742
- #3737
  • Loading branch information
andiwand authored Oct 19, 2024
1 parent 0627ea9 commit dd28958
Show file tree
Hide file tree
Showing 19 changed files with 63 additions and 62 deletions.
20 changes: 10 additions & 10 deletions CI/physmon/phys_perf_mon.sh
Original file line number Diff line number Diff line change
Expand Up @@ -223,11 +223,11 @@ function trackfinding() {
fi

run_histcmp \
$outdir/data/$path/performance_ckf.root \
$refdir/$path/performance_ckf.root \
$outdir/data/$path/performance_finding_ckf.root \
$refdir/$path/performance_finding_ckf.root \
"CKF finding performance | ${name}" \
$path/performance_ckf.html \
$path/performance_ckf_plots \
$path/performance_finding_ckf.html \
$path/performance_finding_ckf_plots \
--config $default_config

run_histcmp \
Expand All @@ -252,17 +252,17 @@ function trackfinding() {
run_histcmp \
$outdir/data/$path/tracksummary_ckf_hist.root \
$refdir/$path/tracksummary_ckf_hist.root \
"Track Summary CKF | ${name}" \
"CKF track summary | ${name}" \
$path/tracksummary_ckf.html \
$path/tracksummary_ckf_plots

if [ -f $refdir/$path/performance_ckf_ambi.root ]; then
if [ -f $refdir/$path/performance_finding_ckf_ambi.root ]; then
run_histcmp \
$outdir/data/$path/performance_ckf_ambi.root \
$refdir/$path/performance_ckf_ambi.root \
$outdir/data/$path/performance_finding_ckf_ambi.root \
$refdir/$path/performance_finding_ckf_ambi.root \
"Ambisolver finding performance | ${name}" \
$path/performance_ckf_ambi.html \
$path/performance_ckf_ambi
$path/performance_finding_ckf_ambi.html \
$path/performance_finding_ckf_ambi
fi
}

Expand Down
2 changes: 1 addition & 1 deletion CI/physmon/workflows/physmon_trackfinding_1muon.py
Original file line number Diff line number Diff line change
Expand Up @@ -164,8 +164,8 @@ def run_ckf_tracking(label, seeding):
else []
) + [
"tracksummary_ckf.root",
"performance_finding_ckf.root",
"performance_fitting_ckf.root",
"performance_ckf.root",
]:
perf_file = tp / file
assert perf_file.exists(), f"Performance file not found {perf_file}"
Expand Down
12 changes: 6 additions & 6 deletions CI/physmon/workflows/physmon_trackfinding_4muon_50vertices.py
Original file line number Diff line number Diff line change
Expand Up @@ -196,12 +196,12 @@
s.run()

shutil.move(
tp / "performance_fitting_ambi.root",
tp / "performance_fitting_ckf_ambi.root",
tp / "performance_finding_ambi.root",
tp / "performance_finding_ckf_ambi.root",
)
shutil.move(
tp / "performance_ambi.root",
tp / "performance_ckf_ambi.root",
tp / "performance_fitting_ambi.root",
tp / "performance_fitting_ckf_ambi.root",
)
for vertexing in ["ivf_notime", "amvf_gauss_notime", "amvf_grid_time"]:
shutil.move(
Expand All @@ -212,10 +212,10 @@
for file in [
"performance_seeding.root",
"tracksummary_ckf.root",
"performance_finding_ckf.root",
"performance_fitting_ckf.root",
"performance_ckf.root",
"performance_finding_ckf_ambi.root",
"performance_fitting_ckf_ambi.root",
"performance_ckf_ambi.root",
"performance_vertexing_ivf_notime.root",
"performance_vertexing_amvf_gauss_notime.root",
"performance_vertexing_amvf_grid_time.root",
Expand Down
12 changes: 6 additions & 6 deletions CI/physmon/workflows/physmon_trackfinding_ttbar_pu200.py
Original file line number Diff line number Diff line change
Expand Up @@ -180,12 +180,12 @@
s.run()

shutil.move(
tp / "performance_fitting_ambi.root",
tp / "performance_fitting_ckf_ambi.root",
tp / "performance_finding_ambi.root",
tp / "performance_finding_ckf_ambi.root",
)
shutil.move(
tp / "performance_ambi.root",
tp / "performance_ckf_ambi.root",
tp / "performance_fitting_ambi.root",
tp / "performance_fitting_ckf_ambi.root",
)
for vertexing in ["amvf_gauss_notime", "amvf_grid_time"]:
shutil.move(
Expand All @@ -196,10 +196,10 @@
for file in [
"performance_seeding.root",
"tracksummary_ckf.root",
"performance_finding_ckf.root",
"performance_fitting_ckf.root",
"performance_ckf.root",
"performance_finding_ckf_ambi.root",
"performance_fitting_ckf_ambi.root",
"performance_ckf_ambi.root",
"performance_vertexing_amvf_gauss_notime.root",
"performance_vertexing_amvf_grid_time.root",
]:
Expand Down
2 changes: 1 addition & 1 deletion Examples/Io/Root/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ add_library(
src/RootAthenaDumpReader.cpp
src/RootNuclearInteractionParametersWriter.cpp
src/detail/NuclearInteractionParametrisation.cpp
src/CKFPerformanceWriter.cpp
src/TrackFinderPerformanceWriter.cpp
src/SeedingPerformanceWriter.cpp
src/TrackFinderNTupleWriter.cpp
src/TrackFitterPerformanceWriter.cpp
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ struct AlgorithmContext;
/// done by setting the Config::rootFile pointer to an existing file.
///
/// Safe to use from multiple writer threads - uses a std::mutex lock.
class CKFPerformanceWriter final : public WriterT<ConstTrackContainer> {
class TrackFinderPerformanceWriter final : public WriterT<ConstTrackContainer> {
public:
struct Config {
/// Input (found) tracks collection.
Expand All @@ -68,8 +68,8 @@ class CKFPerformanceWriter final : public WriterT<ConstTrackContainer> {
};

/// Construct from configuration and log level.
CKFPerformanceWriter(Config cfg, Acts::Logging::Level lvl);
~CKFPerformanceWriter() override;
TrackFinderPerformanceWriter(Config cfg, Acts::Logging::Level lvl);
~TrackFinderPerformanceWriter() override;

/// Finalize plots.
ProcessCode finalize() override;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
// License, v. 2.0. If a copy of the MPL was not distributed with this
// file, You can obtain one at https://mozilla.org/MPL/2.0/.

#include "ActsExamples/Io/Root/CKFPerformanceWriter.hpp"
#include "ActsExamples/Io/Root/TrackFinderPerformanceWriter.hpp"

#include "Acts/EventData/TrackParameters.hpp"
#include "Acts/Utilities/VectorHelpers.hpp"
Expand All @@ -27,9 +27,9 @@ using Acts::VectorHelpers::phi;

namespace ActsExamples {

CKFPerformanceWriter::CKFPerformanceWriter(CKFPerformanceWriter::Config cfg,
Acts::Logging::Level lvl)
: WriterT(cfg.inputTracks, "CKFPerformanceWriter", lvl),
TrackFinderPerformanceWriter::TrackFinderPerformanceWriter(
TrackFinderPerformanceWriter::Config cfg, Acts::Logging::Level lvl)
: WriterT(cfg.inputTracks, "TrackFinderPerformanceWriter", lvl),
m_cfg(std::move(cfg)),
m_effPlotTool(m_cfg.effPlotToolConfig, lvl),
m_fakeRatePlotTool(m_cfg.fakeRatePlotToolConfig, lvl),
Expand Down Expand Up @@ -76,7 +76,7 @@ CKFPerformanceWriter::CKFPerformanceWriter(CKFPerformanceWriter::Config cfg,
m_trackSummaryPlotTool.book(m_trackSummaryPlotCache);
}

CKFPerformanceWriter::~CKFPerformanceWriter() {
TrackFinderPerformanceWriter::~TrackFinderPerformanceWriter() {
m_effPlotTool.clear(m_effPlotCache);
m_fakeRatePlotTool.clear(m_fakeRatePlotCache);
m_duplicationPlotTool.clear(m_duplicationPlotCache);
Expand All @@ -86,7 +86,7 @@ CKFPerformanceWriter::~CKFPerformanceWriter() {
}
}

ProcessCode CKFPerformanceWriter::finalize() {
ProcessCode TrackFinderPerformanceWriter::finalize() {
float eff_tracks = static_cast<float>(m_nTotalMatchedTracks) / m_nTotalTracks;
float fakeRate_tracks =
static_cast<float>(m_nTotalFakeTracks) / m_nTotalTracks;
Expand Down Expand Up @@ -147,8 +147,8 @@ ProcessCode CKFPerformanceWriter::finalize() {
return ProcessCode::SUCCESS;
}

ProcessCode CKFPerformanceWriter::writeT(const AlgorithmContext& ctx,
const ConstTrackContainer& tracks) {
ProcessCode TrackFinderPerformanceWriter::writeT(
const AlgorithmContext& ctx, const ConstTrackContainer& tracks) {
// The number of majority particle hits and fitted track parameters
using Acts::VectorHelpers::perp;

Expand Down
32 changes: 16 additions & 16 deletions Examples/Python/python/acts/examples/reconstruction.py
Original file line number Diff line number Diff line change
Expand Up @@ -1532,7 +1532,7 @@ def addCKFTracks(
writeSummary=writeTrackSummary,
writeStates=writeTrackStates,
writeFitterPerformance=writePerformance,
writeCkfPerformance=writePerformance,
writeFinderPerformance=writePerformance,
writeCovMat=writeCovMat,
logLevel=logLevel,
)
Expand Down Expand Up @@ -1609,7 +1609,7 @@ def addTrackWriters(
writeSummary: bool = True,
writeStates: bool = False,
writeFitterPerformance: bool = False,
writeCkfPerformance: bool = False,
writeFinderPerformance: bool = False,
logLevel: Optional[acts.logging.Level] = None,
writeCovMat=False,
):
Expand Down Expand Up @@ -1655,16 +1655,16 @@ def addTrackWriters(
)
s.addWriter(trackFitterPerformanceWriter)

if writeCkfPerformance:
ckfPerfWriter = acts.examples.CKFPerformanceWriter(
if writeFinderPerformance:
trackFinderPerfWriter = acts.examples.TrackFinderPerformanceWriter(
level=customLogLevel(),
inputTracks=tracks,
inputParticles="particles_selected",
inputTrackParticleMatching="track_particle_matching",
inputParticleTrackMatching="particle_track_matching",
filePath=str(outputDirRoot / f"performance_{name}.root"),
filePath=str(outputDirRoot / f"performance_finding_{name}.root"),
)
s.addWriter(ckfPerfWriter)
s.addWriter(trackFinderPerfWriter)

if outputDirCsv is not None:
outputDirCsv = Path(outputDirCsv)
Expand Down Expand Up @@ -1920,7 +1920,7 @@ def addAmbiguityResolution(
writeSummary=writeTrackStates,
writeStates=writeTrackSummary,
writeFitterPerformance=writePerformance,
writeCkfPerformance=writePerformance,
writeFinderPerformance=writePerformance,
writeCovMat=writeCovMat,
logLevel=logLevel,
)
Expand Down Expand Up @@ -1974,10 +1974,10 @@ def addScoreBasedAmbiguityResolution(
tracks=algScoreBased.config.outputTracks,
outputDirCsv=outputDirCsv,
outputDirRoot=outputDirRoot,
writeSummary=writeTrackSummary,
writeStates=writeTrackStates,
writeSummary=writeTrackStates,
writeStates=writeTrackSummary,
writeFitterPerformance=writePerformance,
writeCkfPerformance=writePerformance,
writeFinderPerformance=writePerformance,
writeCovMat=writeCovMat,
logLevel=logLevel,
)
Expand Down Expand Up @@ -2035,10 +2035,10 @@ def addAmbiguityResolutionML(
tracks=algGreedy.config.outputTracks,
outputDirCsv=outputDirCsv,
outputDirRoot=outputDirRoot,
writeSummary=writeTrackSummary,
writeStates=writeTrackStates,
writeSummary=writeTrackStates,
writeStates=writeTrackSummary,
writeFitterPerformance=writePerformance,
writeCkfPerformance=writePerformance,
writeFinderPerformance=writePerformance,
writeCovMat=writeCovMat,
logLevel=logLevel,
)
Expand Down Expand Up @@ -2084,10 +2084,10 @@ def addAmbiguityResolutionMLDBScan(
trajectories=alg.config.outputTracks,
outputDirRoot=outputDirRoot,
outputDirCsv=outputDirCsv,
writeSummary=writeTrackSummary,
writeStates=writeTrackStates,
writeSummary=writeTrackStates,
writeStates=writeTrackSummary,
writeFitterPerformance=writePerformance,
writeCkfPerformance=writePerformance,
writeFinderPerformance=writePerformance,
writeCovMat=writeCovMat,
logLevel=logLevel,
)
Expand Down
17 changes: 9 additions & 8 deletions Examples/Python/src/Output.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@
#include "ActsExamples/Io/Csv/CsvTrackParameterWriter.hpp"
#include "ActsExamples/Io/Csv/CsvTrackWriter.hpp"
#include "ActsExamples/Io/Csv/CsvTrackingGeometryWriter.hpp"
#include "ActsExamples/Io/Root/CKFPerformanceWriter.hpp"
#include "ActsExamples/Io/Root/RootBFieldWriter.hpp"
#include "ActsExamples/Io/Root/RootMaterialTrackWriter.hpp"
#include "ActsExamples/Io/Root/RootMaterialWriter.hpp"
Expand All @@ -44,6 +43,7 @@
#include "ActsExamples/Io/Root/RootVertexWriter.hpp"
#include "ActsExamples/Io/Root/SeedingPerformanceWriter.hpp"
#include "ActsExamples/Io/Root/TrackFinderNTupleWriter.hpp"
#include "ActsExamples/Io/Root/TrackFinderPerformanceWriter.hpp"
#include "ActsExamples/Io/Root/TrackFitterPerformanceWriter.hpp"
#include "ActsExamples/Io/Root/VertexNTupleWriter.hpp"
#include "ActsExamples/MaterialMapping/IMaterialWriter.hpp"
Expand Down Expand Up @@ -163,7 +163,7 @@ void addOutput(Context& ctx) {
ACTS_PYTHON_STRUCT_END();
}

// Bindings for the binning in e.g., CKFPerformanceWriter
// Bindings for the binning in e.g., TrackFinderPerformanceWriter
{
py::class_<PlotHelpers::Binning>(mex, "Binning")
.def(py::init<std::string, int, double, double>(), "title"_a, "bins"_a,
Expand Down Expand Up @@ -395,12 +395,13 @@ void addOutput(Context& ctx) {
trackingGeometry, outputDir, outputPrecision, writeSensitive,
writeBoundary, writeSurfaceGrid, writeLayerVolume, writePerEvent);

ACTS_PYTHON_DECLARE_WRITER(
ActsExamples::CKFPerformanceWriter, mex, "CKFPerformanceWriter",
inputTracks, inputParticles, inputTrackParticleMatching,
inputParticleTrackMatching, filePath, fileMode, effPlotToolConfig,
fakeRatePlotToolConfig, duplicationPlotToolConfig,
trackSummaryPlotToolConfig, writeMatchingDetails);
ACTS_PYTHON_DECLARE_WRITER(ActsExamples::TrackFinderPerformanceWriter, mex,
"TrackFinderPerformanceWriter", inputTracks,
inputParticles, inputTrackParticleMatching,
inputParticleTrackMatching, filePath, fileMode,
effPlotToolConfig, fakeRatePlotToolConfig,
duplicationPlotToolConfig,
trackSummaryPlotToolConfig, writeMatchingDetails);

ACTS_PYTHON_DECLARE_WRITER(
ActsExamples::RootNuclearInteractionParametersWriter, mex,
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 @@ -73,7 +73,7 @@ test_root_clusters_writer[kwargsConstructor]__clusters.root: e842df4fe04eefff3df
test_exatrkx[cpu-torch]__performance_track_finding.root: 36b3045589c4c17c038dbc87943366f4af4440f7eea6887afb763871ac149b05
test_exatrkx[gpu-onnx]__performance_track_finding.root: 9090de10ffb1489d3f1993e2a3081a3038227e3e5c453e98a9a4f33ea3d6d817
test_exatrkx[gpu-torch]__performance_track_finding.root: 36b3045589c4c17c038dbc87943366f4af4440f7eea6887afb763871ac149b05
test_ML_Ambiguity_Solver__performance_ambiML.root: 284ff5c3a08c0b810938e4ac2f8ba8fe2babb17d4c202b624ed69fff731a9006
test_ML_Ambiguity_Solver__performance_finding_ambiML.root: 284ff5c3a08c0b810938e4ac2f8ba8fe2babb17d4c202b624ed69fff731a9006
test_refitting[odd]__trackstates_gsf_refit.root: e297749dc1e7eda3b8dea13defa0499986c584740d93e723a901b498b8e90c71
test_refitting[odd]__tracksummary_gsf_refit.root: d5085882e45a0b699194dff9f40a36e9291227bf65f9aaaf9087f9242ef5ae22
test_refitting[generic]__trackstates_gsf_refit.root: 4424fdf2f27575db825c1a59f8e53a1595946211cbd5b2c8d3a2f71cdcc77ae9
Expand Down
4 changes: 2 additions & 2 deletions Examples/Python/tests/test_examples.py
Original file line number Diff line number Diff line change
Expand Up @@ -1146,7 +1146,7 @@ def test_ckf_tracks_example(

root_files = [
(
"performance_ckf.root",
"performance_finding_ckf.root",
None,
),
(
Expand Down Expand Up @@ -1290,7 +1290,7 @@ def test_full_chain_odd_example_pythia_geant4(tmp_path):
def test_ML_Ambiguity_Solver(tmp_path, assert_root_hash):
# This test literally only ensures that the full chain example can run without erroring out

root_file = "performance_ambiML.root"
root_file = "performance_finding_ambiML.root"
output_dir = "odd_output"
assert not (tmp_path / root_file).exists()

Expand Down

0 comments on commit dd28958

Please sign in to comment.