diff --git a/DPG/Tasks/TPC/tpcSkimsTableCreator.cxx b/DPG/Tasks/TPC/tpcSkimsTableCreator.cxx index 7bc4d190d6e..86513df7feb 100644 --- a/DPG/Tasks/TPC/tpcSkimsTableCreator.cxx +++ b/DPG/Tasks/TPC/tpcSkimsTableCreator.cxx @@ -42,6 +42,8 @@ #include #include #include +#include +#include #include #include #include @@ -103,12 +105,18 @@ struct TreeWriterTpcV0 { Configurable maxPt4dwnsmplTsalisProtons{"maxPt4dwnsmplTsalisProtons", 100., "Maximum Pt for applying downsampling factor of protons"}; Configurable maxPt4dwnsmplTsalisElectrons{"maxPt4dwnsmplTsalisElectrons", 100., "Maximum Pt for applying downsampling factor of electrons"}; Configurable maxPt4dwnsmplTsalisKaons{"maxPt4dwnsmplTsalisKaons", 100., "Maximum Pt for applying downsampling factor of kaons"}; + // Configurables for output tables reservation size + Configurable reserveV0Ratio{"reserveV0Ratio", 0.05, "Ratio of how many tracks from V0s are expected in the output table to the input V0 table size"}; + Configurable reserveCascRatio{"reserveCascRatio", 0.0025, "Ratio of how many tracks from cascades are expected in the output table to the input Cascade table size"}; + Configurable saveReserveQaHisto{"saveReserveQaHisto", true, "Flag to save the DF-wise ratio of output table size to that of input table"}; // Configurables for run condtion table Configurable rctLabel{"rctLabel", "CBT_hadronPID", "select 1 [CBT, CBT_hadronPID, CBT_muon_glo] see O2Physics/Common/CCDB/RCTSelectionFlags.h"}; Configurable checkZdc{"checkZdc", false, "set ZDC flag for PbPb"}; Configurable treatLimitedAcceptanceAsBad{"treatLimitedAcceptanceAsBad", false, "reject all events where the detectors relevant for the specified Runlist are flagged as LimitedAcceptance"}; Configurable requireGoodRct{"requireGoodRct", false, "require good detector flag in run condtion table"}; + HistogramRegistry registry{"registry", {}}; + // an arbitrary value of N sigma TOF assigned by TOF task to tracks which are not matched to TOF hits constexpr static float NSigmaTofUnmatched{o2::aod::v0data::kNoTOFValue}; const float nSigmaTofUnmatchedEqualityTolerance{std::fabs(NSigmaTofUnmatched) / 1e4f}; @@ -182,6 +190,11 @@ struct TreeWriterTpcV0 { ccdb->setFatalWhenNull(false); rctChecker.init(rctLabel, checkZdc, treatLimitedAcceptanceAsBad); + + if (saveReserveQaHisto) { + registry.add("hV0OutputRatio", "V0 out/in ratio;V0 out/in ratio;Entries", {HistType::kTH1F, {{100, 0, reserveV0Ratio}}}); + registry.add("hCascOutputRatio", "Casc out/in ratio;Casc out/in ratio;Entries", {HistType::kTH1F, {{100, 0, reserveCascRatio}}}); + } } template @@ -422,6 +435,16 @@ struct TreeWriterTpcV0 { aod::pidits::ITSNSigmaEl, aod::pidits::ITSNSigmaPi, aod::pidits::ITSNSigmaKa, aod::pidits::ITSNSigmaPr>(myTracks); + int nV0Entries{0}; + int nCascEntries{0}; + + const int64_t expectedOutputTableSize = static_cast(reserveV0Ratio * myV0s.size() + reserveCascRatio * myCascs.size()); + if constexpr (ModeId == ModeWithdEdxTrkQA || ModeId == ModeStandard) { + rowTPCTree.reserve(expectedOutputTableSize); + } else { + rowTPCTreeWithTrkQA.reserve(expectedOutputTableSize); + } + for (const auto& collision : collisions) { if (!isEventSelected(collision, applyEvSel)) { continue; @@ -441,11 +464,9 @@ struct TreeWriterTpcV0 { if constexpr (ModeId == ModeWithdEdxTrkQA || ModeId == ModeStandard) { bcTimeFrameId = UndefValueInt; bcBcInTimeFrame = UndefValueInt; - rowTPCTree.reserve(2 * v0s.size() + cascs.size()); } else if constexpr (ModeId == ModeWithTrkQA) { bcTimeFrameId = bc.tfId(); bcBcInTimeFrame = bc.bcInTF(); - rowTPCTreeWithTrkQA.reserve(2 * v0s.size() + cascs.size()); } auto getTrackQA = [&](const TrksType::iterator& track) { @@ -481,7 +502,9 @@ struct TreeWriterTpcV0 { evaluateOccupancyVariables(dauTrack, occValues); } fillSkimmedV0Table(mother, dauTrack, trackQAInstance, existTrkQA, collision, daughter.tpcNSigma, daughter.tofNSigma, daughter.itsNSigma, daughter.tpcExpSignal, daughter.id, runnumber, daughter.dwnSmplFactor, hadronicRate, bcGlobalIndex, bcTimeFrameId, bcBcInTimeFrame, occValues, isGoodRctEvent); + return true; } + return false; }; /// Loop over v0 candidates @@ -493,8 +516,12 @@ struct TreeWriterTpcV0 { const auto posTrack = v0.posTrack_as(); const auto negTrack = v0.negTrack_as(); - fillDaughterTrack(v0, posTrack, v0, true); - fillDaughterTrack(v0, negTrack, v0, false); + if (fillDaughterTrack(v0, posTrack, v0, true)) { + ++nV0Entries; + } + if (fillDaughterTrack(v0, negTrack, v0, false)) { + ++nV0Entries; + } } /// Loop over cascade candidates @@ -506,9 +533,23 @@ struct TreeWriterTpcV0 { const auto bachTrack = casc.bachelor_as(); // Omega and antiomega const auto isDaughterPositive = cascId == MotherAntiOmega ? true : false; - fillDaughterTrack(casc, bachTrack, casc, isDaughterPositive); + if (fillDaughterTrack(casc, bachTrack, casc, isDaughterPositive)) { + ++nCascEntries; + } } } + LOG(info) << "runV0() summary:"; + LOG(info) << "V0 table size = " << myV0s.size(); + LOG(info) << "Cascade table size = " << myCascs.size(); + LOG(info) << "nV0Entries = " << nV0Entries; + LOG(info) << "nCascEntries = " << nCascEntries; + LOG(info) << "nV0Entries / V0 table size = " << static_cast(nV0Entries) / myV0s.size(); + LOG(info) << "nCascEntries / Cascade table size = " << static_cast(nCascEntries) / myCascs.size(); + + if (saveReserveQaHisto) { + registry.fill(HIST("hV0OutputRatio"), static_cast(nV0Entries) / myV0s.size()); + registry.fill(HIST("hCascOutputRatio"), static_cast(nCascEntries) / myCascs.size()); + } } /// runV0 void processStandard(Colls const& collisions, @@ -632,12 +673,17 @@ struct TreeWriterTpcTof { Configurable downsamplingTsalisProtons{"downsamplingTsalisProtons", -1., "Downsampling factor to reduce the number of protons"}; Configurable downsamplingTsalisKaons{"downsamplingTsalisKaons", -1., "Downsampling factor to reduce the number of kaons"}; Configurable downsamplingTsalisPions{"downsamplingTsalisPions", -1., "Downsampling factor to reduce the number of pions"}; + // Configurable for output table reservation size + Configurable reserveTrackRatio{"reserveTrackRatio", 0.003, "Ratio of how many tracks are expected in the output table to the input Tracks table size"}; + Configurable saveReserveQaHisto{"saveReserveQaHisto", true, "Flag to save the DF-wise ratio of output table size to that of input table"}; // Configurables for run condtion table Configurable rctLabel{"rctLabel", "CBT_hadronPID", "select 1 [CBT, CBT_hadronPID, CBT_muon_glo] see O2Physics/Common/CCDB/RCTSelectionFlags.h"}; Configurable checkZdc{"checkZdc", false, "set ZDC flag for PbPb"}; Configurable treatLimitedAcceptanceAsBad{"treatLimitedAcceptanceAsBad", false, "reject all events where the detectors relevant for the specified Runlist are flagged as LimitedAcceptance"}; Configurable requireGoodRct{"requireGoodRct", false, "require good detector flag in run condtion table"}; + HistogramRegistry registry{"registry", {}}; + struct TofTrack { bool isApplyHardCutOnly; double maxMomHardCutOnly; @@ -692,6 +738,10 @@ struct TreeWriterTpcTof { ccdb->setFatalWhenNull(false); rctChecker.init(rctLabel, checkZdc, treatLimitedAcceptanceAsBad); + + if (saveReserveQaHisto) { + registry.add("hTrackOutputRatio", "Track out/in ratio;Track out/in ratio;Entries", {HistType::kTH1F, {{100, 0, reserveTrackRatio}}}); + } } template @@ -803,6 +853,14 @@ struct TreeWriterTpcTof { labelTrack2TrackQA.at(trackId) = trackQA.globalIndex(); } } + + const int64_t expectedOutputTableSize = static_cast(reserveTrackRatio * myTracks.size()); + if constexpr (ModeId == ModeWithdEdxTrkQA || ModeId == ModeStandard) { + rowTPCTOFTree.reserve(expectedOutputTableSize); + } else { + rowTPCTOFTreeWithTrkQA.reserve(expectedOutputTableSize); + } + for (const auto& collision : collisions) { const auto tracks = myTracks.sliceBy(perCollisionTracksType, collision.globalIndex()); if (!isEventSelected(collision, applyEvSel)) { @@ -829,11 +887,9 @@ struct TreeWriterTpcTof { if constexpr (ModeId == ModeStandard || ModeId == ModeWithdEdxTrkQA) { bcTimeFrameId = UndefValueInt; bcBcInTimeFrame = UndefValueInt; - rowTPCTOFTree.reserve(tracks.size()); } else { bcTimeFrameId = bc.tfId(); bcBcInTimeFrame = bc.bcInTF(); - rowTPCTOFTreeWithTrkQA.reserve(tracks.size()); } for (auto const& trk : tracksWithITSPid) { if (!isTrackSelected(trk, trackSelection)) { @@ -875,6 +931,14 @@ struct TreeWriterTpcTof { } } /// Loop tracks } + LOG(info) << "runTof() summary:"; + LOG(info) << "Track table size = " << myTracks.size(); + LOG(info) << "nTrackEntries = " << rowTPCTOFTree.lastIndex() + 1; + LOG(info) << "nTrackEntries / Track table size = " << static_cast((rowTPCTOFTree.lastIndex() + 1)) / myTracks.size(); + + if (saveReserveQaHisto) { + registry.fill(HIST("hTrackOutputRatio"), static_cast((rowTPCTOFTree.lastIndex() + 1)) / myTracks.size()); + } } /// runTof void processStandard(Colls const& collisions,