ATLAS Offline Software
Toggle main menu visibility
Loading...
Searching...
No Matches
Tracking
Acts
ActsGPUEventCnv
src
RDOtoTracccCellConverterCommons.cxx
Go to the documentation of this file.
1
/*
2
Copyright (C) 2002-2026 CERN for the benefit of the ATLAS collaboration
3
*/
4
5
#include "
RDOtoTracccCellConverterCommons.h
"
6
7
#include "
AthenaBaseComps/AthCheckMacros.h
"
8
#include "
AthenaBaseComps/AthMsgStreamMacros.h
"
9
#include "
AthenaBaseComps/AthReentrantAlgorithm.h
"
10
#include "
AthenaBaseComps/AthMessaging.h
"
11
#include <GaudiKernel/IMessageSvc.h>
12
13
#include <algorithm>
14
15
namespace
ActsTrk
{
16
17
RDOtoTracccCellConverterCommons::RDOtoTracccCellConverterCommons
(
18
AthReentrantAlgorithm
& parent)
19
:
AthMessaging
{
"RDOtoTracccCellConverterCommons"
}
20
,
m_parent
{parent}
21
,
m_tracccCellsKey
{&parent,
"TracccCells"
,
""
,
"Output traccc cell collection buffer"
}
22
,
m_hostMR
{&parent,
"HostMR"
,
""
,
"The host memory resource tool to use"
}
23
,
m_deviceMR
{&parent,
"DeviceMR"
,
""
,
"The device memory resource tool to use"
}
24
,
m_copiesTool
{&parent,
"CopiesTool"
,
""
,
"Tool that provides host and device copy objects"
}
25
,
m_detDescSvc
{&parent,
"DetectorDescriptionSvc"
,
"ActsTrk::JSONDeviceDetectorDescriptionProviderSvc"
}
26
,
m_hostCondObjectName
{&parent,
"HostConditionsObjectName"
,
""
,
27
"Traccc host conditions object"
}
28
,
m_CPUCellSorting
{&parent,
"CPUCellSorting"
, false,
29
"Whether to sort traccc cells on CPU or GPU"
}
30
,
m_UsePixelToTForCellActivation
{&parent,
"UsePixelToTForCellActivation"
, true,
31
"Use Pixel hit time over threshold value to set traccc cell activation value, otherwise defaults to 1"
}
32
{
33
}
34
35
StatusCode
RDOtoTracccCellConverterCommons::initialize
()
36
{
37
ATH_CHECK
(
m_parent
.detStore()->retrieve(
m_pixelID
,
"PixelID"
));
38
ATH_CHECK
(
m_parent
.detStore()->retrieve(
m_stripID
,
"SCT_ID"
));
39
40
ATH_CHECK
(
m_hostMR
.retrieve());
41
ATH_CHECK
(
m_tracccCellsKey
.initialize());
42
ATH_CHECK
(
m_copiesTool
.retrieve());
43
44
m_athenaToDetray
= &
m_detDescSvc
->athenaToDetrayMap();
45
ATH_CHECK
(
m_parent
.detStore()->retrieve(
m_hostCond
,
m_hostCondObjectName
.value()));
46
47
const
auto
& gids =
m_hostCond
->geometry_id();
48
m_DetrayIdToDetDescrIndexMap
.reserve(gids.size());
49
for
(
unsigned
int
i = 0; i < gids.size(); ++i) {
50
m_DetrayIdToDetDescrIndexMap
[gids[i].value()] = i;
51
}
52
ATH_MSG_INFO
(
"Built detray→detcond map with "
53
<<
m_DetrayIdToDetDescrIndexMap
.size() <<
" entries"
);
54
55
return
StatusCode::SUCCESS;
56
}
57
58
StatusCode
RDOtoTracccCellConverterCommons::finalize
()
59
{
60
//TODO: change to DEBUG once we figure how to set the log level of this class
61
// from that of the parent class
62
ATH_MSG_INFO
(
"Read total number of pixel hits = "
<<
m_nPix
63
<<
", total number of strip hits = "
<<
m_nStrip
64
<<
" and created total number of traccc cells = "
<<
m_nCells
65
);
66
return
StatusCode::SUCCESS;
67
}
68
69
traccc::edm::silicon_cell_collection::buffer
RDOtoTracccCellConverterCommons::sortCells
(
70
vecmem::copy
const
& host_copy
71
, traccc::edm::silicon_cell_collection::device
const
& cells
72
)
const
73
{
74
traccc::edm::silicon_cell_collection::buffer sorted_cells_host_buffer{
75
cells.size(),
m_hostMR
->mr()};
76
host_copy.setup(sorted_cells_host_buffer)->wait();
77
traccc::edm::silicon_cell_collection::device sorted_cells{sorted_cells_host_buffer};
78
sort_traccc_soa
(sorted_cells, cells);
79
return
sorted_cells_host_buffer;
80
}
81
82
StatusCode
RDOtoTracccCellConverterCommons::copyToGpuAndRecordToSG
(
83
EventContext
const
& ctx
84
, traccc::edm::silicon_cell_collection::buffer
const
& cells
85
)
const
86
{
87
auto
device_copy =
m_copiesTool
->deviceCopy(ctx);
88
auto
traccc_cells_gpu_buffer = std::make_unique<traccc::edm::silicon_cell_collection::buffer>(
89
cells.capacity(),
m_deviceMR
->mr());
90
91
// We ignore() the setup and wait() on the copy to allow parallelism.
92
device_copy->setup(*traccc_cells_gpu_buffer)->ignore();
93
(*device_copy)(cells, *traccc_cells_gpu_buffer)->wait();
94
95
auto
outputTracccCells =
SG::makeHandle
(
m_tracccCellsKey
, ctx);
96
ATH_CHECK
(outputTracccCells.record(std::move(traccc_cells_gpu_buffer)));
97
return
StatusCode::SUCCESS;
98
}
99
100
void
sort_traccc_soa
(
101
traccc::edm::silicon_cell_collection::device & sorted_cells
102
, traccc::edm::silicon_cell_collection::device
const
& cells
103
)
104
{
105
using
size_type = traccc::edm::silicon_cell_collection::buffer::size_type;
106
107
std::vector<size_type> indices(cells.size());
108
std::iota(indices.begin(), indices.end(), 0u);
109
110
// Sort the indices according to the cells.
111
std::sort
(indices.begin(), indices.end(),
112
[&](size_type lhs, size_type rhs) {
113
return cells.at(lhs) < cells.at(rhs);
114
});
115
116
// Fill an output container with the sorted cells.
117
size_type s = 0;
118
for
(size_type i : indices) {
119
sorted_cells.at(s++) = cells.at(i);
120
}
121
}
122
123
}
// namespace ActsTrk
AthCheckMacros.h
ATH_CHECK
#define ATH_CHECK
Evaluate an expression and check for errors.
Definition
AthCheckMacros.h:40
AthMessaging.h
AthMsgStreamMacros.h
ATH_MSG_INFO
#define ATH_MSG_INFO(x)
Definition
AthMsgStreamMacros.h:31
AthReentrantAlgorithm.h
RDOtoTracccCellConverterCommons.h
AthMessaging::AthMessaging
AthMessaging(IMessageSvc *msgSvc, const std::string &name)
Constructor.
Definition
AthMessaging.cxx:13
AthReentrantAlgorithm
An algorithm that can be simultaneously executed in multiple threads.
Definition
AthReentrantAlgorithm.h:74
ActsTrk
The AlignStoreProviderAlg loads the rigid alignment corrections and pipes them through the readout ge...
Definition
MdtCalibInput.h:31
ActsTrk::sort_traccc_soa
void sort_traccc_soa(traccc::edm::silicon_cell_collection::device &sorted_cells, traccc::edm::silicon_cell_collection::device const &cells)
Definition
RDOtoTracccCellConverterCommons.cxx:100
SG::makeHandle
SG::ReadCondHandle< T > makeHandle(const SG::ReadCondHandleKey< T > &key, const EventContext &ctx=Gaudi::Hive::currentContext())
Definition
ReadCondHandle.h:269
std::sort
void sort(typename DataModel_detail::iterator< DVL > beg, typename DataModel_detail::iterator< DVL > end)
Specialization of sort for DataVector/List.
Definition
DVL_algorithms.h:554
ActsTrk::RDOtoTracccCellConverterCommons::m_DetrayIdToDetDescrIndexMap
std::unordered_map< uint64_t, unsigned int > m_DetrayIdToDetDescrIndexMap
Definition
RDOtoTracccCellConverterCommons.h:64
ActsTrk::RDOtoTracccCellConverterCommons::m_deviceMR
ToolHandle< AthDevice::IMemoryResourceTool > m_deviceMR
Definition
RDOtoTracccCellConverterCommons.h:55
ActsTrk::RDOtoTracccCellConverterCommons::m_CPUCellSorting
Gaudi::Property< bool > m_CPUCellSorting
Definition
RDOtoTracccCellConverterCommons.h:66
ActsTrk::RDOtoTracccCellConverterCommons::m_hostCondObjectName
Gaudi::Property< std::string > m_hostCondObjectName
Definition
RDOtoTracccCellConverterCommons.h:59
ActsTrk::RDOtoTracccCellConverterCommons::m_pixelID
const PixelID * m_pixelID
Definition
RDOtoTracccCellConverterCommons.h:51
ActsTrk::RDOtoTracccCellConverterCommons::RDOtoTracccCellConverterCommons
RDOtoTracccCellConverterCommons(AthReentrantAlgorithm &parent)
Definition
RDOtoTracccCellConverterCommons.cxx:17
ActsTrk::RDOtoTracccCellConverterCommons::m_stripID
const SCT_ID * m_stripID
Definition
RDOtoTracccCellConverterCommons.h:52
ActsTrk::RDOtoTracccCellConverterCommons::m_athenaToDetray
const std::unordered_map< Identifier, uint64_t > * m_athenaToDetray
Definition
RDOtoTracccCellConverterCommons.h:63
ActsTrk::RDOtoTracccCellConverterCommons::m_tracccCellsKey
SG::WriteHandleKey< traccc::edm::silicon_cell_collection::buffer > m_tracccCellsKey
Definition
RDOtoTracccCellConverterCommons.h:45
ActsTrk::RDOtoTracccCellConverterCommons::m_nPix
std::atomic< int > m_nPix
Definition
RDOtoTracccCellConverterCommons.h:47
ActsTrk::RDOtoTracccCellConverterCommons::m_nCells
std::atomic< int > m_nCells
Definition
RDOtoTracccCellConverterCommons.h:49
ActsTrk::RDOtoTracccCellConverterCommons::m_parent
AthReentrantAlgorithm & m_parent
Definition
RDOtoTracccCellConverterCommons.h:43
ActsTrk::RDOtoTracccCellConverterCommons::m_UsePixelToTForCellActivation
Gaudi::Property< bool > m_UsePixelToTForCellActivation
Definition
RDOtoTracccCellConverterCommons.h:67
ActsTrk::RDOtoTracccCellConverterCommons::finalize
StatusCode finalize()
Definition
RDOtoTracccCellConverterCommons.cxx:58
ActsTrk::RDOtoTracccCellConverterCommons::sortCells
traccc::edm::silicon_cell_collection::buffer sortCells(vecmem::copy const &host_copy, traccc::edm::silicon_cell_collection::device const &cells) const
Definition
RDOtoTracccCellConverterCommons.cxx:69
ActsTrk::RDOtoTracccCellConverterCommons::m_nStrip
std::atomic< int > m_nStrip
Definition
RDOtoTracccCellConverterCommons.h:48
ActsTrk::RDOtoTracccCellConverterCommons::m_copiesTool
ToolHandle< AthDevice::ICopiesTool > m_copiesTool
Definition
RDOtoTracccCellConverterCommons.h:56
ActsTrk::RDOtoTracccCellConverterCommons::m_hostMR
ToolHandle< AthDevice::IMemoryResourceTool > m_hostMR
Definition
RDOtoTracccCellConverterCommons.h:54
ActsTrk::RDOtoTracccCellConverterCommons::m_hostCond
const traccc::detector_conditions_description::host * m_hostCond
Definition
RDOtoTracccCellConverterCommons.h:60
ActsTrk::RDOtoTracccCellConverterCommons::copyToGpuAndRecordToSG
StatusCode copyToGpuAndRecordToSG(EventContext const &ctx, traccc::edm::silicon_cell_collection::buffer const &cells) const
Definition
RDOtoTracccCellConverterCommons.cxx:82
ActsTrk::RDOtoTracccCellConverterCommons::initialize
StatusCode initialize()
Definition
RDOtoTracccCellConverterCommons.cxx:35
ActsTrk::RDOtoTracccCellConverterCommons::m_detDescSvc
ServiceHandle< ActsTrk::IDeviceDetectorDescriptionProviderSvc > m_detDescSvc
Definition
RDOtoTracccCellConverterCommons.h:58
Generated on
for ATLAS Offline Software by
1.17.0