EIC Software
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
AdaptiveMultiVertexFinderAlgorithm.cpp
Go to the documentation of this file. Or view the newest version in sPHENIX GitHub for file AdaptiveMultiVertexFinderAlgorithm.cpp
1 // This file is part of the Acts project.
2 //
3 // Copyright (C) 2020 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 
19 #include "Acts/Utilities/Units.hpp"
31 
32 #include "VertexingHelpers.hpp"
33 
37  : ActsExamples::BareAlgorithm("AdaptiveMultiVertexFinder", lvl),
38  m_cfg(cfg) {
39  if (m_cfg.inputTrackParameters.empty()) {
40  throw std::invalid_argument("Missing input track parameters collection");
41  }
42  if (m_cfg.outputProtoVertices.empty()) {
43  throw std::invalid_argument("Missing output proto vertices collection");
44  }
45 }
46 
49  const ActsExamples::AlgorithmContext& ctx) const {
50  // retrieve input tracks and convert into the expected format
51  const auto& inputTrackParameters =
52  ctx.eventStore.get<TrackParametersContainer>(m_cfg.inputTrackParameters);
53  const auto& inputTrackPointers =
54  makeTrackParametersPointerContainer(inputTrackParameters);
55 
57  /* Full tutorial example code for reference */
59 
60  // Set up EigenStepper
61  Acts::ConstantBField bField(m_cfg.bField);
63 
64  // Set up the propagator
66  auto propagator = std::make_shared<Propagator>(stepper);
67 
68  // Set up ImpactPointEstimator
69  using IPEstimator =
71  IPEstimator::Config ipEstimatorCfg(bField, propagator);
72  IPEstimator ipEstimator(ipEstimatorCfg);
73 
74  // Set up the helical track linearizer
76  Linearizer::Config ltConfig(bField, propagator);
77  Linearizer linearizer(ltConfig);
78 
79  // Set up deterministic annealing with user-defined temperatures
80  std::vector<double> temperatures{8.0, 4.0, 2.0, 1.4142136, 1.2247449, 1.0};
81  Acts::AnnealingUtility::Config annealingConfig(temperatures);
82  Acts::AnnealingUtility annealingUtility(annealingConfig);
83 
84  // Set up the vertex fitter with user-defined annealing
85  using Fitter =
87  Fitter::Config fitterCfg(ipEstimator);
88  fitterCfg.annealingTool = annealingUtility;
89  Fitter fitter(fitterCfg);
90 
91  // Set up the vertex seed finder
92  using SeedFinder = Acts::TrackDensityVertexFinder<
94  SeedFinder seedFinder;
95 
96  // The vertex finder type
98 
99  Finder::Config finderConfig(std::move(fitter), seedFinder, ipEstimator,
100  linearizer);
101  // We do not want to use a beamspot constraint here
102  finderConfig.useBeamSpotConstraint = false;
103 
104  // Instantiate the finder
105  Finder finder(finderConfig);
106  // The vertex finder state
107  Finder::State state;
108 
109  // Default vertexing options, this is where e.g. a constraint could be set
111  VertexingOptions finderOpts(ctx.geoContext, ctx.magFieldContext);
112 
113  // find vertices
114  auto result = finder.find(inputTrackPointers, finderOpts, state);
115  if (not result.ok()) {
116  ACTS_ERROR("Error in vertex finder: " << result.error().message());
117  return ProcessCode::ABORT;
118  }
119  auto vertices = *result;
120 
121  // show some debug output
122  ACTS_INFO("Found " << vertices.size() << " vertices in event");
123  for (const auto& vtx : vertices) {
124  ACTS_INFO("Found vertex at " << vtx.fullPosition().transpose() << " with "
125  << vtx.tracks().size() << " tracks.");
126  }
127 
128  // store proto vertices extracted from the found vertices
129  ctx.eventStore.add(m_cfg.outputProtoVertices,
130  makeProtoVertices(inputTrackParameters, vertices));
131 
133 }