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