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