Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 8 additions & 2 deletions PWGHF/HFC/DataModel/CorrelationTables.h
Original file line number Diff line number Diff line change
Expand Up @@ -462,14 +462,18 @@ DECLARE_SOA_COLUMN(IsSignal, isSignal, bool); //! U
DECLARE_SOA_COLUMN(IsDecayChan, isDecayChan, bool); //! Used in MC-Rec, D+ decay channel check
DECLARE_SOA_COLUMN(IsPrompt, isPrompt, bool); //! Used in MC-Rec, D+ Prompt or Non-Prompt
DECLARE_SOA_COLUMN(IsPhysicalPrimary, isPhysicalPrimary, bool); //! Used in MC-Rec, primary associated particles
DECLARE_SOA_COLUMN(NumPvContrib, numPvContrib, uint16_t); //! Number of PV contributors
DECLARE_SOA_COLUMN(Centrality, centrality, float); //! Centrality of the collision
} // namespace hf_correlation_dplus_hadron

DECLARE_SOA_TABLE(DplusHadronPair, "AOD", "DPLUSHPAIR", //! D+-Hadrons pairs Informations
aod::hf_correlation_dplus_hadron::DeltaPhi,
aod::hf_correlation_dplus_hadron::DeltaEta,
aod::hf_correlation_dplus_hadron::PtD,
aod::hf_correlation_dplus_hadron::PtHadron,
aod::hf_correlation_dplus_hadron::PoolBin);
aod::hf_correlation_dplus_hadron::PoolBin,
aod::hf_correlation_dplus_hadron::NumPvContrib,
aod::hf_correlation_dplus_hadron::Centrality);

DECLARE_SOA_TABLE(DplusHadronRecoInfo, "AOD", "DPLUSHRECOINFO", //! D+-Hadrons pairs Reconstructed Informations
aod::hf_correlation_dplus_hadron::MD,
Expand All @@ -490,7 +494,9 @@ DECLARE_SOA_TABLE(DplusRecoInfo, "AOD", "DPLUSRECOINFO", //! D+ candidates Recon
aod::hf_correlation_dplus_hadron::PtD,
aod::hf_correlation_dplus_hadron::MlScoreBkg,
aod::hf_correlation_dplus_hadron::MlScorePrompt,
aod::hf_correlation_dplus_hadron::MlScoreNonPrompt);
aod::hf_correlation_dplus_hadron::MlScoreNonPrompt,
aod::hf_correlation_dplus_hadron::NumPvContrib,
aod::hf_correlation_dplus_hadron::Centrality);

DECLARE_SOA_TABLE(DplusGenInfo, "AOD", "DPLUSGENOINFO", //! D+ candidates Generated Information
aod::hf_correlation_dplus_hadron::IsPrompt);
Expand Down
31 changes: 21 additions & 10 deletions PWGHF/HFC/TableProducer/correlatorDplusHadrons.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@

#include "Common/CCDB/EventSelectionParams.h"
#include "Common/Core/RecoDecay.h"
#include "Common/DataModel/Centrality.h"
#include "Common/DataModel/EventSelection.h"
#include "Common/DataModel/Multiplicity.h"
#include "Common/DataModel/TrackSelectionTables.h"
Expand Down Expand Up @@ -223,7 +224,7 @@ struct HfCorrelatorDplusHadrons {
SliceCache cache;

// Event Mixing for the Data Mode
using SelCollisionsWithDplus = soa::Filtered<soa::Join<aod::Collisions, aod::Mults, aod::EvSels, aod::DmesonSelection>>;
using SelCollisionsWithDplus = soa::Filtered<soa::Join<aod::Collisions, aod::Mults, aod::CentFT0Ms, aod::EvSels, aod::DmesonSelection>>;
using SelCollisionsWithDplusMc = soa::Filtered<soa::Join<aod::McCollisions, aod::DmesonSelection, aod::MultsExtraMC>>; // collisionFilter applied
using CollisionsMc = soa::Join<aod::McCollisions, aod::MultsExtraMC>;
using CandidatesDplusData = soa::Filtered<soa::Join<aod::HfCand3Prong, aod::HfSelDplusToPiKPi, aod::HfMlDplusToPiKPi>>;
Expand Down Expand Up @@ -448,7 +449,9 @@ struct HfCorrelatorDplusHadrons {
particleAssoc.eta() - particle.eta(),
particle.pt(),
particleAssoc.pt(),
poolBin);
poolBin,
0, // no PV contributors info at gen level
0.f); // no centrality info at gen level

