Skip to content

Commit

Permalink
refactor: print numeric value for multi index (#1859)
Browse files Browse the repository at this point in the history
was useful for me for debugging as it gets easier to compare numeric particle barcode values

also aligns the way we print these values in the root writer
  • Loading branch information
andiwand authored Feb 14, 2023
1 parent 3623733 commit 3d91137
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 13 deletions.
5 changes: 3 additions & 2 deletions Examples/Io/Root/src/RootTrackParameterWriter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -193,8 +193,9 @@ ActsExamples::ProcessCode ActsExamples::RootTrackParameterWriter::writeT(
m_t_charge = static_cast<int>(particle.charge());
m_t_qop = m_t_charge / p;
} else {
ACTS_WARNING("Truth particle with barcode = " << particleId
<< " not found!");
ACTS_WARNING("Truth particle with barcode " << particleId << "="
<< particleId.value()
<< " not found!");
}
}

Expand Down
9 changes: 5 additions & 4 deletions Examples/Io/Root/src/RootTrajectoryStatesWriter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -294,17 +294,18 @@ ActsExamples::ProcessCode ActsExamples::RootTrajectoryStatesWriter::writeT(
particleHitCounts);
if (not particleHitCounts.empty()) {
// Get the barcode of the majority truth particle
auto barcode = particleHitCounts.front().particleId.value();
auto barcode = particleHitCounts.front().particleId;
// Find the truth particle via the barcode
auto ip = particles.find(barcode);
if (ip != particles.end()) {
const auto& particle = *ip;
ACTS_DEBUG("Find the truth particle with barcode = " << barcode);
ACTS_DEBUG("Find the truth particle with barcode "
<< barcode << "=" << barcode.value());
// Get the truth particle charge
truthQ = static_cast<int>(particle.charge());
} else {
ACTS_WARNING("Truth particle with barcode = " << barcode
<< " not found!");
ACTS_WARNING("Truth particle with barcode "
<< barcode << "=" << barcode.value() << " not found!");
}
}

Expand Down
17 changes: 10 additions & 7 deletions Examples/Io/Root/src/RootTrajectorySummaryWriter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -213,7 +213,8 @@ ActsExamples::ProcessCode ActsExamples::RootTrajectorySummaryWriter::writeT(
trajState.outlierLayer.end());

// Initialize the truth particle info
uint64_t majorityParticleId = std::numeric_limits<size_t>::max();
ActsFatras::Barcode majorityParticleId(
std::numeric_limits<size_t>::max());
unsigned int nMajorityHits = std::numeric_limits<unsigned int>::max();
int t_charge = std::numeric_limits<int>::max();
float t_time = NaNfloat;
Expand Down Expand Up @@ -245,7 +246,7 @@ ActsExamples::ProcessCode ActsExamples::RootTrajectorySummaryWriter::writeT(
// Get the truth particle info
if (not particleHitCounts.empty()) {
// Get the barcode of the majority truth particle
majorityParticleId = particleHitCounts.front().particleId.value();
majorityParticleId = particleHitCounts.front().particleId;
nMajorityHits = particleHitCounts.front().hitCount;

// Find the truth particle via the barcode
Expand All @@ -254,8 +255,9 @@ ActsExamples::ProcessCode ActsExamples::RootTrajectorySummaryWriter::writeT(
foundMajorityParticle = true;

const auto& particle = *ip;
ACTS_DEBUG(
"Find the truth particle with barcode = " << majorityParticleId);
ACTS_DEBUG("Find the truth particle with barcode "
<< majorityParticleId << "="
<< majorityParticleId.value());
// Get the truth particle info at vertex
t_p = particle.absoluteMomentum();
t_charge = static_cast<int>(particle.charge());
Expand Down Expand Up @@ -283,8 +285,9 @@ ActsExamples::ProcessCode ActsExamples::RootTrajectorySummaryWriter::writeT(
}
}
} else {
ACTS_WARNING("Truth particle with barcode = "
<< majorityParticleId
ACTS_WARNING("Truth particle with barcode "
<< majorityParticleId << "="
<< majorityParticleId.value()
<< " not found in the input collection!");
}
}
Expand All @@ -295,7 +298,7 @@ ActsExamples::ProcessCode ActsExamples::RootTrajectorySummaryWriter::writeT(

// Push the corresponding truth particle info for the track.
// Always push back even if majority particle not found
m_majorityParticleId.push_back(majorityParticleId);
m_majorityParticleId.push_back(majorityParticleId.value());
m_nMajorityHits.push_back(nMajorityHits);
m_t_charge.push_back(t_charge);
m_t_time.push_back(t_time);
Expand Down

0 comments on commit 3d91137

Please sign in to comment.