From 1d4446e9241325700a1d4d134f787f51bbb34992 Mon Sep 17 00:00:00 2001 From: Deependra Sharma Date: Sat, 28 Nov 2026 18:11:34 +0000 Subject: [PATCH 1/3] "Added MC matched correlation from prompt and non-prompt candidates" --- PWGHF/HFC/DataModel/CorrelationTables.h | 11 ++ .../TableProducer/correlatorDstarHadrons.cxx | 81 +++++++++++-- .../HFC/Tasks/taskCorrelationDstarHadrons.cxx | 108 +++++++++++++++--- 3 files changed, 178 insertions(+), 22 deletions(-) diff --git a/PWGHF/HFC/DataModel/CorrelationTables.h b/PWGHF/HFC/DataModel/CorrelationTables.h index fcea57be77c..0eb1ca7510a 100644 --- a/PWGHF/HFC/DataModel/CorrelationTables.h +++ b/PWGHF/HFC/DataModel/CorrelationTables.h @@ -563,6 +563,12 @@ DECLARE_SOA_TABLE(DstarHadronPair, "AOD", "DSTRHPAIR", // D* Hadrons pairs Infor hf_correlation_dstar_hadron::DeltaEta, hf_correlation_dstar_hadron::DeltaM); +// must be filled row wise along with DstarHadronPair +DECLARE_SOA_TABLE(DstarHadronPairMcRec, "AOD", "DSTRHPAIRMCREC", + hf_cand_mc_flag::OriginMcRec, + hf_cand_mc_flag::PdgBhadMotherPart, + hf_cand_mc_flag::PtBhadMotherPart); + DECLARE_SOA_TABLE(Dstar, "AOD", "DSTAR", // Only Dstar properties hf_correlation_dstar_hadron::CollisionIdx, // D* only properties @@ -575,6 +581,11 @@ DECLARE_SOA_TABLE(Dstar, "AOD", "DSTAR", // Only Dstar properties hf_correlation_dstar_hadron::TimeStamp, hf_correlation_dstar_hadron::PoolBin); +DECLARE_SOA_TABLE(DstarMcRec, "AOD", "DSTARMCREC", + hf_cand_mc_flag::OriginMcRec, + hf_cand_mc_flag::PdgBhadMotherPart, + hf_cand_mc_flag::PtBhadMotherPart); + // Note: Table for selection of Lc in a collision namespace hf_selection_lc_collision { diff --git a/PWGHF/HFC/TableProducer/correlatorDstarHadrons.cxx b/PWGHF/HFC/TableProducer/correlatorDstarHadrons.cxx index aedb3fadca9..ba539ad2502 100644 --- a/PWGHF/HFC/TableProducer/correlatorDstarHadrons.cxx +++ b/PWGHF/HFC/TableProducer/correlatorDstarHadrons.cxx @@ -15,6 +15,7 @@ /// \brief Correlator for D* and hadrons. This task is used to produce table for D* and hadron pairs. +#include "PWGHF/Core/DecayChannels.h" #include "PWGHF/DataModel/AliasTables.h" #include "PWGHF/DataModel/CandidateReconstructionTables.h" #include "PWGHF/DataModel/CandidateSelectionTables.h" @@ -116,7 +117,9 @@ struct HfCorrelatorDstarHadronsCollisionSelector { struct HfCorrelatorDstarHadrons { Produces rowsDstarHadronPair; + Produces rowsDstarHadronPairMcRec; Produces rowsDstar; + Produces rowsDstarMcRec; Produces rowsAssoTrack; // Enable separate tables for Dstar and Track for offline Event mixing @@ -161,6 +164,9 @@ struct HfCorrelatorDstarHadrons { using DstarCandidates = soa::Join; // Added extra cloumns in HfCandDstar (Prong0Id, Prong1Id), so no need to add table HfCandD0Fromdstar using FilteredCandidates = soa::Filtered; + using DstarCandidatesMcRec = soa::Join; + using FilteredCandidatesMcRec = soa::Filtered; + using FilteredTracks = soa::Filtered; // collision table filter @@ -192,7 +198,12 @@ struct HfCorrelatorDstarHadrons { void init(InitContext&) { - std::array processes = {doprocessDataSameEvent, doprocessDataWithMixedEvent}; + + if (doprocessDataSameEvent && doprocessMCRecSameEvent) { + LOGP(fatal, "Both data same event and MC Rec same event processing cannot be enabled simultaneously."); + } + + std::array processes = {doprocessDataSameEvent, doprocessDataWithMixedEvent, doprocessMCRecSameEvent}; if (std::accumulate(processes.begin(), processes.end(), 0) != 1) { LOGP(fatal, "One and only one process function must be enabled at a time."); } @@ -224,15 +235,24 @@ struct HfCorrelatorDstarHadrons { registry.add("QA/hDPhiDEtaDstarAssoTrack", "Delta Phi vs Delta Eta distribution between Dstar and Associated Track", {HistType::kTH2D, {axisDeltaPhi, axisDeltaEta}}); } - void processDataSameEvent(FilteredCollisions const& collisions, // only collisions who have altleast one D* - FilteredTracks const& tracks, - FilteredCandidates const& candidates, - aod::BCsWithTimestamps const&) + /// @brief Run the correlator for same event analysis + /// @tparam isMC Boolean indicating if the analysis is for MC reconstructed data + /// @tparam collisionsType Type of the collisions Table + /// @tparam tracksType Type of the tracks Table + /// @tparam candidatesType Type of the candidates Table + /// @param collisions The collisions Table + /// @param tracks The tracks Table + /// @param candidates The candidates Table + /// @return None + template + void runCorrelatorSameEvent(const collisionsType& collisions, + const tracksType& tracks, + const candidatesType& candidates + /*, aod::BCsWithTimestamps const&*/) { for (const auto& collision : collisions) { registry.fill(HIST("hTriggerColCandPairCounts"), 0); // counting trigger collision - - auto bc = collision.bc_as(); + auto bc = collision.template bc_as(); auto timestamp = bc.timestamp(); binNumber = binningScheme.getBin(std::make_tuple(collision.posZ(), collision.multFT0M())); auto candidatesPerCol = candidates.sliceByCached(aod::hf_cand::collisionId, collision.globalIndex(), cache); @@ -252,6 +272,21 @@ struct HfCorrelatorDstarHadrons { int nCandsSideBand = 0; // Single particle distribution for canfdidates for (const auto& cand : candidatesPerCol) { + if constexpr (isMC) { + // Handle MC-specific logic here + auto yCand = cand.y(constants::physics::MassDStar); + if (std::abs(yCand) > yAbsDstarMax) { + continue; + } + if (std::abs(cand.flagMcMatchRec()) == hf_decay::hf_cand_dstar::DecayChannelMain::DstarToPiKPi) { // if MC matching is successful at Reconstruction Level + // auto ptMother = cand.ptBhadMotherPart(); + int const pdgBhadMother = cand.pdgBhadMotherPart(); + // For unknown reasons there are charm hadrons coming directly from beauty diquarks without an intermediate B-hadron which have an unreasonable correlation between the pT of the charm hadron and the beauty mother. We also remove charm hadrons from quarkonia. + if (cand.originMcRec() == RecoDecay::OriginType::NonPrompt && (pdgBhadMother == 5101 || pdgBhadMother == 5103 || pdgBhadMother == 5201 || pdgBhadMother == 5203 || pdgBhadMother == 5301 || pdgBhadMother == 5303 || pdgBhadMother == 5401 || pdgBhadMother == 5403 || pdgBhadMother == 5503 || pdgBhadMother == 553 || pdgBhadMother == 555 || pdgBhadMother == 557)) { // o2-linter: disable=pdg/explicit-code, magic-number (constants not in the PDG header) + continue; + } + } + } auto gItriggerParticle = cand.globalIndex(); if (cand.signSoftPi() > 0) { invMassDstarParticle = cand.invMassDstar(); @@ -274,6 +309,7 @@ struct HfCorrelatorDstarHadrons { registry.fill(HIST("QA/hEtaDstarSideBand"), cand.eta()); nCandsSideBand++; } + // Fill correlation histograms for signal and sideband candidates versus number of associated tracks registry.fill(HIST("QA/hCandsSignalVsTracksPerCol"), nCandsSignal, tracksPerCol.size()); registry.fill(HIST("QA/hCandsSideBandVsTracksPerCol"), nCandsSideBand, tracksPerCol.size()); @@ -288,7 +324,13 @@ struct HfCorrelatorDstarHadrons { timestamp, binNumber); } - } // Dstar loop + if constexpr (isMC) { + rowsDstarMcRec(cand.originMcRec(), + cand.pdgBhadMotherPart(), + cand.ptBhadMotherPart()); + } + } // canidate loop + // Single particle distribution for tracks for (const auto& track : tracksPerCol) { registry.fill(HIST("QA/hPhiAssoTrack"), track.phi()); @@ -349,9 +391,22 @@ struct HfCorrelatorDstarHadrons { assocParticle.pt(), timestamp, binNumber); + if constexpr (isMC) { + rowsDstarHadronPairMcRec(triggerParticle.originMcRec(), + triggerParticle.pdgBhadMotherPart(), + triggerParticle.ptBhadMotherPart()); + } } // D-H pair loop } // collision loop + } // runCorrelatorSameEvent template function + + void processDataSameEvent(FilteredCollisions const& collisions, // only collisions who have altleast one D* + FilteredTracks const& tracks, + FilteredCandidates const& candidates, + aod::BCsWithTimestamps const&) + { + runCorrelatorSameEvent(collisions, tracks, candidates); } // processDataSameEvent PROCESS_SWITCH(HfCorrelatorDstarHadrons, processDataSameEvent, "process only same event data", true); @@ -406,6 +461,16 @@ struct HfCorrelatorDstarHadrons { } // processDataWithMixedEvent PROCESS_SWITCH(HfCorrelatorDstarHadrons, processDataWithMixedEvent, "process only mixed events data", false); + + void processMCRecSameEvent(FilteredCollisions const& collisions, + FilteredTracks const& tracks, + FilteredCandidatesMcRec const& candidates, + aod::BCsWithTimestamps const&) + { + // Implementation for processing MC reconstructed same event data goes here + runCorrelatorSameEvent(collisions, tracks, candidates); + } + PROCESS_SWITCH(HfCorrelatorDstarHadrons, processMCRecSameEvent, "process only MC reconstructed same event data", false); }; WorkflowSpec defineDataProcessing(ConfigContext const& cfgc) diff --git a/PWGHF/HFC/Tasks/taskCorrelationDstarHadrons.cxx b/PWGHF/HFC/Tasks/taskCorrelationDstarHadrons.cxx index a8c1004df3e..56f24fb5bce 100644 --- a/PWGHF/HFC/Tasks/taskCorrelationDstarHadrons.cxx +++ b/PWGHF/HFC/Tasks/taskCorrelationDstarHadrons.cxx @@ -14,6 +14,8 @@ /// \author Fabrizio Grosa , CERN /// \author Shyam Kumar +/// \brief Task for correlation analysis of D* mesons with hadrons + #include "PWGHF/Core/SelectorCuts.h" #include "PWGHF/HFC/DataModel/CorrelationTables.h" #include "PWGHF/Utils/utilsAnalysis.h" @@ -112,17 +114,26 @@ struct HfTaskCorrelationDstarHadrons { Configurable> rightSidebandInnerBoundary{"rightSidebandInnerBoundary", std::vector{vecSidebandRightInnerDefault}, "right sideband inner boundary"}; Configurable nBinsDeltaPhi{"nBinsDeltaPhi", 64, "number of bins in delta phi axis"}; + o2::ccdb::CcdbApi ccdbApi; + std::vector vecHistEfficiencyDstar; + std::vector vecHistEfficiencyTracks; + + using DstarHadronPairWMcRec = soa::Join; + ConfigurableAxis deltaEtaBinEdges{"deltaEtaBinEdges", {40, -2., 2.}, " Delta Eta Bins of equal width"}; ConfigurableAxis ptHadronBinsEdges{"ptHadronBinsEdges", {11, 0., 11.}, "pT Bins of equal width for Hadrons"}; HistogramRegistry registry{"registry", {}, OutputObjHandlingPolicy::AnalysisObject, true, true}; - o2::ccdb::CcdbApi ccdbApi; - std::vector vecHistEfficiencyDstar; - std::vector vecHistEfficiencyTracks; - void init(InitContext&) { + if (doprocessData && doprocessMcRec) { + LOGP(fatal, "Both data and MC Rec processing cannot be enabled simultaneously."); + } + std::array processes = {doprocessData, doprocessMcRec}; + if (std::accumulate(processes.begin(), processes.end(), 0) != 1) { + LOGP(fatal, "One and only one process function must be enabled at a time."); + } auto axisPtDstar = std::vector(binsPtEfficiency); AxisSpec const axisSpecPtDstar = {axisPtDstar}; @@ -131,14 +142,35 @@ struct HfTaskCorrelationDstarHadrons { AxisSpec const axisSpecPtHadron = {ptHadronBinsEdges}; AxisSpec const axisSpecPoolBin = {9, 0., 9.}; - registry.add("hCorrel2DVsPtSignalRegion", stringDHadron + stringSignal + stringDeltaPhi + stringDeltaEta + stringPtD + stringPtHadron + stringPoolBin + "entries", {HistType::kTHnSparseD, {axisSpecDeltaPhi, axisSpecDeltaEta, axisSpecPtDstar, axisSpecPtHadron, axisSpecPoolBin}}, true); - registry.add("hCorrel2DPtIntSignalRegion", stringDHadron + stringSignal + stringDeltaPhi + stringDeltaEta + "entries", {HistType::kTH2D, {axisSpecDeltaPhi, axisSpecDeltaEta}}, true); - registry.add("hDeltaEtaPtIntSignalRegion", stringDHadron + stringSignal + stringDeltaEta + "entries", {HistType::kTH1D, {axisSpecDeltaEta}}, true); - registry.add("hDeltaPhiPtIntSignalRegion", stringDHadron + stringSignal + stringDeltaPhi + "entries", {HistType::kTH1D, {axisSpecDeltaPhi}}, true); - registry.add("hCorrel2DVsPtSidebands", stringDHadron + stringSideband + stringDeltaPhi + stringDeltaEta + stringPtD + stringPtHadron + stringPoolBin + "entries", {HistType::kTHnSparseD, {axisSpecDeltaPhi, axisSpecDeltaEta, axisSpecPtDstar, axisSpecPtHadron, axisSpecPoolBin}}, true); - registry.add("hCorrel2DPtIntSidebands", stringDHadron + stringSideband + stringDeltaPhi + stringDeltaEta + "entries", {HistType::kTH2D, {axisSpecDeltaPhi, axisSpecDeltaEta}}, true); - registry.add("hDeltaEtaPtIntSidebands", stringDHadron + stringSideband + stringDeltaEta + "entries", {HistType::kTH1D, {axisSpecDeltaEta}}, true); - registry.add("hDeltaPhiPtIntSidebands", stringDHadron + stringSideband + stringDeltaPhi + "entries", {HistType::kTH1D, {axisSpecDeltaPhi}}, true); + const std::string hCorrel2DVsPtSignalRegion = "hCorrel2DVsPtSignalRegion"; + const std::string hCorrel2DPtIntSignalRegion = "hCorrel2DPtIntSignalRegion"; + const std::string hDeltaEtaPtIntSignalRegion = "hDeltaEtaPtIntSignalRegion"; + const std::string hDeltaPhiPtIntSignalRegion = "hDeltaPhiPtIntSignalRegion"; + const std::string hCorrel2DVsPtSidebands = "hCorrel2DVsPtSidebands"; + const std::string hCorrel2DPtIntSidebands = "hCorrel2DPtIntSidebands"; + const std::string hDeltaEtaPtIntSidebands = "hDeltaEtaPtIntSidebands"; + const std::string hDeltaPhiPtIntSidebands = "hDeltaPhiPtIntSidebands"; + + auto addCorrelationHistograms = [&](std::string const& prefix) { + registry.add(prefix + hCorrel2DVsPtSignalRegion, (stringDHadron + stringSignal + stringDeltaPhi + stringDeltaEta + stringPtD + stringPtHadron + stringPoolBin + "entries").Data(), HistType::kTHnSparseD, {axisSpecDeltaPhi, axisSpecDeltaEta, axisSpecPtDstar, axisSpecPtHadron, axisSpecPoolBin}, true); + registry.add(prefix + hCorrel2DPtIntSignalRegion, (stringDHadron + stringSignal + stringDeltaPhi + stringDeltaEta + "entries").Data(), HistType::kTH2D, {axisSpecDeltaPhi, axisSpecDeltaEta}, true); + registry.add(prefix + hDeltaEtaPtIntSignalRegion, (stringDHadron + stringSignal + stringDeltaEta + "entries").Data(), HistType::kTH1D, {axisSpecDeltaEta}, true); + registry.add(prefix + hDeltaPhiPtIntSignalRegion, (stringDHadron + stringSignal + stringDeltaPhi + "entries").Data(), HistType::kTH1D, {axisSpecDeltaPhi}, true); + registry.add(prefix + hCorrel2DVsPtSidebands, (stringDHadron + stringSideband + stringDeltaPhi + stringDeltaEta + stringPtD + stringPtHadron + stringPoolBin + "entries").Data(), HistType::kTHnSparseD, {axisSpecDeltaPhi, axisSpecDeltaEta, axisSpecPtDstar, axisSpecPtHadron, axisSpecPoolBin}, true); + registry.add(prefix + hCorrel2DPtIntSidebands, (stringDHadron + stringSideband + stringDeltaPhi + stringDeltaEta + "entries").Data(), HistType::kTH2D, {axisSpecDeltaPhi, axisSpecDeltaEta}, true); + registry.add(prefix + hDeltaEtaPtIntSidebands, (stringDHadron + stringSideband + stringDeltaEta + "entries").Data(), HistType::kTH1D, {axisSpecDeltaEta}, true); + registry.add(prefix + hDeltaPhiPtIntSidebands, (stringDHadron + stringSideband + stringDeltaPhi + "entries").Data(), HistType::kTH1D, {axisSpecDeltaPhi}, true); + }; + + addCorrelationHistograms(""); + + if (doprocessMcRec) { + const std::string promptPrefix = "MC/Prompt/"; + const std::string nonPromptPrefix = "MC/NonPrompt/"; + + addCorrelationHistograms(promptPrefix); + addCorrelationHistograms(nonPromptPrefix); + } if (applyEfficiency && useCcdbEfficiency) { ccdbApi.init(ccdbUrl); @@ -186,7 +218,8 @@ struct HfTaskCorrelationDstarHadrons { } } - void processData(aod::DstarHadronPair const& dstarHPairs) + template + void runPairTask(pairTableType const& dstarHPairs) { for (const auto& dstarHPair : dstarHPairs) { float const deltaPhi = dstarHPair.deltaPhi(); @@ -256,9 +289,56 @@ struct HfTaskCorrelationDstarHadrons { registry.fill(HIST("hDeltaEtaPtIntSidebands"), deltaEta, netEfficiencyWeight); registry.fill(HIST("hDeltaPhiPtIntSidebands"), deltaPhi, netEfficiencyWeight); } - } + + if constexpr (isMC) { + // Implement MC-specific correlation plots here + + // Check if the D* candidate is prompt in MC reconstruction + if (dstarHPair.originMcRec() == RecoDecay::OriginType::Prompt) { + if (deltaM > signalRegionLefBound->at(corrBinPtDstar) && deltaM < signalRegionRightBound->at(corrBinPtDstar)) { + // in signal region + registry.fill(HIST("MC/Prompt/hCorrel2DVsPtSignalRegion"), deltaPhi, deltaEta, ptDstar, ptTrack, poolBin, netEfficiencyWeight); + registry.fill(HIST("MC/Prompt/hCorrel2DPtIntSignalRegion"), deltaPhi, deltaEta, netEfficiencyWeight); + registry.fill(HIST("MC/Prompt/hDeltaEtaPtIntSignalRegion"), deltaEta, netEfficiencyWeight); + registry.fill(HIST("MC/Prompt/hDeltaPhiPtIntSignalRegion"), deltaPhi, netEfficiencyWeight); + } else if (/*(deltaM > leftSidebandOuterBoundary->at(corrBinPtDstar) && deltaM < leftSidebandInnerBoundary->at(corrBinPtDstar)) ||*/ (deltaM > rightSidebandInnerBoundary->at(corrBinPtDstar) && deltaM < rightSidebandOuterBoundary->at(corrBinPtDstar))) { + registry.fill(HIST("MC/Prompt/hCorrel2DVsPtSidebands"), deltaPhi, deltaEta, ptDstar, ptTrack, poolBin, netEfficiencyWeight); + registry.fill(HIST("MC/Prompt/hCorrel2DPtIntSidebands"), deltaPhi, deltaEta, netEfficiencyWeight); + registry.fill(HIST("MC/Prompt/hDeltaEtaPtIntSidebands"), deltaEta, netEfficiencyWeight); + registry.fill(HIST("MC/Prompt/hDeltaPhiPtIntSidebands"), deltaPhi, netEfficiencyWeight); + } + } else if (dstarHPair.originMcRec() == RecoDecay::OriginType::NonPrompt) { + if (deltaM > signalRegionLefBound->at(corrBinPtDstar) && deltaM < signalRegionRightBound->at(corrBinPtDstar)) { + // in signal region + registry.fill(HIST("MC/NonPrompt/hCorrel2DVsPtSignalRegion"), deltaPhi, deltaEta, ptDstar, ptTrack, poolBin, netEfficiencyWeight); + registry.fill(HIST("MC/NonPrompt/hCorrel2DPtIntSignalRegion"), deltaPhi, deltaEta, netEfficiencyWeight); + registry.fill(HIST("MC/NonPrompt/hDeltaEtaPtIntSignalRegion"), deltaEta, netEfficiencyWeight); + registry.fill(HIST("MC/NonPrompt/hDeltaPhiPtIntSignalRegion"), deltaPhi, netEfficiencyWeight); + } else if (/*(deltaM > leftSidebandOuterBoundary->at(corrBinPtDstar) && deltaM < leftSidebandInnerBoundary->at(corrBinPtDstar)) ||*/ (deltaM > rightSidebandInnerBoundary->at(corrBinPtDstar) && deltaM < rightSidebandOuterBoundary->at(corrBinPtDstar))) { + registry.fill(HIST("MC/NonPrompt/hCorrel2DVsPtSidebands"), deltaPhi, deltaEta, ptDstar, ptTrack, poolBin, netEfficiencyWeight); + registry.fill(HIST("MC/NonPrompt/hCorrel2DPtIntSidebands"), deltaPhi, deltaEta, netEfficiencyWeight); + registry.fill(HIST("MC/NonPrompt/hDeltaEtaPtIntSidebands"), deltaEta, netEfficiencyWeight); + registry.fill(HIST("MC/NonPrompt/hDeltaPhiPtIntSidebands"), deltaPhi, netEfficiencyWeight); + } + } + } // end of isMC + + } // end of loop over DstarHadron pairs + } // end of runPairTask function + + void processData(aod::DstarHadronPair const& dstarHPairs) + { + // Implement the processing of DstarHadronPair data here + runPairTask(dstarHPairs); } PROCESS_SWITCH(HfTaskCorrelationDstarHadrons, processData, " process data only", true); + + void processMcRec(DstarHadronPairWMcRec const& dstarHadronPairsWMcRec) + { + // Implement the processing of DstarHadronPair with MC Rec information here + runPairTask(dstarHadronPairsWMcRec); + } + PROCESS_SWITCH(HfTaskCorrelationDstarHadrons, processMcRec, " process MC Rec only", false); }; WorkflowSpec defineDataProcessing(ConfigContext const& cfgc) From e2c4b250fa544854ebe1f648275a259a415727f1 Mon Sep 17 00:00:00 2001 From: Deependra Sharma Date: Sat, 28 Nov 2026 18:51:56 +0000 Subject: [PATCH 2/3] "rejected unmatched candidated in MC process" --- .../TableProducer/correlatorDstarHadrons.cxx | 24 +++++++++++++++---- 1 file changed, 19 insertions(+), 5 deletions(-) diff --git a/PWGHF/HFC/TableProducer/correlatorDstarHadrons.cxx b/PWGHF/HFC/TableProducer/correlatorDstarHadrons.cxx index ba539ad2502..30ae6350d93 100644 --- a/PWGHF/HFC/TableProducer/correlatorDstarHadrons.cxx +++ b/PWGHF/HFC/TableProducer/correlatorDstarHadrons.cxx @@ -285,6 +285,8 @@ struct HfCorrelatorDstarHadrons { if (cand.originMcRec() == RecoDecay::OriginType::NonPrompt && (pdgBhadMother == 5101 || pdgBhadMother == 5103 || pdgBhadMother == 5201 || pdgBhadMother == 5203 || pdgBhadMother == 5301 || pdgBhadMother == 5303 || pdgBhadMother == 5401 || pdgBhadMother == 5403 || pdgBhadMother == 5503 || pdgBhadMother == 553 || pdgBhadMother == 555 || pdgBhadMother == 557)) { // o2-linter: disable=pdg/explicit-code, magic-number (constants not in the PDG header) continue; } + } else { + continue; // Skip candidates that are not successfully MC matched at Reconstruction Level } } auto gItriggerParticle = cand.globalIndex(); @@ -377,6 +379,22 @@ struct HfCorrelatorDstarHadrons { invMassD0Particle = triggerParticle.invMassD0Bar(); } + if constexpr (isMC) { + // if MC matching is successful at Reconstruction Level + if (std::abs(triggerParticle.flagMcMatchRec()) == hf_decay::hf_cand_dstar::DecayChannelMain::DstarToPiKPi) { + int const pdgBhadMother = triggerParticle.pdgBhadMotherPart(); + if (triggerParticle.originMcRec() == RecoDecay::OriginType::NonPrompt && (pdgBhadMother == 5101 || pdgBhadMother == 5103 || pdgBhadMother == 5201 || pdgBhadMother == 5203 || pdgBhadMother == 5301 || pdgBhadMother == 5303 || pdgBhadMother == 5401 || pdgBhadMother == 5403 || pdgBhadMother == 5503 || pdgBhadMother == 553 || pdgBhadMother == 555 || pdgBhadMother == 557)) { // o2-linter: disable=pdg/explicit-code, magic-number (constants not in the PDG header) + continue; + } + } else { + continue; // Skip pair that are not successfully MC matched at Reconstruction Level + } + + rowsDstarHadronPairMcRec(triggerParticle.originMcRec(), + triggerParticle.pdgBhadMotherPart(), + triggerParticle.ptBhadMotherPart()); + } + // Fill Tables rowsDstarHadronPair(collision.globalIndex(), gItriggerParticle, @@ -391,11 +409,7 @@ struct HfCorrelatorDstarHadrons { assocParticle.pt(), timestamp, binNumber); - if constexpr (isMC) { - rowsDstarHadronPairMcRec(triggerParticle.originMcRec(), - triggerParticle.pdgBhadMotherPart(), - triggerParticle.ptBhadMotherPart()); - } + } // D-H pair loop } // collision loop From 2351a8ee617c2217e8c076ae12e57085e3accc8c Mon Sep 17 00:00:00 2001 From: Deependra Sharma Date: Sat, 28 Nov 2026 20:22:23 +0000 Subject: [PATCH 3/3] "code-check results (try1)" --- .../TableProducer/correlatorDstarHadrons.cxx | 27 ++++++------ .../HFC/Tasks/taskCorrelationDstarHadrons.cxx | 41 +++++++++++-------- 2 files changed, 37 insertions(+), 31 deletions(-) diff --git a/PWGHF/HFC/TableProducer/correlatorDstarHadrons.cxx b/PWGHF/HFC/TableProducer/correlatorDstarHadrons.cxx index 30ae6350d93..4a93689c833 100644 --- a/PWGHF/HFC/TableProducer/correlatorDstarHadrons.cxx +++ b/PWGHF/HFC/TableProducer/correlatorDstarHadrons.cxx @@ -22,6 +22,7 @@ #include "PWGHF/HFC/DataModel/CorrelationTables.h" #include "PWGHF/Utils/utilsAnalysis.h" +#include "Common/Core/RecoDecay.h" #include "Common/DataModel/Multiplicity.h" #include "Common/DataModel/TrackSelectionTables.h" @@ -53,20 +54,20 @@ using namespace o2::framework::expressions; const int nBinsPtCorrelation = 8; -const double binsPtCorrelationsDefault[nBinsPtCorrelation + 1] = {0., 2., 4., 6., 8., 12., 16., 24., 100.}; -const auto vecBinsPtCorrelationsDefault = std::vector{binsPtCorrelationsDefault, binsPtCorrelationsDefault + nBinsPtCorrelation + 1}; +const std::array binsPtCorrelationsDefault = {0., 2., 4., 6., 8., 12., 16., 24., 100.}; +const auto vecBinsPtCorrelationsDefault = std::vector{binsPtCorrelationsDefault.begin(), binsPtCorrelationsDefault.end()}; -const double signalRegionLefBoundDefault[nBinsPtCorrelation] = {0.144, 0.144, 0.144, 0.144, 0.144, 0.144, 0.144, 0.144}; -const auto vecSignalRegionLefBoundDefault = std::vector{signalRegionLefBoundDefault, signalRegionLefBoundDefault + nBinsPtCorrelation}; +const std::array signalRegionLefBoundDefault = {0.144, 0.144, 0.144, 0.144, 0.144, 0.144, 0.144, 0.144}; +const auto vecSignalRegionLefBoundDefault = std::vector{signalRegionLefBoundDefault.begin(), signalRegionLefBoundDefault.end()}; -const double signalRegionRightBoundDefault[nBinsPtCorrelation] = {0.146, 0.146, 0.146, 0.146, 0.146, 0.146, 0.146, 0.146}; -const auto vecSignalRegionRightBoundDefault = std::vector{signalRegionRightBoundDefault, signalRegionRightBoundDefault + nBinsPtCorrelation}; +const std::array signalRegionRightBoundDefault = {0.146, 0.146, 0.146, 0.146, 0.146, 0.146, 0.146, 0.146}; +const auto vecSignalRegionRightBoundDefault = std::vector{signalRegionRightBoundDefault.begin(), signalRegionRightBoundDefault.end()}; -const double sidebandRightInnerDefault[nBinsPtCorrelation] = {0.147, 0.147, 0.147, 0.147, 0.147, 0.147, 0.147, 0.147}; -const auto vecSidebandRightInnerDefault = std::vector{sidebandRightInnerDefault, sidebandRightInnerDefault + nBinsPtCorrelation}; +const std::array sidebandRightInnerDefault = {0.147, 0.147, 0.147, 0.147, 0.147, 0.147, 0.147, 0.147}; +const auto vecSidebandRightInnerDefault = std::vector{sidebandRightInnerDefault.begin(), sidebandRightInnerDefault.end()}; -const double sidebandRightOuterDefault[nBinsPtCorrelation] = {0.154, 0.154, 0.154, 0.154, 0.154, 0.154, 0.154, 0.154}; -const auto vecSidebandRightOuterDefault = std::vector{sidebandRightOuterDefault, sidebandRightOuterDefault + nBinsPtCorrelation}; +const std::array sidebandRightOuterDefault = {0.154, 0.154, 0.154, 0.154, 0.154, 0.154, 0.154, 0.154}; +const auto vecSidebandRightOuterDefault = std::vector{sidebandRightOuterDefault.begin(), sidebandRightOuterDefault.end()}; // flaging a collision if D* meson is found. struct HfCorrelatorDstarHadronsCollisionSelector { @@ -487,8 +488,8 @@ struct HfCorrelatorDstarHadrons { PROCESS_SWITCH(HfCorrelatorDstarHadrons, processMCRecSameEvent, "process only MC reconstructed same event data", false); }; -WorkflowSpec defineDataProcessing(ConfigContext const& cfgc) +WorkflowSpec defineDataProcessing(ConfigContext const& context) { - return WorkflowSpec{adaptAnalysisTask(cfgc), - adaptAnalysisTask(cfgc)}; + return WorkflowSpec{adaptAnalysisTask(context), + adaptAnalysisTask(context)}; } diff --git a/PWGHF/HFC/Tasks/taskCorrelationDstarHadrons.cxx b/PWGHF/HFC/Tasks/taskCorrelationDstarHadrons.cxx index 56f24fb5bce..8df08c58377 100644 --- a/PWGHF/HFC/Tasks/taskCorrelationDstarHadrons.cxx +++ b/PWGHF/HFC/Tasks/taskCorrelationDstarHadrons.cxx @@ -20,8 +20,11 @@ #include "PWGHF/HFC/DataModel/CorrelationTables.h" #include "PWGHF/Utils/utilsAnalysis.h" +#include "Common/Core/RecoDecay.h" + #include #include +#include #include #include #include @@ -34,8 +37,10 @@ #include #include +#include #include #include +#include #include #include @@ -55,26 +60,26 @@ const TString stringPoolBin = "Pool Bin Number;"; const int nBinsPtCorrelation = 8; -const double binsPtCorrelationsDefault[nBinsPtCorrelation + 1] = {0., 2., 4., 6., 8., 12., 16., 24., 100.}; -const auto vecBinsPtCorrelationsDefault = std::vector{binsPtCorrelationsDefault, binsPtCorrelationsDefault + nBinsPtCorrelation + 1}; +const std::array binsPtCorrelationsDefault = {0., 2., 4., 6., 8., 12., 16., 24., 100.}; +const auto vecBinsPtCorrelationsDefault = std::vector{binsPtCorrelationsDefault.begin(), binsPtCorrelationsDefault.end()}; -const double signalRegionLefBoundDefault[nBinsPtCorrelation] = {0.144, 0.144, 0.144, 0.144, 0.144, 0.144, 0.144, 0.144}; -const auto vecSignalRegionLefBoundDefault = std::vector{signalRegionLefBoundDefault, signalRegionLefBoundDefault + nBinsPtCorrelation}; +const std::array signalRegionLefBoundDefault = {0.144, 0.144, 0.144, 0.144, 0.144, 0.144, 0.144, 0.144}; +const auto vecSignalRegionLefBoundDefault = std::vector{signalRegionLefBoundDefault.begin(), signalRegionLefBoundDefault.end()}; -const double signalRegionRightBoundDefault[nBinsPtCorrelation] = {0.146, 0.146, 0.146, 0.146, 0.146, 0.146, 0.146, 0.146}; -const auto vecSignalRegionRightBoundDefault = std::vector{signalRegionRightBoundDefault, signalRegionRightBoundDefault + nBinsPtCorrelation}; +const std::array signalRegionRightBoundDefault = {0.146, 0.146, 0.146, 0.146, 0.146, 0.146, 0.146, 0.146}; +const auto vecSignalRegionRightBoundDefault = std::vector{signalRegionRightBoundDefault.begin(), signalRegionRightBoundDefault.end()}; -// const double sidebandLeftOuterDefault[nBinsPtCorrelation] = {1.7690, 1.7690, 1.7690, 1.7690, 1.7690, 1.7690, 1.7690, 1.7690}; -// const auto vecSidebandLeftOuterDefault = std::vector{sidebandLeftOuterDefault, sidebandLeftOuterDefault + nBinsPtCorrelation}; +// const std::array sidebandLeftOuterDefault = {1.7690, 1.7690, 1.7690, 1.7690, 1.7690, 1.7690, 1.7690, 1.7690}; +// const auto vecSidebandLeftOuterDefault = std::vector{sidebandLeftOuterDefault.begin(), sidebandLeftOuterDefault.end()}; -// const double sidebandLeftInnerDefault[nBinsPtCorrelation] = {1.8250, 1.8250, 1.8250, 1.8250, 1.8250, 1.8250, 1.8250, 1.8250}; -// const auto vecSidebandLeftInnerDefault = std::vector{sidebandLeftInnerDefault, sidebandLeftInnerDefault + nBinsPtCorrelation}; +// const std::array sidebandLeftInnerDefault = {1.8250, 1.8250, 1.8250, 1.8250, 1.8250, 1.8250, 1.8250, 1.8250}; +// const auto vecSidebandLeftInnerDefault = std::vector{sidebandLeftInnerDefault.begin(), sidebandLeftInnerDefault.end()}; -const double sidebandRightInnerDefault[nBinsPtCorrelation] = {0.147, 0.147, 0.147, 0.147, 0.147, 0.147, 0.147, 0.147}; -const auto vecSidebandRightInnerDefault = std::vector{sidebandRightInnerDefault, sidebandRightInnerDefault + nBinsPtCorrelation}; +const std::array sidebandRightInnerDefault = {0.147, 0.147, 0.147, 0.147, 0.147, 0.147, 0.147, 0.147}; +const auto vecSidebandRightInnerDefault = std::vector{sidebandRightInnerDefault.begin(), sidebandRightInnerDefault.end()}; -const double sidebandRightOuterDefault[nBinsPtCorrelation] = {0.154, 0.154, 0.154, 0.154, 0.154, 0.154, 0.154, 0.154}; -const auto vecSidebandRightOuterDefault = std::vector{sidebandRightOuterDefault, sidebandRightOuterDefault + nBinsPtCorrelation}; +const std::array sidebandRightOuterDefault = {0.154, 0.154, 0.154, 0.154, 0.154, 0.154, 0.154, 0.154}; +const auto vecSidebandRightOuterDefault = std::vector{sidebandRightOuterDefault.begin(), sidebandRightOuterDefault.end()}; const int npTBinsEfficiency = o2::analysis::hf_cuts_dstar_to_d0_pi::NBinsPt; const std::vector vecEfficiencyDstarDefault(npTBinsEfficiency); // line # 76 in taskCorrelationDstarHadron.cxx; why (npTBinsEfficiency+1) ? @@ -257,7 +262,7 @@ struct HfTaskCorrelationDstarHadrons { efficiencyWeightDstar = vecHistEfficiencyDstar[0]->GetBinContent(1); } else { efficiencyWeightDstar = vecHistEfficiencyDstar[0]->GetBinContent(vecHistEfficiencyDstar[0]->GetXaxis()->FindBin(ptDstar)); - if (!efficiencyWeightDstar) { + if (efficiencyWeightDstar == 0.f) { LOGF(fatal, "Dstar efficiency weight can't be zero."); } } @@ -266,7 +271,7 @@ struct HfTaskCorrelationDstarHadrons { efficiencyWeightTracks = vecHistEfficiencyTracks[0]->GetBinContent(1); } else { efficiencyWeightTracks = vecHistEfficiencyTracks[0]->GetBinContent(vecHistEfficiencyTracks[0]->GetXaxis()->FindBin(ptTrack)); - if (!efficiencyWeightTracks) { + if (efficiencyWeightTracks == 0.f) { LOGF(fatal, "track efficiency weight can't be zero"); } } @@ -341,7 +346,7 @@ struct HfTaskCorrelationDstarHadrons { PROCESS_SWITCH(HfTaskCorrelationDstarHadrons, processMcRec, " process MC Rec only", false); }; -WorkflowSpec defineDataProcessing(ConfigContext const& cfgc) +WorkflowSpec defineDataProcessing(ConfigContext const& context) { - return WorkflowSpec{adaptAnalysisTask(cfgc)}; + return WorkflowSpec{adaptAnalysisTask(context)}; }