|
|
|||
File indexing completed on 2026-09-25 08:20:47
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/Definitions/Algebra.hpp" 0012 #include "Acts/Utilities/Logger.hpp" 0013 #include "Acts/Utilities/Result.hpp" 0014 #include "Acts/Vertexing/TrackAtVertex.hpp" 0015 #include "Acts/Vertexing/Vertex.hpp" 0016 #include "Acts/Vertexing/VertexingError.hpp" 0017 0018 #include <algorithm> 0019 #include <map> 0020 #include <vector> 0021 0022 namespace Acts { 0023 0024 /// @brief Problem-level description of a single vertex candidate 0025 /// 0026 /// This holds everything a caller has to supply about one vertex before it can 0027 /// be fitted: the constraint to fit against, the position the seed finder 0028 /// proposed, and the tracks assigned to it. It deliberately contains no 0029 /// per-iteration scratch data, so it stays meaningful independently of any 0030 /// particular fitter. 0031 struct VertexFitCandidate { 0032 VertexFitCandidate() = default; 0033 0034 /// Construct a candidate from a constraint and a seed position. 0035 /// @param constr Vertex constraint for the fitting procedure 0036 /// @param pos Seed position as proposed by the vertex seed finder 0037 VertexFitCandidate(const Vertex& constr, const Vector4& pos) 0038 : constraint(constr), seedPosition(pos) {} 0039 0040 /// Vertex constraint for the fitting procedure 0041 Vertex constraint; 0042 0043 /// The seed position, i.e. the first estimate of the vertex position as 0044 /// obtained by the vertex seed finder 0045 Vector4 seedPosition{Vector4::Zero()}; 0046 0047 /// All tracks that are currently assigned to this vertex 0048 std::vector<InputTrack> trackLinks; 0049 }; 0050 0051 /// @brief A multi-vertex fit problem 0052 /// 0053 /// Per-event, caller-owned and fitter-agnostic description of what is to be 0054 /// fitted: a set of vertices, the candidate description of each, and the 0055 /// track-to-vertex association that couples them. Fitter-private scratch data 0056 /// (linearization points, annealing state, field caches) lives in the 0057 /// respective fitter's cache instead, so that this type can be shared between 0058 /// fitters and inspected by callers. 0059 struct VertexFitProblem { 0060 /// The vertices to be fitted 0061 std::vector<Vertex*> vertices; 0062 0063 /// Candidate description (constraint, seed position, tracks) per vertex 0064 std::map<Vertex*, VertexFitCandidate> candidates; 0065 0066 /// Multimap connecting tracks to all of their associated vertices 0067 std::multimap<InputTrack, Vertex*> trackToVertices; 0068 0069 /// Track-at-vertex information for each (track, vertex) pair 0070 std::map<std::pair<InputTrack, Vertex*>, TrackAtVertex> tracksAtVertices; 0071 0072 /// Adds a vertex to @c trackToVertices, using the tracks currently 0073 /// assigned to it in @c candidates 0074 /// @param vtx Vertex to add to the multimap along with its track associations 0075 void addVertexToMultiMap(Vertex& vtx) { 0076 for (auto trk : candidates[&vtx].trackLinks) { 0077 trackToVertices.emplace(trk, &vtx); 0078 } 0079 } 0080 0081 /// Removes a vertex from @c trackToVertices 0082 /// @param vtx Vertex to remove from the multimap along with its track associations 0083 void removeVertexFromMultiMap(const Vertex& vtx) { 0084 std::erase_if(trackToVertices, 0085 [&vtx](const auto& entry) { return entry.second == &vtx; }); 0086 } 0087 0088 /// Remove a vertex from the vertex collection 0089 /// @param vtxToRemove Vertex to remove from the collection 0090 /// @param logger Logger for diagnostic messages 0091 /// @return Result indicating success or failure of the removal operation 0092 Result<void> removeVertexFromCollection(Vertex& vtxToRemove, 0093 const Logger& logger) { 0094 auto it = std::ranges::find(vertices, &vtxToRemove); 0095 // Check if the value was found before erasing 0096 if (it == vertices.end()) { 0097 ACTS_ERROR("vtxToRemove is not part of the vertex collection."); 0098 return VertexingError::ElementNotFound; 0099 } 0100 // Erase the element if found 0101 vertices.erase(it); 0102 return {}; 0103 } 0104 }; 0105 0106 } // namespace Acts
| [ Source navigation ] | [ Diff markup ] | [ Identifier search ] | [ general search ] |
|
This page was automatically generated by the 2.3.7 LXR engine. The LXR team |
|