Back to home page

sPhenix code displayed by LXR

 
 

    


File indexing completed on 2025-08-06 08:10:33

0001 // This file is part of the Acts project.
0002 //
0003 // Copyright (C) 2021 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/Clusterization/Clusterization.hpp"
0012 #include "Acts/Definitions/Algebra.hpp"
0013 #include "Acts/Definitions/TrackParametrization.hpp"
0014 #include "Acts/Utilities/BinUtility.hpp"
0015 #include "ActsExamples/Digitization/MeasurementCreation.hpp"
0016 #include "ActsExamples/EventData/Cluster.hpp"
0017 #include "ActsExamples/EventData/SimHit.hpp"
0018 
0019 #include <algorithm>
0020 #include <cstddef>
0021 #include <set>
0022 #include <unordered_map>
0023 #include <utility>
0024 #include <variant>
0025 #include <vector>
0026 
0027 namespace ActsExamples {
0028 struct DigitizedParameters;
0029 
0030 struct ModuleValue {
0031   std::vector<Acts::BoundIndices> paramIndices = {};
0032   std::vector<Acts::ActsScalar> paramValues = {};
0033   std::vector<Acts::ActsScalar> paramVariances = {};
0034   std::variant<Cluster, Cluster::Cell> value;
0035   std::set<SimHitContainer::size_type> sources = {};
0036   Acts::Ccl::Label label = {Acts::Ccl::NO_LABEL};
0037 };
0038 
0039 class ModuleClusters {
0040  public:
0041   using simhit_t = SimHitContainer::size_type;
0042 
0043   ModuleClusters(Acts::BinUtility segmentation,
0044                  std::vector<Acts::BoundIndices> geoIndices, bool merge,
0045                  double nsigma, bool commonCorner)
0046       : m_segmentation(std::move(segmentation)),
0047         m_geoIndices(std::move(geoIndices)),
0048         m_merge(merge),
0049         m_nsigma(nsigma),
0050         m_commonCorner(commonCorner) {}
0051 
0052   void add(DigitizedParameters params, simhit_t simhit);
0053   std::vector<std::pair<DigitizedParameters, std::set<simhit_t>>>
0054   digitizedParameters();
0055 
0056  private:
0057   Acts::BinUtility m_segmentation;
0058   std::vector<Acts::BoundIndices> m_geoIndices;
0059   std::vector<ModuleValue> m_moduleValues;
0060   bool m_merge;
0061   double m_nsigma;
0062   bool m_commonCorner;
0063 
0064   std::vector<ModuleValue> createCellCollection();
0065   void merge();
0066   ModuleValue squash(std::vector<ModuleValue>& values);
0067   std::vector<std::size_t> nonGeoEntries(
0068       std::vector<Acts::BoundIndices>& indices);
0069   std::vector<std::vector<ModuleValue>> mergeParameters(
0070       std::vector<ModuleValue> values);
0071 };
0072 }  // namespace ActsExamples