entryDplusHadronRecoInfo(MassDPlus, true);
entryDplusHadronGenInfo(isDplusPrompt,
Expand Down Expand Up @@ -511,7 +514,7 @@ struct HfCorrelatorDplusHadrons {
for (unsigned int iclass = 0; iclass < classMl->size(); iclass++) {
outputMl[iclass] = candidate.mlProbDplusToPiKPi()[classMl->at(iclass)];
}
entryDplusCandRecoInfo(HfHelper::invMassDplusToPiKPi(candidate), candidate.pt(), outputMl[0], outputMl[1], outputMl[2]); // 0: BkgBDTScore, 1:PromptBDTScore, 2: FDScore
entryDplusCandRecoInfo(HfHelper::invMassDplusToPiKPi(candidate), candidate.pt(), outputMl[0], outputMl[1], outputMl[2], collision.numContrib(), collision.centFT0M()); // 0: BkgBDTScore, 1:PromptBDTScore, 2: FDScore
entryDplus(candidate.phi(), candidate.eta(), candidate.pt(), HfHelper::invMassDplusToPiKPi(candidate), poolBin, gCollisionId, timeStamp);

// Dplus-Hadron correlation dedicated section
Expand All @@ -530,7 +533,9 @@ struct HfCorrelatorDplusHadrons {
entryDplusHadronPair(getDeltaPhi(track.phi(), candidate.phi()),
track.eta() - candidate.eta(),
candidate.pt(),
track.pt(), poolBin);
track.pt(), poolBin,
collision.numContrib(),
collision.centFT0M());
entryDplusHadronRecoInfo(HfHelper::invMassDplusToPiKPi(candidate), false);
entryDplusHadronGenInfo(false, false, 0);
entryDplusHadronMlInfo(outputMl[0], outputMl[1], outputMl[2]);
Expand Down Expand Up @@ -584,7 +589,7 @@ struct HfCorrelatorDplusHadrons {
assocTrackSelInfo(indexHfcReducedCollision, track.tpcNClsCrossedRows(), track.itsClusterMap(), track.itsNCls(), track.dcaXY(), track.dcaZ());
}

collReduced(collision.multFT0M(), 0.f, collision.numContrib(), collision.posZ());
collReduced(collision.multFT0M(), collision.centFT0M(), collision.numContrib(), collision.posZ());
}
}
PROCESS_SWITCH(HfCorrelatorDplusHadrons, processDerivedDataDplus, "Process derived data D+", false);
Expand Down Expand Up @@ -672,7 +677,7 @@ struct HfCorrelatorDplusHadrons {
outputMl[iclass] = candidate.mlProbDplusToPiKPi()[classMl->at(iclass)];
}
registry.fill(HIST("hMassDplusMcRecSig"), HfHelper::invMassDplusToPiKPi(candidate), candidate.pt(), efficiencyWeightD);
entryDplusCandRecoInfo(HfHelper::invMassDplusToPiKPi(candidate), candidate.pt(), outputMl[0], outputMl[1], outputMl[2]);
entryDplusCandRecoInfo(HfHelper::invMassDplusToPiKPi(candidate), candidate.pt(), outputMl[0], outputMl[1], outputMl[2], collision.numContrib(), collision.centFT0M());
entryDplusCandGenInfo(isDplusPrompt);
entryDplusCandBMotherInfo(ptB, deltaPhiBtoD);
} else {
Expand Down Expand Up @@ -700,7 +705,9 @@ struct HfCorrelatorDplusHadrons {
entryDplusHadronPair(getDeltaPhi(track.phi(), candidate.phi()),
track.eta() - candidate.eta(),
candidate.pt(),
track.pt(), poolBin);
track.pt(), poolBin,
collision.numContrib(),
collision.centFT0M());
entryDplusHadronRecoInfo(HfHelper::invMassDplusToPiKPi(candidate), isDplusSignal);
entryDplusHadronMlInfo(outputMl[0], outputMl[1], outputMl[2]);
entryDplusHadronBMotherInfo(ptB, deltaPhiBtoD);
Expand Down Expand Up @@ -806,7 +813,7 @@ struct HfCorrelatorDplusHadrons {
if (!assocParticle.isGlobalTrackWoDCA() || std::abs(HfHelper::yDplus(trigDplus)) >= yCandMax) {
continue;
}
entryDplusHadronPair(getDeltaPhi(trigDplus.phi(), assocParticle.phi()), trigDplus.eta() - assocParticle.eta(), trigDplus.pt(), assocParticle.pt(), poolBin);
entryDplusHadronPair(getDeltaPhi(trigDplus.phi(), assocParticle.phi()), trigDplus.eta() - assocParticle.eta(), trigDplus.pt(), assocParticle.pt(), poolBin, c1.numContrib(), c1.centFT0M());
entryDplusHadronRecoInfo(HfHelper::invMassDplusToPiKPi(trigDplus), 0);
}
}
Expand Down Expand Up @@ -876,7 +883,9 @@ struct HfCorrelatorDplusHadrons {
pAssoc.eta() - candidate.eta(),
candidate.pt(),
pAssoc.pt(),
poolBin);
poolBin,
c1.numContrib(),
c1.centFT0M());
entryDplusHadronRecoInfo(HfHelper::invMassDplusToPiKPi(candidate), isDplusSignal);
entryDplusHadronGenInfo(isDplusPrompt, isPhysicalPrimary, trackOrigin);
const auto [ptB, deltaPhiBtoD] = hf_correlations::getBMotherInfoMcRec<TracksWithMc>(candidate, mcParticles, Pdg::kDPlus, DepthMaxDplusDaughters);
Expand Down Expand Up @@ -922,7 +931,9 @@ struct HfCorrelatorDplusHadrons {
particleAssoc.eta() - candidate.eta(),
candidate.pt(),
particleAssoc.pt(),
poolBin);
poolBin,
0, // no PV contributors info at gen level
0.f); // no centrality info at gen level
entryDplusHadronRecoInfo(MassDPlus, true);
entryDplusHadronGenInfo(isDplusPrompt, particleAssoc.isPhysicalPrimary(), trackOrigin);
const auto [ptB, deltaPhiBtoD] = hf_correlations::getBMotherInfoMcGen(candidate, mcParticles);
Expand Down
47 changes: 36 additions & 11 deletions PWGHF/HFC/Tasks/taskCorrelationDplusHadrons.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -45,10 +45,13 @@
#include <Framework/StepTHn.h>
#include <Framework/runDataProcessing.h>

