From 5bcf7e7741d72848ff6f338b972bd7e3e6daee84 Mon Sep 17 00:00:00 2001 From: nivram-phy Date: Tue, 24 Nov 2026 12:46:41 +0100 Subject: [PATCH 1/7] Add UPC mode filter for QA matching AO2D output --- PWGDQ/Tasks/qaMatching.cxx | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) diff --git a/PWGDQ/Tasks/qaMatching.cxx b/PWGDQ/Tasks/qaMatching.cxx index 92ae33ab386..b191f36f492 100644 --- a/PWGDQ/Tasks/qaMatching.cxx +++ b/PWGDQ/Tasks/qaMatching.cxx @@ -381,6 +381,7 @@ struct QaMatching { Configurable cfgMftTrackMultiplicityMax{"cfgMftTrackMultiplicityMax", 1000, "Maximum number of MFT tracks per collision"}; Configurable cfgQaMatchingAodDebug{"cfgQaMatchingAodDebug", 0, "If >0, print AO2D filling debug (0=off, N=max collisions)"}; + Configurable cfgUPCMode{"cfgUPCMode", -1, "UPC mode for AO2D output (-1=all, 0=non-UPC, 1=UPC)"}; double mBzAtMftCenter{0}; @@ -1311,6 +1312,10 @@ struct QaMatching { void init(o2::framework::InitContext&) { + if (cfgUPCMode < -1 || cfgUPCMode > 1) { + LOGF(warning, "Invalid cfgUPCMode=%d. Treating it as -1 and writing AO2D output for all UPC modes.", static_cast(cfgUPCMode)); + } + // Load geometry ccdbManager->setURL(ccdbUrl); ccdbManager->setCaching(true); @@ -3624,6 +3629,17 @@ struct QaMatching { } } + template + bool shouldWriteQaMatchingAod(TCOLLISION const& collision) const + { + if (cfgUPCMode != 0 && cfgUPCMode != 1) { + return true; + } + + const bool upcMode = (collision.flags() & o2::dataformats::Vertex>::Flags::UPCMode) != 0; + return static_cast(upcMode) == cfgUPCMode; + } + template void fillQaMatchingAodTablesForCollision(TCOLLISION const& collision, TMUON const& muonTracks, @@ -3634,6 +3650,10 @@ struct QaMatching { std::map reducedMchTrackIds, CMFT const& mftCovs) { + if (!shouldWriteQaMatchingAod(collision)) { + return; + } + for (const auto& [mchIndex, candidates] : matchingCandidates) { if (candidates.empty()) { continue; @@ -3693,6 +3713,10 @@ struct QaMatching { int32_t reducedEventId, int& debugCounter) { + if (!shouldWriteQaMatchingAod(collision)) { + return; + } + const bool upcMode = (collision.flags() & o2::dataformats::Vertex>::Flags::UPCMode) != 0; int32_t mftMultiplicity = static_cast(collisionInfo.mftTracks.size()); qaMatchingEvents( @@ -3715,6 +3739,10 @@ struct QaMatching { int32_t reducedEventId, const std::map& reducedMchTrackIds) { + if (!shouldWriteQaMatchingAod(collision)) { + return; + } + std::vector> orderedMchIds; orderedMchIds.reserve(reducedMchTrackIds.size()); for (const auto& [mchIndex, reducedMchTrackId] : reducedMchTrackIds) { From 1f122d5f64012b821888974bfcb60fef432a0b83 Mon Sep 17 00:00:00 2001 From: nivram-phy Date: Tue, 24 Nov 2026 13:11:54 +0100 Subject: [PATCH 2/7] Require MCH and MFT tracks for QA matching AO2D output --- PWGDQ/Tasks/qaMatching.cxx | 31 ++++++++++++++++--------------- 1 file changed, 16 insertions(+), 15 deletions(-) diff --git a/PWGDQ/Tasks/qaMatching.cxx b/PWGDQ/Tasks/qaMatching.cxx index b191f36f492..f1706530518 100644 --- a/PWGDQ/Tasks/qaMatching.cxx +++ b/PWGDQ/Tasks/qaMatching.cxx @@ -3493,9 +3493,12 @@ struct QaMatching { std::vector taggedMuons; getTaggedMuons(collisionInfo, collisions, muonTracks, taggedMuons); + const bool writeQaMatchingAod = shouldWriteQaMatchingAod(collisionInfo, collision); int debugCounter{0}; - fillQaMatchingAodEventForCollision(collisionInfo, collision, collisionInfo.reducedEventId, debugCounter); - fillQaMatchingMchTracksForCollision(collision, muonTracks, taggedMuons, collisionInfo.reducedEventId, collisionInfo.reducedMchTrackIds); + if (writeQaMatchingAod) { + fillQaMatchingAodEventForCollision(collisionInfo, collision, collisionInfo.reducedEventId, debugCounter); + fillQaMatchingMchTracksForCollision(collision, muonTracks, taggedMuons, collisionInfo.reducedEventId, collisionInfo.reducedMchTrackIds); + } registry.get(HIST("tracksMultiplicityMFT"))->Fill(collisionInfo.mftTracks.size()); registry.get(HIST("tracksMultiplicityMCH"))->Fill(collisionInfo.mchTracks.size()); @@ -3563,7 +3566,9 @@ struct QaMatching { //------------------------------- // Chi2-based matching from production + if (writeQaMatchingAod) { fillQaMatchingAodTablesForCollision(collision, muonTracks, mftTracks, collisionInfo.matchingCandidates, matchingMethodCounter, collisionInfo.reducedEventId, collisionInfo.reducedMchTrackIds, mftCovs); + } if constexpr (isMC) { fillMatchingPlotsMc(collision, collisionInfo, muonTracks, mftTracks, taggedMuons, collisionInfo.matchingCandidates, collisionInfo.matchingCandidates, collisionInfo.matchablePairs, cfgMatchingChi2ScoreMftMchLow, fChi2MatchingPlotter.get(), false); } else { @@ -3594,7 +3599,9 @@ struct QaMatching { double matchingScoreCut = matchingScoreCuts.at(label); matchingMethodCounter += 1; + if (writeQaMatchingAod) { fillQaMatchingAodTablesForCollision(collision, muonTracks, mftTracks, matchingCandidates, matchingMethodCounter, collisionInfo.reducedEventId, collisionInfo.reducedMchTrackIds, mftCovs); + } if constexpr (isMC) { fillMatchingPlotsMc(collision, collisionInfo, muonTracks, mftTracks, taggedMuons, matchingCandidates, collisionInfo.matchingCandidates, collisionInfo.matchablePairs, matchingScoreCut, plotter, false); } else { @@ -3612,7 +3619,9 @@ struct QaMatching { double matchingScoreCut = matchingScoreCuts.at(label); matchingMethodCounter += 1; + if (writeQaMatchingAod) { fillQaMatchingAodTablesForCollision(collision, muonTracks, mftTracks, matchingCandidates, matchingMethodCounter, collisionInfo.reducedEventId, collisionInfo.reducedMchTrackIds, mftCovs); + } if constexpr (isMC) { fillMatchingPlotsMc(collision, collisionInfo, muonTracks, mftTracks, taggedMuons, matchingCandidates, collisionInfo.matchingCandidates, collisionInfo.matchablePairs, matchingScoreCut, plotter); } else { @@ -3630,8 +3639,12 @@ struct QaMatching { } template - bool shouldWriteQaMatchingAod(TCOLLISION const& collision) const + bool shouldWriteQaMatchingAod(const CollisionInfo& collisionInfo, TCOLLISION const& collision) const { + if (collisionInfo.mchTracks.empty() || collisionInfo.mftTracks.empty()) { + return false; + } + if (cfgUPCMode != 0 && cfgUPCMode != 1) { return true; } @@ -3650,10 +3663,6 @@ struct QaMatching { std::map reducedMchTrackIds, CMFT const& mftCovs) { - if (!shouldWriteQaMatchingAod(collision)) { - return; - } - for (const auto& [mchIndex, candidates] : matchingCandidates) { if (candidates.empty()) { continue; @@ -3713,10 +3722,6 @@ struct QaMatching { int32_t reducedEventId, int& debugCounter) { - if (!shouldWriteQaMatchingAod(collision)) { - return; - } - const bool upcMode = (collision.flags() & o2::dataformats::Vertex>::Flags::UPCMode) != 0; int32_t mftMultiplicity = static_cast(collisionInfo.mftTracks.size()); qaMatchingEvents( @@ -3739,10 +3744,6 @@ struct QaMatching { int32_t reducedEventId, const std::map& reducedMchTrackIds) { - if (!shouldWriteQaMatchingAod(collision)) { - return; - } - std::vector> orderedMchIds; orderedMchIds.reserve(reducedMchTrackIds.size()); for (const auto& [mchIndex, reducedMchTrackId] : reducedMchTrackIds) { From c4ebf74b7e57857da3d20a3f68355f45062f51ba Mon Sep 17 00:00:00 2001 From: nivram-phy Date: Tue, 24 Nov 2026 13:12:26 +0100 Subject: [PATCH 3/7] Format QA matching AO2D output gate --- PWGDQ/Tasks/qaMatching.cxx | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/PWGDQ/Tasks/qaMatching.cxx b/PWGDQ/Tasks/qaMatching.cxx index f1706530518..d28bbbfda10 100644 --- a/PWGDQ/Tasks/qaMatching.cxx +++ b/PWGDQ/Tasks/qaMatching.cxx @@ -3567,7 +3567,7 @@ struct QaMatching { //------------------------------- // Chi2-based matching from production if (writeQaMatchingAod) { - fillQaMatchingAodTablesForCollision(collision, muonTracks, mftTracks, collisionInfo.matchingCandidates, matchingMethodCounter, collisionInfo.reducedEventId, collisionInfo.reducedMchTrackIds, mftCovs); + fillQaMatchingAodTablesForCollision(collision, muonTracks, mftTracks, collisionInfo.matchingCandidates, matchingMethodCounter, collisionInfo.reducedEventId, collisionInfo.reducedMchTrackIds, mftCovs); } if constexpr (isMC) { fillMatchingPlotsMc(collision, collisionInfo, muonTracks, mftTracks, taggedMuons, collisionInfo.matchingCandidates, collisionInfo.matchingCandidates, collisionInfo.matchablePairs, cfgMatchingChi2ScoreMftMchLow, fChi2MatchingPlotter.get(), false); @@ -3600,7 +3600,7 @@ struct QaMatching { matchingMethodCounter += 1; if (writeQaMatchingAod) { - fillQaMatchingAodTablesForCollision(collision, muonTracks, mftTracks, matchingCandidates, matchingMethodCounter, collisionInfo.reducedEventId, collisionInfo.reducedMchTrackIds, mftCovs); + fillQaMatchingAodTablesForCollision(collision, muonTracks, mftTracks, matchingCandidates, matchingMethodCounter, collisionInfo.reducedEventId, collisionInfo.reducedMchTrackIds, mftCovs); } if constexpr (isMC) { fillMatchingPlotsMc(collision, collisionInfo, muonTracks, mftTracks, taggedMuons, matchingCandidates, collisionInfo.matchingCandidates, collisionInfo.matchablePairs, matchingScoreCut, plotter, false); @@ -3620,7 +3620,7 @@ struct QaMatching { matchingMethodCounter += 1; if (writeQaMatchingAod) { - fillQaMatchingAodTablesForCollision(collision, muonTracks, mftTracks, matchingCandidates, matchingMethodCounter, collisionInfo.reducedEventId, collisionInfo.reducedMchTrackIds, mftCovs); + fillQaMatchingAodTablesForCollision(collision, muonTracks, mftTracks, matchingCandidates, matchingMethodCounter, collisionInfo.reducedEventId, collisionInfo.reducedMchTrackIds, mftCovs); } if constexpr (isMC) { fillMatchingPlotsMc(collision, collisionInfo, muonTracks, mftTracks, taggedMuons, matchingCandidates, collisionInfo.matchingCandidates, collisionInfo.matchablePairs, matchingScoreCut, plotter); From a554a8ce9cbd05caeaff3f45a0c4eaabba5136d6 Mon Sep 17 00:00:00 2001 From: nivram-phy Date: Tue, 24 Nov 2026 13:40:12 +0100 Subject: [PATCH 4/7] Fix UPC mode configurable comparison --- PWGDQ/Tasks/qaMatching.cxx | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/PWGDQ/Tasks/qaMatching.cxx b/PWGDQ/Tasks/qaMatching.cxx index d28bbbfda10..d9ec96d8e8e 100644 --- a/PWGDQ/Tasks/qaMatching.cxx +++ b/PWGDQ/Tasks/qaMatching.cxx @@ -3645,12 +3645,13 @@ struct QaMatching { return false; } - if (cfgUPCMode != 0 && cfgUPCMode != 1) { + const int upcModeFilter = static_cast(cfgUPCMode); + if (upcModeFilter != 0 && upcModeFilter != 1) { return true; } const bool upcMode = (collision.flags() & o2::dataformats::Vertex>::Flags::UPCMode) != 0; - return static_cast(upcMode) == cfgUPCMode; + return static_cast(upcMode) == upcModeFilter; } template From a953d3fad25d7e5d6d22e6b6727c64ce3500f1fa Mon Sep 17 00:00:00 2001 From: nivram-phy Date: Tue, 24 Nov 2026 13:45:15 +0100 Subject: [PATCH 5/7] Read UPC mode configurable value in const helper --- PWGDQ/Tasks/qaMatching.cxx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/PWGDQ/Tasks/qaMatching.cxx b/PWGDQ/Tasks/qaMatching.cxx index d9ec96d8e8e..c80686eb1f6 100644 --- a/PWGDQ/Tasks/qaMatching.cxx +++ b/PWGDQ/Tasks/qaMatching.cxx @@ -3645,7 +3645,7 @@ struct QaMatching { return false; } - const int upcModeFilter = static_cast(cfgUPCMode); + const int upcModeFilter = cfgUPCMode.value; if (upcModeFilter != 0 && upcModeFilter != 1) { return true; } From 8097849e41281ac0c163af801df0504bc7a445c1 Mon Sep 17 00:00:00 2001 From: nivram-phy Date: Tue, 24 Nov 2026 13:56:22 +0100 Subject: [PATCH 6/7] Fix direct includes and histogram parameter code-check errors --- PWGDQ/Tasks/qaMatching.cxx | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/PWGDQ/Tasks/qaMatching.cxx b/PWGDQ/Tasks/qaMatching.cxx index c80686eb1f6..6233c9c6dc4 100644 --- a/PWGDQ/Tasks/qaMatching.cxx +++ b/PWGDQ/Tasks/qaMatching.cxx @@ -32,6 +32,7 @@ #include #include #include +#include #include #include #include @@ -60,6 +61,7 @@ #include #include #include +#include #include // IWYU pragma: keep (do not replace with Math/Vector4Dfwd.h) #include #include @@ -618,7 +620,7 @@ struct QaMatching { AxisSpec resonanceTypeAxis = {8, 0, 8, ""}; o2::framework::HistPtr histPtr; - auto setAxisLabels = [](std::shared_ptr hn) { + auto setAxisLabels = [](const std::shared_ptr& hn) { hn->GetAxis(4)->SetBinLabel(1, ""); hn->GetAxis(4)->SetBinLabel(2, "#omega"); hn->GetAxis(4)->SetBinLabel(3, "#phi"); @@ -724,7 +726,7 @@ struct QaMatching { AxisSpec uthetaAxis = {500, 0, 50, "pull(theta)"}; AxisSpec utotAxis = {500, 0, 50, "pull(tot)"}; - auto setResonanceAxisLabels = [](std::shared_ptr hn) { + auto setResonanceAxisLabels = [](const std::shared_ptr& hn) { hn->GetAxis(7)->SetBinLabel(1, ""); hn->GetAxis(7)->SetBinLabel(2, "#omega"); hn->GetAxis(7)->SetBinLabel(3, "#phi"); @@ -806,7 +808,7 @@ struct QaMatching { AxisSpec promptNonPromptAxis = {2, 0, 2, ""}; o2::framework::HistPtr histPtr; - auto setResonanceAxisLabels = [](std::shared_ptr hn) { + auto setResonanceAxisLabels = [](const std::shared_ptr& hn) { hn->GetAxis(4)->SetBinLabel(1, ""); hn->GetAxis(4)->SetBinLabel(2, "#omega"); hn->GetAxis(4)->SetBinLabel(3, "#phi"); @@ -1127,7 +1129,7 @@ struct QaMatching { AxisSpec correctAssociationAxis = {4, 0, 4, "correct association"}; o2::framework::HistPtr histPtr; - auto setResonanceAxisLabels = [](std::shared_ptr hn) { + auto setResonanceAxisLabels = [](const std::shared_ptr& hn) { hn->GetAxis(2)->SetBinLabel(1, ""); hn->GetAxis(2)->SetBinLabel(2, "#omega"); hn->GetAxis(2)->SetBinLabel(3, "#phi"); @@ -1137,12 +1139,12 @@ struct QaMatching { hn->GetAxis(2)->SetBinLabel(7, "#Upsilon(2S)"); hn->GetAxis(2)->SetBinLabel(8, "#Upsilon(3S)"); }; - auto setPromptAxisLabels = [](std::shared_ptr hn) { + auto setPromptAxisLabels = [](const std::shared_ptr& hn) { hn->GetAxis(3)->SetBinLabel(1, "undef"); hn->GetAxis(3)->SetBinLabel(2, "prompt"); hn->GetAxis(3)->SetBinLabel(3, "non-prompt"); }; - auto setMotherAxisLabels = [](std::shared_ptr hn) { + auto setMotherAxisLabels = [](const std::shared_ptr& hn) { hn->GetAxis(4)->SetBinLabel(1, "undef"); hn->GetAxis(4)->SetBinLabel(2, "c mesons"); hn->GetAxis(4)->SetBinLabel(3, "b mesons"); From 3c828a0281a2097a2f2769ebde9ebaf1ba8fa986 Mon Sep 17 00:00:00 2001 From: nivram-phy Date: Tue, 24 Nov 2026 14:08:25 +0100 Subject: [PATCH 7/7] Include direct declaration header for ROOT XYZVector --- PWGDQ/Tasks/qaMatching.cxx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/PWGDQ/Tasks/qaMatching.cxx b/PWGDQ/Tasks/qaMatching.cxx index 6233c9c6dc4..505d044e52e 100644 --- a/PWGDQ/Tasks/qaMatching.cxx +++ b/PWGDQ/Tasks/qaMatching.cxx @@ -61,7 +61,7 @@ #include #include #include -#include +#include #include // IWYU pragma: keep (do not replace with Math/Vector4Dfwd.h) #include #include