Analysis Software
Documentation for sPHENIX simulation software
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
SingleSeedVertexFinderAlgorithm.cpp
Go to the documentation of this file. Or view the newest version in sPHENIX GitHub for file SingleSeedVertexFinderAlgorithm.cpp
1 // This file is part of the Acts project.
2 //
3 // Copyright (C) 2023 CERN for the benefit of the Acts project
4 //
5 // This Source Code Form is subject to the terms of the Mozilla Public
6 // License, v. 2.0. If a copy of the MPL was not distributed with this
7 // file, You can obtain one at http://mozilla.org/MPL/2.0/.
8 
10 
13 
14 #include <chrono>
15 #include <vector>
16 
18  const Config& cfg, Acts::Logging::Level lvl)
19  : ActsExamples::IAlgorithm("SingleSeedVertexFinder", lvl), m_cfg(cfg) {
20  if (m_cfg.inputSpacepoints.empty()) {
21  ACTS_ERROR("You have to provide seeds");
22  }
23  if (m_cfg.outputVertices.empty()) {
24  ACTS_ERROR("Missing output vertices collection");
25  }
26 
29 }
30 
33  const ActsExamples::AlgorithmContext& ctx) const {
34  // retrieve input seeds
35  const std::vector<ActsExamples::SimSpacePoint>& inputSpacepoints =
36  m_inputSpacepoints(ctx);
37 
39  singleSeedVtxCfg;
41  SingleSeedVertexFinder(singleSeedVtxCfg);
42 
43  // find vertices and measure elapsed time
44  auto t1 = std::chrono::high_resolution_clock::now();
45  auto vtx = SingleSeedVertexFinder.findVertex(inputSpacepoints);
46  auto t2 = std::chrono::high_resolution_clock::now();
47  if (vtx.ok()) {
48  ACTS_INFO("Found a vertex in the event in " << (t2 - t1).count() / 1e6
49  << " ms");
50  ACTS_INFO("Found vertex at x = " << vtx.value()[0]
51  << "mm, y = " << vtx.value()[1]
52  << "mm, z = " << vtx.value()[2] << "mm");
53 
54  std::vector<Acts::Vertex<Acts::BoundTrackParameters>> vertexCollection;
55  vertexCollection.emplace_back(vtx.value());
56 
57  // store found vertices
58  m_outputVertices(ctx, std::move(vertexCollection));
59  } else {
60  ACTS_INFO("Not found a vertex in the event after "
61  << (t2 - t1).count() / 1e6 << " ms");
62  }
63 
65 }