Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2026-03-28 07:45:54

0001 // This file is part of the ACTS project.
0002 //
0003 // Copyright (C) 2016 CERN for the benefit of the ACTS project
0004 //
0005 // This Source Code Form is subject to the terms of the Mozilla Public
0006 // License, v. 2.0. If a copy of the MPL was not distributed with this
0007 // file, You can obtain one at https://mozilla.org/MPL/2.0/.
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   // retrieve input space points
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   // find vertices and measure elapsed time
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     // store found vertices
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     // store empty container
0067     VertexContainer vertexCollection;
0068     m_outputVertices(ctx, std::move(vertexCollection));
0069   }
0070 
0071   return ProcessCode::SUCCESS;
0072 }
0073 
0074 }  // namespace ActsExamples