ECCE @ EIC Software
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
VertexFindingAlgorithm.cpp
Go to the documentation of this file. Or view the newest version in sPHENIX GitHub for file VertexFindingAlgorithm.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 
13 #include <iostream>
14 
24 #include "Acts/Utilities/Units.hpp"
34 
37  : FW::BareAlgorithm("VertexFinding", level), m_cfg(cfg) {}
38 
42  const FW::AlgorithmContext& ctx) const {
43  using MagneticField = Acts::ConstantBField;
46  using PropagatorOptions = Acts::PropagatorOptions<>;
49  using VertexFitter =
51  using ImpactPointEstimator =
53  using VertexSeeder = Acts::ZScanVertexFinder<VertexFitter>;
55  using VertexFinderOptions = Acts::VertexingOptions<TrackParameters>;
56 
57  static_assert(Acts::VertexFinderConcept<VertexSeeder>,
58  "VertexSeeder does not fulfill vertex finder concept.");
59  static_assert(Acts::VertexFinderConcept<VertexFinder>,
60  "VertexFinder does not fulfill vertex finder concept.");
61 
62  // Set up the magnetic field
63  MagneticField bField(m_cfg.bField);
64  // Set up propagator with void navigator
65  auto propagator = std::make_shared<Propagator>(Stepper(bField));
66  PropagatorOptions propagatorOpts(ctx.geoContext, ctx.magFieldContext);
67  // Setup the vertex fitter
68  VertexFitter::Config vertexFitterCfg;
69  VertexFitter vertexFitter(std::move(vertexFitterCfg));
70  // Setup the track linearizer
71  Linearizer::Config linearizerCfg(bField, propagator);
72  Linearizer linearizer(std::move(linearizerCfg));
73  // Setup the seed finder
74  ImpactPointEstimator::Config ipEstCfg(bField, propagator);
75  ImpactPointEstimator ipEst(std::move(ipEstCfg));
76  VertexSeeder::Config seederCfg(ipEst);
77  VertexSeeder seeder(std::move(seederCfg));
78  // Set up the actual vertex finder
79  VertexFinder::Config finderCfg(std::move(vertexFitter), std::move(linearizer),
80  std::move(seeder), ipEst);
81  finderCfg.maxVertices = 200;
82  finderCfg.reassignTracksAfterFirstFit = true;
83  VertexFinder finder(finderCfg);
84  VertexFinderOptions finderOpts(ctx.geoContext, ctx.magFieldContext);
85 
86  // Setup containers
87  const auto& input = ctx.eventStore.get<std::vector<FW::VertexAndTracks>>(
88  m_cfg.trackCollection);
89  std::vector<Acts::BoundParameters> inputTrackCollection;
90 
91  int counte = 0;
92  for (auto& bla : input) {
93  counte += bla.tracks.size();
94  }
95 
96  ACTS_INFO("Truth vertices in event: " << input.size());
97 
98  for (auto& vertexAndTracks : input) {
99  ACTS_INFO("\t True vertex at ("
100  << vertexAndTracks.vertex.position().x() << ","
101  << vertexAndTracks.vertex.position().y() << ","
102  << vertexAndTracks.vertex.position().z() << ") with "
103  << vertexAndTracks.tracks.size() << " tracks.");
104  inputTrackCollection.insert(inputTrackCollection.end(),
105  vertexAndTracks.tracks.begin(),
106  vertexAndTracks.tracks.end());
107  }
108 
109  std::vector<const Acts::BoundParameters*> inputTrackPtrCollection;
110  for (const auto& trk : inputTrackCollection) {
111  inputTrackPtrCollection.push_back(&trk);
112  }
113 
114  // Find vertices
115  auto res = finder.find(inputTrackPtrCollection, finderOpts);
116 
117  if (res.ok()) {
118  // Retrieve vertices found by vertex finder
119  auto vertexCollection = *res;
120 
121  ACTS_INFO("Found " << vertexCollection.size() << " vertices in event.");
122 
123  unsigned int count = 0;
124  for (const auto& vtx : vertexCollection) {
125  ACTS_INFO("\t" << ++count << ". vertex at "
126  << "(" << vtx.position().x() << "," << vtx.position().y()
127  << "," << vtx.position().z() << ") with "
128  << vtx.tracks().size() << " tracks.");
129  }
130  } else {
131  ACTS_ERROR("Error in vertex finder.");
132  }
133 
135 }