From b0eb2d57463d8cd35b8181523adc68da7822cd3c Mon Sep 17 00:00:00 2001 From: Xin Dong Date: Fri, 16 Aug 2024 14:16:45 -0400 Subject: [PATCH 1/2] Update in IterativeVertexFinder - input chosen to use SeededTrajectories - added association for ReconstructionParticles to output vertices --- .../tracking/IterativeVertexFinder.cc | 48 +++++++++++++++++-- .../tracking/IterativeVertexFinder.h | 3 +- .../tracking/IterativeVertexFinder_factory.h | 4 +- src/global/tracking/tracking.cc | 2 +- 4 files changed, 49 insertions(+), 8 deletions(-) diff --git a/src/algorithms/tracking/IterativeVertexFinder.cc b/src/algorithms/tracking/IterativeVertexFinder.cc index c933a96feb..176e29f738 100644 --- a/src/algorithms/tracking/IterativeVertexFinder.cc +++ b/src/algorithms/tracking/IterativeVertexFinder.cc @@ -29,9 +29,13 @@ #include #include #include +#include #include #include #include +#include +#include +#include #include #include #include @@ -56,10 +60,11 @@ void eicrecon::IterativeVertexFinder::init(std::shared_ptr eicrecon::IterativeVertexFinder::produce( - std::vector trajectories) { + std::vector trajectories, + std::vector reconParticles) { auto outputVertices = std::make_unique(); - + using Propagator = Acts::Propagator>; using PropagatorOptions = Acts::PropagatorOptions<>; #if Acts_VERSION_MAJOR >= 33 @@ -172,14 +177,18 @@ std::unique_ptr eicrecon::IterativeVertexFinder::prod } /// CKF can provide multiple track trajectories for a single input seed for (auto& tip : tips) { + ActsExamples::TrackParameters par = trajectory->trackParameters(tip); + #if Acts_VERSION_MAJOR >= 33 inputTracks.emplace_back(&(trajectory->trackParameters(tip))); #else inputTrackPointers.push_back(&(trajectory->trackParameters(tip))); #endif + m_log->debug(" --- track local position at input = {}, {}", par.localPosition().x(), par.localPosition().y()); + } } - + #if Acts_VERSION_MAJOR >= 33 std::vector vertices; auto result = finder.find(inputTracks, finderOpts, state); @@ -195,7 +204,7 @@ std::unique_ptr eicrecon::IterativeVertexFinder::prod edm4eic::Cov4f cov(vtx.fullCovariance()(0,0), vtx.fullCovariance()(1,1), vtx.fullCovariance()(2,2), vtx.fullCovariance()(3,3), vtx.fullCovariance()(0,1), vtx.fullCovariance()(0,2), vtx.fullCovariance()(0,3), vtx.fullCovariance()(1,2), vtx.fullCovariance()(1,3), - vtx.fullCovariance()(2,3)); + vtx.fullCovariance()(2,3)); auto eicvertex = outputVertices->create(); eicvertex.setType(1); // boolean flag if vertex is primary vertex of event eicvertex.setChi2((float)vtx.fitQuality().first); // chi2 @@ -207,7 +216,36 @@ std::unique_ptr eicrecon::IterativeVertexFinder::prod (float)vtx.time(), }); // vtxposition eicvertex.setPositionError(cov); // covariance - } + + for (const auto& t : vtx.tracks()) { +#if Acts_VERSION_MAJOR >= 33 + const auto& trk = &t.originalParams; + const auto& par = finderCfg.extractParameters(trk); +#else + const auto& par = *t.originalParams; +#endif + m_log->debug(" === track local position from vertex = {}, {}", par.localPosition().x(), par.localPosition().y()); + float loc_a = par.localPosition().x(); + float loc_b = par.localPosition().y(); + + for (const auto part : reconParticles) { + const auto& tracks = part->getTracks(); + for (const auto trk : tracks) { + const auto& traj = trk.getTrajectory(); + const auto& trkPars = traj.getTrackParameters(); + for (const auto par : trkPars) { + if(fabs(par.getLoc().a - loc_a) < 1.e-4 && fabs(par.getLoc().b - loc_b) < 1.e-4) { + m_log->debug(" --- From ReconParticles, track local position = {}, {}", par.getLoc().a, par.getLoc().b); + eicvertex.addToAssociatedParticles(*part); + } // endif + } // end for par + } // end for trk + } // end for part + } // end for t + m_log->info(" +++ One vertex found at (x,y,z) = ({}, {}, {}) mm.", vtx.position().x(), vtx.position().y(), vtx.position().z()); + + } // end for vtx + return std::move(outputVertices); } diff --git a/src/algorithms/tracking/IterativeVertexFinder.h b/src/algorithms/tracking/IterativeVertexFinder.h index b666f99861..183b884a81 100644 --- a/src/algorithms/tracking/IterativeVertexFinder.h +++ b/src/algorithms/tracking/IterativeVertexFinder.h @@ -7,6 +7,7 @@ #include #include #include +#include #include #include #include @@ -24,7 +25,7 @@ class IterativeVertexFinder void init(std::shared_ptr geo_svc, std::shared_ptr log); std::unique_ptr - produce(std::vector trajectories); + produce(std::vector trajectories, std::vector reconParticles); private: std::shared_ptr m_log; diff --git a/src/global/tracking/IterativeVertexFinder_factory.h b/src/global/tracking/IterativeVertexFinder_factory.h index 7ab8450556..c22b9c1bd2 100644 --- a/src/global/tracking/IterativeVertexFinder_factory.h +++ b/src/global/tracking/IterativeVertexFinder_factory.h @@ -7,6 +7,7 @@ #include #include #include +#include #include #include #include @@ -26,6 +27,7 @@ class IterativeVertexFinder_factory : std::unique_ptr m_algo; Input m_acts_trajectories_input {this}; + Input m_edm4eic_reconParticles_input {this, "ReconstructedParticles"}; PodioOutput m_vertices_output {this}; ParameterRef m_maxVertices {this, "maxVertices", config().maxVertices, @@ -47,7 +49,7 @@ class IterativeVertexFinder_factory : } void Process(int64_t run_number, uint64_t event_number) { - m_vertices_output() = m_algo->produce(m_acts_trajectories_input()); + m_vertices_output() = m_algo->produce(m_acts_trajectories_input(), m_edm4eic_reconParticles_input()); } }; diff --git a/src/global/tracking/tracking.cc b/src/global/tracking/tracking.cc index ed5a2ad7a5..480e8a2095 100644 --- a/src/global/tracking/tracking.cc +++ b/src/global/tracking/tracking.cc @@ -226,7 +226,7 @@ void InitPlugin(JApplication *app) { app->Add(new JOmniFactoryGeneratorT( "CentralTrackVertices", - {"CentralCKFActsTrajectories"}, + {"CentralCKFSeededActsTrajectories","ReconstructedSeededChargedParticles"}, {"CentralTrackVertices"}, {}, app From 1444a6ab2b84a38d9b23c37881792d199b13678b Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Fri, 16 Aug 2024 18:24:47 +0000 Subject: [PATCH 2/2] [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --- .../tracking/IterativeVertexFinder.cc | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/src/algorithms/tracking/IterativeVertexFinder.cc b/src/algorithms/tracking/IterativeVertexFinder.cc index 176e29f738..fecd9c8245 100644 --- a/src/algorithms/tracking/IterativeVertexFinder.cc +++ b/src/algorithms/tracking/IterativeVertexFinder.cc @@ -64,7 +64,7 @@ std::unique_ptr eicrecon::IterativeVertexFinder::prod std::vector reconParticles) { auto outputVertices = std::make_unique(); - + using Propagator = Acts::Propagator>; using PropagatorOptions = Acts::PropagatorOptions<>; #if Acts_VERSION_MAJOR >= 33 @@ -177,18 +177,18 @@ std::unique_ptr eicrecon::IterativeVertexFinder::prod } /// CKF can provide multiple track trajectories for a single input seed for (auto& tip : tips) { - ActsExamples::TrackParameters par = trajectory->trackParameters(tip); - + ActsExamples::TrackParameters par = trajectory->trackParameters(tip); + #if Acts_VERSION_MAJOR >= 33 inputTracks.emplace_back(&(trajectory->trackParameters(tip))); #else inputTrackPointers.push_back(&(trajectory->trackParameters(tip))); #endif - m_log->debug(" --- track local position at input = {}, {}", par.localPosition().x(), par.localPosition().y()); - + m_log->debug(" --- track local position at input = {}, {}", par.localPosition().x(), par.localPosition().y()); + } } - + #if Acts_VERSION_MAJOR >= 33 std::vector vertices; auto result = finder.find(inputTracks, finderOpts, state); @@ -204,7 +204,7 @@ std::unique_ptr eicrecon::IterativeVertexFinder::prod edm4eic::Cov4f cov(vtx.fullCovariance()(0,0), vtx.fullCovariance()(1,1), vtx.fullCovariance()(2,2), vtx.fullCovariance()(3,3), vtx.fullCovariance()(0,1), vtx.fullCovariance()(0,2), vtx.fullCovariance()(0,3), vtx.fullCovariance()(1,2), vtx.fullCovariance()(1,3), - vtx.fullCovariance()(2,3)); + vtx.fullCovariance()(2,3)); auto eicvertex = outputVertices->create(); eicvertex.setType(1); // boolean flag if vertex is primary vertex of event eicvertex.setChi2((float)vtx.fitQuality().first); // chi2 @@ -216,7 +216,7 @@ std::unique_ptr eicrecon::IterativeVertexFinder::prod (float)vtx.time(), }); // vtxposition eicvertex.setPositionError(cov); // covariance - + for (const auto& t : vtx.tracks()) { #if Acts_VERSION_MAJOR >= 33 const auto& trk = &t.originalParams; @@ -227,7 +227,7 @@ std::unique_ptr eicrecon::IterativeVertexFinder::prod m_log->debug(" === track local position from vertex = {}, {}", par.localPosition().x(), par.localPosition().y()); float loc_a = par.localPosition().x(); float loc_b = par.localPosition().y(); - + for (const auto part : reconParticles) { const auto& tracks = part->getTracks(); for (const auto trk : tracks) {