|
||||
File indexing completed on 2025-01-18 09:28:00
0001 // This file is part of the Acts project. 0002 // 0003 // Copyright (C) 2019 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/Definitions/Algebra.hpp" 0012 #include "Acts/EventData/TrackParameters.hpp" 0013 #include "Acts/MagneticField/MagneticFieldContext.hpp" 0014 #include "Acts/MagneticField/MagneticFieldProvider.hpp" 0015 #include "Acts/Utilities/Logger.hpp" 0016 #include "Acts/Utilities/Result.hpp" 0017 #include "Acts/Vertexing/FullBilloirVertexFitter.hpp" 0018 #include "Acts/Vertexing/HelicalTrackLinearizer.hpp" 0019 #include "Acts/Vertexing/IVertexFinder.hpp" 0020 #include "Acts/Vertexing/ImpactPointEstimator.hpp" 0021 #include "Acts/Vertexing/TrackLinearizer.hpp" 0022 #include "Acts/Vertexing/Vertex.hpp" 0023 #include "Acts/Vertexing/VertexingOptions.hpp" 0024 0025 #include <functional> 0026 0027 namespace Acts { 0028 0029 /// @class IterativeVertexFinder 0030 /// 0031 /// @brief Implements an iterative vertex finder 0032 /// 0033 //////////////////////////////////////////////////////////// 0034 /// 0035 /// Brief description of the algorithm implemented: 0036 /// Iterative vertex finder which iteratively finds and fits vertices: 0037 /// 1. A list of seed tracks (`seedTracks`, which is the same as the 0038 /// input track list to the finder at the very first iteration) is used 0039 /// to retrieve a single vertex seed using the ZScanVertexFinder. 0040 /// 2. All tracks compatible with the current vertex seed are kept and used 0041 /// for fitting the single vertex. 0042 /// 3.1 If the vertex is a 'good' vertex (i.e. meets requirements) and no 0043 /// track reassignment after first fit is required, go to step 4. If vertex 0044 /// is not a good vertex, remove all tracks in tracksToFit from seedTracks. 0045 /// 3.2 If vertex meets requirements and track reassignment after first fit 0046 /// is required, iterate over all previously found vertices ("old vertex") 0047 /// and over all their tracksAtVertex. Compare compatibility of each track 0048 /// with old vertex and current vertex. If track is more compatible with 0049 /// current vertex, remove track from old vertex, put track back to 0050 /// tracksToFit and refit current vertex with additional track. 0051 /// 4. If good vertex, `removeUsedCompatibleTracks` method is called, which 0052 /// removes all used tracks that are compatible with the fitted vertex 0053 /// from `tracksToFit` and `seedTracks`. It also removes outliers tracks 0054 /// from tracksAtVertex if not compatible. 0055 /// 5. Add vertex to vertexCollection 0056 /// 6. Repeat until no seedTracks are left or max. number of vertices found 0057 class IterativeVertexFinder final : public IVertexFinder { 0058 using VertexFitter = FullBilloirVertexFitter; 0059 0060 public: 0061 /// Configuration struct 0062 struct Config { 0063 /// @brief Config constructor 0064 /// 0065 /// @param fitter Vertex fitter 0066 /// @param sfinder The seed finder 0067 /// @param est ImpactPointEstimator 0068 Config(VertexFitter fitter, std::shared_ptr<IVertexFinder> sfinder, 0069 ImpactPointEstimator est) 0070 : vertexFitter(std::move(fitter)), 0071 seedFinder(std::move(sfinder)), 0072 ipEst(std::move(est)) {} 0073 0074 /// Vertex fitter 0075 VertexFitter vertexFitter; 0076 0077 /// Track linearizer 0078 TrackLinearizer trackLinearizer; 0079 0080 /// Vertex seed finder 0081 std::shared_ptr<IVertexFinder> seedFinder; 0082 0083 /// ImpactPointEstimator 0084 ImpactPointEstimator ipEst; 0085 0086 /// Vertex finder configuration variables. 0087 /// Tracks that are within a distance of 0088 /// 0089 /// significanceCutSeeding * sqrt(sigma(d0)^2+sigma(z0)^2) 0090 /// 0091 /// are considered compatible with the vertex. 0092 double significanceCutSeeding = 10; 0093 double maximumChi2cutForSeeding = 36.; 0094 int maxVertices = 50; 0095 0096 /// Assign a certain fraction of compatible tracks to a different (so-called 0097 /// split) vertex if boolean is set to true. 0098 bool createSplitVertices = false; 0099 /// Inverse of the fraction of tracks that will be assigned to the split 0100 /// vertex. E.g., if splitVerticesTrkInvFraction = 2, about 50% of 0101 /// compatible tracks will be assigned to the split vertex. 0102 int splitVerticesTrkInvFraction = 2; 0103 bool reassignTracksAfterFirstFit = false; 0104 bool doMaxTracksCut = false; 0105 int maxTracks = 5000; 0106 double cutOffTrackWeight = 0.01; 0107 /// If `reassignTracksAfterFirstFit` is set this threshold will be used to 0108 /// decide if a track should be checked for reassignment to other vertices 0109 double cutOffTrackWeightReassign = 1; 0110 0111 /// Function to extract parameters from InputTrack 0112 InputTrack::Extractor extractParameters; 0113 0114 /// Magnetic field provider 0115 std::shared_ptr<MagneticFieldProvider> field; 0116 }; 0117 0118 /// State struct 0119 struct State { 0120 State(const MagneticFieldProvider& field, 0121 const Acts::MagneticFieldContext& _magContext) 0122 : magContext(_magContext), 0123 ipState{field.makeCache(magContext)}, 0124 fieldCache(field.makeCache(magContext)) {} 0125 0126 std::reference_wrapper<const Acts::MagneticFieldContext> magContext; 0127 0128 /// The IP estimator state 0129 ImpactPointEstimator::State ipState; 0130 0131 MagneticFieldProvider::Cache fieldCache; 0132 }; 0133 0134 /// @brief Constructor for user-defined InputTrack type 0135 /// 0136 /// @param cfg Configuration object 0137 /// @param logger The logging instance 0138 IterativeVertexFinder(Config cfg, 0139 std::unique_ptr<const Logger> logger = getDefaultLogger( 0140 "IterativeVertexFinder", Logging::INFO)); 0141 0142 /// @brief Finds vertices corresponding to input trackVector 0143 /// 0144 /// @param trackVector Input tracks 0145 /// @param vertexingOptions Vertexing options 0146 /// @param anyState State for fulfilling interfaces 0147 /// 0148 /// @return Collection of vertices found by finder 0149 Result<std::vector<Vertex>> find( 0150 const std::vector<InputTrack>& trackVector, 0151 const VertexingOptions& vertexingOptions, 0152 IVertexFinder::State& anyState) const override; 0153 0154 IVertexFinder::State makeState( 0155 const MagneticFieldContext& mctx) const override { 0156 return IVertexFinder::State{State{*m_cfg.field, mctx}}; 0157 } 0158 0159 void setTracksToRemove( 0160 IVertexFinder::State& /*anyState*/, 0161 const std::vector<InputTrack>& /*removedTracks*/) const override { 0162 // Nothing to do here 0163 } 0164 0165 private: 0166 /// Configuration object 0167 const Config m_cfg; 0168 0169 /// Logging instance 0170 std::unique_ptr<const Logger> m_logger; 0171 0172 /// Private access to logging instance 0173 const Logger& logger() const { return *m_logger; } 0174 0175 /// @brief Method that calls seed finder to retrieve a vertex seed 0176 /// 0177 /// @param state The state object 0178 /// @param seedTracks Seeding tracks 0179 /// @param vertexingOptions Vertexing options 0180 /// 0181 /// @return Vertex seed 0182 Result<std::optional<Vertex>> getVertexSeed( 0183 State& state, const std::vector<InputTrack>& seedTracks, 0184 const VertexingOptions& vertexingOptions) const; 0185 0186 /// @brief Removes all tracks in tracksToRemove from seedTracks 0187 /// 0188 /// @param tracksToRemove Tracks to be removed from seedTracks 0189 /// @param seedTracks List to remove tracks from 0190 void removeTracks(const std::vector<InputTrack>& tracksToRemove, 0191 std::vector<InputTrack>& seedTracks) const; 0192 0193 /// @brief Function for calculating how compatible 0194 /// a given track is to a given vertex 0195 /// 0196 /// @param params Track parameters 0197 /// @param vertex The vertex 0198 /// @param perigeeSurface The perigee surface at vertex position 0199 /// @param vertexingOptions Vertexing options 0200 /// @param state The state object 0201 Result<double> getCompatibility(const BoundTrackParameters& params, 0202 const Vertex& vertex, 0203 const Surface& perigeeSurface, 0204 const VertexingOptions& vertexingOptions, 0205 State& state) const; 0206 0207 /// @brief Function that removes used tracks compatible with 0208 /// current vertex (`vertex`) from `tracksToFit` and `seedTracks` 0209 /// as well as outliers from vertex.tracksAtVertex 0210 /// 0211 /// @param vertex Current vertex 0212 /// @param tracksToFit Tracks used to fit `vertex` 0213 /// @param seedTracks Tracks used for vertex seeding 0214 /// @param vertexingOptions Vertexing options 0215 /// @param state The state object 0216 Result<void> removeUsedCompatibleTracks( 0217 Vertex& vertex, std::vector<InputTrack>& tracksToFit, 0218 std::vector<InputTrack>& seedTracks, 0219 const VertexingOptions& vertexingOptions, State& state) const; 0220 0221 /// @brief Function that fills vector with tracks compatible with seed vertex 0222 /// 0223 /// @param seedTracks List of all available tracks used for seeding 0224 /// @param seedVertex Seed vertex 0225 /// @param tracksToFitOut Tracks to fit 0226 /// @param tracksToFitSplitVertexOut Tracks to fit to split vertex 0227 /// @param vertexingOptions Vertexing options 0228 /// @param state The state object 0229 Result<void> fillTracksToFit( 0230 const std::vector<InputTrack>& seedTracks, const Vertex& seedVertex, 0231 std::vector<InputTrack>& tracksToFitOut, 0232 std::vector<InputTrack>& tracksToFitSplitVertexOut, 0233 const VertexingOptions& vertexingOptions, State& state) const; 0234 0235 /// @brief Function that reassigns tracks from other vertices 0236 /// to the current vertex if they are more compatible 0237 /// 0238 /// @param vertexCollection Collection of vertices 0239 /// @param currentVertex Current vertex to assign tracks to 0240 /// @param tracksToFit Tracks to fit vector 0241 /// @param seedTracks Seed tracks vector 0242 /// @param origTracks Vector of original track objects 0243 /// @param vertexingOptions Vertexing options 0244 /// @param state The state object 0245 /// 0246 /// @return Bool if currentVertex is still a good vertex 0247 Result<bool> reassignTracksToNewVertex( 0248 std::vector<Vertex>& vertexCollection, Vertex& currentVertex, 0249 std::vector<InputTrack>& tracksToFit, std::vector<InputTrack>& seedTracks, 0250 const std::vector<InputTrack>& origTracks, 0251 const VertexingOptions& vertexingOptions, State& state) const; 0252 0253 /// @brief Counts all tracks that are significant for a vertex 0254 /// 0255 /// @param vtx The vertex 0256 /// 0257 /// @return Number of significant tracks 0258 int countSignificantTracks(const Vertex& vtx) const; 0259 }; 0260 0261 } // 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 |