ATLAS Offline Software
Loading...
Searching...
No Matches
DeviceGBTSSeedingAlg.cxx
Go to the documentation of this file.
1/*
2 Copyright (C) 2002-2026 CERN for the benefit of the ATLAS collaboration
3*/
5
8
9// traccc EDM
10#include "traccc/edm/silicon_cell_collection.hpp"
11#include "traccc/edm/measurement_collection.hpp"
13
14// vecmem
15#include "vecmem/memory/memory_resource.hpp"
16
17// ACTS logging
18#include "ActsInterop/Logger.h"
19
20#include <fstream>
21#include <memory>
22#include <cstdint>
23#include <unordered_map>
24#include <algorithm>
25#include <vector>
26
27namespace ActsTrk {
28
29// -----------------------------------------------------------------------
31{
32 ATH_MSG_DEBUG("Initializing " << name());
33
35 ATH_CHECK(m_inputPixelSPKey.initialize());
36 ATH_CHECK(m_inputMeasKey.initialize());
37 ATH_CHECK(m_outputPixelSeedsKey.initialize());
39
40 ATH_CHECK(detStore()->retrieve(m_pixelManager, "ITkPixel"));
41 ATH_CHECK(detStore()->retrieve(m_pixelID, "PixelID") );
42 ATH_CHECK(m_layerNumberTool.retrieve());
44
45 ATH_MSG_DEBUG("Successfully initialized");
46 return StatusCode::SUCCESS;
47}
48
49StatusCode DeviceGBTSSeedingAlg::execute(const EventContext& ctx) const
50{
51 ATH_MSG_DEBUG("Executing device GBTS seeding.");
52
53 // ---- 1. Read input traccc measurements from StoreGate --------------------------------
54 auto inputTracccPixelSpacepoints = SG::makeHandle(m_inputPixelSPKey, ctx);
55 ATH_CHECK(inputTracccPixelSpacepoints.isValid());
56 ATH_MSG_DEBUG("Read traccc spacepoints from '"
57 << inputTracccPixelSpacepoints.key() << "'");
58
59 auto inputTracccMeasurements = SG::makeHandle(m_inputMeasKey, ctx);
60 ATH_CHECK(inputTracccMeasurements.isValid());
61 ATH_MSG_DEBUG("Read traccc measurements from '"
62 << inputTracccMeasurements.key() << "'");
63
64 // ---- 2. Get traccc seeding alg ---------------------------------------------
65 auto seeding_alg = m_seedingAlgProviderTool->getGBTSAlgorithm(ctx, m_gbts_config);
66
67 // ---- 3. Run traccc pixel seed formation ---------------------------------------------
68 traccc::edm::seed_collection::buffer pixel_seeds_gpu_buffer = (*seeding_alg)(*inputTracccPixelSpacepoints, *inputTracccMeasurements);
69
70 ATH_MSG_DEBUG("Reconstructed " << seeding_alg.copy().get_size(pixel_seeds_gpu_buffer) << " pixel seeds.");
71
72 // ---- 4. Write output traccc seeds to StoreGate -------------------------
73 auto outputTracccPixelSeeds = SG::makeHandle(m_outputPixelSeedsKey, ctx);
74 ATH_CHECK(outputTracccPixelSeeds.record(
75 std::make_unique<traccc::edm::seed_collection::buffer>(
76 std::move(pixel_seeds_gpu_buffer))));
77 ATH_MSG_DEBUG("Wrote spacepoint buffer to '" << m_outputPixelSeedsKey.key() << "'");
78
79 return StatusCode::SUCCESS;
80}
81
83{
84
85 // traccc-gbts defaults are ITk tuned
86
87 // The layer tool builds the GBTS layers, in dense layer index order, and
88 // knows which layer each module hash belongs to and what it is made of.
89 const std::vector<Acts::Experimental::GbtsLayerDescription>& layers =
90 m_layerNumberTool->layerDescriptions();
91
92 m_pixelHashToLayer = &m_layerNumberTool->pixelLayers();
93 m_stripHashToLayer = &m_layerNumberTool->stripLayers();
94
95 std::vector<Acts::Experimental::GbtsLayerConnection> connections;
96 float etaBinWidth = 0.0f;
97 ATH_CHECK(m_layerNumberTool->readConnections(layers, connections, etaBinWidth, m_connectorInputFile, true, false));
98
99 // create geoemtry object that holds allowed pairing of allowed eta regions in each layer
100 // holds all geometry information (m_layergeomtry and connection table)
101 auto gbtsGeo = std::make_shared<Acts::Experimental::GbtsGeometry>(
102 layers, connections, etaBinWidth, Acts::Experimental::GbtsZ0Range{}, logger());
103
104 traccc::device::gbts_layerInfo layerInfo;
105 // convert save and convert layer info to SoA
106 layerInfo.reserve(static_cast<unsigned int>(gbtsGeo->numLayers()));
107
108 for (unsigned int index = 0; index < gbtsGeo->numLayers(); ++index) {
109 Acts::Experimental::GbtsLayerBinning binning = gbtsGeo->layerBinning(index);
110 Acts::Experimental::GbtsLayerDescription desc =
111 gbtsGeo->layerDescription(index);
112 int vol_id = (desc.id - (desc.id % 1000)) / 1000;
113 bool is_inc_barrel = (vol_id == 97) | (vol_id == 95) | (vol_id == 93) |
114 (vol_id == 77) | (vol_id == 75) | (vol_id == 73);
115 char type = 0;
116 if (desc.technology == Acts::Experimental::GbtsLayerTechnology::Strip) {
117 type = 3;
118 } else if (is_inc_barrel) {
119 type = 2;
120 } else if (desc.type == Acts::Experimental::GbtsLayerType::Endcap) {
121 type = 1;
122 }
123 layerInfo.addLayer(type, binning.firstBin, binning.numBins, binning.minEta,
124 binning.etaBinWidth);
125 }
126
127 std::vector<std::pair<std::uint64_t, short>> identifierBinning;
128 identifierBinning.reserve(m_idMapping->size());
129
130 // construct identifier -> layer table
131 IdContext pixel_context = m_pixelID->wafer_context();
132 for (const auto& [detrayId, compactId] : m_idMapping->detrayToAthenaMap()) {
133 Identifier athenaId(compactId);
134 if (m_pixelManager->identifierBelongs(athenaId)) {
135 IdentifierHash idHash{};//default c'tor produces detectable invalid hash
136 int rc = m_pixelID->get_hash(athenaId, idHash, &pixel_context); //rc=0 is ok
137 if (rc!=0)[[unlikely]] continue;
138 const short layer = m_pixelHashToLayer->at(static_cast<int>(idHash));
139 if (layer == IGbtsLayerTool::kNoLayer) [[unlikely]] continue;
140 identifierBinning.push_back(std::make_pair(
141 detrayId, layer));
142 }
143 }
144 ATH_MSG_INFO(identifierBinning.size() << " identifiers with a layer");
145
146 std::vector<std::pair<unsigned int, std::vector<unsigned int>>> binGroups;
147 for (Acts::Experimental::GbtsBinGroup groups : gbtsGeo->binGroups()) {
148 binGroups.emplace_back(groups.bin, groups.links);
149 }
150
151 if (!m_gbts_config.setLinkingScheme(binGroups, std::move(layerInfo), identifierBinning,
152 900.0f, makeActsAthenaLogger(this, "GBTSConfig")))
153 return StatusCode::FAILURE;
154
155 return StatusCode::SUCCESS;
156}
157
158
159} // namespace ActsTrk
#define ATH_CHECK
Evaluate an expression and check for errors.
#define ATH_MSG_DEBUG(x,...)
#define ATH_MSG_INFO(x,...)
static Double_t rc
Handle class for reading from StoreGate.
Handle class for recording to StoreGate.
std::unique_ptr< const Acts::Logger > makeActsAthenaLogger(IMessageSvc *svc, const std::string &name, int level, std::optional< std::string > parent_name)
Definition Logger.cxx:64
Gaudi::Property< std::string > m_connectorInputFile
SG::ReadHandleKey< traccc::edm::measurement_collection::const_view > m_inputMeasKey
SG::WriteHandleKey< traccc::edm::seed_collection::buffer > m_outputPixelSeedsKey
ToolHandle< IGbtsLayerTool > m_layerNumberTool
const ActsTrk::GeometryIdMapping * m_idMapping
ToolHandle< IDeviceSeedingAlgProviderTool > m_seedingAlgProviderTool
SG::ReadHandleKey< traccc::edm::spacepoint_collection::const_view > m_inputPixelSPKey
const std::vector< short > * m_pixelHashToLayer
const std::vector< short > * m_stripHashToLayer
Wafer hash to dense GBTS layer index, one map per technology.
const InDetDD::PixelDetectorManager * m_pixelManager
traccc::gbts_seedfinder_config m_gbts_config
virtual StatusCode execute(const EventContext &ctx) const override
Function executing the algorithm.
virtual StatusCode initialize() override
Function initializing the algorithm.
Gaudi::Property< std::string > m_geoIdMappingObjectName
const Acts::Logger & logger() const
Private access to the logger.
static constexpr short kNoLayer
Value stored in the hash maps for a module GBTS does not use.
const ServiceHandle< StoreGateSvc > & detStore() const
This class saves the "context" of an expanded identifier (ExpandedIdentifier) for compact or hash ver...
Definition IdContext.h:26
This is a "hash" representation of an Identifier.
The AlignStoreProviderAlg loads the rigid alignment corrections and pipes them through the readout ge...
SG::ReadCondHandle< T > makeHandle(const SG::ReadCondHandleKey< T > &key, const EventContext &ctx=Gaudi::Hive::currentContext())
Definition index.py:1
#define unlikely(x)