Skip to content

Commit

Permalink
feat: Update RootVertexPerformanceWriter to work with track finding (#…
Browse files Browse the repository at this point in the history
…1460)

Previously, the `RootVertexPerformanceWriter` assumed a 1:1 correspondence between truth particles and reconstructed tracks. This PR implements hit based truth matching to enable this to run.
  • Loading branch information
paulgessinger committed Sep 1, 2022
1 parent a5df559 commit 48daa1a
Show file tree
Hide file tree
Showing 9 changed files with 304 additions and 40 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,8 @@ class TrackFindingAlgorithm final : public BareAlgorithm {
std::string outputTrajectories;
/// Output track parameters collection.
std::string outputTrackParameters;
/// Output track parameters tips w.r.t outputTrajectories.
std::string outputTrackParametersTips;
/// Type erased track finder function.
std::shared_ptr<TrackFinderFunction> findTracks;
/// CKF measurement selector config
Expand Down
13 changes: 13 additions & 0 deletions Examples/Algorithms/TrackFinding/src/TrackFindingAlgorithm.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,15 @@ ActsExamples::TrackFindingAlgorithm::TrackFindingAlgorithm(
if (m_cfg.outputTrajectories.empty()) {
throw std::invalid_argument("Missing trajectories output collection");
}

if (m_cfg.outputTrackParameters.empty()) {
throw std::invalid_argument(
"Missing track parameter tips output collection");
}

if (m_cfg.outputTrackParametersTips.empty()) {
throw std::invalid_argument("Missing track parameters output collection");
}
}

ActsExamples::ProcessCode ActsExamples::TrackFindingAlgorithm::execute(
Expand All @@ -54,6 +63,7 @@ ActsExamples::ProcessCode ActsExamples::TrackFindingAlgorithm::execute(

// Prepare the output data with TrackParameters
TrackParametersContainer trackParametersContainer;
std::vector<std::pair<size_t, size_t>> trackParametersTips;

// Construct a perigee surface as the target surface
auto pSurface = Acts::Surface::makeShared<Acts::PerigeeSurface>(
Expand Down Expand Up @@ -118,6 +128,7 @@ ActsExamples::ProcessCode ActsExamples::TrackFindingAlgorithm::execute(
for (const auto tip : traj.tips()) {
if (traj.hasTrackParameters(tip)) {
trackParametersContainer.push_back(traj.trackParameters(tip));
trackParametersTips.push_back({trajectories.size() - 1, tip});
}
}
} else {
Expand All @@ -136,6 +147,8 @@ ActsExamples::ProcessCode ActsExamples::TrackFindingAlgorithm::execute(
ctx.eventStore.add(m_cfg.outputTrajectories, std::move(trajectories));
ctx.eventStore.add(m_cfg.outputTrackParameters,
std::move(trackParametersContainer));
ctx.eventStore.add(m_cfg.outputTrackParametersTips,
std::move(trackParametersTips));
return ActsExamples::ProcessCode::SUCCESS;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,14 @@ class RootVertexPerformanceWriter final
std::string inputAssociatedTruthParticles;
/// All event fitted tracks
std::string inputFittedTracks;
/// All event fitted tracks indices
std::string inputFittedTracksIndices;
/// All event fitted tracks tips
std::string inputAllFittedTracksTips;
/// Trajectories object from track finidng
std::string inputTrajectories;
/// Input hit-particles map collection.
std::string inputMeasurementParticlesMap;
/// Input vertex collection.
std::string inputVertices;
/// Input reconstruction time.
Expand All @@ -54,6 +62,9 @@ class RootVertexPerformanceWriter final
/// Minimum fraction of tracks matched between truth
/// and reco vertices to be matched for resolution plots
double minTrackVtxMatchFraction = 0.5;
/// Minimum fraction of hits associated to particle to consider
/// as truth matched
double truthMatchProbMin = 0.5;
};

/// Constructor
Expand Down Expand Up @@ -88,6 +99,20 @@ class RootVertexPerformanceWriter final
std::vector<float>
m_diffz; ///< Difference in z positon between reco and true vtx

std::vector<float> m_truthX;
std::vector<float> m_truthY;
std::vector<float> m_truthZ;

std::vector<float> m_recoX;
std::vector<float> m_recoY;
std::vector<float> m_recoZ;

std::vector<float> m_covXX;
std::vector<float> m_covYY;
std::vector<float> m_covXY;
std::vector<float> m_covYX;
std::vector<float> m_trackVtxMatchFraction;

int m_nrecoVtx = -1; ///< Number of reconstructed vertices
int m_ntrueVtx = -1; ///< Number of true vertices
int m_nVtxDetAcceptance = -1; ///< Number of vertices in detector acceptance
Expand Down

0 comments on commit 48daa1a

Please sign in to comment.