#include <TAxis.h>
#include <TH1.h>
#include <TH2.h>
#include <THnSparse.h>
#include <TString.h>

#include <algorithm>
#include <chrono>
#include <cstddef>
#include <cstdint>
Expand Down Expand Up @@ -104,6 +107,7 @@ struct HfTaskCorrelationDplusHadrons {
Configurable<bool> fillHistoMcGen{"fillHistoMcGen", true, "Flag for filling histograms in MC Gen processes"};
Configurable<int> applyEfficiency{"applyEfficiency", 1, "Flag for applying efficiency weights"};
Configurable<bool> loadAccXEffFromCCDB{"loadAccXEffFromCCDB", false, "Flag for loading efficiency distributions from CCDB"};
Configurable<bool> useEffDplusVsPvContrib{"useEffDplusVsPvContrib", false, "Use D+ efficiency TH2 from CCDB, with pT on the x axis and the number of PV contributors on the y axis"};
Configurable<int> selectionFlagDplus{"selectionFlagDplus", 7, "Selection Flag for D+"}; // 7 corresponds to topo+PID cuts
Configurable<bool> selNoSameBunchPileUpColl{"selNoSameBunchPileUpColl", true, "Flag for rejecting the collisions associated with the same bunch crossing"};
// Machine Learning options and selections
Expand Down Expand Up @@ -317,13 +321,22 @@ struct HfTaskCorrelationDplusHadrons {
ccdb->setLocalObjectValidityChecking();
ccdb->setCreatedNotAfter(ccdbNoLaterThan.value);

mEfficiencyPrompt = std::shared_ptr<TH1>(ccdb->getForTimeStamp<TH1F>(promptEffCcdbPath, timestampCcdb));
// D+ efficiency: TH1 vs pT, or TH2 vs pT (x axis) and number of PV contributors (y axis)
if (useEffDplusVsPvContrib) {
mEfficiencyPrompt = std::shared_ptr<TH1>(ccdb->getForTimeStamp<TH2F>(promptEffCcdbPath, timestampCcdb));
} else {
mEfficiencyPrompt = std::shared_ptr<TH1>(ccdb->getForTimeStamp<TH1F>(promptEffCcdbPath, timestampCcdb));
}
if (mEfficiencyPrompt == nullptr) {
LOGF(fatal, "Could not load efficiency histogram for trigger particles from %s", promptEffCcdbPath.value.c_str());
}
LOGF(info, "Loaded trigger efficiency (prompt D) histogram from %s", promptEffCcdbPath.value.c_str());

mEfficiencyFD = std::shared_ptr<TH1>(ccdb->getForTimeStamp<TH1F>(fdEffCcdbPath, timestampCcdb));
if (useEffDplusVsPvContrib) {
mEfficiencyFD = std::shared_ptr<TH1>(ccdb->getForTimeStamp<TH2F>(fdEffCcdbPath, timestampCcdb));
} else {
mEfficiencyFD = std::shared_ptr<TH1>(ccdb->getForTimeStamp<TH1F>(fdEffCcdbPath, timestampCcdb));
}
if (mEfficiencyFD == nullptr) {
LOGF(fatal, "Could not load efficiency histogram for trigger particles from %s", fdEffCcdbPath.value.c_str());
}
Expand All @@ -336,6 +349,10 @@ struct HfTaskCorrelationDplusHadrons {
LOGF(info, "Loaded associated efficiency histogram from %s", associatedEffCcdbPath.value.c_str());
}

if ((applyEfficiency != 0) && useEffDplusVsPvContrib && !loadAccXEffFromCCDB) {
LOGF(fatal, "useEffDplusVsPvContrib requires loadAccXEffFromCCDB: the D+ efficiency vs pT and PV contributors is only available from CCDB");
}

constexpr std::size_t NBinLimitsMin{2u}; // at least one pT bin

// efficiency values from configurables: one entry per pT bin
Expand Down Expand Up @@ -382,12 +399,19 @@ struct HfTaskCorrelationDplusHadrons {

/// D+ efficiency, from the CCDB histograms or from the configurable vectors
/// \param ptD is the D+ transverse momentum
/// \param numPvContrib is the number of PV contributors of the collision (used only with useEffDplusVsPvContrib)
/// \param isPrompt selects the prompt (true) or non-prompt (false) efficiency
/// \return the efficiency, or a non-positive value if it is not available for this pT
double getEfficiencyDplus(float ptD, bool isPrompt)
double getEfficiencyDplus(float ptD, int numPvContrib, bool isPrompt)
{
if (loadAccXEffFromCCDB) {
auto const& hEfficiency = isPrompt ? mEfficiencyPrompt : mEfficiencyFD;
if (useEffDplusVsPvContrib) {
// pT on the x axis; PV contributors on the y axis, clamped to the axis range (under/overflow -> first/last bin)
int const binPt = hEfficiency->GetXaxis()->FindFixBin(ptD);
int const binPvContrib = std::clamp(hEfficiency->GetYaxis()->FindFixBin(numPvContrib), 1, hEfficiency->GetYaxis()->GetNbins());
return hEfficiency->GetBinContent(binPt, binPvContrib);
}
return hEfficiency->GetBinContent(hEfficiency->FindBin(ptD));
}
int const effBinD = o2::analysis::findBin(binsPtEfficiencyD, ptD);
Expand All @@ -414,15 +438,16 @@ struct HfTaskCorrelationDplusHadrons {

/// Efficiency weight of the D+ candidate, or of the D+-hadron pair if ptHadron is given
/// \param ptD is the D+ transverse momentum
/// \param numPvContrib is the number of PV contributors of the collision (used only with useEffDplusVsPvContrib)
/// \param isPrompt selects the prompt (true) or non-prompt (false) D+ efficiency
/// \param ptHadron is the associated-hadron transverse momentum (negative for the D+ only)
/// \return 1/efficiency, 1 if the efficiencies are not applied, or -1 if the efficiency is not available
double getEfficiencyWeight(float ptD, bool isPrompt, float ptHadron = -1.f)
double getEfficiencyWeight(float ptD, int numPvContrib, bool isPrompt, float ptHadron = -1.f)
{
if (applyEfficiency == 0) {
return 1.;
}
double efficiency = getEfficiencyDplus(ptD, isPrompt);
double efficiency = getEfficiencyDplus(ptD, numPvContrib, isPrompt);
if (efficiency <= 0.) {
return -1.;
}
Expand All @@ -449,7 +474,7 @@ struct HfTaskCorrelationDplusHadrons {
if (!isSelectedMl(ptD, bdtScoreBkg, bdtScorePrompt, bdtScoreNonPrompt)) {
continue;
}
double const efficiencyWeightD = getEfficiencyWeight(ptD, isPromptAnalysis);
double const efficiencyWeightD = getEfficiencyWeight(ptD, candidate.numPvContrib(), isPromptAnalysis);
if (efficiencyWeightD < 0.) {
continue; // efficiency not available for this pT
}
Expand Down Expand Up @@ -481,7 +506,7 @@ struct HfTaskCorrelationDplusHadrons {
if (std::abs(trackDcaXY) >= dcaXYTrackMax || std::abs(trackDcaZ) >= dcaZTrackMax || trackTpcCrossedRows < nTpcCrossedRows) {
continue;
}
double const efficiencyWeight = getEfficiencyWeight(ptD, isPromptAnalysis, ptHadron);
double const efficiencyWeight = getEfficiencyWeight(ptD, pairEntry.numPvContrib(), isPromptAnalysis, ptHadron);
if (efficiencyWeight < 0.) {
continue; // efficiency not available for this pT
}
Expand Down Expand Up @@ -541,7 +566,7 @@ struct HfTaskCorrelationDplusHadrons {
if (!isSelectedMl(ptD, bdtScoreBkg, bdtScorePrompt, bdtScoreNonPrompt)) {
continue;
}
double const efficiencyWeightD = getEfficiencyWeight(ptD, isDplusPrompt);
double const efficiencyWeightD = getEfficiencyWeight(ptD, candidate.numPvContrib(), isDplusPrompt);
if (efficiencyWeightD < 0.) {
continue; // efficiency not available for this pT
}
Expand Down Expand Up @@ -585,7 +610,7 @@ struct HfTaskCorrelationDplusHadrons {
if (std::abs(trackDcaXY) > dcaXYTrackMax || std::abs(trackDcaZ) > dcaZTrackMax || trackTpcCrossedRows < nTpcCrossedRows) {
continue;
}
double const efficiencyWeight = getEfficiencyWeight(ptD, isDplusPrompt, ptHadron);
double const efficiencyWeight = getEfficiencyWeight(ptD, pairEntry.numPvContrib(), isDplusPrompt, ptHadron);
if (efficiencyWeight < 0.) {
continue; // efficiency not available for this pT
}
Expand All @@ -608,15 +633,15 @@ struct HfTaskCorrelationDplusHadrons {
registry.fill(HIST("hCorrel2DPtIntSignalRegionMcRec"), deltaPhi, deltaEta, efficiencyWeight);
registry.fill(HIST("hDeltaEtaPtIntSignalRegionMcRec"), deltaEta, efficiencyWeight);
registry.fill(HIST("hDeltaPhiPtIntSignalRegionMcRec"), deltaPhi, efficiencyWeight);
if (isPhysicalPrimary) {
if (isPhysicalPrimary && pairEntry.signalStatus()) {
registry.fill(HIST("hCorrel2DVsPtPhysicalPrimaryMcRec"), deltaPhi, deltaEta, ptD, ptHadron, static_cast<int>(isDplusPrompt), poolBin, efficiencyWeight);
if (isDplusPrompt && originHadron == RecoDecay::OriginType::Prompt) {
registry.fill(HIST("hCorrel2DVsPtSignalRegionPromptDplusPromptHadronMcRec"), deltaPhi, deltaEta, ptD, ptHadron, poolBin, efficiencyWeight);
} else if (!isDplusPrompt && originHadron == RecoDecay::OriginType::NonPrompt) {
registry.fill(HIST("hCorrel2DVsPtSignalRegionNonPromptDplusNonPromptHadronMcRec"), deltaPhi, deltaEta, ptD, ptHadron, poolBin, efficiencyWeight);
}
// beauty-mother information, only for true non-prompt D+, to study the structures in the MC Closure test
if (storeBMotherInfo && pairEntry.signalStatus() && !isDplusPrompt) {
if (storeBMotherInfo && !isDplusPrompt) {
float const ptB = pairEntry.ptB();
float const deltaPhiBtoD = pairEntry.deltaPhiBtoD();
registry.fill(HIST("hCorrel2DVsPtNonPromptDplusPhysicalPrimaryMcRecBMother"), deltaPhi, deltaEta, ptD, ptHadron, ptB, deltaPhiBtoD, efficiencyWeight);
Expand Down
Loading