diff --git a/PWGDQ/Tasks/dqEfficiency_withAssoc.cxx b/PWGDQ/Tasks/dqEfficiency_withAssoc.cxx index 176d7ce64b2..089292b608e 100644 --- a/PWGDQ/Tasks/dqEfficiency_withAssoc.cxx +++ b/PWGDQ/Tasks/dqEfficiency_withAssoc.cxx @@ -3818,8 +3818,28 @@ struct AnalysisAsymmetricPairing { int sign1 = 0; int sign2 = 0; uint32_t mcDecision = 0; - ditrackList.reserve(1); - ditrackExtraList.reserve(1); + + // estimate reserved size + int64_t reserveSize = 0; + for (auto const& event : events) { + auto groupedLegAAssocs = legACandidateAssocs.sliceBy(preslice, event.globalIndex()); + auto groupedLegBAssocs = legBCandidateAssocs.sliceBy(preslice, event.globalIndex()); + size_t nGoodA = 0; + size_t nGoodB = 0; + for (auto const& t : groupedLegAAssocs) { + if (t.isBarrelSelected_raw()) { + nGoodA++; + } + } + for (auto const& t : groupedLegBAssocs) { + if (t.isBarrelSelected_raw()) { + nGoodB++; + } + } + reserveSize += nGoodA * nGoodB; + } + ditrackList.reserve(reserveSize); + ditrackExtraList.reserve(reserveSize); constexpr bool trackHasCov = ((TTrackFillMap & VarManager::ObjTypes::TrackCov) > 0 || (TTrackFillMap & VarManager::ObjTypes::ReducedTrackBarrelCov) > 0); diff --git a/PWGDQ/Tasks/tableReader_withAssoc.h b/PWGDQ/Tasks/tableReader_withAssoc.h index 88bdbc0fd67..105a6527aba 100644 --- a/PWGDQ/Tasks/tableReader_withAssoc.h +++ b/PWGDQ/Tasks/tableReader_withAssoc.h @@ -3574,16 +3574,21 @@ struct AnalysisAsymmetricPairing { // Reserve capacity for the output tables int64_t reserveSize = 0; for (auto const& event : events) { - if (!event.isEventSelected_bit(0)) { - continue; - } - if (fConfigRemoveCollSplittingCandidates.value && event.isEventSelected_bit(2)) { - continue; - } auto groupedLegAAssocs = legACandidateAssocs.sliceBy(preslice, event.globalIndex()); auto groupedLegBAssocs = legBCandidateAssocs.sliceBy(preslice, event.globalIndex()); - reserveSize += static_cast(groupedLegAAssocs.size()) * - static_cast(groupedLegBAssocs.size()); + size_t nGoodA = 0; + size_t nGoodB = 0; + for (auto const& t : groupedLegAAssocs) { + if (t.isBarrelSelected_raw()) { + nGoodA++; + } + } + for (auto const& t : groupedLegBAssocs) { + if (t.isBarrelSelected_raw()) { + nGoodB++; + } + } + reserveSize += nGoodA * nGoodB; } ditrackList.reserve(reserveSize); ditrackExtraList.reserve(reserveSize);