diff --git a/PWGHF/HFC/TableProducer/correlatorFlowCharmHadronsReduced.cxx b/PWGHF/HFC/TableProducer/correlatorFlowCharmHadronsReduced.cxx index b6d8857069f..168dc87a9f3 100644 --- a/PWGHF/HFC/TableProducer/correlatorFlowCharmHadronsReduced.cxx +++ b/PWGHF/HFC/TableProducer/correlatorFlowCharmHadronsReduced.cxx @@ -166,7 +166,8 @@ struct HfCorrelatorFlowCharmHadronsReduced { HistogramRegistry registry{"registry", {}, OutputObjHandlingPolicy::AnalysisObject}; - std::shared_ptr loadEfficiencyHistogram(const std::string& path, int histoType) { + std::shared_ptr loadEfficiencyHistogram(const std::string& path, int histoType) + { TObject* object = nullptr; switch (histoType) { @@ -600,8 +601,8 @@ struct HfCorrelatorFlowCharmHadronsReduced { } void processSECharmHadWMultMix(SameEvtPairsChHad::iterator const& pair, - aod::HfcRedTrigCharms const&, - aod::HfcRedCorrColls const&) + aod::HfcRedTrigCharms const&, + aod::HfcRedCorrColls const&) { BinningMultPosZ binPolicyPosZMult{{binsZPool, binsMultPool}}; auto trigCand = pair.template hfcRedTrigCharm_as(); @@ -620,8 +621,8 @@ struct HfCorrelatorFlowCharmHadronsReduced { PROCESS_SWITCH(HfCorrelatorFlowCharmHadronsReduced, processSECharmHadWMultMixWEffInfo, "Process Same Event for Charm-Had with multiplicity pools", false); void processSEHadHadWMultMix(SameEvtPairsHadHad::iterator const& pair, - aod::HfcRedTrigTracks const&, - aod::HfcRedCorrColls const&) + aod::HfcRedTrigTracks const&, + aod::HfcRedCorrColls const&) { BinningMultPosZ binPolicyPosZMult{{binsZPool, binsMultPool}}; auto trigCand = pair.template hfcRedTrigTrack_as(); @@ -630,8 +631,8 @@ struct HfCorrelatorFlowCharmHadronsReduced { PROCESS_SWITCH(HfCorrelatorFlowCharmHadronsReduced, processSEHadHadWMultMix, "Process Same Event for Had-Had with multiplicity pools", false); void processSECharmHadWCentMix(SameEvtPairsChHad::iterator const& pair, - aod::HfcRedTrigCharms const&, - aod::HfcRedCorrColls const&) + aod::HfcRedTrigCharms const&, + aod::HfcRedCorrColls const&) { BinningCentPosZ binPolicyPosZCent{{binsZPool, binsCentPool}}; auto trigCand = pair.template hfcRedTrigCharm_as(); @@ -650,8 +651,8 @@ struct HfCorrelatorFlowCharmHadronsReduced { PROCESS_SWITCH(HfCorrelatorFlowCharmHadronsReduced, processSECharmHadWCentMixWEffInfo, "Process Same Event for Charm-Had with centrality pools", false); void processSEHadHadWCentMix(SameEvtPairsHadHad::iterator const& pair, - aod::HfcRedTrigTracks const&, - aod::HfcRedCorrColls const&) + aod::HfcRedTrigTracks const&, + aod::HfcRedCorrColls const&) { BinningCentPosZ binPolicyPosZCent{{binsZPool, binsCentPool}}; auto trigCand = pair.template hfcRedTrigTrack_as(); diff --git a/PWGHF/HFC/TableProducer/derivedDataCreatorCorrelationsReduced.cxx b/PWGHF/HFC/TableProducer/derivedDataCreatorCorrelationsReduced.cxx index a6e34ed6efb..64c534cd38b 100644 --- a/PWGHF/HFC/TableProducer/derivedDataCreatorCorrelationsReduced.cxx +++ b/PWGHF/HFC/TableProducer/derivedDataCreatorCorrelationsReduced.cxx @@ -637,7 +637,6 @@ struct HfDerivedDataCreatorCorrelationsReduced { } PROCESS_SWITCH(HfDerivedDataCreatorCorrelationsReduced, processDataLcME, "Process Mixed Event for Lc candidates", false); - // CHARM-HADRON CORRELATIONS PROCESS FUNCTIONS --- MC // Dplus MC void processMcDplusSE(McCollsWithCentMult::iterator const& coll, @@ -799,12 +798,11 @@ struct HfDerivedDataCreatorCorrelationsReduced { } PROCESS_SWITCH(HfDerivedDataCreatorCorrelationsReduced, processMcLcME, "Process Mixed Event for Lc candidates", false); - // HADRON-HADRON CORRELATIONS PROCESS FUNCTIONS --- DATA // Hadron Hadron Same Event void processDataHadronHadronSE(DataCollsWithCentMult::iterator const& coll, TracksData const& tracks) - { + { float cent{-1.}, mult{-1.}; if (!checkCollision(coll, cent, mult)) { return; @@ -817,7 +815,7 @@ struct HfDerivedDataCreatorCorrelationsReduced { // Hadron Hadron Mixed Event void processDataHadronHadronME(DataCollsWithCentMult::iterator const& coll, TracksData const& tracks) - { + { float cent{-1.}, mult{-1.}; if (!checkCollision(coll, cent, mult)) { return; @@ -827,12 +825,11 @@ struct HfDerivedDataCreatorCorrelationsReduced { } PROCESS_SWITCH(HfDerivedDataCreatorCorrelationsReduced, processDataHadronHadronME, "Process Mixed Event for hadron candidates", false); - // HADRON-HADRON CORRELATIONS PROCESS FUNCTIONS --- MC // Hadron Hadron Same Event void processMcHadronHadronSE(McCollsWithCentMult::iterator const& coll, TracksMc const& tracks) - { + { float cent{-1.}, mult{-1.}; if (!checkCollision(coll, cent, mult)) { return; @@ -845,7 +842,7 @@ struct HfDerivedDataCreatorCorrelationsReduced { // Hadron Hadron Mixed Event void processMcHadronHadronME(McCollsWithCentMult::iterator const& coll, TracksMc const& tracks) - { + { float cent{-1.}, mult{-1.}; if (!checkCollision(coll, cent, mult)) { return; diff --git a/PWGHF/HFC/Tasks/taskCorrelationsEfficiencies.cxx b/PWGHF/HFC/Tasks/taskCorrelationsEfficiencies.cxx index 5794bf7a7c2..d67836e2c22 100644 --- a/PWGHF/HFC/Tasks/taskCorrelationsEfficiencies.cxx +++ b/PWGHF/HFC/Tasks/taskCorrelationsEfficiencies.cxx @@ -19,8 +19,8 @@ #include "PWGHF/DataModel/CandidateReconstructionTables.h" #include "PWGHF/DataModel/CandidateSelectionTables.h" #include "PWGHF/HFC/DataModel/DerivedDataCorrelationTables.h" -#include "PWGHF/Utils/utilsEvSelHf.h" #include "PWGHF/HFC/Utils/utilsFlow.h" +#include "PWGHF/Utils/utilsEvSelHf.h" #include "Common/Core/RecoDecay.h" #include "Common/DataModel/Centrality.h" @@ -63,13 +63,13 @@ namespace o2::aod namespace hf_correlations_eff { // Charm-hadron candidate columns -DECLARE_SOA_COLUMN(Pt, pt, float); //! Transverse momentum of candidate (GeV/c) -DECLARE_SOA_COLUMN(PvContrib, pvContrib, int); //! Number of primary vertex contributors -DECLARE_SOA_COLUMN(Eta, eta, float); //! Pseudorapidity of candidate -DECLARE_SOA_COLUMN(Phi, phi, float); //! Azimuthal angle of candidate -DECLARE_SOA_COLUMN(Origin, origin, int); //! Origin of the candidate (prompt or non-prompt) -DECLARE_SOA_COLUMN(MlScore0, mlScore0, float); //! ML score of the first configured index -DECLARE_SOA_COLUMN(MlScore1, mlScore1, float); //! ML score of the second configured index +DECLARE_SOA_COLUMN(Pt, pt, float); //! Transverse momentum of candidate (GeV/c) +DECLARE_SOA_COLUMN(PvContrib, pvContrib, int); //! Number of primary vertex contributors +DECLARE_SOA_COLUMN(Eta, eta, float); //! Pseudorapidity of candidate +DECLARE_SOA_COLUMN(Phi, phi, float); //! Azimuthal angle of candidate +DECLARE_SOA_COLUMN(Origin, origin, int); //! Origin of the candidate (prompt or non-prompt) +DECLARE_SOA_COLUMN(MlScore0, mlScore0, float); //! ML score of the first configured index +DECLARE_SOA_COLUMN(MlScore1, mlScore1, float); //! ML score of the second configured index // Associated track columns DECLARE_SOA_COLUMN(PtAssoc, ptAssoc, float); //! Transverse momentum of associated track (GeV/c) @@ -219,7 +219,6 @@ struct HfTaskCorrelationsEfficiencies { std::vector axesAssocTracks = {axisPtAssoc, axisEtaAssoc, axisPhiAssoc, axisZVtx, axisAssTrkSpecie, axisTrackOrigin}; registry.add("hAssTrackReco", "Reconstructed associated tracks;;", {HistType::kTHnSparseF}, axesAssocTracks); registry.add("hAssTrackGen", "Generated associated tracks;;", {HistType::kTHnSparseF}, axesAssocTracks); - } /// Match charm-hadron based on its reconstruction flag @@ -428,10 +427,8 @@ struct HfTaskCorrelationsEfficiencies { auto genCollision = genTrk.template mcCollision_as(); registry.fill(HIST("hAssTrackGen"), genTrk.pt(), genTrk.eta(), genTrk.phi(), genCollision.posZ(), matchedSpecie, genTrkOrigin); } - } PROCESS_SWITCH(HfTaskCorrelationsEfficiencies, processEffAssTracks, "Process efficiencies for associated tracks", true); - }; WorkflowSpec defineDataProcessing(ConfigContext const& cfgc) diff --git a/PWGHF/HFC/Utils/utilsFlow.h b/PWGHF/HFC/Utils/utilsFlow.h index f99f2d6e3e1..31dda4f1943 100644 --- a/PWGHF/HFC/Utils/utilsFlow.h +++ b/PWGHF/HFC/Utils/utilsFlow.h @@ -68,155 +68,155 @@ enum AssTracksTypes { NAssTracksTypes }; -class HfcFlowHelper { - - public: - - HfcFlowHelper() = default; - - void init(o2::framework::Service& ccdb, - o2::framework::HistogramRegistry& registry, - std::vector classMl, - float yCandMax) { - - LOG(info) << "Initializing HFC flow helper!"; - this->hfEvSel.addHistograms(registry); - this->ccdb = &ccdb; - this->registry = ®istry; - this->classMl = std::move(classMl); - this->yCandMax = yCandMax; - } - - /// Get charm hadron candidate mass - /// \param candidate is the charm hadron candidate - template - double getCandMass(const TCand& candidate) - { - if constexpr (CandType == TriggerChannels::DsToKKPi) { - return HfHelper::invMassDsToKKPi(candidate); - } - if constexpr (CandType == TriggerChannels::DsToPiKK) { - return HfHelper::invMassDsToPiKK(candidate); - } - if constexpr (CandType == TriggerChannels::DplusToPiKPi) { - return HfHelper::invMassDplusToPiKPi(candidate); - } - if constexpr (CandType == TriggerChannels::D0ToPiK) { - return HfHelper::invMassD0ToPiK(candidate); - } - if constexpr (CandType == TriggerChannels::D0ToKPi) { - return HfHelper::invMassD0barToKPi(candidate); - } - if constexpr (CandType == TriggerChannels::LcToPKPi) { - return HfHelper::invMassLcToPKPi(candidate); - } - if constexpr (CandType == TriggerChannels::LcToPiKP) { - return HfHelper::invMassLcToPiKP(candidate); - } - return -1.; - } - - /// Get charm hadron bdt scores - /// \param candidate is the charm hadron candidate - template - std::array getCandMlScores(const TCand& candidate) - { - std::array outputMl{-999.f, -999.f}; - if constexpr (CandType == TriggerChannels::DsToKKPi) { - for (unsigned int iclass = 0; iclass < classMl.size(); iclass++) { - outputMl[iclass] = candidate.mlProbDsToKKPi()[classMl.at(iclass)]; - } - } - if constexpr (CandType == TriggerChannels::DsToPiKK) { - for (unsigned int iclass = 0; iclass < classMl.size(); iclass++) { - outputMl[iclass] = candidate.mlProbDsToPiKK()[classMl.at(iclass)]; - } - } - if constexpr (CandType == TriggerChannels::DplusToPiKPi) { - for (unsigned int iclass = 0; iclass < classMl.size(); iclass++) { - outputMl[iclass] = candidate.mlProbDplusToPiKPi()[classMl.at(iclass)]; - } - } - if constexpr (CandType == TriggerChannels::D0ToPiK) { - for (unsigned int iclass = 0; iclass < classMl.size(); iclass++) { - outputMl[iclass] = candidate.mlProbD0()[classMl.at(iclass)]; - } - } - if constexpr (CandType == TriggerChannels::D0ToKPi) { - for (unsigned int iclass = 0; iclass < classMl.size(); iclass++) { - outputMl[iclass] = candidate.mlProbD0bar()[classMl.at(iclass)]; - } - } - if constexpr (CandType == TriggerChannels::LcToPKPi) { - for (unsigned int iclass = 0; iclass < classMl.size(); iclass++) { - outputMl[iclass] = candidate.mlProbLcToPKPi()[classMl.at(iclass)]; - } - } - if constexpr (CandType == TriggerChannels::LcToPiKP) { - for (unsigned int iclass = 0; iclass < classMl.size(); iclass++) { - outputMl[iclass] = candidate.mlProbLcToPiKP()[classMl.at(iclass)]; - } - } - return outputMl; - } - - /// Cut on rapidity of the candidate - /// \param candidate is the charm hadron candidate - template - bool cutCandRapidity(const TCand& candidate) - { - double y = 0.0; - if constexpr (CandType == TriggerChannels::DsToKKPi || CandType == TriggerChannels::DsToPiKK) { - y = HfHelper::yDs(candidate); - } else if constexpr (CandType == TriggerChannels::DplusToPiKPi) { - y = HfHelper::yDplus(candidate); - } else if constexpr (CandType == TriggerChannels::D0ToPiK || CandType == TriggerChannels::D0ToKPi) { - y = HfHelper::yD0(candidate); - } else if constexpr (CandType == TriggerChannels::LcToPKPi || CandType == TriggerChannels::LcToPiKP) { - y = HfHelper::yLc(candidate); - } else { - return true; - } - return std::fabs(y) < yCandMax; - } - - /// 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 constexpr (CentEst == o2::hf_centrality::CentralityEstimator::FT0A) { - collRejMask = hfEvSel.getHfCollisionRejectionMask(collision, cent, *ccdb, *registry); - mult = collision.multFT0A(); - } else if constexpr (CentEst == o2::hf_centrality::CentralityEstimator::FT0C) { - collRejMask = hfEvSel.getHfCollisionRejectionMask(collision, cent, *ccdb, *registry); - mult = collision.multFT0C(); - } else if constexpr (CentEst == o2::hf_centrality::CentralityEstimator::FT0M) { - collRejMask = hfEvSel.getHfCollisionRejectionMask(collision, cent, *ccdb, *registry); - mult = collision.multFT0M(); - } else if constexpr (CentEst == o2::hf_centrality::CentralityEstimator::FV0A) { - collRejMask = hfEvSel.getHfCollisionRejectionMask(collision, cent, *ccdb, *registry); - mult = collision.multFV0A(); - } else if constexpr (CentEst == o2::hf_centrality::CentralityEstimator::None) { - collRejMask = hfEvSel.getHfCollisionRejectionMask(collision, cent, *ccdb, *registry); - mult = -1.f; - } else { - LOG(fatal) << "Centrality estimator not recognized for collision selection"; - std::abort(); - } - hfEvSel.fillHistograms(collision, collRejMask, cent); - return collRejMask == 0; - } - - private: - o2::hf_evsel::HfEventSelection hfEvSel; - o2::framework::Service* ccdb{nullptr}; - o2::framework::HistogramRegistry* registry{nullptr}; - std::vector classMl{}; - float yCandMax{-999.f}; -}; +class HfcFlowHelper +{ + public: + HfcFlowHelper() = default; + + void init(o2::framework::Service& ccdb, + o2::framework::HistogramRegistry& registry, + std::vector classMl, + float yCandMax) + { + + LOG(info) << "Initializing HFC flow helper!"; + this->hfEvSel.addHistograms(registry); + this->ccdb = &ccdb; + this->registry = ®istry; + this->classMl = std::move(classMl); + this->yCandMax = yCandMax; + } + + /// Get charm hadron candidate mass + /// \param candidate is the charm hadron candidate + template + double getCandMass(const TCand& candidate) + { + if constexpr (CandType == TriggerChannels::DsToKKPi) { + return HfHelper::invMassDsToKKPi(candidate); + } + if constexpr (CandType == TriggerChannels::DsToPiKK) { + return HfHelper::invMassDsToPiKK(candidate); + } + if constexpr (CandType == TriggerChannels::DplusToPiKPi) { + return HfHelper::invMassDplusToPiKPi(candidate); + } + if constexpr (CandType == TriggerChannels::D0ToPiK) { + return HfHelper::invMassD0ToPiK(candidate); + } + if constexpr (CandType == TriggerChannels::D0ToKPi) { + return HfHelper::invMassD0barToKPi(candidate); + } + if constexpr (CandType == TriggerChannels::LcToPKPi) { + return HfHelper::invMassLcToPKPi(candidate); + } + if constexpr (CandType == TriggerChannels::LcToPiKP) { + return HfHelper::invMassLcToPiKP(candidate); + } + return -1.; + } + + /// Get charm hadron bdt scores + /// \param candidate is the charm hadron candidate + template + std::array getCandMlScores(const TCand& candidate) + { + std::array outputMl{-999.f, -999.f}; + if constexpr (CandType == TriggerChannels::DsToKKPi) { + for (unsigned int iclass = 0; iclass < classMl.size(); iclass++) { + outputMl[iclass] = candidate.mlProbDsToKKPi()[classMl.at(iclass)]; + } + } + if constexpr (CandType == TriggerChannels::DsToPiKK) { + for (unsigned int iclass = 0; iclass < classMl.size(); iclass++) { + outputMl[iclass] = candidate.mlProbDsToPiKK()[classMl.at(iclass)]; + } + } + if constexpr (CandType == TriggerChannels::DplusToPiKPi) { + for (unsigned int iclass = 0; iclass < classMl.size(); iclass++) { + outputMl[iclass] = candidate.mlProbDplusToPiKPi()[classMl.at(iclass)]; + } + } + if constexpr (CandType == TriggerChannels::D0ToPiK) { + for (unsigned int iclass = 0; iclass < classMl.size(); iclass++) { + outputMl[iclass] = candidate.mlProbD0()[classMl.at(iclass)]; + } + } + if constexpr (CandType == TriggerChannels::D0ToKPi) { + for (unsigned int iclass = 0; iclass < classMl.size(); iclass++) { + outputMl[iclass] = candidate.mlProbD0bar()[classMl.at(iclass)]; + } + } + if constexpr (CandType == TriggerChannels::LcToPKPi) { + for (unsigned int iclass = 0; iclass < classMl.size(); iclass++) { + outputMl[iclass] = candidate.mlProbLcToPKPi()[classMl.at(iclass)]; + } + } + if constexpr (CandType == TriggerChannels::LcToPiKP) { + for (unsigned int iclass = 0; iclass < classMl.size(); iclass++) { + outputMl[iclass] = candidate.mlProbLcToPiKP()[classMl.at(iclass)]; + } + } + return outputMl; + } + + /// Cut on rapidity of the candidate + /// \param candidate is the charm hadron candidate + template + bool cutCandRapidity(const TCand& candidate) + { + double y = 0.0; + if constexpr (CandType == TriggerChannels::DsToKKPi || CandType == TriggerChannels::DsToPiKK) { + y = HfHelper::yDs(candidate); + } else if constexpr (CandType == TriggerChannels::DplusToPiKPi) { + y = HfHelper::yDplus(candidate); + } else if constexpr (CandType == TriggerChannels::D0ToPiK || CandType == TriggerChannels::D0ToKPi) { + y = HfHelper::yD0(candidate); + } else if constexpr (CandType == TriggerChannels::LcToPKPi || CandType == TriggerChannels::LcToPiKP) { + y = HfHelper::yLc(candidate); + } else { + return true; + } + return std::fabs(y) < yCandMax; + } + + /// 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 constexpr (CentEst == o2::hf_centrality::CentralityEstimator::FT0A) { + collRejMask = hfEvSel.getHfCollisionRejectionMask(collision, cent, *ccdb, *registry); + mult = collision.multFT0A(); + } else if constexpr (CentEst == o2::hf_centrality::CentralityEstimator::FT0C) { + collRejMask = hfEvSel.getHfCollisionRejectionMask(collision, cent, *ccdb, *registry); + mult = collision.multFT0C(); + } else if constexpr (CentEst == o2::hf_centrality::CentralityEstimator::FT0M) { + collRejMask = hfEvSel.getHfCollisionRejectionMask(collision, cent, *ccdb, *registry); + mult = collision.multFT0M(); + } else if constexpr (CentEst == o2::hf_centrality::CentralityEstimator::FV0A) { + collRejMask = hfEvSel.getHfCollisionRejectionMask(collision, cent, *ccdb, *registry); + mult = collision.multFV0A(); + } else if constexpr (CentEst == o2::hf_centrality::CentralityEstimator::None) { + collRejMask = hfEvSel.getHfCollisionRejectionMask(collision, cent, *ccdb, *registry); + mult = -1.f; + } else { + LOG(fatal) << "Centrality estimator not recognized for collision selection"; + std::abort(); + } + hfEvSel.fillHistograms(collision, collRejMask, cent); + return collRejMask == 0; + } + + private: + o2::hf_evsel::HfEventSelection hfEvSel; + o2::framework::Service* ccdb{nullptr}; + o2::framework::HistogramRegistry* registry{nullptr}; + std::vector classMl{}; + float yCandMax{-999.f}; +}; -} // namespace o2::analysis::hfc_utils_flow +} // namespace o2::hfc_utils_flow #endif // PWGHF_HFC_UTILS_FLOW_H_