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
#include <cstddef>
15
16
namespace
ActsTrk
{
17
18
RDOtoTracccCellConverterCommons::RDOtoTracccCellConverterCommons
(
19
AthReentrantAlgorithm
& parent)
20
:
AthMessaging
{
"RDOtoTracccCellConverterCommons"
}
21
,
m_parent
{parent}
22
,
m_tracccCellsKey
{&parent,
"TracccCells"
,
""
,
"Output traccc cell collection buffer"
}
23
,
m_hostMR
{&parent,
"HostMR"
,
""
,
"The host memory resource tool to use"
}
24
,
m_deviceMR
{&parent,
"DeviceMR"
,
""
,
"The device memory resource tool to use"
}
25
,
m_copiesTool
{&parent,
"CopiesTool"
,
""
,
"Tool that provides host and device copy objects"
}
26
,
m_geoIdMappingObjectName
{&parent,
"GeoIdMappingObjectName"
,
""
,
27
"StoreGate name for the detray/acts/athena geo id mapping"
}
28
,
m_hostCondObjectName
{&parent,
"HostConditionsObjectName"
,
""
,
29
"Traccc host conditions object"
}
30
,
m_CPUCellSorting
{&parent,
"CPUCellSorting"
, false,
31
"Whether to sort traccc cells on CPU or GPU"
}
32
,
m_UsePixelToTForCellActivation
{&parent,
"UsePixelToTForCellActivation"
, true,
33
"Use Pixel hit time over threshold value to set traccc cell activation value, otherwise defaults to 1"
}
34
,
m_stripRDOTimeBinStr
{&parent,
"timeBins"
,
"Allowed time bins pattern for Strip RDOs"
}
35
{
36
}
37
38
StatusCode
RDOtoTracccCellConverterCommons::initialize
()
39
{
40
ATH_CHECK
(
m_parent
.detStore()->retrieve(
m_pixelID
,
"PixelID"
));
41
ATH_CHECK
(
m_parent
.detStore()->retrieve(
m_stripID
,
"SCT_ID"
));
42
43
ATH_CHECK
(
m_hostMR
.retrieve());
44
ATH_CHECK
(
m_tracccCellsKey
.initialize());
45
ATH_CHECK
(
m_copiesTool
.retrieve());
46
47
ATH_CHECK
(
m_parent
.detStore()->retrieve(
m_geoIdMapping
,
m_geoIdMappingObjectName
.value()));
48
ATH_CHECK
(
m_parent
.detStore()->retrieve(
m_hostCond
,
m_hostCondObjectName
.value()));
49
50
ATH_CHECK
(
decodeTimeBins
());
51
52
return
StatusCode::SUCCESS;
53
}
54
55
StatusCode
RDOtoTracccCellConverterCommons::finalize
()
56
{
57
//TODO: change to DEBUG once we figure how to set the log level of this class
58
// from that of the parent class
59
ATH_MSG_INFO
(
"Read total number of pixel hits = "
<<
m_nPix
60
<<
", total number of strip hits = "
<<
m_nStrip
61
<<
" and created total number of traccc cells = "
<<
m_nCells
62
);
63
return
StatusCode::SUCCESS;
64
}
65
66
traccc::edm::silicon_cell_collection::buffer
RDOtoTracccCellConverterCommons::sortCells
(
67
vecmem::copy
const
& host_copy
68
, traccc::edm::silicon_cell_collection::device
const
& cells
69
)
const
70
{
71
traccc::edm::silicon_cell_collection::buffer sorted_cells_host_buffer{
72
cells.size(),
m_hostMR
->mr()};
73
host_copy.setup(sorted_cells_host_buffer)->wait();
74
traccc::edm::silicon_cell_collection::device sorted_cells{sorted_cells_host_buffer};
75
sort_traccc_soa
(sorted_cells, cells);
76
return
sorted_cells_host_buffer;
77
}
78
79
StatusCode
RDOtoTracccCellConverterCommons::copyToGpuAndRecordToSG
(
80
EventContext
const
& ctx
81
, traccc::edm::silicon_cell_collection::buffer
const
& cells
82
)
const
83
{
84
auto
device_copy =
m_copiesTool
->deviceCopy(ctx);
85
auto
traccc_cells_gpu_buffer = std::make_unique<traccc::edm::silicon_cell_collection::buffer>(
86
cells.capacity(),
m_deviceMR
->mr());
87
88
// We ignore() the setup and wait() on the copy to allow parallelism.
89
device_copy->setup(*traccc_cells_gpu_buffer)->ignore();
90
(*device_copy)(cells, *traccc_cells_gpu_buffer)->wait();
91
92
auto
outputTracccCells =
SG::makeHandle
(
m_tracccCellsKey
, ctx);
93
ATH_CHECK
(outputTracccCells.record(std::move(traccc_cells_gpu_buffer)));
94
return
StatusCode::SUCCESS;
95
}
96
97
void
sort_traccc_soa
(
98
traccc::edm::silicon_cell_collection::device & sorted_cells
99
, traccc::edm::silicon_cell_collection::device
const
& cells
100
)
101
{
102
using
size_type = traccc::edm::silicon_cell_collection::buffer::size_type;
103
104
std::vector<size_type>
indices
(cells.size());
105
std::iota(
indices
.begin(),
indices
.end(), 0u);
106
107
// Sort the indices according to the cells.
108
std::sort
(
indices
.begin(),
indices
.end(),
109
[&](size_type lhs, size_type rhs) {
110
return cells.at(lhs) < cells.at(rhs);
111
});
112
113
// Fill an output container with the sorted cells.
114
size_type s = 0;
115
for
(size_type i :
indices
) {
116
sorted_cells.at(s++) = cells.at(i);
117
}
118
}
119
120
StatusCode
RDOtoTracccCellConverterCommons::decodeTimeBins
()
121
{
122
static
const
size_t
MAX_BINS = 2;
123
if
(
m_stripRDOTimeBinStr
.size() > MAX_BINS) {
124
ATH_MSG_WARNING
(
"Time bin string has excess characters"
);
125
}
126
127
for
(
size_t
i = 0; i < MAX_BINS; ++i) {
128
switch
(std::toupper(
m_stripRDOTimeBinStr
[i])) {
129
case
'X'
:
m_stripRDOTimeBinBits
[i] = -1;
break
;
130
case
'0'
:
m_stripRDOTimeBinBits
[i] = 0;
break
;
131
case
'1'
:
m_stripRDOTimeBinBits
[i] = 1;
break
;
132
default
:
133
ATH_MSG_FATAL
(
"Invalid time bin string: "
<<
m_stripRDOTimeBinStr
);
134
return
StatusCode::FAILURE;
135
}
136
}
137
return
StatusCode::SUCCESS;
138
}
139
140
bool
RDOtoTracccCellConverterCommons::passTiming
(
const
std::bitset<3>& timePattern)
const
141
{
142
// Convert the given timebin to a bit set and test each bit
143
// if bit is -1 (i.e. X) it always passes, otherwise require exact match of 0/1
144
// N.B. bitset has opposite order to the bit pattern we define
145
if
(
m_stripRDOTimeBinBits
[0] != -1 and timePattern.test(2) !=
static_cast<
bool
>
(
m_stripRDOTimeBinBits
[0]))
return
false
;
146
if
(
m_stripRDOTimeBinBits
[1] != -1 and timePattern.test(1) !=
static_cast<
bool
>
(
m_stripRDOTimeBinBits
[1]))
return
false
;
147
if
(
m_stripRDOTimeBinBits
[2] != -1 and timePattern.test(0) !=
static_cast<
bool
>
(
m_stripRDOTimeBinBits
[2]))
return
false
;
148
return
true
;
149
}
150
151
}
// 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_WARNING
#define ATH_MSG_WARNING(x,...)
Definition
AthMsgStreamMacros.h:46
ATH_MSG_INFO
#define ATH_MSG_INFO(x,...)
Definition
AthMsgStreamMacros.h:45
ATH_MSG_FATAL
#define ATH_MSG_FATAL(x,...)
Definition
AthMsgStreamMacros.h:48
AthReentrantAlgorithm.h
indices
std::vector< std::vector< int64_t > > indices
Definition
HyPERTopoReco.h:16
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:97
SG::makeHandle
SG::ReadCondHandle< T > makeHandle(const SG::ReadCondHandleKey< T > &key, const EventContext &ctx=Gaudi::Hive::currentContext())
Definition
ReadCondHandle.h:268
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_stripRDOTimeBinStr
StringProperty m_stripRDOTimeBinStr
Definition
RDOtoTracccCellConverterCommons.h:77
ActsTrk::RDOtoTracccCellConverterCommons::m_deviceMR
ToolHandle< AthDevice::IMemoryResourceTool > m_deviceMR
Definition
RDOtoTracccCellConverterCommons.h:56
ActsTrk::RDOtoTracccCellConverterCommons::m_geoIdMapping
const ActsTrk::GeometryIdMapping * m_geoIdMapping
Definition
RDOtoTracccCellConverterCommons.h:60
ActsTrk::RDOtoTracccCellConverterCommons::m_CPUCellSorting
Gaudi::Property< bool > m_CPUCellSorting
Definition
RDOtoTracccCellConverterCommons.h:64
ActsTrk::RDOtoTracccCellConverterCommons::m_hostCondObjectName
Gaudi::Property< std::string > m_hostCondObjectName
Definition
RDOtoTracccCellConverterCommons.h:61
ActsTrk::RDOtoTracccCellConverterCommons::m_pixelID
const PixelID * m_pixelID
Definition
RDOtoTracccCellConverterCommons.h:52
ActsTrk::RDOtoTracccCellConverterCommons::RDOtoTracccCellConverterCommons
RDOtoTracccCellConverterCommons(AthReentrantAlgorithm &parent)
Definition
RDOtoTracccCellConverterCommons.cxx:18
ActsTrk::RDOtoTracccCellConverterCommons::m_stripID
const SCT_ID * m_stripID
Definition
RDOtoTracccCellConverterCommons.h:53
ActsTrk::RDOtoTracccCellConverterCommons::m_stripRDOTimeBinBits
int m_stripRDOTimeBinBits[3]
Definition
RDOtoTracccCellConverterCommons.h:78
ActsTrk::RDOtoTracccCellConverterCommons::m_tracccCellsKey
SG::WriteHandleKey< traccc::edm::silicon_cell_collection::buffer > m_tracccCellsKey
Definition
RDOtoTracccCellConverterCommons.h:46
ActsTrk::RDOtoTracccCellConverterCommons::m_nPix
std::atomic< int > m_nPix
Definition
RDOtoTracccCellConverterCommons.h:48
ActsTrk::RDOtoTracccCellConverterCommons::decodeTimeBins
StatusCode decodeTimeBins()
Definition
RDOtoTracccCellConverterCommons.cxx:120
ActsTrk::RDOtoTracccCellConverterCommons::m_nCells
std::atomic< int > m_nCells
Definition
RDOtoTracccCellConverterCommons.h:50
ActsTrk::RDOtoTracccCellConverterCommons::m_parent
AthReentrantAlgorithm & m_parent
Definition
RDOtoTracccCellConverterCommons.h:44
ActsTrk::RDOtoTracccCellConverterCommons::m_UsePixelToTForCellActivation
Gaudi::Property< bool > m_UsePixelToTForCellActivation
Definition
RDOtoTracccCellConverterCommons.h:65
ActsTrk::RDOtoTracccCellConverterCommons::finalize
StatusCode finalize()
Definition
RDOtoTracccCellConverterCommons.cxx:55
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:66
ActsTrk::RDOtoTracccCellConverterCommons::passTiming
bool passTiming(const std::bitset< 3 > &timePattern) const
Definition
RDOtoTracccCellConverterCommons.cxx:140
ActsTrk::RDOtoTracccCellConverterCommons::m_nStrip
std::atomic< int > m_nStrip
Definition
RDOtoTracccCellConverterCommons.h:49
ActsTrk::RDOtoTracccCellConverterCommons::m_copiesTool
ToolHandle< AthDevice::ICopiesTool > m_copiesTool
Definition
RDOtoTracccCellConverterCommons.h:57
ActsTrk::RDOtoTracccCellConverterCommons::m_hostMR
ToolHandle< AthDevice::IMemoryResourceTool > m_hostMR
Definition
RDOtoTracccCellConverterCommons.h:55
ActsTrk::RDOtoTracccCellConverterCommons::m_hostCond
const traccc::detector_conditions_description::host * m_hostCond
Definition
RDOtoTracccCellConverterCommons.h:62
ActsTrk::RDOtoTracccCellConverterCommons::copyToGpuAndRecordToSG
StatusCode copyToGpuAndRecordToSG(EventContext const &ctx, traccc::edm::silicon_cell_collection::buffer const &cells) const
Definition
RDOtoTracccCellConverterCommons.cxx:79
ActsTrk::RDOtoTracccCellConverterCommons::initialize
StatusCode initialize()
Definition
RDOtoTracccCellConverterCommons.cxx:38
ActsTrk::RDOtoTracccCellConverterCommons::m_geoIdMappingObjectName
Gaudi::Property< std::string > m_geoIdMappingObjectName
Definition
RDOtoTracccCellConverterCommons.h:59
Generated on
for ATLAS Offline Software by
1.17.0