Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update in IterativeVertexFinder #1574

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
42 changes: 40 additions & 2 deletions src/algorithms/tracking/IterativeVertexFinder.cc
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,13 @@
#include <Acts/Vertexing/Vertex.hpp>
#include <Acts/Vertexing/VertexingOptions.hpp>
#include <Acts/Vertexing/ZScanVertexFinder.hpp>
#include <Acts/Vertexing/TrackAtVertex.hpp>
#include <ActsExamples/EventData/Trajectories.hpp>
#include <boost/container/vector.hpp>
#include <edm4eic/Cov4f.h>
#include <edm4eic/Trajectory.h>
#include <edm4eic/TrackParameters.h>
#include <edm4hep/Vector2f.h>
#include <math.h>
#include <Eigen/Core>
#include <Eigen/Geometry>
Expand All @@ -56,7 +60,8 @@ void eicrecon::IterativeVertexFinder::init(std::shared_ptr<const ActsGeometryPro
}

std::unique_ptr<edm4eic::VertexCollection> eicrecon::IterativeVertexFinder::produce(
std::vector<const ActsExamples::Trajectories*> trajectories) {
std::vector<const ActsExamples::Trajectories*> trajectories,
std::vector<const edm4eic::ReconstructedParticle*> reconParticles) {

auto outputVertices = std::make_unique<edm4eic::VertexCollection>();

Expand Down Expand Up @@ -172,11 +177,15 @@ std::unique_ptr<edm4eic::VertexCollection> 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());

}
}

Expand Down Expand Up @@ -207,7 +216,36 @@ std::unique_ptr<edm4eic::VertexCollection> 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);
}
3 changes: 2 additions & 1 deletion src/algorithms/tracking/IterativeVertexFinder.h
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
#include <Acts/Geometry/GeometryContext.hpp>
#include <Acts/MagneticField/MagneticFieldContext.hpp>
#include <edm4eic/VertexCollection.h>
#include <edm4eic/ReconstructedParticle.h>
#include <spdlog/logger.h>
#include <memory>
#include <vector>
Expand All @@ -24,7 +25,7 @@ class IterativeVertexFinder
void init(std::shared_ptr<const ActsGeometryProvider> geo_svc,
std::shared_ptr<spdlog::logger> log);
std::unique_ptr<edm4eic::VertexCollection>
produce(std::vector<const ActsExamples::Trajectories*> trajectories);
produce(std::vector<const ActsExamples::Trajectories*> trajectories, std::vector<const edm4eic::ReconstructedParticle*> reconParticles);

private:
std::shared_ptr<spdlog::logger> m_log;
Expand Down
4 changes: 3 additions & 1 deletion src/global/tracking/IterativeVertexFinder_factory.h
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
#include <ActsExamples/EventData/Trajectories.hpp>
#include <JANA/JEvent.h>
#include <edm4eic/VertexCollection.h>
#include <edm4eic/ReconstructedParticle.h>
#include <memory>
#include <string>
#include <utility>
Expand All @@ -26,6 +27,7 @@ class IterativeVertexFinder_factory :
std::unique_ptr<AlgoT> m_algo;

Input<ActsExamples::Trajectories> m_acts_trajectories_input {this};
Input<edm4eic::ReconstructedParticle> m_edm4eic_reconParticles_input {this, "ReconstructedParticles"};
PodioOutput<edm4eic::Vertex> m_vertices_output {this};

ParameterRef<int> m_maxVertices {this, "maxVertices", config().maxVertices,
Expand All @@ -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());
}
};

Expand Down
2 changes: 1 addition & 1 deletion src/global/tracking/tracking.cc
Original file line number Diff line number Diff line change
Expand Up @@ -226,7 +226,7 @@ void InitPlugin(JApplication *app) {

app->Add(new JOmniFactoryGeneratorT<IterativeVertexFinder_factory>(
"CentralTrackVertices",
{"CentralCKFActsTrajectories"},
{"CentralCKFSeededActsTrajectories","ReconstructedSeededChargedParticles"},
{"CentralTrackVertices"},
{},
app
Expand Down
Loading