63 using size_type = traccc::edm::measurement_collection::buffer::size_type;
64 constexpr unsigned int invalidIndex = std::numeric_limits<unsigned int>::max();
73 const traccc::detector_conditions_description::host& hostCond = **hostCondHandle;
75 const unsigned int nPixel = pixelClusters->size();
76 const unsigned int nStrip = stripClusters->size();
77 const size_type nMeas = nPixel + nStrip;
78 ATH_MSG_DEBUG(
"Found " << nPixel <<
" pixel clusters and " << nStrip
79 <<
" strip clusters, total " << nMeas <<
" clusters");
81 std::vector<MeasurementRecord> records;
82 records.reserve(nMeas);
91 const auto locPos = cl->localPosition<2>();
92 const auto locCov = cl->localCovariance<2>();
96 records.push_back(rec);
109 const unsigned int designIdx = hostCond.module_to_design_id()[rec.
condIndex];
110 const unsigned int measuredAxis =
static_cast<unsigned int>(
m_hostDesign->subspace()[designIdx][0]);
111 const unsigned int otherAxis = (measuredAxis == 0u) ? 1u : 0u;
112 const auto& otherEdges = (otherAxis == 0u) ?
m_hostDesign->bin_edges_x()[designIdx]
114 float otherCentre = 0.f;
115 float otherVariance = 0.f;
116 if (!otherEdges.empty()) {
117 const float width = otherEdges.back() - otherEdges.front();
118 otherCentre = 0.5f * (otherEdges.front() + otherEdges.back());
122 const auto locPos = cl->localPosition<1>();
123 const auto locCov = cl->localCovariance<1>();
128 records.push_back(rec);
132 std::vector<unsigned int> order(records.size());
133 std::iota(order.begin(), order.end(), 0u);
134 std::sort(order.begin(), order.end(), [&records](
unsigned int lhs,
unsigned int rhs) {
135 const MeasurementRecord& a = records[lhs];
136 const MeasurementRecord& b = records[rhs];
137 if (a.geometryId != b.geometryId) return a.geometryId < b.geometryId;
138 if (a.localPosition[0] != b.localPosition[0]) return a.localPosition[0] < b.localPosition[0];
139 return a.localPosition[1] < b.localPosition[1];
142 std::pmr::memory_resource* hostMR =
m_MRs->hostMR();
144 auto measHostBuffer = std::make_unique<traccc::edm::measurement_collection::buffer>(
145 nMeas, hostMR ? *hostMR :
m_MRs->mainMR());
146 hostCopy->setup(*measHostBuffer)->wait();
149 traccc::edm::measurement_collection::device measurements{*measHostBuffer};
151 auto measToPixel = std::make_unique<std::vector<unsigned int>>(nMeas, invalidIndex);
152 auto measToStrip = std::make_unique<std::vector<unsigned int>>(nMeas, invalidIndex);
155 for (size_type i = 0; i < nMeas; ++i) {
157 const unsigned int designIdx = hostCond.module_to_design_id()[rec.
condIndex];
159 auto meas = measurements.at(i);
162 meas.dimensions() =
static_cast<unsigned int>(
m_hostDesign->dimensions()[designIdx]);
165 meas.identifier() = i;
166 meas.surface_link() = hostCond.geometry_id()[rec.
condIndex];
180 auto measDeviceBuffer = std::make_unique<traccc::edm::measurement_collection::buffer>(
181 measHostBuffer->capacity(),
m_MRs->mainMR());
184 deviceCopy->setup(*measDeviceBuffer)->ignore();
185 (*deviceCopy)(*measHostBuffer, *measDeviceBuffer)->wait();
186 ATH_CHECK(measHandle.record(std::move(measDeviceBuffer)));
188 ATH_CHECK(measHandle.record(std::move(measHostBuffer)));
192 ATH_CHECK(measToPixelHandle.record(std::move(measToPixel)));
194 ATH_CHECK(measToStripHandle.record(std::move(measToStrip)));
201 return StatusCode::SUCCESS;