@@ -1794,19 +1794,23 @@ struct AnalysisSameEventPairing {
17941794 uint32_t dileptonMcDecision = static_cast <uint32_t >(0 ); // placeholder, copy of the dqEfficiency.cxx one
17951795 int sign1 = 0 ;
17961796 int sign2 = 0 ;
1797- dielectronList.reserve (1 );
1798- dimuonList.reserve (1 );
1799- dielectronsExtraList.reserve (1 );
1800- dielectronInfoList.reserve (1 );
1801- dimuonsExtraList.reserve (1 );
1802- dileptonInfoList.reserve (1 );
1803- dileptonFlowList.reserve (1 );
1797+ // Reserve capacity for the output tables to avoid repeated reallocations
1798+ // inside the Arrow builders. Unused capacity is virtual address space
1799+ // only — pages are not faulted in until written.
1800+ auto nAssocs = assocs.size ();
1801+ dielectronList.reserve (nAssocs);
1802+ dimuonList.reserve (nAssocs);
1803+ dielectronsExtraList.reserve (nAssocs);
1804+ dielectronInfoList.reserve (nAssocs);
1805+ dimuonsExtraList.reserve (nAssocs);
1806+ dileptonInfoList.reserve (nAssocs);
1807+ dileptonFlowList.reserve (nAssocs);
18041808 if (fConfigOptions .flatTables .value ) {
1805- dielectronAllList.reserve (1 );
1806- dimuonAllList.reserve (1 );
1809+ dielectronAllList.reserve (nAssocs );
1810+ dimuonAllList.reserve (nAssocs );
18071811 }
18081812 if (fConfigOptions .polarTables .value ) {
1809- dileptonPolarList.reserve (1 );
1813+ dileptonPolarList.reserve (nAssocs );
18101814 }
18111815 fAmbiguousPairs .clear ();
18121816 constexpr bool eventHasQvector = ((TEventFillMap & VarManager::ObjTypes::ReducedEventQvector) > 0 );
@@ -2388,7 +2392,7 @@ struct AnalysisSameEventPairing {
23882392 const auto & histNames = fTrackMuonHistNames ;
23892393 int nPairCuts = (fPairCuts .size () > 0 ) ? fPairCuts .size () : 1 ;
23902394
2391- electronmuonList.reserve (1 );
2395+ electronmuonList.reserve (assocs1. size () );
23922396
23932397 uint32_t twoTrackFilter = 0 ;
23942398 int sign1 = 0 ;
@@ -3085,7 +3089,7 @@ struct AnalysisAsymmetricPairing {
30853089
30863090 // Template function to run same event pairing with asymmetric pairs (e.g. kaon-pion)
30873091 template <bool TTwoProngFitter, int TPairType, uint32_t TEventFillMap, uint32_t TTrackFillMap, typename TEvents, typename TTrackAssocs, typename TTracks>
3088- void runAsymmetricPairing (TEvents const & events, Preslice<TTrackAssocs>& preslice, TTrackAssocs const & /* assocs*/ , TTracks const & /* tracks*/ )
3092+ void runAsymmetricPairing (TEvents const & events, Preslice<TTrackAssocs>& preslice, TTrackAssocs const & assocs, TTracks const & /* tracks*/ )
30893093 {
30903094 fPairCount .clear ();
30913095
@@ -3098,8 +3102,8 @@ struct AnalysisAsymmetricPairing {
30983102
30993103 int sign1 = 0 ;
31003104 int sign2 = 0 ;
3101- ditrackList.reserve (1 );
3102- ditrackExtraList.reserve (1 );
3105+ ditrackList.reserve (assocs. size () );
3106+ ditrackExtraList.reserve (assocs. size () );
31033107
31043108 constexpr bool trackHasCov = ((TTrackFillMap & VarManager::ObjTypes::TrackCov) > 0 || (TTrackFillMap & VarManager::ObjTypes::ReducedTrackBarrelCov) > 0 );
31053109
0 commit comments