diff --git a/PWGDQ/Tasks/qaMatching.cxx b/PWGDQ/Tasks/qaMatching.cxx index dbff66e92ae..9b5cdef037c 100644 --- a/PWGDQ/Tasks/qaMatching.cxx +++ b/PWGDQ/Tasks/qaMatching.cxx @@ -151,6 +151,10 @@ struct qaMatching { Configurable fConfigGrpMagPath{"grpmagPath-", "GLO/Config/GRPMagField", "CCDB path of the GRPMagField object"}; } fConfigCCDB; + struct : ConfigurableGroup { + Configurable fCreatePdgMomHistograms{"cfgCreatePdgMomHistograms", false, "create matching characteristics plots with particle mom PDG codes"}; + } fConfigQAs; + /// Variables for histograms configuration Configurable fNCandidatesMax{"nCandidatesMax", 5, ""}; @@ -297,20 +301,29 @@ struct qaMatching { struct EfficiencyPlotter { o2::framework::HistPtr p_num; o2::framework::HistPtr p_den; + o2::framework::HistPtr p_pdg_num; + o2::framework::HistPtr p_pdg_den; o2::framework::HistPtr pt_num; o2::framework::HistPtr pt_den; + o2::framework::HistPtr pt_pdg_num; + o2::framework::HistPtr pt_pdg_den; o2::framework::HistPtr phi_num; o2::framework::HistPtr phi_den; + o2::framework::HistPtr phi_pdg_num; + o2::framework::HistPtr phi_pdg_den; o2::framework::HistPtr eta_num; o2::framework::HistPtr eta_den; + o2::framework::HistPtr eta_pdg_num; + o2::framework::HistPtr eta_pdg_den; EfficiencyPlotter(std::string path, std::string title, - HistogramRegistry& registry) + HistogramRegistry& registry, bool createPdgMomHistograms) { AxisSpec pAxis = {100, 0, 100, "p (GeV/c)"}; AxisSpec pTAxis = {100, 0, 10, "p_{T} (GeV/c)"}; AxisSpec etaAxis = {100, -4, -2, "#eta"}; AxisSpec phiAxis = {90, -180, 180, "#phi (degrees)"}; + AxisSpec motherPDGAxis{1201, -600.5, 600.5, "Direct mother PDG"}; std::string histName; std::string histTitle; @@ -324,6 +337,16 @@ struct qaMatching { histTitle = title + " vs. p - den"; p_den = registry.add(histName.c_str(), histTitle.c_str(), {HistType::kTH1F, {pAxis}}); + if (createPdgMomHistograms) { + histName = path + "p_pdg_num"; + histTitle = title + " vs. p vs pdg ID - num"; + p_pdg_num = registry.add(histName.c_str(), histTitle.c_str(), {HistType::kTH2F, {pAxis, motherPDGAxis}}); + + histName = path + "p_pdg_den"; + histTitle = title + " vs. p vs pdg ID - den"; + p_pdg_den = registry.add(histName.c_str(), histTitle.c_str(), {HistType::kTH2F, {pAxis, motherPDGAxis}}); + } + // pT dependence histName = path + "pt_num"; histTitle = title + " vs. p_{T} - num"; @@ -333,6 +356,16 @@ struct qaMatching { histTitle = title + " vs. p_{T} - den"; pt_den = registry.add(histName.c_str(), histTitle.c_str(), {HistType::kTH1F, {pTAxis}}); + if (createPdgMomHistograms) { + histName = path + "pt_pdg_num"; + histTitle = title + " vs. p_{T} vs pdg ID - num"; + pt_pdg_num = registry.add(histName.c_str(), histTitle.c_str(), {HistType::kTH2F, {pTAxis, motherPDGAxis}}); + + histName = path + "pt_pdg_den"; + histTitle = title + " vs. p_{T} vs pdg ID - den"; + pt_pdg_den = registry.add(histName.c_str(), histTitle.c_str(), {HistType::kTH2F, {pTAxis, motherPDGAxis}}); + } + // eta dependence histName = path + "eta_num"; histTitle = title + " vs. #eta - num"; @@ -342,6 +375,16 @@ struct qaMatching { histTitle = title + " vs. #eta - den"; eta_den = registry.add(histName.c_str(), histTitle.c_str(), {HistType::kTH1F, {etaAxis}}); + if (createPdgMomHistograms) { + histName = path + "eta_pdg_num"; + histTitle = title + " vs. #eta vs pdg ID - num"; + eta_pdg_num = registry.add(histName.c_str(), histTitle.c_str(), {HistType::kTH2F, {etaAxis, motherPDGAxis}}); + + histName = path + "eta_pdg_den"; + histTitle = title + " vs. #eta vs pdg ID - den"; + eta_pdg_den = registry.add(histName.c_str(), histTitle.c_str(), {HistType::kTH2F, {etaAxis, motherPDGAxis}}); + } + // phi dependence histName = path + "phi_num"; histTitle = title + " vs. #phi - num"; @@ -350,6 +393,16 @@ struct qaMatching { histName = path + "phi_den"; histTitle = title + " vs. #phi - den"; phi_den = registry.add(histName.c_str(), histTitle.c_str(), {HistType::kTH1F, {phiAxis}}); + + if (createPdgMomHistograms) { + histName = path + "phi_pdg_num"; + histTitle = title + " vs. #phi vs pdg ID - num"; + phi_pdg_num = registry.add(histName.c_str(), histTitle.c_str(), {HistType::kTH2F, {phiAxis, motherPDGAxis}}); + + histName = path + "phi_pdg_den"; + histTitle = title + " vs. #phi vs pdg ID - den"; + phi_pdg_den = registry.add(histName.c_str(), histTitle.c_str(), {HistType::kTH2F, {phiAxis, motherPDGAxis}}); + } } template @@ -368,6 +421,24 @@ struct qaMatching { std::get>(phi_num)->Fill(phi); } } + + // Study the PDG origin of particles and their effect on the purity score + template + void Fill(const T& track, int pdgCode, bool passed) + { + double phi = track.phi() * 180 / TMath::Pi(); + std::get>(p_pdg_den)->Fill(track.p(), pdgCode); + std::get>(pt_pdg_den)->Fill(track.pt(), pdgCode); + std::get>(eta_pdg_den)->Fill(track.eta(), pdgCode); + std::get>(phi_pdg_den)->Fill(phi, pdgCode); + + if (passed) { + std::get>(p_pdg_num)->Fill(track.p(), pdgCode); + std::get>(pt_pdg_num)->Fill(track.pt(), pdgCode); + std::get>(eta_pdg_num)->Fill(track.eta(), pdgCode); + std::get>(phi_pdg_num)->Fill(phi, pdgCode); + } + } }; struct MatchRankingHistos { @@ -458,11 +529,11 @@ struct qaMatching { HistogramRegistry* registry; MatchingPlotter(std::string path, - HistogramRegistry* reg) - : fMatchingPurityPlotter(path + "matching-purity/", "Matching purity", *reg), - fPairingEfficiencyPlotter(path + "pairing-efficiency/", "Pairing efficiency", *reg), - fMatchingEfficiencyPlotter(path + "matching-efficiency/", "Matching efficiency", *reg), - fFakeMatchingEfficiencyPlotter(path + "fake-matching-efficiency/", "Fake matching efficiency", *reg) + HistogramRegistry* reg, bool createPdgMomHistograms) + : fMatchingPurityPlotter(path + "matching-purity/", "Matching purity", *reg, createPdgMomHistograms), + fPairingEfficiencyPlotter(path + "pairing-efficiency/", "Pairing efficiency", *reg, createPdgMomHistograms), + fMatchingEfficiencyPlotter(path + "matching-efficiency/", "Matching efficiency", *reg, createPdgMomHistograms), + fFakeMatchingEfficiencyPlotter(path + "fake-matching-efficiency/", "Fake matching efficiency", *reg, createPdgMomHistograms) { registry = reg; AxisSpec pAxis = {100, 0, 100, "p (GeV/c)"}; @@ -688,19 +759,19 @@ struct qaMatching { registry.add((histPath + "selectedMCHTracksAtMFTTrue").c_str(), "Selected MCH tracks position at MFT end - true", {HistType::kTH2F, {trackPositionXAtMFTAxis, trackPositionYAtMFTAxis}}); registry.add((histPath + "selectedMCHTracksAtMFTFake").c_str(), "Selected MCH tracks position at MFT end - fake", {HistType::kTH2F, {trackPositionXAtMFTAxis, trackPositionYAtMFTAxis}}); - fChi2MatchingPlotter = std::make_unique(histPath + "Prod/", ®istryMatching); + fChi2MatchingPlotter = std::make_unique(histPath + "Prod/", ®istryMatching, fConfigQAs.fCreatePdgMomHistograms); int registryIndex = 0; for (const auto& [label, func] : matchingChi2Functions) { - fMatchingPlotters[label] = std::make_unique(histPath + label + "/", registryMatchingVec[registryIndex]); + fMatchingPlotters[label] = std::make_unique(histPath + label + "/", registryMatchingVec[registryIndex], fConfigQAs.fCreatePdgMomHistograms); registryIndex += 1; } for (const auto& [label, response] : matchingMlResponses) { - fMatchingPlotters[label] = std::make_unique(histPath + label + "/", (registryMatchingVec[registryIndex])); + fMatchingPlotters[label] = std::make_unique(histPath + label + "/", (registryMatchingVec[registryIndex]), fConfigQAs.fCreatePdgMomHistograms); registryIndex += 1; } - fTaggedMuonsMatchingPlotter = std::make_unique(histPath + "Tagged/", ®istryMatching); - fSelectedMuonsMatchingPlotter = std::make_unique(histPath + "Selected/", ®istryMatching); + fTaggedMuonsMatchingPlotter = std::make_unique(histPath + "Tagged/", ®istryMatching, fConfigQAs.fCreatePdgMomHistograms); + fSelectedMuonsMatchingPlotter = std::make_unique(histPath + "Selected/", ®istryMatching, fConfigQAs.fCreatePdgMomHistograms); } void CreateDimuonHistos() @@ -2066,10 +2137,26 @@ struct qaMatching { // check if the matching candidate is a true one bool isTrueMatch = IsTrueGlobalMatching(muonTrack, matchablePairs); - if (verbose) + // ---- MC ancestry ---- + auto motherParticles = GetMotherParticles(muonTrack); + int motherPDG = 0; + if (motherParticles.size() > 1) { + motherPDG = motherParticles[1].first; + } + + if (verbose) { std::cout << std::format(" MCH track #{} -> Muon track #{}, isTrueMatch={}", mchIndex, globalTracksVector[0].globalTrackId, isTrueMatch) << std::endl; + std::cout << " MC ancestry (pdg): "; + for (auto const& [pdg, idx] : motherParticles) { + std::cout << "(" << pdg << ") "; + } + std::cout << std::endl; + } // fill matching purity plots plotter->fMatchingPurityPlotter.Fill(mchTrack, isTrueMatch); + if (fConfigQAs.fCreatePdgMomHistograms) { + plotter->fMatchingPurityPlotter.Fill(mchTrack, motherPDG, isTrueMatch); + } } // ==================================== @@ -2105,10 +2192,34 @@ struct qaMatching { } } + // ---- MC ancestry ---- + auto motherParticles = GetMotherParticles(mchTrack); + int motherPDG = 0; + if (motherParticles.size() > 1) { + motherPDG = motherParticles[1].first; + } + + if (verbose) { + std::cout << " MC ancestry (pdg): "; + for (auto const& [pdg, idx] : motherParticles) { + std::cout << "(" << pdg << ") "; + } + std::cout << std::endl; + } + // fill matching efficiency plots plotter->fPairingEfficiencyPlotter.Fill(mchTrack, goodMatchFound); + if (fConfigQAs.fCreatePdgMomHistograms) { + plotter->fPairingEfficiencyPlotter.Fill(mchTrack, motherPDG, goodMatchFound); + } plotter->fMatchingEfficiencyPlotter.Fill(mchTrack, (goodMatchFound && isTrueMatch)); + if (fConfigQAs.fCreatePdgMomHistograms) { + plotter->fMatchingEfficiencyPlotter.Fill(mchTrack, motherPDG, (goodMatchFound && isTrueMatch)); + } plotter->fFakeMatchingEfficiencyPlotter.Fill(mchTrack, (goodMatchFound && !isTrueMatch)); + if (fConfigQAs.fCreatePdgMomHistograms) { + plotter->fFakeMatchingEfficiencyPlotter.Fill(mchTrack, motherPDG, (goodMatchFound && !isTrueMatch)); + } } }