Analysis Software
Documentation for sPHENIX simulation software
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
VertexingHelpers.hpp
Go to the documentation of this file. Or view the newest version in sPHENIX GitHub for file VertexingHelpers.hpp
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 
9 #pragma once
10 
17 
18 #include <vector>
19 
20 namespace ActsExamples {
21 
26 inline std::vector<const Acts::BoundTrackParameters*>
28  const TrackParametersContainer& trackParameters) {
29  std::vector<const Acts::BoundTrackParameters*> trackParametersPointers;
30  trackParametersPointers.reserve(trackParameters.size());
31 
32  for (const auto& trackParam : trackParameters) {
33  trackParametersPointers.push_back(&trackParam);
34  }
35  return trackParametersPointers;
36 }
37 
40  const ReadDataHandle<std::vector<Acts::BoundTrackParameters>>&
41  inputTrackParametersHandle,
42  const ReadDataHandle<TrajectoriesContainer>& inputTrajectoriesHandle) {
43  std::vector<Acts::BoundTrackParameters> inputTrackParameters;
44  std::vector<const Acts::BoundTrackParameters*> inputTrackPointers;
45 
46  if (inputTrackParametersHandle.isInitialized()) {
47  const auto& tmp = inputTrackParametersHandle(ctx);
48  inputTrackParameters = tmp;
49  inputTrackPointers = makeTrackParametersPointerContainer(tmp);
50  } else {
51  const auto& inputTrajectories = inputTrajectoriesHandle(ctx);
52 
53  for (const auto& trajectories : inputTrajectories) {
54  for (auto tip : trajectories.tips()) {
55  if (!trajectories.hasTrackParameters(tip)) {
56  continue;
57  }
58  const auto& trackParam = trajectories.trackParameters(tip);
59  inputTrackParameters.push_back(trackParam);
60  inputTrackPointers.push_back(&trackParam);
61  }
62  }
63  }
64 
65  return std::make_tuple(inputTrackParameters, inputTrackPointers);
66 }
67 
78  const TrackParametersContainer& trackParameters,
80  ProtoVertexContainer protoVertices;
81  protoVertices.reserve(vertices.size());
82 
83  // use pointer arithmetic to compute the position/index of the original
84  // parameters in the input track parameters container.
85  const Acts::BoundTrackParameters* first = trackParameters.data();
86  for (const auto& vertex : vertices) {
87  ProtoVertex protoVertex;
88  protoVertex.reserve(vertex.tracks().size());
89 
90  for (const auto& track : vertex.tracks()) {
91  protoVertex.push_back(std::distance(first, track.originalParams));
92  }
93  protoVertices.push_back(std::move(protoVertex));
94  }
95 
96  return protoVertices;
97 }
98 
99 } // namespace ActsExamples