@@ -33,62 +33,32 @@ namespace o2::itsmft::tracking
3333
3434#ifndef GPUCA_GPUCODE
3535
36- // Host-only immutable output view around the established clock-layer
37- // implementation. Symmetry, clamping, and ROF lookup stay in LayerTiming .
38- class ClockTimingPublicationView
36+ // Tracks already carry a symmetric timestamp. Apply the publication clock's
37+ // uncertainty limit without modifying the frame-owned track .
38+ inline o2::its::TimeStamp makeOutputTimestamp (o2::its::TimeStamp timestamp, const o2::its::LayerTiming& clock) noexcept
3939{
40- public:
41- explicit ClockTimingPublicationView (const o2::its::LayerTiming& clock) : mClock{clock} {}
42-
43- std::optional<o2::its::TimeStamp> makeOutputTimestamp (const o2::its::TimeStamp& timestamp) const noexcept
44- {
45- if (!std::isfinite (timestamp.getTimeStamp ()) || !std::isfinite (timestamp.getTimeStampError ()) ||
46- timestamp.getTimeStampError () <= 0 .f ) {
47- return std::nullopt ;
48- }
49- auto symmetric = timestamp;
50- const float clamp = mClock .mROFLength * 0 .5f ;
51- if (symmetric.getTimeStampError () > clamp) {
52- symmetric.setTimeStampError (clamp);
53- }
54- return symmetric;
55- }
56-
57- int getROF (const o2::its::TimeStamp& timestamp) const noexcept { return mClock .getROF (timestamp); }
58- uint32_t getROFCount () const noexcept { return mClock .mNROFsTF ; }
59- const o2::its::LayerTiming& getLegacyClockLayer () const noexcept { return mClock ; }
60-
61- private:
62- o2::its::LayerTiming mClock ;
63- };
64-
65- struct TrackPublicationSelection {
66- std::vector<uint32_t > globalIndices;
67- };
68-
69- struct TrackPublicationOrderEntry {
70- uint32_t globalIndex{};
71- o2::its::TimeStamp timestamp{};
72- };
40+ timestamp.setTimeStampError (std::min (timestamp.getTimeStampError (), clock.mROFLength * 0 .5f ));
41+ return timestamp;
42+ }
7343
7444// This context is intentionally source-local. ROFRecord payload is copied
7545// only into the returned publication product, never into TimeFrame.
7646struct TrackPublicationTimingContext {
7747 gsl::span<const o2::itsmft::ROFRecord> inputROFs;
78- ClockTimingPublicationView clock;
48+ o2::its::LayerTiming clock;
7949};
8050
81- inline std::optional<TrackPublicationSelection > selectGenericTracksForSurfaces (
51+ inline std::optional<std::vector< uint32_t > > selectGenericTracksForSurfaces (
8252 const TimeFrame& frame,
8353 gsl::span<const LayerId> sourceSurfaces)
8454{
8555 const auto & tracks = frame.getGenericTracks ();
8656 if (tracks.size () > std::numeric_limits<uint32_t >::max ()) {
8757 return std::nullopt ;
8858 }
89- TrackPublicationSelection selection;
59+ std::vector< uint32_t > selection;
9060 const auto & references = frame.getTrackClusterIndices ();
91- selection.globalIndices . reserve (tracks.size ());
61+ selection.reserve (tracks.size ());
9262 for (uint32_t globalIndex = 0 ; globalIndex < tracks.size (); ++globalIndex) {
9363 const auto & track = tracks[globalIndex];
9464 if (!isValidTrackRange (track, static_cast <uint32_t >(references.size ()))) {
@@ -109,37 +79,39 @@ inline std::optional<TrackPublicationSelection> selectGenericTracksForSurfaces(
10979 return std::nullopt ;
11080 }
11181 if (requested) {
112- selection.globalIndices . push_back (globalIndex);
82+ selection.push_back (globalIndex);
11383 }
11484 }
11585 return selection;
11686}
11787
118- inline std::optional<std::vector<TrackPublicationOrderEntry >> makeLegacyOutputOrder (
119- const TimeFrame& frame, const TrackPublicationSelection& selection,
120- const ClockTimingPublicationView & clock)
88+ inline std::optional<std::vector<uint32_t >> makeLegacyOutputOrder (
89+ const TimeFrame& frame, std::vector< uint32_t > selection,
90+ const o2::its::LayerTiming & clock)
12191{
122- std::vector<TrackPublicationOrderEntry> ordered ;
123- ordered. reserve ( selection. globalIndices . size ());
124- for ( const auto index : selection. globalIndices ) {
125- const auto timestamp = clock. makeOutputTimestamp (frame. getGenericTracks ()[index]. timestamp );
126- if (! timestamp) {
92+ const auto & tracks = frame. getGenericTracks () ;
93+ for ( const auto index : selection) {
94+ const auto & timestamp = tracks[index]. timestamp ;
95+ if (! std::isfinite ( timestamp. getTimeStamp ()) || ! std::isfinite (timestamp. getTimeStampError ()) ||
96+ timestamp. getTimeStampError () <= 0 . f ) {
12797 return std::nullopt ;
12898 }
129- ordered.push_back ({index, *timestamp});
13099 }
100+ // Sort only indices, using the same clamped timestamp that will be published.
131101 // Match Tracker::sortTracks(): lower timestamp edge, then chi2.
132- std::sort (ordered.begin (), ordered.end (), [&frame](const auto & left, const auto & right) {
133- const auto & leftTrack = frame.getGenericTracks ()[left.globalIndex ];
134- const auto & rightTrack = frame.getGenericTracks ()[right.globalIndex ];
135- const auto leftLower = left.timestamp .getTimeStamp () - left.timestamp .getTimeStampError ();
136- const auto rightLower = right.timestamp .getTimeStamp () - right.timestamp .getTimeStampError ();
102+ std::sort (selection.begin (), selection.end (), [&](uint32_t left, uint32_t right) {
103+ const auto & leftTrack = tracks[left];
104+ const auto & rightTrack = tracks[right];
105+ const auto leftTime = makeOutputTimestamp (leftTrack.timestamp , clock);
106+ const auto rightTime = makeOutputTimestamp (rightTrack.timestamp , clock);
107+ const auto leftLower = leftTime.getTimeStamp () - leftTime.getTimeStampError ();
108+ const auto rightLower = rightTime.getTimeStamp () - rightTime.getTimeStampError ();
137109 if (leftLower != rightLower) {
138110 return leftLower < rightLower;
139111 }
140112 return leftTrack.chi2 < rightTrack.chi2 ;
141113 });
142- return ordered ;
114+ return selection ;
143115}
144116
145117inline void finalizeROFs (std::vector<o2::itsmft::ROFRecord>& rofs, const std::vector<o2::its::TimeStamp>& times,
0 commit comments