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"
12
13// vecmem
14#include "vecmem/memory/memory_resource.hpp"
15
16// ACTS logging
17#include "ActsInterop/Logger.h"
18
19#include <fstream>
20
21namespace ActsTrk {
22
23// -----------------------------------------------------------------------
25{
26 ATH_MSG_DEBUG("Initializing " << name());
27
29 ATH_CHECK(m_deviceMR.retrieve());
30 ATH_CHECK(m_inputPixelSPKey.initialize());
31 ATH_CHECK(m_inputMeasKey.initialize());
32 ATH_CHECK(m_outputPixelSeedsKey.initialize());
33
34 ATH_CHECK(detStore()->retrieve(m_pixelManager, "ITkPixel"));
35 ATH_CHECK(detStore()->retrieve(m_pixelID, "PixelID") );
36 ATH_CHECK(m_layerNumberTool.retrieve());
38
39 ATH_MSG_DEBUG("Successfully initialized");
40 return StatusCode::SUCCESS;
41}
42
43StatusCode DeviceGBTSSeedingAlg::execute(const EventContext& ctx) const
44{
45 ATH_MSG_DEBUG("Executing device GBTS seeding.");
46
47 // ---- 1. Read input traccc measurements from StoreGate --------------------------------
48 auto inputTracccPixelSpacepoints = SG::makeHandle(m_inputPixelSPKey, ctx);
49 ATH_CHECK(inputTracccPixelSpacepoints.isValid());
50 ATH_MSG_DEBUG("Read traccc spacepoints from '"
51 << inputTracccPixelSpacepoints.key() << "'");
52
53 auto inputTracccMeasurements = SG::makeHandle(m_inputMeasKey, ctx);
54 ATH_CHECK(inputTracccMeasurements.isValid());
55 ATH_MSG_DEBUG("Read traccc measurements from '"
56 << inputTracccMeasurements.key() << "'");
57
58 // ---- 2. Get traccc seeding alg ---------------------------------------------
59 auto seeding_pair = m_seedingAlgProviderTool->getGBTSAlgorithm(ctx, m_gbts_config);
60 std::shared_ptr<const traccc::device::gbts_seeding_algorithm> seeding_alg = seeding_pair.second;
61
62 // ---- 3. Run traccc pixel seed formation ---------------------------------------------
63 traccc::edm::seed_collection::buffer pixel_seeds_gpu_buffer = (*seeding_alg)(*inputTracccPixelSpacepoints, *inputTracccMeasurements);
64
65 ATH_MSG_DEBUG("Reconstructed " << (seeding_pair.first)->get_size(pixel_seeds_gpu_buffer) << " pixel seeds.");
66
67 // ---- 4. Write output traccc seeds to StoreGate -------------------------
68 auto outputTracccPixelSeeds = SG::makeHandle(m_outputPixelSeedsKey, ctx);
69 ATH_CHECK(outputTracccPixelSeeds.record(
70 std::make_unique<traccc::edm::seed_collection::buffer>(
71 std::move(pixel_seeds_gpu_buffer))));
72 ATH_MSG_DEBUG("Wrote spacepoint buffer to '" << m_outputPixelSeedsKey.key() << "'");
73
74 return StatusCode::SUCCESS;
75}
76
78{
79
80 const std::unordered_map<uint64_t, Identifier> detrayToAthena = m_detDescSvc->detrayToAthenaMap();
81 // traccc-gbts defaults are ITk tuned
82 // get layer linking scheme from the athena tools
83 std::string conn_fileName =
85 if (conn_fileName.empty()) {
86 ATH_MSG_FATAL("Cannot find layer connections file for GBTS "
87 << conn_fileName);
88 return StatusCode::FAILURE;
89 }
90 std::ifstream ifs(conn_fileName.c_str());
91 std::unique_ptr<GNN_FASTRACK_CONNECTOR> gbts_connector =
92 std::make_unique<GNN_FASTRACK_CONNECTOR>(ifs, false);
93 ATH_MSG_INFO("Layer connections are initialized from file for GBTS "
94 << conn_fileName);
95
96 const std::vector<TrigInDetSiLayer>* pVL =
97 m_layerNumberTool->layerGeometry();
98 std::vector<TrigInDetSiLayer> layerGeometry;
99 std::copy(pVL->begin(), pVL->end(), std::back_inserter(layerGeometry));
100
101 std::unique_ptr<TrigFTF_GNN_Geometry> GBTS_geo =
102 std::make_unique<TrigFTF_GNN_Geometry>(layerGeometry, gbts_connector);
103
104 traccc::device::gbts_layerInfo layerInfo;
105 // convert save and convert layer info to SoA
106 layerInfo.reserve(GBTS_geo->num_layers());
107
108 for (unsigned int index = 0; index < GBTS_geo->num_layers(); ++index) {
109 const TrigFTF_GNN_Layer* layer =
110 GBTS_geo->getTrigFTF_GNN_LayerByIndex(index);
111 // pixel barrel=0 pixel endcap=1 pixel inc. barrel=2 strip=3
112 int vol_id =
113 (layer->m_layer.m_subdet - (layer->m_layer.m_subdet % 1000)) / 1000;
114 int is_inc_barrel = (vol_id == 97) | (vol_id == 95) | (vol_id == 93) |
115 (vol_id == 77) | (vol_id == 75) | (vol_id == 73);
116 char type = (layer->m_layer.m_type != 0) + is_inc_barrel;
117 if (layer->m_layer.m_subdet <= 20000) {
118 type = 3;
119 }
120 // eta prediction cut occurs for type=0 and cluster width cut for type=1
121 layerInfo.addLayer(type, layer->m_bins[0], layer->num_bins(),
122 layer->m_minEta, layer->m_etaBin);
123 }
124
125 const std::vector<short>* pixel_h2l = m_layerNumberTool->pixelLayers();
126
127
128 std::vector<std::pair<std::uint64_t, short>> identifierBinning;
129 identifierBinning.reserve(detrayToAthena.size());
130
131 // construct identifier -> layer table
132 IdContext pixel_context = m_pixelID->wafer_context();
133 for (std::pair<std::uint64_t, Identifier> dToI : detrayToAthena) {
134 if (m_pixelManager->identifierBelongs(dToI.second)) {
135 IdentifierHash idHash = 0;
136 m_pixelID->get_hash(dToI.second, idHash, &pixel_context);
137 identifierBinning.push_back(std::make_pair(
138 dToI.first, pixel_h2l->at(static_cast<int>(idHash))));
139 }
140 }
141 ATH_MSG_INFO(identifierBinning.size() << " identifiers with a layer");
142
143 std::vector<std::pair<unsigned int, std::vector<unsigned int>>> binGroups;
144 {
145 const auto rawBinGroups = GBTS_geo->bin_groups();
146 binGroups.reserve(rawBinGroups.size());
147 for (const auto& p : rawBinGroups) {
148 binGroups.emplace_back(static_cast<unsigned int>(p.first),
149 std::vector<unsigned int>(p.second.begin(), p.second.end()));
150 }
151 }
152
153 for (auto& pair : binGroups) {
154 bool barrel = (pair.first <= 83); // unsigned, so `0 <= pair.first` is always true — dropped
155 if (barrel) {
156 pair.second.push_back(pair.first);
157 }
158 }
159
160 // traccc::gbts_seedfinder_config gbts_config;
161 if (!m_gbts_config.setLinkingScheme(binGroups, layerInfo, identifierBinning,
162 900.0f, makeActsAthenaLogger(this, "GBTSConfig")))
163 return StatusCode::FAILURE;
164
165 return StatusCode::SUCCESS;
166}
167
168
169} // namespace ActsTrk
#define ATH_CHECK
Evaluate an expression and check for errors.
#define ATH_MSG_FATAL(x)
#define ATH_MSG_INFO(x)
#define ATH_MSG_DEBUG(x)
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
ToolHandle< AthDevice::IMemoryResourceTool > m_deviceMR
SG::ReadHandleKey< traccc::edm::measurement_collection::const_view > m_inputMeasKey
SG::WriteHandleKey< traccc::edm::seed_collection::buffer > m_outputPixelSeedsKey
ToolHandle< IDeviceSeedingAlgProviderTool > m_seedingAlgProviderTool
SG::ReadHandleKey< traccc::edm::spacepoint_collection::const_view > m_inputPixelSPKey
ServiceHandle< ActsTrk::IDeviceDetectorDescriptionProviderSvc > m_detDescSvc
ToolHandle< ITrigL2LayerNumberTool > m_layerNumberTool
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_connectionFileName
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.
static std::string find_file(const std::string &logical_file_name, const std::string &search_path)
STL class.
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