Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2026-04-01 07:46:20

0001 // This file is part of the ACTS project.
0002 //
0003 // Copyright (C) 2016 CERN for the benefit of the ACTS project
0004 //
0005 // This Source Code Form is subject to the terms of the Mozilla Public
0006 // License, v. 2.0. If a copy of the MPL was not distributed with this
0007 // file, You can obtain one at https://mozilla.org/MPL/2.0/.
0008 
0009 #pragma once
0010 
0011 #include "Acts/Vertexing/Vertex.hpp"
0012 #include "ActsExamples/EventData/ProtoVertex.hpp"
0013 #include "ActsExamples/EventData/Track.hpp"
0014 #include "ActsExamples/EventData/Vertex.hpp"
0015 
0016 #include <algorithm>
0017 #include <vector>
0018 
0019 namespace ActsExamples {
0020 
0021 /// Create a pointers container for all track parameters in the input container.
0022 ///
0023 /// @param trackParameters input examples track parameters container
0024 /// @return track parameters pointer container referencing the input tracks
0025 inline std::vector<Acts::InputTrack> makeInputTracks(
0026     const TrackParametersContainer& trackParameters) {
0027   std::vector<Acts::InputTrack> inputTracks;
0028   inputTracks.reserve(trackParameters.size());
0029 
0030   for (const auto& trackParam : trackParameters) {
0031     inputTracks.emplace_back(&trackParam);
0032   }
0033   return inputTracks;
0034 }
0035 
0036 /// Create proto vertices from reconstructed vertices.
0037 ///
0038 /// @param inputTracks input track parameters container
0039 /// @param vertices reconstructed vertices
0040 /// @return proto vertices corresponding to the reconstructed vertices
0041 ///
0042 /// Assumes that the original parameters pointers in the vertices point to
0043 /// elements in the given input track parameters container. If that is not the
0044 /// case the behaviour is undefined.
0045 inline ProtoVertexContainer makeProtoVertices(
0046     const std::vector<Acts::InputTrack>& inputTracks,
0047     const VertexContainer& vertices) {
0048   ProtoVertexContainer protoVertices;
0049   protoVertices.reserve(vertices.size());
0050 
0051   for (const auto& vertex : vertices) {
0052     ProtoVertex protoVertex;
0053     protoVertex.reserve(vertex.tracks().size());
0054 
0055     for (const auto& track : vertex.tracks()) {
0056       auto it = std::ranges::find(inputTracks, track.originalParams);
0057       if (it != inputTracks.end()) {
0058         protoVertex.push_back(std::distance(inputTracks.begin(), it));
0059       } else {
0060         protoVertex.push_back(-1);
0061       }
0062     }
0063     protoVertices.push_back(std::move(protoVertex));
0064   }
0065 
0066   return protoVertices;
0067 }
0068 
0069 }  // namespace ActsExamples