Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-01-18 09:11:43

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/Trajectories.hpp"
0015 #include "ActsExamples/Framework/AlgorithmContext.hpp"
0016 #include "ActsExamples/Framework/DataHandle.hpp"
0017 
0018 #include <algorithm>
0019 #include <memory>
0020 #include <vector>
0021 
0022 namespace ActsExamples {
0023 
0024 /// Create a pointers container for all track parameters in the input container.
0025 ///
0026 /// @param trackParameters input examples track parameters container
0027 /// @return track parameters pointer container referencing the input tracks
0028 inline std::vector<Acts::InputTrack> makeInputTracks(
0029     const TrackParametersContainer& trackParameters) {
0030   std::vector<Acts::InputTrack> inputTracks;
0031   inputTracks.reserve(trackParameters.size());
0032 
0033   for (const auto& trackParam : trackParameters) {
0034     inputTracks.emplace_back(&trackParam);
0035   }
0036   return inputTracks;
0037 }
0038 
0039 /// Create proto vertices from reconstructed vertices.
0040 ///
0041 /// @param inputTracks input track parameters container
0042 /// @param vertices reconstructed vertices
0043 /// @return proto vertices corresponding to the reconstructed vertices
0044 ///
0045 /// Assumes that the original parameters pointers in the vertices point to
0046 /// elements in the given input track parameters container. If that is not the
0047 /// case the behaviour is undefined.
0048 inline ProtoVertexContainer makeProtoVertices(
0049     const std::vector<Acts::InputTrack>& inputTracks,
0050     const std::vector<Acts::Vertex>& vertices) {
0051   ProtoVertexContainer protoVertices;
0052   protoVertices.reserve(vertices.size());
0053 
0054   for (const auto& vertex : vertices) {
0055     ProtoVertex protoVertex;
0056     protoVertex.reserve(vertex.tracks().size());
0057 
0058     for (const auto& track : vertex.tracks()) {
0059       auto it = std::ranges::find(inputTracks, track.originalParams);
0060       if (it != inputTracks.end()) {
0061         protoVertex.push_back(std::distance(inputTracks.begin(), it));
0062       } else {
0063         protoVertex.push_back(-1);
0064       }
0065     }
0066     protoVertices.push_back(std::move(protoVertex));
0067   }
0068 
0069   return protoVertices;
0070 }
0071 
0072 }  // namespace ActsExamples