Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-05-14 07:56:47

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/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   // retrieve input seeds
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   // find vertices and measure elapsed time
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     // store found vertices
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 }  // namespace ActsExamples