32{
33 using size_type = traccc::edm::silicon_cell_collection::buffer::size_type;
34
35
40
41
42
43
44 size_type nPix = 0,
nStrip = 0;
45
46 for (const auto* coll : *pixelRDOHandle) {
47 if (coll) {
48 nPix += coll->size();
49 }
50 }
51 for (const auto* coll : *stripRDOHandle) {
52 if (coll) {
53 for (const SCT_RDORawData* rdo : *coll) {
54
55 assert(dynamic_cast<const SCT3_RawData*>(rdo)!=nullptr);
56 const SCT3_RawData* raw3 = static_cast<const SCT3_RawData*>(rdo);
57
58 std::bitset<3> timePattern(raw3->
getTimeBin());
59 if (!
m_common.passTiming(timePattern)) {
61 continue;
62 }
63 nStrip += rdo->getGroupSize();
64 }
65 }
66 }
67
68 ATH_MSG_DEBUG(
"Found " << nPix <<
" Pixel RDOs and " << nStrip
69 << " Strip RDOs, total " << (nPix + nStrip) << " RDOs");
71
72
73
74 auto host_copy =
m_common.m_copiesTool->hostCopy(ctx);
75 traccc::edm::silicon_cell_collection::buffer traccc_cells_host_buffer{
77 host_copy->setup(traccc_cells_host_buffer)->wait();
78
79 if (nCells == 0) {
80 ATH_MSG_DEBUG(
"no input hits — writing empty cell collection");
82 return StatusCode::SUCCESS;
83 }
84
85
86 traccc::edm::silicon_cell_collection::device
cells{traccc_cells_host_buffer};
87
88
89
90
91 size_type cell_index = 0;
92 uint64_t current_geometry_id = detray::geometry::identifier{}.value();
93 unsigned int current_det_cond_idx = -1;
94
95
96 for (const auto* coll : *pixelRDOHandle) {
97
98 for (const PixelRDORawData* rdo : *coll) {
99 const Identifier rdoId = rdo->identify();
100 const InDetDD::SiDetectorElement*
el =
102 if (!el) continue;
103 const Identifier modId =
el->identify();
104 const InDetDD::SiCellId cellId =
el->cellIdFromIdentifier(rdoId);
105 const std::optional<detray_id_type> geoIdOpt =
m_common.m_geoIdMapping->athenaToDetray(modId);
106 if (!geoIdOpt.has_value()) {
107 ATH_MSG_FATAL(
"No detray id found for Athena identifier " << modId);
108 return StatusCode::FAILURE;
109 }
111
112 if (geoId != current_geometry_id) {
113 current_geometry_id = geoId;
114 std::optional<unsigned int> det_cond_idx_opt =
115 m_common.m_geoIdMapping->detrayToDetDescIndex(current_geometry_id);
116 if (!det_cond_idx_opt.has_value()) {
117 ATH_MSG_FATAL(
"No detector conditions index found for detray identifier " << current_geometry_id);
118 return StatusCode::FAILURE;
119 }
120 current_det_cond_idx = det_cond_idx_opt.value();
121 }
122
123 float activation = 1.;
124 if (
m_common.m_UsePixelToTForCellActivation) {
125 activation = static_cast<float>(rdo->getToT());
126 if (activation == 0.) {
127 ATH_MSG_ERROR(
"input data error: RDO must not have ToT=0; RDO index: "
128 << cell_index);
129 }
130 }
131
132 traccc::edm::silicon_cell
cell =
cells.at(cell_index++);
135 cell.module_index() = current_det_cond_idx;
136 cell.activation() = activation;
138 }
139 }
140
141
142 for (const auto* coll : *stripRDOHandle) {
143 for (const SCT_RDORawData* rdo : *coll) {
144
145 assert(dynamic_cast<const SCT3_RawData*>(rdo)!=nullptr);
146 const SCT3_RawData* raw3 = static_cast<const SCT3_RawData*>(rdo);
147
148 std::bitset<3> timePattern(raw3->
getTimeBin());
149 if (!
m_common.passTiming(timePattern)) {
151 continue;
152 }
153
154 const Identifier rdoId = rdo->identify();
155 const InDetDD::SiDetectorElement*
el =
157 if (!el) continue;
158 const Identifier modId =
el->identify();
159 const InDetDD::SiCellId cellId =
el->cellIdFromIdentifier(rdoId);
160 const std::optional<detray_id_type> geoIdOpt =
m_common.m_geoIdMapping->athenaToDetray(modId);
161 if (!geoIdOpt.has_value()) {
162 ATH_MSG_FATAL(
"No detray id found for Athena identifier " << modId);
163 return StatusCode::FAILURE;
164 }
166
167 if (geoId != current_geometry_id) {
168 current_geometry_id = geoId;
169 std::optional<unsigned int> det_cond_idx_opt =
170 m_common.m_geoIdMapping->detrayToDetDescIndex(current_geometry_id);
171 if (!det_cond_idx_opt.has_value()) {
172 ATH_MSG_FATAL(
"No detector conditions index found for detray identifier " << current_geometry_id);
173 return StatusCode::FAILURE;
174 }
175 current_det_cond_idx = det_cond_idx_opt.value();
176 }
177
178 if (
m_common.m_stripID->barrel_ec(modId) == 0) {
179 for (
int i = 0;
i < rdo->getGroupSize(); ++
i) {
180
181 traccc::edm::silicon_cell
cell =
cells.at(cell_index++);
184 cell.module_index() = current_det_cond_idx;
185 cell.activation() = 1.;
187
188 }
189 } else {
190 for (
int i = 0;
i < rdo->getGroupSize(); ++
i) {
191
192 traccc::edm::silicon_cell
cell =
cells.at(cell_index++);
195 cell.module_index() = current_det_cond_idx;
196 cell.activation() = 1.;
198
199 }
200 }
201 }
202 }
203
204
206 traccc::edm::silicon_cell_collection::buffer sorted_cells_host_buffer =
207 m_common.sortCells(*host_copy, cells);
208
209
211 } else {
212
213
214
215
217 }
218
219
223
225 <<
m_common.m_tracccCellsKey.key() <<
"'");
226 return StatusCode::SUCCESS;
227}
#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,...)
const InDetDD::PixelDetectorManager * m_pixelManager
const InDetDD::SCT_DetectorManager * m_stripManager
SG::ReadHandleKey< PixelRDO_Container > m_pixelRDOKey
SG::ReadHandleKey< SCT_RDO_Container > m_stripRDOKey
RDOtoTracccCellConverterCommons m_common
int phiIndex() const
Get phi index. Equivalent to strip().
int etaIndex() const
Get eta index.
GeometryIdMapping::detray_id_type detray_id_type
SG::ReadCondHandle< T > makeHandle(const SG::ReadCondHandleKey< T > &key, const EventContext &ctx=Gaudi::Hive::currentContext())
@ nStrip
Get number of strips.
setRawEt setRawPhi nCells