From 9854009505553d6df95ab71f332fe69e6193e755 Mon Sep 17 00:00:00 2001 From: Andreas Stefl Date: Wed, 28 Feb 2024 22:30:01 +0100 Subject: [PATCH] feat: Use `Barcode` for vertex ID in `VertexPerformanceWriter` (#2970) Instead of decomposing the `Barcode` in primary and secondary we can set the other components to zero and use it as a vertex ID. It would be handy to have an actual vertex ID and a truth vertex EDM but this is a story for another day. blocked by - https://github.com/acts-project/acts/pull/2989 --- .../Performance/VertexPerformanceWriter.cpp | 35 +++++++++---------- 1 file changed, 17 insertions(+), 18 deletions(-) diff --git a/Examples/Io/Performance/ActsExamples/Io/Performance/VertexPerformanceWriter.cpp b/Examples/Io/Performance/ActsExamples/Io/Performance/VertexPerformanceWriter.cpp index ae179a88b0c..7ed676f31fc 100644 --- a/Examples/Io/Performance/ActsExamples/Io/Performance/VertexPerformanceWriter.cpp +++ b/Examples/Io/Performance/ActsExamples/Io/Performance/VertexPerformanceWriter.cpp @@ -19,6 +19,7 @@ #include "Acts/Utilities/MultiIndex.hpp" #include "Acts/Utilities/UnitVectors.hpp" #include "Acts/Vertexing/TrackAtVertex.hpp" +#include "ActsExamples/EventData/SimHit.hpp" #include "ActsExamples/EventData/SimParticle.hpp" #include "ActsExamples/EventData/Trajectories.hpp" #include "ActsExamples/Validation/TrackClassification.hpp" @@ -396,7 +397,7 @@ ActsExamples::ProcessCode ActsExamples::VertexPerformanceWriter::writeT( // Containers for storing truth particles and truth vertices that contribute // to the reconstructed vertex SimParticleContainer particleAtVtx; - std::vector contributingTruthVertices; + std::vector contributingTruthVertices; if (m_cfg.useTracks) { for (const auto& trk : tracksAtVtx) { @@ -418,8 +419,9 @@ ActsExamples::ProcessCode ActsExamples::VertexPerformanceWriter::writeT( // the i-th track parameters const auto& particle = associatedTruthParticles[i]; particleAtVtx.insert(particle); - int priVtxId = particle.particleId().vertexPrimary(); - contributingTruthVertices.push_back(priVtxId); + SimBarcode vtxId = + particle.particleId().setParticle(0).setSubParticle(0); + contributingTruthVertices.push_back(vtxId); foundMatchingParams = true; break; } @@ -430,18 +432,19 @@ ActsExamples::ProcessCode ActsExamples::VertexPerformanceWriter::writeT( } // end loop tracksAtVtx } else { for (const auto& particle : allTruthParticles) { - int priVtxId = particle.particleId().vertexPrimary(); - contributingTruthVertices.push_back(priVtxId); + SimBarcode vtxId = + particle.particleId().setParticle(0).setSubParticle(0); + contributingTruthVertices.push_back(vtxId); } } // Find true vertex that contributes most to the reconstructed vertex - std::map fmap; - for (int priVtxId : contributingTruthVertices) { - fmap[priVtxId]++; + std::map fmap; + for (const SimBarcode& vtxId : contributingTruthVertices) { + fmap[vtxId]++; } int maxOccurrence = -1; - int maxOccurrenceId = -1; + SimBarcode maxOccurrenceId = -1; for (auto it : fmap) { if (it.second > maxOccurrence) { maxOccurrenceId = it.first; @@ -452,8 +455,8 @@ ActsExamples::ProcessCode ActsExamples::VertexPerformanceWriter::writeT( // Count number of reconstructible tracks on truth vertex int nTracksOnTruthVertex = 0; for (const auto& particle : associatedTruthParticles) { - int priVtxId = particle.particleId().vertexPrimary(); - if (priVtxId == maxOccurrenceId) { + SimBarcode vtxId = particle.particleId().setParticle(0).setSubParticle(0); + if (vtxId == maxOccurrenceId) { ++nTracksOnTruthVertex; } } @@ -510,14 +513,10 @@ ActsExamples::ProcessCode ActsExamples::VertexPerformanceWriter::writeT( for (std::size_t j = 0; j < associatedTruthParticles.size(); ++j) { const auto& particle = associatedTruthParticles[j]; - int priVtxId = particle.particleId().vertexPrimary(); - int generation = particle.particleId().generation(); + SimBarcode vtxId = + particle.particleId().setParticle(0).setSubParticle(0); - if (generation > 0) { - // truthparticle from secondary vtx - continue; - } - if (priVtxId == maxOccurrenceId) { + if (vtxId == maxOccurrenceId) { // Vertex found, fill variables // Helper function for computing the pull