Skip to content

Commit 14f1e4e

Browse files
authored
[Common] Add protection for malformed ambiguous track table entries in AO2Ds (#13794)
1 parent dd749bb commit 14f1e4e

File tree

1 file changed

+9
-3
lines changed

1 file changed

+9
-3
lines changed

Common/Core/CollisionAssociation.h

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,8 @@ class CollisionAssociation
8080
switch (mTrackSelection) {
8181
case o2::aod::track_association::TrackSelection::CentralBarrelRun2: {
8282
unsigned char itsClusterMap = track.itsClusterMap();
83-
if (!(track.tpcNClsFound() >= 50 && track.flags() & o2::aod::track::ITSrefit && track.flags() & o2::aod::track::TPCrefit && (TESTBIT(itsClusterMap, 0) || TESTBIT(itsClusterMap, 1)))) {
83+
int minTpcNClsFound{50};
84+
if (!(track.tpcNClsFound() >= minTpcNClsFound && track.flags() & o2::aod::track::ITSrefit && track.flags() & o2::aod::track::TPCrefit && (TESTBIT(itsClusterMap, 0) || TESTBIT(itsClusterMap, 1)))) {
8485
hasGoodQuality = false;
8586
}
8687
break;
@@ -127,7 +128,7 @@ class CollisionAssociation
127128
TTracksUnfiltered const& tracksUnfiltered,
128129
TTracks const& tracks,
129130
TAmbiTracks const& ambiguousTracks,
130-
o2::aod::BCs const&,
131+
o2::aod::BCs const& bcs,
131132
Assoc& association,
132133
RevIndices& reverseIndices)
133134
{
@@ -151,6 +152,11 @@ class CollisionAssociation
151152
for (const auto& ambTrack : ambiguousTracks) {
152153
if constexpr (isCentralBarrel) { // FIXME: to be removed as soon as it is possible to use getId<Table>() for joined tables
153154
if (ambTrack.trackId() == track.globalIndex()) {
155+
// special check to avoid crashes (in particular on some MC datasets)
156+
// related to shifts in ambiguous tracks association to bc slices (off by 1) - see https://mattermost.web.cern.ch/alice/pl/g9yaaf3tn3g4pgn7c1yex9copy
157+
if (ambTrack.bcIds()[0] >= bcs.size() || ambTrack.bcIds()[1] >= bcs.size()) {
158+
break;
159+
}
154160
if (!ambTrack.has_bc() || ambTrack.bc().size() == 0) {
155161
break;
156162
}
@@ -194,7 +200,7 @@ class CollisionAssociation
194200
uint64_t collBC = collision.bc().globalBC();
195201

196202
// This is done per block to allow optimization below. Within each block the globalBC increase continously
197-
for (auto& iterationWindow : trackIterationWindows) {
203+
for (auto& iterationWindow : trackIterationWindows) { // o2-linter: disable=const-ref-in-for-loop (iterationWindow is modified)
198204
bool iteratorMoved = false;
199205
const bool isAssignedTrackWindow = (iterationWindow.first != iterationWindow.second) ? iterationWindow.first.has_collision() : false;
200206
for (auto trackInWindow = iterationWindow.first; trackInWindow != iterationWindow.second; ++trackInWindow) {

0 commit comments

Comments
 (0)