27{
28 using size_type = traccc::edm::silicon_cell_collection::buffer::size_type;
33
34
39
40
41
42
43 size_type nPix = 0,
nStrip = 0;
44
45
47 for (PixelRawDataContainerProxy module_rdo_container_proxy : pixel_rdo_container_collection_proxy) {
48 if (!module_rdo_container_proxy.empty()) {
49 nPix += module_rdo_container_proxy.size();
50 }
51 }
52
53
55
56 for (StripRawDataContainerProxy module_rdo_container_proxy : strip_rdo_container_collection_proxy) {
57 if (!module_rdo_container_proxy.empty()) {
58 for (StripRawDataProxy strip_rdo: module_rdo_container_proxy) {
59 if (!
m_common.passTiming(strip_rdo.getTimeBin())) {
61 continue;
62 }
63 nStrip += strip_rdo.getGroupSize();
64 }
65 }
66 }
67
69
70
71 auto host_copy =
m_common.m_copiesTool->hostCopy(ctx);
72 traccc::edm::silicon_cell_collection::buffer traccc_cells_host_buffer{
74 host_copy->setup(traccc_cells_host_buffer)->wait();
75
76 if (nCells == 0) {
77 ATH_MSG_DEBUG(
"no input hits — writing empty cell collection");
79 return StatusCode::SUCCESS;
80 }
81
82
83 traccc::edm::silicon_cell_collection::device
cells{traccc_cells_host_buffer};
84
85
86
87
88 size_type cell_index = 0;
89 detray_id_type current_geometry_id = detray::geometry::identifier{}.value();
90 unsigned int current_det_cond_idx = -1;
91
92
93 for (PixelRawDataContainerProxy module_rdo_container_proxy : pixel_rdo_container_collection_proxy) {
94 if (module_rdo_container_proxy.empty()) {
95 continue;
96 }
97 IdentifierHash const module_id_hash(module_rdo_container_proxy.identifyHash());
98 Identifier
const module_id =
m_common.m_pixelID->wafer_id(module_id_hash);
99 std::optional<detray_id_type>
const detray_geometry_id_opt =
m_common.m_geoIdMapping->athenaToDetray(module_id);
100 if (!detray_geometry_id_opt.has_value()) {
101 ATH_MSG_FATAL(
"No detray id found for Athena identifier " << module_id);
102 return StatusCode::FAILURE;
103 }
104 const detray_id_type detray_geometry_id{detray_geometry_id_opt.value()};
105 if (detray_geometry_id != current_geometry_id) {
106 current_geometry_id = detray_geometry_id;
107 std::optional<unsigned int> det_cond_idx_opt =
108 m_common.m_geoIdMapping->detrayToDetDescIndex(current_geometry_id);
109 if (!det_cond_idx_opt.has_value()) {
110 ATH_MSG_FATAL(
"No detector conditions index found for detray identifier " << current_geometry_id);
111 return StatusCode::FAILURE;
112 }
113 current_det_cond_idx = det_cond_idx_opt.value();
114 }
115
116 for (PixelRawDataProxy pixel_rdo: module_rdo_container_proxy) {
117 float activation = 1.;
118 if (
m_common.m_UsePixelToTForCellActivation) {
119 activation = static_cast<float>(pixel_rdo.getToT());
120 if (activation == 0.) {
121 ATH_MSG_ERROR(
"input data error: RDO must not have ToT=0; RDO index: "
122 << cell_index);
123 }
124 }
125
126 traccc::edm::silicon_cell
cell =
cells.at(cell_index++);
127 cell.channel0() =
static_cast<uint32_t>(pixel_rdo.coordinates()[0]);
128 cell.channel1() =
static_cast<uint32_t>(pixel_rdo.coordinates()[1]);
129 cell.module_index() = current_det_cond_idx;
130 cell.activation() = activation;
132 }
133 }
134
135
136 for (StripRawDataContainerProxy module_rdo_container_proxy : strip_rdo_container_collection_proxy) {
137 if (module_rdo_container_proxy.empty()) {
138 continue;
139 }
140 IdentifierHash const module_id_hash(module_rdo_container_proxy.identifyHash());
141 Identifier
const module_id =
m_common.m_stripID->wafer_id(module_id_hash);
142 std::optional<detray_id_type>
const detray_geometry_id_opt =
m_common.m_geoIdMapping->athenaToDetray(module_id);
143 if (!detray_geometry_id_opt.has_value()) {
144 ATH_MSG_FATAL(
"No detray id found for Athena identifier " << module_id);
145 return StatusCode::FAILURE;
146 }
147 const detray_id_type detray_geometry_id{detray_geometry_id_opt.value()};
148 if (detray_geometry_id != current_geometry_id) {
149 current_geometry_id = detray_geometry_id;
150 std::optional<unsigned int> det_cond_idx_opt =
151 m_common.m_geoIdMapping->detrayToDetDescIndex(current_geometry_id);
152 if (!det_cond_idx_opt.has_value()) {
153 ATH_MSG_FATAL(
"No detector conditions index found for detray identifier " << current_geometry_id);
154 return StatusCode::FAILURE;
155 }
156 current_det_cond_idx = det_cond_idx_opt.value();
157 }
158
159 for (StripRawDataProxy strip_rdo: module_rdo_container_proxy) {
160 if (!
m_common.passTiming(strip_rdo.getTimeBin())) {
162 continue;
163 }
164
165 if (
m_common.m_stripID->barrel_ec(module_id) == 0) {
166 for (
int i = 0;
i < strip_rdo.getGroupSize(); ++
i) {
167 traccc::edm::silicon_cell
cell =
cells.at(cell_index++);
168 cell.channel0() =
static_cast<uint32_t>(strip_rdo.coordinates()[0] + i);
170 cell.module_index() = current_det_cond_idx;
171 cell.activation() = 1.;
173 }
174 } else {
175 for (
int i = 0;
i < strip_rdo.getGroupSize(); ++
i) {
176 traccc::edm::silicon_cell
cell =
cells.at(cell_index++);
178 cell.channel1() =
static_cast<uint32_t>(strip_rdo.coordinates()[0] + i);
179 cell.module_index() = current_det_cond_idx;
180 cell.activation() = 1.;
182 }
183 }
184 }
185 }
186
188
189 traccc::edm::silicon_cell_collection::buffer sorted_cells_host_buffer =
190 m_common.sortCells(*host_copy, cells);
191
192
194 } else {
195
196
197
198
200 }
201
202
206
208 <<
m_common.m_tracccCellsKey.key() <<
"'");
209 return StatusCode::SUCCESS;
210}
#define ATH_CHECK
Evaluate an expression and check for errors.
#define ATH_MSG_DEBUG(x,...)
#define ATH_MSG_ERROR(x,...)
#define ATH_MSG_FATAL(x,...)
SG::ReadHandleKey< PhaseIIStripRawDataContainer > m_ph2StripRDOKey
SG::ReadHandleKey< PhaseIIPixelRawDataContainer > m_ph2PixelRDOKey
RDOtoTracccCellConverterCommons m_common
GeometryIdMapping::detray_id_type detray_id_type
auto makeRawDataCollectionProxy(const T_RawDataContainerCollection &collection)
Create the top level container proxy for an RDO container collection (read only).
SG::ReadCondHandle< T > makeHandle(const SG::ReadCondHandleKey< T > &key, const EventContext &ctx=Gaudi::Hive::currentContext())
@ nStrip
Get number of strips.
setRawEt setRawPhi nCells
typename RawData::details::traits< ContainerNonConst >::template RawDataProxy< accessPolicy > RawDataProxy
PhaseII::RawDataContainerProxy< typename Utils::ContainerAccessHelper< T_RawDataContainer, accessPolicy >::ContainerType, RawDataProxy > RawDataContainerProxy