72 using size_type = traccc::edm::measurement_collection::buffer::size_type;
73 constexpr unsigned int invalidIndex = std::numeric_limits<unsigned int>::max();
80 const unsigned int nPixel = pixelClusters->size();
81 const unsigned int nStrip = stripClusters->size();
82 const size_type nMeas = nPixel + nStrip;
83 ATH_MSG_DEBUG(
"Found " << nPixel <<
" pixel clusters and " << nStrip
84 <<
" strip clusters, total " << nMeas <<
" clusters");
86 std::vector<MeasurementRecord> records;
87 records.reserve(nMeas);
96 const auto locPos = cl->localPosition<2>();
97 const auto locCov = cl->localCovariance<2>();
101 records.push_back(rec);
115 const unsigned int measuredAxis =
static_cast<unsigned int>(
m_hostDesign->subspace()[designIdx][0]);
116 const unsigned int otherAxis = (measuredAxis == 0u) ? 1u : 0u;
117 const auto& otherEdges = (otherAxis == 0u) ?
m_hostDesign->bin_edges_x()[designIdx]
119 float otherCentre = 0.f;
120 float otherVariance = 0.f;
121 if (!otherEdges.empty()) {
122 const float width = otherEdges.back() - otherEdges.front();
123 otherCentre = 0.5f * (otherEdges.front() + otherEdges.back());
127 const auto locPos = cl->localPosition<1>();
128 const auto locCov = cl->localCovariance<1>();
133 records.push_back(rec);
137 std::vector<unsigned int> order(records.size());
138 std::iota(order.begin(), order.end(), 0u);
139 std::sort(order.begin(), order.end(), [&records](
unsigned int lhs,
unsigned int rhs) {
140 const MeasurementRecord& a = records[lhs];
141 const MeasurementRecord& b = records[rhs];
142 if (a.geometryId != b.geometryId) return a.geometryId < b.geometryId;
143 if (a.localPosition[0] != b.localPosition[0]) return a.localPosition[0] < b.localPosition[0];
144 return a.localPosition[1] < b.localPosition[1];
147 std::pmr::memory_resource* hostMR =
m_MRs->hostMR();
149 auto measHostBuffer = std::make_unique<traccc::edm::measurement_collection::buffer>(
150 nMeas, hostMR ? *hostMR :
m_MRs->mainMR());
151 hostCopy->setup(*measHostBuffer)->wait();
154 traccc::edm::measurement_collection::device measurements{*measHostBuffer};
156 auto measToPixel = std::make_unique<std::vector<unsigned int>>(nMeas, invalidIndex);
157 auto measToStrip = std::make_unique<std::vector<unsigned int>>(nMeas, invalidIndex);
160 for (size_type i = 0; i < nMeas; ++i) {
164 auto meas = measurements.at(i);
167 meas.dimensions() =
static_cast<unsigned int>(
m_hostDesign->dimensions()[designIdx]);
170 meas.identifier() = i;
185 auto measDeviceBuffer = std::make_unique<traccc::edm::measurement_collection::buffer>(
186 measHostBuffer->capacity(),
m_MRs->mainMR());
189 deviceCopy->setup(*measDeviceBuffer)->ignore();
190 (*deviceCopy)(*measHostBuffer, *measDeviceBuffer)->wait();
191 ATH_CHECK(measHandle.record(std::move(measDeviceBuffer)));
193 ATH_CHECK(measHandle.record(std::move(measHostBuffer)));
197 ATH_CHECK(measToPixelHandle.record(std::move(measToPixel)));
199 ATH_CHECK(measToStripHandle.record(std::move(measToStrip)));
206 return StatusCode::SUCCESS;