@@ -999,20 +999,24 @@ struct EventSelectionQaTask {
999999 for (const auto & track : tracks) {
10001000 auto mapAmbTrIdsIt = mapAmbTrIds.find (track.globalIndex ());
10011001 int ambTrId = mapAmbTrIdsIt == mapAmbTrIds.end () ? -1 : mapAmbTrIdsIt->second ;
1002+
1003+ // special check to avoid crashes (in particular, on some MC Pb-Pb datasets)
1004+ // (related to shifts in ambiguous tracks association to bc slices (off by 1) - see https://mattermost.web.cern.ch/alice/pl/g9yaaf3tn3g4pgn7c1yex9copy
1005+ if (ambTrId >= 0 && (ambTracks.iteratorAt (ambTrId).bcIds ()[0 ] >= bcs.size ()))
1006+ continue ;
1007+
10021008 int indexBc = ambTrId < 0 ? track.collision_as <ColEvSels>().bc_as <BCsRun3>().globalIndex () : ambTracks.iteratorAt (ambTrId).bc_as <BCsRun3>().begin ().globalIndex ();
1003- if (ambTrId < 0 ) { // temprorary limitation, to avoid crashes, in particular, on MC Pb-Pb datasets
1004- auto bc = bcs.iteratorAt (indexBc);
1005- int64_t globalBC = bc.globalBC () + floor (track.trackTime () / o2::constants::lhc::LHCBunchSpacingNS);
1009+ auto bc = bcs.iteratorAt (indexBc);
1010+ int64_t globalBC = bc.globalBC () + floor (track.trackTime () / o2::constants::lhc::LHCBunchSpacingNS);
10061011
1007- int32_t indexClosestTVX = findClosest (globalBC, mapGlobalBcWithTVX);
1008- int bcDiff = static_cast <int >(globalBC - vGlobalBCs[indexClosestTVX]);
1009- if (track.hasTOF () || track.hasTRD () || !track.hasITS () || !track.hasTPC () || track.pt () < 1 )
1010- continue ;
1011- histos.fill (HIST (" hTrackBcDiffVsEtaAll" ), track.eta (), bcDiff);
1012- if (track.eta () < -0.2 || track.eta () > 0.2 )
1013- continue ;
1014- histos.fill (HIST (" hSecondsTVXvsBcDifAll" ), bc.timestamp () / 1000 ., bcDiff);
1015- }
1012+ int32_t indexClosestTVX = findClosest (globalBC, mapGlobalBcWithTVX);
1013+ int bcDiff = static_cast <int >(globalBC - vGlobalBCs[indexClosestTVX]);
1014+ if (track.hasTOF () || track.hasTRD () || !track.hasITS () || !track.hasTPC () || track.pt () < 1 )
1015+ continue ;
1016+ histos.fill (HIST (" hTrackBcDiffVsEtaAll" ), track.eta (), bcDiff);
1017+ if (track.eta () < -0.2 || track.eta () > 0.2 )
1018+ continue ;
1019+ histos.fill (HIST (" hSecondsTVXvsBcDifAll" ), bc.timestamp () / 1000 ., bcDiff);
10161020 }
10171021
10181022 // collision-based event selection qa
0 commit comments