Analysis Software
Documentation for sPHENIX simulation software
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
IterativeVertexFinderAlgorithm.cpp
Go to the documentation of this file. Or view the newest version in sPHENIX GitHub for file IterativeVertexFinderAlgorithm.cpp
1 // This file is part of the Acts project.
2 //
3 // Copyright (C) 2019-2021 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 
20 
21 #include <chrono>
22 #include <ostream>
23 #include <stdexcept>
24 #include <system_error>
25 
26 #include "VertexingHelpers.hpp"
27 
30  : ActsExamples::IAlgorithm("IterativeVertexFinder", level), m_cfg(config) {
31  if (m_cfg.inputTrackParameters.empty() == m_cfg.inputTrajectories.empty()) {
32  throw std::invalid_argument(
33  "You have to either provide track parameters or trajectories");
34  }
35  if (m_cfg.outputProtoVertices.empty()) {
36  throw std::invalid_argument("Missing output proto vertices collection");
37  }
38  if (m_cfg.outputVertices.empty()) {
39  throw std::invalid_argument("Missing output vertices collection");
40  }
41 
44 
47 }
48 
50  const ActsExamples::AlgorithmContext& ctx) const {
51  // retrieve input tracks and convert into the expected format
52 
53  auto [inputTrackParameters, inputTrackPointers] =
54  makeParameterContainers(ctx, m_inputTrackParameters, m_inputTrajectories);
55 
56  if (inputTrackParameters.size() != inputTrackPointers.size()) {
57  ACTS_ERROR("Input track containers do not align: "
58  << inputTrackParameters.size()
59  << " != " << inputTrackPointers.size());
60  }
61 
62  for (const auto& trk : inputTrackParameters) {
63  if (trk.covariance() && trk.covariance()->determinant() <= 0) {
64  // actually we should consider this as an error but I do not want the CI
65  // to fail
66  ACTS_WARNING("input track " << trk << " has det(cov) = "
67  << trk.covariance()->determinant());
68  }
69  }
70 
71  // Set up EigenStepper
73 
74  // Set up propagator with void navigator
75  auto propagator = std::make_shared<Propagator>(
77  // Setup the vertex fitter
78  Fitter::Config vertexFitterCfg;
79  Fitter vertexFitter(vertexFitterCfg);
80  // Setup the track linearizer
81  Linearizer::Config linearizerCfg(m_cfg.bField, propagator);
82  Linearizer linearizer(linearizerCfg, logger().cloneWithSuffix("HelLin"));
83  // Setup the seed finder
84  IPEstimator::Config ipEstCfg(m_cfg.bField, propagator);
85  IPEstimator ipEst(ipEstCfg);
86  Seeder seeder;
87  // Set up the actual vertex finder
88  Finder::Config finderCfg(vertexFitter, std::move(linearizer),
89  std::move(seeder), ipEst);
90  finderCfg.maxVertices = 200;
91  finderCfg.reassignTracksAfterFirstFit = false;
92  Finder finder(finderCfg, logger().cloneWithSuffix("Finder"));
94  Options finderOpts(ctx.geoContext, ctx.magFieldContext);
95 
96  // find vertices
97  auto result = finder.find(inputTrackPointers, finderOpts, state);
98 
100  if (result.ok()) {
101  vertices = std::move(result.value());
102  } else {
103  ACTS_ERROR("Error in vertex finder: " << result.error().message());
104  }
105 
106  // show some debug output
107  ACTS_INFO("Found " << vertices.size() << " vertices in event");
108  for (const auto& vtx : vertices) {
109  ACTS_INFO("Found vertex at " << vtx.fullPosition().transpose() << " with "
110  << vtx.tracks().size() << " tracks.");
111  }
112 
113  // store proto vertices extracted from the found vertices
114  m_outputProtoVertices(ctx, makeProtoVertices(inputTrackParameters, vertices));
115 
116  // store found vertices
117  m_outputVertices(ctx, std::move(vertices));
118 
120 }