|
|
|||
File indexing completed on 2026-09-22 07:59:27
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/Clusterization/Clusterization.hpp" 0012 #include "Acts/Definitions/TrackParametrization.hpp" 0013 #include "Acts/Utilities/IMultiAxis.hpp" 0014 #include "ActsExamples/Digitization/MeasurementCreation.hpp" 0015 #include "ActsExamples/EventData/Cluster.hpp" 0016 #include "ActsExamples/EventData/SimHit.hpp" 0017 0018 #include <cstddef> 0019 #include <set> 0020 #include <utility> 0021 #include <variant> 0022 #include <vector> 0023 0024 namespace ActsExamples { 0025 0026 struct DigitizedParameters; 0027 0028 /// Intermediate, mutable representation of a measurement inside a module. 0029 /// 0030 /// Carries the bound parameters as a struct of arrays (parallel to the layout 0031 /// of @c DigitizedParameters) together with the cluster or single cell it 0032 /// originates from. It is the working unit during the clustering and merging 0033 /// performed by @c ModuleClusters. 0034 struct ModuleValue { 0035 /// Bound indices addressed by this value. 0036 std::vector<Acts::BoundIndices> paramIndices; 0037 /// Parameter values, one per entry in @c paramIndices. 0038 std::vector<double> paramValues; 0039 /// Parameter variances, one per entry in @c paramIndices. 0040 std::vector<double> paramVariances; 0041 /// The payload: either a full cluster or a single, not-yet-merged cell. 0042 std::variant<Cluster, Cluster::Cell> value; 0043 /// Simulated hits contributing to this value. 0044 std::set<SimHitIndex> sources; 0045 /// Connected-component label assigned during geometric clustering. 0046 Acts::Ccl::Label label = Acts::Ccl::NO_LABEL; 0047 }; 0048 0049 /// Collects the digitized values of a single module and turns them into 0050 /// measurements, optionally merging cells into clusters. 0051 /// 0052 /// Values are accumulated via @c add and finalized via @c digitizedParameters. 0053 /// When merging is enabled, cells are first grouped by a connected-component 0054 /// analysis on the module segmentation and then split again where the 0055 /// non-geometric parameters (e.g. time) are incompatible within @c nsigma. 0056 class ModuleClusters { 0057 public: 0058 /// Construct an empty collection for one module. 0059 /// 0060 /// @param segmentation the module segmentation used to position cells 0061 /// @param geoIndices the bound indices resolved from the cell geometry 0062 /// @param merge whether to merge cells into clusters 0063 /// @param nsigma compatibility window (in sigma) for merging non-geometric 0064 /// parameters 0065 /// @param commonCorner whether cells touching only at a corner are connected 0066 ModuleClusters(std::shared_ptr<const Acts::IMultiAxis> segmentation, 0067 std::vector<Acts::BoundIndices> geoIndices, bool merge, 0068 double nsigma, bool commonCorner) 0069 : m_segmentation(std::move(segmentation)), 0070 m_geoIndices(std::move(geoIndices)), 0071 m_merge(merge), 0072 m_nsigma(nsigma), 0073 m_commonCorner(commonCorner) {} 0074 0075 /// Add a digitized measurement to the module. 0076 /// 0077 /// In merging mode the cluster is broken up into its individual cells; 0078 /// otherwise the parameters are stored as-is (pass-through mode). 0079 /// 0080 /// @param params the digitized parameters to add 0081 /// @param simhit the index of the simulated hit they originate from 0082 void add(DigitizedParameters params, SimHitIndex simhit); 0083 0084 /// Finalize the module and return the digitized measurements. 0085 /// 0086 /// Triggers the merging step if enabled and converts the internal values 0087 /// back into @c DigitizedParameters. 0088 /// 0089 /// @return the digitized parameters paired with their contributing sim hits 0090 std::vector<std::pair<DigitizedParameters, std::set<SimHitIndex>>> 0091 digitizedParameters(); 0092 0093 private: 0094 /// Module segmentation used to position cells. 0095 std::shared_ptr<const Acts::IMultiAxis> m_segmentation; 0096 /// Bound indices resolved from the cell geometry. 0097 std::vector<Acts::BoundIndices> m_geoIndices; 0098 /// Accumulated values, holding cells before and clusters after merging. 0099 std::vector<ModuleValue> m_moduleValues; 0100 /// Whether cells are merged into clusters. 0101 bool m_merge; 0102 /// Compatibility window (in sigma) for merging non-geometric parameters. 0103 double m_nsigma; 0104 /// Whether cells touching only at a corner are considered connected. 0105 bool m_commonCorner; 0106 0107 /// Collect the unique cells, summing the activation of duplicates. 0108 /// 0109 /// @return the deduplicated cell values 0110 std::vector<ModuleValue> createCellCollection() const; 0111 0112 /// Merge the accumulated cells into clusters in @c m_moduleValues. 0113 /// 0114 /// Performs a connected-component analysis on the geometry and then splits 0115 /// groups whose non-geometric parameters are incompatible. 0116 void merge(); 0117 0118 /// Squash a group of values into a single, weighted cluster value. 0119 /// 0120 /// Cell positions are averaged by activation weight and the geometric 0121 /// parameters are filled before the non-geometric ones to keep slot 0122 /// positions aligned with the source layout. 0123 /// 0124 /// @param values the values forming one cluster 0125 /// 0126 /// @throws std::runtime_error if @p values is empty 0127 /// 0128 /// @return the merged cluster value 0129 ModuleValue squash(std::vector<ModuleValue>& values) const; 0130 0131 /// Find the entries of @p indices that are not geometric. 0132 /// 0133 /// @param indices the bound indices to inspect 0134 /// 0135 /// @return the positions into @p indices of the non-geometric entries 0136 std::vector<std::size_t> nonGeoEntries( 0137 std::vector<Acts::BoundIndices>& indices) const; 0138 0139 /// Group values whose non-geometric parameters are compatible within 0140 /// @c nsigma. 0141 /// 0142 /// @param values the values to group 0143 /// 0144 /// @return the values partitioned into compatible groups 0145 std::vector<std::vector<ModuleValue>> mergeParameters( 0146 std::vector<ModuleValue> values) const; 0147 }; 0148 0149 } // namespace ActsExamples
| [ Source navigation ] | [ Diff markup ] | [ Identifier search ] | [ general search ] |
|
This page was automatically generated by the 2.3.7 LXR engine. The LXR team |
|