diff --git a/src/algorithms/tracking/IterativeVertexFinder.cc b/src/algorithms/tracking/IterativeVertexFinder.cc index c933a96fe..b0fcbb4fd 100644 --- a/src/algorithms/tracking/IterativeVertexFinder.cc +++ b/src/algorithms/tracking/IterativeVertexFinder.cc @@ -7,13 +7,18 @@ #include #include #include +#include #include #include #include #include #include #include +#include #include +#include +#include +#include #if Acts_VERSION_MAJOR >= 32 #include #else @@ -26,17 +31,23 @@ #include #include #include +#include #include #include #include #include #include #include -#include +#include +#include +#include +#include +#include #include #include #include #include +#include #include #include #include @@ -56,7 +67,8 @@ void eicrecon::IterativeVertexFinder::init(std::shared_ptr eicrecon::IterativeVertexFinder::produce( - std::vector trajectories) { + std::vector trajectories, + const edm4eic::ReconstructedParticleCollection* reconParticles) { auto outputVertices = std::make_unique(); @@ -172,11 +184,14 @@ 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->trace("Track local position at input = {} mm, {} mm", par.localPosition().x() / Acts::UnitConstants::mm, par.localPosition().y() / Acts::UnitConstants::mm); } } @@ -207,7 +222,38 @@ 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->trace("Track local position from vertex = {} mm, {} mm", par.localPosition().x() / Acts::UnitConstants::mm, par.localPosition().y() / Acts::UnitConstants::mm); + 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) { + const double EPSILON = 1.0e-4; // mm + if (fabs((par.getLoc().a / edm4eic::unit::mm) - (loc_a / Acts::UnitConstants::mm)) < EPSILON + && fabs((par.getLoc().b / edm4eic::unit::mm) - (loc_b / Acts::UnitConstants::mm)) < EPSILON) { + m_log->trace("From ReconParticles, track local position [Loc a, Loc b] = {} mm, {} mm", par.getLoc().a / edm4eic::unit::mm, par.getLoc().b / edm4eic::unit::mm); + eicvertex.addToAssociatedParticles(part); + } // endif + } // end for par + } // end for trk + } // end for part + } // end for t + m_log->debug("One vertex found at (x,y,z) = ({}, {}, {}) mm.", vtx.position().x() / Acts::UnitConstants::mm, vtx.position().y() / Acts::UnitConstants::mm, vtx.position().z() / Acts::UnitConstants::mm); + + } // end for vtx + return std::move(outputVertices); } diff --git a/src/algorithms/tracking/IterativeVertexFinder.h b/src/algorithms/tracking/IterativeVertexFinder.h index b666f9986..1bdb81ad9 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, const edm4eic::ReconstructedParticleCollection* reconParticles); private: std::shared_ptr m_log; diff --git a/src/global/tracking/IterativeVertexFinder_factory.h b/src/global/tracking/IterativeVertexFinder_factory.h index 7ab845055..6f981db1a 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}; + PodioInput m_edm4eic_reconParticles_input {this}; 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 7a916effd..fc1b48e97 100644 --- a/src/global/tracking/tracking.cc +++ b/src/global/tracking/tracking.cc @@ -225,7 +225,7 @@ void InitPlugin(JApplication *app) { app->Add(new JOmniFactoryGeneratorT( "CentralTrackVertices", - {"CentralCKFActsTrajectories"}, + {"CentralCKFActsTrajectories","ReconstructedChargedParticles"}, {"CentralTrackVertices"}, {}, app