|
||||
File indexing completed on 2025-01-18 09:11:13
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/EventData/TrackParameters.hpp" 0013 #include "Acts/Utilities/Result.hpp" 0014 0015 namespace Acts { 0016 /// @class GaussianGridTrackDensity 0017 /// @brief Implements a 1-dim density grid to be filled with 0018 /// track Gaussian distributions. Each single track is modelled 0019 /// as a 2(!)-dim Gaussian distribution grid in the d0-z0 plane, 0020 /// but only the overlap with the z-axis (i.e. a 1-dim density 0021 /// vector) needs to be calculated. 0022 /// The position of the highest track density (of either a single 0023 /// bin or the sum of a certain region) can be determined. 0024 /// Single tracks can be cached and removed from the overall density. 0025 class GaussianGridTrackDensity { 0026 public: 0027 using MainGridVector = Eigen::Matrix<float, Eigen::Dynamic, 1>; 0028 using TrackGridVector = Eigen::Matrix<float, Eigen::Dynamic, 1>; 0029 0030 /// The configuration struct 0031 struct Config { 0032 /// @param zMinMax_ The minimum and maximum z-values (in mm) that 0033 /// should be covered by the main 1-dim density grid along 0034 /// the z-axis 0035 /// @param mainGridSize_ The size of the z-axis 1-dim main density grid 0036 /// @param trkGridSize_ The 2(!)-dim grid size of a single track, i.e. 0037 /// a single track is modelled as a (trkGridSize x trkGridSize) grid 0038 /// in the d0-z0 plane. Note: trkGridSize has to be an odd value. 0039 /// @note The value of @p zMinMax_ together with @p mainGridSize_ determines the 0040 /// overall bin size to be used as seen below 0041 Config(float zMinMax_ = 100, int mainGridSize_ = 2000, 0042 int trkGridSize_ = 15) 0043 : mainGridSize(mainGridSize_), 0044 trkGridSize(trkGridSize_), 0045 zMinMax(zMinMax_) { 0046 binSize = 2. * zMinMax / mainGridSize; 0047 0048 if (trkGridSize % 2 == 0) { 0049 throw std::runtime_error( 0050 "GaussianGridTrackDensity: trkGridSize has to be an odd value!"); 0051 } 0052 if (mainGridSize < trkGridSize) { 0053 throw std::runtime_error( 0054 "GaussianGridTrackDensity: mainGridSize has to be bigger than " 0055 "trkGridSize!"); 0056 } 0057 } 0058 0059 int mainGridSize; 0060 int trkGridSize; 0061 0062 // Min and max z value of big grid 0063 float zMinMax; // mm 0064 0065 // Z size of one single bin in grid 0066 float binSize; // mm 0067 0068 // Do NOT use just the z-bin with the highest 0069 // track density, but instead check the (up to) 0070 // first three density maxima (only those that have 0071 // a maximum relative deviation of 'relativeDensityDev' 0072 // from the main maximum) and take the z-bin of the 0073 // maximum with the highest surrounding density sum 0074 bool useHighestSumZPosition = false; 0075 0076 // The maximum relative density deviation from the main 0077 // maximum to consider the second and third maximum for 0078 // the highest-sum approach from above 0079 float maxRelativeDensityDev = 0.01; 0080 }; 0081 0082 GaussianGridTrackDensity(const Config& cfg) : m_cfg(cfg) {} 0083 0084 /// @brief Returns the z position of maximum track density 0085 /// 0086 /// @param mainGrid The main 1-dim density grid along the z-axis 0087 /// 0088 /// @return The z position of maximum track density 0089 Result<float> getMaxZPosition(MainGridVector& mainGrid) const; 0090 0091 /// @brief Returns the z position of maximum track density and 0092 /// the estimated width 0093 /// 0094 /// @param mainGrid The main 1-dim density grid along the z-axis 0095 /// 0096 /// @return The z position of maximum track density and width 0097 Result<std::pair<float, float>> getMaxZPositionAndWidth( 0098 MainGridVector& mainGrid) const; 0099 0100 /// @brief Adds a single track to the overall grid density 0101 /// 0102 /// @param trk The track to be added 0103 /// @param mainGrid The main 1-dim density grid along the z-axis 0104 /// 0105 /// @return A pair storing information about the z-bin position 0106 /// the track was added (int) and the 1-dim density contribution 0107 /// of the track itself 0108 std::pair<int, TrackGridVector> addTrack(const BoundTrackParameters& trk, 0109 MainGridVector& mainGrid) const; 0110 0111 /// @brief Removes a track from the overall grid density 0112 /// 0113 /// @param zBin The center z-bin position the track needs to be 0114 /// removed from 0115 /// @param trkGrid The 1-dim density contribution of the track 0116 /// @param mainGrid The main 1-dim density grid along the z-axis 0117 void removeTrackGridFromMainGrid(int zBin, const TrackGridVector& trkGrid, 0118 MainGridVector& mainGrid) const; 0119 0120 const Config& config() const { return m_cfg; } 0121 0122 private: 0123 /// @brief Helper function that actually adds the track to the 0124 /// main density grid 0125 /// 0126 /// @param zBin The center z-bin position the track 0127 /// @param trkGrid The 1-dim density contribution of the track 0128 /// @param mainGrid The main 1-dim density grid along the z-axis 0129 void addTrackGridToMainGrid(int zBin, const TrackGridVector& trkGrid, 0130 MainGridVector& mainGrid) const; 0131 0132 /// @brief Helper function that modifies the main density grid 0133 /// (either adds or removes a track) 0134 /// 0135 /// @param zBin The center z-bin position the track 0136 /// @param trkGrid The 1-dim density contribution of the track 0137 /// @param mainGrid The main 1-dim density grid along the z-axis 0138 /// @param modifyModeSign Sign that determines the mode of modification, 0139 /// +1 for adding a track, -1 for removing a track 0140 void modifyMainGridWithTrackGrid(int zBin, const TrackGridVector& trkGrid, 0141 MainGridVector& mainGrid, 0142 int modifyModeSign) const; 0143 0144 /// @brief Function that creates a 1-dim track grid (i.e. a vector) 0145 /// with the correct density contribution of a track along the z-axis 0146 /// 0147 /// @param d0 Transverse impact parameter 0148 /// @param distCtrZ The distance in z0 from the track position to its 0149 /// bin center in the 2-dim grid 0150 /// @param cov The track covariance matrix 0151 TrackGridVector createTrackGrid(float d0, float distCtrZ, 0152 const Acts::SquareMatrix2& cov) const; 0153 0154 /// @brief Function that estimates the seed width based on the FWHM of 0155 /// the maximum density peak 0156 /// @note This only works if the maximum is sufficiently isolated since 0157 /// overlapping neighboring peaks might lead to an overestimation of the 0158 /// seed width. 0159 /// 0160 /// @param mainGrid The main 1-dim density grid along the z-axis 0161 /// @param maxZ z-position of the maximum density value 0162 /// 0163 /// @return The width 0164 Result<float> estimateSeedWidth(MainGridVector& mainGrid, float maxZ) const; 0165 0166 /// @brief Helper to retrieve values according to a 2-dim normal distribution 0167 /// @note This function is defined in coordinate system centered around d0 and z0 0168 float normal2D(float d, float z, const SquareMatrix2& cov) const; 0169 0170 /// @brief Checks the (up to) first three density maxima (only those that have 0171 /// a maximum relative deviation of 'relativeDensityDev' from the main 0172 /// maximum) and take the z-bin of the maximum with the highest surrounding 0173 /// density 0174 /// 0175 /// @param mainGrid The main 1-dim density grid along the z-axis 0176 /// 0177 /// @return The z-bin position 0178 int getHighestSumZPosition(MainGridVector& mainGrid) const; 0179 0180 /// @brief Calculates the density sum of a z-bin and its two neighboring bins 0181 /// as needed for 'getHighestSumZPosition' 0182 /// 0183 /// @param mainGrid The main 1-dim density grid along the z-axis 0184 /// @param pos The center z-bin position 0185 /// 0186 /// @return The sum 0187 double getDensitySum(const MainGridVector& mainGrid, int pos) const; 0188 0189 Config m_cfg; 0190 }; 0191 0192 } // 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 |