Back to home page

sPhenix code displayed by LXR

 
 

    


File indexing completed on 2025-08-05 08:09:51

0001 // This file is part of the Acts project.
0002 //
0003 // Copyright (C) 2020 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 http://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 <memory>
0019 #include <vector>
0020 
0021 namespace ActsExamples {
0022 
0023 /// Create a pointers container for all track parameters in the input container.
0024 ///
0025 /// @param trackParameters input examples track parameters container
0026 /// @return track parameters pointer container referencing the input tracks
0027 inline std::vector<Acts::InputTrack> makeInputTracks(
0028     const TrackParametersContainer& trackParameters) {
0029   std::vector<Acts::InputTrack> inputTracks;
0030   inputTracks.reserve(trackParameters.size());
0031 
0032   for (const auto& trackParam : trackParameters) {
0033     inputTracks.emplace_back(&trackParam);
0034   }
0035   return inputTracks;
0036 }
0037 
0038 /// Create proto vertices from reconstructed vertices.
0039 ///
0040 /// @param inputTracks input track parameters container
0041 /// @param vertices reconstructed vertices
0042 /// @return proto vertices corresponding to the reconstructed vertices
0043 ///
0044 /// Assumes that the original parameters pointers in the vertices point to
0045 /// elements in the given input track parameters container. If that is not the
0046 /// case the behaviour is undefined.
0047 inline ProtoVertexContainer makeProtoVertices(
0048     const std::vector<Acts::InputTrack>& inputTracks,
0049     const std::vector<Acts::Vertex>& vertices) {
0050   ProtoVertexContainer protoVertices;
0051   protoVertices.reserve(vertices.size());
0052 
0053   for (const auto& vertex : vertices) {
0054     ProtoVertex protoVertex;
0055     protoVertex.reserve(vertex.tracks().size());
0056 
0057     for (const auto& track : vertex.tracks()) {
0058       auto it = std::find(inputTracks.begin(), inputTracks.end(),
0059                           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