Skip to content

Commit 527055a

Browse files
committed
reserve tables sizes in a smart way
1 parent 40f22ce commit 527055a

1 file changed

Lines changed: 20 additions & 4 deletions

File tree

DPG/Tasks/TPC/tpcSkimsTableCreator.cxx

Lines changed: 20 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -103,6 +103,9 @@ struct TreeWriterTpcV0 {
103103
Configurable<float> maxPt4dwnsmplTsalisProtons{"maxPt4dwnsmplTsalisProtons", 100., "Maximum Pt for applying downsampling factor of protons"};
104104
Configurable<float> maxPt4dwnsmplTsalisElectrons{"maxPt4dwnsmplTsalisElectrons", 100., "Maximum Pt for applying downsampling factor of electrons"};
105105
Configurable<float> maxPt4dwnsmplTsalisKaons{"maxPt4dwnsmplTsalisKaons", 100., "Maximum Pt for applying downsampling factor of kaons"};
106+
// Configurables for output tables reservation size
107+
Configurable<float> reserveV0Ratio{"reserveV0Ratio", 0.06, "Ratio of how many tracks from V0s are expected in the output table to the input V0 table size"};
108+
Configurable<float> reserveCascRatio{"reserveCascRatio", 0.003, "Ratio of how many tracks from cascades are expected in the output table to the input Cascade table size"};
106109
// Configurables for run condtion table
107110
Configurable<std::string> rctLabel{"rctLabel", "CBT_hadronPID", "select 1 [CBT, CBT_hadronPID, CBT_muon_glo] see O2Physics/Common/CCDB/RCTSelectionFlags.h"};
108111
Configurable<bool> checkZdc{"checkZdc", false, "set ZDC flag for PbPb"};
@@ -425,6 +428,13 @@ struct TreeWriterTpcV0 {
425428
int nV0Entries{0};
426429
int nCascEntries{0};
427430

431+
const int64_t expectedOutputTableSize = static_cast<int64_t>(reserveV0Ratio * myV0s.size() + reserveCascRatio * myCascs.size());
432+
if constexpr (ModeId == ModeWithdEdxTrkQA || ModeId == ModeStandard) {
433+
rowTPCTree.reserve(expectedOutputTableSize);
434+
} else {
435+
rowTPCTreeWithTrkQA.reserve(expectedOutputTableSize);
436+
}
437+
428438
for (const auto& collision : collisions) {
429439
if (!isEventSelected(collision, applyEvSel)) {
430440
continue;
@@ -444,11 +454,9 @@ struct TreeWriterTpcV0 {
444454
if constexpr (ModeId == ModeWithdEdxTrkQA || ModeId == ModeStandard) {
445455
bcTimeFrameId = UndefValueInt;
446456
bcBcInTimeFrame = UndefValueInt;
447-
rowTPCTree.reserve(2 * v0s.size() + cascs.size());
448457
} else if constexpr (ModeId == ModeWithTrkQA) {
449458
bcTimeFrameId = bc.tfId();
450459
bcBcInTimeFrame = bc.bcInTF();
451-
rowTPCTreeWithTrkQA.reserve(2 * v0s.size() + cascs.size());
452460
}
453461

454462
auto getTrackQA = [&](const TrksType::iterator& track) {
@@ -650,6 +658,8 @@ struct TreeWriterTpcTof {
650658
Configurable<float> downsamplingTsalisProtons{"downsamplingTsalisProtons", -1., "Downsampling factor to reduce the number of protons"};
651659
Configurable<float> downsamplingTsalisKaons{"downsamplingTsalisKaons", -1., "Downsampling factor to reduce the number of kaons"};
652660
Configurable<float> downsamplingTsalisPions{"downsamplingTsalisPions", -1., "Downsampling factor to reduce the number of pions"};
661+
// Configurable for output table reservation size
662+
Configurable<float> reserveTrackRatio{"reserveTrackRatio", 0.005, "Ratio of how many tracks are expected in the output table to the input Tracks table size"};
653663
// Configurables for run condtion table
654664
Configurable<std::string> rctLabel{"rctLabel", "CBT_hadronPID", "select 1 [CBT, CBT_hadronPID, CBT_muon_glo] see O2Physics/Common/CCDB/RCTSelectionFlags.h"};
655665
Configurable<bool> checkZdc{"checkZdc", false, "set ZDC flag for PbPb"};
@@ -821,6 +831,14 @@ struct TreeWriterTpcTof {
821831
labelTrack2TrackQA.at(trackId) = trackQA.globalIndex();
822832
}
823833
}
834+
835+
const int64_t expectedOutputTableSize = static_cast<int64_t>(reserveTrackRatio * myTracks.size());
836+
if constexpr (ModeId == ModeWithdEdxTrkQA || ModeId == ModeStandard) {
837+
rowTPCTOFTree.reserve(expectedOutputTableSize);
838+
} else {
839+
rowTPCTOFTreeWithTrkQA.reserve(expectedOutputTableSize);
840+
}
841+
824842
for (const auto& collision : collisions) {
825843
const auto tracks = myTracks.sliceBy(perCollisionTracksType, collision.globalIndex());
826844
if (!isEventSelected(collision, applyEvSel)) {
@@ -847,11 +865,9 @@ struct TreeWriterTpcTof {
847865
if constexpr (ModeId == ModeStandard || ModeId == ModeWithdEdxTrkQA) {
848866
bcTimeFrameId = UndefValueInt;
849867
bcBcInTimeFrame = UndefValueInt;
850-
rowTPCTOFTree.reserve(tracks.size());
851868
} else {
852869
bcTimeFrameId = bc.tfId();
853870
bcBcInTimeFrame = bc.bcInTF();
854-
rowTPCTOFTreeWithTrkQA.reserve(tracks.size());
855871
}
856872
for (auto const& trk : tracksWithITSPid) {
857873
if (!isTrackSelected(trk, trackSelection)) {

0 commit comments

Comments
 (0)