From ce10844a98d0ec3e99230b601b309074b36d214d Mon Sep 17 00:00:00 2001 From: marcellocosti Date: Mon, 15 Sep 2025 18:55:34 +0200 Subject: [PATCH 01/15] Modify data creator structure --- .../DataModel/DerivedDataCorrelationTables.h | 72 ++- .../correlatorFlowCharmHadronsReduced.cxx | 61 +- .../derivedDataCreatorCorrelationsReduced.cxx | 578 ++++++++++++++---- 3 files changed, 552 insertions(+), 159 deletions(-) diff --git a/PWGHF/HFC/DataModel/DerivedDataCorrelationTables.h b/PWGHF/HFC/DataModel/DerivedDataCorrelationTables.h index 40274d89cef..d5367f6fbe5 100644 --- a/PWGHF/HFC/DataModel/DerivedDataCorrelationTables.h +++ b/PWGHF/HFC/DataModel/DerivedDataCorrelationTables.h @@ -88,27 +88,28 @@ DECLARE_SOA_TABLE(HfcRedCharmTrigs, "AOD", "HFCREDCHARMTRIG", //! Table with cha aod::hf_candidate_reduced::EtaCand, aod::hf_candidate_reduced::PtCand, aod::hf_candidate_reduced::InvMassCand, - aod::hf_candidate_reduced::Prong0Id, - aod::hf_candidate_reduced::Prong1Id, - aod::hf_candidate_reduced::Prong2Id); - -DECLARE_SOA_TABLE(HfcRedCharmMls, "AOD", "HFCREDCHARMML", //! Table with charm hadron candidate selection info - soa::Index<>, - aod::hf_candidate_reduced::HfcRedFlowCollId, aod::hf_candidate_reduced::BdtScore0, aod::hf_candidate_reduced::BdtScore1); namespace hf_assoc_track_reduced { -DECLARE_SOA_COLUMN(OriginTrackId, originTrackId, int); //! Original track index -DECLARE_SOA_COLUMN(NTpcCrossedRows, nTpcCrossedRows, int); //! Number of crossed TPC Rows -DECLARE_SOA_COLUMN(ItsClusterMap, itsClusterMap, int); //! ITS cluster map, one bit per a layer, starting from the innermost -DECLARE_SOA_COLUMN(ItsNCls, itsNCls, int); //! Number of ITS clusters -DECLARE_SOA_COLUMN(EtaAssocTrack, etaAssocTrack, float); //! Eta of the track -DECLARE_SOA_COLUMN(PhiAssocTrack, phiAssocTrack, float); //! Phi of the track -DECLARE_SOA_COLUMN(PtAssocTrack, ptAssocTrack, float); //! Pt of the track -DECLARE_SOA_COLUMN(DcaXY, dcaXY, float); //! Impact parameter in XY of the track to the primary vertex -DECLARE_SOA_COLUMN(DcaZ, dcaZ, float); //! Impact parameter in Z of the track to the primary vertex +DECLARE_SOA_COLUMN(OriginTrackId, originTrackId, int); //! Original track index +DECLARE_SOA_COLUMN(NTpcCrossedRows, nTpcCrossedRows, UChar_t); //! Number of crossed TPC Rows +DECLARE_SOA_COLUMN(ItsClusterMap, itsClusterMap, UChar_t); //! ITS cluster map, one bit per a layer, starting from the innermost +DECLARE_SOA_COLUMN(ItsNCls, itsNCls, UChar_t); //! Number of ITS clusters +DECLARE_SOA_COLUMN(EtaAssocTrack, etaAssocTrack, float); //! Eta of the track +DECLARE_SOA_COLUMN(PhiAssocTrack, phiAssocTrack, float); //! Phi of the track +DECLARE_SOA_COLUMN(PtAssocTrack, ptAssocTrack, float); //! Pt of the track +DECLARE_SOA_COLUMN(DcaXY, dcaXY, float); //! Impact parameter in XY of the track to the primary vertex +DECLARE_SOA_COLUMN(DcaZ, dcaZ, float); //! Impact parameter in Z of the track to the primary vertex +DECLARE_SOA_COLUMN(NTpcCrossedRowsTrig, nTpcCrossedRowsTrig, UChar_t); //! Number of crossed TPC Rows +DECLARE_SOA_COLUMN(ItsClusterMapTrig, itsClusterMapTrig, UChar_t); //! ITS cluster map, one bit per a layer, starting from the innermost +DECLARE_SOA_COLUMN(ItsNClsTrig, itsNClsTrig, UChar_t); //! Number of ITS clusters +DECLARE_SOA_COLUMN(EtaAssocTrackTrig, etaAssocTrackTrig, float); //! Eta of the track +DECLARE_SOA_COLUMN(PhiAssocTrackTrig, phiAssocTrackTrig, float); //! Phi of the track +DECLARE_SOA_COLUMN(PtAssocTrackTrig, ptAssocTrackTrig, float); //! Pt of the track +DECLARE_SOA_COLUMN(DcaXYTrig, dcaXYTrig, float); //! Impact parameter in XY of the track to the primary vertex +DECLARE_SOA_COLUMN(DcaZTrig, dcaZTrig, float); //! Impact parameter in Z of the track to the primary vertex } // namespace hf_assoc_track_reduced DECLARE_SOA_TABLE(AssocTrackReds, "AOD", "ASSOCTRACKRED", //! Table with associated track info soa::Index<>, @@ -130,14 +131,9 @@ DECLARE_SOA_TABLE(AssocTrackSels, "AOD", "ASSOCTRACKSEL", //! Table with associa DECLARE_SOA_TABLE(HfcRedTrkAssocs, "AOD", "HFCREDTRKASSOC", //! Table with associated track info soa::Index<>, aod::hf_candidate_reduced::HfcRedFlowCollId, - aod::hf_assoc_track_reduced::OriginTrackId, aod::hf_assoc_track_reduced::PhiAssocTrack, aod::hf_assoc_track_reduced::EtaAssocTrack, - aod::hf_assoc_track_reduced::PtAssocTrack); - -DECLARE_SOA_TABLE(HfcRedTrkSels, "AOD", "HFCREDTRKSEL", //! Table with associated track info - soa::Index<>, - aod::hf_candidate_reduced::HfcRedFlowCollId, + aod::hf_assoc_track_reduced::PtAssocTrack, aod::hf_assoc_track_reduced::NTpcCrossedRows, aod::hf_assoc_track_reduced::ItsClusterMap, aod::hf_assoc_track_reduced::ItsNCls, @@ -155,6 +151,38 @@ DECLARE_SOA_COLUMN(DeltaEta, deltaEta, float); DECLARE_SOA_COLUMN(PoolBin, poolBin, int); //! Pool Bin for the MixedEvent } // namespace hf_correlation_charm_hadron_reduced +DECLARE_SOA_TABLE(HfcRedSEChHads, "AOD", "HFCREDSECHHAD", //! Table with Same Event Charm-Hadron pairs information + aod::hf_correlation_charm_hadron_reduced::DeltaEta, + aod::hf_correlation_charm_hadron_reduced::DeltaPhi, + aod::hf_correlation_charm_hadron_reduced::PoolBin, + aod::hf_candidate_reduced::PtCand, + aod::hf_candidate_reduced::InvMassCand, + aod::hf_candidate_reduced::BdtScore0, + aod::hf_candidate_reduced::BdtScore1, + aod::hf_assoc_track_reduced::PtAssocTrack, + aod::hf_assoc_track_reduced::NTpcCrossedRows, + aod::hf_assoc_track_reduced::ItsClusterMap, + aod::hf_assoc_track_reduced::ItsNCls, + aod::hf_assoc_track_reduced::DcaXY, + aod::hf_assoc_track_reduced::DcaZ); + +DECLARE_SOA_TABLE(HfcRedSEHadHads, "AOD", "HFCREDSEHADHAD", //! Table with Same Event Hadron-Hadron pairs information + aod::hf_correlation_charm_hadron_reduced::DeltaEta, + aod::hf_correlation_charm_hadron_reduced::DeltaPhi, + aod::hf_correlation_charm_hadron_reduced::PoolBin, + aod::hf_assoc_track_reduced::PtAssocTrackTrig, + aod::hf_assoc_track_reduced::NTpcCrossedRowsTrig, + aod::hf_assoc_track_reduced::ItsClusterMapTrig, + aod::hf_assoc_track_reduced::ItsNClsTrig, + aod::hf_assoc_track_reduced::DcaXYTrig, + aod::hf_assoc_track_reduced::DcaZTrig, + aod::hf_assoc_track_reduced::PtAssocTrack, + aod::hf_assoc_track_reduced::NTpcCrossedRows, + aod::hf_assoc_track_reduced::ItsClusterMap, + aod::hf_assoc_track_reduced::ItsNCls, + aod::hf_assoc_track_reduced::DcaXY, + aod::hf_assoc_track_reduced::DcaZ); + DECLARE_SOA_TABLE(HfcRedChHads, "AOD", "HFCREDCHHAD", //! Charm-Hadron pairs information aod::hf_correlation_charm_hadron_reduced::CharmTrigId, aod::hf_correlation_charm_hadron_reduced::TrkAssocId, diff --git a/PWGHF/HFC/TableProducer/correlatorFlowCharmHadronsReduced.cxx b/PWGHF/HFC/TableProducer/correlatorFlowCharmHadronsReduced.cxx index e1d1662924e..70dac06e48b 100644 --- a/PWGHF/HFC/TableProducer/correlatorFlowCharmHadronsReduced.cxx +++ b/PWGHF/HFC/TableProducer/correlatorFlowCharmHadronsReduced.cxx @@ -67,10 +67,13 @@ struct HfCorrelatorFlowCharmHadronsReduced { Configurable dcaZTrackMax{"dcaZTrackMax", 1., "max. track DCA Z"}; Configurable tpcCrossedRowsMin{"tpcCrossedRowsMin", 1, "min. TPC crossed rows"}; Configurable itsNClsMin{"itsNClsMin", 1, "min. ITS clusters"}; + Configurable downSamplePairsME{"downSamplePairsME", 1., "Fraction of ME pairs to keep"}; + Configurable ptMaxForDownSampleME{"ptMaxForDownSampleME", 10., "Maximum pt for the application of the downsampling factor"}; + Configurable centMaxForDownSampleME{"centMaxForDownSampleME", 10., "Maximum centrality for the application of the downsampling factor"}; SliceCache cache; - using AssocTracks = soa::Filtered>; + using AssocTracks = soa::Filtered; Filter filterSelectTrackData = (nabs(aod::hf_assoc_track_reduced::dcaXY) < dcaXYTrackMax) && (nabs(aod::hf_assoc_track_reduced::dcaZ) < dcaZTrackMax) && (aod::hf_assoc_track_reduced::nTpcCrossedRows > tpcCrossedRowsMin) && (aod::hf_assoc_track_reduced::itsNCls > itsNClsMin); @@ -211,20 +214,21 @@ struct HfCorrelatorFlowCharmHadronsReduced { return poolBin; } - /// Reject daughter-track pairs and same-track pairs - /// \param cand is the trigger candidate - /// \param track is the associated track - template - bool rejSameEvtPair(const TTrigPart& cand, const TTrack& track) - { - if constexpr (requires { cand.originTrackId(); }) { - // Remove same track pairs for Had-Had correlations - return (cand.originTrackId() == track.originTrackId()); - } else { - // Remove pairs with 2- and 3-prong daughters (prong2Id returns -1 for 2-prongs) - return ((cand.prong0Id() == track.originTrackId()) || (cand.prong1Id() == track.originTrackId()) || (cand.prong2Id() == track.originTrackId())); - } - } + // /// Reject daughter-track pairs and same-track pairs + // /// \param cand is the trigger candidate + // /// \param track is the associated track + // template + // bool rejSameEvtPair(const TTrigPart& cand, const TTrack& track) + // { + // if constexpr (requires { cand.originTrackId(); }) { + // // Remove same track pairs for Had-Had correlations + // return (cand.originTrackId() == track.originTrackId()); + // } else { + // return false; + // // Remove pairs with 2- and 3-prong daughters (prong2Id returns -1 for 2-prongs) + // // return ((cand.prong0Id() == track.originTrackId()) || (cand.prong1Id() == track.originTrackId()) || (cand.prong2Id() == track.originTrackId())); + // } + // } /// Slice trigger candidates by collision /// \param cands are the trigger candidates @@ -251,7 +255,8 @@ struct HfCorrelatorFlowCharmHadronsReduced { double deltaEta = getEta(assocTrack) - getEta(trigCand); double deltaPhi = RecoDecay::constrainAngle(getPhi(assocTrack) - getPhi(trigCand), -o2::constants::math::PIHalf); if (fillTables) { - entryCharmHadPair(trigCand.globalIndex(), assocTrack.globalIndex(), deltaEta, deltaPhi, poolBin); + entryCharmHadPair(-1, -1, deltaEta, deltaPhi, poolBin); + // entryCharmHadPair(trigCand.globalIndex(), assocTrack.globalIndex(), deltaEta, deltaPhi, poolBin); } if (fillSparses) { if constexpr (isMixedEvent) { @@ -278,7 +283,8 @@ struct HfCorrelatorFlowCharmHadronsReduced { double deltaEta = getEta(assocTrack) - getEta(trigCand); double deltaPhi = RecoDecay::constrainAngle(getPhi(assocTrack) - getPhi(trigCand), -o2::constants::math::PIHalf); if (fillTables) { - entryHadHadPair(trigCand.globalIndex(), assocTrack.globalIndex(), deltaEta, deltaPhi, poolBin); + // entryHadHadPair(trigCand.globalIndex(), assocTrack.globalIndex(), deltaEta, deltaPhi, poolBin); + entryHadHadPair(-1, -1, deltaEta, deltaPhi, poolBin); } if (fillSparses) { if constexpr (isMixedEvent) { @@ -314,9 +320,9 @@ struct HfCorrelatorFlowCharmHadronsReduced { registry.fill(HIST("hPhiVsPtTrig"), RecoDecay::constrainAngle(getPhi(trigCand), -o2::constants::math::PIHalf), getPt(trigCand)); registry.fill(HIST("hEtaVsPtTrig"), getEta(trigCand), getPt(trigCand)); for (const auto& assocTrack : assocTracksThisColl) { - if (rejSameEvtPair(trigCand, assocTrack)) { - continue; - } + // if (rejSameEvtPair(trigCand, assocTrack)) { + // continue; + // } double deltaEta = getEta(assocTrack) - getEta(trigCand); if (std::abs(deltaEta) < deltaEtaAbsMin || std::abs(deltaEta) > deltaEtaAbsMax) { continue; @@ -385,6 +391,13 @@ struct HfCorrelatorFlowCharmHadronsReduced { if (std::abs(deltaEta) < deltaEtaAbsMin || std::abs(deltaEta) > deltaEtaAbsMax) { continue; } + if (downSamplePairsME < 1.) { + float pseudoRndm = getPt(assocTrack) * 1000. - static_cast(getPt(assocTrack) * 1000); + if (getPt(trigCand) < ptMaxForDownSampleME && trigColl.centrality() < centMaxForDownSampleME && + assocColl.centrality() < centMaxForDownSampleME && pseudoRndm >= downSamplePairsME) { + continue; + } + } // LOGF(info, "Mixed event tracks pair: (%d, %d) from events (%d, %d), track event: (%d, %d)", trigCand.index(), assocTrack.index(), trigColl.index(), assocColl.index(), trigCand.hfcRedFlowCollId(), assocTrack.hfcRedFlowCollId()); if constexpr (std::is_same_v) { fillHadHadInfo(trigCand, assocTrack, poolBinCharm); @@ -396,7 +409,7 @@ struct HfCorrelatorFlowCharmHadronsReduced { } void processSameEventCharmHadWCentMix(aod::HfcRedFlowColls const& collisions, - soa::Join const& candidates, + aod::HfcRedCharmTrigs const& candidates, AssocTracks const& tracks) { ColumnBinningPolicy corrBinningCent{{zPoolBins, centPoolBins}, true}; @@ -405,7 +418,7 @@ struct HfCorrelatorFlowCharmHadronsReduced { PROCESS_SWITCH(HfCorrelatorFlowCharmHadronsReduced, processSameEventCharmHadWCentMix, "Process Same Event for Charm-Had with centrality pools", true); void processSameEventCharmHadWMultMix(aod::HfcRedFlowColls const& collisions, - soa::Join const& candidates, + aod::HfcRedCharmTrigs const& candidates, AssocTracks const& tracks) { ColumnBinningPolicy corrBinningMult{{zPoolBins, multPoolBins}, true}; @@ -414,7 +427,7 @@ struct HfCorrelatorFlowCharmHadronsReduced { PROCESS_SWITCH(HfCorrelatorFlowCharmHadronsReduced, processSameEventCharmHadWMultMix, "Process Same Event for Charm-Had with multiplicity pools", false); void processMixedEventCharmHadWCentMix(aod::HfcRedFlowColls const& collisions, - soa::Join const& candidates, + aod::HfcRedCharmTrigs const& candidates, AssocTracks const& tracks) { ColumnBinningPolicy corrBinningCent{{zPoolBins, centPoolBins}, true}; @@ -423,7 +436,7 @@ struct HfCorrelatorFlowCharmHadronsReduced { PROCESS_SWITCH(HfCorrelatorFlowCharmHadronsReduced, processMixedEventCharmHadWCentMix, "Process Mixed Event for Charm-Had with centrality pools", false); void processMixedEventCharmHadWMultMix(aod::HfcRedFlowColls const& collisions, - soa::Join const& candidates, + aod::HfcRedCharmTrigs const& candidates, AssocTracks const& tracks) { ColumnBinningPolicy corrBinningMult{{zPoolBins, multPoolBins}, true}; diff --git a/PWGHF/HFC/TableProducer/derivedDataCreatorCorrelationsReduced.cxx b/PWGHF/HFC/TableProducer/derivedDataCreatorCorrelationsReduced.cxx index e5bb19f2e9e..5e1cb2b8d48 100644 --- a/PWGHF/HFC/TableProducer/derivedDataCreatorCorrelationsReduced.cxx +++ b/PWGHF/HFC/TableProducer/derivedDataCreatorCorrelationsReduced.cxx @@ -51,35 +51,59 @@ using namespace o2::framework::expressions; using namespace o2::hf_centrality; using namespace o2::hf_evsel; -enum DecayChannel { +using BinningTypeDerivedCent = ColumnBinningPolicy; +using BinningTypeDerivedMult = ColumnBinningPolicy; + +enum CandType { DplusToPiKPi = 0, DsToKKPi, DsToPiKK, D0ToPiK, - D0ToKPi + D0ToKPi, + Hadron +}; + +enum PoolBinningPolicy { + Centrality = 0, + Multiplicity }; /// Code to select collisions with at least one Ds meson struct HfDerivedDataCreatorCorrelationsReduced { Produces rowCollisions; Produces rowCharmCandidates; - Produces rowCharmCandidatesMl; Produces rowAssocTrackReduced; - Produces rowAssocTrackSelInfo; + Produces entryCharmHadSEPair; + Produces entryHadHadSEPair; Configurable centEstimator{"centEstimator", 2, "Centrality estimation (FT0A: 1, FT0C: 2, FT0M: 3, FV0A: 4)"}; - Configurable selectionFlag{"selectionFlag", 1, "Selection Flag for hadron (e.g. 1 for skimming, 3 for topo. and kine., 7 for PID)"}; - Configurable forceCharmInCollision{"forceCharmInCollision", false, "Flag to force charm in collision"}; + Configurable selectionFlag{"selectionFlag", 15, "Selection Flag for hadron (ML score tables are required to run the task)"}; + Configurable forceCharmInCollision{"forceCharmInCollision", true, "Flag to force charm in collision"}; + Configurable useCentMixing{"useCentMixing", true, "Flag to use centrality mixing"}; + Configurable useMultMixing{"useMultMixing", false, "Flag to use multiplicity mixing"}; Configurable ccdbUrl{"ccdbUrl", "http://alice-ccdb.cern.ch", "url of the ccdb repository"}; Configurable> classMl{"classMl", {0, 2}, "Indexes of BDT scores to be stored. Two indexes max."}; Configurable yCandMax{"yCandMax", 0.8, "max. cand. rapidity"}; Configurable ptCandMin{"ptCandMin", 1., "min. cand. pT"}; Configurable ptCandMax{"ptCandMax", 24., "max. cand. pT"}; + Configurable tpcNClsCrossedRowsMin{"tpcNClsCrossedRowsMin", 70, "min. TPC crossed rows for associated tracks"}; Configurable etaTrackMax{"etaTrackMax", 1., "max. track eta"}; Configurable ptTrackMin{"ptTrackMin", 0.15, "min. track pT"}; Configurable ptTrackMax{"ptTrackMax", 5., "max. track pT"}; Configurable dcaXYTrackMax{"dcaXYTrackMax", 1., "max. track DCA XY"}; Configurable dcaZTrackMax{"dcaZTrackMax", 1., "max. track DCA Z"}; + Configurable deltaEtaAbsMin{"deltaEtaAbsMin", 0.5, "min. pair delta eta"}; + Configurable deltaEtaAbsMax{"deltaEtaAbsMax", 2., "max. pair delta eta"}; + Configurable downSampleTracksFactorSE{"downSampleTracksFactorSE", 1., "Fraction of associated tracks to keep"}; + Configurable ptMaxForDownSampleSE{"ptMaxForDownSampleSE", 10., "Maximum pt for the application of the downsampling factor"}; + Configurable centMaxForDownSampleSE{"centMaxForDownSampleSE", 10., "Maximum centrality for the application of the downsampling factor"}; + Configurable downSampleTracksFactorME{"downSampleTracksFactorME", 1., "Fraction of associated tracks to keep"}; + Configurable ptMaxForDownSampleME{"ptMaxForDownSampleME", 10., "Maximum pt for the application of the downsampling factor"}; + Configurable centMaxForDownSampleME{"centMaxForDownSampleME", 10., "Maximum centrality for the application of the downsampling factor"}; + Configurable> binsPtTrig{"binsPtTrig", std::vector{1., 3., 5., 8., 16., 36.}, "pT bin limits for trigger candidates"}; + Configurable> binsPtAssoc{"binsPtAssoc", std::vector{0.3, 1., 2., 50.}, "pT bin limits for associated particles"}; + Configurable fillSparses{"fillSparses", true, "Fill sparse histograms"}; + Configurable fillTables{"fillTables", false, "Fill tables"}; HfHelper hfHelper; HfEventSelection hfEvSel; // event selection and monitoring @@ -89,9 +113,9 @@ struct HfDerivedDataCreatorCorrelationsReduced { double massCharm{0.}; using CollsWithCentMult = soa::Join; - using CandDsDataWMl = soa::Filtered>; - using CandDplusDataWMl = soa::Filtered>; - using CandD0DataWMl = soa::Filtered>; + using CandDsData = soa::Filtered>; + using CandDplusData = soa::Filtered>; + using CandD0Data = soa::Filtered>; using TracksData = soa::Filtered>; Filter filterSelectDsCandidates = aod::hf_sel_candidate_ds::isSelDsToKKPi >= selectionFlag || aod::hf_sel_candidate_ds::isSelDsToPiKK >= selectionFlag; @@ -99,25 +123,43 @@ struct HfDerivedDataCreatorCorrelationsReduced { Filter filterSelectD0Candidates = aod::hf_sel_candidate_d0::isSelD0 >= selectionFlag || aod::hf_sel_candidate_d0::isSelD0bar >= selectionFlag; Filter filterSelectTrackData = (nabs(aod::track::eta) < etaTrackMax) && (aod::track::pt > ptTrackMin) && (aod::track::pt < ptTrackMax) && (nabs(aod::track::dcaXY) < dcaXYTrackMax) && (nabs(aod::track::dcaZ) < dcaZTrackMax); - Preslice candsDsPerCollWMl = aod::hf_cand::collisionId; - Preslice candsDplusPerCollWMl = aod::hf_cand::collisionId; - Preslice candsD0PerCollWMl = aod::hf_cand::collisionId; + Preslice candsDsPerColl = aod::hf_cand::collisionId; + Preslice candsDplusPerColl = aod::hf_cand::collisionId; + Preslice candsD0PerColl = aod::hf_cand::collisionId; Preslice trackIndicesPerColl = aod::track::collisionId; - Partition selectedDsToKKPiWMl = aod::hf_sel_candidate_ds::isSelDsToKKPi >= selectionFlag; - Partition selectedDsToPiKKWMl = aod::hf_sel_candidate_ds::isSelDsToPiKK >= selectionFlag; - Partition selectedD0ToPiKWMl = aod::hf_sel_candidate_d0::isSelD0 >= selectionFlag; - Partition selectedD0ToKPiWMl = aod::hf_sel_candidate_d0::isSelD0bar >= selectionFlag; + Partition selectedDsToKKPi = aod::hf_sel_candidate_ds::isSelDsToKKPi >= selectionFlag; + Partition selectedDsToPiKK = aod::hf_sel_candidate_ds::isSelDsToPiKK >= selectionFlag; + Partition selectedD0ToPiK = aod::hf_sel_candidate_d0::isSelD0 >= selectionFlag; + Partition selectedD0ToKPi = aod::hf_sel_candidate_d0::isSelD0bar >= selectionFlag; + + ConfigurableAxis zPoolBins{"zPoolBins", {VARIABLE_WIDTH, -10.0, -2.5, 2.5, 10.0}, "Z vertex position pools"}; + ConfigurableAxis multPoolBins{"multPoolBins", {VARIABLE_WIDTH, 0., 900., 1800., 6000.}, "Event multiplicity pools (FT0M)"}; + ConfigurableAxis centPoolBins{"centPoolBins", {VARIABLE_WIDTH, 0., 10., 20., 30.}, "Event centrality pools"}; + ConfigurableAxis binsInvMass{"binsInvMass", {300, 1.6, 2.2}, ""}; + ConfigurableAxis binsMultFT0M{"binsMultFT0M", {100, 0., 10000.}, "Multiplicity as FT0M signal amplitude"}; + ConfigurableAxis binsCent{"binsCent", {100, 0., 100.}, "Centrality bins"}; + ConfigurableAxis binsPosZ{"binsPosZ", {100, -10., 10.}, "Primary vertex z coordinate"}; + ConfigurableAxis binsEta{"binsEta", {50, -2., 2.}, "Eta bins"}; + ConfigurableAxis binsPhi{"binsPhi", {64, -o2::constants::math::PIHalf, 3. * o2::constants::math::PIHalf}, "Phi bins"}; + ConfigurableAxis binsDeltaEta{"binsDeltaEta", {100, -2., 2.}, "Delta Eta bins"}; + ConfigurableAxis binsDeltaPhi{"binsDeltaPhi", {64, -3., 3.}, "Delta Phi bins"}; + ConfigurableAxis binsPoolBin{"binsPoolBin", {9, 0., 9.}, "PoolBin"}; + ConfigurableAxis binsMlOne{"binsMlOne", {100, 0., 1.}, ""}; + ConfigurableAxis binsMlTwo{"binsMlTwo", {100, 0., 1.}, ""}; HistogramRegistry registry{"registry", {}}; + ColumnBinningPolicy corrBinningCent{{zPoolBins, centPoolBins}, true}; + ColumnBinningPolicy corrBinningMult{{zPoolBins, multPoolBins}, true}; + void init(InitContext&) { - if (doprocessDplusWithMl) { + if (doprocessDplusSameEvent || doprocessDplusMixedEvent) { massCharm = o2::constants::physics::MassDPlus; - } else if (doprocessDsWithMl) { + } else if (doprocessDsSameEvent || doprocessDsMixedEvent) { massCharm = o2::constants::physics::MassDS; - } else if (doprocessD0WithMl) { + } else if (doprocessD0SameEvent || doprocessD0MixedEvent) { massCharm = o2::constants::physics::MassD0; } else { LOG(fatal) << "No decay channel selected to process"; @@ -127,58 +169,73 @@ struct HfDerivedDataCreatorCorrelationsReduced { ccdb->setURL(ccdbUrl); ccdb->setCaching(true); ccdb->setLocalObjectValidityChecking(); - }; // end init - /// Check event selections for collision and fill the collision table - /// \param collision is the collision - template - bool checkAndFillCollision(Coll const& collision) - { - float cent{-1.f}; - float mult{-1.f}; - o2::hf_evsel::HfCollisionRejectionMask collRejMask{}; - if (centEstimator == CentralityEstimator::FT0A) { - collRejMask = hfEvSel.getHfCollisionRejectionMask(collision, cent, ccdb, registry); - mult = collision.multFT0A(); - } else if (centEstimator == CentralityEstimator::FT0C) { - collRejMask = hfEvSel.getHfCollisionRejectionMask(collision, cent, ccdb, registry); - mult = collision.multFT0C(); - } else if (centEstimator == CentralityEstimator::FT0M) { - collRejMask = hfEvSel.getHfCollisionRejectionMask(collision, cent, ccdb, registry); - mult = collision.multFT0M(); - } else if (centEstimator == CentralityEstimator::FV0A) { - collRejMask = hfEvSel.getHfCollisionRejectionMask(collision, cent, ccdb, registry); - mult = collision.multFV0A(); + const AxisSpec axisInvMass{binsInvMass, "Inv. mass (GeV/#it{c}^{2})"}; + const AxisSpec axisCent = {binsCent, "Centrality"}; + const AxisSpec axisMultFT0M = {binsMultFT0M, "MultiplicityFT0M"}; + const AxisSpec axisPosZ = {binsPosZ, "PosZ"}; + const AxisSpec axisPoolBin = {binsPoolBin, "PoolBin"}; + const AxisSpec axisEta = {binsEta, "#it{#eta}"}; + const AxisSpec axisPhi = {binsPhi, "#it{#varphi}"}; + const AxisSpec axisDeltaEta = {binsDeltaEta, "#Delta#it{#eta}"}; + const AxisSpec axisDeltaPhi = {binsDeltaPhi, "#Delta#it{#varphi}"}; + const AxisSpec axisPtTrig = {(std::vector)binsPtTrig, "#it{p}_{T} Trig (GeV/#it{c})"}; + const AxisSpec axisPtAssoc = {(std::vector)binsPtAssoc, "#it{p}_{T} Assoc (GeV/#it{c})"}; + const AxisSpec axisMlOne{binsMlOne, "bdtScore0"}; + const AxisSpec axisMlTwo{binsMlTwo, "bdtScore1"}; + + // Histograms for data analysis + if (useCentMixing) { + registry.add("hCent", "Centrality", {HistType::kTH2F, {{axisCent}, {axisPoolBin}}}); } else { - LOG(fatal) << "Centrality estimator not recognized for collision selection"; - std::abort(); - } - hfEvSel.fillHistograms(collision, collRejMask, cent); - if (collRejMask != 0) { - return false; + registry.add("hMultFT0M", "Multiplicity FT0M", {HistType::kTH2F, {{axisMultFT0M}, {axisPoolBin}}}); } - rowCollisions(mult, collision.numContrib(), cent, collision.posZ()); - return true; - } + registry.add("hZVtx", "z vertex", {HistType::kTH2F, {{axisPosZ}, {axisPoolBin}}}); + registry.add("hCollisionPoolBin", "Collision pool bin", {HistType::kTH1F, {axisPoolBin}}); + registry.add("hPoolBinTrig", "Trigger candidates pool bin", {HistType::kTH1F, {axisPoolBin}}); + registry.add("hPhiVsPtTrig", "Trigger candidates phiVsPt", {HistType::kTH2F, {{axisPhi}, {axisPtTrig}}}); + registry.add("hEtaVsPtTrig", "Trigger candidates etaVsPt", {HistType::kTH2F, {{axisEta}, {axisPtTrig}}}); + registry.add("hPhiVsPtTrigAssoc", "Associated particles phiVsPt", {HistType::kTH3F, {{axisPhi}, {axisPtTrig}, {axisPtAssoc}}}); + registry.add("hEtaVsPtTrigAssoc", "Associated particles etaVsPt", {HistType::kTH3F, {{axisEta}, {axisPtTrig}, {axisPtAssoc}}}); + registry.add("hPhiVsPtAssoc", "Associated particles phiVsPt", {HistType::kTH2F, {{axisPhi}, {axisPtAssoc}}}); + registry.add("hEtaVsPtAssoc", "Associated particles etaVsPt", {HistType::kTH2F, {{axisEta}, {axisPtAssoc}}}); + registry.add("hPoolBinAssoc", "Associated particles pool bin", {HistType::kTH1F, {axisPoolBin}}); + + // if (fillSparses) { + // std::vector axes = {axisPtTrig, axisPtAssoc, axisDeltaEta, axisDeltaPhi, axisPoolBin}; + // if (doprocessSameEventDplusWCentMix) { + // registry.add("hSparseCorrelationsSEHadHad", "THn for SE Had-Had correlations", HistType::kTHnSparseF, axes); + // } else if (doprocessMixedEventHadHadWCentMix || doprocessMixedEventHadHadWMultMix) { + // registry.add("hSparseCorrelationsMEHadHad", "THn for ME Had-Had correlations", HistType::kTHnSparseF, axes); + // } else { + // axes.insert(axes.end(), {axisMlOne, axisMlTwo, axisInvMass}); + // if (doprocessSameEventDplusCharmHadWCentMix || doprocessSameEventCharmHadWMultMix) { + // registry.add("hSparseCorrelationsSECharmHad", "THn for SE Charm-Had correlations", HistType::kTHnSparseF, axes); + // } else if (doprocessMixedEventCharmHadWCentMix || doprocessMixedEventCharmHadWMultMix) { + // registry.add("hSparseCorrelationsMECharmHad", "THn for ME Charm-Had correlations", HistType::kTHnSparseF, axes); + // } + // } + // } + }; // end init /// Get charm hadron candidate mass /// \param candidate is the charm hadron candidate - template + template double getCandMass(const TCand& candidate) { - if constexpr (channel == DecayChannel::DsToKKPi) { + if constexpr (candType == CandType::DsToKKPi) { return hfHelper.invMassDsToKKPi(candidate); } - if constexpr (channel == DecayChannel::DsToPiKK) { + if constexpr (candType == CandType::DsToPiKK) { return hfHelper.invMassDsToPiKK(candidate); } - if constexpr (channel == DecayChannel::DplusToPiKPi) { + if constexpr (candType == CandType::DplusToPiKPi) { return hfHelper.invMassDplusToPiKPi(candidate); } - if constexpr (channel == DecayChannel::D0ToPiK) { + if constexpr (candType == CandType::D0ToPiK) { return hfHelper.invMassD0ToPiK(candidate); } - if constexpr (channel == DecayChannel::D0ToKPi) { + if constexpr (candType == CandType::D0ToKPi) { return hfHelper.invMassD0barToKPi(candidate); } return -1.; @@ -186,31 +243,31 @@ struct HfDerivedDataCreatorCorrelationsReduced { /// Get charm hadron bdt scores /// \param candidate is the charm hadron candidate - template + template std::vector getCandMlScores(const TCand& candidate) { std::vector outputMl{-999., -999.}; - if constexpr (channel == DecayChannel::DsToKKPi) { + if constexpr (candType == CandType::DsToKKPi) { for (unsigned int iclass = 0; iclass < classMl->size(); iclass++) { outputMl[iclass] = candidate.mlProbDsToKKPi()[classMl->at(iclass)]; } } - if constexpr (channel == DecayChannel::DsToPiKK) { + if constexpr (candType == CandType::DsToPiKK) { for (unsigned int iclass = 0; iclass < classMl->size(); iclass++) { outputMl[iclass] = candidate.mlProbDsToPiKK()[classMl->at(iclass)]; } } - if constexpr (channel == DecayChannel::DplusToPiKPi) { + if constexpr (candType == CandType::DplusToPiKPi) { for (unsigned int iclass = 0; iclass < classMl->size(); iclass++) { outputMl[iclass] = candidate.mlProbDplusToPiKPi()[classMl->at(iclass)]; } } - if constexpr (channel == DecayChannel::D0ToPiK) { + if constexpr (candType == CandType::D0ToPiK) { for (unsigned int iclass = 0; iclass < classMl->size(); iclass++) { outputMl[iclass] = candidate.mlProbD0()[classMl->at(iclass)]; } } - if constexpr (channel == DecayChannel::D0ToKPi) { + if constexpr (candType == CandType::D0ToKPi) { for (unsigned int iclass = 0; iclass < classMl->size(); iclass++) { outputMl[iclass] = candidate.mlProbD0bar()[classMl->at(iclass)]; } @@ -218,108 +275,403 @@ struct HfDerivedDataCreatorCorrelationsReduced { return outputMl; } - /// Fill charm hadron tables - /// \param candidates are the selected charm hadron candidates - template - void fillCharmHadronTables(TCand const& candidates) + /// Check event selections for collision and fill the collision table + /// \param collision is the collision + template + bool checkCollision(Coll const& collision, float& cent, float& mult) + { + o2::hf_evsel::HfCollisionRejectionMask collRejMask{}; + if (centEstimator == CentralityEstimator::FT0A) { + collRejMask = hfEvSel.getHfCollisionRejectionMask(collision, cent, ccdb, registry); + mult = collision.multFT0A(); + } else if (centEstimator == CentralityEstimator::FT0C) { + collRejMask = hfEvSel.getHfCollisionRejectionMask(collision, cent, ccdb, registry); + mult = collision.multFT0C(); + } else if (centEstimator == CentralityEstimator::FT0M) { + collRejMask = hfEvSel.getHfCollisionRejectionMask(collision, cent, ccdb, registry); + mult = collision.multFT0M(); + } else if (centEstimator == CentralityEstimator::FV0A) { + collRejMask = hfEvSel.getHfCollisionRejectionMask(collision, cent, ccdb, registry); + mult = collision.multFV0A(); + } else { + LOG(fatal) << "Centrality estimator not recognized for collision selection"; + std::abort(); + } + hfEvSel.fillHistograms(collision, collRejMask, cent); + if (collRejMask != 0) { + return false; + } + return true; + } + + template + bool checkDaughterTrack(TTrack const& track, TCand const& cand) + { + if constexpr ((requires { cand.prong2Id(); })) { // Check 3-prong + return (track.globalIndex() == cand.prong0Id() || track.globalIndex() == cand.prong1Id() || track.globalIndex() == cand.prong2Id()); + } else { // Check 2-prong + return (track.globalIndex() == cand.prong0Id() || track.globalIndex() == cand.prong1Id()); + } + } + + /// Fill Charm-Hadron correlation table and sparse + /// \param trigCand is the trigger charm hadron candidate + /// \param assTrk is the associated hadron track + /// \param poolBin is the pool bin of the collision + template + void fillCharmHadSE(TTrigCand const& trigCand, + TTrack const& assTrk, + const int poolBin) + { + double deltaEta = assTrk.eta() - trigCand.eta(); + double deltaPhi = RecoDecay::constrainAngle(assTrk.phi() - trigCand.phi(), -o2::constants::math::PIHalf); + std::vector outputMl = getCandMlScores(trigCand); + double massCand = getCandMass(trigCand); + if (fillTables) { + entryCharmHadSEPair(deltaEta, deltaPhi, poolBin, trigCand.pt(), massCand, outputMl[0], outputMl[1], + assTrk.pt(), assTrk.tpcNClsCrossedRows(), assTrk.itsClusterMap(), assTrk.itsNCls(), assTrk.dcaXY(), assTrk.dcaZ()); + } + // if (fillSparses) { + // registry.fill(HIST("hSparseCorrelationsSECharmHad"), trigCand.pt(), assTrk.pt(), + // deltaEta, deltaPhi, poolBin, trigCand.bdtScore0(), + // trigCand.bdtScore1(), trigCand.invMassCand()); + // } + } + + /// Fill Hadron-Hadron correlation table and sparse + /// \param trigTrack is the trigger hadron candidate + /// \param assTrk is the associated hadron track + /// \param poolBin is the pool bin of the collision + template + void fillHadHadSE(TCand const& trigTrack, + TCand const& assTrk, + const int poolBin) + { + double deltaEta = assTrk.eta() - trigTrack.eta(); + double deltaPhi = RecoDecay::constrainAngle(assTrk.phi() - trigTrack.phi(), -o2::constants::math::PIHalf); + if (fillTables) { + entryHadHadSEPair(deltaEta, deltaPhi, poolBin, + trigTrack.pt(), assTrk.tpcNClsCrossedRows(), assTrk.itsClusterMap(), assTrk.itsNCls(), assTrk.dcaXY(), assTrk.dcaZ(), + assTrk.pt(), assTrk.tpcNClsCrossedRows(), assTrk.itsClusterMap(), assTrk.itsNCls(), assTrk.dcaXY(), assTrk.dcaZ()); + } + // if (fillSparses) { + // registry.fill(HIST("hSparseCorrelationsSEHadHad"), trigCand.pt(), assTrk.pt(), deltaEta, deltaPhi, poolBin); + // } + } + + template + void fillSameEvent(TTrigCands const& trigCands, + TAssocTracks const& assTrks, + const int poolBin, + const float collCentrality) { - int indexRedColl = rowCollisions.lastIndex(); - for (const auto& candidate : candidates) { - if (std::abs(candidate.y(massCharm)) > yCandMax || candidate.pt() < ptCandMin || candidate.pt() > ptCandMax) { + + for (const auto& trigCand : trigCands) { + registry.fill(HIST("hPoolBinTrig"), poolBin); + registry.fill(HIST("hPhiVsPtTrig"), RecoDecay::constrainAngle(trigCand.phi(), -o2::constants::math::PIHalf), trigCand.pt()); + registry.fill(HIST("hEtaVsPtTrig"), trigCand.eta(), trigCand.pt()); + for (const auto& assTrk : assTrks) { + if (assTrk.tpcNClsCrossedRows() < tpcNClsCrossedRowsMin) { + continue; + } + double deltaEta = assTrk.eta() - trigCand.eta(); + if (std::abs(deltaEta) < deltaEtaAbsMin || std::abs(deltaEta) > deltaEtaAbsMax) { + continue; + } + if constexpr (candType == CandType::Hadron) { + if (assTrk.globalIndex() == trigCand.globalIndex()) { + continue; // skip self-correlation for hadron-hadron + } + if (downSampleTracksFactorSE < 1.) { + float pseudoRndm = assTrk.pt() * 1000. - static_cast(assTrk.pt() * 1000); + if (assTrk.pt() < ptMaxForDownSampleSE && collCentrality < centMaxForDownSampleSE && pseudoRndm >= downSampleTracksFactorSE) { + continue; + } + } + } else { + if (checkDaughterTrack(assTrk, trigCand)) { + continue; // skip daughter tracks for charm-hadron + } + } + + registry.fill(HIST("hPoolBinAssoc"), poolBin); + registry.fill(HIST("hPhiVsPtTrigAssoc"), RecoDecay::constrainAngle(assTrk.phi(), -o2::constants::math::PIHalf), trigCand.pt(), assTrk.pt()); + registry.fill(HIST("hEtaVsPtAssoc"), assTrk.eta(), trigCand.pt(), assTrk.pt()); + if constexpr (candType == CandType::Hadron) { + fillHadHadSE(trigCand, assTrk, poolBin); + } else { + fillCharmHadSE(trigCand, assTrk, poolBin); + } + } + } + } + + template + void fillCharmMixedEvent(TTrigCands const& trigCands, + const int poolBin) + { + for (const auto& trigCand : trigCands) { + registry.fill(HIST("hPoolBinTrig"), poolBin); + registry.fill(HIST("hPhiVsPtTrig"), RecoDecay::constrainAngle(trigCand.phi(), -o2::constants::math::PIHalf), trigCand.pt()); + registry.fill(HIST("hEtaVsPtTrig"), trigCand.eta(), trigCand.pt()); + + rowCharmCandidates(rowCollisions.lastIndex(), trigCand.phi(), trigCand.eta(), trigCand.pt(), + getCandMass(trigCand), getCandMlScores(trigCand)[0], + getCandMlScores(trigCand)[1]); + } + } + + template + void fillTrackMixedEvent(TAssocTracks const& assTrks, + const int poolBin, + const float collCentrality) + { + bool first = true; + for (const auto& assTrk : assTrks) { + if (assTrk.tpcNClsCrossedRows() < tpcNClsCrossedRowsMin) { continue; } - double massCand = getCandMass(candidate); - if constexpr (channel == DecayChannel::D0ToKPi || channel == DecayChannel::D0ToPiK) { - rowCharmCandidates(indexRedColl, candidate.phi(), candidate.eta(), candidate.pt(), massCand, candidate.prong0Id(), candidate.prong1Id(), -1); - } else { - rowCharmCandidates(indexRedColl, candidate.phi(), candidate.eta(), candidate.pt(), massCand, candidate.prong0Id(), candidate.prong1Id(), candidate.prong2Id()); + if (!first && downSampleTracksFactorME < 1.) { + float pseudoRndm = assTrk.pt() * 1000. - static_cast(assTrk.pt() * 1000); + if (assTrk.pt() < ptMaxForDownSampleME && collCentrality < centMaxForDownSampleME && pseudoRndm >= downSampleTracksFactorME) { + continue; + } } - std::vector outputMl = getCandMlScores(candidate); - rowCharmCandidatesMl(indexRedColl, outputMl[0], outputMl[1]); + first = false; + registry.fill(HIST("hPoolBinAssoc"), poolBin); + registry.fill(HIST("hPhiVsPtAssoc"), RecoDecay::constrainAngle(assTrk.phi(), -o2::constants::math::PIHalf), assTrk.pt()); + registry.fill(HIST("hEtaVsPtAssoc"), assTrk.eta(), assTrk.pt()); + rowAssocTrackReduced(rowCollisions.lastIndex(), assTrk.phi(), assTrk.eta(), + assTrk.pt(), assTrk.tpcNClsCrossedRows(), assTrk.itsClusterMap(), + assTrk.itsNCls(), assTrk.dcaXY(), assTrk.dcaZ()); } } - /// Fill tracks tables - /// \param tracks are the selected tracks - template - void fillTracksTables(TTrack const& tracks) + /// Get the binning pool associated to the collision + /// \param collision is the collision + /// \param corrBinning is the binning policy for the correlation + template + int getPoolBin(const TColl& collision, const float cent, const float mult) { - int indexRedColl = rowCollisions.lastIndex(); - for (const auto& track : tracks) { - if (!track.isGlobalTrackWoDCA()) { + int poolBin{0}; + if constexpr (binningPolicy == PoolBinningPolicy::Centrality) { + poolBin = corrBinningCent.getBin(std::make_tuple(collision.posZ(), cent)); + if constexpr (fillHistos) { + registry.fill(HIST("hCent"), cent, poolBin); + } + } else if constexpr (binningPolicy == PoolBinningPolicy::Multiplicity) { + poolBin = corrBinningMult.getBin(std::make_tuple(collision.posZ(), mult)); + if constexpr (fillHistos) { + registry.fill(HIST("hMultFT0M"), mult, poolBin); + } + } + return poolBin; + } + + // Dplus with ML selections + void processDplusSameEvent(CollsWithCentMult const& colls, + CandDplusData const& candsDplus, + TracksData const& tracks) + { + for (const auto& coll : colls) { + auto thisCollId = coll.globalIndex(); + auto candsCThisColl = candsDplus.sliceBy(candsDplusPerColl, thisCollId); + if (forceCharmInCollision && candsCThisColl.size() < 1) { continue; } - rowAssocTrackReduced(indexRedColl, track.globalIndex(), track.phi(), track.eta(), track.pt()); - rowAssocTrackSelInfo(indexRedColl, track.tpcNClsCrossedRows(), track.itsClusterMap(), track.itsNCls(), track.dcaXY(), track.dcaZ()); + float cent{-1.}, mult{-1.}; + if (!checkCollision(coll, cent, mult)) { + continue; + } + rowCollisions(mult, coll.numContrib(), cent, coll.posZ()); + int poolBin = useCentMixing ? getPoolBin(coll, cent, mult) : getPoolBin(coll, cent, mult); + registry.fill(HIST("hCollisionPoolBin"), poolBin); + registry.fill(HIST("hZVtx"), coll.posZ(), poolBin); + auto trackIdsThisColl = tracks.sliceBy(trackIndicesPerColl, thisCollId); + fillSameEvent(candsCThisColl, trackIdsThisColl, poolBin, cent); } } + PROCESS_SWITCH(HfDerivedDataCreatorCorrelationsReduced, processDplusSameEvent, "Process Same Event for Dplus candidates", true); // Dplus with ML selections - void processDplusWithMl(CollsWithCentMult const& colls, - CandDplusDataWMl const& candsDplus, + void processDplusMixedEvent(CollsWithCentMult const& colls, + CandDplusData const& candsDplus, + TracksData const& tracks) + { + for (const auto& coll : colls) { + auto thisCollId = coll.globalIndex(); + auto candsCThisColl = candsDplus.sliceBy(candsDplusPerColl, thisCollId); + if (forceCharmInCollision && candsCThisColl.size() < 1) { + continue; + } + float cent{-1.}, mult{-1.}; + if (!checkCollision(coll, cent, mult)) { + continue; + } + rowCollisions(mult, coll.numContrib(), cent, coll.posZ()); + int poolBin = useCentMixing ? getPoolBin(coll, cent, mult) : getPoolBin(coll, cent, mult); + registry.fill(HIST("hCollisionPoolBin"), poolBin); + registry.fill(HIST("hZVtx"), coll.posZ(), poolBin); + auto trackIdsThisColl = tracks.sliceBy(trackIndicesPerColl, thisCollId); + fillCharmMixedEvent(candsCThisColl, poolBin); + fillTrackMixedEvent(trackIdsThisColl, poolBin, cent); + } + } + PROCESS_SWITCH(HfDerivedDataCreatorCorrelationsReduced, processDplusMixedEvent, "Process Mixed Event for Dplus candidates", false); + + // Ds with ML selections + void processDsSameEvent(CollsWithCentMult const& colls, + CandDsData const& candsDs, TracksData const& tracks) { for (const auto& coll : colls) { auto thisCollId = coll.globalIndex(); - auto candsCThisColl = candsDplus.sliceBy(candsDplusPerCollWMl, thisCollId); + auto candsCThisColl = candsDs.sliceBy(candsDsPerColl, thisCollId); if (forceCharmInCollision && candsCThisColl.size() < 1) { continue; } - if (!checkAndFillCollision(coll)) { + float cent{-1.}, mult{-1.}; + if (!checkCollision(coll, cent, mult)) { continue; } + rowCollisions(mult, coll.numContrib(), cent, coll.posZ()); + int poolBin = useCentMixing ? getPoolBin(coll, cent, mult) : getPoolBin(coll, cent, mult); + registry.fill(HIST("hCollisionPoolBin"), poolBin); + registry.fill(HIST("hZVtx"), coll.posZ(), poolBin); auto trackIdsThisColl = tracks.sliceBy(trackIndicesPerColl, thisCollId); - fillCharmHadronTables(candsCThisColl); - fillTracksTables(trackIdsThisColl); + auto candsDsToPiKK = selectedDsToPiKK->sliceByCached(aod::hf_cand::collisionId, thisCollId, cache); + auto candsDsToKKPi = selectedDsToKKPi->sliceByCached(aod::hf_cand::collisionId, thisCollId, cache); + fillSameEvent(candsDsToPiKK, trackIdsThisColl, poolBin, cent); + fillSameEvent(candsDsToKKPi, trackIdsThisColl, poolBin, cent); } } - PROCESS_SWITCH(HfDerivedDataCreatorCorrelationsReduced, processDplusWithMl, "Process Dplus candidates with ML info", false); + PROCESS_SWITCH(HfDerivedDataCreatorCorrelationsReduced, processDsSameEvent, "Process Same Event for Ds candidates", false); // Ds with ML selections - void processDsWithMl(CollsWithCentMult const& colls, - TracksData const& tracks, - CandDsDataWMl const&) + void processDsMixedEvent(CollsWithCentMult const& colls, + CandDsData const& candsDs, + TracksData const& tracks) + { + for (const auto& coll : colls) { + auto thisCollId = coll.globalIndex(); + auto candsCThisColl = candsDs.sliceBy(candsDsPerColl, thisCollId); + if (forceCharmInCollision && candsCThisColl.size() < 1) { + continue; + } + float cent{-1.}, mult{-1.}; + if (!checkCollision(coll, cent, mult)) { + continue; + } + rowCollisions(mult, coll.numContrib(), cent, coll.posZ()); + int poolBin = useCentMixing ? getPoolBin(coll, cent, mult) : getPoolBin(coll, cent, mult); + registry.fill(HIST("hCollisionPoolBin"), poolBin); + registry.fill(HIST("hZVtx"), coll.posZ(), poolBin); + auto trackIdsThisColl = tracks.sliceBy(trackIndicesPerColl, thisCollId); + auto candsDsToPiKK = selectedDsToPiKK->sliceByCached(aod::hf_cand::collisionId, thisCollId, cache); + auto candsDsToKKPi = selectedDsToKKPi->sliceByCached(aod::hf_cand::collisionId, thisCollId, cache); + fillCharmMixedEvent(candsDsToPiKK, poolBin); + fillCharmMixedEvent(candsDsToKKPi, poolBin); + fillTrackMixedEvent(trackIdsThisColl, poolBin, cent); + } + } + PROCESS_SWITCH(HfDerivedDataCreatorCorrelationsReduced, processDsMixedEvent, "Process Mixed Event for Ds candidates", false); + + // D0 with ML selections + void processD0SameEvent(CollsWithCentMult const& colls, + CandD0Data const& candsD0, + TracksData const& tracks) { for (const auto& coll : colls) { auto thisCollId = coll.globalIndex(); - auto candsDsToKKPiWMl = selectedDsToKKPiWMl->sliceByCached(aod::hf_cand::collisionId, thisCollId, cache); - auto candsDsToPiKKWMl = selectedDsToPiKKWMl->sliceByCached(aod::hf_cand::collisionId, thisCollId, cache); - if (forceCharmInCollision && candsDsToKKPiWMl.size() < 1 && candsDsToPiKKWMl.size() < 1) { + auto candsCThisColl = candsD0.sliceBy(candsD0PerColl, thisCollId); + if (forceCharmInCollision && candsCThisColl.size() < 1) { continue; } - if (!checkAndFillCollision(coll)) { + float cent{-1.}, mult{-1.}; + if (!checkCollision(coll, cent, mult)) { continue; } + rowCollisions(mult, coll.numContrib(), cent, coll.posZ()); + int poolBin = useCentMixing ? getPoolBin(coll, cent, mult) : getPoolBin(coll, cent, mult); + registry.fill(HIST("hCollisionPoolBin"), poolBin); + registry.fill(HIST("hZVtx"), coll.posZ(), poolBin); auto trackIdsThisColl = tracks.sliceBy(trackIndicesPerColl, thisCollId); - fillCharmHadronTables(candsDsToPiKKWMl); - fillCharmHadronTables(candsDsToKKPiWMl); - fillTracksTables(trackIdsThisColl); + auto candsD0ToPiK = selectedD0ToPiK->sliceByCached(aod::hf_cand::collisionId, thisCollId, cache); + auto candsD0ToKPi = selectedD0ToKPi->sliceByCached(aod::hf_cand::collisionId, thisCollId, cache); + fillSameEvent(candsD0ToPiK, trackIdsThisColl, poolBin, cent); + fillSameEvent(candsD0ToKPi, trackIdsThisColl, poolBin, cent); } } - PROCESS_SWITCH(HfDerivedDataCreatorCorrelationsReduced, processDsWithMl, "Process Ds candidates with ML info", false); + PROCESS_SWITCH(HfDerivedDataCreatorCorrelationsReduced, processD0SameEvent, "Process Same Event for D0 candidates", false); // D0 with ML selections - void processD0WithMl(CollsWithCentMult const& colls, - TracksData const& tracks, - CandD0DataWMl const&) + void processD0MixedEvent(CollsWithCentMult const& colls, + CandD0Data const& candsD0, + TracksData const& tracks) + { + for (const auto& coll : colls) { + auto thisCollId = coll.globalIndex(); + auto candsCThisColl = candsD0.sliceBy(candsD0PerColl, thisCollId); + if (forceCharmInCollision && candsCThisColl.size() < 1) { + continue; + } + float cent{-1.}, mult{-1.}; + if (!checkCollision(coll, cent, mult)) { + continue; + } + rowCollisions(mult, coll.numContrib(), cent, coll.posZ()); + int poolBin = useCentMixing ? getPoolBin(coll, cent, mult) : getPoolBin(coll, cent, mult); + registry.fill(HIST("hCollisionPoolBin"), poolBin); + registry.fill(HIST("hZVtx"), coll.posZ(), poolBin); + auto trackIdsThisColl = tracks.sliceBy(trackIndicesPerColl, thisCollId); + auto candsD0ToPiK = selectedD0ToPiK->sliceByCached(aod::hf_cand::collisionId, thisCollId, cache); + auto candsD0ToKPi = selectedD0ToKPi->sliceByCached(aod::hf_cand::collisionId, thisCollId, cache); + fillCharmMixedEvent(candsD0ToPiK, poolBin); + fillCharmMixedEvent(candsD0ToKPi, poolBin); + fillTrackMixedEvent(trackIdsThisColl, poolBin, cent); + } + } + PROCESS_SWITCH(HfDerivedDataCreatorCorrelationsReduced, processD0MixedEvent, "Process Mixed Event for D0 candidates", false); + + // Hadron Hadron Same Event + void processHadronHadronSameEvent(CollsWithCentMult const& colls, + TracksData const& tracks) { for (const auto& coll : colls) { auto thisCollId = coll.globalIndex(); - auto candsD0ToPiKWMl = selectedD0ToPiKWMl->sliceByCached(aod::hf_cand::collisionId, thisCollId, cache); - auto candsD0ToKPiWMl = selectedD0ToKPiWMl->sliceByCached(aod::hf_cand::collisionId, thisCollId, cache); - if (forceCharmInCollision && candsD0ToPiKWMl.size() < 1 && candsD0ToKPiWMl.size() < 1) { + float cent{-1.}, mult{-1.}; + if (!checkCollision(coll, cent, mult)) { continue; } - if (!checkAndFillCollision(coll)) { + rowCollisions(mult, coll.numContrib(), cent, coll.posZ()); + int poolBin = useCentMixing ? getPoolBin(coll, cent, mult) : getPoolBin(coll, cent, mult); + registry.fill(HIST("hCollisionPoolBin"), poolBin); + registry.fill(HIST("hZVtx"), coll.posZ(), poolBin); + auto trackIdsThisColl = tracks.sliceBy(trackIndicesPerColl, thisCollId); + fillSameEvent(trackIdsThisColl, trackIdsThisColl, poolBin, cent); + } + } + PROCESS_SWITCH(HfDerivedDataCreatorCorrelationsReduced, processHadronHadronSameEvent, "Process Same Event for hadron candidates", true); + + // Hadron Hadron Mixed Event + void processHadronHadronMixedEvent(CollsWithCentMult const& colls, + TracksData const& tracks) + { + for (const auto& coll : colls) { + auto thisCollId = coll.globalIndex(); + float cent{-1.}, mult{-1.}; + if (!checkCollision(coll, cent, mult)) { continue; } + rowCollisions(mult, coll.numContrib(), cent, coll.posZ()); + int poolBin = useCentMixing ? getPoolBin(coll, cent, mult) : getPoolBin(coll, cent, mult); + registry.fill(HIST("hCollisionPoolBin"), poolBin); + registry.fill(HIST("hZVtx"), coll.posZ(), poolBin); auto trackIdsThisColl = tracks.sliceBy(trackIndicesPerColl, thisCollId); - fillCharmHadronTables(candsD0ToPiKWMl); - fillCharmHadronTables(candsD0ToKPiWMl); - fillTracksTables(trackIdsThisColl); + fillTrackMixedEvent(trackIdsThisColl, poolBin, cent); } } - PROCESS_SWITCH(HfDerivedDataCreatorCorrelationsReduced, processD0WithMl, "Process D0 candidates with ML info", false); + PROCESS_SWITCH(HfDerivedDataCreatorCorrelationsReduced, processHadronHadronMixedEvent, "Process Mixed Event for hadron candidates", false); }; WorkflowSpec defineDataProcessing(ConfigContext const& cfgc) From 9295187080ea01ef367eac7fbe38e60c957d2da2 Mon Sep 17 00:00:00 2001 From: marcellocosti Date: Mon, 15 Sep 2025 22:49:41 +0200 Subject: [PATCH 02/15] Move to iterators in process functions --- .../derivedDataCreatorCorrelationsReduced.cxx | 264 ++++++++---------- 1 file changed, 113 insertions(+), 151 deletions(-) diff --git a/PWGHF/HFC/TableProducer/derivedDataCreatorCorrelationsReduced.cxx b/PWGHF/HFC/TableProducer/derivedDataCreatorCorrelationsReduced.cxx index 5e1cb2b8d48..e43bae8dcfb 100644 --- a/PWGHF/HFC/TableProducer/derivedDataCreatorCorrelationsReduced.cxx +++ b/PWGHF/HFC/TableProducer/derivedDataCreatorCorrelationsReduced.cxx @@ -469,207 +469,169 @@ struct HfDerivedDataCreatorCorrelationsReduced { } // Dplus with ML selections - void processDplusSameEvent(CollsWithCentMult const& colls, + void processDplusSameEvent(CollsWithCentMult::iterator const& coll, CandDplusData const& candsDplus, TracksData const& tracks) { - for (const auto& coll : colls) { - auto thisCollId = coll.globalIndex(); - auto candsCThisColl = candsDplus.sliceBy(candsDplusPerColl, thisCollId); - if (forceCharmInCollision && candsCThisColl.size() < 1) { - continue; - } - float cent{-1.}, mult{-1.}; - if (!checkCollision(coll, cent, mult)) { - continue; - } - rowCollisions(mult, coll.numContrib(), cent, coll.posZ()); - int poolBin = useCentMixing ? getPoolBin(coll, cent, mult) : getPoolBin(coll, cent, mult); - registry.fill(HIST("hCollisionPoolBin"), poolBin); - registry.fill(HIST("hZVtx"), coll.posZ(), poolBin); - auto trackIdsThisColl = tracks.sliceBy(trackIndicesPerColl, thisCollId); - fillSameEvent(candsCThisColl, trackIdsThisColl, poolBin, cent); + if (forceCharmInCollision && candsDplus.size() < 1) { + return; + } + float cent{-1.}, mult{-1.}; + if (!checkCollision(coll, cent, mult)) { + return; } + rowCollisions(mult, coll.numContrib(), cent, coll.posZ()); + int poolBin = useCentMixing ? getPoolBin(coll, cent, mult) : getPoolBin(coll, cent, mult); + registry.fill(HIST("hCollisionPoolBin"), poolBin); + registry.fill(HIST("hZVtx"), coll.posZ(), poolBin); + fillSameEvent(candsDplus, tracks, poolBin, cent); } PROCESS_SWITCH(HfDerivedDataCreatorCorrelationsReduced, processDplusSameEvent, "Process Same Event for Dplus candidates", true); // Dplus with ML selections - void processDplusMixedEvent(CollsWithCentMult const& colls, + void processDplusMixedEvent(CollsWithCentMult::iterator const& coll, CandDplusData const& candsDplus, TracksData const& tracks) { - for (const auto& coll : colls) { - auto thisCollId = coll.globalIndex(); - auto candsCThisColl = candsDplus.sliceBy(candsDplusPerColl, thisCollId); - if (forceCharmInCollision && candsCThisColl.size() < 1) { - continue; - } - float cent{-1.}, mult{-1.}; - if (!checkCollision(coll, cent, mult)) { - continue; - } - rowCollisions(mult, coll.numContrib(), cent, coll.posZ()); - int poolBin = useCentMixing ? getPoolBin(coll, cent, mult) : getPoolBin(coll, cent, mult); - registry.fill(HIST("hCollisionPoolBin"), poolBin); - registry.fill(HIST("hZVtx"), coll.posZ(), poolBin); - auto trackIdsThisColl = tracks.sliceBy(trackIndicesPerColl, thisCollId); - fillCharmMixedEvent(candsCThisColl, poolBin); - fillTrackMixedEvent(trackIdsThisColl, poolBin, cent); + if (forceCharmInCollision && candsDplus.size() < 1) { + return; } + float cent{-1.}, mult{-1.}; + if (!checkCollision(coll, cent, mult)) { + return; + } + rowCollisions(mult, coll.numContrib(), cent, coll.posZ()); + int poolBin = useCentMixing ? getPoolBin(coll, cent, mult) : getPoolBin(coll, cent, mult); + registry.fill(HIST("hCollisionPoolBin"), poolBin); + registry.fill(HIST("hZVtx"), coll.posZ(), poolBin); + fillCharmMixedEvent(candsDplus, poolBin); + fillTrackMixedEvent(tracks, poolBin, cent); } PROCESS_SWITCH(HfDerivedDataCreatorCorrelationsReduced, processDplusMixedEvent, "Process Mixed Event for Dplus candidates", false); // Ds with ML selections - void processDsSameEvent(CollsWithCentMult const& colls, - CandDsData const& candsDs, - TracksData const& tracks) + void processDsSameEvent(CollsWithCentMult::iterator const& coll, + TracksData const& tracks, + CandDsData const&) { - for (const auto& coll : colls) { - auto thisCollId = coll.globalIndex(); - auto candsCThisColl = candsDs.sliceBy(candsDsPerColl, thisCollId); - if (forceCharmInCollision && candsCThisColl.size() < 1) { - continue; - } - float cent{-1.}, mult{-1.}; - if (!checkCollision(coll, cent, mult)) { - continue; - } - rowCollisions(mult, coll.numContrib(), cent, coll.posZ()); - int poolBin = useCentMixing ? getPoolBin(coll, cent, mult) : getPoolBin(coll, cent, mult); - registry.fill(HIST("hCollisionPoolBin"), poolBin); - registry.fill(HIST("hZVtx"), coll.posZ(), poolBin); - auto trackIdsThisColl = tracks.sliceBy(trackIndicesPerColl, thisCollId); - auto candsDsToPiKK = selectedDsToPiKK->sliceByCached(aod::hf_cand::collisionId, thisCollId, cache); - auto candsDsToKKPi = selectedDsToKKPi->sliceByCached(aod::hf_cand::collisionId, thisCollId, cache); - fillSameEvent(candsDsToPiKK, trackIdsThisColl, poolBin, cent); - fillSameEvent(candsDsToKKPi, trackIdsThisColl, poolBin, cent); + auto candsDsToPiKK = selectedDsToPiKK->sliceByCached(aod::hf_cand::collisionId, coll.globalIndex(), cache); + auto candsDsToKKPi = selectedDsToKKPi->sliceByCached(aod::hf_cand::collisionId, coll.globalIndex(), cache); + if (forceCharmInCollision && candsDsToPiKK.size() < 1 && candsDsToKKPi.size() < 1) { + return; } + float cent{-1.}, mult{-1.}; + if (!checkCollision(coll, cent, mult)) { + return; + } + rowCollisions(mult, coll.numContrib(), cent, coll.posZ()); + int poolBin = useCentMixing ? getPoolBin(coll, cent, mult) : getPoolBin(coll, cent, mult); + registry.fill(HIST("hCollisionPoolBin"), poolBin); + registry.fill(HIST("hZVtx"), coll.posZ(), poolBin); + fillSameEvent(candsDsToPiKK, tracks, poolBin, cent); + fillSameEvent(candsDsToKKPi, tracks, poolBin, cent); } PROCESS_SWITCH(HfDerivedDataCreatorCorrelationsReduced, processDsSameEvent, "Process Same Event for Ds candidates", false); // Ds with ML selections - void processDsMixedEvent(CollsWithCentMult const& colls, - CandDsData const& candsDs, - TracksData const& tracks) + void processDsMixedEvent(CollsWithCentMult::iterator const& coll, + TracksData const& tracks, + CandDsData const&) { - for (const auto& coll : colls) { - auto thisCollId = coll.globalIndex(); - auto candsCThisColl = candsDs.sliceBy(candsDsPerColl, thisCollId); - if (forceCharmInCollision && candsCThisColl.size() < 1) { - continue; - } - float cent{-1.}, mult{-1.}; - if (!checkCollision(coll, cent, mult)) { - continue; - } - rowCollisions(mult, coll.numContrib(), cent, coll.posZ()); - int poolBin = useCentMixing ? getPoolBin(coll, cent, mult) : getPoolBin(coll, cent, mult); - registry.fill(HIST("hCollisionPoolBin"), poolBin); - registry.fill(HIST("hZVtx"), coll.posZ(), poolBin); - auto trackIdsThisColl = tracks.sliceBy(trackIndicesPerColl, thisCollId); - auto candsDsToPiKK = selectedDsToPiKK->sliceByCached(aod::hf_cand::collisionId, thisCollId, cache); - auto candsDsToKKPi = selectedDsToKKPi->sliceByCached(aod::hf_cand::collisionId, thisCollId, cache); - fillCharmMixedEvent(candsDsToPiKK, poolBin); - fillCharmMixedEvent(candsDsToKKPi, poolBin); - fillTrackMixedEvent(trackIdsThisColl, poolBin, cent); + auto candsDsToPiKK = selectedDsToPiKK->sliceByCached(aod::hf_cand::collisionId, coll.globalIndex(), cache); + auto candsDsToKKPi = selectedDsToKKPi->sliceByCached(aod::hf_cand::collisionId, coll.globalIndex(), cache); + if (forceCharmInCollision && candsDsToPiKK.size() < 1 && candsDsToKKPi.size() < 1) { + return; + } + float cent{-1.}, mult{-1.}; + if (!checkCollision(coll, cent, mult)) { + return; } + rowCollisions(mult, coll.numContrib(), cent, coll.posZ()); + int poolBin = useCentMixing ? getPoolBin(coll, cent, mult) : getPoolBin(coll, cent, mult); + registry.fill(HIST("hCollisionPoolBin"), poolBin); + registry.fill(HIST("hZVtx"), coll.posZ(), poolBin); + fillCharmMixedEvent(candsDsToPiKK, poolBin); + fillCharmMixedEvent(candsDsToKKPi, poolBin); + fillTrackMixedEvent(tracks, poolBin, cent); } PROCESS_SWITCH(HfDerivedDataCreatorCorrelationsReduced, processDsMixedEvent, "Process Mixed Event for Ds candidates", false); // D0 with ML selections - void processD0SameEvent(CollsWithCentMult const& colls, - CandD0Data const& candsD0, - TracksData const& tracks) + void processD0SameEvent(CollsWithCentMult::iterator const& coll, + TracksData const& tracks, + CandD0Data const&) { - for (const auto& coll : colls) { - auto thisCollId = coll.globalIndex(); - auto candsCThisColl = candsD0.sliceBy(candsD0PerColl, thisCollId); - if (forceCharmInCollision && candsCThisColl.size() < 1) { - continue; - } - float cent{-1.}, mult{-1.}; - if (!checkCollision(coll, cent, mult)) { - continue; - } - rowCollisions(mult, coll.numContrib(), cent, coll.posZ()); - int poolBin = useCentMixing ? getPoolBin(coll, cent, mult) : getPoolBin(coll, cent, mult); - registry.fill(HIST("hCollisionPoolBin"), poolBin); - registry.fill(HIST("hZVtx"), coll.posZ(), poolBin); - auto trackIdsThisColl = tracks.sliceBy(trackIndicesPerColl, thisCollId); - auto candsD0ToPiK = selectedD0ToPiK->sliceByCached(aod::hf_cand::collisionId, thisCollId, cache); - auto candsD0ToKPi = selectedD0ToKPi->sliceByCached(aod::hf_cand::collisionId, thisCollId, cache); - fillSameEvent(candsD0ToPiK, trackIdsThisColl, poolBin, cent); - fillSameEvent(candsD0ToKPi, trackIdsThisColl, poolBin, cent); + auto candsD0ToPiK = selectedD0ToPiK->sliceByCached(aod::hf_cand::collisionId, coll.globalIndex(), cache); + auto candsD0ToKPi = selectedD0ToKPi->sliceByCached(aod::hf_cand::collisionId, coll.globalIndex(), cache); + if (forceCharmInCollision && candsD0ToPiK.size() < 1 && candsD0ToKPi.size() < 1) { + return; + } + float cent{-1.}, mult{-1.}; + if (!checkCollision(coll, cent, mult)) { + return; } + rowCollisions(mult, coll.numContrib(), cent, coll.posZ()); + int poolBin = useCentMixing ? getPoolBin(coll, cent, mult) : getPoolBin(coll, cent, mult); + registry.fill(HIST("hCollisionPoolBin"), poolBin); + registry.fill(HIST("hZVtx"), coll.posZ(), poolBin); + fillSameEvent(candsD0ToPiK, tracks, poolBin, cent); + fillSameEvent(candsD0ToKPi, tracks, poolBin, cent); } PROCESS_SWITCH(HfDerivedDataCreatorCorrelationsReduced, processD0SameEvent, "Process Same Event for D0 candidates", false); // D0 with ML selections - void processD0MixedEvent(CollsWithCentMult const& colls, - CandD0Data const& candsD0, - TracksData const& tracks) + void processD0MixedEvent(CollsWithCentMult::iterator const& coll, + TracksData const& tracks, + CandD0Data const&) { - for (const auto& coll : colls) { - auto thisCollId = coll.globalIndex(); - auto candsCThisColl = candsD0.sliceBy(candsD0PerColl, thisCollId); - if (forceCharmInCollision && candsCThisColl.size() < 1) { - continue; - } - float cent{-1.}, mult{-1.}; - if (!checkCollision(coll, cent, mult)) { - continue; - } - rowCollisions(mult, coll.numContrib(), cent, coll.posZ()); - int poolBin = useCentMixing ? getPoolBin(coll, cent, mult) : getPoolBin(coll, cent, mult); - registry.fill(HIST("hCollisionPoolBin"), poolBin); - registry.fill(HIST("hZVtx"), coll.posZ(), poolBin); - auto trackIdsThisColl = tracks.sliceBy(trackIndicesPerColl, thisCollId); - auto candsD0ToPiK = selectedD0ToPiK->sliceByCached(aod::hf_cand::collisionId, thisCollId, cache); - auto candsD0ToKPi = selectedD0ToKPi->sliceByCached(aod::hf_cand::collisionId, thisCollId, cache); - fillCharmMixedEvent(candsD0ToPiK, poolBin); - fillCharmMixedEvent(candsD0ToKPi, poolBin); - fillTrackMixedEvent(trackIdsThisColl, poolBin, cent); + auto candsD0ToPiK = selectedD0ToPiK->sliceByCached(aod::hf_cand::collisionId, coll.globalIndex(), cache); + auto candsD0ToKPi = selectedD0ToKPi->sliceByCached(aod::hf_cand::collisionId, coll.globalIndex(), cache); + if (forceCharmInCollision && candsD0ToPiK.size() < 1 && candsD0ToKPi.size() < 1) { + return; + } + float cent{-1.}, mult{-1.}; + if (!checkCollision(coll, cent, mult)) { + return; } + rowCollisions(mult, coll.numContrib(), cent, coll.posZ()); + int poolBin = useCentMixing ? getPoolBin(coll, cent, mult) : getPoolBin(coll, cent, mult); + registry.fill(HIST("hCollisionPoolBin"), poolBin); + registry.fill(HIST("hZVtx"), coll.posZ(), poolBin); + fillCharmMixedEvent(candsD0ToPiK, poolBin); + fillCharmMixedEvent(candsD0ToKPi, poolBin); + fillTrackMixedEvent(tracks, poolBin, cent); } PROCESS_SWITCH(HfDerivedDataCreatorCorrelationsReduced, processD0MixedEvent, "Process Mixed Event for D0 candidates", false); // Hadron Hadron Same Event - void processHadronHadronSameEvent(CollsWithCentMult const& colls, + void processHadronHadronSameEvent(CollsWithCentMult::iterator const& coll, TracksData const& tracks) { - for (const auto& coll : colls) { - auto thisCollId = coll.globalIndex(); - float cent{-1.}, mult{-1.}; - if (!checkCollision(coll, cent, mult)) { - continue; - } - rowCollisions(mult, coll.numContrib(), cent, coll.posZ()); - int poolBin = useCentMixing ? getPoolBin(coll, cent, mult) : getPoolBin(coll, cent, mult); - registry.fill(HIST("hCollisionPoolBin"), poolBin); - registry.fill(HIST("hZVtx"), coll.posZ(), poolBin); - auto trackIdsThisColl = tracks.sliceBy(trackIndicesPerColl, thisCollId); - fillSameEvent(trackIdsThisColl, trackIdsThisColl, poolBin, cent); + float cent{-1.}, mult{-1.}; + if (!checkCollision(coll, cent, mult)) { + return; } + rowCollisions(mult, coll.numContrib(), cent, coll.posZ()); + int poolBin = useCentMixing ? getPoolBin(coll, cent, mult) : getPoolBin(coll, cent, mult); + registry.fill(HIST("hCollisionPoolBin"), poolBin); + registry.fill(HIST("hZVtx"), coll.posZ(), poolBin); + fillSameEvent(tracks, tracks, poolBin, cent); } PROCESS_SWITCH(HfDerivedDataCreatorCorrelationsReduced, processHadronHadronSameEvent, "Process Same Event for hadron candidates", true); // Hadron Hadron Mixed Event - void processHadronHadronMixedEvent(CollsWithCentMult const& colls, + void processHadronHadronMixedEvent(CollsWithCentMult::iterator const& coll, TracksData const& tracks) { - for (const auto& coll : colls) { - auto thisCollId = coll.globalIndex(); - float cent{-1.}, mult{-1.}; - if (!checkCollision(coll, cent, mult)) { - continue; - } - rowCollisions(mult, coll.numContrib(), cent, coll.posZ()); - int poolBin = useCentMixing ? getPoolBin(coll, cent, mult) : getPoolBin(coll, cent, mult); - registry.fill(HIST("hCollisionPoolBin"), poolBin); - registry.fill(HIST("hZVtx"), coll.posZ(), poolBin); - auto trackIdsThisColl = tracks.sliceBy(trackIndicesPerColl, thisCollId); - fillTrackMixedEvent(trackIdsThisColl, poolBin, cent); + float cent{-1.}, mult{-1.}; + if (!checkCollision(coll, cent, mult)) { + return; } + rowCollisions(mult, coll.numContrib(), cent, coll.posZ()); + int poolBin = useCentMixing ? getPoolBin(coll, cent, mult) : getPoolBin(coll, cent, mult); + registry.fill(HIST("hCollisionPoolBin"), poolBin); + registry.fill(HIST("hZVtx"), coll.posZ(), poolBin); + fillTrackMixedEvent(tracks, poolBin, cent); } PROCESS_SWITCH(HfDerivedDataCreatorCorrelationsReduced, processHadronHadronMixedEvent, "Process Mixed Event for hadron candidates", false); }; From 63964bc9a8eddcbb93e66d4acde819ec0dce3fb0 Mon Sep 17 00:00:00 2001 From: ALICE Action Bot Date: Mon, 15 Sep 2025 20:57:28 +0000 Subject: [PATCH 03/15] Please consider the following formatting changes --- .../DataModel/DerivedDataCorrelationTables.h | 18 +++++++++--------- .../correlatorFlowCharmHadronsReduced.cxx | 2 +- .../derivedDataCreatorCorrelationsReduced.cxx | 8 ++++---- 3 files changed, 14 insertions(+), 14 deletions(-) diff --git a/PWGHF/HFC/DataModel/DerivedDataCorrelationTables.h b/PWGHF/HFC/DataModel/DerivedDataCorrelationTables.h index d5367f6fbe5..72dc30617fd 100644 --- a/PWGHF/HFC/DataModel/DerivedDataCorrelationTables.h +++ b/PWGHF/HFC/DataModel/DerivedDataCorrelationTables.h @@ -93,15 +93,15 @@ DECLARE_SOA_TABLE(HfcRedCharmTrigs, "AOD", "HFCREDCHARMTRIG", //! Table with cha namespace hf_assoc_track_reduced { -DECLARE_SOA_COLUMN(OriginTrackId, originTrackId, int); //! Original track index -DECLARE_SOA_COLUMN(NTpcCrossedRows, nTpcCrossedRows, UChar_t); //! Number of crossed TPC Rows -DECLARE_SOA_COLUMN(ItsClusterMap, itsClusterMap, UChar_t); //! ITS cluster map, one bit per a layer, starting from the innermost -DECLARE_SOA_COLUMN(ItsNCls, itsNCls, UChar_t); //! Number of ITS clusters -DECLARE_SOA_COLUMN(EtaAssocTrack, etaAssocTrack, float); //! Eta of the track -DECLARE_SOA_COLUMN(PhiAssocTrack, phiAssocTrack, float); //! Phi of the track -DECLARE_SOA_COLUMN(PtAssocTrack, ptAssocTrack, float); //! Pt of the track -DECLARE_SOA_COLUMN(DcaXY, dcaXY, float); //! Impact parameter in XY of the track to the primary vertex -DECLARE_SOA_COLUMN(DcaZ, dcaZ, float); //! Impact parameter in Z of the track to the primary vertex +DECLARE_SOA_COLUMN(OriginTrackId, originTrackId, int); //! Original track index +DECLARE_SOA_COLUMN(NTpcCrossedRows, nTpcCrossedRows, UChar_t); //! Number of crossed TPC Rows +DECLARE_SOA_COLUMN(ItsClusterMap, itsClusterMap, UChar_t); //! ITS cluster map, one bit per a layer, starting from the innermost +DECLARE_SOA_COLUMN(ItsNCls, itsNCls, UChar_t); //! Number of ITS clusters +DECLARE_SOA_COLUMN(EtaAssocTrack, etaAssocTrack, float); //! Eta of the track +DECLARE_SOA_COLUMN(PhiAssocTrack, phiAssocTrack, float); //! Phi of the track +DECLARE_SOA_COLUMN(PtAssocTrack, ptAssocTrack, float); //! Pt of the track +DECLARE_SOA_COLUMN(DcaXY, dcaXY, float); //! Impact parameter in XY of the track to the primary vertex +DECLARE_SOA_COLUMN(DcaZ, dcaZ, float); //! Impact parameter in Z of the track to the primary vertex DECLARE_SOA_COLUMN(NTpcCrossedRowsTrig, nTpcCrossedRowsTrig, UChar_t); //! Number of crossed TPC Rows DECLARE_SOA_COLUMN(ItsClusterMapTrig, itsClusterMapTrig, UChar_t); //! ITS cluster map, one bit per a layer, starting from the innermost DECLARE_SOA_COLUMN(ItsNClsTrig, itsNClsTrig, UChar_t); //! Number of ITS clusters diff --git a/PWGHF/HFC/TableProducer/correlatorFlowCharmHadronsReduced.cxx b/PWGHF/HFC/TableProducer/correlatorFlowCharmHadronsReduced.cxx index 70dac06e48b..b8eac589d1f 100644 --- a/PWGHF/HFC/TableProducer/correlatorFlowCharmHadronsReduced.cxx +++ b/PWGHF/HFC/TableProducer/correlatorFlowCharmHadronsReduced.cxx @@ -393,7 +393,7 @@ struct HfCorrelatorFlowCharmHadronsReduced { } if (downSamplePairsME < 1.) { float pseudoRndm = getPt(assocTrack) * 1000. - static_cast(getPt(assocTrack) * 1000); - if (getPt(trigCand) < ptMaxForDownSampleME && trigColl.centrality() < centMaxForDownSampleME && + if (getPt(trigCand) < ptMaxForDownSampleME && trigColl.centrality() < centMaxForDownSampleME && assocColl.centrality() < centMaxForDownSampleME && pseudoRndm >= downSamplePairsME) { continue; } diff --git a/PWGHF/HFC/TableProducer/derivedDataCreatorCorrelationsReduced.cxx b/PWGHF/HFC/TableProducer/derivedDataCreatorCorrelationsReduced.cxx index e43bae8dcfb..fa8da654e0e 100644 --- a/PWGHF/HFC/TableProducer/derivedDataCreatorCorrelationsReduced.cxx +++ b/PWGHF/HFC/TableProducer/derivedDataCreatorCorrelationsReduced.cxx @@ -307,9 +307,9 @@ struct HfDerivedDataCreatorCorrelationsReduced { template bool checkDaughterTrack(TTrack const& track, TCand const& cand) { - if constexpr ((requires { cand.prong2Id(); })) { // Check 3-prong + if constexpr ((requires { cand.prong2Id(); })) { // Check 3-prong return (track.globalIndex() == cand.prong0Id() || track.globalIndex() == cand.prong1Id() || track.globalIndex() == cand.prong2Id()); - } else { // Check 2-prong + } else { // Check 2-prong return (track.globalIndex() == cand.prong0Id() || track.globalIndex() == cand.prong1Id()); } } @@ -441,8 +441,8 @@ struct HfDerivedDataCreatorCorrelationsReduced { registry.fill(HIST("hPoolBinAssoc"), poolBin); registry.fill(HIST("hPhiVsPtAssoc"), RecoDecay::constrainAngle(assTrk.phi(), -o2::constants::math::PIHalf), assTrk.pt()); registry.fill(HIST("hEtaVsPtAssoc"), assTrk.eta(), assTrk.pt()); - rowAssocTrackReduced(rowCollisions.lastIndex(), assTrk.phi(), assTrk.eta(), - assTrk.pt(), assTrk.tpcNClsCrossedRows(), assTrk.itsClusterMap(), + rowAssocTrackReduced(rowCollisions.lastIndex(), assTrk.phi(), assTrk.eta(), + assTrk.pt(), assTrk.tpcNClsCrossedRows(), assTrk.itsClusterMap(), assTrk.itsNCls(), assTrk.dcaXY(), assTrk.dcaZ()); } } From 6a918f9052fe80475841894186dde7ebac640e83 Mon Sep 17 00:00:00 2001 From: marcellocosti Date: Mon, 15 Sep 2025 23:01:23 +0200 Subject: [PATCH 04/15] Restore correct data types --- .../DataModel/DerivedDataCorrelationTables.h | 24 +++++++++---------- 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/PWGHF/HFC/DataModel/DerivedDataCorrelationTables.h b/PWGHF/HFC/DataModel/DerivedDataCorrelationTables.h index 72dc30617fd..2b5e41cf04f 100644 --- a/PWGHF/HFC/DataModel/DerivedDataCorrelationTables.h +++ b/PWGHF/HFC/DataModel/DerivedDataCorrelationTables.h @@ -93,18 +93,18 @@ DECLARE_SOA_TABLE(HfcRedCharmTrigs, "AOD", "HFCREDCHARMTRIG", //! Table with cha namespace hf_assoc_track_reduced { -DECLARE_SOA_COLUMN(OriginTrackId, originTrackId, int); //! Original track index -DECLARE_SOA_COLUMN(NTpcCrossedRows, nTpcCrossedRows, UChar_t); //! Number of crossed TPC Rows -DECLARE_SOA_COLUMN(ItsClusterMap, itsClusterMap, UChar_t); //! ITS cluster map, one bit per a layer, starting from the innermost -DECLARE_SOA_COLUMN(ItsNCls, itsNCls, UChar_t); //! Number of ITS clusters -DECLARE_SOA_COLUMN(EtaAssocTrack, etaAssocTrack, float); //! Eta of the track -DECLARE_SOA_COLUMN(PhiAssocTrack, phiAssocTrack, float); //! Phi of the track -DECLARE_SOA_COLUMN(PtAssocTrack, ptAssocTrack, float); //! Pt of the track -DECLARE_SOA_COLUMN(DcaXY, dcaXY, float); //! Impact parameter in XY of the track to the primary vertex -DECLARE_SOA_COLUMN(DcaZ, dcaZ, float); //! Impact parameter in Z of the track to the primary vertex -DECLARE_SOA_COLUMN(NTpcCrossedRowsTrig, nTpcCrossedRowsTrig, UChar_t); //! Number of crossed TPC Rows -DECLARE_SOA_COLUMN(ItsClusterMapTrig, itsClusterMapTrig, UChar_t); //! ITS cluster map, one bit per a layer, starting from the innermost -DECLARE_SOA_COLUMN(ItsNClsTrig, itsNClsTrig, UChar_t); //! Number of ITS clusters +DECLARE_SOA_COLUMN(OriginTrackId, originTrackId, int); //! Original track index +DECLARE_SOA_COLUMN(NTpcCrossedRows, nTpcCrossedRows, int); //! Number of crossed TPC Rows +DECLARE_SOA_COLUMN(ItsClusterMap, itsClusterMap, int); //! ITS cluster map, one bit per a layer, starting from the innermost +DECLARE_SOA_COLUMN(ItsNCls, itsNCls, int); //! Number of ITS clusters +DECLARE_SOA_COLUMN(EtaAssocTrack, etaAssocTrack, float); //! Eta of the track +DECLARE_SOA_COLUMN(PhiAssocTrack, phiAssocTrack, float); //! Phi of the track +DECLARE_SOA_COLUMN(PtAssocTrack, ptAssocTrack, float); //! Pt of the track +DECLARE_SOA_COLUMN(DcaXY, dcaXY, float); //! Impact parameter in XY of the track to the primary vertex +DECLARE_SOA_COLUMN(DcaZ, dcaZ, float); //! Impact parameter in Z of the track to the primary vertex +DECLARE_SOA_COLUMN(NTpcCrossedRowsTrig, nTpcCrossedRowsTrig, int); //! Number of crossed TPC Rows +DECLARE_SOA_COLUMN(ItsClusterMapTrig, itsClusterMapTrig, int); //! ITS cluster map, one bit per a layer, starting from the innermost +DECLARE_SOA_COLUMN(ItsNClsTrig, itsNClsTrig, int); //! Number of ITS clusters DECLARE_SOA_COLUMN(EtaAssocTrackTrig, etaAssocTrackTrig, float); //! Eta of the track DECLARE_SOA_COLUMN(PhiAssocTrackTrig, phiAssocTrackTrig, float); //! Phi of the track DECLARE_SOA_COLUMN(PtAssocTrackTrig, ptAssocTrackTrig, float); //! Pt of the track From bd9b294b418343c7d5cecd1570b79023c116af3a Mon Sep 17 00:00:00 2001 From: marcellocosti Date: Tue, 16 Sep 2025 18:46:52 +0200 Subject: [PATCH 05/15] Update correlator script and table structure --- .../DataModel/DerivedDataCorrelationTables.h | 144 +++--- .../correlatorFlowCharmHadronsReduced.cxx | 429 ++++++++---------- .../derivedDataCreatorCorrelationsReduced.cxx | 346 +++++--------- 3 files changed, 354 insertions(+), 565 deletions(-) diff --git a/PWGHF/HFC/DataModel/DerivedDataCorrelationTables.h b/PWGHF/HFC/DataModel/DerivedDataCorrelationTables.h index 2b5e41cf04f..64265da6905 100644 --- a/PWGHF/HFC/DataModel/DerivedDataCorrelationTables.h +++ b/PWGHF/HFC/DataModel/DerivedDataCorrelationTables.h @@ -35,7 +35,7 @@ DECLARE_SOA_TABLE(HfcRedCollisions, "AOD", "HFCREDCOLLISION", //! Table with col aod::hf_collisions_reduced::NumPvContrib, aod::hf_collisions_reduced::PosZ); -DECLARE_SOA_TABLE(HfcRedFlowColls, "AOD", "HFCREDFLOWCOLL", //! Table with collision info +DECLARE_SOA_TABLE(HfcRedCorrColls, "AOD", "HFCREDCORRCOLL", //! Table with collision info soa::Index<>, aod::hf_collisions_reduced::Multiplicity, aod::hf_collisions_reduced::NumPvContrib, @@ -43,14 +43,11 @@ DECLARE_SOA_TABLE(HfcRedFlowColls, "AOD", "HFCREDFLOWCOLL", //! Table with colli aod::hf_collisions_reduced::PosZ); using HfcRedCollision = HfcRedCollisions::iterator; - -// DECLARE_SOA_TABLE(HfCandColCounts, "AOD", "HFCANDCOLCOUNT", //! Table with number of collisions which contain at least one candidate -// aod::hf_collisions_reduced::OriginalCollisionCount); +using HfcRedCorrColl = HfcRedCorrColls::iterator; namespace hf_candidate_reduced { DECLARE_SOA_INDEX_COLUMN(HfcRedCollision, hfcRedCollision); //! ReducedCollision index -DECLARE_SOA_INDEX_COLUMN(HfcRedFlowColl, hfcRedFlowColl); //! ReducedCollision index DECLARE_SOA_COLUMN(Prong0Id, prong0Id, int); //! Prong 0 index DECLARE_SOA_COLUMN(Prong1Id, prong1Id, int); //! Prong 1 index DECLARE_SOA_COLUMN(Prong2Id, prong2Id, int); //! Prong2 index @@ -58,11 +55,8 @@ DECLARE_SOA_COLUMN(PhiCand, phiCand, float); //! Phi of the candi DECLARE_SOA_COLUMN(EtaCand, etaCand, float); //! Eta of the candidate DECLARE_SOA_COLUMN(PtCand, ptCand, float); //! Pt of the candidate DECLARE_SOA_COLUMN(InvMassDs, invMassDs, float); //! Invariant mass of Ds candidate -DECLARE_SOA_COLUMN(InvMassCand, invMassCand, float); //! Invariant mass of Charm candidate DECLARE_SOA_COLUMN(BdtScorePrompt, bdtScorePrompt, float); //! BDT output score for prompt hypothesis DECLARE_SOA_COLUMN(BdtScoreBkg, bdtScoreBkg, float); //! BDT output score for background hypothesis -DECLARE_SOA_COLUMN(BdtScore0, bdtScore0, float); //! First BDT output score -DECLARE_SOA_COLUMN(BdtScore1, bdtScore1, float); //! Second BDT output score } // namespace hf_candidate_reduced DECLARE_SOA_TABLE(DsCandReduceds, "AOD", "DSCANDREDUCED", //! Table with Ds candidate info soa::Index<>, @@ -81,35 +75,58 @@ DECLARE_SOA_TABLE(DsCandSelInfos, "AOD", "DSCANDSELINFO", //! Table with Ds cand aod::hf_candidate_reduced::BdtScorePrompt, aod::hf_candidate_reduced::BdtScoreBkg); -DECLARE_SOA_TABLE(HfcRedCharmTrigs, "AOD", "HFCREDCHARMTRIG", //! Table with charm hadron candidate info +namespace hf_correlation_trigger_reduced +{ +DECLARE_SOA_INDEX_COLUMN(HfcRedCorrColl, hfcRedCorrColl); //! ReducedCollision index +DECLARE_SOA_COLUMN(PhiTrig, phiTrig, float); //! Phi of the trigger candidate +DECLARE_SOA_COLUMN(EtaTrig, etaTrig, float); //! Eta of the trigger candidate +DECLARE_SOA_COLUMN(PtTrig, ptTrig, float); //! Pt of the trigger candidate +DECLARE_SOA_COLUMN(InvMassTrig, invMassTrig, float); //! Invariant mass of Charm trigger candidate +DECLARE_SOA_COLUMN(BdtScore0Trig, bdtScore0Trig, float); //! First BDT output score +DECLARE_SOA_COLUMN(BdtScore1Trig, bdtScore1Trig, float); //! Second BDT output score +DECLARE_SOA_COLUMN(NTpcCrossedRowsTrig, nTpcCrossedRowsTrig, int); //! Number of crossed TPC Rows +DECLARE_SOA_COLUMN(ItsClusterMapTrig, itsClusterMapTrig, int); //! ITS cluster map, one bit per a layer, starting from the innermost +DECLARE_SOA_COLUMN(ItsNClsTrig, itsNClsTrig, int); //! Number of ITS clusters +DECLARE_SOA_COLUMN(EtaTrigTrack, etaTrigTrack, float); //! Eta of the track +DECLARE_SOA_COLUMN(PhiTrigTrack, phiTrigTrack, float); //! Phi of the track +DECLARE_SOA_COLUMN(PtTrigTrack, ptTrigTrack, float); //! Pt of the track +DECLARE_SOA_COLUMN(DcaXYTrig, dcaXYTrig, float); //! Impact parameter in XY of the track to the primary vertex +DECLARE_SOA_COLUMN(DcaZTrig, dcaZTrig, float); //! Impact parameter in Z of the track to the primary vertex +} // namespace hf_correlation_trigger_reduced + +DECLARE_SOA_TABLE(HfcRedTrigs, "AOD", "HFCREDTRIG", //! Table with charm hadron candidate info soa::Index<>, - aod::hf_candidate_reduced::HfcRedFlowCollId, - aod::hf_candidate_reduced::PhiCand, - aod::hf_candidate_reduced::EtaCand, - aod::hf_candidate_reduced::PtCand, - aod::hf_candidate_reduced::InvMassCand, - aod::hf_candidate_reduced::BdtScore0, - aod::hf_candidate_reduced::BdtScore1); + aod::hf_correlation_trigger_reduced::HfcRedCorrCollId, + aod::hf_correlation_trigger_reduced::PhiTrig, + aod::hf_correlation_trigger_reduced::EtaTrig, + aod::hf_correlation_trigger_reduced::PtTrig); + +DECLARE_SOA_TABLE(HfcRedTrigCharms, "AOD", "HFCREDTRIGCHARM", //! Table with Same Event Charm-Hadron pairs information + aod::hf_correlation_trigger_reduced::HfcRedCorrCollId, + aod::hf_correlation_trigger_reduced::InvMassTrig, + aod::hf_correlation_trigger_reduced::BdtScore0Trig, + aod::hf_correlation_trigger_reduced::BdtScore1Trig); + +DECLARE_SOA_TABLE(HfcRedTrigHads, "AOD", "HFCREDTRIGHAD", //! Table with Same Event Charm-Hadron pairs information + aod::hf_correlation_trigger_reduced::HfcRedCorrCollId, + aod::hf_correlation_trigger_reduced::NTpcCrossedRowsTrig, + aod::hf_correlation_trigger_reduced::ItsClusterMapTrig, + aod::hf_correlation_trigger_reduced::ItsNClsTrig, + aod::hf_correlation_trigger_reduced::DcaXYTrig, + aod::hf_correlation_trigger_reduced::DcaZTrig); namespace hf_assoc_track_reduced { -DECLARE_SOA_COLUMN(OriginTrackId, originTrackId, int); //! Original track index -DECLARE_SOA_COLUMN(NTpcCrossedRows, nTpcCrossedRows, int); //! Number of crossed TPC Rows -DECLARE_SOA_COLUMN(ItsClusterMap, itsClusterMap, int); //! ITS cluster map, one bit per a layer, starting from the innermost -DECLARE_SOA_COLUMN(ItsNCls, itsNCls, int); //! Number of ITS clusters -DECLARE_SOA_COLUMN(EtaAssocTrack, etaAssocTrack, float); //! Eta of the track -DECLARE_SOA_COLUMN(PhiAssocTrack, phiAssocTrack, float); //! Phi of the track -DECLARE_SOA_COLUMN(PtAssocTrack, ptAssocTrack, float); //! Pt of the track -DECLARE_SOA_COLUMN(DcaXY, dcaXY, float); //! Impact parameter in XY of the track to the primary vertex -DECLARE_SOA_COLUMN(DcaZ, dcaZ, float); //! Impact parameter in Z of the track to the primary vertex -DECLARE_SOA_COLUMN(NTpcCrossedRowsTrig, nTpcCrossedRowsTrig, int); //! Number of crossed TPC Rows -DECLARE_SOA_COLUMN(ItsClusterMapTrig, itsClusterMapTrig, int); //! ITS cluster map, one bit per a layer, starting from the innermost -DECLARE_SOA_COLUMN(ItsNClsTrig, itsNClsTrig, int); //! Number of ITS clusters -DECLARE_SOA_COLUMN(EtaAssocTrackTrig, etaAssocTrackTrig, float); //! Eta of the track -DECLARE_SOA_COLUMN(PhiAssocTrackTrig, phiAssocTrackTrig, float); //! Phi of the track -DECLARE_SOA_COLUMN(PtAssocTrackTrig, ptAssocTrackTrig, float); //! Pt of the track -DECLARE_SOA_COLUMN(DcaXYTrig, dcaXYTrig, float); //! Impact parameter in XY of the track to the primary vertex -DECLARE_SOA_COLUMN(DcaZTrig, dcaZTrig, float); //! Impact parameter in Z of the track to the primary vertex +DECLARE_SOA_INDEX_COLUMN(HfcRedCorrColl, hfcRedCorrColl); //! ReducedCollision index +DECLARE_SOA_COLUMN(OriginTrackId, originTrackId, int); //! Original track index +DECLARE_SOA_COLUMN(NTpcCrossedRows, nTpcCrossedRows, int); //! Number of crossed TPC Rows +DECLARE_SOA_COLUMN(ItsClusterMap, itsClusterMap, int); //! ITS cluster map, one bit per a layer, starting from the innermost +DECLARE_SOA_COLUMN(ItsNCls, itsNCls, int); //! Number of ITS clusters +DECLARE_SOA_COLUMN(EtaAssocTrack, etaAssocTrack, float); //! Eta of the track +DECLARE_SOA_COLUMN(PhiAssocTrack, phiAssocTrack, float); //! Phi of the track +DECLARE_SOA_COLUMN(PtAssocTrack, ptAssocTrack, float); //! Pt of the track +DECLARE_SOA_COLUMN(DcaXY, dcaXY, float); //! Impact parameter in XY of the track to the primary vertex +DECLARE_SOA_COLUMN(DcaZ, dcaZ, float); //! Impact parameter in Z of the track to the primary vertex } // namespace hf_assoc_track_reduced DECLARE_SOA_TABLE(AssocTrackReds, "AOD", "ASSOCTRACKRED", //! Table with associated track info soa::Index<>, @@ -130,72 +147,41 @@ DECLARE_SOA_TABLE(AssocTrackSels, "AOD", "ASSOCTRACKSEL", //! Table with associa DECLARE_SOA_TABLE(HfcRedTrkAssocs, "AOD", "HFCREDTRKASSOC", //! Table with associated track info soa::Index<>, - aod::hf_candidate_reduced::HfcRedFlowCollId, + aod::hf_correlation_trigger_reduced::HfcRedCorrCollId, aod::hf_assoc_track_reduced::PhiAssocTrack, aod::hf_assoc_track_reduced::EtaAssocTrack, - aod::hf_assoc_track_reduced::PtAssocTrack, + aod::hf_assoc_track_reduced::PtAssocTrack) + +DECLARE_SOA_TABLE(HfcRedTrkSels, "AOD", "HFCREDSETRKSEL", //! Table with Same Event Track Selections information + aod::hf_correlation_trigger_reduced::HfcRedCorrCollId, aod::hf_assoc_track_reduced::NTpcCrossedRows, aod::hf_assoc_track_reduced::ItsClusterMap, aod::hf_assoc_track_reduced::ItsNCls, aod::hf_assoc_track_reduced::DcaXY, - aod::hf_assoc_track_reduced::DcaZ) + aod::hf_assoc_track_reduced::DcaZ); // definition of columns and tables for Charm-Hadron and Hadron-Hadron correlation pairs namespace hf_correlation_charm_hadron_reduced { -DECLARE_SOA_INDEX_COLUMN_FULL(CharmTrig, charmTrig, int, HfcRedCharmTrigs, "_0"); //! Reduced charm trigger candidate index -DECLARE_SOA_INDEX_COLUMN_FULL(HadTrig, hadTrig, int, HfcRedTrkAssocs, "_1"); //! Reduced hadron trigger candidate index -DECLARE_SOA_INDEX_COLUMN_FULL(TrkAssoc, trkAssoc, int, HfcRedTrkAssocs, "_2"); //! Reduced associated track index +DECLARE_SOA_INDEX_COLUMN(HfcRedCorrColl, hfcRedCorrColl); //! ReducedCollision index DECLARE_SOA_COLUMN(DeltaPhi, deltaPhi, float); //! DeltaPhi between charm hadron and Hadrons DECLARE_SOA_COLUMN(DeltaEta, deltaEta, float); //! DeltaEta between charm hadron and Hadrons DECLARE_SOA_COLUMN(PoolBin, poolBin, int); //! Pool Bin for the MixedEvent } // namespace hf_correlation_charm_hadron_reduced -DECLARE_SOA_TABLE(HfcRedSEChHads, "AOD", "HFCREDSECHHAD", //! Table with Same Event Charm-Hadron pairs information - aod::hf_correlation_charm_hadron_reduced::DeltaEta, - aod::hf_correlation_charm_hadron_reduced::DeltaPhi, - aod::hf_correlation_charm_hadron_reduced::PoolBin, - aod::hf_candidate_reduced::PtCand, - aod::hf_candidate_reduced::InvMassCand, - aod::hf_candidate_reduced::BdtScore0, - aod::hf_candidate_reduced::BdtScore1, +DECLARE_SOA_TABLE(HfcRedSEPairs, "AOD", "HFCREDSEPAIR", //! Table with Same Event Trig-Assoc pairs + aod::hf_correlation_charm_hadron_reduced::HfcRedCorrCollId, + aod::hf_correlation_trigger_reduced::PtTrig, aod::hf_assoc_track_reduced::PtAssocTrack, - aod::hf_assoc_track_reduced::NTpcCrossedRows, - aod::hf_assoc_track_reduced::ItsClusterMap, - aod::hf_assoc_track_reduced::ItsNCls, - aod::hf_assoc_track_reduced::DcaXY, - aod::hf_assoc_track_reduced::DcaZ); - -DECLARE_SOA_TABLE(HfcRedSEHadHads, "AOD", "HFCREDSEHADHAD", //! Table with Same Event Hadron-Hadron pairs information aod::hf_correlation_charm_hadron_reduced::DeltaEta, - aod::hf_correlation_charm_hadron_reduced::DeltaPhi, + aod::hf_correlation_charm_hadron_reduced::DeltaPhi); + +DECLARE_SOA_TABLE(HfcRedCorrPair, "AOD", "HFCREDCORRPAIR", //! Correlation pairs information aod::hf_correlation_charm_hadron_reduced::PoolBin, - aod::hf_assoc_track_reduced::PtAssocTrackTrig, - aod::hf_assoc_track_reduced::NTpcCrossedRowsTrig, - aod::hf_assoc_track_reduced::ItsClusterMapTrig, - aod::hf_assoc_track_reduced::ItsNClsTrig, - aod::hf_assoc_track_reduced::DcaXYTrig, - aod::hf_assoc_track_reduced::DcaZTrig, + aod::hf_correlation_trigger_reduced::PtTrig, aod::hf_assoc_track_reduced::PtAssocTrack, - aod::hf_assoc_track_reduced::NTpcCrossedRows, - aod::hf_assoc_track_reduced::ItsClusterMap, - aod::hf_assoc_track_reduced::ItsNCls, - aod::hf_assoc_track_reduced::DcaXY, - aod::hf_assoc_track_reduced::DcaZ); - -DECLARE_SOA_TABLE(HfcRedChHads, "AOD", "HFCREDCHHAD", //! Charm-Hadron pairs information - aod::hf_correlation_charm_hadron_reduced::CharmTrigId, - aod::hf_correlation_charm_hadron_reduced::TrkAssocId, - aod::hf_correlation_charm_hadron_reduced::DeltaEta, - aod::hf_correlation_charm_hadron_reduced::DeltaPhi, - aod::hf_correlation_charm_hadron_reduced::PoolBin); - -DECLARE_SOA_TABLE(HfcRedHadHads, "AOD", "HFCREDHADHAD", //! Hadron-Hadron pairs information - aod::hf_correlation_charm_hadron_reduced::HadTrigId, - aod::hf_correlation_charm_hadron_reduced::TrkAssocId, aod::hf_correlation_charm_hadron_reduced::DeltaEta, - aod::hf_correlation_charm_hadron_reduced::DeltaPhi, - aod::hf_correlation_charm_hadron_reduced::PoolBin); + aod::hf_correlation_charm_hadron_reduced::DeltaPhi); } // namespace o2::aod diff --git a/PWGHF/HFC/TableProducer/correlatorFlowCharmHadronsReduced.cxx b/PWGHF/HFC/TableProducer/correlatorFlowCharmHadronsReduced.cxx index b8eac589d1f..2c598b227e9 100644 --- a/PWGHF/HFC/TableProducer/correlatorFlowCharmHadronsReduced.cxx +++ b/PWGHF/HFC/TableProducer/correlatorFlowCharmHadronsReduced.cxx @@ -52,9 +52,44 @@ using namespace o2::hf_evsel; using BinningTypeDerivedCent = ColumnBinningPolicy; using BinningTypeDerivedMult = ColumnBinningPolicy; +/// Get charm candidate or hadron track pT +/// \param track is the candidate +template +double getPt(const TTrack& track) +{ + if constexpr (requires { track.ptAssocTrack(); }) { + return track.ptAssocTrack(); + } else { + return track.ptTrig(); + } +} + +/// Get charm candidate or hadron track eta +/// \param track is the candidate +template +double getEta(const TTrack& track) +{ + if constexpr (requires { track.etaAssocTrack(); }) { + return track.etaAssocTrack(); + } else { + return track.etaTrig(); + } +} + +/// Get charm candidate or hadron track phi +/// \param track is the candidate +template +double getPhi(const TTrack& track) +{ + if constexpr (requires { track.phiAssocTrack(); }) { + return track.phiAssocTrack(); + } else { + return track.phiTrig(); + } +} + struct HfCorrelatorFlowCharmHadronsReduced { - Produces entryCharmHadPair; - Produces entryHadHadPair; + Produces entryCorrPair; Configurable fillSparses{"fillSparses", true, "Fill sparse histograms"}; Configurable fillTables{"fillTables", false, "Fill tables"}; @@ -73,12 +108,14 @@ struct HfCorrelatorFlowCharmHadronsReduced { SliceCache cache; - using AssocTracks = soa::Filtered; + using AssocTracks = aod::HfcRedTrkAssocs; + // using AssocTracks = soa::Filtered>; + using SameEvtPairsChHad = soa::Filtered>; + using SameEvtPairsHadHad = soa::Filtered>; - Filter filterSelectTrackData = (nabs(aod::hf_assoc_track_reduced::dcaXY) < dcaXYTrackMax) && (nabs(aod::hf_assoc_track_reduced::dcaZ) < dcaZTrackMax) && (aod::hf_assoc_track_reduced::nTpcCrossedRows > tpcCrossedRowsMin) && (aod::hf_assoc_track_reduced::itsNCls > itsNClsMin); - - Preslice tracksPerCol = aod::hf_candidate_reduced::hfcRedFlowCollId; - Preslice candsPerCol = aod::hf_candidate_reduced::hfcRedFlowCollId; + Filter filterTrackData = (nabs(aod::hf_assoc_track_reduced::dcaXY) < dcaXYTrackMax) && (nabs(aod::hf_assoc_track_reduced::dcaZ) < dcaZTrackMax) && (aod::hf_assoc_track_reduced::nTpcCrossedRows > tpcCrossedRowsMin) && (aod::hf_assoc_track_reduced::itsNCls > itsNClsMin); + Filter filterSameEvtPairsChHad = (nabs(aod::hf_assoc_track_reduced::dcaXY) < dcaXYTrackMax) && (nabs(aod::hf_assoc_track_reduced::dcaZ) < dcaZTrackMax) && (aod::hf_assoc_track_reduced::nTpcCrossedRows > tpcCrossedRowsMin) && (aod::hf_assoc_track_reduced::itsNCls > itsNClsMin); + Filter filterSameEvtPairsHadHad = (nabs(aod::hf_assoc_track_reduced::dcaXY) < dcaXYTrackMax) && (nabs(aod::hf_assoc_track_reduced::dcaZ) < dcaZTrackMax) && (aod::hf_assoc_track_reduced::nTpcCrossedRows > tpcCrossedRowsMin) && (aod::hf_assoc_track_reduced::itsNCls > itsNClsMin); ConfigurableAxis zPoolBins{"zPoolBins", {VARIABLE_WIDTH, -10.0, -2.5, 2.5, 10.0}, "Z vertex position pools"}; ConfigurableAxis multPoolBins{"multPoolBins", {VARIABLE_WIDTH, 0., 900., 1800., 6000.}, "Event multiplicity pools (FT0M)"}; @@ -97,18 +134,18 @@ struct HfCorrelatorFlowCharmHadronsReduced { HistogramRegistry registry{"registry", {}, OutputObjHandlingPolicy::AnalysisObject}; + ColumnBinningPolicy binPolicyPosZMult{{zPoolBins, multPoolBins}, true}; + ColumnBinningPolicy binPolicyPosZCent{{zPoolBins, centPoolBins}, true}; + void init(InitContext&) { std::array doprocess{doprocessSameEventCharmHadWCentMix, doprocessSameEventCharmHadWMultMix, doprocessMixedEventCharmHadWCentMix, doprocessMixedEventCharmHadWMultMix, doprocessSameEventHadHadWCentMix, doprocessSameEventHadHadWMultMix, doprocessMixedEventHadHadWCentMix, doprocessMixedEventHadHadWMultMix}; - if ((std::accumulate(doprocess.begin(), doprocess.end(), 0)) > 1) { + if ((std::accumulate(doprocess.begin(), doprocess.end(), 0)) != 1) { LOGP(fatal, "Only one process function should be enabled! Please check your configuration!"); - if (!((doprocessSameEventCharmHadWCentMix && doprocessMixedEventCharmHadWCentMix) || (doprocessSameEventCharmHadWMultMix && doprocessMixedEventCharmHadWMultMix))) { - LOG(fatal) << "Different binning policies between Same Event and Mixed Event"; - } - if (!((doprocessSameEventHadHadWCentMix && doprocessMixedEventHadHadWCentMix) || (doprocessSameEventHadHadWMultMix && doprocessMixedEventHadHadWMultMix))) { - LOG(fatal) << "Different binning policies between Same Event and Mixed Event"; - } + } + if (!fillSparses && !fillTables) { + LOGP(fatal, "At least one of fillSparses or fillTables must be true!"); } const AxisSpec axisInvMass{binsInvMass, "Inv. mass (GeV/#it{c}^{2})"}; @@ -141,7 +178,7 @@ struct HfCorrelatorFlowCharmHadronsReduced { registry.add("hEtaVsPtAssoc", "Associated particles etaVsPt", {HistType::kTH3F, {{axisEta}, {axisPtTrig}, {axisPtAssoc}}}); if (fillSparses) { - std::vector axes = {axisPtTrig, axisPtAssoc, axisDeltaEta, axisDeltaPhi, axisPoolBin}; + std::vector axes = {axisPoolBin, axisPtTrig, axisPtAssoc, axisDeltaEta, axisDeltaPhi}; if (doprocessSameEventHadHadWCentMix || doprocessSameEventHadHadWMultMix) { registry.add("hSparseCorrelationsSEHadHad", "THn for SE Had-Had correlations", HistType::kTHnSparseF, axes); } else if (doprocessMixedEventHadHadWCentMix || doprocessMixedEventHadHadWMultMix) { @@ -157,56 +194,20 @@ struct HfCorrelatorFlowCharmHadronsReduced { } } - /// Get charm candidate or hadron track pT - /// \param track is the candidate - template - double getPt(const TTrack& track) - { - if constexpr (requires { track.ptAssocTrack(); }) { - return track.ptAssocTrack(); - } else { - return track.ptCand(); - } - } - - /// Get charm candidate or hadron track eta - /// \param track is the candidate - template - double getEta(const TTrack& track) - { - if constexpr (requires { track.etaAssocTrack(); }) { - return track.etaAssocTrack(); - } else { - return track.etaCand(); - } - } - - /// Get charm candidate or hadron track phi - /// \param track is the candidate - template - double getPhi(const TTrack& track) - { - if constexpr (requires { track.phiAssocTrack(); }) { - return track.phiAssocTrack(); - } else { - return track.phiCand(); - } - } - /// Get the binning pool associated to the collision /// \param collision is the collision - /// \param corrBinning is the binning policy for the correlation + /// \param binPolicy is the binning policy for the correlation template - int getPoolBin(const TColl& collision, const TBinningType& corrBinning) + int getPoolBin(const TColl& collision, const TBinningType& binPolicy) { int poolBin{0}; if constexpr (std::is_same_v) { - poolBin = corrBinning.getBin(std::make_tuple(collision.posZ(), collision.centrality())); + poolBin = binPolicy.getBin(std::make_tuple(collision.posZ(), collision.centrality())); if constexpr (fillHistos) { registry.fill(HIST("hCent"), collision.centrality(), poolBin); } } else if constexpr (std::is_same_v) { - poolBin = corrBinning.getBin(std::make_tuple(collision.posZ(), collision.multiplicity())); + poolBin = binPolicy.getBin(std::make_tuple(collision.posZ(), collision.multiplicity())); if constexpr (fillHistos) { registry.fill(HIST("hMultFT0M"), collision.multiplicity(), poolBin); } @@ -214,129 +215,32 @@ struct HfCorrelatorFlowCharmHadronsReduced { return poolBin; } - // /// Reject daughter-track pairs and same-track pairs - // /// \param cand is the trigger candidate - // /// \param track is the associated track - // template - // bool rejSameEvtPair(const TTrigPart& cand, const TTrack& track) - // { - // if constexpr (requires { cand.originTrackId(); }) { - // // Remove same track pairs for Had-Had correlations - // return (cand.originTrackId() == track.originTrackId()); - // } else { - // return false; - // // Remove pairs with 2- and 3-prong daughters (prong2Id returns -1 for 2-prongs) - // // return ((cand.prong0Id() == track.originTrackId()) || (cand.prong1Id() == track.originTrackId()) || (cand.prong2Id() == track.originTrackId())); - // } - // } - - /// Slice trigger candidates by collision - /// \param cands are the trigger candidates - /// \param collId is the collision index - template - auto sliceTrigCands(TTrigCands const& cands, const int collId) - { - if constexpr (std::is_same_v) { - return cands.sliceBy(tracksPerCol, collId); - } else { - return cands.sliceBy(candsPerCol, collId); - } - } - - /// Fill Charm-Hadron correlation table and sparse - /// \param trigCand is the trigger charm hadron candidate - /// \param assocTrack is the associated hadron track - /// \param poolBin is the pool bin of the collision - template - void fillCharmHadInfo(TTrigCand const& trigCand, - TTrack const& assocTrack, - const int poolBin) - { - double deltaEta = getEta(assocTrack) - getEta(trigCand); - double deltaPhi = RecoDecay::constrainAngle(getPhi(assocTrack) - getPhi(trigCand), -o2::constants::math::PIHalf); - if (fillTables) { - entryCharmHadPair(-1, -1, deltaEta, deltaPhi, poolBin); - // entryCharmHadPair(trigCand.globalIndex(), assocTrack.globalIndex(), deltaEta, deltaPhi, poolBin); - } - if (fillSparses) { - if constexpr (isMixedEvent) { - registry.fill(HIST("hSparseCorrelationsMECharmHad"), getPt(trigCand), getPt(assocTrack), - deltaEta, deltaPhi, poolBin, trigCand.bdtScore0(), - trigCand.bdtScore1(), trigCand.invMassCand()); - } else { - registry.fill(HIST("hSparseCorrelationsSECharmHad"), getPt(trigCand), getPt(assocTrack), - deltaEta, deltaPhi, poolBin, trigCand.bdtScore0(), - trigCand.bdtScore1(), trigCand.invMassCand()); - } - } - } - - /// Fill Hadron-Hadron correlation table and sparse - /// \param trigCand is the trigger hadron candidate - /// \param assocTrack is the associated hadron track - /// \param poolBin is the pool bin of the collision - template - void fillHadHadInfo(TCand const& trigCand, - TCand const& assocTrack, - const int poolBin) - { - double deltaEta = getEta(assocTrack) - getEta(trigCand); - double deltaPhi = RecoDecay::constrainAngle(getPhi(assocTrack) - getPhi(trigCand), -o2::constants::math::PIHalf); - if (fillTables) { - // entryHadHadPair(trigCand.globalIndex(), assocTrack.globalIndex(), deltaEta, deltaPhi, poolBin); - entryHadHadPair(-1, -1, deltaEta, deltaPhi, poolBin); - } - if (fillSparses) { - if constexpr (isMixedEvent) { - registry.fill(HIST("hSparseCorrelationsMEHadHad"), getPt(trigCand), getPt(assocTrack), deltaEta, deltaPhi, poolBin); - } else { - registry.fill(HIST("hSparseCorrelationsSEHadHad"), getPt(trigCand), getPt(assocTrack), deltaEta, deltaPhi, poolBin); - } - } - } - /// Save info for Same Event pairs /// \param collisions are the selected collisions /// \param trigCands are the selected trigger candidates /// \param assocTracks are the selected associated tracks - /// \param corrBinning is the binning policy for the correlation - template - void fillSameEvent(aod::HfcRedFlowColls const& collisions, - TTrigCands const& trigCands, - TAssocTracks const& assocTracks, - TBinningType corrBinning) + /// \param binPolicy is the binning policy for the correlation + template + void fillSameEvent(TPair const& pair, + TBinningType binPolicy) { - for (const auto& collision : collisions) { - int poolBin = getPoolBin(collision, corrBinning); - registry.fill(HIST("hCollisionPoolBin"), poolBin); - registry.fill(HIST("hZVtx"), collision.posZ(), poolBin); - - auto thisCollId = collision.globalIndex(); - auto trigCandsThisColl = sliceTrigCands(trigCands, thisCollId); - auto assocTracksThisColl = assocTracks.sliceBy(tracksPerCol, thisCollId); - - for (const auto& trigCand : trigCandsThisColl) { - registry.fill(HIST("hPoolBinTrig"), poolBin); - registry.fill(HIST("hPhiVsPtTrig"), RecoDecay::constrainAngle(getPhi(trigCand), -o2::constants::math::PIHalf), getPt(trigCand)); - registry.fill(HIST("hEtaVsPtTrig"), getEta(trigCand), getPt(trigCand)); - for (const auto& assocTrack : assocTracksThisColl) { - // if (rejSameEvtPair(trigCand, assocTrack)) { - // continue; - // } - double deltaEta = getEta(assocTrack) - getEta(trigCand); - if (std::abs(deltaEta) < deltaEtaAbsMin || std::abs(deltaEta) > deltaEtaAbsMax) { - continue; - } - registry.fill(HIST("hPoolBinAssoc"), poolBin); - registry.fill(HIST("hPhiVsPtAssoc"), RecoDecay::constrainAngle(getPhi(assocTrack), -o2::constants::math::PIHalf), getPt(trigCand), getPt(assocTrack)); - registry.fill(HIST("hEtaVsPtAssoc"), getEta(assocTrack), getPt(trigCand), getPt(assocTrack)); - - if constexpr (std::is_same_v) { - fillHadHadInfo(trigCand, assocTrack, poolBin); - } else { - fillCharmHadInfo(trigCand, assocTrack, poolBin); - } - } + // auto collision = pair.template hfcRedCorrColl_as(); + int poolBin = -1; + // int poolBin = getPoolBin(collision, binPolicy); + registry.fill(HIST("hCollisionPoolBin"), poolBin); + registry.fill(HIST("hZVtx"), -1, poolBin); + // registry.fill(HIST("hZVtx"), collision.posZ(), poolBin); + registry.fill(HIST("hPoolBinTrig"), poolBin); + registry.fill(HIST("hPoolBinAssoc"), poolBin); + if constexpr (fillTables) { + entryCorrPair(poolBin, pair.ptTrig(), pair.ptAssocTrack(), pair.deltaEta(), pair.deltaPhi()); + } + if constexpr (fillSparses) { + if constexpr (requires{ pair.bdtScore0Trig(); }) { // Separate Charm-Had and Had-Had cases + registry.fill(HIST("hSparseCorrelationsSECharmHad"), poolBin, pair.ptTrig(), pair.ptAssocTrack(), pair.deltaEta(), + pair.deltaPhi(), pair.bdtScore0Trig(), pair.bdtScore1Trig(), pair.invMassTrig()); + } else { + registry.fill(HIST("hSparseCorrelationsSEHadHad"), poolBin, pair.ptTrig(), pair.ptAssocTrack(), pair.deltaEta(), pair.deltaPhi()); } } } @@ -345,134 +249,161 @@ struct HfCorrelatorFlowCharmHadronsReduced { /// \param collisions are the selected collisions /// \param trigCands are the selected trigger candidates /// \param assocTracks are the selected associated tracks - /// \param corrBinning is the binning policy for the correlation - template - void fillMixedEvent(aod::HfcRedFlowColls const& collisions, + /// \param binPolicy is the binning policy for the correlation + template + void fillMixedEvent(TColl const& collisions, TTrigCands const& trigCands, TAssocTracks const& assocTracks, - TBinningType corrBinning) + TBinningType binPolicy) { - for (const auto& collision : collisions) { - int poolBin = getPoolBin(collision, corrBinning); - registry.fill(HIST("hCollisionPoolBin"), poolBin); - registry.fill(HIST("hZVtx"), collision.posZ(), poolBin); - - auto thisCollId = collision.globalIndex(); - auto trigCandsThisColl = sliceTrigCands(trigCands, thisCollId); - auto assocTracksThisColl = assocTracks.sliceBy(tracksPerCol, thisCollId); - for (const auto& trigCand : trigCandsThisColl) { - registry.fill(HIST("hPoolBinTrig"), poolBin); - registry.fill(HIST("hPhiVsPtTrig"), RecoDecay::constrainAngle(getPhi(trigCand), -o2::constants::math::PIHalf), getPt(trigCand)); - registry.fill(HIST("hEtaVsPtTrig"), getEta(trigCand), getPt(trigCand)); - for (const auto& assocTrack : assocTracksThisColl) { - registry.fill(HIST("hPoolBinAssoc"), poolBin); - registry.fill(HIST("hPhiVsPtAssoc"), RecoDecay::constrainAngle(getPhi(assocTrack), -o2::constants::math::PIHalf), getPt(trigCand), getPt(assocTrack)); - registry.fill(HIST("hEtaVsPtAssoc"), getEta(assocTrack), getPt(trigCand), getPt(assocTrack)); - } - } - } - auto pairsTuple = std::make_tuple(trigCands, assocTracks); - Pair pairData{corrBinning, numberEventsMixed, -1, collisions, pairsTuple, &cache}; + Pair pairData{binPolicy, numberEventsMixed, -1, collisions, pairsTuple, &cache}; for (const auto& [trigColl, trigCands, assocColl, assocTracks] : pairData) { if (trigCands.size() == 0 || assocTracks.size() == 0) { continue; } - int poolBinCharm = getPoolBin(trigColl, corrBinning); - int poolBinAssoc = getPoolBin(assocColl, corrBinning); - if (poolBinAssoc != poolBinCharm) { + int poolBinTrig = getPoolBin(trigColl, binPolicy); + int poolBinAssoc = getPoolBin(assocColl, binPolicy); + if (poolBinAssoc != poolBinTrig) { LOGF(info, "Error, poolBins are different"); continue; } for (const auto& [trigCand, assocTrack] : o2::soa::combinations(o2::soa::CombinationsFullIndexPolicy(trigCands, assocTracks))) { + // LOGF(info, "Mixed event tracks pair: (%d, %d) from events (%d, %d), track event: (%d, %d)", trigCand.index(), assocTrack.index(), trigColl.index(), assocColl.index(), trigCand.hfcRedFlowCollId(), assocTrack.hfcRedFlowCollId()); double deltaEta = getEta(assocTrack) - getEta(trigCand); if (std::abs(deltaEta) < deltaEtaAbsMin || std::abs(deltaEta) > deltaEtaAbsMax) { continue; } + double ptTrig = getPt(trigCand); + double ptAssoc = getPt(assocTrack); if (downSamplePairsME < 1.) { - float pseudoRndm = getPt(assocTrack) * 1000. - static_cast(getPt(assocTrack) * 1000); - if (getPt(trigCand) < ptMaxForDownSampleME && trigColl.centrality() < centMaxForDownSampleME && - assocColl.centrality() < centMaxForDownSampleME && pseudoRndm >= downSamplePairsME) { + float pseudoRndm = ptAssoc * 1000. - static_cast(ptAssoc * 1000); + if (ptTrig < ptMaxForDownSampleME && trigColl.centrality() < centMaxForDownSampleME && + assocColl.centrality() < centMaxForDownSampleME && pseudoRndm >= downSamplePairsME) { continue; } } - // LOGF(info, "Mixed event tracks pair: (%d, %d) from events (%d, %d), track event: (%d, %d)", trigCand.index(), assocTrack.index(), trigColl.index(), assocColl.index(), trigCand.hfcRedFlowCollId(), assocTrack.hfcRedFlowCollId()); - if constexpr (std::is_same_v) { - fillHadHadInfo(trigCand, assocTrack, poolBinCharm); - } else { - fillCharmHadInfo(trigCand, assocTrack, poolBinCharm); + double deltaPhi = getPhi(assocTrack) - getPhi(trigCand); + if constexpr (fillTables) { + entryCorrPair(poolBinTrig, ptTrig, ptAssoc, deltaEta, deltaPhi); + } + if constexpr (fillSparses) { + if constexpr (requires{ trigCand.bdtScore0(); }) { // Separate Charm-Had and Had-Had cases + registry.fill(HIST("hSparseCorrelationsMECharmHad"), poolBinTrig, ptTrig, ptAssoc, deltaEta, + deltaPhi, trigCand.bdtScore0(), trigCand.bdtScore1(), trigCand.invMassCand()); + } else { + registry.fill(HIST("hSparseCorrelationsMEHadHad"), poolBinTrig, ptTrig, ptAssoc, deltaEta, deltaPhi); + } } } } } - void processSameEventCharmHadWCentMix(aod::HfcRedFlowColls const& collisions, - aod::HfcRedCharmTrigs const& candidates, - AssocTracks const& tracks) + void processSameEventCharmHadWMultMix(SameEvtPairsChHad::iterator const& pair, + aod::HfcRedCorrColls const&) { - ColumnBinningPolicy corrBinningCent{{zPoolBins, centPoolBins}, true}; - fillSameEvent(collisions, candidates, tracks, corrBinningCent); + if (fillSparses && fillTables) { + fillSameEvent(pair, binPolicyPosZMult); + } else if (fillSparses) { + fillSameEvent(pair, binPolicyPosZMult); + } else if (fillTables) { + fillSameEvent(pair, binPolicyPosZMult); + } } - PROCESS_SWITCH(HfCorrelatorFlowCharmHadronsReduced, processSameEventCharmHadWCentMix, "Process Same Event for Charm-Had with centrality pools", true); + PROCESS_SWITCH(HfCorrelatorFlowCharmHadronsReduced, processSameEventCharmHadWMultMix, "Process Same Event for Charm-Had with multiplicity pools", true); - void processSameEventCharmHadWMultMix(aod::HfcRedFlowColls const& collisions, - aod::HfcRedCharmTrigs const& candidates, - AssocTracks const& tracks) + void processSameEventHadHadWMultMix(SameEvtPairsHadHad::iterator const& pair, + aod::HfcRedCorrColls const&) { - ColumnBinningPolicy corrBinningMult{{zPoolBins, multPoolBins}, true}; - fillSameEvent(collisions, candidates, tracks, corrBinningMult); + if (fillSparses && fillTables) { + fillSameEvent(pair, binPolicyPosZMult); + } else if (fillSparses) { + fillSameEvent(pair, binPolicyPosZMult); + } else if (fillTables) { + fillSameEvent(pair, binPolicyPosZMult); + } } - PROCESS_SWITCH(HfCorrelatorFlowCharmHadronsReduced, processSameEventCharmHadWMultMix, "Process Same Event for Charm-Had with multiplicity pools", false); + PROCESS_SWITCH(HfCorrelatorFlowCharmHadronsReduced, processSameEventHadHadWMultMix, "Process Same Event for Had-Had with multiplicity pools", false); - void processMixedEventCharmHadWCentMix(aod::HfcRedFlowColls const& collisions, - aod::HfcRedCharmTrigs const& candidates, - AssocTracks const& tracks) + void processSameEventCharmHadWCentMix(SameEvtPairsChHad::iterator const& pair, + aod::HfcRedCorrColls const&) { - ColumnBinningPolicy corrBinningCent{{zPoolBins, centPoolBins}, true}; - fillMixedEvent(collisions, candidates, tracks, corrBinningCent); + if (fillSparses && fillTables) { + fillSameEvent(pair, binPolicyPosZCent); + } else if (fillSparses) { + fillSameEvent(pair, binPolicyPosZCent); + } else if (fillTables) { + fillSameEvent(pair, binPolicyPosZCent); + } } - PROCESS_SWITCH(HfCorrelatorFlowCharmHadronsReduced, processMixedEventCharmHadWCentMix, "Process Mixed Event for Charm-Had with centrality pools", false); + PROCESS_SWITCH(HfCorrelatorFlowCharmHadronsReduced, processSameEventCharmHadWCentMix, "Process Same Event for Charm-Had with centrality pools", true); - void processMixedEventCharmHadWMultMix(aod::HfcRedFlowColls const& collisions, - aod::HfcRedCharmTrigs const& candidates, - AssocTracks const& tracks) + void processSameEventHadHadWCentMix(SameEvtPairsHadHad::iterator const& pair, + aod::HfcRedCorrColls const&) { - ColumnBinningPolicy corrBinningMult{{zPoolBins, multPoolBins}, true}; - fillMixedEvent(collisions, candidates, tracks, corrBinningMult); + if (fillSparses && fillTables) { + fillSameEvent(pair, binPolicyPosZCent); + } else if (fillSparses) { + fillSameEvent(pair, binPolicyPosZCent); + } else if (fillTables) { + fillSameEvent(pair, binPolicyPosZCent); + } } - PROCESS_SWITCH(HfCorrelatorFlowCharmHadronsReduced, processMixedEventCharmHadWMultMix, "Process Mixed Event for Charm-Had with multiplicity pools", false); + PROCESS_SWITCH(HfCorrelatorFlowCharmHadronsReduced, processSameEventHadHadWCentMix, "Process Same Event for Had-Had with centrality pools", false); - void processSameEventHadHadWCentMix(aod::HfcRedFlowColls const& collisions, - AssocTracks const& tracks) + void processMixedEventCharmHadWCentMix(aod::HfcRedCorrColls const& collisions, + soa::Join const& candidates, + AssocTracks const& tracks) { - ColumnBinningPolicy corrBinningCent{{zPoolBins, centPoolBins}, true}; - fillSameEvent(collisions, tracks, tracks, corrBinningCent); + if (fillSparses && fillTables) { + fillMixedEvent(collisions, candidates, tracks, binPolicyPosZCent); + } else if (fillSparses) { + fillMixedEvent(collisions, candidates, tracks, binPolicyPosZCent); + } else if (fillTables) { + fillMixedEvent(collisions, candidates, tracks, binPolicyPosZCent); + } } - PROCESS_SWITCH(HfCorrelatorFlowCharmHadronsReduced, processSameEventHadHadWCentMix, "Process Same Event for Had-Had with centrality pools", false); + PROCESS_SWITCH(HfCorrelatorFlowCharmHadronsReduced, processMixedEventCharmHadWCentMix, "Process Mixed Event for Charm-Had with centrality pools", false); - void processSameEventHadHadWMultMix(aod::HfcRedFlowColls const& collisions, - AssocTracks const& tracks) + void processMixedEventCharmHadWMultMix(aod::HfcRedCorrColls const& collisions, + soa::Join const& candidates, + AssocTracks const& tracks) { - ColumnBinningPolicy corrBinningMult{{zPoolBins, multPoolBins}, true}; - fillSameEvent(collisions, tracks, tracks, corrBinningMult); + if (fillSparses && fillTables) { + fillMixedEvent(collisions, candidates, tracks, binPolicyPosZMult); + } else if (fillSparses) { + fillMixedEvent(collisions, candidates, tracks, binPolicyPosZMult); + } else if (fillTables) { + fillMixedEvent(collisions, candidates, tracks, binPolicyPosZMult); + } } - PROCESS_SWITCH(HfCorrelatorFlowCharmHadronsReduced, processSameEventHadHadWMultMix, "Process Same Event for Had-Had with multiplicity pools", false); + PROCESS_SWITCH(HfCorrelatorFlowCharmHadronsReduced, processMixedEventCharmHadWMultMix, "Process Mixed Event for Charm-Had with multiplicity pools", false); - void processMixedEventHadHadWCentMix(aod::HfcRedFlowColls const& collisions, + void processMixedEventHadHadWCentMix(aod::HfcRedCorrColls const& collisions, AssocTracks const& tracks) { - ColumnBinningPolicy corrBinningCent{{zPoolBins, centPoolBins}, true}; - fillMixedEvent(collisions, tracks, tracks, corrBinningCent); + if (fillSparses && fillTables) { + fillMixedEvent(collisions, tracks, tracks, binPolicyPosZCent); + } else if (fillSparses) { + fillMixedEvent(collisions, tracks, tracks, binPolicyPosZCent); + } else if (fillTables) { + fillMixedEvent(collisions, tracks, tracks, binPolicyPosZCent); + } } PROCESS_SWITCH(HfCorrelatorFlowCharmHadronsReduced, processMixedEventHadHadWCentMix, "Process Mixed Event for Had-Had with centrality pools", false); - void processMixedEventHadHadWMultMix(aod::HfcRedFlowColls const& collisions, + void processMixedEventHadHadWMultMix(aod::HfcRedCorrColls const& collisions, AssocTracks const& tracks) { - ColumnBinningPolicy corrBinningMult{{zPoolBins, multPoolBins}, true}; - fillMixedEvent(collisions, tracks, tracks, corrBinningMult); + if (fillSparses && fillTables) { + fillMixedEvent(collisions, tracks, tracks, binPolicyPosZMult); + } else if (fillSparses) { + fillMixedEvent(collisions, tracks, tracks, binPolicyPosZMult); + } else if (fillTables) { + fillMixedEvent(collisions, tracks, tracks, binPolicyPosZMult); + } } PROCESS_SWITCH(HfCorrelatorFlowCharmHadronsReduced, processMixedEventHadHadWMultMix, "Process Mixed Event for Had-Had with multiplicity pools", false); }; diff --git a/PWGHF/HFC/TableProducer/derivedDataCreatorCorrelationsReduced.cxx b/PWGHF/HFC/TableProducer/derivedDataCreatorCorrelationsReduced.cxx index fa8da654e0e..f52a0585ad1 100644 --- a/PWGHF/HFC/TableProducer/derivedDataCreatorCorrelationsReduced.cxx +++ b/PWGHF/HFC/TableProducer/derivedDataCreatorCorrelationsReduced.cxx @@ -51,9 +51,6 @@ using namespace o2::framework::expressions; using namespace o2::hf_centrality; using namespace o2::hf_evsel; -using BinningTypeDerivedCent = ColumnBinningPolicy; -using BinningTypeDerivedMult = ColumnBinningPolicy; - enum CandType { DplusToPiKPi = 0, DsToKKPi, @@ -63,47 +60,37 @@ enum CandType { Hadron }; -enum PoolBinningPolicy { - Centrality = 0, - Multiplicity -}; - /// Code to select collisions with at least one Ds meson struct HfDerivedDataCreatorCorrelationsReduced { - Produces rowCollisions; - Produces rowCharmCandidates; - Produces rowAssocTrackReduced; - Produces entryCharmHadSEPair; - Produces entryHadHadSEPair; + Produces rowCollisions; // Table with reduced collision info + Produces rowSEPairs; // Table with same-event pairs info + Produces rowAssocTrks; // Table with associated track info + Produces rowAssocTrkSels; // Table with associated track selection info + Produces rowTrigs; // Table with charm candidate info + Produces rowTrigCharms; // Table with charm trigger candidate info + Produces rowTrigHads; // Table with hadron trigger candidate info Configurable centEstimator{"centEstimator", 2, "Centrality estimation (FT0A: 1, FT0C: 2, FT0M: 3, FV0A: 4)"}; Configurable selectionFlag{"selectionFlag", 15, "Selection Flag for hadron (ML score tables are required to run the task)"}; Configurable forceCharmInCollision{"forceCharmInCollision", true, "Flag to force charm in collision"}; - Configurable useCentMixing{"useCentMixing", true, "Flag to use centrality mixing"}; - Configurable useMultMixing{"useMultMixing", false, "Flag to use multiplicity mixing"}; Configurable ccdbUrl{"ccdbUrl", "http://alice-ccdb.cern.ch", "url of the ccdb repository"}; Configurable> classMl{"classMl", {0, 2}, "Indexes of BDT scores to be stored. Two indexes max."}; Configurable yCandMax{"yCandMax", 0.8, "max. cand. rapidity"}; Configurable ptCandMin{"ptCandMin", 1., "min. cand. pT"}; Configurable ptCandMax{"ptCandMax", 24., "max. cand. pT"}; Configurable tpcNClsCrossedRowsMin{"tpcNClsCrossedRowsMin", 70, "min. TPC crossed rows for associated tracks"}; - Configurable etaTrackMax{"etaTrackMax", 1., "max. track eta"}; - Configurable ptTrackMin{"ptTrackMin", 0.15, "min. track pT"}; - Configurable ptTrackMax{"ptTrackMax", 5., "max. track pT"}; - Configurable dcaXYTrackMax{"dcaXYTrackMax", 1., "max. track DCA XY"}; - Configurable dcaZTrackMax{"dcaZTrackMax", 1., "max. track DCA Z"}; + Configurable etaTrkMax{"etaTrkMax", 1., "max. track eta"}; + Configurable ptTrkMin{"ptTrkMin", 0.5, "min. track pT"}; + Configurable ptTrkMax{"ptTrkMax", 5., "max. track pT"}; + Configurable dcaXYTrkMax{"dcaXYTrkMax", 1., "max. track DCA XY"}; + Configurable dcaZTrkMax{"dcaZTrkMax", 1., "max. track DCA Z"}; Configurable deltaEtaAbsMin{"deltaEtaAbsMin", 0.5, "min. pair delta eta"}; Configurable deltaEtaAbsMax{"deltaEtaAbsMax", 2., "max. pair delta eta"}; - Configurable downSampleTracksFactorSE{"downSampleTracksFactorSE", 1., "Fraction of associated tracks to keep"}; - Configurable ptMaxForDownSampleSE{"ptMaxForDownSampleSE", 10., "Maximum pt for the application of the downsampling factor"}; - Configurable centMaxForDownSampleSE{"centMaxForDownSampleSE", 10., "Maximum centrality for the application of the downsampling factor"}; - Configurable downSampleTracksFactorME{"downSampleTracksFactorME", 1., "Fraction of associated tracks to keep"}; - Configurable ptMaxForDownSampleME{"ptMaxForDownSampleME", 10., "Maximum pt for the application of the downsampling factor"}; - Configurable centMaxForDownSampleME{"centMaxForDownSampleME", 10., "Maximum centrality for the application of the downsampling factor"}; + Configurable downSampleTrksFactor{"downSampleTrksFactor", 1., "Fraction of associated tracks to keep"}; + Configurable ptMaxForDownSample{"ptMaxForDownSample", 10., "Maximum pt for the application of the downsampling factor"}; + Configurable centMaxForDownSample{"centMaxForDownSample", 101., "Maximum centrality for the application of the downsampling factor"}; Configurable> binsPtTrig{"binsPtTrig", std::vector{1., 3., 5., 8., 16., 36.}, "pT bin limits for trigger candidates"}; Configurable> binsPtAssoc{"binsPtAssoc", std::vector{0.3, 1., 2., 50.}, "pT bin limits for associated particles"}; - Configurable fillSparses{"fillSparses", true, "Fill sparse histograms"}; - Configurable fillTables{"fillTables", false, "Fill tables"}; HfHelper hfHelper; HfEventSelection hfEvSel; // event selection and monitoring @@ -116,26 +103,23 @@ struct HfDerivedDataCreatorCorrelationsReduced { using CandDsData = soa::Filtered>; using CandDplusData = soa::Filtered>; using CandD0Data = soa::Filtered>; - using TracksData = soa::Filtered>; + using TrksData = soa::Filtered>; Filter filterSelectDsCandidates = aod::hf_sel_candidate_ds::isSelDsToKKPi >= selectionFlag || aod::hf_sel_candidate_ds::isSelDsToPiKK >= selectionFlag; Filter filterSelectDplusCandidates = aod::hf_sel_candidate_dplus::isSelDplusToPiKPi >= selectionFlag; Filter filterSelectD0Candidates = aod::hf_sel_candidate_d0::isSelD0 >= selectionFlag || aod::hf_sel_candidate_d0::isSelD0bar >= selectionFlag; - Filter filterSelectTrackData = (nabs(aod::track::eta) < etaTrackMax) && (aod::track::pt > ptTrackMin) && (aod::track::pt < ptTrackMax) && (nabs(aod::track::dcaXY) < dcaXYTrackMax) && (nabs(aod::track::dcaZ) < dcaZTrackMax); + Filter filterSelectTrkData = (nabs(aod::track::eta) < etaTrkMax) && (aod::track::pt > ptTrkMin) && (aod::track::pt < ptTrkMax) && (nabs(aod::track::dcaXY) < dcaXYTrkMax) && (nabs(aod::track::dcaZ) < dcaZTrkMax); Preslice candsDsPerColl = aod::hf_cand::collisionId; Preslice candsDplusPerColl = aod::hf_cand::collisionId; Preslice candsD0PerColl = aod::hf_cand::collisionId; - Preslice trackIndicesPerColl = aod::track::collisionId; + Preslice trackIndicesPerColl = aod::track::collisionId; Partition selectedDsToKKPi = aod::hf_sel_candidate_ds::isSelDsToKKPi >= selectionFlag; Partition selectedDsToPiKK = aod::hf_sel_candidate_ds::isSelDsToPiKK >= selectionFlag; Partition selectedD0ToPiK = aod::hf_sel_candidate_d0::isSelD0 >= selectionFlag; Partition selectedD0ToKPi = aod::hf_sel_candidate_d0::isSelD0bar >= selectionFlag; - ConfigurableAxis zPoolBins{"zPoolBins", {VARIABLE_WIDTH, -10.0, -2.5, 2.5, 10.0}, "Z vertex position pools"}; - ConfigurableAxis multPoolBins{"multPoolBins", {VARIABLE_WIDTH, 0., 900., 1800., 6000.}, "Event multiplicity pools (FT0M)"}; - ConfigurableAxis centPoolBins{"centPoolBins", {VARIABLE_WIDTH, 0., 10., 20., 30.}, "Event centrality pools"}; ConfigurableAxis binsInvMass{"binsInvMass", {300, 1.6, 2.2}, ""}; ConfigurableAxis binsMultFT0M{"binsMultFT0M", {100, 0., 10000.}, "Multiplicity as FT0M signal amplitude"}; ConfigurableAxis binsCent{"binsCent", {100, 0., 100.}, "Centrality bins"}; @@ -144,15 +128,11 @@ struct HfDerivedDataCreatorCorrelationsReduced { ConfigurableAxis binsPhi{"binsPhi", {64, -o2::constants::math::PIHalf, 3. * o2::constants::math::PIHalf}, "Phi bins"}; ConfigurableAxis binsDeltaEta{"binsDeltaEta", {100, -2., 2.}, "Delta Eta bins"}; ConfigurableAxis binsDeltaPhi{"binsDeltaPhi", {64, -3., 3.}, "Delta Phi bins"}; - ConfigurableAxis binsPoolBin{"binsPoolBin", {9, 0., 9.}, "PoolBin"}; ConfigurableAxis binsMlOne{"binsMlOne", {100, 0., 1.}, ""}; ConfigurableAxis binsMlTwo{"binsMlTwo", {100, 0., 1.}, ""}; HistogramRegistry registry{"registry", {}}; - ColumnBinningPolicy corrBinningCent{{zPoolBins, centPoolBins}, true}; - ColumnBinningPolicy corrBinningMult{{zPoolBins, multPoolBins}, true}; - void init(InitContext&) { if (doprocessDplusSameEvent || doprocessDplusMixedEvent) { @@ -161,6 +141,8 @@ struct HfDerivedDataCreatorCorrelationsReduced { massCharm = o2::constants::physics::MassDS; } else if (doprocessD0SameEvent || doprocessD0MixedEvent) { massCharm = o2::constants::physics::MassD0; + } else if (doprocessHadronHadronSameEvent || doprocessHadronHadronMixedEvent) { + LOG(info) << "Charm mass not set, processing Hadron-Hadron case"; } else { LOG(fatal) << "No decay channel selected to process"; } @@ -170,52 +152,21 @@ struct HfDerivedDataCreatorCorrelationsReduced { ccdb->setCaching(true); ccdb->setLocalObjectValidityChecking(); - const AxisSpec axisInvMass{binsInvMass, "Inv. mass (GeV/#it{c}^{2})"}; const AxisSpec axisCent = {binsCent, "Centrality"}; const AxisSpec axisMultFT0M = {binsMultFT0M, "MultiplicityFT0M"}; const AxisSpec axisPosZ = {binsPosZ, "PosZ"}; - const AxisSpec axisPoolBin = {binsPoolBin, "PoolBin"}; const AxisSpec axisEta = {binsEta, "#it{#eta}"}; const AxisSpec axisPhi = {binsPhi, "#it{#varphi}"}; - const AxisSpec axisDeltaEta = {binsDeltaEta, "#Delta#it{#eta}"}; - const AxisSpec axisDeltaPhi = {binsDeltaPhi, "#Delta#it{#varphi}"}; const AxisSpec axisPtTrig = {(std::vector)binsPtTrig, "#it{p}_{T} Trig (GeV/#it{c})"}; const AxisSpec axisPtAssoc = {(std::vector)binsPtAssoc, "#it{p}_{T} Assoc (GeV/#it{c})"}; - const AxisSpec axisMlOne{binsMlOne, "bdtScore0"}; - const AxisSpec axisMlTwo{binsMlTwo, "bdtScore1"}; // Histograms for data analysis - if (useCentMixing) { - registry.add("hCent", "Centrality", {HistType::kTH2F, {{axisCent}, {axisPoolBin}}}); - } else { - registry.add("hMultFT0M", "Multiplicity FT0M", {HistType::kTH2F, {{axisMultFT0M}, {axisPoolBin}}}); - } - registry.add("hZVtx", "z vertex", {HistType::kTH2F, {{axisPosZ}, {axisPoolBin}}}); - registry.add("hCollisionPoolBin", "Collision pool bin", {HistType::kTH1F, {axisPoolBin}}); - registry.add("hPoolBinTrig", "Trigger candidates pool bin", {HistType::kTH1F, {axisPoolBin}}); registry.add("hPhiVsPtTrig", "Trigger candidates phiVsPt", {HistType::kTH2F, {{axisPhi}, {axisPtTrig}}}); registry.add("hEtaVsPtTrig", "Trigger candidates etaVsPt", {HistType::kTH2F, {{axisEta}, {axisPtTrig}}}); registry.add("hPhiVsPtTrigAssoc", "Associated particles phiVsPt", {HistType::kTH3F, {{axisPhi}, {axisPtTrig}, {axisPtAssoc}}}); registry.add("hEtaVsPtTrigAssoc", "Associated particles etaVsPt", {HistType::kTH3F, {{axisEta}, {axisPtTrig}, {axisPtAssoc}}}); registry.add("hPhiVsPtAssoc", "Associated particles phiVsPt", {HistType::kTH2F, {{axisPhi}, {axisPtAssoc}}}); registry.add("hEtaVsPtAssoc", "Associated particles etaVsPt", {HistType::kTH2F, {{axisEta}, {axisPtAssoc}}}); - registry.add("hPoolBinAssoc", "Associated particles pool bin", {HistType::kTH1F, {axisPoolBin}}); - - // if (fillSparses) { - // std::vector axes = {axisPtTrig, axisPtAssoc, axisDeltaEta, axisDeltaPhi, axisPoolBin}; - // if (doprocessSameEventDplusWCentMix) { - // registry.add("hSparseCorrelationsSEHadHad", "THn for SE Had-Had correlations", HistType::kTHnSparseF, axes); - // } else if (doprocessMixedEventHadHadWCentMix || doprocessMixedEventHadHadWMultMix) { - // registry.add("hSparseCorrelationsMEHadHad", "THn for ME Had-Had correlations", HistType::kTHnSparseF, axes); - // } else { - // axes.insert(axes.end(), {axisMlOne, axisMlTwo, axisInvMass}); - // if (doprocessSameEventDplusCharmHadWCentMix || doprocessSameEventCharmHadWMultMix) { - // registry.add("hSparseCorrelationsSECharmHad", "THn for SE Charm-Had correlations", HistType::kTHnSparseF, axes); - // } else if (doprocessMixedEventCharmHadWCentMix || doprocessMixedEventCharmHadWMultMix) { - // registry.add("hSparseCorrelationsMECharmHad", "THn for ME Charm-Had correlations", HistType::kTHnSparseF, axes); - // } - // } - // } }; // end init /// Get charm hadron candidate mass @@ -244,9 +195,9 @@ struct HfDerivedDataCreatorCorrelationsReduced { /// Get charm hadron bdt scores /// \param candidate is the charm hadron candidate template - std::vector getCandMlScores(const TCand& candidate) + std::array getCandMlScores(const TCand& candidate) { - std::vector outputMl{-999., -999.}; + std::array outputMl{-999.f, -999.f}; if constexpr (candType == CandType::DsToKKPi) { for (unsigned int iclass = 0; iclass < classMl->size(); iclass++) { outputMl[iclass] = candidate.mlProbDsToKKPi()[classMl->at(iclass)]; @@ -304,174 +255,119 @@ struct HfDerivedDataCreatorCorrelationsReduced { return true; } - template - bool checkDaughterTrack(TTrack const& track, TCand const& cand) + /// Checks if the trigger cand-associated track pair can be accepted for SE correlation + /// \param assTrk is the associated track + /// \param cand is the trigger candidate + template + bool acceptSameEvtPair(TAssocTrk const& assTrk, TCand const& cand) { - if constexpr ((requires { cand.prong2Id(); })) { // Check 3-prong - return (track.globalIndex() == cand.prong0Id() || track.globalIndex() == cand.prong1Id() || track.globalIndex() == cand.prong2Id()); - } else { // Check 2-prong - return (track.globalIndex() == cand.prong0Id() || track.globalIndex() == cand.prong1Id()); + double deltaEta = assTrk.eta() - cand.eta(); + if (std::abs(deltaEta) <= deltaEtaAbsMin || std::abs(deltaEta) > deltaEtaAbsMax) { + return false; } - } - /// Fill Charm-Hadron correlation table and sparse - /// \param trigCand is the trigger charm hadron candidate - /// \param assTrk is the associated hadron track - /// \param poolBin is the pool bin of the collision - template - void fillCharmHadSE(TTrigCand const& trigCand, - TTrack const& assTrk, - const int poolBin) - { - double deltaEta = assTrk.eta() - trigCand.eta(); - double deltaPhi = RecoDecay::constrainAngle(assTrk.phi() - trigCand.phi(), -o2::constants::math::PIHalf); - std::vector outputMl = getCandMlScores(trigCand); - double massCand = getCandMass(trigCand); - if (fillTables) { - entryCharmHadSEPair(deltaEta, deltaPhi, poolBin, trigCand.pt(), massCand, outputMl[0], outputMl[1], - assTrk.pt(), assTrk.tpcNClsCrossedRows(), assTrk.itsClusterMap(), assTrk.itsNCls(), assTrk.dcaXY(), assTrk.dcaZ()); - } - // if (fillSparses) { - // registry.fill(HIST("hSparseCorrelationsSECharmHad"), trigCand.pt(), assTrk.pt(), - // deltaEta, deltaPhi, poolBin, trigCand.bdtScore0(), - // trigCand.bdtScore1(), trigCand.invMassCand()); - // } - } + if (!assTrk.isGlobalTrackWoDCA() || assTrk.tpcNClsCrossedRows() < tpcNClsCrossedRowsMin) { + return false; + } - /// Fill Hadron-Hadron correlation table and sparse - /// \param trigTrack is the trigger hadron candidate - /// \param assTrk is the associated hadron track - /// \param poolBin is the pool bin of the collision - template - void fillHadHadSE(TCand const& trigTrack, - TCand const& assTrk, - const int poolBin) - { - double deltaEta = assTrk.eta() - trigTrack.eta(); - double deltaPhi = RecoDecay::constrainAngle(assTrk.phi() - trigTrack.phi(), -o2::constants::math::PIHalf); - if (fillTables) { - entryHadHadSEPair(deltaEta, deltaPhi, poolBin, - trigTrack.pt(), assTrk.tpcNClsCrossedRows(), assTrk.itsClusterMap(), assTrk.itsNCls(), assTrk.dcaXY(), assTrk.dcaZ(), - assTrk.pt(), assTrk.tpcNClsCrossedRows(), assTrk.itsClusterMap(), assTrk.itsNCls(), assTrk.dcaXY(), assTrk.dcaZ()); - } - // if (fillSparses) { - // registry.fill(HIST("hSparseCorrelationsSEHadHad"), trigCand.pt(), assTrk.pt(), deltaEta, deltaPhi, poolBin); - // } + if constexpr (candType == CandType::Hadron) { + if (!cand.isGlobalTrackWoDCA() || cand.tpcNClsCrossedRows() < tpcNClsCrossedRowsMin) { + return false; + } + if (assTrk.globalIndex() == cand.globalIndex()) { + return false; // skip self-correlation for hadron-hadron + } + } else { // Remove Daughter-Cand pairs for charm-hadron correlations + if constexpr ((requires { cand.prong2Id(); })) { // Check 3-prong + return (assTrk.globalIndex() == cand.prong0Id() || assTrk.globalIndex() == cand.prong1Id() || assTrk.globalIndex() == cand.prong2Id()); + } else { // Check 2-prong + return (assTrk.globalIndex() == cand.prong0Id() || assTrk.globalIndex() == cand.prong1Id()); + } + } + return true; } - template + /// Fill histograms and tables for same-event correlations + /// \param trigCands are the trigger candidates + /// \param assTrks are the associated tracks + /// \param collCentrality is the collision centrality + template void fillSameEvent(TTrigCands const& trigCands, - TAssocTracks const& assTrks, - const int poolBin, + TAssocTrks const& assTrks, const float collCentrality) { - for (const auto& trigCand : trigCands) { - registry.fill(HIST("hPoolBinTrig"), poolBin); registry.fill(HIST("hPhiVsPtTrig"), RecoDecay::constrainAngle(trigCand.phi(), -o2::constants::math::PIHalf), trigCand.pt()); registry.fill(HIST("hEtaVsPtTrig"), trigCand.eta(), trigCand.pt()); for (const auto& assTrk : assTrks) { - if (assTrk.tpcNClsCrossedRows() < tpcNClsCrossedRowsMin) { + if (!acceptSameEvtPair(assTrk, trigCand)) { continue; } - double deltaEta = assTrk.eta() - trigCand.eta(); - if (std::abs(deltaEta) < deltaEtaAbsMin || std::abs(deltaEta) > deltaEtaAbsMax) { - continue; - } - if constexpr (candType == CandType::Hadron) { - if (assTrk.globalIndex() == trigCand.globalIndex()) { - continue; // skip self-correlation for hadron-hadron - } - if (downSampleTracksFactorSE < 1.) { - float pseudoRndm = assTrk.pt() * 1000. - static_cast(assTrk.pt() * 1000); - if (assTrk.pt() < ptMaxForDownSampleSE && collCentrality < centMaxForDownSampleSE && pseudoRndm >= downSampleTracksFactorSE) { - continue; - } - } - } else { - if (checkDaughterTrack(assTrk, trigCand)) { - continue; // skip daughter tracks for charm-hadron + double assTrkPt = assTrk.pt(); + if (downSampleTrksFactor < 1.) { + float pseudoRndm = assTrkPt * 1000. - static_cast(assTrkPt * 1000); + if (assTrkPt < ptMaxForDownSample && collCentrality < centMaxForDownSample && pseudoRndm >= downSampleTrksFactor) { + continue; } } - - registry.fill(HIST("hPoolBinAssoc"), poolBin); - registry.fill(HIST("hPhiVsPtTrigAssoc"), RecoDecay::constrainAngle(assTrk.phi(), -o2::constants::math::PIHalf), trigCand.pt(), assTrk.pt()); - registry.fill(HIST("hEtaVsPtAssoc"), assTrk.eta(), trigCand.pt(), assTrk.pt()); + registry.fill(HIST("hPhiVsPtTrigAssoc"), RecoDecay::constrainAngle(assTrk.phi(), -o2::constants::math::PIHalf), trigCand.pt(), assTrkPt); + registry.fill(HIST("hEtaVsPtAssoc"), assTrk.eta(), trigCand.pt(), assTrkPt); + + double deltaEta = assTrk.eta() - trigCand.eta(); + double deltaPhi = RecoDecay::constrainAngle(assTrk.phi() - trigCand.phi(), -o2::constants::math::PIHalf); + rowSEPairs(rowCollisions.lastIndex(), trigCand.pt(), assTrkPt, deltaEta, deltaPhi); + rowAssocTrkSels(rowCollisions.lastIndex(), assTrk.tpcNClsCrossedRows(), assTrk.itsClusterMap(), assTrk.itsNCls(), assTrk.dcaXY(), assTrk.dcaZ()); if constexpr (candType == CandType::Hadron) { - fillHadHadSE(trigCand, assTrk, poolBin); + rowTrigHads(rowCollisions.lastIndex(), trigCand.tpcNClsCrossedRows(), trigCand.itsClusterMap(), trigCand.itsNCls(), trigCand.dcaXY(), trigCand.dcaZ()); } else { - fillCharmHadSE(trigCand, assTrk, poolBin); + std::array outputMl = getCandMlScores(trigCand); + rowTrigCharms(rowCollisions.lastIndex(), getCandMass(trigCand), outputMl[0], outputMl[1]); } } } } template - void fillCharmMixedEvent(TTrigCands const& trigCands, - const int poolBin) + void fillCharmMixedEvent(TTrigCands const& trigCands) { for (const auto& trigCand : trigCands) { - registry.fill(HIST("hPoolBinTrig"), poolBin); registry.fill(HIST("hPhiVsPtTrig"), RecoDecay::constrainAngle(trigCand.phi(), -o2::constants::math::PIHalf), trigCand.pt()); registry.fill(HIST("hEtaVsPtTrig"), trigCand.eta(), trigCand.pt()); - rowCharmCandidates(rowCollisions.lastIndex(), trigCand.phi(), trigCand.eta(), trigCand.pt(), - getCandMass(trigCand), getCandMlScores(trigCand)[0], - getCandMlScores(trigCand)[1]); + std::array outputMl = getCandMlScores(trigCand); + rowTrigs(rowCollisions.lastIndex(), trigCand.phi(), trigCand.eta(), trigCand.pt()); + rowTrigCharms(rowCollisions.lastIndex(), getCandMass(trigCand), outputMl[0], outputMl[1]); } } - template - void fillTrackMixedEvent(TAssocTracks const& assTrks, - const int poolBin, - const float collCentrality) + template + void fillTrkMixedEvent(TAssocTrks const& assTrks, + const float collCentrality) { bool first = true; for (const auto& assTrk : assTrks) { - if (assTrk.tpcNClsCrossedRows() < tpcNClsCrossedRowsMin) { + if (!assTrk.isGlobalTrackWoDCA() || assTrk.tpcNClsCrossedRows() < tpcNClsCrossedRowsMin) { continue; } - if (!first && downSampleTracksFactorME < 1.) { - float pseudoRndm = assTrk.pt() * 1000. - static_cast(assTrk.pt() * 1000); - if (assTrk.pt() < ptMaxForDownSampleME && collCentrality < centMaxForDownSampleME && pseudoRndm >= downSampleTracksFactorME) { + double assTrkPt = assTrk.pt(); + if (!first && downSampleTrksFactor < 1.) { // skip downsampling for the first track to avoid empty tables + float pseudoRndm = assTrkPt * 1000. - static_cast(assTrkPt * 1000); + if (assTrkPt < ptMaxForDownSample && collCentrality < centMaxForDownSample && pseudoRndm >= downSampleTrksFactor) { continue; } } first = false; - registry.fill(HIST("hPoolBinAssoc"), poolBin); - registry.fill(HIST("hPhiVsPtAssoc"), RecoDecay::constrainAngle(assTrk.phi(), -o2::constants::math::PIHalf), assTrk.pt()); - registry.fill(HIST("hEtaVsPtAssoc"), assTrk.eta(), assTrk.pt()); - rowAssocTrackReduced(rowCollisions.lastIndex(), assTrk.phi(), assTrk.eta(), - assTrk.pt(), assTrk.tpcNClsCrossedRows(), assTrk.itsClusterMap(), - assTrk.itsNCls(), assTrk.dcaXY(), assTrk.dcaZ()); - } - } - - /// Get the binning pool associated to the collision - /// \param collision is the collision - /// \param corrBinning is the binning policy for the correlation - template - int getPoolBin(const TColl& collision, const float cent, const float mult) - { - int poolBin{0}; - if constexpr (binningPolicy == PoolBinningPolicy::Centrality) { - poolBin = corrBinningCent.getBin(std::make_tuple(collision.posZ(), cent)); - if constexpr (fillHistos) { - registry.fill(HIST("hCent"), cent, poolBin); - } - } else if constexpr (binningPolicy == PoolBinningPolicy::Multiplicity) { - poolBin = corrBinningMult.getBin(std::make_tuple(collision.posZ(), mult)); - if constexpr (fillHistos) { - registry.fill(HIST("hMultFT0M"), mult, poolBin); - } + registry.fill(HIST("hPhiVsPtAssoc"), RecoDecay::constrainAngle(assTrk.phi(), -o2::constants::math::PIHalf), assTrkPt); + registry.fill(HIST("hEtaVsPtAssoc"), assTrk.eta(), assTrkPt); + rowAssocTrks(rowCollisions.lastIndex(), assTrk.phi(), assTrk.eta(), assTrkPt); + rowAssocTrkSels(rowCollisions.lastIndex(), assTrk.tpcNClsCrossedRows(), assTrk.itsClusterMap(), assTrk.itsNCls(), assTrk.dcaXY(), assTrk.dcaZ()); } - return poolBin; } // Dplus with ML selections void processDplusSameEvent(CollsWithCentMult::iterator const& coll, CandDplusData const& candsDplus, - TracksData const& tracks) + TrksData const& tracks) { if (forceCharmInCollision && candsDplus.size() < 1) { return; @@ -481,17 +377,14 @@ struct HfDerivedDataCreatorCorrelationsReduced { return; } rowCollisions(mult, coll.numContrib(), cent, coll.posZ()); - int poolBin = useCentMixing ? getPoolBin(coll, cent, mult) : getPoolBin(coll, cent, mult); - registry.fill(HIST("hCollisionPoolBin"), poolBin); - registry.fill(HIST("hZVtx"), coll.posZ(), poolBin); - fillSameEvent(candsDplus, tracks, poolBin, cent); + fillSameEvent(candsDplus, tracks, cent); } PROCESS_SWITCH(HfDerivedDataCreatorCorrelationsReduced, processDplusSameEvent, "Process Same Event for Dplus candidates", true); // Dplus with ML selections void processDplusMixedEvent(CollsWithCentMult::iterator const& coll, CandDplusData const& candsDplus, - TracksData const& tracks) + TrksData const& tracks) { if (forceCharmInCollision && candsDplus.size() < 1) { return; @@ -501,17 +394,14 @@ struct HfDerivedDataCreatorCorrelationsReduced { return; } rowCollisions(mult, coll.numContrib(), cent, coll.posZ()); - int poolBin = useCentMixing ? getPoolBin(coll, cent, mult) : getPoolBin(coll, cent, mult); - registry.fill(HIST("hCollisionPoolBin"), poolBin); - registry.fill(HIST("hZVtx"), coll.posZ(), poolBin); - fillCharmMixedEvent(candsDplus, poolBin); - fillTrackMixedEvent(tracks, poolBin, cent); + fillCharmMixedEvent(candsDplus); + fillTrkMixedEvent(tracks, cent); } PROCESS_SWITCH(HfDerivedDataCreatorCorrelationsReduced, processDplusMixedEvent, "Process Mixed Event for Dplus candidates", false); // Ds with ML selections void processDsSameEvent(CollsWithCentMult::iterator const& coll, - TracksData const& tracks, + TrksData const& tracks, CandDsData const&) { auto candsDsToPiKK = selectedDsToPiKK->sliceByCached(aod::hf_cand::collisionId, coll.globalIndex(), cache); @@ -524,17 +414,14 @@ struct HfDerivedDataCreatorCorrelationsReduced { return; } rowCollisions(mult, coll.numContrib(), cent, coll.posZ()); - int poolBin = useCentMixing ? getPoolBin(coll, cent, mult) : getPoolBin(coll, cent, mult); - registry.fill(HIST("hCollisionPoolBin"), poolBin); - registry.fill(HIST("hZVtx"), coll.posZ(), poolBin); - fillSameEvent(candsDsToPiKK, tracks, poolBin, cent); - fillSameEvent(candsDsToKKPi, tracks, poolBin, cent); + fillSameEvent(candsDsToPiKK, tracks, cent); + fillSameEvent(candsDsToKKPi, tracks, cent); } PROCESS_SWITCH(HfDerivedDataCreatorCorrelationsReduced, processDsSameEvent, "Process Same Event for Ds candidates", false); // Ds with ML selections void processDsMixedEvent(CollsWithCentMult::iterator const& coll, - TracksData const& tracks, + TrksData const& tracks, CandDsData const&) { auto candsDsToPiKK = selectedDsToPiKK->sliceByCached(aod::hf_cand::collisionId, coll.globalIndex(), cache); @@ -547,18 +434,15 @@ struct HfDerivedDataCreatorCorrelationsReduced { return; } rowCollisions(mult, coll.numContrib(), cent, coll.posZ()); - int poolBin = useCentMixing ? getPoolBin(coll, cent, mult) : getPoolBin(coll, cent, mult); - registry.fill(HIST("hCollisionPoolBin"), poolBin); - registry.fill(HIST("hZVtx"), coll.posZ(), poolBin); - fillCharmMixedEvent(candsDsToPiKK, poolBin); - fillCharmMixedEvent(candsDsToKKPi, poolBin); - fillTrackMixedEvent(tracks, poolBin, cent); + fillCharmMixedEvent(candsDsToPiKK); + fillCharmMixedEvent(candsDsToKKPi); + fillTrkMixedEvent(tracks, cent); } PROCESS_SWITCH(HfDerivedDataCreatorCorrelationsReduced, processDsMixedEvent, "Process Mixed Event for Ds candidates", false); // D0 with ML selections void processD0SameEvent(CollsWithCentMult::iterator const& coll, - TracksData const& tracks, + TrksData const& tracks, CandD0Data const&) { auto candsD0ToPiK = selectedD0ToPiK->sliceByCached(aod::hf_cand::collisionId, coll.globalIndex(), cache); @@ -571,17 +455,14 @@ struct HfDerivedDataCreatorCorrelationsReduced { return; } rowCollisions(mult, coll.numContrib(), cent, coll.posZ()); - int poolBin = useCentMixing ? getPoolBin(coll, cent, mult) : getPoolBin(coll, cent, mult); - registry.fill(HIST("hCollisionPoolBin"), poolBin); - registry.fill(HIST("hZVtx"), coll.posZ(), poolBin); - fillSameEvent(candsD0ToPiK, tracks, poolBin, cent); - fillSameEvent(candsD0ToKPi, tracks, poolBin, cent); + fillSameEvent(candsD0ToPiK, tracks, cent); + fillSameEvent(candsD0ToKPi, tracks, cent); } PROCESS_SWITCH(HfDerivedDataCreatorCorrelationsReduced, processD0SameEvent, "Process Same Event for D0 candidates", false); // D0 with ML selections void processD0MixedEvent(CollsWithCentMult::iterator const& coll, - TracksData const& tracks, + TrksData const& tracks, CandD0Data const&) { auto candsD0ToPiK = selectedD0ToPiK->sliceByCached(aod::hf_cand::collisionId, coll.globalIndex(), cache); @@ -594,44 +475,35 @@ struct HfDerivedDataCreatorCorrelationsReduced { return; } rowCollisions(mult, coll.numContrib(), cent, coll.posZ()); - int poolBin = useCentMixing ? getPoolBin(coll, cent, mult) : getPoolBin(coll, cent, mult); - registry.fill(HIST("hCollisionPoolBin"), poolBin); - registry.fill(HIST("hZVtx"), coll.posZ(), poolBin); - fillCharmMixedEvent(candsD0ToPiK, poolBin); - fillCharmMixedEvent(candsD0ToKPi, poolBin); - fillTrackMixedEvent(tracks, poolBin, cent); + fillCharmMixedEvent(candsD0ToPiK); + fillCharmMixedEvent(candsD0ToKPi); + fillTrkMixedEvent(tracks, cent); } PROCESS_SWITCH(HfDerivedDataCreatorCorrelationsReduced, processD0MixedEvent, "Process Mixed Event for D0 candidates", false); // Hadron Hadron Same Event void processHadronHadronSameEvent(CollsWithCentMult::iterator const& coll, - TracksData const& tracks) + TrksData const& tracks) { float cent{-1.}, mult{-1.}; if (!checkCollision(coll, cent, mult)) { return; } rowCollisions(mult, coll.numContrib(), cent, coll.posZ()); - int poolBin = useCentMixing ? getPoolBin(coll, cent, mult) : getPoolBin(coll, cent, mult); - registry.fill(HIST("hCollisionPoolBin"), poolBin); - registry.fill(HIST("hZVtx"), coll.posZ(), poolBin); - fillSameEvent(tracks, tracks, poolBin, cent); + fillSameEvent(tracks, tracks, cent); } PROCESS_SWITCH(HfDerivedDataCreatorCorrelationsReduced, processHadronHadronSameEvent, "Process Same Event for hadron candidates", true); // Hadron Hadron Mixed Event void processHadronHadronMixedEvent(CollsWithCentMult::iterator const& coll, - TracksData const& tracks) + TrksData const& tracks) { float cent{-1.}, mult{-1.}; if (!checkCollision(coll, cent, mult)) { return; } rowCollisions(mult, coll.numContrib(), cent, coll.posZ()); - int poolBin = useCentMixing ? getPoolBin(coll, cent, mult) : getPoolBin(coll, cent, mult); - registry.fill(HIST("hCollisionPoolBin"), poolBin); - registry.fill(HIST("hZVtx"), coll.posZ(), poolBin); - fillTrackMixedEvent(tracks, poolBin, cent); + fillTrkMixedEvent(tracks, cent); } PROCESS_SWITCH(HfDerivedDataCreatorCorrelationsReduced, processHadronHadronMixedEvent, "Process Mixed Event for hadron candidates", false); }; From ab71ca15f5712f2b0adee08d1ef421724dddc2ed Mon Sep 17 00:00:00 2001 From: marcellocosti Date: Tue, 16 Sep 2025 22:48:24 +0200 Subject: [PATCH 06/15] Fix missing preslice for event mixing --- .../DataModel/DerivedDataCorrelationTables.h | 11 +++------ .../correlatorFlowCharmHadronsReduced.cxx | 23 ++++++++++--------- .../derivedDataCreatorCorrelationsReduced.cxx | 15 ++++++++---- 3 files changed, 25 insertions(+), 24 deletions(-) diff --git a/PWGHF/HFC/DataModel/DerivedDataCorrelationTables.h b/PWGHF/HFC/DataModel/DerivedDataCorrelationTables.h index 64265da6905..23ad203d9a8 100644 --- a/PWGHF/HFC/DataModel/DerivedDataCorrelationTables.h +++ b/PWGHF/HFC/DataModel/DerivedDataCorrelationTables.h @@ -102,13 +102,11 @@ DECLARE_SOA_TABLE(HfcRedTrigs, "AOD", "HFCREDTRIG", //! Table with charm hadron aod::hf_correlation_trigger_reduced::PtTrig); DECLARE_SOA_TABLE(HfcRedTrigCharms, "AOD", "HFCREDTRIGCHARM", //! Table with Same Event Charm-Hadron pairs information - aod::hf_correlation_trigger_reduced::HfcRedCorrCollId, aod::hf_correlation_trigger_reduced::InvMassTrig, aod::hf_correlation_trigger_reduced::BdtScore0Trig, aod::hf_correlation_trigger_reduced::BdtScore1Trig); DECLARE_SOA_TABLE(HfcRedTrigHads, "AOD", "HFCREDTRIGHAD", //! Table with Same Event Charm-Hadron pairs information - aod::hf_correlation_trigger_reduced::HfcRedCorrCollId, aod::hf_correlation_trigger_reduced::NTpcCrossedRowsTrig, aod::hf_correlation_trigger_reduced::ItsClusterMapTrig, aod::hf_correlation_trigger_reduced::ItsNClsTrig, @@ -117,7 +115,6 @@ DECLARE_SOA_TABLE(HfcRedTrigHads, "AOD", "HFCREDTRIGHAD", //! Table with Same Ev namespace hf_assoc_track_reduced { -DECLARE_SOA_INDEX_COLUMN(HfcRedCorrColl, hfcRedCorrColl); //! ReducedCollision index DECLARE_SOA_COLUMN(OriginTrackId, originTrackId, int); //! Original track index DECLARE_SOA_COLUMN(NTpcCrossedRows, nTpcCrossedRows, int); //! Number of crossed TPC Rows DECLARE_SOA_COLUMN(ItsClusterMap, itsClusterMap, int); //! ITS cluster map, one bit per a layer, starting from the innermost @@ -143,17 +140,16 @@ DECLARE_SOA_TABLE(AssocTrackSels, "AOD", "ASSOCTRACKSEL", //! Table with associa aod::hf_assoc_track_reduced::ItsClusterMap, aod::hf_assoc_track_reduced::ItsNCls, aod::hf_assoc_track_reduced::DcaXY, - aod::hf_assoc_track_reduced::DcaZ) + aod::hf_assoc_track_reduced::DcaZ); DECLARE_SOA_TABLE(HfcRedTrkAssocs, "AOD", "HFCREDTRKASSOC", //! Table with associated track info soa::Index<>, aod::hf_correlation_trigger_reduced::HfcRedCorrCollId, aod::hf_assoc_track_reduced::PhiAssocTrack, aod::hf_assoc_track_reduced::EtaAssocTrack, - aod::hf_assoc_track_reduced::PtAssocTrack) + aod::hf_assoc_track_reduced::PtAssocTrack); DECLARE_SOA_TABLE(HfcRedTrkSels, "AOD", "HFCREDSETRKSEL", //! Table with Same Event Track Selections information - aod::hf_correlation_trigger_reduced::HfcRedCorrCollId, aod::hf_assoc_track_reduced::NTpcCrossedRows, aod::hf_assoc_track_reduced::ItsClusterMap, aod::hf_assoc_track_reduced::ItsNCls, @@ -163,14 +159,13 @@ DECLARE_SOA_TABLE(HfcRedTrkSels, "AOD", "HFCREDSETRKSEL", //! Table with Same Ev // definition of columns and tables for Charm-Hadron and Hadron-Hadron correlation pairs namespace hf_correlation_charm_hadron_reduced { -DECLARE_SOA_INDEX_COLUMN(HfcRedCorrColl, hfcRedCorrColl); //! ReducedCollision index DECLARE_SOA_COLUMN(DeltaPhi, deltaPhi, float); //! DeltaPhi between charm hadron and Hadrons DECLARE_SOA_COLUMN(DeltaEta, deltaEta, float); //! DeltaEta between charm hadron and Hadrons DECLARE_SOA_COLUMN(PoolBin, poolBin, int); //! Pool Bin for the MixedEvent } // namespace hf_correlation_charm_hadron_reduced DECLARE_SOA_TABLE(HfcRedSEPairs, "AOD", "HFCREDSEPAIR", //! Table with Same Event Trig-Assoc pairs - aod::hf_correlation_charm_hadron_reduced::HfcRedCorrCollId, + aod::hf_correlation_trigger_reduced::HfcRedCorrCollId, aod::hf_correlation_trigger_reduced::PtTrig, aod::hf_assoc_track_reduced::PtAssocTrack, aod::hf_correlation_charm_hadron_reduced::DeltaEta, diff --git a/PWGHF/HFC/TableProducer/correlatorFlowCharmHadronsReduced.cxx b/PWGHF/HFC/TableProducer/correlatorFlowCharmHadronsReduced.cxx index 2c598b227e9..56ebaaa0494 100644 --- a/PWGHF/HFC/TableProducer/correlatorFlowCharmHadronsReduced.cxx +++ b/PWGHF/HFC/TableProducer/correlatorFlowCharmHadronsReduced.cxx @@ -108,15 +108,18 @@ struct HfCorrelatorFlowCharmHadronsReduced { SliceCache cache; - using AssocTracks = aod::HfcRedTrkAssocs; - // using AssocTracks = soa::Filtered>; + using AssocTracks = soa::Filtered>; using SameEvtPairsChHad = soa::Filtered>; using SameEvtPairsHadHad = soa::Filtered>; + using TrigCands = soa::Join; Filter filterTrackData = (nabs(aod::hf_assoc_track_reduced::dcaXY) < dcaXYTrackMax) && (nabs(aod::hf_assoc_track_reduced::dcaZ) < dcaZTrackMax) && (aod::hf_assoc_track_reduced::nTpcCrossedRows > tpcCrossedRowsMin) && (aod::hf_assoc_track_reduced::itsNCls > itsNClsMin); Filter filterSameEvtPairsChHad = (nabs(aod::hf_assoc_track_reduced::dcaXY) < dcaXYTrackMax) && (nabs(aod::hf_assoc_track_reduced::dcaZ) < dcaZTrackMax) && (aod::hf_assoc_track_reduced::nTpcCrossedRows > tpcCrossedRowsMin) && (aod::hf_assoc_track_reduced::itsNCls > itsNClsMin); Filter filterSameEvtPairsHadHad = (nabs(aod::hf_assoc_track_reduced::dcaXY) < dcaXYTrackMax) && (nabs(aod::hf_assoc_track_reduced::dcaZ) < dcaZTrackMax) && (aod::hf_assoc_track_reduced::nTpcCrossedRows > tpcCrossedRowsMin) && (aod::hf_assoc_track_reduced::itsNCls > itsNClsMin); + Preslice tracksPerCol = aod::hf_correlation_trigger_reduced::hfcRedCorrCollId; + Preslice candPerCol = aod::hf_correlation_trigger_reduced::hfcRedCorrCollId; + ConfigurableAxis zPoolBins{"zPoolBins", {VARIABLE_WIDTH, -10.0, -2.5, 2.5, 10.0}, "Z vertex position pools"}; ConfigurableAxis multPoolBins{"multPoolBins", {VARIABLE_WIDTH, 0., 900., 1800., 6000.}, "Event multiplicity pools (FT0M)"}; ConfigurableAxis centPoolBins{"centPoolBins", {VARIABLE_WIDTH, 0., 10., 20., 30.}, "Event centrality pools"}; @@ -224,12 +227,10 @@ struct HfCorrelatorFlowCharmHadronsReduced { void fillSameEvent(TPair const& pair, TBinningType binPolicy) { - // auto collision = pair.template hfcRedCorrColl_as(); - int poolBin = -1; - // int poolBin = getPoolBin(collision, binPolicy); + auto collision = pair.template hfcRedCorrColl_as(); + int poolBin = getPoolBin(collision, binPolicy); registry.fill(HIST("hCollisionPoolBin"), poolBin); - registry.fill(HIST("hZVtx"), -1, poolBin); - // registry.fill(HIST("hZVtx"), collision.posZ(), poolBin); + registry.fill(HIST("hZVtx"), collision.posZ(), poolBin); registry.fill(HIST("hPoolBinTrig"), poolBin); registry.fill(HIST("hPoolBinAssoc"), poolBin); if constexpr (fillTables) { @@ -290,9 +291,9 @@ struct HfCorrelatorFlowCharmHadronsReduced { entryCorrPair(poolBinTrig, ptTrig, ptAssoc, deltaEta, deltaPhi); } if constexpr (fillSparses) { - if constexpr (requires{ trigCand.bdtScore0(); }) { // Separate Charm-Had and Had-Had cases + if constexpr (requires{ trigCand.bdtScore0Trig(); }) { // Separate Charm-Had and Had-Had cases registry.fill(HIST("hSparseCorrelationsMECharmHad"), poolBinTrig, ptTrig, ptAssoc, deltaEta, - deltaPhi, trigCand.bdtScore0(), trigCand.bdtScore1(), trigCand.invMassCand()); + deltaPhi, trigCand.bdtScore0Trig(), trigCand.bdtScore1Trig(), trigCand.invMassTrig()); } else { registry.fill(HIST("hSparseCorrelationsMEHadHad"), poolBinTrig, ptTrig, ptAssoc, deltaEta, deltaPhi); } @@ -354,7 +355,7 @@ struct HfCorrelatorFlowCharmHadronsReduced { PROCESS_SWITCH(HfCorrelatorFlowCharmHadronsReduced, processSameEventHadHadWCentMix, "Process Same Event for Had-Had with centrality pools", false); void processMixedEventCharmHadWCentMix(aod::HfcRedCorrColls const& collisions, - soa::Join const& candidates, + TrigCands const& candidates, AssocTracks const& tracks) { if (fillSparses && fillTables) { @@ -368,7 +369,7 @@ struct HfCorrelatorFlowCharmHadronsReduced { PROCESS_SWITCH(HfCorrelatorFlowCharmHadronsReduced, processMixedEventCharmHadWCentMix, "Process Mixed Event for Charm-Had with centrality pools", false); void processMixedEventCharmHadWMultMix(aod::HfcRedCorrColls const& collisions, - soa::Join const& candidates, + TrigCands const& candidates, AssocTracks const& tracks) { if (fillSparses && fillTables) { diff --git a/PWGHF/HFC/TableProducer/derivedDataCreatorCorrelationsReduced.cxx b/PWGHF/HFC/TableProducer/derivedDataCreatorCorrelationsReduced.cxx index f52a0585ad1..c9d94417f56 100644 --- a/PWGHF/HFC/TableProducer/derivedDataCreatorCorrelationsReduced.cxx +++ b/PWGHF/HFC/TableProducer/derivedDataCreatorCorrelationsReduced.cxx @@ -316,17 +316,19 @@ struct HfDerivedDataCreatorCorrelationsReduced { double deltaEta = assTrk.eta() - trigCand.eta(); double deltaPhi = RecoDecay::constrainAngle(assTrk.phi() - trigCand.phi(), -o2::constants::math::PIHalf); rowSEPairs(rowCollisions.lastIndex(), trigCand.pt(), assTrkPt, deltaEta, deltaPhi); - rowAssocTrkSels(rowCollisions.lastIndex(), assTrk.tpcNClsCrossedRows(), assTrk.itsClusterMap(), assTrk.itsNCls(), assTrk.dcaXY(), assTrk.dcaZ()); + rowAssocTrkSels(assTrk.tpcNClsCrossedRows(), assTrk.itsClusterMap(), assTrk.itsNCls(), assTrk.dcaXY(), assTrk.dcaZ()); if constexpr (candType == CandType::Hadron) { - rowTrigHads(rowCollisions.lastIndex(), trigCand.tpcNClsCrossedRows(), trigCand.itsClusterMap(), trigCand.itsNCls(), trigCand.dcaXY(), trigCand.dcaZ()); + rowTrigHads(trigCand.tpcNClsCrossedRows(), trigCand.itsClusterMap(), trigCand.itsNCls(), trigCand.dcaXY(), trigCand.dcaZ()); } else { std::array outputMl = getCandMlScores(trigCand); - rowTrigCharms(rowCollisions.lastIndex(), getCandMass(trigCand), outputMl[0], outputMl[1]); + rowTrigCharms(getCandMass(trigCand), outputMl[0], outputMl[1]); } } } } + /// Fill charm hadron tables for mixed-event + /// \param trigCands are the charm trigger candidates template void fillCharmMixedEvent(TTrigCands const& trigCands) { @@ -336,10 +338,13 @@ struct HfDerivedDataCreatorCorrelationsReduced { std::array outputMl = getCandMlScores(trigCand); rowTrigs(rowCollisions.lastIndex(), trigCand.phi(), trigCand.eta(), trigCand.pt()); - rowTrigCharms(rowCollisions.lastIndex(), getCandMass(trigCand), outputMl[0], outputMl[1]); + rowTrigCharms(getCandMass(trigCand), outputMl[0], outputMl[1]); } } + /// Fill track tables for mixed-event + /// \param assTrks are the associated tracks + /// \param collCentrality is the collision centrality template void fillTrkMixedEvent(TAssocTrks const& assTrks, const float collCentrality) @@ -360,7 +365,7 @@ struct HfDerivedDataCreatorCorrelationsReduced { registry.fill(HIST("hPhiVsPtAssoc"), RecoDecay::constrainAngle(assTrk.phi(), -o2::constants::math::PIHalf), assTrkPt); registry.fill(HIST("hEtaVsPtAssoc"), assTrk.eta(), assTrkPt); rowAssocTrks(rowCollisions.lastIndex(), assTrk.phi(), assTrk.eta(), assTrkPt); - rowAssocTrkSels(rowCollisions.lastIndex(), assTrk.tpcNClsCrossedRows(), assTrk.itsClusterMap(), assTrk.itsNCls(), assTrk.dcaXY(), assTrk.dcaZ()); + rowAssocTrkSels(assTrk.tpcNClsCrossedRows(), assTrk.itsClusterMap(), assTrk.itsNCls(), assTrk.dcaXY(), assTrk.dcaZ()); } } From 52ac256530337cd0eb66bd1aac9eb5aaa74d1ef0 Mon Sep 17 00:00:00 2001 From: ALICE Action Bot Date: Tue, 16 Sep 2025 20:51:49 +0000 Subject: [PATCH 07/15] Please consider the following formatting changes --- .../DataModel/DerivedDataCorrelationTables.h | 48 +++++++++---------- .../correlatorFlowCharmHadronsReduced.cxx | 6 +-- .../derivedDataCreatorCorrelationsReduced.cxx | 22 ++++----- 3 files changed, 38 insertions(+), 38 deletions(-) diff --git a/PWGHF/HFC/DataModel/DerivedDataCorrelationTables.h b/PWGHF/HFC/DataModel/DerivedDataCorrelationTables.h index 23ad203d9a8..8766b203891 100644 --- a/PWGHF/HFC/DataModel/DerivedDataCorrelationTables.h +++ b/PWGHF/HFC/DataModel/DerivedDataCorrelationTables.h @@ -77,21 +77,21 @@ DECLARE_SOA_TABLE(DsCandSelInfos, "AOD", "DSCANDSELINFO", //! Table with Ds cand namespace hf_correlation_trigger_reduced { -DECLARE_SOA_INDEX_COLUMN(HfcRedCorrColl, hfcRedCorrColl); //! ReducedCollision index -DECLARE_SOA_COLUMN(PhiTrig, phiTrig, float); //! Phi of the trigger candidate -DECLARE_SOA_COLUMN(EtaTrig, etaTrig, float); //! Eta of the trigger candidate -DECLARE_SOA_COLUMN(PtTrig, ptTrig, float); //! Pt of the trigger candidate -DECLARE_SOA_COLUMN(InvMassTrig, invMassTrig, float); //! Invariant mass of Charm trigger candidate -DECLARE_SOA_COLUMN(BdtScore0Trig, bdtScore0Trig, float); //! First BDT output score -DECLARE_SOA_COLUMN(BdtScore1Trig, bdtScore1Trig, float); //! Second BDT output score -DECLARE_SOA_COLUMN(NTpcCrossedRowsTrig, nTpcCrossedRowsTrig, int); //! Number of crossed TPC Rows -DECLARE_SOA_COLUMN(ItsClusterMapTrig, itsClusterMapTrig, int); //! ITS cluster map, one bit per a layer, starting from the innermost -DECLARE_SOA_COLUMN(ItsNClsTrig, itsNClsTrig, int); //! Number of ITS clusters -DECLARE_SOA_COLUMN(EtaTrigTrack, etaTrigTrack, float); //! Eta of the track -DECLARE_SOA_COLUMN(PhiTrigTrack, phiTrigTrack, float); //! Phi of the track -DECLARE_SOA_COLUMN(PtTrigTrack, ptTrigTrack, float); //! Pt of the track -DECLARE_SOA_COLUMN(DcaXYTrig, dcaXYTrig, float); //! Impact parameter in XY of the track to the primary vertex -DECLARE_SOA_COLUMN(DcaZTrig, dcaZTrig, float); //! Impact parameter in Z of the track to the primary vertex +DECLARE_SOA_INDEX_COLUMN(HfcRedCorrColl, hfcRedCorrColl); //! ReducedCollision index +DECLARE_SOA_COLUMN(PhiTrig, phiTrig, float); //! Phi of the trigger candidate +DECLARE_SOA_COLUMN(EtaTrig, etaTrig, float); //! Eta of the trigger candidate +DECLARE_SOA_COLUMN(PtTrig, ptTrig, float); //! Pt of the trigger candidate +DECLARE_SOA_COLUMN(InvMassTrig, invMassTrig, float); //! Invariant mass of Charm trigger candidate +DECLARE_SOA_COLUMN(BdtScore0Trig, bdtScore0Trig, float); //! First BDT output score +DECLARE_SOA_COLUMN(BdtScore1Trig, bdtScore1Trig, float); //! Second BDT output score +DECLARE_SOA_COLUMN(NTpcCrossedRowsTrig, nTpcCrossedRowsTrig, int); //! Number of crossed TPC Rows +DECLARE_SOA_COLUMN(ItsClusterMapTrig, itsClusterMapTrig, int); //! ITS cluster map, one bit per a layer, starting from the innermost +DECLARE_SOA_COLUMN(ItsNClsTrig, itsNClsTrig, int); //! Number of ITS clusters +DECLARE_SOA_COLUMN(EtaTrigTrack, etaTrigTrack, float); //! Eta of the track +DECLARE_SOA_COLUMN(PhiTrigTrack, phiTrigTrack, float); //! Phi of the track +DECLARE_SOA_COLUMN(PtTrigTrack, ptTrigTrack, float); //! Pt of the track +DECLARE_SOA_COLUMN(DcaXYTrig, dcaXYTrig, float); //! Impact parameter in XY of the track to the primary vertex +DECLARE_SOA_COLUMN(DcaZTrig, dcaZTrig, float); //! Impact parameter in Z of the track to the primary vertex } // namespace hf_correlation_trigger_reduced DECLARE_SOA_TABLE(HfcRedTrigs, "AOD", "HFCREDTRIG", //! Table with charm hadron candidate info @@ -115,15 +115,15 @@ DECLARE_SOA_TABLE(HfcRedTrigHads, "AOD", "HFCREDTRIGHAD", //! Table with Same Ev namespace hf_assoc_track_reduced { -DECLARE_SOA_COLUMN(OriginTrackId, originTrackId, int); //! Original track index -DECLARE_SOA_COLUMN(NTpcCrossedRows, nTpcCrossedRows, int); //! Number of crossed TPC Rows -DECLARE_SOA_COLUMN(ItsClusterMap, itsClusterMap, int); //! ITS cluster map, one bit per a layer, starting from the innermost -DECLARE_SOA_COLUMN(ItsNCls, itsNCls, int); //! Number of ITS clusters -DECLARE_SOA_COLUMN(EtaAssocTrack, etaAssocTrack, float); //! Eta of the track -DECLARE_SOA_COLUMN(PhiAssocTrack, phiAssocTrack, float); //! Phi of the track -DECLARE_SOA_COLUMN(PtAssocTrack, ptAssocTrack, float); //! Pt of the track -DECLARE_SOA_COLUMN(DcaXY, dcaXY, float); //! Impact parameter in XY of the track to the primary vertex -DECLARE_SOA_COLUMN(DcaZ, dcaZ, float); //! Impact parameter in Z of the track to the primary vertex +DECLARE_SOA_COLUMN(OriginTrackId, originTrackId, int); //! Original track index +DECLARE_SOA_COLUMN(NTpcCrossedRows, nTpcCrossedRows, int); //! Number of crossed TPC Rows +DECLARE_SOA_COLUMN(ItsClusterMap, itsClusterMap, int); //! ITS cluster map, one bit per a layer, starting from the innermost +DECLARE_SOA_COLUMN(ItsNCls, itsNCls, int); //! Number of ITS clusters +DECLARE_SOA_COLUMN(EtaAssocTrack, etaAssocTrack, float); //! Eta of the track +DECLARE_SOA_COLUMN(PhiAssocTrack, phiAssocTrack, float); //! Phi of the track +DECLARE_SOA_COLUMN(PtAssocTrack, ptAssocTrack, float); //! Pt of the track +DECLARE_SOA_COLUMN(DcaXY, dcaXY, float); //! Impact parameter in XY of the track to the primary vertex +DECLARE_SOA_COLUMN(DcaZ, dcaZ, float); //! Impact parameter in Z of the track to the primary vertex } // namespace hf_assoc_track_reduced DECLARE_SOA_TABLE(AssocTrackReds, "AOD", "ASSOCTRACKRED", //! Table with associated track info soa::Index<>, diff --git a/PWGHF/HFC/TableProducer/correlatorFlowCharmHadronsReduced.cxx b/PWGHF/HFC/TableProducer/correlatorFlowCharmHadronsReduced.cxx index 56ebaaa0494..fa132c4233c 100644 --- a/PWGHF/HFC/TableProducer/correlatorFlowCharmHadronsReduced.cxx +++ b/PWGHF/HFC/TableProducer/correlatorFlowCharmHadronsReduced.cxx @@ -237,7 +237,7 @@ struct HfCorrelatorFlowCharmHadronsReduced { entryCorrPair(poolBin, pair.ptTrig(), pair.ptAssocTrack(), pair.deltaEta(), pair.deltaPhi()); } if constexpr (fillSparses) { - if constexpr (requires{ pair.bdtScore0Trig(); }) { // Separate Charm-Had and Had-Had cases + if constexpr (requires { pair.bdtScore0Trig(); }) { // Separate Charm-Had and Had-Had cases registry.fill(HIST("hSparseCorrelationsSECharmHad"), poolBin, pair.ptTrig(), pair.ptAssocTrack(), pair.deltaEta(), pair.deltaPhi(), pair.bdtScore0Trig(), pair.bdtScore1Trig(), pair.invMassTrig()); } else { @@ -282,7 +282,7 @@ struct HfCorrelatorFlowCharmHadronsReduced { if (downSamplePairsME < 1.) { float pseudoRndm = ptAssoc * 1000. - static_cast(ptAssoc * 1000); if (ptTrig < ptMaxForDownSampleME && trigColl.centrality() < centMaxForDownSampleME && - assocColl.centrality() < centMaxForDownSampleME && pseudoRndm >= downSamplePairsME) { + assocColl.centrality() < centMaxForDownSampleME && pseudoRndm >= downSamplePairsME) { continue; } } @@ -291,7 +291,7 @@ struct HfCorrelatorFlowCharmHadronsReduced { entryCorrPair(poolBinTrig, ptTrig, ptAssoc, deltaEta, deltaPhi); } if constexpr (fillSparses) { - if constexpr (requires{ trigCand.bdtScore0Trig(); }) { // Separate Charm-Had and Had-Had cases + if constexpr (requires { trigCand.bdtScore0Trig(); }) { // Separate Charm-Had and Had-Had cases registry.fill(HIST("hSparseCorrelationsMECharmHad"), poolBinTrig, ptTrig, ptAssoc, deltaEta, deltaPhi, trigCand.bdtScore0Trig(), trigCand.bdtScore1Trig(), trigCand.invMassTrig()); } else { diff --git a/PWGHF/HFC/TableProducer/derivedDataCreatorCorrelationsReduced.cxx b/PWGHF/HFC/TableProducer/derivedDataCreatorCorrelationsReduced.cxx index c9d94417f56..9d384471401 100644 --- a/PWGHF/HFC/TableProducer/derivedDataCreatorCorrelationsReduced.cxx +++ b/PWGHF/HFC/TableProducer/derivedDataCreatorCorrelationsReduced.cxx @@ -62,13 +62,13 @@ enum CandType { /// Code to select collisions with at least one Ds meson struct HfDerivedDataCreatorCorrelationsReduced { - Produces rowCollisions; // Table with reduced collision info - Produces rowSEPairs; // Table with same-event pairs info - Produces rowAssocTrks; // Table with associated track info - Produces rowAssocTrkSels; // Table with associated track selection info - Produces rowTrigs; // Table with charm candidate info - Produces rowTrigCharms; // Table with charm trigger candidate info - Produces rowTrigHads; // Table with hadron trigger candidate info + Produces rowCollisions; // Table with reduced collision info + Produces rowSEPairs; // Table with same-event pairs info + Produces rowAssocTrks; // Table with associated track info + Produces rowAssocTrkSels; // Table with associated track selection info + Produces rowTrigs; // Table with charm candidate info + Produces rowTrigCharms; // Table with charm trigger candidate info + Produces rowTrigHads; // Table with hadron trigger candidate info Configurable centEstimator{"centEstimator", 2, "Centrality estimation (FT0A: 1, FT0C: 2, FT0M: 3, FV0A: 4)"}; Configurable selectionFlag{"selectionFlag", 15, "Selection Flag for hadron (ML score tables are required to run the task)"}; @@ -270,14 +270,14 @@ struct HfDerivedDataCreatorCorrelationsReduced { return false; } - if constexpr (candType == CandType::Hadron) { + if constexpr (candType == CandType::Hadron) { if (!cand.isGlobalTrackWoDCA() || cand.tpcNClsCrossedRows() < tpcNClsCrossedRowsMin) { return false; } if (assTrk.globalIndex() == cand.globalIndex()) { return false; // skip self-correlation for hadron-hadron } - } else { // Remove Daughter-Cand pairs for charm-hadron correlations + } else { // Remove Daughter-Cand pairs for charm-hadron correlations if constexpr ((requires { cand.prong2Id(); })) { // Check 3-prong return (assTrk.globalIndex() == cand.prong0Id() || assTrk.globalIndex() == cand.prong1Id() || assTrk.globalIndex() == cand.prong2Id()); } else { // Check 2-prong @@ -312,7 +312,7 @@ struct HfDerivedDataCreatorCorrelationsReduced { } registry.fill(HIST("hPhiVsPtTrigAssoc"), RecoDecay::constrainAngle(assTrk.phi(), -o2::constants::math::PIHalf), trigCand.pt(), assTrkPt); registry.fill(HIST("hEtaVsPtAssoc"), assTrk.eta(), trigCand.pt(), assTrkPt); - + double deltaEta = assTrk.eta() - trigCand.eta(); double deltaPhi = RecoDecay::constrainAngle(assTrk.phi() - trigCand.phi(), -o2::constants::math::PIHalf); rowSEPairs(rowCollisions.lastIndex(), trigCand.pt(), assTrkPt, deltaEta, deltaPhi); @@ -355,7 +355,7 @@ struct HfDerivedDataCreatorCorrelationsReduced { continue; } double assTrkPt = assTrk.pt(); - if (!first && downSampleTrksFactor < 1.) { // skip downsampling for the first track to avoid empty tables + if (!first && downSampleTrksFactor < 1.) { // skip downsampling for the first track to avoid empty tables float pseudoRndm = assTrkPt * 1000. - static_cast(assTrkPt * 1000); if (assTrkPt < ptMaxForDownSample && collCentrality < centMaxForDownSample && pseudoRndm >= downSampleTrksFactor) { continue; From 326cd7109b757f3c96033dea87981d2ff3a6d7af Mon Sep 17 00:00:00 2001 From: marcellocosti Date: Wed, 17 Sep 2025 23:27:31 +0200 Subject: [PATCH 08/15] Reshape datamodel --- .../DataModel/DerivedDataCorrelationTables.h | 154 ++++++++++-------- .../correlatorFlowCharmHadronsReduced.cxx | 141 ++++++++++------ .../derivedDataCreatorCorrelationsReduced.cxx | 24 +-- 3 files changed, 181 insertions(+), 138 deletions(-) diff --git a/PWGHF/HFC/DataModel/DerivedDataCorrelationTables.h b/PWGHF/HFC/DataModel/DerivedDataCorrelationTables.h index 8766b203891..a15e8d2dc88 100644 --- a/PWGHF/HFC/DataModel/DerivedDataCorrelationTables.h +++ b/PWGHF/HFC/DataModel/DerivedDataCorrelationTables.h @@ -43,7 +43,6 @@ DECLARE_SOA_TABLE(HfcRedCorrColls, "AOD", "HFCREDCORRCOLL", //! Table with colli aod::hf_collisions_reduced::PosZ); using HfcRedCollision = HfcRedCollisions::iterator; -using HfcRedCorrColl = HfcRedCorrColls::iterator; namespace hf_candidate_reduced { @@ -75,44 +74,6 @@ DECLARE_SOA_TABLE(DsCandSelInfos, "AOD", "DSCANDSELINFO", //! Table with Ds cand aod::hf_candidate_reduced::BdtScorePrompt, aod::hf_candidate_reduced::BdtScoreBkg); -namespace hf_correlation_trigger_reduced -{ -DECLARE_SOA_INDEX_COLUMN(HfcRedCorrColl, hfcRedCorrColl); //! ReducedCollision index -DECLARE_SOA_COLUMN(PhiTrig, phiTrig, float); //! Phi of the trigger candidate -DECLARE_SOA_COLUMN(EtaTrig, etaTrig, float); //! Eta of the trigger candidate -DECLARE_SOA_COLUMN(PtTrig, ptTrig, float); //! Pt of the trigger candidate -DECLARE_SOA_COLUMN(InvMassTrig, invMassTrig, float); //! Invariant mass of Charm trigger candidate -DECLARE_SOA_COLUMN(BdtScore0Trig, bdtScore0Trig, float); //! First BDT output score -DECLARE_SOA_COLUMN(BdtScore1Trig, bdtScore1Trig, float); //! Second BDT output score -DECLARE_SOA_COLUMN(NTpcCrossedRowsTrig, nTpcCrossedRowsTrig, int); //! Number of crossed TPC Rows -DECLARE_SOA_COLUMN(ItsClusterMapTrig, itsClusterMapTrig, int); //! ITS cluster map, one bit per a layer, starting from the innermost -DECLARE_SOA_COLUMN(ItsNClsTrig, itsNClsTrig, int); //! Number of ITS clusters -DECLARE_SOA_COLUMN(EtaTrigTrack, etaTrigTrack, float); //! Eta of the track -DECLARE_SOA_COLUMN(PhiTrigTrack, phiTrigTrack, float); //! Phi of the track -DECLARE_SOA_COLUMN(PtTrigTrack, ptTrigTrack, float); //! Pt of the track -DECLARE_SOA_COLUMN(DcaXYTrig, dcaXYTrig, float); //! Impact parameter in XY of the track to the primary vertex -DECLARE_SOA_COLUMN(DcaZTrig, dcaZTrig, float); //! Impact parameter in Z of the track to the primary vertex -} // namespace hf_correlation_trigger_reduced - -DECLARE_SOA_TABLE(HfcRedTrigs, "AOD", "HFCREDTRIG", //! Table with charm hadron candidate info - soa::Index<>, - aod::hf_correlation_trigger_reduced::HfcRedCorrCollId, - aod::hf_correlation_trigger_reduced::PhiTrig, - aod::hf_correlation_trigger_reduced::EtaTrig, - aod::hf_correlation_trigger_reduced::PtTrig); - -DECLARE_SOA_TABLE(HfcRedTrigCharms, "AOD", "HFCREDTRIGCHARM", //! Table with Same Event Charm-Hadron pairs information - aod::hf_correlation_trigger_reduced::InvMassTrig, - aod::hf_correlation_trigger_reduced::BdtScore0Trig, - aod::hf_correlation_trigger_reduced::BdtScore1Trig); - -DECLARE_SOA_TABLE(HfcRedTrigHads, "AOD", "HFCREDTRIGHAD", //! Table with Same Event Charm-Hadron pairs information - aod::hf_correlation_trigger_reduced::NTpcCrossedRowsTrig, - aod::hf_correlation_trigger_reduced::ItsClusterMapTrig, - aod::hf_correlation_trigger_reduced::ItsNClsTrig, - aod::hf_correlation_trigger_reduced::DcaXYTrig, - aod::hf_correlation_trigger_reduced::DcaZTrig); - namespace hf_assoc_track_reduced { DECLARE_SOA_COLUMN(OriginTrackId, originTrackId, int); //! Original track index @@ -142,41 +103,90 @@ DECLARE_SOA_TABLE(AssocTrackSels, "AOD", "ASSOCTRACKSEL", //! Table with associa aod::hf_assoc_track_reduced::DcaXY, aod::hf_assoc_track_reduced::DcaZ); -DECLARE_SOA_TABLE(HfcRedTrkAssocs, "AOD", "HFCREDTRKASSOC", //! Table with associated track info - soa::Index<>, - aod::hf_correlation_trigger_reduced::HfcRedCorrCollId, - aod::hf_assoc_track_reduced::PhiAssocTrack, - aod::hf_assoc_track_reduced::EtaAssocTrack, - aod::hf_assoc_track_reduced::PtAssocTrack); - -DECLARE_SOA_TABLE(HfcRedTrkSels, "AOD", "HFCREDSETRKSEL", //! Table with Same Event Track Selections information - aod::hf_assoc_track_reduced::NTpcCrossedRows, - aod::hf_assoc_track_reduced::ItsClusterMap, - aod::hf_assoc_track_reduced::ItsNCls, - aod::hf_assoc_track_reduced::DcaXY, - aod::hf_assoc_track_reduced::DcaZ); - // definition of columns and tables for Charm-Hadron and Hadron-Hadron correlation pairs -namespace hf_correlation_charm_hadron_reduced +namespace hf_correl_charm_had_reduced { -DECLARE_SOA_COLUMN(DeltaPhi, deltaPhi, float); //! DeltaPhi between charm hadron and Hadrons -DECLARE_SOA_COLUMN(DeltaEta, deltaEta, float); //! DeltaEta between charm hadron and Hadrons -DECLARE_SOA_COLUMN(PoolBin, poolBin, int); //! Pool Bin for the MixedEvent -} // namespace hf_correlation_charm_hadron_reduced - -DECLARE_SOA_TABLE(HfcRedSEPairs, "AOD", "HFCREDSEPAIR", //! Table with Same Event Trig-Assoc pairs - aod::hf_correlation_trigger_reduced::HfcRedCorrCollId, - aod::hf_correlation_trigger_reduced::PtTrig, - aod::hf_assoc_track_reduced::PtAssocTrack, - aod::hf_correlation_charm_hadron_reduced::DeltaEta, - aod::hf_correlation_charm_hadron_reduced::DeltaPhi); - -DECLARE_SOA_TABLE(HfcRedCorrPair, "AOD", "HFCREDCORRPAIR", //! Correlation pairs information - aod::hf_correlation_charm_hadron_reduced::PoolBin, - aod::hf_correlation_trigger_reduced::PtTrig, - aod::hf_assoc_track_reduced::PtAssocTrack, - aod::hf_correlation_charm_hadron_reduced::DeltaEta, - aod::hf_correlation_charm_hadron_reduced::DeltaPhi); +DECLARE_SOA_INDEX_COLUMN(HfcRedCorrColl, hfcRedCorrColl); //! ReducedCollision index +DECLARE_SOA_COLUMN(DeltaPhi, deltaPhi, float); //! DeltaPhi between charm hadron and Hadrons +DECLARE_SOA_COLUMN(DeltaEta, deltaEta, float); //! DeltaEta between charm hadron and Hadrons +DECLARE_SOA_COLUMN(PoolBin, poolBin, int); //! Pool Bin for the MixedEvent +DECLARE_SOA_COLUMN(PhiTrig, phiTrig, float); //! Phi of the trigger candidate +DECLARE_SOA_COLUMN(EtaTrig, etaTrig, float); //! Eta of the trigger candidate +DECLARE_SOA_COLUMN(PtTrig, ptTrig, float); //! Pt of the trigger candidate +DECLARE_SOA_COLUMN(InvMassTrig, invMassTrig, float); //! Invariant mass of Charm trigger candidate +DECLARE_SOA_COLUMN(BdtScore0Trig, bdtScore0Trig, float); //! First BDT output score +DECLARE_SOA_COLUMN(BdtScore1Trig, bdtScore1Trig, float); //! Second BDT output score +DECLARE_SOA_COLUMN(NTpcCrossedRowsTrig, nTpcCrossedRowsTrig, int); //! Number of crossed TPC Rows +DECLARE_SOA_COLUMN(ItsClsMapTrig, itsClsMapTrig, int); //! ITS cluster map, one bit per a layer, starting from the innermost +DECLARE_SOA_COLUMN(ItsNClsTrig, itsNClsTrig, int); //! Number of ITS clusters +DECLARE_SOA_COLUMN(EtaTrigTrack, etaTrigTrack, float); //! Eta of the track +DECLARE_SOA_COLUMN(PhiTrigTrack, phiTrigTrack, float); //! Phi of the track +DECLARE_SOA_COLUMN(PtTrigTrack, ptTrigTrack, float); //! Pt of the track +DECLARE_SOA_COLUMN(DcaXYTrig, dcaXYTrig, float); //! Impact parameter in XY of the track to the primary vertex +DECLARE_SOA_COLUMN(DcaZTrig, dcaZTrig, float); //! Impact parameter in Z of the track to the primary vertex +DECLARE_SOA_COLUMN(NTpcCrossedRowsAssoc, nTpcCrossedRowsAssoc, int); //! Number of crossed TPC Rows +DECLARE_SOA_COLUMN(ItsClsMapAssoc, itsClsMapAssoc, int); //! ITS cluster map, one bit per a layer, starting from the innermost +DECLARE_SOA_COLUMN(ItsNClsAssoc, itsNClsAssoc, int); //! Number of ITS clusters +DECLARE_SOA_COLUMN(EtaAssoc, etaAssoc, float); //! Eta of the track +DECLARE_SOA_COLUMN(PhiAssoc, phiAssoc, float); //! Phi of the track +DECLARE_SOA_COLUMN(PtAssoc, ptAssoc, float); //! Pt of the track +DECLARE_SOA_COLUMN(DcaXYAssoc, dcaXYAssoc, float); //! Impact parameter in XY of the track to the primary vertex +DECLARE_SOA_COLUMN(DcaZAssoc, dcaZAssoc, float); //! Impact parameter in Z of the track to the primary vertex +} // namespace hf_correl_charm_had_reduced + +DECLARE_SOA_TABLE(HfcRedTrigBases, "AOD", "HFCREDTRIGBASE", //! Table with trigger candidate base info + soa::Index<>, + aod::hf_correl_charm_had_reduced::HfcRedCorrCollId, + aod::hf_correl_charm_had_reduced::PhiTrig, + aod::hf_correl_charm_had_reduced::EtaTrig, + aod::hf_correl_charm_had_reduced::PtTrig); + +DECLARE_SOA_TABLE(HfcRedTrigCharms, "AOD", "HFCREDTRIGCHARM", //! Table with Same Event Charm-Hadron pairs information + aod::hf_correl_charm_had_reduced::InvMassTrig, + aod::hf_correl_charm_had_reduced::BdtScore0Trig, + aod::hf_correl_charm_had_reduced::BdtScore1Trig); + +DECLARE_SOA_TABLE(HfcRedTrigTrks, "AOD", "HFCREDTRIGTRK", //! Table with Same Event Charm-Hadron pairs information + aod::hf_correl_charm_had_reduced::NTpcCrossedRowsTrig, + aod::hf_correl_charm_had_reduced::ItsClsMapTrig, + aod::hf_correl_charm_had_reduced::ItsNClsTrig, + aod::hf_correl_charm_had_reduced::DcaXYTrig, + aod::hf_correl_charm_had_reduced::DcaZTrig); + +DECLARE_SOA_TABLE(HfcRedAssocBases, "AOD", "HFCREDASSOCBASE", //! Table with associated candidate base info + soa::Index<>, + aod::hf_correl_charm_had_reduced::HfcRedCorrCollId, + aod::hf_correl_charm_had_reduced::PhiAssoc, + aod::hf_correl_charm_had_reduced::EtaAssoc, + aod::hf_correl_charm_had_reduced::PtAssoc); + +DECLARE_SOA_TABLE(HfcRedAssocTrks, "AOD", "HFCREDASSOCTRK", //! Table with Same Event Track Selections information + aod::hf_correl_charm_had_reduced::NTpcCrossedRowsAssoc, + aod::hf_correl_charm_had_reduced::ItsClsMapAssoc, + aod::hf_correl_charm_had_reduced::ItsNClsAssoc, + aod::hf_correl_charm_had_reduced::DcaXYAssoc, + aod::hf_correl_charm_had_reduced::DcaZAssoc); + +DECLARE_SOA_TABLE(HfcRedSEBases, "AOD", "HFCREDSEBASE", //! Table with Same Event Trig-Assoc pairs + aod::hf_correl_charm_had_reduced::HfcRedCorrCollId, + aod::hf_correl_charm_had_reduced::PtTrig, + aod::hf_correl_charm_had_reduced::PtAssoc, + aod::hf_correl_charm_had_reduced::DeltaEta, + aod::hf_correl_charm_had_reduced::DeltaPhi); + +DECLARE_SOA_TABLE(HfcRedCorrSEs, "AOD", "HFCREDCORRSE", //! Correlation pairs information Same Event + aod::hf_correl_charm_had_reduced::PoolBin, + aod::hf_correl_charm_had_reduced::PtTrig, + aod::hf_correl_charm_had_reduced::PtAssoc, + aod::hf_correl_charm_had_reduced::DeltaEta, + aod::hf_correl_charm_had_reduced::DeltaPhi); + +DECLARE_SOA_TABLE(HfcRedCorrMEs, "AOD", "HFCREDCORRME", //! Correlation pairs information Mixed Event + aod::hf_correl_charm_had_reduced::PoolBin, + aod::hf_correl_charm_had_reduced::PtTrig, + aod::hf_correl_charm_had_reduced::PtAssoc, + aod::hf_correl_charm_had_reduced::DeltaEta, + aod::hf_correl_charm_had_reduced::DeltaPhi); } // namespace o2::aod diff --git a/PWGHF/HFC/TableProducer/correlatorFlowCharmHadronsReduced.cxx b/PWGHF/HFC/TableProducer/correlatorFlowCharmHadronsReduced.cxx index fa132c4233c..879cd629fbc 100644 --- a/PWGHF/HFC/TableProducer/correlatorFlowCharmHadronsReduced.cxx +++ b/PWGHF/HFC/TableProducer/correlatorFlowCharmHadronsReduced.cxx @@ -57,8 +57,8 @@ using BinningTypeDerivedMult = ColumnBinningPolicy double getPt(const TTrack& track) { - if constexpr (requires { track.ptAssocTrack(); }) { - return track.ptAssocTrack(); + if constexpr (requires { track.ptAssoc(); }) { + return track.ptAssoc(); } else { return track.ptTrig(); } @@ -69,8 +69,8 @@ double getPt(const TTrack& track) template double getEta(const TTrack& track) { - if constexpr (requires { track.etaAssocTrack(); }) { - return track.etaAssocTrack(); + if constexpr (requires { track.etaAssoc(); }) { + return track.etaAssoc(); } else { return track.etaTrig(); } @@ -81,15 +81,16 @@ double getEta(const TTrack& track) template double getPhi(const TTrack& track) { - if constexpr (requires { track.phiAssocTrack(); }) { - return track.phiAssocTrack(); + if constexpr (requires { track.phiAssoc(); }) { + return track.phiAssoc(); } else { return track.phiTrig(); } } struct HfCorrelatorFlowCharmHadronsReduced { - Produces entryCorrPair; + Produces rowPairSE; + Produces rowPairME; Configurable fillSparses{"fillSparses", true, "Fill sparse histograms"}; Configurable fillTables{"fillTables", false, "Fill tables"}; @@ -100,25 +101,32 @@ struct HfCorrelatorFlowCharmHadronsReduced { Configurable deltaEtaAbsMax{"deltaEtaAbsMax", 2., "max. pair delta eta"}; Configurable dcaXYTrackMax{"dcaXYTrackMax", 1., "max. track DCA XY"}; Configurable dcaZTrackMax{"dcaZTrackMax", 1., "max. track DCA Z"}; + Configurable bdtBkgScoreMax{"bdtBkgScoreMax", 1.01, "max. BDT score for background candidates"}; Configurable tpcCrossedRowsMin{"tpcCrossedRowsMin", 1, "min. TPC crossed rows"}; Configurable itsNClsMin{"itsNClsMin", 1, "min. ITS clusters"}; + Configurable downSamplePairsSE{"downSamplePairsSE", 1., "Fraction of SE pairs to keep"}; + Configurable ptMaxForDownSampleSE{"ptMaxForDownSampleSE", 10., "Maximum pt for the application of the downsampling factor"}; + Configurable centMaxForDownSampleSE{"centMaxForDownSampleSE", 10., "Maximum centrality for the application of the downsampling factor"}; Configurable downSamplePairsME{"downSamplePairsME", 1., "Fraction of ME pairs to keep"}; Configurable ptMaxForDownSampleME{"ptMaxForDownSampleME", 10., "Maximum pt for the application of the downsampling factor"}; Configurable centMaxForDownSampleME{"centMaxForDownSampleME", 10., "Maximum centrality for the application of the downsampling factor"}; SliceCache cache; - using AssocTracks = soa::Filtered>; - using SameEvtPairsChHad = soa::Filtered>; - using SameEvtPairsHadHad = soa::Filtered>; - using TrigCands = soa::Join; + int poolBins{0}; - Filter filterTrackData = (nabs(aod::hf_assoc_track_reduced::dcaXY) < dcaXYTrackMax) && (nabs(aod::hf_assoc_track_reduced::dcaZ) < dcaZTrackMax) && (aod::hf_assoc_track_reduced::nTpcCrossedRows > tpcCrossedRowsMin) && (aod::hf_assoc_track_reduced::itsNCls > itsNClsMin); - Filter filterSameEvtPairsChHad = (nabs(aod::hf_assoc_track_reduced::dcaXY) < dcaXYTrackMax) && (nabs(aod::hf_assoc_track_reduced::dcaZ) < dcaZTrackMax) && (aod::hf_assoc_track_reduced::nTpcCrossedRows > tpcCrossedRowsMin) && (aod::hf_assoc_track_reduced::itsNCls > itsNClsMin); - Filter filterSameEvtPairsHadHad = (nabs(aod::hf_assoc_track_reduced::dcaXY) < dcaXYTrackMax) && (nabs(aod::hf_assoc_track_reduced::dcaZ) < dcaZTrackMax) && (aod::hf_assoc_track_reduced::nTpcCrossedRows > tpcCrossedRowsMin) && (aod::hf_assoc_track_reduced::itsNCls > itsNClsMin); + using SameEvtPairsChHad = soa::Filtered>; + using SameEvtPairsHadHad = soa::Filtered>; + using AssocTracks = soa::Filtered>; + using TrigCharmCands = soa::Filtered>; - Preslice tracksPerCol = aod::hf_correlation_trigger_reduced::hfcRedCorrCollId; - Preslice candPerCol = aod::hf_correlation_trigger_reduced::hfcRedCorrCollId; + Filter filterAssocTracks = (nabs(aod::hf_correl_charm_had_reduced::dcaXYAssoc) < dcaXYTrackMax) && (nabs(aod::hf_correl_charm_had_reduced::dcaZAssoc) < dcaZTrackMax) && (aod::hf_correl_charm_had_reduced::nTpcCrossedRowsAssoc > tpcCrossedRowsMin) && (aod::hf_correl_charm_had_reduced::itsNClsAssoc > itsNClsMin); + Filter filterTrigTracks = (nabs(aod::hf_correl_charm_had_reduced::dcaXYTrig) < dcaXYTrackMax) && (nabs(aod::hf_correl_charm_had_reduced::dcaZTrig) < dcaZTrackMax) && (aod::hf_correl_charm_had_reduced::nTpcCrossedRowsTrig > tpcCrossedRowsMin) && (aod::hf_correl_charm_had_reduced::itsNClsTrig > itsNClsMin); + Filter filterSameEvtPairs = (nabs(aod::hf_correl_charm_had_reduced::deltaEta) > deltaEtaAbsMin) && (nabs(aod::hf_correl_charm_had_reduced::deltaEta) < deltaEtaAbsMax); + Filter filterTrigCharmCands = (nabs(aod::hf_correl_charm_had_reduced::bdtScore0Trig) < bdtBkgScoreMax); + + Preslice assocTracksPerCol = aod::hf_correl_charm_had_reduced::hfcRedCorrCollId; + Preslice trigCharmCandsPerCol = aod::hf_correl_charm_had_reduced::hfcRedCorrCollId; ConfigurableAxis zPoolBins{"zPoolBins", {VARIABLE_WIDTH, -10.0, -2.5, 2.5, 10.0}, "Z vertex position pools"}; ConfigurableAxis multPoolBins{"multPoolBins", {VARIABLE_WIDTH, 0., 900., 1800., 6000.}, "Event multiplicity pools (FT0M)"}; @@ -131,7 +139,7 @@ struct HfCorrelatorFlowCharmHadronsReduced { ConfigurableAxis binsPhi{"binsPhi", {64, -o2::constants::math::PIHalf, 3. * o2::constants::math::PIHalf}, "Phi bins"}; ConfigurableAxis binsDeltaEta{"binsDeltaEta", {100, -2., 2.}, "Delta Eta bins"}; ConfigurableAxis binsDeltaPhi{"binsDeltaPhi", {64, -3., 3.}, "Delta Phi bins"}; - ConfigurableAxis binsPoolBin{"binsPoolBin", {9, 0., 9.}, "PoolBin"}; + // ConfigurableAxis binsPoolBin{"binsPoolBin", {9, 0., 9.}, "PoolBin"}; ConfigurableAxis binsMlOne{"binsMlOne", {100, 0., 1.}, ""}; ConfigurableAxis binsMlTwo{"binsMlTwo", {100, 0., 1.}, ""}; @@ -142,20 +150,29 @@ struct HfCorrelatorFlowCharmHadronsReduced { void init(InitContext&) { - std::array doprocess{doprocessSameEventCharmHadWCentMix, doprocessSameEventCharmHadWMultMix, doprocessMixedEventCharmHadWCentMix, doprocessMixedEventCharmHadWMultMix, - doprocessSameEventHadHadWCentMix, doprocessSameEventHadHadWMultMix, doprocessMixedEventHadHadWCentMix, doprocessMixedEventHadHadWMultMix}; - if ((std::accumulate(doprocess.begin(), doprocess.end(), 0)) != 1) { - LOGP(fatal, "Only one process function should be enabled! Please check your configuration!"); + if ( (doprocessSameEventCharmHadWCentMix && doprocessMixedEventCharmHadWMultMix) || + (doprocessSameEventCharmHadWMultMix && doprocessMixedEventCharmHadWCentMix) || + (doprocessSameEventHadHadWCentMix && doprocessMixedEventHadHadWMultMix) || + (doprocessSameEventHadHadWMultMix && doprocessMixedEventHadHadWCentMix) ) { + LOGP(fatal, "You cannot mix centrality and multiplicity mixing in the same processing! Please check your configuration!"); } if (!fillSparses && !fillTables) { LOGP(fatal, "At least one of fillSparses or fillTables must be true!"); } + if (doprocessSameEventCharmHadWCentMix || doprocessSameEventHadHadWCentMix || doprocessMixedEventCharmHadWCentMix || doprocessMixedEventHadHadWCentMix) { + poolBins = (centPoolBins->size() - 1) * (zPoolBins->size() - 1); + } else { + poolBins = (multPoolBins->size() - 1) * (zPoolBins->size() - 1); + } + + // binsPoolBin = {poolBins, 0., static_cast(poolBins)}; + const AxisSpec axisInvMass{binsInvMass, "Inv. mass (GeV/#it{c}^{2})"}; const AxisSpec axisCent = {binsCent, "Centrality"}; const AxisSpec axisMultFT0M = {binsMultFT0M, "MultiplicityFT0M"}; const AxisSpec axisPosZ = {binsPosZ, "PosZ"}; - const AxisSpec axisPoolBin = {binsPoolBin, "PoolBin"}; + const AxisSpec axisPoolBin = {poolBins, 0., static_cast(poolBins), "PoolBin"}; const AxisSpec axisEta = {binsEta, "#it{#eta}"}; const AxisSpec axisPhi = {binsPhi, "#it{#varphi}"}; const AxisSpec axisDeltaEta = {binsDeltaEta, "#Delta#it{#eta}"}; @@ -166,20 +183,21 @@ struct HfCorrelatorFlowCharmHadronsReduced { const AxisSpec axisMlTwo{binsMlTwo, "bdtScore1"}; // Histograms for data analysis - if (doprocessSameEventCharmHadWCentMix || doprocessMixedEventCharmHadWCentMix || doprocessSameEventHadHadWCentMix || doprocessMixedEventHadHadWCentMix) { - registry.add("hCent", "Centrality", {HistType::kTH2F, {{axisCent}, {axisPoolBin}}}); - } else { - registry.add("hMultFT0M", "Multiplicity FT0M", {HistType::kTH2F, {{axisMultFT0M}, {axisPoolBin}}}); + if (doprocessSameEventCharmHadWCentMix || doprocessSameEventHadHadWCentMix) { + registry.add("hCentPoolBinSE", "Centrality SE", {HistType::kTH2F, {{axisCent}, {axisPoolBin}}}); + } else if (doprocessSameEventCharmHadWMultMix || doprocessSameEventHadHadWMultMix) { + registry.add("hMultFT0MPoolBinSE", "Multiplicity FT0M SE", {HistType::kTH2F, {{axisMultFT0M}, {axisPoolBin}}}); + } else if (doprocessMixedEventCharmHadWCentMix || doprocessMixedEventHadHadWCentMix) { + registry.add("hCentPoolBinME", "Centrality ME", {HistType::kTH2F, {{axisCent}, {axisPoolBin}}}); + } else if (doprocessMixedEventCharmHadWMultMix || doprocessMixedEventHadHadWMultMix) { + registry.add("hMultFT0MPoolBinME", "Multiplicity FT0M ME", {HistType::kTH2F, {{axisMultFT0M}, {axisPoolBin}}}); } - registry.add("hZVtx", "z vertex", {HistType::kTH2F, {{axisPosZ}, {axisPoolBin}}}); - registry.add("hCollisionPoolBin", "Collision pool bin", {HistType::kTH1F, {axisPoolBin}}); - registry.add("hPoolBinTrig", "Trigger candidates pool bin", {HistType::kTH1F, {axisPoolBin}}); - registry.add("hPhiVsPtTrig", "Trigger candidates phiVsPt", {HistType::kTH2F, {{axisPhi}, {axisPtTrig}}}); - registry.add("hEtaVsPtTrig", "Trigger candidates etaVsPt", {HistType::kTH2F, {{axisEta}, {axisPtTrig}}}); - registry.add("hPoolBinAssoc", "Associated particles pool bin", {HistType::kTH1F, {axisPoolBin}}); - registry.add("hPhiVsPtAssoc", "Associated particles phiVsPt", {HistType::kTH3F, {{axisPhi}, {axisPtTrig}, {axisPtAssoc}}}); - registry.add("hEtaVsPtAssoc", "Associated particles etaVsPt", {HistType::kTH3F, {{axisEta}, {axisPtTrig}, {axisPtAssoc}}}); - + registry.add("hZVtxPoolBinSE", "z vertex SE", {HistType::kTH2F, {{axisPosZ}, {axisPoolBin}}}); + registry.add("hZVtxPoolBinME", "z vertex ME", {HistType::kTH2F, {{axisPosZ}, {axisPoolBin}}}); + registry.add("hPoolBinTrigSE", "Trigger candidates pool bin SE", {HistType::kTH1F, {axisPoolBin}}); + registry.add("hPoolBinTrigME", "Trigger candidates pool bin ME", {HistType::kTH1F, {axisPoolBin}}); + registry.add("hPoolBinAssocSE", "Associated particles pool bin SE", {HistType::kTH1F, {axisPoolBin}}); + registry.add("hPoolBinAssocME", "Associated particles pool bin ME", {HistType::kTH1F, {axisPoolBin}}); if (fillSparses) { std::vector axes = {axisPoolBin, axisPtTrig, axisPtAssoc, axisDeltaEta, axisDeltaPhi}; if (doprocessSameEventHadHadWCentMix || doprocessSameEventHadHadWMultMix) { @@ -200,19 +218,27 @@ struct HfCorrelatorFlowCharmHadronsReduced { /// Get the binning pool associated to the collision /// \param collision is the collision /// \param binPolicy is the binning policy for the correlation - template + template int getPoolBin(const TColl& collision, const TBinningType& binPolicy) { int poolBin{0}; if constexpr (std::is_same_v) { poolBin = binPolicy.getBin(std::make_tuple(collision.posZ(), collision.centrality())); - if constexpr (fillHistos) { - registry.fill(HIST("hCent"), collision.centrality(), poolBin); + if constexpr (isMixedEvent) { + registry.fill(HIST("hCentPoolBinME"), collision.centrality(), poolBin); + registry.fill(HIST("hZVtxPoolBinME"), collision.posZ(), poolBin); + } else { + registry.fill(HIST("hCentPoolBinSE"), collision.centrality(), poolBin); + registry.fill(HIST("hZVtxPoolBinSE"), collision.posZ(), poolBin); } } else if constexpr (std::is_same_v) { poolBin = binPolicy.getBin(std::make_tuple(collision.posZ(), collision.multiplicity())); - if constexpr (fillHistos) { - registry.fill(HIST("hMultFT0M"), collision.multiplicity(), poolBin); + if constexpr (isMixedEvent) { + registry.fill(HIST("hMultFT0MPoolBinME"), collision.multiplicity(), poolBin); + registry.fill(HIST("hZVtxPoolBinME"), collision.posZ(), poolBin); + } else { + registry.fill(HIST("hMultFT0MPoolBinSE"), collision.multiplicity(), poolBin); + registry.fill(HIST("hZVtxPoolBinSE"), collision.posZ(), poolBin); } } return poolBin; @@ -228,20 +254,25 @@ struct HfCorrelatorFlowCharmHadronsReduced { TBinningType binPolicy) { auto collision = pair.template hfcRedCorrColl_as(); - int poolBin = getPoolBin(collision, binPolicy); - registry.fill(HIST("hCollisionPoolBin"), poolBin); - registry.fill(HIST("hZVtx"), collision.posZ(), poolBin); - registry.fill(HIST("hPoolBinTrig"), poolBin); - registry.fill(HIST("hPoolBinAssoc"), poolBin); + double ptTrig = pair.ptTrig(); + if (downSamplePairsSE < 1.) { + float pseudoRndm = ptTrig * 1000. - static_cast(ptTrig * 1000); + if (ptTrig < ptMaxForDownSampleSE && collision.centrality() < centMaxForDownSampleSE && pseudoRndm >= downSamplePairsSE) { + return; + } + } + int poolBin = getPoolBin(collision, binPolicy); + registry.fill(HIST("hPoolBinTrigSE"), poolBin); + registry.fill(HIST("hPoolBinAssocSE"), poolBin); if constexpr (fillTables) { - entryCorrPair(poolBin, pair.ptTrig(), pair.ptAssocTrack(), pair.deltaEta(), pair.deltaPhi()); + rowPairSE(poolBin, ptTrig, pair.ptAssoc(), pair.deltaEta(), pair.deltaPhi()); } if constexpr (fillSparses) { - if constexpr (requires { pair.bdtScore0Trig(); }) { // Separate Charm-Had and Had-Had cases - registry.fill(HIST("hSparseCorrelationsSECharmHad"), poolBin, pair.ptTrig(), pair.ptAssocTrack(), pair.deltaEta(), + if constexpr (requires{ pair.bdtScore0Trig(); }) { // Separate Charm-Had and Had-Had cases + registry.fill(HIST("hSparseCorrelationsSECharmHad"), poolBin, ptTrig, pair.ptAssoc(), pair.deltaEta(), pair.deltaPhi(), pair.bdtScore0Trig(), pair.bdtScore1Trig(), pair.invMassTrig()); } else { - registry.fill(HIST("hSparseCorrelationsSEHadHad"), poolBin, pair.ptTrig(), pair.ptAssocTrack(), pair.deltaEta(), pair.deltaPhi()); + registry.fill(HIST("hSparseCorrelationsSEHadHad"), poolBin, ptTrig, pair.ptAssoc(), pair.deltaEta(), pair.deltaPhi()); } } } @@ -264,12 +295,14 @@ struct HfCorrelatorFlowCharmHadronsReduced { if (trigCands.size() == 0 || assocTracks.size() == 0) { continue; } - int poolBinTrig = getPoolBin(trigColl, binPolicy); - int poolBinAssoc = getPoolBin(assocColl, binPolicy); + int poolBinTrig = getPoolBin(trigColl, binPolicy); + int poolBinAssoc = getPoolBin(assocColl, binPolicy); if (poolBinAssoc != poolBinTrig) { LOGF(info, "Error, poolBins are different"); continue; } + registry.fill(HIST("hPoolBinTrigME"), poolBinTrig); + registry.fill(HIST("hPoolBinAssocME"), poolBinAssoc); for (const auto& [trigCand, assocTrack] : o2::soa::combinations(o2::soa::CombinationsFullIndexPolicy(trigCands, assocTracks))) { // LOGF(info, "Mixed event tracks pair: (%d, %d) from events (%d, %d), track event: (%d, %d)", trigCand.index(), assocTrack.index(), trigColl.index(), assocColl.index(), trigCand.hfcRedFlowCollId(), assocTrack.hfcRedFlowCollId()); @@ -288,7 +321,7 @@ struct HfCorrelatorFlowCharmHadronsReduced { } double deltaPhi = getPhi(assocTrack) - getPhi(trigCand); if constexpr (fillTables) { - entryCorrPair(poolBinTrig, ptTrig, ptAssoc, deltaEta, deltaPhi); + rowPairME(poolBinTrig, ptTrig, ptAssoc, deltaEta, deltaPhi); } if constexpr (fillSparses) { if constexpr (requires { trigCand.bdtScore0Trig(); }) { // Separate Charm-Had and Had-Had cases @@ -355,7 +388,7 @@ struct HfCorrelatorFlowCharmHadronsReduced { PROCESS_SWITCH(HfCorrelatorFlowCharmHadronsReduced, processSameEventHadHadWCentMix, "Process Same Event for Had-Had with centrality pools", false); void processMixedEventCharmHadWCentMix(aod::HfcRedCorrColls const& collisions, - TrigCands const& candidates, + TrigCharmCands const& candidates, AssocTracks const& tracks) { if (fillSparses && fillTables) { @@ -369,7 +402,7 @@ struct HfCorrelatorFlowCharmHadronsReduced { PROCESS_SWITCH(HfCorrelatorFlowCharmHadronsReduced, processMixedEventCharmHadWCentMix, "Process Mixed Event for Charm-Had with centrality pools", false); void processMixedEventCharmHadWMultMix(aod::HfcRedCorrColls const& collisions, - TrigCands const& candidates, + TrigCharmCands const& candidates, AssocTracks const& tracks) { if (fillSparses && fillTables) { diff --git a/PWGHF/HFC/TableProducer/derivedDataCreatorCorrelationsReduced.cxx b/PWGHF/HFC/TableProducer/derivedDataCreatorCorrelationsReduced.cxx index 9d384471401..8fcd8fff6a4 100644 --- a/PWGHF/HFC/TableProducer/derivedDataCreatorCorrelationsReduced.cxx +++ b/PWGHF/HFC/TableProducer/derivedDataCreatorCorrelationsReduced.cxx @@ -62,13 +62,13 @@ enum CandType { /// Code to select collisions with at least one Ds meson struct HfDerivedDataCreatorCorrelationsReduced { - Produces rowCollisions; // Table with reduced collision info - Produces rowSEPairs; // Table with same-event pairs info - Produces rowAssocTrks; // Table with associated track info - Produces rowAssocTrkSels; // Table with associated track selection info - Produces rowTrigs; // Table with charm candidate info - Produces rowTrigCharms; // Table with charm trigger candidate info - Produces rowTrigHads; // Table with hadron trigger candidate info + Produces rowCollisions; // Table with reduced collision info + Produces rowSEPairs; // Table with same-event pairs info + Produces rowAssocTrks; // Table with associated track info + Produces rowAssocTrkSels; // Table with associated track selection info + Produces rowTrigs; // Table with charm candidate info + Produces rowTrigCharms; // Table with charm trigger candidate info + Produces rowTrigHads; // Table with hadron trigger candidate info Configurable centEstimator{"centEstimator", 2, "Centrality estimation (FT0A: 1, FT0C: 2, FT0M: 3, FV0A: 4)"}; Configurable selectionFlag{"selectionFlag", 15, "Selection Flag for hadron (ML score tables are required to run the task)"}; @@ -270,21 +270,21 @@ struct HfDerivedDataCreatorCorrelationsReduced { return false; } - if constexpr (candType == CandType::Hadron) { + int trackGlobalIndex = assTrk.globalIndex(); + if constexpr (candType == CandType::Hadron) { if (!cand.isGlobalTrackWoDCA() || cand.tpcNClsCrossedRows() < tpcNClsCrossedRowsMin) { return false; } - if (assTrk.globalIndex() == cand.globalIndex()) { + if (trackGlobalIndex == cand.globalIndex()) { return false; // skip self-correlation for hadron-hadron } } else { // Remove Daughter-Cand pairs for charm-hadron correlations if constexpr ((requires { cand.prong2Id(); })) { // Check 3-prong - return (assTrk.globalIndex() == cand.prong0Id() || assTrk.globalIndex() == cand.prong1Id() || assTrk.globalIndex() == cand.prong2Id()); + return (trackGlobalIndex != cand.prong0Id() && trackGlobalIndex != cand.prong1Id() && trackGlobalIndex != cand.prong2Id()); } else { // Check 2-prong - return (assTrk.globalIndex() == cand.prong0Id() || assTrk.globalIndex() == cand.prong1Id()); + return (trackGlobalIndex != cand.prong0Id() && trackGlobalIndex != cand.prong1Id()); } } - return true; } /// Fill histograms and tables for same-event correlations From 21fb70af2e251ab6103a3b6fdda9d65f644d4193 Mon Sep 17 00:00:00 2001 From: ALICE Action Bot Date: Wed, 17 Sep 2025 21:31:28 +0000 Subject: [PATCH 09/15] Please consider the following formatting changes --- .../DataModel/DerivedDataCorrelationTables.h | 52 +++++++++---------- .../correlatorFlowCharmHadronsReduced.cxx | 14 ++--- .../derivedDataCreatorCorrelationsReduced.cxx | 8 +-- 3 files changed, 37 insertions(+), 37 deletions(-) diff --git a/PWGHF/HFC/DataModel/DerivedDataCorrelationTables.h b/PWGHF/HFC/DataModel/DerivedDataCorrelationTables.h index a15e8d2dc88..441b6823aa1 100644 --- a/PWGHF/HFC/DataModel/DerivedDataCorrelationTables.h +++ b/PWGHF/HFC/DataModel/DerivedDataCorrelationTables.h @@ -106,32 +106,32 @@ DECLARE_SOA_TABLE(AssocTrackSels, "AOD", "ASSOCTRACKSEL", //! Table with associa // definition of columns and tables for Charm-Hadron and Hadron-Hadron correlation pairs namespace hf_correl_charm_had_reduced { -DECLARE_SOA_INDEX_COLUMN(HfcRedCorrColl, hfcRedCorrColl); //! ReducedCollision index -DECLARE_SOA_COLUMN(DeltaPhi, deltaPhi, float); //! DeltaPhi between charm hadron and Hadrons -DECLARE_SOA_COLUMN(DeltaEta, deltaEta, float); //! DeltaEta between charm hadron and Hadrons -DECLARE_SOA_COLUMN(PoolBin, poolBin, int); //! Pool Bin for the MixedEvent -DECLARE_SOA_COLUMN(PhiTrig, phiTrig, float); //! Phi of the trigger candidate -DECLARE_SOA_COLUMN(EtaTrig, etaTrig, float); //! Eta of the trigger candidate -DECLARE_SOA_COLUMN(PtTrig, ptTrig, float); //! Pt of the trigger candidate -DECLARE_SOA_COLUMN(InvMassTrig, invMassTrig, float); //! Invariant mass of Charm trigger candidate -DECLARE_SOA_COLUMN(BdtScore0Trig, bdtScore0Trig, float); //! First BDT output score -DECLARE_SOA_COLUMN(BdtScore1Trig, bdtScore1Trig, float); //! Second BDT output score -DECLARE_SOA_COLUMN(NTpcCrossedRowsTrig, nTpcCrossedRowsTrig, int); //! Number of crossed TPC Rows -DECLARE_SOA_COLUMN(ItsClsMapTrig, itsClsMapTrig, int); //! ITS cluster map, one bit per a layer, starting from the innermost -DECLARE_SOA_COLUMN(ItsNClsTrig, itsNClsTrig, int); //! Number of ITS clusters -DECLARE_SOA_COLUMN(EtaTrigTrack, etaTrigTrack, float); //! Eta of the track -DECLARE_SOA_COLUMN(PhiTrigTrack, phiTrigTrack, float); //! Phi of the track -DECLARE_SOA_COLUMN(PtTrigTrack, ptTrigTrack, float); //! Pt of the track -DECLARE_SOA_COLUMN(DcaXYTrig, dcaXYTrig, float); //! Impact parameter in XY of the track to the primary vertex -DECLARE_SOA_COLUMN(DcaZTrig, dcaZTrig, float); //! Impact parameter in Z of the track to the primary vertex -DECLARE_SOA_COLUMN(NTpcCrossedRowsAssoc, nTpcCrossedRowsAssoc, int); //! Number of crossed TPC Rows -DECLARE_SOA_COLUMN(ItsClsMapAssoc, itsClsMapAssoc, int); //! ITS cluster map, one bit per a layer, starting from the innermost -DECLARE_SOA_COLUMN(ItsNClsAssoc, itsNClsAssoc, int); //! Number of ITS clusters -DECLARE_SOA_COLUMN(EtaAssoc, etaAssoc, float); //! Eta of the track -DECLARE_SOA_COLUMN(PhiAssoc, phiAssoc, float); //! Phi of the track -DECLARE_SOA_COLUMN(PtAssoc, ptAssoc, float); //! Pt of the track -DECLARE_SOA_COLUMN(DcaXYAssoc, dcaXYAssoc, float); //! Impact parameter in XY of the track to the primary vertex -DECLARE_SOA_COLUMN(DcaZAssoc, dcaZAssoc, float); //! Impact parameter in Z of the track to the primary vertex +DECLARE_SOA_INDEX_COLUMN(HfcRedCorrColl, hfcRedCorrColl); //! ReducedCollision index +DECLARE_SOA_COLUMN(DeltaPhi, deltaPhi, float); //! DeltaPhi between charm hadron and Hadrons +DECLARE_SOA_COLUMN(DeltaEta, deltaEta, float); //! DeltaEta between charm hadron and Hadrons +DECLARE_SOA_COLUMN(PoolBin, poolBin, int); //! Pool Bin for the MixedEvent +DECLARE_SOA_COLUMN(PhiTrig, phiTrig, float); //! Phi of the trigger candidate +DECLARE_SOA_COLUMN(EtaTrig, etaTrig, float); //! Eta of the trigger candidate +DECLARE_SOA_COLUMN(PtTrig, ptTrig, float); //! Pt of the trigger candidate +DECLARE_SOA_COLUMN(InvMassTrig, invMassTrig, float); //! Invariant mass of Charm trigger candidate +DECLARE_SOA_COLUMN(BdtScore0Trig, bdtScore0Trig, float); //! First BDT output score +DECLARE_SOA_COLUMN(BdtScore1Trig, bdtScore1Trig, float); //! Second BDT output score +DECLARE_SOA_COLUMN(NTpcCrossedRowsTrig, nTpcCrossedRowsTrig, int); //! Number of crossed TPC Rows +DECLARE_SOA_COLUMN(ItsClsMapTrig, itsClsMapTrig, int); //! ITS cluster map, one bit per a layer, starting from the innermost +DECLARE_SOA_COLUMN(ItsNClsTrig, itsNClsTrig, int); //! Number of ITS clusters +DECLARE_SOA_COLUMN(EtaTrigTrack, etaTrigTrack, float); //! Eta of the track +DECLARE_SOA_COLUMN(PhiTrigTrack, phiTrigTrack, float); //! Phi of the track +DECLARE_SOA_COLUMN(PtTrigTrack, ptTrigTrack, float); //! Pt of the track +DECLARE_SOA_COLUMN(DcaXYTrig, dcaXYTrig, float); //! Impact parameter in XY of the track to the primary vertex +DECLARE_SOA_COLUMN(DcaZTrig, dcaZTrig, float); //! Impact parameter in Z of the track to the primary vertex +DECLARE_SOA_COLUMN(NTpcCrossedRowsAssoc, nTpcCrossedRowsAssoc, int); //! Number of crossed TPC Rows +DECLARE_SOA_COLUMN(ItsClsMapAssoc, itsClsMapAssoc, int); //! ITS cluster map, one bit per a layer, starting from the innermost +DECLARE_SOA_COLUMN(ItsNClsAssoc, itsNClsAssoc, int); //! Number of ITS clusters +DECLARE_SOA_COLUMN(EtaAssoc, etaAssoc, float); //! Eta of the track +DECLARE_SOA_COLUMN(PhiAssoc, phiAssoc, float); //! Phi of the track +DECLARE_SOA_COLUMN(PtAssoc, ptAssoc, float); //! Pt of the track +DECLARE_SOA_COLUMN(DcaXYAssoc, dcaXYAssoc, float); //! Impact parameter in XY of the track to the primary vertex +DECLARE_SOA_COLUMN(DcaZAssoc, dcaZAssoc, float); //! Impact parameter in Z of the track to the primary vertex } // namespace hf_correl_charm_had_reduced DECLARE_SOA_TABLE(HfcRedTrigBases, "AOD", "HFCREDTRIGBASE", //! Table with trigger candidate base info diff --git a/PWGHF/HFC/TableProducer/correlatorFlowCharmHadronsReduced.cxx b/PWGHF/HFC/TableProducer/correlatorFlowCharmHadronsReduced.cxx index 879cd629fbc..f5bd688be88 100644 --- a/PWGHF/HFC/TableProducer/correlatorFlowCharmHadronsReduced.cxx +++ b/PWGHF/HFC/TableProducer/correlatorFlowCharmHadronsReduced.cxx @@ -115,9 +115,9 @@ struct HfCorrelatorFlowCharmHadronsReduced { int poolBins{0}; - using SameEvtPairsChHad = soa::Filtered>; + using SameEvtPairsChHad = soa::Filtered>; using SameEvtPairsHadHad = soa::Filtered>; - using AssocTracks = soa::Filtered>; + using AssocTracks = soa::Filtered>; using TrigCharmCands = soa::Filtered>; Filter filterAssocTracks = (nabs(aod::hf_correl_charm_had_reduced::dcaXYAssoc) < dcaXYTrackMax) && (nabs(aod::hf_correl_charm_had_reduced::dcaZAssoc) < dcaZTrackMax) && (aod::hf_correl_charm_had_reduced::nTpcCrossedRowsAssoc > tpcCrossedRowsMin) && (aod::hf_correl_charm_had_reduced::itsNClsAssoc > itsNClsMin); @@ -150,10 +150,10 @@ struct HfCorrelatorFlowCharmHadronsReduced { void init(InitContext&) { - if ( (doprocessSameEventCharmHadWCentMix && doprocessMixedEventCharmHadWMultMix) || - (doprocessSameEventCharmHadWMultMix && doprocessMixedEventCharmHadWCentMix) || - (doprocessSameEventHadHadWCentMix && doprocessMixedEventHadHadWMultMix) || - (doprocessSameEventHadHadWMultMix && doprocessMixedEventHadHadWCentMix) ) { + if ((doprocessSameEventCharmHadWCentMix && doprocessMixedEventCharmHadWMultMix) || + (doprocessSameEventCharmHadWMultMix && doprocessMixedEventCharmHadWCentMix) || + (doprocessSameEventHadHadWCentMix && doprocessMixedEventHadHadWMultMix) || + (doprocessSameEventHadHadWMultMix && doprocessMixedEventHadHadWCentMix)) { LOGP(fatal, "You cannot mix centrality and multiplicity mixing in the same processing! Please check your configuration!"); } if (!fillSparses && !fillTables) { @@ -268,7 +268,7 @@ struct HfCorrelatorFlowCharmHadronsReduced { rowPairSE(poolBin, ptTrig, pair.ptAssoc(), pair.deltaEta(), pair.deltaPhi()); } if constexpr (fillSparses) { - if constexpr (requires{ pair.bdtScore0Trig(); }) { // Separate Charm-Had and Had-Had cases + if constexpr (requires { pair.bdtScore0Trig(); }) { // Separate Charm-Had and Had-Had cases registry.fill(HIST("hSparseCorrelationsSECharmHad"), poolBin, ptTrig, pair.ptAssoc(), pair.deltaEta(), pair.deltaPhi(), pair.bdtScore0Trig(), pair.bdtScore1Trig(), pair.invMassTrig()); } else { diff --git a/PWGHF/HFC/TableProducer/derivedDataCreatorCorrelationsReduced.cxx b/PWGHF/HFC/TableProducer/derivedDataCreatorCorrelationsReduced.cxx index 8fcd8fff6a4..69061a2d102 100644 --- a/PWGHF/HFC/TableProducer/derivedDataCreatorCorrelationsReduced.cxx +++ b/PWGHF/HFC/TableProducer/derivedDataCreatorCorrelationsReduced.cxx @@ -64,9 +64,9 @@ enum CandType { struct HfDerivedDataCreatorCorrelationsReduced { Produces rowCollisions; // Table with reduced collision info Produces rowSEPairs; // Table with same-event pairs info - Produces rowAssocTrks; // Table with associated track info - Produces rowAssocTrkSels; // Table with associated track selection info - Produces rowTrigs; // Table with charm candidate info + Produces rowAssocTrks; // Table with associated track info + Produces rowAssocTrkSels; // Table with associated track selection info + Produces rowTrigs; // Table with charm candidate info Produces rowTrigCharms; // Table with charm trigger candidate info Produces rowTrigHads; // Table with hadron trigger candidate info @@ -271,7 +271,7 @@ struct HfDerivedDataCreatorCorrelationsReduced { } int trackGlobalIndex = assTrk.globalIndex(); - if constexpr (candType == CandType::Hadron) { + if constexpr (candType == CandType::Hadron) { if (!cand.isGlobalTrackWoDCA() || cand.tpcNClsCrossedRows() < tpcNClsCrossedRowsMin) { return false; } From 550c7ee9bd31d7e97b423862c7c2f10455805f7b Mon Sep 17 00:00:00 2001 From: marcellocosti Date: Wed, 17 Sep 2025 23:33:44 +0200 Subject: [PATCH 10/15] Delete comments --- PWGHF/HFC/TableProducer/correlatorFlowCharmHadronsReduced.cxx | 3 --- 1 file changed, 3 deletions(-) diff --git a/PWGHF/HFC/TableProducer/correlatorFlowCharmHadronsReduced.cxx b/PWGHF/HFC/TableProducer/correlatorFlowCharmHadronsReduced.cxx index f5bd688be88..8b877527261 100644 --- a/PWGHF/HFC/TableProducer/correlatorFlowCharmHadronsReduced.cxx +++ b/PWGHF/HFC/TableProducer/correlatorFlowCharmHadronsReduced.cxx @@ -139,7 +139,6 @@ struct HfCorrelatorFlowCharmHadronsReduced { ConfigurableAxis binsPhi{"binsPhi", {64, -o2::constants::math::PIHalf, 3. * o2::constants::math::PIHalf}, "Phi bins"}; ConfigurableAxis binsDeltaEta{"binsDeltaEta", {100, -2., 2.}, "Delta Eta bins"}; ConfigurableAxis binsDeltaPhi{"binsDeltaPhi", {64, -3., 3.}, "Delta Phi bins"}; - // ConfigurableAxis binsPoolBin{"binsPoolBin", {9, 0., 9.}, "PoolBin"}; ConfigurableAxis binsMlOne{"binsMlOne", {100, 0., 1.}, ""}; ConfigurableAxis binsMlTwo{"binsMlTwo", {100, 0., 1.}, ""}; @@ -166,8 +165,6 @@ struct HfCorrelatorFlowCharmHadronsReduced { poolBins = (multPoolBins->size() - 1) * (zPoolBins->size() - 1); } - // binsPoolBin = {poolBins, 0., static_cast(poolBins)}; - const AxisSpec axisInvMass{binsInvMass, "Inv. mass (GeV/#it{c}^{2})"}; const AxisSpec axisCent = {binsCent, "Centrality"}; const AxisSpec axisMultFT0M = {binsMultFT0M, "MultiplicityFT0M"}; From 5539e6ec4702c85a3a783ed878f7389d5e64314d Mon Sep 17 00:00:00 2001 From: marcellocosti Date: Thu, 18 Sep 2025 18:01:56 +0200 Subject: [PATCH 11/15] Avoid pair repetition in Had-Had case and renamings --- .../DataModel/DerivedDataCorrelationTables.h | 82 +++++++-- .../correlatorFlowCharmHadronsReduced.cxx | 162 +++++++++++------- .../derivedDataCreatorCorrelationsReduced.cxx | 72 ++++---- 3 files changed, 210 insertions(+), 106 deletions(-) diff --git a/PWGHF/HFC/DataModel/DerivedDataCorrelationTables.h b/PWGHF/HFC/DataModel/DerivedDataCorrelationTables.h index 441b6823aa1..28bd5b0e213 100644 --- a/PWGHF/HFC/DataModel/DerivedDataCorrelationTables.h +++ b/PWGHF/HFC/DataModel/DerivedDataCorrelationTables.h @@ -106,30 +106,33 @@ DECLARE_SOA_TABLE(AssocTrackSels, "AOD", "ASSOCTRACKSEL", //! Table with associa // definition of columns and tables for Charm-Hadron and Hadron-Hadron correlation pairs namespace hf_correl_charm_had_reduced { +// Correlation columns DECLARE_SOA_INDEX_COLUMN(HfcRedCorrColl, hfcRedCorrColl); //! ReducedCollision index DECLARE_SOA_COLUMN(DeltaPhi, deltaPhi, float); //! DeltaPhi between charm hadron and Hadrons DECLARE_SOA_COLUMN(DeltaEta, deltaEta, float); //! DeltaEta between charm hadron and Hadrons DECLARE_SOA_COLUMN(PoolBin, poolBin, int); //! Pool Bin for the MixedEvent +// General trigger particle columns DECLARE_SOA_COLUMN(PhiTrig, phiTrig, float); //! Phi of the trigger candidate DECLARE_SOA_COLUMN(EtaTrig, etaTrig, float); //! Eta of the trigger candidate DECLARE_SOA_COLUMN(PtTrig, ptTrig, float); //! Pt of the trigger candidate +// Charm trigger particle selection columns DECLARE_SOA_COLUMN(InvMassTrig, invMassTrig, float); //! Invariant mass of Charm trigger candidate DECLARE_SOA_COLUMN(BdtScore0Trig, bdtScore0Trig, float); //! First BDT output score DECLARE_SOA_COLUMN(BdtScore1Trig, bdtScore1Trig, float); //! Second BDT output score +// Hadron trigger particle selection columns DECLARE_SOA_COLUMN(NTpcCrossedRowsTrig, nTpcCrossedRowsTrig, int); //! Number of crossed TPC Rows DECLARE_SOA_COLUMN(ItsClsMapTrig, itsClsMapTrig, int); //! ITS cluster map, one bit per a layer, starting from the innermost DECLARE_SOA_COLUMN(ItsNClsTrig, itsNClsTrig, int); //! Number of ITS clusters -DECLARE_SOA_COLUMN(EtaTrigTrack, etaTrigTrack, float); //! Eta of the track -DECLARE_SOA_COLUMN(PhiTrigTrack, phiTrigTrack, float); //! Phi of the track -DECLARE_SOA_COLUMN(PtTrigTrack, ptTrigTrack, float); //! Pt of the track DECLARE_SOA_COLUMN(DcaXYTrig, dcaXYTrig, float); //! Impact parameter in XY of the track to the primary vertex DECLARE_SOA_COLUMN(DcaZTrig, dcaZTrig, float); //! Impact parameter in Z of the track to the primary vertex +// General associated particle columns +DECLARE_SOA_COLUMN(EtaAssoc, etaAssoc, float); //! Eta of the associated candidate +DECLARE_SOA_COLUMN(PhiAssoc, phiAssoc, float); //! Phi of the associated candidate +DECLARE_SOA_COLUMN(PtAssoc, ptAssoc, float); //! Pt of the associated candidate +// Hadron associated particle selection columns DECLARE_SOA_COLUMN(NTpcCrossedRowsAssoc, nTpcCrossedRowsAssoc, int); //! Number of crossed TPC Rows DECLARE_SOA_COLUMN(ItsClsMapAssoc, itsClsMapAssoc, int); //! ITS cluster map, one bit per a layer, starting from the innermost DECLARE_SOA_COLUMN(ItsNClsAssoc, itsNClsAssoc, int); //! Number of ITS clusters -DECLARE_SOA_COLUMN(EtaAssoc, etaAssoc, float); //! Eta of the track -DECLARE_SOA_COLUMN(PhiAssoc, phiAssoc, float); //! Phi of the track -DECLARE_SOA_COLUMN(PtAssoc, ptAssoc, float); //! Pt of the track DECLARE_SOA_COLUMN(DcaXYAssoc, dcaXYAssoc, float); //! Impact parameter in XY of the track to the primary vertex DECLARE_SOA_COLUMN(DcaZAssoc, dcaZAssoc, float); //! Impact parameter in Z of the track to the primary vertex } // namespace hf_correl_charm_had_reduced @@ -146,21 +149,21 @@ DECLARE_SOA_TABLE(HfcRedTrigCharms, "AOD", "HFCREDTRIGCHARM", //! Table with Sam aod::hf_correl_charm_had_reduced::BdtScore0Trig, aod::hf_correl_charm_had_reduced::BdtScore1Trig); -DECLARE_SOA_TABLE(HfcRedTrigTrks, "AOD", "HFCREDTRIGTRK", //! Table with Same Event Charm-Hadron pairs information +DECLARE_SOA_TABLE(HfcRedTrigTracks, "AOD", "HFCREDTRIGTRACK", //! Table with Same Event Charm-Hadron pairs information aod::hf_correl_charm_had_reduced::NTpcCrossedRowsTrig, aod::hf_correl_charm_had_reduced::ItsClsMapTrig, aod::hf_correl_charm_had_reduced::ItsNClsTrig, aod::hf_correl_charm_had_reduced::DcaXYTrig, aod::hf_correl_charm_had_reduced::DcaZTrig); -DECLARE_SOA_TABLE(HfcRedAssocBases, "AOD", "HFCREDASSOCBASE", //! Table with associated candidate base info +DECLARE_SOA_TABLE(HfcRedAssBases, "AOD", "HFCREDASSBASE", //! Table with associated candidate base info soa::Index<>, aod::hf_correl_charm_had_reduced::HfcRedCorrCollId, aod::hf_correl_charm_had_reduced::PhiAssoc, aod::hf_correl_charm_had_reduced::EtaAssoc, aod::hf_correl_charm_had_reduced::PtAssoc); -DECLARE_SOA_TABLE(HfcRedAssocTrks, "AOD", "HFCREDASSOCTRK", //! Table with Same Event Track Selections information +DECLARE_SOA_TABLE(HfcRedAssTracks, "AOD", "HFCREDASSTRACK", //! Table with Same Event Track Selections information aod::hf_correl_charm_had_reduced::NTpcCrossedRowsAssoc, aod::hf_correl_charm_had_reduced::ItsClsMapAssoc, aod::hf_correl_charm_had_reduced::ItsNClsAssoc, @@ -174,20 +177,73 @@ DECLARE_SOA_TABLE(HfcRedSEBases, "AOD", "HFCREDSEBASE", //! Table with Same Even aod::hf_correl_charm_had_reduced::DeltaEta, aod::hf_correl_charm_had_reduced::DeltaPhi); -DECLARE_SOA_TABLE(HfcRedCorrSEs, "AOD", "HFCREDCORRSE", //! Correlation pairs information Same Event +DECLARE_SOA_TABLE(HfcRedSEChHads, "AOD", "HFCREDSECHHAD", //! Correlation pairs information Same Event aod::hf_correl_charm_had_reduced::PoolBin, aod::hf_correl_charm_had_reduced::PtTrig, aod::hf_correl_charm_had_reduced::PtAssoc, aod::hf_correl_charm_had_reduced::DeltaEta, - aod::hf_correl_charm_had_reduced::DeltaPhi); + aod::hf_correl_charm_had_reduced::DeltaPhi, + aod::hf_correl_charm_had_reduced::InvMassTrig, + aod::hf_correl_charm_had_reduced::BdtScore0Trig, + aod::hf_correl_charm_had_reduced::BdtScore1Trig, + aod::hf_correl_charm_had_reduced::NTpcCrossedRowsAssoc, + aod::hf_correl_charm_had_reduced::ItsClsMapAssoc, + aod::hf_correl_charm_had_reduced::ItsNClsAssoc, + aod::hf_correl_charm_had_reduced::DcaXYAssoc, + aod::hf_correl_charm_had_reduced::DcaZAssoc, + soa::Marker<1>); -DECLARE_SOA_TABLE(HfcRedCorrMEs, "AOD", "HFCREDCORRME", //! Correlation pairs information Mixed Event +DECLARE_SOA_TABLE(HfcRedMEChHads, "AOD", "HFCREDMECHHAD", //! Correlation pairs information Same Event aod::hf_correl_charm_had_reduced::PoolBin, aod::hf_correl_charm_had_reduced::PtTrig, aod::hf_correl_charm_had_reduced::PtAssoc, aod::hf_correl_charm_had_reduced::DeltaEta, - aod::hf_correl_charm_had_reduced::DeltaPhi); + aod::hf_correl_charm_had_reduced::DeltaPhi, + aod::hf_correl_charm_had_reduced::InvMassTrig, + aod::hf_correl_charm_had_reduced::BdtScore0Trig, + aod::hf_correl_charm_had_reduced::BdtScore1Trig, + aod::hf_correl_charm_had_reduced::NTpcCrossedRowsAssoc, + aod::hf_correl_charm_had_reduced::ItsClsMapAssoc, + aod::hf_correl_charm_had_reduced::ItsNClsAssoc, + aod::hf_correl_charm_had_reduced::DcaXYAssoc, + aod::hf_correl_charm_had_reduced::DcaZAssoc, + soa::Marker<2>); +DECLARE_SOA_TABLE(HfcRedSEHadHads, "AOD", "HFCREDSEHADHAD", //! Correlation pairs information Same Event + aod::hf_correl_charm_had_reduced::PoolBin, + aod::hf_correl_charm_had_reduced::PtTrig, + aod::hf_correl_charm_had_reduced::PtAssoc, + aod::hf_correl_charm_had_reduced::DeltaEta, + aod::hf_correl_charm_had_reduced::DeltaPhi, + aod::hf_correl_charm_had_reduced::NTpcCrossedRowsTrig, + aod::hf_correl_charm_had_reduced::ItsClsMapTrig, + aod::hf_correl_charm_had_reduced::ItsNClsTrig, + aod::hf_correl_charm_had_reduced::DcaXYTrig, + aod::hf_correl_charm_had_reduced::DcaZTrig, + aod::hf_correl_charm_had_reduced::NTpcCrossedRowsAssoc, + aod::hf_correl_charm_had_reduced::ItsClsMapAssoc, + aod::hf_correl_charm_had_reduced::ItsNClsAssoc, + aod::hf_correl_charm_had_reduced::DcaXYAssoc, + aod::hf_correl_charm_had_reduced::DcaZAssoc, + soa::Marker<1>); + +DECLARE_SOA_TABLE(HfcRedMEHadHads, "AOD", "HFCREDMEHADHAD", //! Correlation pairs information Same Event + aod::hf_correl_charm_had_reduced::PoolBin, + aod::hf_correl_charm_had_reduced::PtTrig, + aod::hf_correl_charm_had_reduced::PtAssoc, + aod::hf_correl_charm_had_reduced::DeltaEta, + aod::hf_correl_charm_had_reduced::DeltaPhi, + aod::hf_correl_charm_had_reduced::NTpcCrossedRowsTrig, + aod::hf_correl_charm_had_reduced::ItsClsMapTrig, + aod::hf_correl_charm_had_reduced::ItsNClsTrig, + aod::hf_correl_charm_had_reduced::DcaXYTrig, + aod::hf_correl_charm_had_reduced::DcaZTrig, + aod::hf_correl_charm_had_reduced::NTpcCrossedRowsAssoc, + aod::hf_correl_charm_had_reduced::ItsClsMapAssoc, + aod::hf_correl_charm_had_reduced::ItsNClsAssoc, + aod::hf_correl_charm_had_reduced::DcaXYAssoc, + aod::hf_correl_charm_had_reduced::DcaZAssoc, + soa::Marker<2>); } // namespace o2::aod #endif // PWGHF_HFC_DATAMODEL_DERIVEDDATACORRELATIONTABLES_H_ diff --git a/PWGHF/HFC/TableProducer/correlatorFlowCharmHadronsReduced.cxx b/PWGHF/HFC/TableProducer/correlatorFlowCharmHadronsReduced.cxx index 8b877527261..6bb2daf27aa 100644 --- a/PWGHF/HFC/TableProducer/correlatorFlowCharmHadronsReduced.cxx +++ b/PWGHF/HFC/TableProducer/correlatorFlowCharmHadronsReduced.cxx @@ -40,6 +40,7 @@ #include #include +#include #include #include @@ -49,8 +50,8 @@ using namespace o2::framework::expressions; using namespace o2::hf_centrality; using namespace o2::hf_evsel; -using BinningTypeDerivedCent = ColumnBinningPolicy; -using BinningTypeDerivedMult = ColumnBinningPolicy; +using BinningCentPosZ = ColumnBinningPolicy; +using BinningMultPosZ = ColumnBinningPolicy; /// Get charm candidate or hadron track pT /// \param track is the candidate @@ -89,49 +90,47 @@ double getPhi(const TTrack& track) } struct HfCorrelatorFlowCharmHadronsReduced { - Produces rowPairSE; - Produces rowPairME; + Produces rowPairSECharmHads; //! Correlation pairs information Same Event + Produces rowPairMECharmHads; //! Correlation pairs information Mixed Event + Produces rowPairSEHadHads; //! Correlation pairs information Same Event + Produces rowPairMEHadHads; //! Correlation pairs information Mixed Event Configurable fillSparses{"fillSparses", true, "Fill sparse histograms"}; Configurable fillTables{"fillTables", false, "Fill tables"}; Configurable numberEventsMixed{"numberEventsMixed", 5, "Number of events mixed in ME process"}; - Configurable> binsPtTrig{"binsPtTrig", std::vector{1., 3., 5., 8., 16., 36.}, "pT bin limits for trigger candidates"}; + Configurable> binsPtTrig{"binsPtTrig", std::vector{0., 3., 5., 8., 16., 36.}, "pT bin limits for trigger candidates"}; + Configurable> bkgScoresPtMaxs{"bkgScoresPtMaxs", std::vector{0.1, 0.1, 0.1, 0.1, 0.1}, "pT-differential maximum bkg scores for charm candidates"}; Configurable> binsPtAssoc{"binsPtAssoc", std::vector{0.3, 1., 2., 50.}, "pT bin limits for associated particles"}; Configurable deltaEtaAbsMin{"deltaEtaAbsMin", 0.5, "min. pair delta eta"}; Configurable deltaEtaAbsMax{"deltaEtaAbsMax", 2., "max. pair delta eta"}; Configurable dcaXYTrackMax{"dcaXYTrackMax", 1., "max. track DCA XY"}; Configurable dcaZTrackMax{"dcaZTrackMax", 1., "max. track DCA Z"}; - Configurable bdtBkgScoreMax{"bdtBkgScoreMax", 1.01, "max. BDT score for background candidates"}; Configurable tpcCrossedRowsMin{"tpcCrossedRowsMin", 1, "min. TPC crossed rows"}; Configurable itsNClsMin{"itsNClsMin", 1, "min. ITS clusters"}; - Configurable downSamplePairsSE{"downSamplePairsSE", 1., "Fraction of SE pairs to keep"}; - Configurable ptMaxForDownSampleSE{"ptMaxForDownSampleSE", 10., "Maximum pt for the application of the downsampling factor"}; - Configurable centMaxForDownSampleSE{"centMaxForDownSampleSE", 10., "Maximum centrality for the application of the downsampling factor"}; - Configurable downSamplePairsME{"downSamplePairsME", 1., "Fraction of ME pairs to keep"}; - Configurable ptMaxForDownSampleME{"ptMaxForDownSampleME", 10., "Maximum pt for the application of the downsampling factor"}; - Configurable centMaxForDownSampleME{"centMaxForDownSampleME", 10., "Maximum centrality for the application of the downsampling factor"}; + Configurable downSamplePairs{"downSamplePairs", 1., "Fraction of pairs to keep"}; + Configurable ptMaxForDownSample{"ptMaxForDownSample", 10., "Maximum pt for the application of the downsampling factor"}; + Configurable centMaxForDownSample{"centMaxForDownSample", 10., "Maximum centrality for the application of the downsampling factor"}; SliceCache cache; int poolBins{0}; - using SameEvtPairsChHad = soa::Filtered>; - using SameEvtPairsHadHad = soa::Filtered>; - using AssocTracks = soa::Filtered>; - using TrigCharmCands = soa::Filtered>; + using SameEvtPairsChHad = soa::Filtered>; + using SameEvtPairsHadHad = soa::Filtered>; + using AssocTracks = soa::Filtered>; + using TrigCharmCands = soa::Join; Filter filterAssocTracks = (nabs(aod::hf_correl_charm_had_reduced::dcaXYAssoc) < dcaXYTrackMax) && (nabs(aod::hf_correl_charm_had_reduced::dcaZAssoc) < dcaZTrackMax) && (aod::hf_correl_charm_had_reduced::nTpcCrossedRowsAssoc > tpcCrossedRowsMin) && (aod::hf_correl_charm_had_reduced::itsNClsAssoc > itsNClsMin); Filter filterTrigTracks = (nabs(aod::hf_correl_charm_had_reduced::dcaXYTrig) < dcaXYTrackMax) && (nabs(aod::hf_correl_charm_had_reduced::dcaZTrig) < dcaZTrackMax) && (aod::hf_correl_charm_had_reduced::nTpcCrossedRowsTrig > tpcCrossedRowsMin) && (aod::hf_correl_charm_had_reduced::itsNClsTrig > itsNClsMin); Filter filterSameEvtPairs = (nabs(aod::hf_correl_charm_had_reduced::deltaEta) > deltaEtaAbsMin) && (nabs(aod::hf_correl_charm_had_reduced::deltaEta) < deltaEtaAbsMax); - Filter filterTrigCharmCands = (nabs(aod::hf_correl_charm_had_reduced::bdtScore0Trig) < bdtBkgScoreMax); Preslice assocTracksPerCol = aod::hf_correl_charm_had_reduced::hfcRedCorrCollId; Preslice trigCharmCandsPerCol = aod::hf_correl_charm_had_reduced::hfcRedCorrCollId; ConfigurableAxis zPoolBins{"zPoolBins", {VARIABLE_WIDTH, -10.0, -2.5, 2.5, 10.0}, "Z vertex position pools"}; ConfigurableAxis multPoolBins{"multPoolBins", {VARIABLE_WIDTH, 0., 900., 1800., 6000.}, "Event multiplicity pools (FT0M)"}; - ConfigurableAxis centPoolBins{"centPoolBins", {VARIABLE_WIDTH, 0., 10., 20., 30.}, "Event centrality pools"}; - ConfigurableAxis binsInvMass{"binsInvMass", {300, 1.6, 2.2}, ""}; + ConfigurableAxis centPoolBins{"centPoolBins", {VARIABLE_WIDTH, 0., 10., 20., 30., 40., 50., 60., 70., 80., 90., 100}, "Event centrality pools"}; + ConfigurableAxis binsInvMass{"binsInvMass", {300, 1.6, 2.2}, "Invariant mass bins"}; ConfigurableAxis binsMultFT0M{"binsMultFT0M", {100, 0., 10000.}, "Multiplicity as FT0M signal amplitude"}; ConfigurableAxis binsCent{"binsCent", {100, 0., 100.}, "Centrality bins"}; ConfigurableAxis binsPosZ{"binsPosZ", {100, -10., 10.}, "Primary vertex z coordinate"}; @@ -139,13 +138,13 @@ struct HfCorrelatorFlowCharmHadronsReduced { ConfigurableAxis binsPhi{"binsPhi", {64, -o2::constants::math::PIHalf, 3. * o2::constants::math::PIHalf}, "Phi bins"}; ConfigurableAxis binsDeltaEta{"binsDeltaEta", {100, -2., 2.}, "Delta Eta bins"}; ConfigurableAxis binsDeltaPhi{"binsDeltaPhi", {64, -3., 3.}, "Delta Phi bins"}; - ConfigurableAxis binsMlOne{"binsMlOne", {100, 0., 1.}, ""}; - ConfigurableAxis binsMlTwo{"binsMlTwo", {100, 0., 1.}, ""}; + ConfigurableAxis binsMlOne{"binsMlOne", {100, 0., 1.}, "ML score index 1 bins"}; + ConfigurableAxis binsMlTwo{"binsMlTwo", {100, 0., 1.}, "ML score index 2 bins"}; HistogramRegistry registry{"registry", {}, OutputObjHandlingPolicy::AnalysisObject}; - ColumnBinningPolicy binPolicyPosZMult{{zPoolBins, multPoolBins}, true}; - ColumnBinningPolicy binPolicyPosZCent{{zPoolBins, centPoolBins}, true}; + BinningMultPosZ binPolicyPosZMult{{zPoolBins, multPoolBins}, true}; + BinningCentPosZ binPolicyPosZCent{{zPoolBins, centPoolBins}, true}; void init(InitContext&) { @@ -158,6 +157,9 @@ struct HfCorrelatorFlowCharmHadronsReduced { if (!fillSparses && !fillTables) { LOGP(fatal, "At least one of fillSparses or fillTables must be true!"); } + if (binsPtTrig.value.size() != (bkgScoresPtMaxs.value.size() + 1) ) { + LOGP(fatal, "The size of binsPtTrig must be the one of bkgScorePtMaxs plus one!"); + } if (doprocessSameEventCharmHadWCentMix || doprocessSameEventHadHadWCentMix || doprocessMixedEventCharmHadWCentMix || doprocessMixedEventHadHadWCentMix) { poolBins = (centPoolBins->size() - 1) * (zPoolBins->size() - 1); @@ -170,8 +172,6 @@ struct HfCorrelatorFlowCharmHadronsReduced { const AxisSpec axisMultFT0M = {binsMultFT0M, "MultiplicityFT0M"}; const AxisSpec axisPosZ = {binsPosZ, "PosZ"}; const AxisSpec axisPoolBin = {poolBins, 0., static_cast(poolBins), "PoolBin"}; - const AxisSpec axisEta = {binsEta, "#it{#eta}"}; - const AxisSpec axisPhi = {binsPhi, "#it{#varphi}"}; const AxisSpec axisDeltaEta = {binsDeltaEta, "#Delta#it{#eta}"}; const AxisSpec axisDeltaPhi = {binsDeltaPhi, "#Delta#it{#varphi}"}; const AxisSpec axisPtTrig = {(std::vector)binsPtTrig, "#it{p}_{T} Trig (GeV/#it{c})"}; @@ -202,7 +202,7 @@ struct HfCorrelatorFlowCharmHadronsReduced { } else if (doprocessMixedEventHadHadWCentMix || doprocessMixedEventHadHadWMultMix) { registry.add("hSparseCorrelationsMEHadHad", "THn for ME Had-Had correlations", HistType::kTHnSparseF, axes); } else { - axes.insert(axes.end(), {axisMlOne, axisMlTwo, axisInvMass}); + axes.insert(axes.end(), {axisInvMass, axisMlOne, axisMlTwo}); if (doprocessSameEventCharmHadWCentMix || doprocessSameEventCharmHadWMultMix) { registry.add("hSparseCorrelationsSECharmHad", "THn for SE Charm-Had correlations", HistType::kTHnSparseF, axes); } else if (doprocessMixedEventCharmHadWCentMix || doprocessMixedEventCharmHadWMultMix) { @@ -219,7 +219,7 @@ struct HfCorrelatorFlowCharmHadronsReduced { int getPoolBin(const TColl& collision, const TBinningType& binPolicy) { int poolBin{0}; - if constexpr (std::is_same_v) { + if constexpr (std::is_same_v) { poolBin = binPolicy.getBin(std::make_tuple(collision.posZ(), collision.centrality())); if constexpr (isMixedEvent) { registry.fill(HIST("hCentPoolBinME"), collision.centrality(), poolBin); @@ -228,7 +228,7 @@ struct HfCorrelatorFlowCharmHadronsReduced { registry.fill(HIST("hCentPoolBinSE"), collision.centrality(), poolBin); registry.fill(HIST("hZVtxPoolBinSE"), collision.posZ(), poolBin); } - } else if constexpr (std::is_same_v) { + } else if constexpr (std::is_same_v) { poolBin = binPolicy.getBin(std::make_tuple(collision.posZ(), collision.multiplicity())); if constexpr (isMixedEvent) { registry.fill(HIST("hMultFT0MPoolBinME"), collision.multiplicity(), poolBin); @@ -241,6 +241,20 @@ struct HfCorrelatorFlowCharmHadronsReduced { return poolBin; } + /// Apply pT-differential ML BDT bkg score cut + /// \param ptTrig is the pT of the charm candidate + template + bool applyMlBkgScoreCut(TCand const& cand, + double ptTrig) + { + for (size_t iPt = 0; iPt < binsPtTrig.value.size()-1; iPt++) { + if (ptTrig >= binsPtTrig.value[iPt] && ptTrig < binsPtTrig.value[iPt + 1]) { + return cand.bdtScore0Trig() < bkgScoresPtMaxs.value[iPt]; + } + } + return false; + } + /// Save info for Same Event pairs /// \param collisions are the selected collisions /// \param trigCands are the selected trigger candidates @@ -252,9 +266,14 @@ struct HfCorrelatorFlowCharmHadronsReduced { { auto collision = pair.template hfcRedCorrColl_as(); double ptTrig = pair.ptTrig(); - if (downSamplePairsSE < 1.) { + if constexpr (requires { pair.bdtScore0Trig(); }) { // ML selection on bkg score for Charm-Had case + if (!applyMlBkgScoreCut(pair, ptTrig)) { + return; + } + } + if (downSamplePairs < 1.) { float pseudoRndm = ptTrig * 1000. - static_cast(ptTrig * 1000); - if (ptTrig < ptMaxForDownSampleSE && collision.centrality() < centMaxForDownSampleSE && pseudoRndm >= downSamplePairsSE) { + if (ptTrig < ptMaxForDownSample && collision.centrality() < centMaxForDownSample && pseudoRndm >= downSamplePairs) { return; } } @@ -262,12 +281,20 @@ struct HfCorrelatorFlowCharmHadronsReduced { registry.fill(HIST("hPoolBinTrigSE"), poolBin); registry.fill(HIST("hPoolBinAssocSE"), poolBin); if constexpr (fillTables) { - rowPairSE(poolBin, ptTrig, pair.ptAssoc(), pair.deltaEta(), pair.deltaPhi()); + if constexpr (requires { pair.bdtScore0Trig(); }) { // Separate Charm-Had and Had-Had cases + rowPairSECharmHads(poolBin, ptTrig, pair.ptAssoc(), pair.deltaEta(), pair.deltaPhi(), + pair.invMassTrig(), pair.bdtScore0Trig(), pair.bdtScore1Trig(), + pair.nTpcCrossedRowsAssoc(), pair.itsClsMapAssoc(), pair.itsNClsAssoc(), pair.dcaXYAssoc(), pair.dcaZAssoc()); + } else { + rowPairSEHadHads(poolBin, ptTrig, pair.ptAssoc(), pair.deltaEta(), pair.deltaPhi(), + pair.nTpcCrossedRowsTrig(), pair.itsClsMapTrig(), pair.itsNClsTrig(), pair.dcaXYTrig(), pair.dcaZTrig(), + pair.nTpcCrossedRowsAssoc(), pair.itsClsMapAssoc(), pair.itsNClsAssoc(), pair.dcaXYAssoc(), pair.dcaZAssoc()); + } } if constexpr (fillSparses) { if constexpr (requires { pair.bdtScore0Trig(); }) { // Separate Charm-Had and Had-Had cases registry.fill(HIST("hSparseCorrelationsSECharmHad"), poolBin, ptTrig, pair.ptAssoc(), pair.deltaEta(), - pair.deltaPhi(), pair.bdtScore0Trig(), pair.bdtScore1Trig(), pair.invMassTrig()); + pair.deltaPhi(), pair.invMassTrig(), pair.bdtScore0Trig(), pair.bdtScore1Trig()); } else { registry.fill(HIST("hSparseCorrelationsSEHadHad"), poolBin, ptTrig, pair.ptAssoc(), pair.deltaEta(), pair.deltaPhi()); } @@ -276,19 +303,13 @@ struct HfCorrelatorFlowCharmHadronsReduced { /// Save info for Mixed Event pairs /// \param collisions are the selected collisions - /// \param trigCands are the selected trigger candidates - /// \param assocTracks are the selected associated tracks + /// \param pairs are the mixed event pairs of trigger candidates and associated tracks /// \param binPolicy is the binning policy for the correlation - template - void fillMixedEvent(TColl const& collisions, - TTrigCands const& trigCands, - TAssocTracks const& assocTracks, + template + void fillMixedEvent(TPairs const& pairs, TBinningType binPolicy) { - auto pairsTuple = std::make_tuple(trigCands, assocTracks); - Pair pairData{binPolicy, numberEventsMixed, -1, collisions, pairsTuple, &cache}; - - for (const auto& [trigColl, trigCands, assocColl, assocTracks] : pairData) { + for (const auto& [trigColl, trigCands, assocColl, assocTracks] : pairs) { if (trigCands.size() == 0 || assocTracks.size() == 0) { continue; } @@ -308,22 +329,35 @@ struct HfCorrelatorFlowCharmHadronsReduced { continue; } double ptTrig = getPt(trigCand); + if constexpr (requires { trigCand.bdtScore0Trig(); }) { // ML selection on bkg score for Charm-Had case + if (!applyMlBkgScoreCut(trigCand, ptTrig)) { + continue; + } + } double ptAssoc = getPt(assocTrack); - if (downSamplePairsME < 1.) { + if (downSamplePairs < 1.) { float pseudoRndm = ptAssoc * 1000. - static_cast(ptAssoc * 1000); - if (ptTrig < ptMaxForDownSampleME && trigColl.centrality() < centMaxForDownSampleME && - assocColl.centrality() < centMaxForDownSampleME && pseudoRndm >= downSamplePairsME) { + if (ptTrig < ptMaxForDownSample && trigColl.centrality() < centMaxForDownSample && + assocColl.centrality() < centMaxForDownSample && pseudoRndm >= downSamplePairs) { continue; } } - double deltaPhi = getPhi(assocTrack) - getPhi(trigCand); + double deltaPhi = RecoDecay::constrainAngle(getPhi(assocTrack) - getPhi(trigCand), -o2::constants::math::PIHalf); if constexpr (fillTables) { - rowPairME(poolBinTrig, ptTrig, ptAssoc, deltaEta, deltaPhi); + if constexpr (requires { trigCand.bdtScore0Trig(); }) { // Separate Charm-Had and Had-Had cases + rowPairMECharmHads(poolBinTrig, ptTrig, ptAssoc, deltaEta, deltaPhi, + trigCand.invMassTrig(), trigCand.bdtScore0Trig(), trigCand.bdtScore1Trig(), + assocTrack.nTpcCrossedRowsAssoc(), assocTrack.itsClsMapAssoc(), assocTrack.itsNClsAssoc(), assocTrack.dcaXYAssoc(), assocTrack.dcaZAssoc()); + } else { + rowPairMEHadHads(poolBinTrig, ptTrig, ptAssoc, deltaEta, deltaPhi, + trigCand.nTpcCrossedRowsAssoc(), trigCand.itsClsMapAssoc(), trigCand.itsNClsAssoc(), trigCand.dcaXYAssoc(), trigCand.dcaZAssoc(), + assocTrack.nTpcCrossedRowsAssoc(), assocTrack.itsClsMapAssoc(), assocTrack.itsNClsAssoc(), assocTrack.dcaXYAssoc(), assocTrack.dcaZAssoc()); + } } if constexpr (fillSparses) { if constexpr (requires { trigCand.bdtScore0Trig(); }) { // Separate Charm-Had and Had-Had cases registry.fill(HIST("hSparseCorrelationsMECharmHad"), poolBinTrig, ptTrig, ptAssoc, deltaEta, - deltaPhi, trigCand.bdtScore0Trig(), trigCand.bdtScore1Trig(), trigCand.invMassTrig()); + deltaPhi, trigCand.invMassTrig(), trigCand.bdtScore0Trig(), trigCand.bdtScore1Trig()); } else { registry.fill(HIST("hSparseCorrelationsMEHadHad"), poolBinTrig, ptTrig, ptAssoc, deltaEta, deltaPhi); } @@ -388,12 +422,14 @@ struct HfCorrelatorFlowCharmHadronsReduced { TrigCharmCands const& candidates, AssocTracks const& tracks) { + auto pairsTuple = std::make_tuple(candidates, tracks); + Pair pairs{binPolicyPosZCent, numberEventsMixed, -1, collisions, pairsTuple, &cache}; if (fillSparses && fillTables) { - fillMixedEvent(collisions, candidates, tracks, binPolicyPosZCent); + fillMixedEvent(pairs, binPolicyPosZCent); } else if (fillSparses) { - fillMixedEvent(collisions, candidates, tracks, binPolicyPosZCent); + fillMixedEvent(pairs, binPolicyPosZCent); } else if (fillTables) { - fillMixedEvent(collisions, candidates, tracks, binPolicyPosZCent); + fillMixedEvent(pairs, binPolicyPosZCent); } } PROCESS_SWITCH(HfCorrelatorFlowCharmHadronsReduced, processMixedEventCharmHadWCentMix, "Process Mixed Event for Charm-Had with centrality pools", false); @@ -402,12 +438,14 @@ struct HfCorrelatorFlowCharmHadronsReduced { TrigCharmCands const& candidates, AssocTracks const& tracks) { + auto pairsTuple = std::make_tuple(candidates, tracks); + Pair pairs{binPolicyPosZMult, numberEventsMixed, -1, collisions, pairsTuple, &cache}; if (fillSparses && fillTables) { - fillMixedEvent(collisions, candidates, tracks, binPolicyPosZMult); + fillMixedEvent(pairs, binPolicyPosZMult); } else if (fillSparses) { - fillMixedEvent(collisions, candidates, tracks, binPolicyPosZMult); + fillMixedEvent(pairs, binPolicyPosZMult); } else if (fillTables) { - fillMixedEvent(collisions, candidates, tracks, binPolicyPosZMult); + fillMixedEvent(pairs, binPolicyPosZMult); } } PROCESS_SWITCH(HfCorrelatorFlowCharmHadronsReduced, processMixedEventCharmHadWMultMix, "Process Mixed Event for Charm-Had with multiplicity pools", false); @@ -415,12 +453,14 @@ struct HfCorrelatorFlowCharmHadronsReduced { void processMixedEventHadHadWCentMix(aod::HfcRedCorrColls const& collisions, AssocTracks const& tracks) { + auto tracksTuple = std::make_tuple(tracks); + SameKindPair pairs{binPolicyPosZCent, numberEventsMixed, -1, collisions, tracksTuple, &cache}; if (fillSparses && fillTables) { - fillMixedEvent(collisions, tracks, tracks, binPolicyPosZCent); + fillMixedEvent(pairs, binPolicyPosZCent); } else if (fillSparses) { - fillMixedEvent(collisions, tracks, tracks, binPolicyPosZCent); + fillMixedEvent(pairs, binPolicyPosZCent); } else if (fillTables) { - fillMixedEvent(collisions, tracks, tracks, binPolicyPosZCent); + fillMixedEvent(pairs, binPolicyPosZCent); } } PROCESS_SWITCH(HfCorrelatorFlowCharmHadronsReduced, processMixedEventHadHadWCentMix, "Process Mixed Event for Had-Had with centrality pools", false); @@ -428,12 +468,14 @@ struct HfCorrelatorFlowCharmHadronsReduced { void processMixedEventHadHadWMultMix(aod::HfcRedCorrColls const& collisions, AssocTracks const& tracks) { + auto tracksTuple = std::make_tuple(tracks); + SameKindPair pairs{binPolicyPosZMult, numberEventsMixed, -1, collisions, tracksTuple, &cache}; if (fillSparses && fillTables) { - fillMixedEvent(collisions, tracks, tracks, binPolicyPosZMult); + fillMixedEvent(pairs, binPolicyPosZMult); } else if (fillSparses) { - fillMixedEvent(collisions, tracks, tracks, binPolicyPosZMult); + fillMixedEvent(pairs, binPolicyPosZMult); } else if (fillTables) { - fillMixedEvent(collisions, tracks, tracks, binPolicyPosZMult); + fillMixedEvent(pairs, binPolicyPosZMult); } } PROCESS_SWITCH(HfCorrelatorFlowCharmHadronsReduced, processMixedEventHadHadWMultMix, "Process Mixed Event for Had-Had with multiplicity pools", false); diff --git a/PWGHF/HFC/TableProducer/derivedDataCreatorCorrelationsReduced.cxx b/PWGHF/HFC/TableProducer/derivedDataCreatorCorrelationsReduced.cxx index 69061a2d102..2ab4282b371 100644 --- a/PWGHF/HFC/TableProducer/derivedDataCreatorCorrelationsReduced.cxx +++ b/PWGHF/HFC/TableProducer/derivedDataCreatorCorrelationsReduced.cxx @@ -62,13 +62,13 @@ enum CandType { /// Code to select collisions with at least one Ds meson struct HfDerivedDataCreatorCorrelationsReduced { - Produces rowCollisions; // Table with reduced collision info - Produces rowSEPairs; // Table with same-event pairs info - Produces rowAssocTrks; // Table with associated track info - Produces rowAssocTrkSels; // Table with associated track selection info - Produces rowTrigs; // Table with charm candidate info - Produces rowTrigCharms; // Table with charm trigger candidate info - Produces rowTrigHads; // Table with hadron trigger candidate info + Produces rowCollisions; // Table with reduced collision info + Produces rowSEPairs; // Table with same-event pairs info + Produces rowAssocBases; // Table with associated candidate base info + Produces rowAssocTrkSels; // Table with associated track selection info + Produces rowTrigBases; // Table with base trigger candidate info + Produces rowTrigCharms; // Table with charm trigger candidate selection info + Produces rowTrigHads; // Table with hadron trigger candidate selection info Configurable centEstimator{"centEstimator", 2, "Centrality estimation (FT0A: 1, FT0C: 2, FT0M: 3, FV0A: 4)"}; Configurable selectionFlag{"selectionFlag", 15, "Selection Flag for hadron (ML score tables are required to run the task)"}; @@ -76,12 +76,12 @@ struct HfDerivedDataCreatorCorrelationsReduced { Configurable ccdbUrl{"ccdbUrl", "http://alice-ccdb.cern.ch", "url of the ccdb repository"}; Configurable> classMl{"classMl", {0, 2}, "Indexes of BDT scores to be stored. Two indexes max."}; Configurable yCandMax{"yCandMax", 0.8, "max. cand. rapidity"}; - Configurable ptCandMin{"ptCandMin", 1., "min. cand. pT"}; + Configurable ptCandMin{"ptCandMin", 0., "min. cand. pT"}; Configurable ptCandMax{"ptCandMax", 24., "max. cand. pT"}; Configurable tpcNClsCrossedRowsMin{"tpcNClsCrossedRowsMin", 70, "min. TPC crossed rows for associated tracks"}; Configurable etaTrkMax{"etaTrkMax", 1., "max. track eta"}; - Configurable ptTrkMin{"ptTrkMin", 0.5, "min. track pT"}; - Configurable ptTrkMax{"ptTrkMax", 5., "max. track pT"}; + Configurable ptTrkMin{"ptTrkMin", 0.2, "min. track pT"}; + Configurable ptTrkMax{"ptTrkMax", 3., "max. track pT"}; Configurable dcaXYTrkMax{"dcaXYTrkMax", 1., "max. track DCA XY"}; Configurable dcaZTrkMax{"dcaZTrkMax", 1., "max. track DCA Z"}; Configurable deltaEtaAbsMin{"deltaEtaAbsMin", 0.5, "min. pair delta eta"}; @@ -89,8 +89,8 @@ struct HfDerivedDataCreatorCorrelationsReduced { Configurable downSampleTrksFactor{"downSampleTrksFactor", 1., "Fraction of associated tracks to keep"}; Configurable ptMaxForDownSample{"ptMaxForDownSample", 10., "Maximum pt for the application of the downsampling factor"}; Configurable centMaxForDownSample{"centMaxForDownSample", 101., "Maximum centrality for the application of the downsampling factor"}; - Configurable> binsPtTrig{"binsPtTrig", std::vector{1., 3., 5., 8., 16., 36.}, "pT bin limits for trigger candidates"}; - Configurable> binsPtAssoc{"binsPtAssoc", std::vector{0.3, 1., 2., 50.}, "pT bin limits for associated particles"}; + Configurable> binsPtTrig{"binsPtTrig", std::vector{0., 1., 2., 3., 5., 8., 12., 24., 36.}, "pT bin limits for trigger candidates"}; + Configurable> binsPtAssoc{"binsPtAssoc", std::vector{0.2, 1., 2., 50.}, "pT bin limits for associated particles"}; HfHelper hfHelper; HfEventSelection hfEvSel; // event selection and monitoring @@ -103,7 +103,7 @@ struct HfDerivedDataCreatorCorrelationsReduced { using CandDsData = soa::Filtered>; using CandDplusData = soa::Filtered>; using CandD0Data = soa::Filtered>; - using TrksData = soa::Filtered>; + using TracksData = soa::Filtered>; Filter filterSelectDsCandidates = aod::hf_sel_candidate_ds::isSelDsToKKPi >= selectionFlag || aod::hf_sel_candidate_ds::isSelDsToPiKK >= selectionFlag; Filter filterSelectDplusCandidates = aod::hf_sel_candidate_dplus::isSelDplusToPiKPi >= selectionFlag; @@ -113,7 +113,7 @@ struct HfDerivedDataCreatorCorrelationsReduced { Preslice candsDsPerColl = aod::hf_cand::collisionId; Preslice candsDplusPerColl = aod::hf_cand::collisionId; Preslice candsD0PerColl = aod::hf_cand::collisionId; - Preslice trackIndicesPerColl = aod::track::collisionId; + Preslice trackIndicesPerColl = aod::track::collisionId; Partition selectedDsToKKPi = aod::hf_sel_candidate_ds::isSelDsToKKPi >= selectionFlag; Partition selectedDsToPiKK = aod::hf_sel_candidate_ds::isSelDsToPiKK >= selectionFlag; @@ -275,16 +275,21 @@ struct HfDerivedDataCreatorCorrelationsReduced { if (!cand.isGlobalTrackWoDCA() || cand.tpcNClsCrossedRows() < tpcNClsCrossedRowsMin) { return false; } - if (trackGlobalIndex == cand.globalIndex()) { - return false; // skip self-correlation for hadron-hadron + if (trackGlobalIndex <= cand.globalIndex()) { + return false; // skip self-correlation and avoid pair duplication for hadron-hadron } } else { // Remove Daughter-Cand pairs for charm-hadron correlations if constexpr ((requires { cand.prong2Id(); })) { // Check 3-prong - return (trackGlobalIndex != cand.prong0Id() && trackGlobalIndex != cand.prong1Id() && trackGlobalIndex != cand.prong2Id()); + if (trackGlobalIndex == cand.prong0Id() || trackGlobalIndex == cand.prong1Id() || trackGlobalIndex == cand.prong2Id()) { + return false; + } } else { // Check 2-prong - return (trackGlobalIndex != cand.prong0Id() && trackGlobalIndex != cand.prong1Id()); + if (trackGlobalIndex == cand.prong0Id() || trackGlobalIndex == cand.prong1Id()) { + return false; + } } } + return true; } /// Fill histograms and tables for same-event correlations @@ -297,8 +302,9 @@ struct HfDerivedDataCreatorCorrelationsReduced { const float collCentrality) { for (const auto& trigCand : trigCands) { - registry.fill(HIST("hPhiVsPtTrig"), RecoDecay::constrainAngle(trigCand.phi(), -o2::constants::math::PIHalf), trigCand.pt()); - registry.fill(HIST("hEtaVsPtTrig"), trigCand.eta(), trigCand.pt()); + double trigCandPt = trigCand.pt(); + registry.fill(HIST("hPhiVsPtTrig"), RecoDecay::constrainAngle(trigCand.phi(), -o2::constants::math::PIHalf), trigCandPt); + registry.fill(HIST("hEtaVsPtTrig"), trigCand.eta(), trigCandPt); for (const auto& assTrk : assTrks) { if (!acceptSameEvtPair(assTrk, trigCand)) { continue; @@ -310,12 +316,12 @@ struct HfDerivedDataCreatorCorrelationsReduced { continue; } } - registry.fill(HIST("hPhiVsPtTrigAssoc"), RecoDecay::constrainAngle(assTrk.phi(), -o2::constants::math::PIHalf), trigCand.pt(), assTrkPt); - registry.fill(HIST("hEtaVsPtAssoc"), assTrk.eta(), trigCand.pt(), assTrkPt); + registry.fill(HIST("hPhiVsPtTrigAssoc"), RecoDecay::constrainAngle(assTrk.phi(), -o2::constants::math::PIHalf), trigCandPt, assTrkPt); + registry.fill(HIST("hEtaVsPtAssoc"), assTrk.eta(), trigCandPt, assTrkPt); double deltaEta = assTrk.eta() - trigCand.eta(); double deltaPhi = RecoDecay::constrainAngle(assTrk.phi() - trigCand.phi(), -o2::constants::math::PIHalf); - rowSEPairs(rowCollisions.lastIndex(), trigCand.pt(), assTrkPt, deltaEta, deltaPhi); + rowSEPairs(rowCollisions.lastIndex(), trigCandPt, assTrkPt, deltaEta, deltaPhi); rowAssocTrkSels(assTrk.tpcNClsCrossedRows(), assTrk.itsClusterMap(), assTrk.itsNCls(), assTrk.dcaXY(), assTrk.dcaZ()); if constexpr (candType == CandType::Hadron) { rowTrigHads(trigCand.tpcNClsCrossedRows(), trigCand.itsClusterMap(), trigCand.itsNCls(), trigCand.dcaXY(), trigCand.dcaZ()); @@ -337,7 +343,7 @@ struct HfDerivedDataCreatorCorrelationsReduced { registry.fill(HIST("hEtaVsPtTrig"), trigCand.eta(), trigCand.pt()); std::array outputMl = getCandMlScores(trigCand); - rowTrigs(rowCollisions.lastIndex(), trigCand.phi(), trigCand.eta(), trigCand.pt()); + rowTrigBases(rowCollisions.lastIndex(), trigCand.phi(), trigCand.eta(), trigCand.pt()); rowTrigCharms(getCandMass(trigCand), outputMl[0], outputMl[1]); } } @@ -364,7 +370,7 @@ struct HfDerivedDataCreatorCorrelationsReduced { first = false; registry.fill(HIST("hPhiVsPtAssoc"), RecoDecay::constrainAngle(assTrk.phi(), -o2::constants::math::PIHalf), assTrkPt); registry.fill(HIST("hEtaVsPtAssoc"), assTrk.eta(), assTrkPt); - rowAssocTrks(rowCollisions.lastIndex(), assTrk.phi(), assTrk.eta(), assTrkPt); + rowAssocBases(rowCollisions.lastIndex(), assTrk.phi(), assTrk.eta(), assTrkPt); rowAssocTrkSels(assTrk.tpcNClsCrossedRows(), assTrk.itsClusterMap(), assTrk.itsNCls(), assTrk.dcaXY(), assTrk.dcaZ()); } } @@ -372,7 +378,7 @@ struct HfDerivedDataCreatorCorrelationsReduced { // Dplus with ML selections void processDplusSameEvent(CollsWithCentMult::iterator const& coll, CandDplusData const& candsDplus, - TrksData const& tracks) + TracksData const& tracks) { if (forceCharmInCollision && candsDplus.size() < 1) { return; @@ -389,7 +395,7 @@ struct HfDerivedDataCreatorCorrelationsReduced { // Dplus with ML selections void processDplusMixedEvent(CollsWithCentMult::iterator const& coll, CandDplusData const& candsDplus, - TrksData const& tracks) + TracksData const& tracks) { if (forceCharmInCollision && candsDplus.size() < 1) { return; @@ -406,7 +412,7 @@ struct HfDerivedDataCreatorCorrelationsReduced { // Ds with ML selections void processDsSameEvent(CollsWithCentMult::iterator const& coll, - TrksData const& tracks, + TracksData const& tracks, CandDsData const&) { auto candsDsToPiKK = selectedDsToPiKK->sliceByCached(aod::hf_cand::collisionId, coll.globalIndex(), cache); @@ -426,7 +432,7 @@ struct HfDerivedDataCreatorCorrelationsReduced { // Ds with ML selections void processDsMixedEvent(CollsWithCentMult::iterator const& coll, - TrksData const& tracks, + TracksData const& tracks, CandDsData const&) { auto candsDsToPiKK = selectedDsToPiKK->sliceByCached(aod::hf_cand::collisionId, coll.globalIndex(), cache); @@ -447,7 +453,7 @@ struct HfDerivedDataCreatorCorrelationsReduced { // D0 with ML selections void processD0SameEvent(CollsWithCentMult::iterator const& coll, - TrksData const& tracks, + TracksData const& tracks, CandD0Data const&) { auto candsD0ToPiK = selectedD0ToPiK->sliceByCached(aod::hf_cand::collisionId, coll.globalIndex(), cache); @@ -467,7 +473,7 @@ struct HfDerivedDataCreatorCorrelationsReduced { // D0 with ML selections void processD0MixedEvent(CollsWithCentMult::iterator const& coll, - TrksData const& tracks, + TracksData const& tracks, CandD0Data const&) { auto candsD0ToPiK = selectedD0ToPiK->sliceByCached(aod::hf_cand::collisionId, coll.globalIndex(), cache); @@ -488,7 +494,7 @@ struct HfDerivedDataCreatorCorrelationsReduced { // Hadron Hadron Same Event void processHadronHadronSameEvent(CollsWithCentMult::iterator const& coll, - TrksData const& tracks) + TracksData const& tracks) { float cent{-1.}, mult{-1.}; if (!checkCollision(coll, cent, mult)) { @@ -501,7 +507,7 @@ struct HfDerivedDataCreatorCorrelationsReduced { // Hadron Hadron Mixed Event void processHadronHadronMixedEvent(CollsWithCentMult::iterator const& coll, - TrksData const& tracks) + TracksData const& tracks) { float cent{-1.}, mult{-1.}; if (!checkCollision(coll, cent, mult)) { From 6ead8e93355f4043ca0cdd5547dd5c19b6ab8537 Mon Sep 17 00:00:00 2001 From: ALICE Action Bot Date: Thu, 18 Sep 2025 16:04:38 +0000 Subject: [PATCH 12/15] Please consider the following formatting changes --- .../DataModel/DerivedDataCorrelationTables.h | 36 +++++++++---------- .../correlatorFlowCharmHadronsReduced.cxx | 14 ++++---- .../derivedDataCreatorCorrelationsReduced.cxx | 14 ++++---- 3 files changed, 32 insertions(+), 32 deletions(-) diff --git a/PWGHF/HFC/DataModel/DerivedDataCorrelationTables.h b/PWGHF/HFC/DataModel/DerivedDataCorrelationTables.h index 28bd5b0e213..d119d416f86 100644 --- a/PWGHF/HFC/DataModel/DerivedDataCorrelationTables.h +++ b/PWGHF/HFC/DataModel/DerivedDataCorrelationTables.h @@ -107,28 +107,28 @@ DECLARE_SOA_TABLE(AssocTrackSels, "AOD", "ASSOCTRACKSEL", //! Table with associa namespace hf_correl_charm_had_reduced { // Correlation columns -DECLARE_SOA_INDEX_COLUMN(HfcRedCorrColl, hfcRedCorrColl); //! ReducedCollision index -DECLARE_SOA_COLUMN(DeltaPhi, deltaPhi, float); //! DeltaPhi between charm hadron and Hadrons -DECLARE_SOA_COLUMN(DeltaEta, deltaEta, float); //! DeltaEta between charm hadron and Hadrons -DECLARE_SOA_COLUMN(PoolBin, poolBin, int); //! Pool Bin for the MixedEvent +DECLARE_SOA_INDEX_COLUMN(HfcRedCorrColl, hfcRedCorrColl); //! ReducedCollision index +DECLARE_SOA_COLUMN(DeltaPhi, deltaPhi, float); //! DeltaPhi between charm hadron and Hadrons +DECLARE_SOA_COLUMN(DeltaEta, deltaEta, float); //! DeltaEta between charm hadron and Hadrons +DECLARE_SOA_COLUMN(PoolBin, poolBin, int); //! Pool Bin for the MixedEvent // General trigger particle columns -DECLARE_SOA_COLUMN(PhiTrig, phiTrig, float); //! Phi of the trigger candidate -DECLARE_SOA_COLUMN(EtaTrig, etaTrig, float); //! Eta of the trigger candidate -DECLARE_SOA_COLUMN(PtTrig, ptTrig, float); //! Pt of the trigger candidate +DECLARE_SOA_COLUMN(PhiTrig, phiTrig, float); //! Phi of the trigger candidate +DECLARE_SOA_COLUMN(EtaTrig, etaTrig, float); //! Eta of the trigger candidate +DECLARE_SOA_COLUMN(PtTrig, ptTrig, float); //! Pt of the trigger candidate // Charm trigger particle selection columns -DECLARE_SOA_COLUMN(InvMassTrig, invMassTrig, float); //! Invariant mass of Charm trigger candidate -DECLARE_SOA_COLUMN(BdtScore0Trig, bdtScore0Trig, float); //! First BDT output score -DECLARE_SOA_COLUMN(BdtScore1Trig, bdtScore1Trig, float); //! Second BDT output score +DECLARE_SOA_COLUMN(InvMassTrig, invMassTrig, float); //! Invariant mass of Charm trigger candidate +DECLARE_SOA_COLUMN(BdtScore0Trig, bdtScore0Trig, float); //! First BDT output score +DECLARE_SOA_COLUMN(BdtScore1Trig, bdtScore1Trig, float); //! Second BDT output score // Hadron trigger particle selection columns -DECLARE_SOA_COLUMN(NTpcCrossedRowsTrig, nTpcCrossedRowsTrig, int); //! Number of crossed TPC Rows -DECLARE_SOA_COLUMN(ItsClsMapTrig, itsClsMapTrig, int); //! ITS cluster map, one bit per a layer, starting from the innermost -DECLARE_SOA_COLUMN(ItsNClsTrig, itsNClsTrig, int); //! Number of ITS clusters -DECLARE_SOA_COLUMN(DcaXYTrig, dcaXYTrig, float); //! Impact parameter in XY of the track to the primary vertex -DECLARE_SOA_COLUMN(DcaZTrig, dcaZTrig, float); //! Impact parameter in Z of the track to the primary vertex +DECLARE_SOA_COLUMN(NTpcCrossedRowsTrig, nTpcCrossedRowsTrig, int); //! Number of crossed TPC Rows +DECLARE_SOA_COLUMN(ItsClsMapTrig, itsClsMapTrig, int); //! ITS cluster map, one bit per a layer, starting from the innermost +DECLARE_SOA_COLUMN(ItsNClsTrig, itsNClsTrig, int); //! Number of ITS clusters +DECLARE_SOA_COLUMN(DcaXYTrig, dcaXYTrig, float); //! Impact parameter in XY of the track to the primary vertex +DECLARE_SOA_COLUMN(DcaZTrig, dcaZTrig, float); //! Impact parameter in Z of the track to the primary vertex // General associated particle columns -DECLARE_SOA_COLUMN(EtaAssoc, etaAssoc, float); //! Eta of the associated candidate -DECLARE_SOA_COLUMN(PhiAssoc, phiAssoc, float); //! Phi of the associated candidate -DECLARE_SOA_COLUMN(PtAssoc, ptAssoc, float); //! Pt of the associated candidate +DECLARE_SOA_COLUMN(EtaAssoc, etaAssoc, float); //! Eta of the associated candidate +DECLARE_SOA_COLUMN(PhiAssoc, phiAssoc, float); //! Phi of the associated candidate +DECLARE_SOA_COLUMN(PtAssoc, ptAssoc, float); //! Pt of the associated candidate // Hadron associated particle selection columns DECLARE_SOA_COLUMN(NTpcCrossedRowsAssoc, nTpcCrossedRowsAssoc, int); //! Number of crossed TPC Rows DECLARE_SOA_COLUMN(ItsClsMapAssoc, itsClsMapAssoc, int); //! ITS cluster map, one bit per a layer, starting from the innermost diff --git a/PWGHF/HFC/TableProducer/correlatorFlowCharmHadronsReduced.cxx b/PWGHF/HFC/TableProducer/correlatorFlowCharmHadronsReduced.cxx index 6bb2daf27aa..2028c569ca2 100644 --- a/PWGHF/HFC/TableProducer/correlatorFlowCharmHadronsReduced.cxx +++ b/PWGHF/HFC/TableProducer/correlatorFlowCharmHadronsReduced.cxx @@ -90,10 +90,10 @@ double getPhi(const TTrack& track) } struct HfCorrelatorFlowCharmHadronsReduced { - Produces rowPairSECharmHads; //! Correlation pairs information Same Event - Produces rowPairMECharmHads; //! Correlation pairs information Mixed Event - Produces rowPairSEHadHads; //! Correlation pairs information Same Event - Produces rowPairMEHadHads; //! Correlation pairs information Mixed Event + Produces rowPairSECharmHads; //! Correlation pairs information Same Event + Produces rowPairMECharmHads; //! Correlation pairs information Mixed Event + Produces rowPairSEHadHads; //! Correlation pairs information Same Event + Produces rowPairMEHadHads; //! Correlation pairs information Mixed Event Configurable fillSparses{"fillSparses", true, "Fill sparse histograms"}; Configurable fillTables{"fillTables", false, "Fill tables"}; @@ -157,7 +157,7 @@ struct HfCorrelatorFlowCharmHadronsReduced { if (!fillSparses && !fillTables) { LOGP(fatal, "At least one of fillSparses or fillTables must be true!"); } - if (binsPtTrig.value.size() != (bkgScoresPtMaxs.value.size() + 1) ) { + if (binsPtTrig.value.size() != (bkgScoresPtMaxs.value.size() + 1)) { LOGP(fatal, "The size of binsPtTrig must be the one of bkgScorePtMaxs plus one!"); } @@ -244,10 +244,10 @@ struct HfCorrelatorFlowCharmHadronsReduced { /// Apply pT-differential ML BDT bkg score cut /// \param ptTrig is the pT of the charm candidate template - bool applyMlBkgScoreCut(TCand const& cand, + bool applyMlBkgScoreCut(TCand const& cand, double ptTrig) { - for (size_t iPt = 0; iPt < binsPtTrig.value.size()-1; iPt++) { + for (size_t iPt = 0; iPt < binsPtTrig.value.size() - 1; iPt++) { if (ptTrig >= binsPtTrig.value[iPt] && ptTrig < binsPtTrig.value[iPt + 1]) { return cand.bdtScore0Trig() < bkgScoresPtMaxs.value[iPt]; } diff --git a/PWGHF/HFC/TableProducer/derivedDataCreatorCorrelationsReduced.cxx b/PWGHF/HFC/TableProducer/derivedDataCreatorCorrelationsReduced.cxx index 2ab4282b371..87d86bb6f1c 100644 --- a/PWGHF/HFC/TableProducer/derivedDataCreatorCorrelationsReduced.cxx +++ b/PWGHF/HFC/TableProducer/derivedDataCreatorCorrelationsReduced.cxx @@ -62,13 +62,13 @@ enum CandType { /// Code to select collisions with at least one Ds meson struct HfDerivedDataCreatorCorrelationsReduced { - Produces rowCollisions; // Table with reduced collision info - Produces rowSEPairs; // Table with same-event pairs info - Produces rowAssocBases; // Table with associated candidate base info - Produces rowAssocTrkSels; // Table with associated track selection info - Produces rowTrigBases; // Table with base trigger candidate info - Produces rowTrigCharms; // Table with charm trigger candidate selection info - Produces rowTrigHads; // Table with hadron trigger candidate selection info + Produces rowCollisions; // Table with reduced collision info + Produces rowSEPairs; // Table with same-event pairs info + Produces rowAssocBases; // Table with associated candidate base info + Produces rowAssocTrkSels; // Table with associated track selection info + Produces rowTrigBases; // Table with base trigger candidate info + Produces rowTrigCharms; // Table with charm trigger candidate selection info + Produces rowTrigHads; // Table with hadron trigger candidate selection info Configurable centEstimator{"centEstimator", 2, "Centrality estimation (FT0A: 1, FT0C: 2, FT0M: 3, FV0A: 4)"}; Configurable selectionFlag{"selectionFlag", 15, "Selection Flag for hadron (ML score tables are required to run the task)"}; From b15caff557d6142e964395f483430f788b585dcc Mon Sep 17 00:00:00 2001 From: marcellocosti Date: Thu, 18 Sep 2025 18:53:15 +0200 Subject: [PATCH 13/15] Add table for collision properties --- PWGHF/HFC/DataModel/DerivedDataCorrelationTables.h | 5 +++++ .../TableProducer/correlatorFlowCharmHadronsReduced.cxx | 9 ++++++--- .../derivedDataCreatorCorrelationsReduced.cxx | 2 ++ 3 files changed, 13 insertions(+), 3 deletions(-) diff --git a/PWGHF/HFC/DataModel/DerivedDataCorrelationTables.h b/PWGHF/HFC/DataModel/DerivedDataCorrelationTables.h index d119d416f86..b0a9cf3e390 100644 --- a/PWGHF/HFC/DataModel/DerivedDataCorrelationTables.h +++ b/PWGHF/HFC/DataModel/DerivedDataCorrelationTables.h @@ -244,6 +244,11 @@ DECLARE_SOA_TABLE(HfcRedMEHadHads, "AOD", "HFCREDMEHADHAD", //! Correlation pair aod::hf_correl_charm_had_reduced::DcaXYAssoc, aod::hf_correl_charm_had_reduced::DcaZAssoc, soa::Marker<2>); + +DECLARE_SOA_TABLE(HfcRedCollInfos, "AOD", "HFCREDCOLLINFO", //! Table with collision info + aod::hf_collisions_reduced::Multiplicity, + aod::hf_collisions_reduced::NumPvContrib, + aod::hf_collisions_reduced::Centrality); } // namespace o2::aod #endif // PWGHF_HFC_DATAMODEL_DERIVEDDATACORRELATIONTABLES_H_ diff --git a/PWGHF/HFC/TableProducer/correlatorFlowCharmHadronsReduced.cxx b/PWGHF/HFC/TableProducer/correlatorFlowCharmHadronsReduced.cxx index 2028c569ca2..c2174f97994 100644 --- a/PWGHF/HFC/TableProducer/correlatorFlowCharmHadronsReduced.cxx +++ b/PWGHF/HFC/TableProducer/correlatorFlowCharmHadronsReduced.cxx @@ -94,6 +94,7 @@ struct HfCorrelatorFlowCharmHadronsReduced { Produces rowPairMECharmHads; //! Correlation pairs information Mixed Event Produces rowPairSEHadHads; //! Correlation pairs information Same Event Produces rowPairMEHadHads; //! Correlation pairs information Mixed Event + Produces rowCollInfos; //! Collision info Configurable fillSparses{"fillSparses", true, "Fill sparse histograms"}; Configurable fillTables{"fillTables", false, "Fill tables"}; @@ -244,7 +245,7 @@ struct HfCorrelatorFlowCharmHadronsReduced { /// Apply pT-differential ML BDT bkg score cut /// \param ptTrig is the pT of the charm candidate template - bool applyMlBkgScoreCut(TCand const& cand, + bool isSelBdtBkgScoreCut(TCand const& cand, double ptTrig) { for (size_t iPt = 0; iPt < binsPtTrig.value.size() - 1; iPt++) { @@ -267,7 +268,7 @@ struct HfCorrelatorFlowCharmHadronsReduced { auto collision = pair.template hfcRedCorrColl_as(); double ptTrig = pair.ptTrig(); if constexpr (requires { pair.bdtScore0Trig(); }) { // ML selection on bkg score for Charm-Had case - if (!applyMlBkgScoreCut(pair, ptTrig)) { + if (!isSelBdtBkgScoreCut(pair, ptTrig)) { return; } } @@ -290,6 +291,7 @@ struct HfCorrelatorFlowCharmHadronsReduced { pair.nTpcCrossedRowsTrig(), pair.itsClsMapTrig(), pair.itsNClsTrig(), pair.dcaXYTrig(), pair.dcaZTrig(), pair.nTpcCrossedRowsAssoc(), pair.itsClsMapAssoc(), pair.itsNClsAssoc(), pair.dcaXYAssoc(), pair.dcaZAssoc()); } + rowCollInfos(collision.multiplicity(), collision.numPvContrib(), collision.centrality()); } if constexpr (fillSparses) { if constexpr (requires { pair.bdtScore0Trig(); }) { // Separate Charm-Had and Had-Had cases @@ -330,7 +332,7 @@ struct HfCorrelatorFlowCharmHadronsReduced { } double ptTrig = getPt(trigCand); if constexpr (requires { trigCand.bdtScore0Trig(); }) { // ML selection on bkg score for Charm-Had case - if (!applyMlBkgScoreCut(trigCand, ptTrig)) { + if (!isSelBdtBkgScoreCut(trigCand, ptTrig)) { continue; } } @@ -353,6 +355,7 @@ struct HfCorrelatorFlowCharmHadronsReduced { trigCand.nTpcCrossedRowsAssoc(), trigCand.itsClsMapAssoc(), trigCand.itsNClsAssoc(), trigCand.dcaXYAssoc(), trigCand.dcaZAssoc(), assocTrack.nTpcCrossedRowsAssoc(), assocTrack.itsClsMapAssoc(), assocTrack.itsNClsAssoc(), assocTrack.dcaXYAssoc(), assocTrack.dcaZAssoc()); } + rowCollInfos(trigColl.multiplicity(), trigColl.numPvContrib(), trigColl.centrality()); } if constexpr (fillSparses) { if constexpr (requires { trigCand.bdtScore0Trig(); }) { // Separate Charm-Had and Had-Had cases diff --git a/PWGHF/HFC/TableProducer/derivedDataCreatorCorrelationsReduced.cxx b/PWGHF/HFC/TableProducer/derivedDataCreatorCorrelationsReduced.cxx index 87d86bb6f1c..61ef6bd3348 100644 --- a/PWGHF/HFC/TableProducer/derivedDataCreatorCorrelationsReduced.cxx +++ b/PWGHF/HFC/TableProducer/derivedDataCreatorCorrelationsReduced.cxx @@ -318,6 +318,8 @@ struct HfDerivedDataCreatorCorrelationsReduced { } registry.fill(HIST("hPhiVsPtTrigAssoc"), RecoDecay::constrainAngle(assTrk.phi(), -o2::constants::math::PIHalf), trigCandPt, assTrkPt); registry.fill(HIST("hEtaVsPtAssoc"), assTrk.eta(), trigCandPt, assTrkPt); + registry.fill(HIST("hPhiVsPtAssoc"), RecoDecay::constrainAngle(assTrk.phi(), -o2::constants::math::PIHalf), assTrkPt); + registry.fill(HIST("hEtaVsPtAssoc"), assTrk.eta(), assTrkPt); double deltaEta = assTrk.eta() - trigCand.eta(); double deltaPhi = RecoDecay::constrainAngle(assTrk.phi() - trigCand.phi(), -o2::constants::math::PIHalf); From 474634f02b1d8ab3cdec7f7aa06008afa11e87dd Mon Sep 17 00:00:00 2001 From: ALICE Action Bot Date: Thu, 18 Sep 2025 16:55:52 +0000 Subject: [PATCH 14/15] Please consider the following formatting changes --- PWGHF/HFC/TableProducer/correlatorFlowCharmHadronsReduced.cxx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/PWGHF/HFC/TableProducer/correlatorFlowCharmHadronsReduced.cxx b/PWGHF/HFC/TableProducer/correlatorFlowCharmHadronsReduced.cxx index c2174f97994..85df595a4b0 100644 --- a/PWGHF/HFC/TableProducer/correlatorFlowCharmHadronsReduced.cxx +++ b/PWGHF/HFC/TableProducer/correlatorFlowCharmHadronsReduced.cxx @@ -246,7 +246,7 @@ struct HfCorrelatorFlowCharmHadronsReduced { /// \param ptTrig is the pT of the charm candidate template bool isSelBdtBkgScoreCut(TCand const& cand, - double ptTrig) + double ptTrig) { for (size_t iPt = 0; iPt < binsPtTrig.value.size() - 1; iPt++) { if (ptTrig >= binsPtTrig.value[iPt] && ptTrig < binsPtTrig.value[iPt + 1]) { From 55925878e150f9a04186b23afdc4f5fd1b651125 Mon Sep 17 00:00:00 2001 From: marcellocosti Date: Wed, 24 Sep 2025 12:17:37 +0200 Subject: [PATCH 15/15] Pt differential DCA cut and Stefano comments --- .../derivedDataCreatorCorrelationsReduced.cxx | 44 ++++++++++++++++--- 1 file changed, 38 insertions(+), 6 deletions(-) diff --git a/PWGHF/HFC/TableProducer/derivedDataCreatorCorrelationsReduced.cxx b/PWGHF/HFC/TableProducer/derivedDataCreatorCorrelationsReduced.cxx index 61ef6bd3348..e46a1d27bca 100644 --- a/PWGHF/HFC/TableProducer/derivedDataCreatorCorrelationsReduced.cxx +++ b/PWGHF/HFC/TableProducer/derivedDataCreatorCorrelationsReduced.cxx @@ -84,6 +84,9 @@ struct HfDerivedDataCreatorCorrelationsReduced { Configurable ptTrkMax{"ptTrkMax", 3., "max. track pT"}; Configurable dcaXYTrkMax{"dcaXYTrkMax", 1., "max. track DCA XY"}; Configurable dcaZTrkMax{"dcaZTrkMax", 1., "max. track DCA Z"}; + Configurable usePtDiffDcaXYCut{"usePtDiffDcaXYCut", false, "Use pt-differential DCAxy cut for associated tracks"}; + Configurable dcaXYTrkNSigmaMax{"dcaXYTrkNSigmaMax", 7, "Cut on number of sigma deviations from expected DCA in the transverse direction"}; + Configurable dcaXYPtPrimTrkFunc{"dcaXYPtPrimTrkFunc", "(0.0026+0.005/(x^1.01))", "Functional form of pt-dependent DCAxy cut"}; Configurable deltaEtaAbsMin{"deltaEtaAbsMin", 0.5, "min. pair delta eta"}; Configurable deltaEtaAbsMax{"deltaEtaAbsMax", 2., "max. pair delta eta"}; Configurable downSampleTrksFactor{"downSampleTrksFactor", 1., "Fraction of associated tracks to keep"}; @@ -98,6 +101,7 @@ struct HfDerivedDataCreatorCorrelationsReduced { SliceCache cache; double massCharm{0.}; + TF1* funcDcaXYPtCutPrimTrk = nullptr; using CollsWithCentMult = soa::Join; using CandDsData = soa::Filtered>; @@ -130,6 +134,7 @@ struct HfDerivedDataCreatorCorrelationsReduced { ConfigurableAxis binsDeltaPhi{"binsDeltaPhi", {64, -3., 3.}, "Delta Phi bins"}; ConfigurableAxis binsMlOne{"binsMlOne", {100, 0., 1.}, ""}; ConfigurableAxis binsMlTwo{"binsMlTwo", {100, 0., 1.}, ""}; + ConfigurableAxis binsDca{"binsDca", {200, -1., 1.}, ""}; HistogramRegistry registry{"registry", {}}; @@ -159,6 +164,8 @@ struct HfDerivedDataCreatorCorrelationsReduced { const AxisSpec axisPhi = {binsPhi, "#it{#varphi}"}; const AxisSpec axisPtTrig = {(std::vector)binsPtTrig, "#it{p}_{T} Trig (GeV/#it{c})"}; const AxisSpec axisPtAssoc = {(std::vector)binsPtAssoc, "#it{p}_{T} Assoc (GeV/#it{c})"}; + const AxisSpec axisDcaXY = {binsDca, "DCA XY (cm)"}; + const AxisSpec axisDcaZ = {binsDca, "DCA Z (cm)"}; // Histograms for data analysis registry.add("hPhiVsPtTrig", "Trigger candidates phiVsPt", {HistType::kTH2F, {{axisPhi}, {axisPtTrig}}}); @@ -167,6 +174,15 @@ struct HfDerivedDataCreatorCorrelationsReduced { registry.add("hEtaVsPtTrigAssoc", "Associated particles etaVsPt", {HistType::kTH3F, {{axisEta}, {axisPtTrig}, {axisPtAssoc}}}); registry.add("hPhiVsPtAssoc", "Associated particles phiVsPt", {HistType::kTH2F, {{axisPhi}, {axisPtAssoc}}}); registry.add("hEtaVsPtAssoc", "Associated particles etaVsPt", {HistType::kTH2F, {{axisEta}, {axisPtAssoc}}}); + registry.add("hDcaXYVsPtAssoc", "Associated particles DCAxyVsPt", {HistType::kTH2F, {{axisDcaXY}, {axisPtAssoc}}}); + registry.add("hDcaZVsPtAssoc", "Associated particles DCAzVsPt", {HistType::kTH2F, {{axisDcaZ}, {axisPtAssoc}}}); + + // Setup pt-dependent DCAxy cut function + if (usePtDiffDcaXYCut) { + funcDcaXYPtCutPrimTrk = new TF1("funcDcaXYPtCutPrimTrk", Form("[0]*%s", dcaXYPtPrimTrkFunc.value.data()), 0.001, 100); + funcDcaXYPtCutPrimTrk->SetParameter(0, dcaXYTrkNSigmaMax); + LOGF(info, "DCAxy pt-dependence function: %s", Form("[0]*%s", dcaXYPtPrimTrkFunc.value.data())); + } }; // end init /// Get charm hadron candidate mass @@ -259,9 +275,8 @@ struct HfDerivedDataCreatorCorrelationsReduced { /// \param assTrk is the associated track /// \param cand is the trigger candidate template - bool acceptSameEvtPair(TAssocTrk const& assTrk, TCand const& cand) + bool acceptSameEvtPair(TAssocTrk const& assTrk, TCand const& cand, double deltaEta) { - double deltaEta = assTrk.eta() - cand.eta(); if (std::abs(deltaEta) <= deltaEtaAbsMin || std::abs(deltaEta) > deltaEtaAbsMax) { return false; } @@ -306,10 +321,18 @@ struct HfDerivedDataCreatorCorrelationsReduced { registry.fill(HIST("hPhiVsPtTrig"), RecoDecay::constrainAngle(trigCand.phi(), -o2::constants::math::PIHalf), trigCandPt); registry.fill(HIST("hEtaVsPtTrig"), trigCand.eta(), trigCandPt); for (const auto& assTrk : assTrks) { - if (!acceptSameEvtPair(assTrk, trigCand)) { + double assTrkPt = assTrk.pt(); + if (usePtDiffDcaXYCut) { + float dcaXYTrkCut = funcDcaXYPtCutPrimTrk->Eval(assTrkPt); + if (std::fabs(assTrk.dcaXY()) > dcaXYTrkCut) { + continue; + } + } + + double deltaEta = assTrk.eta() - trigCand.eta(); + if (!acceptSameEvtPair(assTrk, trigCand, deltaEta)) { continue; } - double assTrkPt = assTrk.pt(); if (downSampleTrksFactor < 1.) { float pseudoRndm = assTrkPt * 1000. - static_cast(assTrkPt * 1000); if (assTrkPt < ptMaxForDownSample && collCentrality < centMaxForDownSample && pseudoRndm >= downSampleTrksFactor) { @@ -317,11 +340,12 @@ struct HfDerivedDataCreatorCorrelationsReduced { } } registry.fill(HIST("hPhiVsPtTrigAssoc"), RecoDecay::constrainAngle(assTrk.phi(), -o2::constants::math::PIHalf), trigCandPt, assTrkPt); - registry.fill(HIST("hEtaVsPtAssoc"), assTrk.eta(), trigCandPt, assTrkPt); + registry.fill(HIST("hEtaVsPtTrigAssoc"), assTrk.eta(), trigCandPt, assTrkPt); registry.fill(HIST("hPhiVsPtAssoc"), RecoDecay::constrainAngle(assTrk.phi(), -o2::constants::math::PIHalf), assTrkPt); registry.fill(HIST("hEtaVsPtAssoc"), assTrk.eta(), assTrkPt); + registry.fill(HIST("hDcaXYVsPtAssoc"), assTrk.dcaXY(), assTrkPt); + registry.fill(HIST("hDcaZVsPtAssoc"), assTrk.dcaZ(), assTrkPt); - double deltaEta = assTrk.eta() - trigCand.eta(); double deltaPhi = RecoDecay::constrainAngle(assTrk.phi() - trigCand.phi(), -o2::constants::math::PIHalf); rowSEPairs(rowCollisions.lastIndex(), trigCandPt, assTrkPt, deltaEta, deltaPhi); rowAssocTrkSels(assTrk.tpcNClsCrossedRows(), assTrk.itsClusterMap(), assTrk.itsNCls(), assTrk.dcaXY(), assTrk.dcaZ()); @@ -363,6 +387,12 @@ struct HfDerivedDataCreatorCorrelationsReduced { continue; } double assTrkPt = assTrk.pt(); + if (usePtDiffDcaXYCut) { + float dcaXYTrkCut = funcDcaXYPtCutPrimTrk->Eval(assTrkPt); + if (std::fabs(assTrk.dcaXY()) > dcaXYTrkCut) { + continue; + } + } if (!first && downSampleTrksFactor < 1.) { // skip downsampling for the first track to avoid empty tables float pseudoRndm = assTrkPt * 1000. - static_cast(assTrkPt * 1000); if (assTrkPt < ptMaxForDownSample && collCentrality < centMaxForDownSample && pseudoRndm >= downSampleTrksFactor) { @@ -372,6 +402,8 @@ struct HfDerivedDataCreatorCorrelationsReduced { first = false; registry.fill(HIST("hPhiVsPtAssoc"), RecoDecay::constrainAngle(assTrk.phi(), -o2::constants::math::PIHalf), assTrkPt); registry.fill(HIST("hEtaVsPtAssoc"), assTrk.eta(), assTrkPt); + registry.fill(HIST("hDcaXYVsPtAssoc"), assTrk.dcaXY(), assTrkPt); + registry.fill(HIST("hDcaZVsPtAssoc"), assTrk.dcaZ(), assTrkPt); rowAssocBases(rowCollisions.lastIndex(), assTrk.phi(), assTrk.eta(), assTrkPt); rowAssocTrkSels(assTrk.tpcNClsCrossedRows(), assTrk.itsClusterMap(), assTrk.itsNCls(), assTrk.dcaXY(), assTrk.dcaZ()); }