From 0e018fd25e1670ed7681c0e351d26a9d7a84dbcb Mon Sep 17 00:00:00 2001 From: scattaru Date: Mon, 10 Nov 2025 18:24:56 +0100 Subject: [PATCH 1/4] Added base processes for correlation studies --- .../HFC/TableProducer/correlatorDsHadrons.cxx | 18 +-- .../correlatorFlowCharmHadronsReduced.cxx | 118 ++++++++++++++++++ 2 files changed, 124 insertions(+), 12 deletions(-) diff --git a/PWGHF/HFC/TableProducer/correlatorDsHadrons.cxx b/PWGHF/HFC/TableProducer/correlatorDsHadrons.cxx index 315036c2fd7..1acccb3f53f 100644 --- a/PWGHF/HFC/TableProducer/correlatorDsHadrons.cxx +++ b/PWGHF/HFC/TableProducer/correlatorDsHadrons.cxx @@ -280,12 +280,9 @@ struct HfCorrelatorDsHadrons { registry.add("hDsPoolBin", "Ds candidates pool bin", {HistType::kTH1F, {axisPoolBin}}); registry.add("hTracksPoolBin", "Particles associated pool bin", {HistType::kTH1F, {axisPoolBin}}); if (pidTrkApplied) { - registry.add("hTpcNSigmaPIDpion", "n sigma tpc for pion hypothesis", {HistType::kTH2F, {{axisPid}, {axisPtHadron}}}); - registry.add("hTpcNSigmaPIDkaon", "n sigma tpc for kaon hypothesis", {HistType::kTH2F, {{axisPid}, {axisPtHadron}}}); - registry.add("hTpcNSigmaPIDproton", "n sigma tpc for proton hypothesis", {HistType::kTH2F, {{axisPid}, {axisPtHadron}}}); - registry.add("hTofNSigmaPIDpion", "n sigma tof for pion hypothesis", {HistType::kTH2F, {{axisPid}, {axisPtHadron}}}); - registry.add("hTofNSigmaPIDkaon", "n sigma tof for kaon hypothesis", {HistType::kTH2F, {{axisPid}, {axisPtHadron}}}); - registry.add("hTofNSigmaPIDproton", "n sigma tof for proton hypothesis", {HistType::kTH2F, {{axisPid}, {axisPtHadron}}}); + registry.add("hTpcTofNSigmaPIDpion", "n sigma tpc and tof for pion hypothesis", {HistType::kTH2F, {{axisPid}, {axisPid}, {axisPtHadron}}}); + registry.add("hTpcTofNSigmaPIDkaon", "n sigma tpc and tof for kaon hypothesis", {HistType::kTH2F, {{axisPid}, {axisPid}, {axisPtHadron}}}); + registry.add("hTpcTofNSigmaPIDproton", "n sigma tpc and tof for proton hypothesis", {HistType::kTH2F, {{axisPid}, {axisPid}, {axisPtHadron}}}); } } // Histograms for MC Reco analysis @@ -840,12 +837,9 @@ struct HfCorrelatorDsHadrons { if (!passPIDSelection(track, trkPIDspecies, pidTPCMax, pidTOFMax, tofPIDThreshold, forceTOF)) { continue; } - registry.fill(HIST("hTpcNSigmaPIDpion"), track.tpcNSigmaPi(), track.pt()); - registry.fill(HIST("hTpcNSigmaPIDkaon"), track.tpcNSigmaKa(), track.pt()); - registry.fill(HIST("hTpcNSigmaPIDproton"), track.tpcNSigmaPr(), track.pt()); - registry.fill(HIST("hTofNSigmaPIDpion"), track.tofNSigmaPi(), track.pt()); - registry.fill(HIST("hTofNSigmaPIDkaon"), track.tofNSigmaKa(), track.pt()); - registry.fill(HIST("hTofNSigmaPIDproton"), track.tofNSigmaPr(), track.pt()); + registry.fill(HIST("hTpcTofNSigmaPIDpion"), track.tpcNSigmaPi(), track.tofNSigmaPi(), track.pt()); + registry.fill(HIST("hTpcTofNSigmaPIDkaon"), track.tpcNSigmaKa(), track.tofNSigmaKa(), track.pt()); + registry.fill(HIST("hTpcTofNSigmaPIDproton"), track.tpcNSigmaPr(), track.tofNSigmaPr(), track.pt()); } assocTrackReduced(indexHfcReducedCollision, track.globalIndex(), track.phi(), track.eta(), track.pt() * track.sign()); assocTrackSelInfo(indexHfcReducedCollision, track.tpcNClsCrossedRows(), track.itsClusterMap(), track.itsNCls(), track.dcaXY(), track.dcaZ()); diff --git a/PWGHF/HFC/TableProducer/correlatorFlowCharmHadronsReduced.cxx b/PWGHF/HFC/TableProducer/correlatorFlowCharmHadronsReduced.cxx index 63a34e84fc3..9a42960d447 100644 --- a/PWGHF/HFC/TableProducer/correlatorFlowCharmHadronsReduced.cxx +++ b/PWGHF/HFC/TableProducer/correlatorFlowCharmHadronsReduced.cxx @@ -375,6 +375,93 @@ struct HfCorrelatorFlowCharmHadronsReduced { } } + /// Correlations for Same Event pairs + /// \param poolBin collision pool bin based on multiplicity and z-vertex position + /// \param trigCandsThisColl are the selected trigger candidates in the collision + /// \param assocTracksThisColl are the selected associated tracks in the collision + template + void doCorrelationsSameEvent(int poolBin, + const TTrigCand& trigCandsThisColl, + const TTrackAssoc& assocTracksThisColl) + { + for (const auto& trigCand : trigCandsThisColl) { + double const ptTrig = trigCand.ptTrig(); + if constexpr (requires { trigCand.bdtScore0Trig(); }) { // ML selection on bkg score for Charm-Had case + if (!isSelBdtScoreCut(trigCand, ptTrig)) { + continue; + } + } + + for (const auto& assTrk : assocTracksThisColl) { + // TODO: Remove Ds daughters + /*if (assTrk.originTrackId() == candidate.prong0Id() || + assTrk.originTrackId() == candidate.prong1Id() || + assTrk.originTrackId() == candidate.prong2Id()) { + continue; + }*/ + // TODO: DCA cut + double deltaPhi = RecoDecay::constrainAngle(assTrk.phiAssoc() - trigCand.phiTrig(), -o2::constants::math::PIHalf); + double deltaEta = assTrk.etaAssoc() - trigCand.etaTrig(); + if constexpr (FillSparses) { + if constexpr (requires { trigCand.bdtScore0Trig(); }) { // Separate Charm-Had and Had-Had cases + registry.fill(HIST("hSparseCorrelationsSECharmHad"), poolBin, ptTrig, assTrk.ptAssoc(), deltaEta, + deltaPhi, trigCand.invMassTrig()); + } else { + registry.fill(HIST("hSparseCorrelationsSEHadHad"), poolBin, ptTrig, assTrk.ptAssoc(), deltaEta, deltaPhi); + } + } + } + } + } + + /// Correlations for Mixed Event pairs + /// \param collisions are the selected collisions + /// \param trigCands are the trigger candidates + /// \param assocTracks are the associated tracks + /// \param binPolicy is the binning policy for the correlation + template + void doCorrelationsMixedEvent(const TCollision& collisions, + const TTrigCand& trigCands, + const TTrackAssoc& assocTracks, + TBinningType binPolicy) + { + auto tracksTuple = std::make_tuple(trigCands, assocTracks); + + Pair pairData{binPolicy, numberEventsMixed, -1, collisions, tracksTuple, &cache}; + + for (const auto& [c1, tracks1, c2, tracks2] : pairData) { + if (tracks1.size() == 0) { + continue; + } + + int poolBin = binPolicy.getBin({c2.posZ(), c2.multiplicity()}); + int poolBinTrigCand = binPolicy.getBin({c1.posZ(), c1.multiplicity()}); + + if (poolBin != poolBinTrigCand) { + LOGF(info, "Error, poolBins are different"); + continue; + } + + for (const auto& [trigCand, assTrk] : o2::soa::combinations(o2::soa::CombinationsFullIndexPolicy(tracks1, tracks2))) { + if (!isSelBdtScoreCut(trigCand, trigCand.ptTrig())) { + continue; + } + LOGF(info, "Mixed event tracks pair: (%d, %d) from events (%d, %d), track event: (%d, %d)", trigCand.index(), assTrk.index(), c1.index(), c2.index(), trigCand.hfcRedCorrCollId(), assTrk.hfcRedCorrCollId()); + + double deltaPhi = RecoDecay::constrainAngle(assTrk.phiAssoc() - trigCand.phiTrig(), -o2::constants::math::PIHalf); + double deltaEta = assTrk.etaAssoc() - trigCand.etaTrig(); + if constexpr (FillSparses) { + if constexpr (requires { trigCand.bdtScore0Trig(); }) { // Separate Charm-Had and Had-Had cases + registry.fill(HIST("hSparseCorrelationsMECharmHad"), poolBin, trigCand.ptTrig(), assTrk.ptAssoc(), deltaEta, + deltaPhi, trigCand.invMassTrig()); + } else { + registry.fill(HIST("hSparseCorrelationsMEHadHad"), poolBin, trigCand.ptTrig(), assTrk.ptAssoc(), deltaEta, deltaPhi); + } + } + } + } + } + void processSameEventCharmHadWMultMix(SameEvtPairsChHad::iterator const& pair, aod::HfcRedTrigCharms const&, aod::HfcRedCorrColls const&) @@ -520,6 +607,37 @@ struct HfCorrelatorFlowCharmHadronsReduced { } } PROCESS_SWITCH(HfCorrelatorFlowCharmHadronsReduced, processCharmTriggers, "Process charm trigger info", false); + + void processSameEventCharmHadWCentMixBase(aod::HfcRedCorrColls const& collisions, + TrigCharmCands const& candidates, + AssocTracks const& tracks) + { + BinningCentPosZ binPolicyPosZCent{{zPoolBins, centPoolBins}, true}; + + for (const auto& collision : collisions) { + if (collision.centrality() < centralityMin || collision.centrality() > centralityMax) { + continue; + } + int poolBin = binPolicyPosZCent.getBin({collision.posZ(), collision.multiplicity()}); + + auto thisCollId = collision.globalIndex(); + auto candsThisColl = candidates.sliceBy(trigCharmCandsPerCol, thisCollId); + auto tracksThisColl = tracks.sliceBy(assocTracksPerCol, thisCollId); + + doCorrelationsSameEvent(poolBin, candsThisColl, tracksThisColl); + } + } + PROCESS_SWITCH(HfCorrelatorFlowCharmHadronsReduced, processSameEventCharmHadWCentMixBase, "Process Same Event base", false); + + void processMixedEventCharmHadWCentMixBase(aod::HfcRedCorrColls const& collisions, + TrigCharmCands const& candidates, + AssocTracks const& tracks) + { + BinningCentPosZ binPolicyPosZCent{{zPoolBins, centPoolBins}, true}; + + doCorrelationsMixedEvent(collisions, candidates, tracks, binPolicyPosZCent); + } + PROCESS_SWITCH(HfCorrelatorFlowCharmHadronsReduced, processMixedEventCharmHadWCentMixBase, "Process Mixed Event base", false); }; WorkflowSpec defineDataProcessing(ConfigContext const& cfgc) From e6181a7faf19fb6761c5ed5aecbfac25e356bf2b Mon Sep 17 00:00:00 2001 From: scattaru Date: Tue, 11 Nov 2025 11:35:25 +0100 Subject: [PATCH 2/4] Fix histogram --- PWGHF/HFC/TableProducer/correlatorFlowCharmHadronsReduced.cxx | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/PWGHF/HFC/TableProducer/correlatorFlowCharmHadronsReduced.cxx b/PWGHF/HFC/TableProducer/correlatorFlowCharmHadronsReduced.cxx index 9a42960d447..6e35180e390 100644 --- a/PWGHF/HFC/TableProducer/correlatorFlowCharmHadronsReduced.cxx +++ b/PWGHF/HFC/TableProducer/correlatorFlowCharmHadronsReduced.cxx @@ -199,9 +199,9 @@ struct HfCorrelatorFlowCharmHadronsReduced { } else { axes.insert(axes.end(), {axisInvMass}); // axes.insert(axes.end(), {axisInvMass, axisMlOne, axisMlTwo}); - if (doprocessSameEventCharmHadWCentMix || doprocessSameEventCharmHadWMultMix) { + if (doprocessSameEventCharmHadWCentMix || doprocessSameEventCharmHadWMultMix || doprocessSameEventCharmHadWCentMixBase) { registry.add("hSparseCorrelationsSECharmHad", "THn for SE Charm-Had correlations", HistType::kTHnSparseF, axes); - } else if (doprocessMixedEventCharmHadWCentMix || doprocessMixedEventCharmHadWMultMix) { + } else if (doprocessMixedEventCharmHadWCentMix || doprocessMixedEventCharmHadWMultMix || doprocessMixedEventCharmHadWCentMixBase) { registry.add("hSparseCorrelationsMECharmHad", "THn for ME Charm-Had correlations", HistType::kTHnSparseF, axes); } if (doprocessCharmTriggers) { From e683a3f784d7aa18d00d9a9a46649d946e4ac142 Mon Sep 17 00:00:00 2001 From: scattaru Date: Tue, 11 Nov 2025 12:10:39 +0100 Subject: [PATCH 3/4] Fix histogram --- PWGHF/HFC/TableProducer/correlatorDsHadrons.cxx | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/PWGHF/HFC/TableProducer/correlatorDsHadrons.cxx b/PWGHF/HFC/TableProducer/correlatorDsHadrons.cxx index 1acccb3f53f..e6c5b0407e8 100644 --- a/PWGHF/HFC/TableProducer/correlatorDsHadrons.cxx +++ b/PWGHF/HFC/TableProducer/correlatorDsHadrons.cxx @@ -280,9 +280,9 @@ struct HfCorrelatorDsHadrons { registry.add("hDsPoolBin", "Ds candidates pool bin", {HistType::kTH1F, {axisPoolBin}}); registry.add("hTracksPoolBin", "Particles associated pool bin", {HistType::kTH1F, {axisPoolBin}}); if (pidTrkApplied) { - registry.add("hTpcTofNSigmaPIDpion", "n sigma tpc and tof for pion hypothesis", {HistType::kTH2F, {{axisPid}, {axisPid}, {axisPtHadron}}}); - registry.add("hTpcTofNSigmaPIDkaon", "n sigma tpc and tof for kaon hypothesis", {HistType::kTH2F, {{axisPid}, {axisPid}, {axisPtHadron}}}); - registry.add("hTpcTofNSigmaPIDproton", "n sigma tpc and tof for proton hypothesis", {HistType::kTH2F, {{axisPid}, {axisPid}, {axisPtHadron}}}); + registry.add("hTpcTofNSigmaPIDpion", "n sigma tpc and tof for pion hypothesis", {HistType::kTH3F, {{axisPid}, {axisPid}, {axisPtHadron}}}); + registry.add("hTpcTofNSigmaPIDkaon", "n sigma tpc and tof for kaon hypothesis", {HistType::kTH3F, {{axisPid}, {axisPid}, {axisPtHadron}}}); + registry.add("hTpcTofNSigmaPIDproton", "n sigma tpc and tof for proton hypothesis", {HistType::kTH3F, {{axisPid}, {axisPid}, {axisPtHadron}}}); } } // Histograms for MC Reco analysis From fbf9f35a28373b4c14a03e36e6b3cf4632ef14f7 Mon Sep 17 00:00:00 2001 From: Samuele Cattaruzzi <124249902+scattaru@users.noreply.github.com> Date: Wed, 12 Nov 2025 15:17:56 +0100 Subject: [PATCH 4/4] Update correlatorDsHadrons.cxx --- PWGHF/HFC/TableProducer/correlatorDsHadrons.cxx | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/PWGHF/HFC/TableProducer/correlatorDsHadrons.cxx b/PWGHF/HFC/TableProducer/correlatorDsHadrons.cxx index e6c5b0407e8..0d16489b562 100644 --- a/PWGHF/HFC/TableProducer/correlatorDsHadrons.cxx +++ b/PWGHF/HFC/TableProducer/correlatorDsHadrons.cxx @@ -280,9 +280,9 @@ struct HfCorrelatorDsHadrons { registry.add("hDsPoolBin", "Ds candidates pool bin", {HistType::kTH1F, {axisPoolBin}}); registry.add("hTracksPoolBin", "Particles associated pool bin", {HistType::kTH1F, {axisPoolBin}}); if (pidTrkApplied) { - registry.add("hTpcTofNSigmaPIDpion", "n sigma tpc and tof for pion hypothesis", {HistType::kTH3F, {{axisPid}, {axisPid}, {axisPtHadron}}}); - registry.add("hTpcTofNSigmaPIDkaon", "n sigma tpc and tof for kaon hypothesis", {HistType::kTH3F, {{axisPid}, {axisPid}, {axisPtHadron}}}); - registry.add("hTpcTofNSigmaPIDproton", "n sigma tpc and tof for proton hypothesis", {HistType::kTH3F, {{axisPid}, {axisPid}, {axisPtHadron}}}); + registry.add("hTpcTofNSigmaPidPion", "n sigma tpc and tof for pion hypothesis", {HistType::kTH3F, {{axisPid}, {axisPid}, {axisPtHadron}}}); + registry.add("hTpcTofNSigmaPidKaon", "n sigma tpc and tof for kaon hypothesis", {HistType::kTH3F, {{axisPid}, {axisPid}, {axisPtHadron}}}); + registry.add("hTpcTofNSigmaPidProton", "n sigma tpc and tof for proton hypothesis", {HistType::kTH3F, {{axisPid}, {axisPid}, {axisPtHadron}}}); } } // Histograms for MC Reco analysis @@ -837,9 +837,9 @@ struct HfCorrelatorDsHadrons { if (!passPIDSelection(track, trkPIDspecies, pidTPCMax, pidTOFMax, tofPIDThreshold, forceTOF)) { continue; } - registry.fill(HIST("hTpcTofNSigmaPIDpion"), track.tpcNSigmaPi(), track.tofNSigmaPi(), track.pt()); - registry.fill(HIST("hTpcTofNSigmaPIDkaon"), track.tpcNSigmaKa(), track.tofNSigmaKa(), track.pt()); - registry.fill(HIST("hTpcTofNSigmaPIDproton"), track.tpcNSigmaPr(), track.tofNSigmaPr(), track.pt()); + registry.fill(HIST("hTpcTofNSigmaPidPion"), track.tpcNSigmaPi(), track.tofNSigmaPi(), track.pt()); + registry.fill(HIST("hTpcTofNSigmaPidKaon"), track.tpcNSigmaKa(), track.tofNSigmaKa(), track.pt()); + registry.fill(HIST("hTpcTofNSigmaPidProton"), track.tpcNSigmaPr(), track.tofNSigmaPr(), track.pt()); } assocTrackReduced(indexHfcReducedCollision, track.globalIndex(), track.phi(), track.eta(), track.pt() * track.sign()); assocTrackSelInfo(indexHfcReducedCollision, track.tpcNClsCrossedRows(), track.itsClusterMap(), track.itsNCls(), track.dcaXY(), track.dcaZ());