EIC 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 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 #include "Acts/Utilities/Units.hpp"
34 
35 #include "VertexingHelpers.hpp"
36 
38  const Config& cfg, Acts::Logging::Level lvl)
39  : ActsExamples::BareAlgorithm("IterativeVertexFinder", lvl), m_cfg(cfg) {
40  if (m_cfg.inputTrackParameters.empty()) {
41  throw std::invalid_argument("Missing input track parameters collection");
42  }
43  if (m_cfg.outputProtoVertices.empty()) {
44  throw std::invalid_argument("Missing output proto vertices collection");
45  }
46 }
47 
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 
56  using MagneticField = Acts::ConstantBField;
59  using PropagatorOptions = Acts::PropagatorOptions<>;
61  using VertexFitter =
63  using ImpactPointEstimator =
65  using VertexSeeder = Acts::ZScanVertexFinder<VertexFitter>;
67  using VertexFinderOptions =
69 
70  // Set up the magnetic field
71  MagneticField bField(m_cfg.bField);
72  // Set up propagator with void navigator
73  auto propagator = std::make_shared<Propagator>(Stepper(bField));
74  PropagatorOptions propagatorOpts(ctx.geoContext, ctx.magFieldContext,
75  Acts::LoggerWrapper{logger()});
76  // Setup the vertex fitter
77  VertexFitter::Config vertexFitterCfg;
78  VertexFitter vertexFitter(std::move(vertexFitterCfg));
79  // Setup the track linearizer
80  Linearizer::Config linearizerCfg(bField, propagator);
81  Linearizer linearizer(std::move(linearizerCfg));
82  // Setup the seed finder
83  ImpactPointEstimator::Config ipEstCfg(bField, propagator);
84  ImpactPointEstimator ipEst(std::move(ipEstCfg));
85  VertexSeeder::Config seederCfg(ipEst);
86  VertexSeeder seeder(std::move(seederCfg));
87  // Set up the actual vertex finder
88  VertexFinder::Config finderCfg(std::move(vertexFitter), std::move(linearizer),
89  std::move(seeder), ipEst);
90  finderCfg.maxVertices = 200;
91  finderCfg.reassignTracksAfterFirstFit = true;
92  VertexFinder finder(finderCfg);
93  VertexFinder::State state(ctx.magFieldContext);
94  VertexFinderOptions finderOpts(ctx.geoContext, ctx.magFieldContext);
95 
96  // find vertices
97  auto result = finder.find(inputTrackPointers, finderOpts, state);
98  if (not result.ok()) {
99  ACTS_ERROR("Error in vertex finder: " << result.error().message());
100  return ProcessCode::ABORT;
101  }
102  auto vertices = *result;
103 
104  // show some debug output
105  ACTS_INFO("Found " << vertices.size() << " vertices in event");
106  for (const auto& vtx : vertices) {
107  ACTS_INFO("Found vertex at " << vtx.fullPosition().transpose() << " with "
108  << vtx.tracks().size() << " tracks.");
109  }
110 
111  // store proto vertices extracted from the found vertices
112  ctx.eventStore.add(m_cfg.outputProtoVertices,
113  makeProtoVertices(inputTrackParameters, vertices));
114 
116 }