Skip to content

Commit ebfff6d

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 c8c6eb7 commit ebfff6d

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
@@ -3485,8 +3485,23 @@ struct AnalysisAsymmetricPairing {
34853485

34863486
int sign1 = 0;
34873487
int sign2 = 0;
3488-
ditrackList.reserve(assocs.size());
3489-
ditrackExtraList.reserve(assocs.size());
3488+
3489+
//Reserve capacity for the output tables
3490+
int64_t reserveSize = 0;
3491+
for (auto const& event : events) {
3492+
if (!event.isEventSelected_bit(0)) {
3493+
continue;
3494+
}
3495+
if (fConfigRemoveCollSplittingCandidates.value && event.isEventSelected_bit(2)) {
3496+
continue;
3497+
}
3498+
auto groupedLegAAssocs = legACandidateAssocs.sliceBy(preslice, event.globalIndex());
3499+
auto groupedLegBAssocs = legBCandidateAssocs.sliceBy(preslice, event.globalIndex());
3500+
reserveSize += static_cast<int64_t>(groupedLegAAssocs.size()) *
3501+
static_cast<int64_t>(groupedLegBAssocs.size());
3502+
}
3503+
ditrackList.reserve(reserveSize);
3504+
ditrackExtraList.reserve(reserveSize);
34903505

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

0 commit comments

Comments
 (0)