File indexing completed on 2026-03-28 07:45:54
0001
0002
0003
0004
0005
0006
0007
0008
0009 #include "ActsExamples/Vertexing/HoughVertexFinderAlgorithm.hpp"
0010
0011 #include "Acts/Utilities/Logger.hpp"
0012 #include "Acts/Vertexing/HoughVertexFinder2.hpp"
0013 #include "ActsExamples/EventData/SpacePoint.hpp"
0014
0015 #include <chrono>
0016
0017 namespace ActsExamples {
0018
0019 HoughVertexFinderAlgorithm::HoughVertexFinderAlgorithm(
0020 const Config& cfg, std::unique_ptr<const Acts::Logger> logger)
0021 : IAlgorithm("HoughVertexFinder", std::move(logger)), m_cfg(cfg) {
0022 if (m_cfg.inputSpacePoints.empty()) {
0023 throw std::invalid_argument("Missing input space points collection");
0024 }
0025 if (m_cfg.outputVertices.empty()) {
0026 throw std::invalid_argument("Missing output vertices collection");
0027 }
0028
0029 m_inputSpacePoints.initialize(m_cfg.inputSpacePoints);
0030 m_outputVertices.initialize(m_cfg.outputVertices);
0031 }
0032
0033 ProcessCode HoughVertexFinderAlgorithm::execute(
0034 const AlgorithmContext& ctx) const {
0035
0036 const SpacePointContainer& inputSpacePoints = m_inputSpacePoints(ctx);
0037
0038 Acts::HoughVertexFinder2::Config houghVtxCfg;
0039 houghVtxCfg.targetSPs = m_cfg.targetSPs;
0040 houghVtxCfg.minAbsEta = m_cfg.minAbsEta;
0041 houghVtxCfg.maxAbsEta = m_cfg.maxAbsEta;
0042 houghVtxCfg.minHits = m_cfg.minHits;
0043 houghVtxCfg.defVtxPosition = m_cfg.defVtxPosition;
0044 Acts::HoughVertexFinder2 houghVertexFinder(houghVtxCfg);
0045
0046
0047 auto t1 = std::chrono::high_resolution_clock::now();
0048 auto vtx = houghVertexFinder.find(inputSpacePoints);
0049 auto t2 = std::chrono::high_resolution_clock::now();
0050 if (vtx.ok()) {
0051 ACTS_INFO("Found a vertex in the event in " << (t2 - t1).count() / 1e6
0052 << " ms");
0053 ACTS_INFO("Found vertex at x = " << vtx.value()[0]
0054 << "mm, y = " << vtx.value()[1]
0055 << "mm, z = " << vtx.value()[2] << "mm");
0056
0057 VertexContainer vertexCollection;
0058 vertexCollection.emplace_back(vtx.value());
0059
0060
0061 m_outputVertices(ctx, std::move(vertexCollection));
0062 } else {
0063 ACTS_INFO("Not found a vertex in the event after "
0064 << (t2 - t1).count() / 1e6 << " ms");
0065
0066
0067 VertexContainer vertexCollection;
0068 m_outputVertices(ctx, std::move(vertexCollection));
0069 }
0070
0071 return ProcessCode::SUCCESS;
0072 }
0073
0074 }