ATLAS Offline Software
Loading...
Searching...
No Matches
DeviceClusterizationAlg.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
16namespace ActsTrk {
17
18// -----------------------------------------------------------------------
20{
21 ATH_MSG_DEBUG("Initializing " << name());
22
24 ATH_CHECK(m_deviceMR.retrieve());
25 ATH_CHECK(m_inputCellsKey.initialize());
26 ATH_CHECK(m_outputMeasKey.initialize());
27 ATH_CHECK(m_outputClusterKey.initialize());
28
31
32 // for debug prints only (size of device buffers)
33 ATH_CHECK(m_copy.retrieve());
34
35
36 ATH_MSG_DEBUG("Successfully initialized");
37 return StatusCode::SUCCESS;
38}
39
40StatusCode DeviceClusterizationAlg::execute(const EventContext& ctx) const
41{
42 ATH_MSG_DEBUG("Executing device clusterization.");
43
44 // ---- 1. Read input traccc cells from StoreGate --------------------------------
45 auto inputTracccCells = SG::makeHandle(m_inputCellsKey, ctx);
46 ATH_CHECK(inputTracccCells.isValid());
47 ATH_MSG_DEBUG("Read traccc cells from '"
48 << m_inputCellsKey.key() << "'");
49
50 ATH_MSG_DEBUG("Receiving " << (m_copy->copy(ctx))->get_size(*inputTracccCells) << " cells.");
51
52 // ---- 2. Get traccc clusterization alg ---------------------------------------------
53 auto clustering_pair = m_clusteringAlgProviderTool->getClusterizationAlgorithm(ctx);
54 std::shared_ptr<const traccc::device::clusterization_algorithm> clustering_alg = clustering_pair.second;
55
56 // ---- 2.5 Retrieve the sorting algorithm ---------------------------------------------
57 auto sorting_pair = m_clusteringAlgProviderTool->getSortingAlgorithm(ctx);
58 std::shared_ptr<const IDeviceClusterizationAlgProviderTool::sorting_algorithm_type> sorting_alg = sorting_pair.second;
59
60 // ---- 3. Run traccc clusterization ---------------------------------------------
61 traccc::edm::silicon_cluster_collection::buffer cluster_gpu_buffer;
62 traccc::edm::measurement_collection::buffer measurements_gpu_buffer;
63
65 ATH_MSG_DEBUG("Running clusterization with returning cell info");
66 std::tie(measurements_gpu_buffer, cluster_gpu_buffer) =
67 (*clustering_alg)(
68 *inputTracccCells, *m_deviceDesign, *m_deviceCond,
69 traccc::device::clustering_keep_disjoint_set{});
70 } else {
71 ATH_MSG_DEBUG("Running clusterization without returning cell info");
72 measurements_gpu_buffer = (*clustering_alg)(*inputTracccCells, *m_deviceDesign, *m_deviceCond);
73 }
74
75 // ---- 3.5 Run measurement sorting ---------------------------------------------
76 auto sortedTracccMeasurements =
77 (*sorting_alg)(measurements_gpu_buffer);
78
79 ATH_MSG_DEBUG("Reconstructed " << (m_copy->copy(ctx))->get_size(measurements_gpu_buffer) << " measurements.");
80
81 // ---- 4. Write output traccc measurements to StoreGate -------------------------
82 auto outputTracccMeas = SG::makeHandle(m_outputMeasKey, ctx);
83 ATH_CHECK(outputTracccMeas.record(
84 std::make_unique<traccc::edm::measurement_collection::buffer>(
85 std::move(sortedTracccMeasurements))));
86 ATH_MSG_DEBUG("Wrote measurement buffer to '" << m_outputMeasKey.key() << "'");
87
88 auto outputTracccClusters = SG::makeHandle(m_outputClusterKey, ctx);
89 ATH_CHECK(outputTracccClusters.record(
90 std::make_unique<traccc::edm::silicon_cluster_collection::buffer>(
91 std::move(cluster_gpu_buffer))));
92 ATH_MSG_DEBUG("Wrote cluster buffer to '" << m_outputClusterKey.key() << "'");
93
94 return StatusCode::SUCCESS;
95}
96
97} // namespace ActsTrk
#define ATH_CHECK
Evaluate an expression and check for errors.
#define ATH_MSG_DEBUG(x)
Handle class for reading from StoreGate.
Handle class for recording to StoreGate.
Gaudi::Property< std::string > m_deviceCondObjectName
virtual StatusCode execute(const EventContext &ctx) const override
ToolHandle< AthDevice::ICopyTool > m_copy
SG::WriteHandleKey< traccc::edm::measurement_collection::buffer > m_outputMeasKey
SG::WriteHandleKey< traccc::edm::silicon_cluster_collection::buffer > m_outputClusterKey
const traccc::detector_design_description::buffer * m_deviceDesign
virtual StatusCode initialize() override
ToolHandle< IDeviceClusterizationAlgProviderTool > m_clusteringAlgProviderTool
const traccc::detector_conditions_description::buffer * m_deviceCond
Gaudi::Property< std::string > m_deviceDesignObjectName
Gaudi::Property< bool > m_retrieveClusterCells
SG::ReadHandleKey< traccc::edm::silicon_cell_collection::buffer > m_inputCellsKey
ToolHandle< AthDevice::IMemoryResourceTool > m_deviceMR
const ServiceHandle< StoreGateSvc > & detStore() const
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())