ATLAS Offline Software
Loading...
Searching...
No Matches
StripSpacepointAdapter.cxx
Go to the documentation of this file.
1/*
2 Copyright (C) 2002-2026 CERN for the benefit of the ATLAS collaboration
3*/
5
6#include <algorithm>
7#include <array>
8#include <cmath>
9#include <stdexcept>
10#include <string>
11#include <tuple>
12#include <vector>
13
22
23namespace ActsTrk {
24namespace {
25// Athena-only staging data: design and neighbour conventions never cross the
26// traccc input boundary. Keep cut preparation independent of GPU execution.
27constexpr unsigned int max_strip_rows = 4u;
28struct athena_strip_surface_info {
30 std::uint64_t surface_link;
32 unsigned int is_endcap;
34 traccc::scalar spacepoint_variance_r;
35 traccc::scalar spacepoint_variance_z;
37 double min_r;
39 double max_r;
41 unsigned int is_annulus;
43 std::array<double, 3> origin;
44 std::array<double, 3> eta_axis;
45 std::array<double, 3> phi_axis;
47 std::array<double, 3> transform_local_x;
48 std::array<double, 3> transform_normal;
49 std::array<double, 3> transform_translation;
50 std::array<double, 3> element_center;
52 unsigned int barrel_n_rows;
53 unsigned int barrel_n_strips;
54 double barrel_pitch;
55 double barrel_row_length;
57 unsigned int endcap_n_strips;
58 double endcap_phi_pitch;
59 double endcap_stereo_angle;
60 double endcap_wafer_center_r;
62 double endcap_phi_width;
63 double endcap_length_bf;
64 double endcap_sin_stereo;
65 double endcap_cos_stereo;
67 unsigned int endcap_uses_polar_coordinates;
69 int barrel_ec;
71 unsigned int is_reference_surface;
73 std::uint64_t opposite_surface_link;
74 std::uint64_t eta_minus_surface_link;
75 std::uint64_t eta_plus_surface_link;
76 std::uint64_t phi_minus_surface_link;
77 std::uint64_t phi_plus_surface_link;
79 traccc::scalar opposite_min;
80 traccc::scalar opposite_max;
81 traccc::scalar eta_minus_min;
82 traccc::scalar eta_minus_max;
83 traccc::scalar eta_plus_min;
84 traccc::scalar eta_plus_max;
86 traccc::scalar phi_minus_reference_min;
87 traccc::scalar phi_minus_reference_max;
88 traccc::scalar phi_minus_candidate_min;
89 traccc::scalar phi_minus_candidate_max;
90 traccc::scalar phi_plus_reference_min;
91 traccc::scalar phi_plus_reference_max;
92 traccc::scalar phi_plus_candidate_min;
93 traccc::scalar phi_plus_candidate_max;
94};
95
98traccc::scalar strip_length_gap_tolerance(
99 const athena_strip_surface_info& first_info,
100 const athena_strip_surface_info& second_info,
101 const traccc::scalar strip_gap_parameter = 0.0015f) {
102
103 if (strip_gap_parameter == 0.f) {
104 return 0.f;
105 }
106
107 // Relative local-x orientation and displacement along the reference normal
108 // reproduce the CPU tool's inputs to the strip-gap correction. Keep these
109 // host calculations in double precision until the final Traccc input cast.
110 const double x12 =
111 first_info.transform_local_x[0] * second_info.transform_local_x[0] +
112 first_info.transform_local_x[1] * second_info.transform_local_x[1] +
113 first_info.transform_local_x[2] * second_info.transform_local_x[2];
114 const double dx = first_info.transform_translation[0] -
115 second_info.transform_translation[0];
116 const double dy = first_info.transform_translation[1] -
117 second_info.transform_translation[1];
118 const double dz = first_info.transform_translation[2] -
119 second_info.transform_translation[2];
120 const double surface_separation = dx * first_info.transform_normal[0] +
121 dy * first_info.transform_normal[1] +
122 dz * first_info.transform_normal[2];
123 // The CPU offset uses the element centre for Annulus designs and the
124 // transform origin otherwise; these positions need not coincide.
125 const double radius_x = first_info.is_annulus != 0u
126 ? first_info.element_center[0]
127 : first_info.transform_translation[0];
128 const double radius_y = first_info.is_annulus != 0u
129 ? first_info.element_center[1]
130 : first_info.transform_translation[1];
131 const double surface_reference_r =
132 std::sqrt(radius_x * radius_x + radius_y * radius_y);
133 const double dm = static_cast<double>(strip_gap_parameter) *
134 surface_reference_r * std::abs(surface_separation * x12);
135
136 // Convert the transverse gap allowance into a strip-length allowance.
137 // Preserve the CPU tool's Annulus factor (0.04) and its relative-axis
138 // expression for other designs rather than introducing a new cut here.
139 double tolerance = 0.;
140 if (first_info.is_annulus != 0u) {
141 tolerance = dm / 0.04;
142 } else {
143 const double denominator2 = (1. - x12) * (1. + x12);
144 if (denominator2 > 0.) {
145 tolerance = dm / std::sqrt(denominator2);
146 }
147 }
148
149 // Apply the CPU tool's extra radial/longitudinal projection for surfaces
150 // whose normal is predominantly along z. Avoid division at z = 0.
151 if ((std::abs(first_info.transform_normal[2]) > 0.7) &&
152 (std::abs(first_info.transform_translation[2]) > 0.)) {
153 tolerance *=
154 surface_reference_r / std::abs(first_info.transform_translation[2]);
155 }
156 return static_cast<traccc::scalar>(tolerance);
157}
158
159} // namespace
160
163 const SCT_ID& strip_id, const InDet::SiElementPropertiesTable& properties,
164 const GeometryIdMapping& mapping, vecmem::memory_resource& mr) {
165 // Build host-only staging records first, then translate them into the
166 // surface records and directed pairing rules consumed by Traccc. Athena
167 // design objects and neighbour lookups stay on the host.
168 StripSpacepointInputs result(mr);
169 std::vector<athena_strip_surface_info> legacy_infos;
170 // Express Athena element relationships in the same Detray surface IDs as
171 // the measurements. Null neighbours cannot contribute a pair; an unmapped
172 // element is an error.
173 const auto detray_surface_link =
174 [&](const InDetDD::SiDetectorElement* element) {
175 if (element == nullptr) {
176 return traccc::invalid_strip_surface_link;
177 }
178 const auto link = mapping.athenaToDetray(element->identify());
179 if (!link) {
180 throw std::runtime_error(
181 "Missing Detray mapping for strip element " +
182 std::to_string(element->identify().get_compact()));
183 }
184 return *link;
185 };
186
187 // Widen the CPU pairing-coordinate windows to account for the separation
188 // and relative orientation of two surfaces. This is the transverse offset;
189 // strip_length_gap_tolerance converts it for the later intersection test.
190 const auto strip_range_offset =
192 const InDetDD::SiDetectorElement* candidate) {
193 constexpr double strip_gap_parameter = 0.0015;
194 const Amg::Transform3D& first = reference->transform();
195 const Amg::Transform3D& second = candidate->transform();
196 const Amg::Vector3D center = reference->center();
197 const bool is_annulus = reference->isEndcap();
198 const double x12 = first(0, 0) * second(0, 0) +
199 first(1, 0) * second(1, 0) +
200 first(2, 0) * second(2, 0);
201 const double radius = is_annulus ? std::hypot(center.x(), center.y())
202 : std::hypot(first(0, 3), first(1, 3));
203 const double separation = (first(0, 3) - second(0, 3)) * first(0, 2) +
204 (first(1, 3) - second(1, 3)) * first(1, 2) +
205 (first(2, 3) - second(2, 3)) * first(2, 2);
206 return strip_gap_parameter * radius * std::abs(separation * x12);
207 };
208
209 // Reproduce the CPU correctPolarRange convention for endcap windows:
210 // resolve edge strip IDs at a representative row-0 radius, then express
211 // the coordinate bounds as angles. Phi-overlap rules use the strip IDs;
212 // opposite-side rules use the angular bounds.
213 const auto correct_polar_range = [](const InDetDD::SiDetectorElement* element,
214 double& min_value, double& max_value,
215 std::size_t& min_strip,
216 std::size_t& max_strip) {
217 if ((element == nullptr) || element->isBarrel()) {
218 return;
219 }
220 const auto* design = dynamic_cast<const InDetDD::StripStereoAnnulusDesign*>(
221 &element->design());
222 if ((design == nullptr) || (design->diodesInRow(0) == 0)) {
223 return;
224 }
225 const auto first_position =
226 0.5 * (design->localPositionOfCell(design->strip1Dim(0, 0)) +
227 design->localPositionOfCell(
228 design->strip1Dim(design->diodesInRow(0) - 1, 0)));
229 const double radius = first_position.xEta();
230 InDetDD::SiCellId min_cell = element->cellIdOfPosition(
231 InDetDD::SiLocalPosition(radius, min_value, 0.));
232 InDetDD::SiCellId max_cell = element->cellIdOfPosition(
233 InDetDD::SiLocalPosition(radius, max_value, 0.));
234 // Match the reference fallback when a window edge lies outside the
235 // active region: use the first/last strip of the row.
236 if (!min_cell.isValid()) {
237 min_cell = InDetDD::SiCellId(0);
238 }
239 if (!max_cell.isValid()) {
240 max_cell = InDetDD::SiCellId(design->diodesInRow(0) - 1);
241 }
242 min_strip = min_cell.strip();
243 max_strip = max_cell.strip();
244 min_value = std::atan2(min_value, radius);
245 max_value = std::atan2(max_value, radius);
246 };
247
248 // Prepare the CPU tool's opposite, eta-overlap and phi-overlap windows.
249 // Only the non-stereo side initiates pairs, avoiding a reverse duplicate.
250 const auto fill_offline_relationships =
251 [&](athena_strip_surface_info& info,
253 const IdentifierHash reference_hash) {
254 if ((reference == nullptr) || reference->isStereo()) {
255 return;
256 }
257 info.is_reference_surface = 1u;
258 // These window sizes follow the reference CPU pairing cuts (mm
259 // before any endcap conversion), not new GPU-specific selections.
260 constexpr double opposite_limit = 2.8;
261 constexpr double phi_overlap = 5.64;
262 constexpr double eta_min = 1.68;
263 constexpr double eta_max = 3.0;
264 const double half_width = properties.halfWidth(reference_hash);
265 const auto candidate_from_hash = [&](const IdentifierHash hash) {
266 return elements.getDetectorElement(hash);
267 };
268 const auto make_range =
269 [&](const InDetDD::SiDetectorElement* candidate,
270 const InDetDD::SiDetectorElement* polar_element,
271 double min_value, double max_value, traccc::scalar& output_min,
272 traccc::scalar& output_max, bool use_strip_index) {
273 const double offset = strip_range_offset(reference, candidate);
274 min_value -= offset;
275 max_value += offset;
276 std::size_t min_strip = 0u;
277 std::size_t max_strip = 0u;
278 correct_polar_range(polar_element, min_value, max_value,
279 min_strip, max_strip);
280 output_min = static_cast<traccc::scalar>(
281 use_strip_index ? min_strip : min_value);
282 output_max = static_cast<traccc::scalar>(
283 use_strip_index ? max_strip : max_value);
284 };
285
286 // The other side of the module supplies the standard SP partner.
287 // Overlap partners are neighbours of that opposite side.
288 IdentifierHash opposite_hash;
289 if (strip_id.get_other_side(reference_hash, opposite_hash) != 0) {
290 return;
291 }
292 const InDetDD::SiDetectorElement* opposite =
293 candidate_from_hash(opposite_hash);
294 const std::uint64_t opposite_link = detray_surface_link(opposite);
295 if (opposite_link == traccc::invalid_strip_surface_link) {
296 return;
297 }
298 info.opposite_surface_link = opposite_link;
299 make_range(opposite, reference, -opposite_limit, opposite_limit,
300 info.opposite_min, info.opposite_max, false);
301
302 // Phi overlaps require separate edge windows on the reference and
303 // candidate surfaces. Endcap windows are stored as strip-index cuts.
304 const auto fill_phi_neighbour = [&](const IdentifierHash neighbour_hash,
305 const bool is_minus) {
306 const InDetDD::SiDetectorElement* candidate =
307 candidate_from_hash(neighbour_hash);
308 const std::uint64_t candidate_link = detray_surface_link(candidate);
309 if (candidate_link == traccc::invalid_strip_surface_link) {
310 return;
311 }
312 if (is_minus) {
313 info.phi_minus_surface_link = candidate_link;
314 make_range(candidate, reference, -half_width,
315 -half_width + phi_overlap, info.phi_minus_reference_min,
316 info.phi_minus_reference_max, reference->isEndcap());
317 make_range(candidate, candidate, half_width - phi_overlap,
318 half_width, info.phi_minus_candidate_min,
319 info.phi_minus_candidate_max, candidate->isEndcap());
320 } else {
321 info.phi_plus_surface_link = candidate_link;
322 make_range(candidate, reference, half_width - phi_overlap,
323 half_width, info.phi_plus_reference_min,
324 info.phi_plus_reference_max, reference->isEndcap());
325 make_range(candidate, candidate, -half_width,
326 -half_width + phi_overlap, info.phi_plus_candidate_min,
327 info.phi_plus_candidate_max, candidate->isEndcap());
328 }
329 };
330
331 IdentifierHash neighbour_hash;
332 if (strip_id.get_prev_in_phi(opposite_hash, neighbour_hash) == 0) {
333 fill_phi_neighbour(neighbour_hash, true);
334 }
335 if (strip_id.get_next_in_phi(opposite_hash, neighbour_hash) == 0) {
336 fill_phi_neighbour(neighbour_hash, false);
337 }
338
339 // The reference CPU path adds eta-neighbour overlap pairs only for
340 // barrel elements; endcap elements retain the phi-neighbour pairs.
341 if (reference->isBarrel()) {
342 const auto fill_eta_neighbour = [&](const IdentifierHash eta_hash,
343 const bool is_minus) {
344 const InDetDD::SiDetectorElement* candidate =
345 candidate_from_hash(eta_hash);
346 const std::uint64_t candidate_link = detray_surface_link(candidate);
347 if (candidate_link == traccc::invalid_strip_surface_link) {
348 return;
349 }
350 if (is_minus) {
351 info.eta_minus_surface_link = candidate_link;
352 make_range(candidate, reference, eta_min, eta_max,
353 info.eta_minus_min, info.eta_minus_max, false);
354 } else {
355 info.eta_plus_surface_link = candidate_link;
356 make_range(candidate, reference, eta_min, eta_max,
357 info.eta_plus_min, info.eta_plus_max, false);
358 }
359 };
360 if (strip_id.get_prev_in_eta(opposite_hash, neighbour_hash) == 0) {
361 fill_eta_neighbour(neighbour_hash, true);
362 }
363 if (strip_id.get_next_in_eta(opposite_hash, neighbour_hash) == 0) {
364 fill_eta_neighbour(neighbour_hash, false);
365 }
366 }
367 };
368
369 // Collect aligned frames, design parameters and neighbour windows for
370 // each mapped strip surface. Zero-initialisation leaves absent neighbours
371 // inactive until a valid surface link is assigned below.
372 for (auto element_it = elements.begin(); element_it != elements.end();
373 ++element_it) {
374 const InDetDD::SiDetectorElement* element = *element_it;
375 const std::uint64_t surface_link = detray_surface_link(element);
376 if ((element == nullptr) ||
377 (surface_link == traccc::invalid_strip_surface_link)) {
378 continue;
379 }
380
381 athena_strip_surface_info info{};
382 info.surface_link = surface_link;
383 info.opposite_surface_link = traccc::invalid_strip_surface_link;
384 info.eta_minus_surface_link = traccc::invalid_strip_surface_link;
385 info.eta_plus_surface_link = traccc::invalid_strip_surface_link;
386 info.phi_minus_surface_link = traccc::invalid_strip_surface_link;
387 info.phi_plus_surface_link = traccc::invalid_strip_surface_link;
388 info.is_endcap = element->isEndcap() ? 1u : 0u;
389 // Match StripSpacePointFormationTool::makeStripSpacePoint.
390 info.spacepoint_variance_r = info.is_endcap != 0u ? 5.12f : 0.1f;
391 info.spacepoint_variance_z = info.is_endcap != 0u ? 0.1f : 5.12f;
392 info.barrel_ec = strip_id.barrel_ec(element->identify());
393
394 info.is_annulus = 0u;
395
396 // Preserve the exact frame used by
397 // SolidStateDetectorElementBase::globalPosition(Vector2D).
398 const Amg::Vector3D origin = element->globalPosition(Amg::Vector2D(0., 0.));
399 const Amg::Vector3D eta_axis = element->etaAxis();
400 const Amg::Vector3D phi_axis = element->phiAxis();
401 const Amg::Transform3D& transform = element->transform();
402 const Amg::Vector3D element_center = element->center();
403 info.origin = {origin.x(), origin.y(), origin.z()};
404 info.eta_axis = {eta_axis.x(), eta_axis.y(), eta_axis.z()};
405 info.phi_axis = {phi_axis.x(), phi_axis.y(), phi_axis.z()};
406 info.transform_local_x = {transform(0, 0), transform(1, 0),
407 transform(2, 0)};
408 info.transform_normal = {transform(0, 2), transform(1, 2), transform(2, 2)};
409 info.transform_translation = {transform(0, 3), transform(1, 3),
410 transform(2, 3)};
411 info.element_center = {element_center.x(), element_center.y(),
412 element_center.z()};
413
414 // Barrel strips use straight segments with a length and linear pitch;
415 // endcap strips require the annulus row layout and stereo-frame geometry.
416 if (element->isBarrel()) {
417 const auto* design = dynamic_cast<const InDetDD::SCT_ModuleSideDesign*>(
418 &element->design());
419 if ((design == nullptr) || (design->diodesInRow(0) <= 0)) {
420 throw std::runtime_error("Unsupported strip design for surface " +
421 std::to_string(surface_link));
422 }
423 info.barrel_n_strips = static_cast<unsigned int>(design->diodesInRow(0));
424 info.barrel_n_rows =
425 static_cast<unsigned int>(design->diodes()) / info.barrel_n_strips;
426 info.barrel_pitch = design->stripPitch();
427 info.barrel_row_length =
428 design->length() / static_cast<double>(info.barrel_n_rows);
429 } else {
430 const auto* design =
431 dynamic_cast<const InDetDD::StripStereoAnnulusDesign*>(
432 &element->design());
433 if ((design == nullptr) || (design->diodesInRow(0) <= 0)) {
434 throw std::runtime_error("Unsupported strip design for surface " +
435 std::to_string(surface_link));
436 }
437 // Check the complete supported row layout, but retain only the row-0
438 // parameters used by the existing Traccc endpoint/index convention.
439 const unsigned int total_diodes =
440 static_cast<unsigned int>(design->diodes());
441 unsigned int first_strip = 0u;
442 for (unsigned int row = 0u;
443 (row < max_strip_rows) && (first_strip < total_diodes); ++row) {
444 const unsigned int n_strips =
445 static_cast<unsigned int>(design->diodesInRow(row));
446 if (n_strips == 0u) {
447 break;
448 }
449 if (row == 0u) {
450 info.endcap_n_strips = n_strips;
451 info.endcap_phi_pitch =
452 design->phiPitchPhi(InDetDD::SiCellId(0, row));
453 }
454 first_strip += n_strips;
455 }
456 if (first_strip != total_diodes) {
457 throw std::runtime_error(
458 "Unsupported or incomplete annulus row layout for "
459 "surface " +
460 std::to_string(surface_link) + ": mapped " +
461 std::to_string(first_strip) + " of " +
462 std::to_string(total_diodes) + " strips");
463 }
464 info.min_r = design->minR();
465 info.max_r = design->maxR();
466 const double stereo_angle = design->stereo();
467 const double wafer_center_r = design->waferCentreR();
468 info.endcap_stereo_angle = stereo_angle;
469 info.endcap_wafer_center_r = wafer_center_r;
470 info.endcap_phi_width = design->phiWidth();
471 // Cache the constants used by the Athena strip-frame transformation,
472 // including whether the local coordinates are polar or Cartesian.
473 info.endcap_length_bf =
474 2. * wafer_center_r * std::sin(0.5 * stereo_angle);
475 info.endcap_sin_stereo = std::sin(stereo_angle);
476 info.endcap_cos_stereo = std::cos(stereo_angle);
477 info.endcap_uses_polar_coordinates =
478 design->shape() == InDetDD::PolarAnnulus ? 1u : 0u;
479 // StripSpacePointFormationTool::offset() uses the
480 // Annulus shape specifically, not every end-cap design.
481 info.is_annulus = design->shape() == InDetDD::Annulus ? 1u : 0u;
482 }
483
484 const IdentifierHash module_hash = strip_id.wafer_hash(element->identify());
485 fill_offline_relationships(info, element, module_hash);
486 legacy_infos.push_back(info);
487 }
488
489 // Traccc looks up surfaces by ID. Sorting also permits neighbour lookup
490 // by lower_bound; duplicate IDs would make that lookup ambiguous.
491 std::sort(legacy_infos.begin(), legacy_infos.end(),
492 [](const auto& lhs, const auto& rhs) {
493 return lhs.surface_link < rhs.surface_link;
494 });
495 const auto duplicate =
496 std::adjacent_find(legacy_infos.begin(), legacy_infos.end(),
497 [](const auto& lhs, const auto& rhs) {
498 return lhs.surface_link == rhs.surface_link;
499 });
500 if (duplicate != legacy_infos.end()) {
501 throw std::runtime_error("Duplicate strip surface link in static geometry");
502 }
503
504 // Translate the staging records into Traccc's scalar geometry inputs.
505 // Keep the existing casts and strip-index conventions unchanged.
506 result.surface_infos.reserve(legacy_infos.size());
507 result.pairing_rules.reserve(legacy_infos.size() * 3u);
508 for (const auto& source : legacy_infos) {
509 traccc::strip_measurement_surface_info info{};
510 info.surface_link = source.surface_link;
511 for (std::size_t axis = 0; axis < 3u; ++axis) {
512 info.origin[axis] = static_cast<traccc::scalar>(source.origin[axis]);
513 info.local_u[axis] = static_cast<traccc::scalar>(source.eta_axis[axis]);
514 info.local_v[axis] = static_cast<traccc::scalar>(source.phi_axis[axis]);
515 }
516 info.spacepoint_variance_r = source.spacepoint_variance_r;
517 info.spacepoint_variance_z = source.spacepoint_variance_z;
518 if (source.is_endcap == 0u) {
519 info.geometry_model = traccc::strip_geometry_model::linear;
520 info.linear = {source.barrel_n_rows, source.barrel_n_strips,
521 static_cast<traccc::scalar>(source.barrel_pitch),
522 static_cast<traccc::scalar>(source.barrel_row_length), 0.};
523 // Barrel measurements use local0 and a positive channel direction.
524 info.index_mapping = {
525 0u,
526 source.barrel_n_strips,
527 static_cast<traccc::scalar>(source.barrel_pitch),
528 1.,
529 static_cast<traccc::scalar>(source.barrel_n_strips) * 0.5f,
530 false};
531 } else {
532 // Preserve the validated row-0 getStripEnds convention. Selection
533 // of an additional row/design belongs to this adapter.
534 info.geometry_model = traccc::strip_geometry_model::radial;
535 info.radial = {source.endcap_n_strips,
536 static_cast<traccc::scalar>(source.endcap_phi_pitch),
537 static_cast<traccc::scalar>(source.min_r),
538 static_cast<traccc::scalar>(source.max_r),
539 static_cast<traccc::scalar>(source.endcap_stereo_angle),
540 static_cast<traccc::scalar>(source.endcap_wafer_center_r),
541 static_cast<traccc::scalar>(source.endcap_length_bf),
542 static_cast<traccc::scalar>(source.endcap_sin_stereo),
543 static_cast<traccc::scalar>(source.endcap_cos_stereo),
544 source.endcap_uses_polar_coordinates != 0u
545 ? traccc::strip_local_frame::polar
546 : traccc::strip_local_frame::cartesian};
547 // Endcap measurements use local1 (angle), reverse the strip direction
548 // and apply the CPU row-0 offset. The mapping pitch is phiWidth/count.
549 info.index_mapping = {
550 1u,
551 source.endcap_n_strips,
552 static_cast<traccc::scalar>(
553 source.endcap_phi_width /
554 static_cast<double>(source.endcap_n_strips)),
555 -1.,
556 static_cast<traccc::scalar>(source.endcap_n_strips) * 0.5f - 0.5f,
557 true};
558 }
559 result.surface_infos.push_back(info);
560
561 if (source.is_reference_surface == 0u) {
562 continue;
563 }
564 // Emit at most one directed rule per reference/candidate relationship.
565 // Entry 0 is the standard partner; eta and phi neighbours are overlaps.
566 const std::array<std::uint64_t, 5> links{
567 source.opposite_surface_link, source.eta_minus_surface_link,
568 source.eta_plus_surface_link, source.phi_minus_surface_link,
569 source.phi_plus_surface_link};
570 for (std::size_t i = 0; i < links.size(); ++i) {
571 const auto link = links[i];
572 // Preserve the original first-matching relationship precedence.
573 if (link == traccc::invalid_strip_surface_link ||
574 std::find(links.begin(), links.begin() + i, link) !=
575 links.begin() + i) {
576 continue;
577 }
578 const auto candidate =
579 std::lower_bound(legacy_infos.begin(), legacy_infos.end(), link,
580 [](const auto& item, std::uint64_t value) {
581 return item.surface_link < value;
582 });
583 if (candidate == legacy_infos.end() || candidate->surface_link != link ||
584 candidate->is_endcap != source.is_endcap) {
585 continue;
586 }
587 traccc::strip_pairing_rule rule{};
588 rule.reference_surface_link = source.surface_link;
589 rule.candidate_surface_link = link;
590 rule.category = i == 0u ? traccc::strip_pair_category::standard
591 : traccc::strip_pair_category::overlap;
592 rule.strip_length_gap_tolerance =
593 strip_length_gap_tolerance(source, *candidate);
594 rule.strip_length_tolerance = static_cast<traccc::scalar>(0.01f);
595 // Opposite/eta partners use a coordinate-difference cut. Phi partners
596 // instead require both clusters to lie in their respective edge windows.
597 if (i < 3u) {
598 rule.mode = traccc::strip_pairing_mode::difference;
599 rule.reference_coordinate = rule.candidate_coordinate =
600 source.is_endcap != 0u ? traccc::strip_pairing_coordinate::local1
601 : traccc::strip_pairing_coordinate::local0;
602 rule.difference_scale = candidate->barrel_ec < 0 ? -1.f : 1.f;
603 const traccc::scalar minima[]{source.opposite_min, source.eta_minus_min,
604 source.eta_plus_min};
605 const traccc::scalar maxima[]{source.opposite_max, source.eta_minus_max,
606 source.eta_plus_max};
607 rule.difference_min = minima[i];
608 rule.difference_max = maxima[i];
609 } else {
610 rule.mode = traccc::strip_pairing_mode::windows;
611 rule.reference_coordinate = rule.candidate_coordinate =
612 source.is_endcap != 0u
613 ? traccc::strip_pairing_coordinate::strip_index
614 : traccc::strip_pairing_coordinate::local0;
615 const bool minus = i == 3u;
616 rule.reference_min = minus ? source.phi_minus_reference_min
617 : source.phi_plus_reference_min;
618 rule.reference_max = minus ? source.phi_minus_reference_max
619 : source.phi_plus_reference_max;
620 rule.candidate_min = minus ? source.phi_minus_candidate_min
621 : source.phi_plus_candidate_min;
622 rule.candidate_max = minus ? source.phi_minus_candidate_max
623 : source.phi_plus_candidate_max;
624 }
625 result.pairing_rules.push_back(rule);
626 }
627 }
628 // Group rules by reference/candidate ID for Traccc's surface-pair lookup.
629 std::sort(
630 result.pairing_rules.begin(), result.pairing_rules.end(),
631 [](const auto& a, const auto& b) {
632 return std::tie(a.reference_surface_link, a.candidate_surface_link) <
633 std::tie(b.reference_surface_link, b.candidate_surface_link);
634 });
635 return result;
636}
637
638} // namespace ActsTrk
static Double_t a
This is an Identifier helper class for the SCT subdetector.
Lookup table between the three surface-identifier "worlds" used across the ACTS / Detray / Athena tra...
const_iterator end() const noexcept
Return a const_iterator pointing past the end of the collection.
const_iterator begin() const noexcept
Return a const_iterator pointing at the beginning of the collection.
This is a "hash" representation of an Identifier.
Base class for the SCT module side design, extended by the Forward and Barrel module design.
Identifier for the strip or pixel cell.
Definition SiCellId.h:29
int strip() const
Get strip number. Equivalent to phiIndex().
Definition SiCellId.h:131
bool isValid() const
Test if its in a valid state.
Definition SiCellId.h:136
Class to hold the SiDetectorElement objects to be put in the detector store.
const SiDetectorElement * getDetectorElement(const IdentifierHash &hash) const
Class to hold geometrical description of a silicon detector element.
virtual const SiDetectorDesign & design() const override final
access to the local description (inline):
Class to represent a position in the natural frame of a silicon sensor, for Pixel and SCT For Pixel: ...
SiCellId cellIdOfPosition(const Amg::Vector2D &localPos) const
As in previous method but returns SiCellId.
virtual const Amg::Transform3D & transform() const override final
Return local to global transform.
HepGeom::Point3D< double > globalPosition(const HepGeom::Point3D< double > &localPos) const
transform a reconstruction local position into a global position (inline):
virtual const Amg::Vector3D & center() const override final
Center in global coordinates.
virtual Identifier identify() const override final
identifier of this detector element (inline)
This is an Identifier helper class for the SCT subdetector.
Definition SCT_ID.h:68
IdentifierHash wafer_hash(const Identifier &wafer_id) const
wafer hash from id - optimized
Definition SCT_ID.h:487
int get_prev_in_eta(const IdentifierHash &id, IdentifierHash &prev) const
Previous wafer hash in eta (return == 0 for neighbor found).
Definition SCT_ID.cxx:407
int get_prev_in_phi(const IdentifierHash &id, IdentifierHash &prev) const
Previous wafer hash in phi (return == 0 for neighbor found).
Definition SCT_ID.cxx:387
int barrel_ec(const Identifier &id) const
Values of different levels (failure returns 0).
Definition SCT_ID.h:681
int get_next_in_eta(const IdentifierHash &id, IdentifierHash &next) const
Next wafer hash in eta (return == 0 for neighbor found).
Definition SCT_ID.cxx:417
int get_next_in_phi(const IdentifierHash &id, IdentifierHash &next) const
Next wafer hash in phi (return == 0 for neighbor found).
Definition SCT_ID.cxx:397
int get_other_side(const IdentifierHash &id, IdentifierHash &other) const
Wafer hash on other side.
Definition SCT_ID.cxx:427
The AlignStoreProviderAlg loads the rigid alignment corrections and pipes them through the readout ge...
StripSpacepointInputs makeStripSpacepointInputs(const InDetDD::SiDetectorElementCollection &elements, const SCT_ID &strip_id, const InDet::SiElementPropertiesTable &properties, const GeometryIdMapping &mapping, vecmem::memory_resource &mr)
Interpret Athena designs/topology using the reference CPU pairing cuts.
Eigen::Affine3d Transform3D
Eigen::Matrix< double, 2, 1 > Vector2D
Eigen::Matrix< double, 3, 1 > Vector3D
@ u
Enums for curvilinear frames.
Definition ParamDefs.h:77
void sort(typename DataModel_detail::iterator< DVL > beg, typename DataModel_detail::iterator< DVL > end)
Specialization of sort for DataVector/List.
constexpr double tolerance
Host inputs share the caller's memory resource, which must outlive them.