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 ATH_MSG_DEBUG("Successfully initialized");
33 return StatusCode::SUCCESS;
34}
35
36StatusCode DeviceClusterizationAlg::execute(const EventContext& ctx) const
37{
38 ATH_MSG_DEBUG("Executing device clusterization.");
39
41 if (!deviceCond.isValid()) {
42 ATH_MSG_ERROR("Could not retrieve conditions object '" << m_deviceCondObjectName.key() << "'");
43 return StatusCode::FAILURE;
44 }
45
46 // ---- 1. Read input traccc cells from StoreGate --------------------------------
47 auto inputTracccCells = SG::makeHandle(m_inputCellsKey, ctx);
48 ATH_CHECK(inputTracccCells.isValid());
49 ATH_MSG_DEBUG("Read traccc cells from '"
50 << m_inputCellsKey.key() << "'");
51
52 // ---- 2. Get traccc clusterization alg ---------------------------------------------
53 auto clustering_alg = m_clusteringAlgProviderTool->getClusterizationAlgorithm(ctx);
54
55 // ---- 2.5 Retrieve the sorting algorithm ---------------------------------------------
56 auto sorting_alg = m_clusteringAlgProviderTool->getSortingAlgorithm(ctx);
57
58 // ---- 3. Run traccc clusterization ---------------------------------------------
59 traccc::edm::silicon_cluster_collection::buffer cluster_gpu_buffer;
60 traccc::edm::measurement_collection::buffer measurements_gpu_buffer;
61
63 ATH_MSG_DEBUG("Running clusterization with returning cell info");
64 std::tie(measurements_gpu_buffer, cluster_gpu_buffer) =
65 (*clustering_alg)(
66 *inputTracccCells, *m_deviceDesign, **deviceCond,
67 traccc::device::clustering_keep_disjoint_set{});
68 } else {
69 ATH_MSG_DEBUG("Running clusterization without returning cell info");
70 measurements_gpu_buffer = (*clustering_alg)(*inputTracccCells, *m_deviceDesign, **deviceCond);
71 }
72
73 // ---- 3.5 Run measurement sorting ---------------------------------------------
74 auto sortedTracccMeasurements =
75 (*sorting_alg)(measurements_gpu_buffer);
76
77 ATH_MSG_DEBUG("Reconstructed " << clustering_alg.copy().get_size(measurements_gpu_buffer) << " measurements.");
78
79 // ---- 4. Write output traccc measurements to StoreGate -------------------------
80 auto outputTracccMeas = SG::makeHandle(m_outputMeasKey, ctx);
81 ATH_CHECK(outputTracccMeas.record(
82 std::make_unique<traccc::edm::measurement_collection::buffer>(
83 std::move(sortedTracccMeasurements))));
84 ATH_MSG_DEBUG("Wrote measurement buffer to '" << m_outputMeasKey.key() << "'");
85
86 auto outputTracccClusters = SG::makeHandle(m_outputClusterKey, ctx);
87 ATH_CHECK(outputTracccClusters.record(
88 std::make_unique<traccc::edm::silicon_cluster_collection::buffer>(
89 std::move(cluster_gpu_buffer))));
90 ATH_MSG_DEBUG("Wrote cluster buffer to '" << m_outputClusterKey.key() << "'");
91
92 return StatusCode::SUCCESS;
93}
94
95} // namespace ActsTrk
#define ATH_CHECK
Evaluate an expression and check for errors.
#define ATH_MSG_DEBUG(x,...)
#define ATH_MSG_ERROR(x,...)
Handle class for reading from StoreGate.
Handle class for recording to StoreGate.
virtual StatusCode execute(const EventContext &ctx) const override
Function executing the algorithm.
SG::WriteHandleKey< traccc::edm::measurement_collection::buffer > m_outputMeasKey
SG::WriteHandleKey< traccc::edm::silicon_cluster_collection::buffer > m_outputClusterKey
SG::ReadCondHandleKey< traccc::detector_conditions_description::buffer > m_deviceCondObjectName
virtual StatusCode initialize() override
Function initializing the algorithm.
const traccc::detector_design_description::const_view * m_deviceDesign
ToolHandle< IDeviceClusterizationAlgProviderTool > m_clusteringAlgProviderTool
Gaudi::Property< std::string > m_deviceDesignObjectName
Gaudi::Property< bool > m_retrieveClusterCells
SG::ReadHandleKey< traccc::edm::silicon_cell_collection::const_view > 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())