Skip to content

Commit

Permalink
feat: Use Barcode for vertex ID in VertexPerformanceWriter (acts-…
Browse files Browse the repository at this point in the history
…project#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
- acts-project#2989
  • Loading branch information
andiwand authored Feb 28, 2024
1 parent 5eb39c3 commit 9854009
Showing 1 changed file with 17 additions and 18 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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<int> contributingTruthVertices;
std::vector<SimBarcode> contributingTruthVertices;

if (m_cfg.useTracks) {
for (const auto& trk : tracksAtVtx) {
Expand All @@ -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;
}
Expand All @@ -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<int, int> fmap;
for (int priVtxId : contributingTruthVertices) {
fmap[priVtxId]++;
std::map<SimBarcode, int> 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;
Expand All @@ -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;
}
}
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit 9854009

Please sign in to comment.