Skip to content

Commit 3e06d51

Browse files
author
Jifeng Deng
committed
Fix the reserve size problem in asymmetric pairing of tableReader_withAssoc
In the original code, ditrack table reserves based on the number of tracks rather than on the number of pairs, which may cause the crash of the program. Adapt the similar strategy as what has been done in same event pairing to fix the problem.
1 parent ec2c083 commit 3e06d51

1 file changed

Lines changed: 17 additions & 2 deletions

File tree

PWGDQ/Tasks/tableReader_withAssoc.cxx

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3471,8 +3471,23 @@ struct AnalysisAsymmetricPairing {
34713471

34723472
int sign1 = 0;
34733473
int sign2 = 0;
3474-
ditrackList.reserve(assocs.size());
3475-
ditrackExtraList.reserve(assocs.size());
3474+
3475+
//Reserve capacity for the output tables
3476+
int64_t reserveSize = 0;
3477+
for (auto const& event : events) {
3478+
if (!event.isEventSelected_bit(0)) {
3479+
continue;
3480+
}
3481+
if (fConfigRemoveCollSplittingCandidates.value && event.isEventSelected_bit(2)) {
3482+
continue;
3483+
}
3484+
auto groupedLegAAssocs = legACandidateAssocs.sliceBy(preslice, event.globalIndex());
3485+
auto groupedLegBAssocs = legBCandidateAssocs.sliceBy(preslice, event.globalIndex());
3486+
reserveSize += static_cast<int64_t>(groupedLegAAssocs.size()) *
3487+
static_cast<int64_t>(groupedLegBAssocs.size());
3488+
}
3489+
ditrackList.reserve(reserveSize);
3490+
ditrackExtraList.reserve(reserveSize);
34763491

34773492
constexpr bool trackHasCov = ((TTrackFillMap & VarManager::ObjTypes::TrackCov) > 0 || (TTrackFillMap & VarManager::ObjTypes::ReducedTrackBarrelCov) > 0);
34783493

0 commit comments

Comments
 (0)