Skip to content

Commit 95d1efe

Browse files
authored
[PWGCF] FemtoUniverse: update in the MC functions for D0s (#12619)
1 parent 41e44e1 commit 95d1efe

File tree

4 files changed

+126
-150
lines changed

4 files changed

+126
-150
lines changed

PWGCF/FemtoUniverse/TableProducer/femtoUniverseProducerMCTruthTask.cxx

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
#include "PWGCF/FemtoUniverse/DataModel/FemtoDerived.h"
2020

2121
#include "Common/CCDB/TriggerAliases.h"
22+
#include "Common/Core/RecoDecay.h"
2223
#include "Common/DataModel/EventSelection.h"
2324
#include "Common/DataModel/Multiplicity.h"
2425

@@ -171,10 +172,10 @@ struct FemtoUniverseProducerMCTruthTask {
171172
if (confAnalysisWithPID) {
172173
bool pass = false;
173174
std::vector<int> tmpPDGCodes = confPDGCodes; // necessary due to some features of the Configurable
174-
for (const int& pdg : tmpPDGCodes) {
175+
for (auto const& pdg : tmpPDGCodes) {
175176
if (pdgCode == Pdg::kPhi) { // phi meson
176177
pass = true;
177-
} else if (pdgCode == Pdg::kD0) { // D0 meson
178+
} else if (std::abs(pdgCode) == Pdg::kD0) { // D0(bar) meson
178179
pass = true;
179180
} else if (pdgCode == Pdg::kDPlus) { // D+ meson
180181
pass = true;
@@ -187,6 +188,13 @@ struct FemtoUniverseProducerMCTruthTask {
187188
continue;
188189
}
189190

191+
/// check if we end-up with the correct final state using MC info
192+
int8_t sign = 0;
193+
if (std::abs(pdgCode) == Pdg::kD0 && !RecoDecay::isMatchedMCGen(tracks, particle, Pdg::kD0, std::array{+kPiPlus, -kKPlus}, true, &sign)) {
194+
/// check if we have D0(bar) → π± K∓
195+
continue;
196+
}
197+
190198
// we cannot use isSelectedMinimal since it takes Ncls
191199
// if (!trackCuts.isSelectedMinimal(track)) {
192200
// continue;

PWGCF/FemtoUniverse/TableProducer/femtoUniverseProducerTask.cxx

Lines changed: 31 additions & 63 deletions
Original file line numberDiff line numberDiff line change
@@ -328,10 +328,7 @@ struct FemtoUniverseProducerTask {
328328

329329
// D0/D0bar mesons
330330
struct : o2::framework::ConfigurableGroup {
331-
Configurable<float> confD0D0barCandMaxY{"confD0D0barCandMaxY", -1., "max. cand. rapidity"};
332331
Configurable<float> confD0D0barCandEtaCut{"confD0D0barCandEtaCut", 0.8, "max. cand. pseudorapidity"};
333-
Configurable<float> yD0D0barCandRecoMax{"yD0D0barCandRecoMax", 0.8, "MC Reco, max. rapidity of D0/D0bar cand."};
334-
Configurable<float> yD0D0barCandGenMax{"yD0D0barCandGenMax", 0.8, "MC Truth, max. rapidity of D0/D0bar cand."};
335332
Configurable<float> trackD0pTGenMin{"trackD0pTGenMin", 0.0, "MC Truth, min. pT for tracks and D0/D0bar cand."};
336333
Configurable<float> trackD0pTGenMax{"trackD0pTGenMax", 24.0, "MC Truth, max. pT for tracks and D0/D0bar cand."};
337334
Configurable<bool> storeD0D0barDoubleMassHypo{"storeD0D0barDoubleMassHypo", false, "Store D0/D0bar cand. which pass selection criteria for both, D0 and D0bar"};
@@ -1357,10 +1354,6 @@ struct FemtoUniverseProducerTask {
13571354
continue;
13581355
}
13591356

1360-
if (ConfD0Selection.confD0D0barCandMaxY >= 0. && std::abs(hfHelper.yD0(hfCand)) > ConfD0Selection.confD0D0barCandMaxY) {
1361-
continue;
1362-
}
1363-
13641357
if (std::abs(hfCand.eta()) > ConfD0Selection.confD0D0barCandEtaCut) {
13651358
continue;
13661359
}
@@ -1480,10 +1473,6 @@ struct FemtoUniverseProducerTask {
14801473
continue;
14811474
}
14821475

1483-
if (ConfD0Selection.confD0D0barCandMaxY >= 0. && std::abs(hfHelper.yD0(hfCand)) > ConfD0Selection.confD0D0barCandMaxY) {
1484-
continue;
1485-
}
1486-
14871476
if (std::abs(hfCand.eta()) > ConfD0Selection.confD0D0barCandEtaCut) {
14881477
continue;
14891478
}
@@ -1610,10 +1599,6 @@ struct FemtoUniverseProducerTask {
16101599
continue;
16111600
}
16121601

1613-
if (ConfD0Selection.confD0D0barCandMaxY >= 0. && std::abs(hfHelper.yD0(hfCand)) > ConfD0Selection.confD0D0barCandMaxY) {
1614-
continue;
1615-
}
1616-
16171602
if (std::abs(hfCand.eta()) > ConfD0Selection.confD0D0barCandEtaCut) {
16181603
continue;
16191604
}
@@ -1997,20 +1982,18 @@ struct FemtoUniverseProducerTask {
19971982
}
19981983

19991984
template <typename TrackType, bool transientLabels = false>
2000-
void fillMCTruthParticlesD0(TrackType const& mcParts, std::optional<std::reference_wrapper<const std::set<int>>> recoMcIds = std::nullopt)
1985+
void fillMCTruthParticlesD0(TrackType const& mcParts)
20011986
{
20021987
std::vector<int> childIDs = {0, 0}; // these IDs are necessary to keep track of the children
20031988
std::vector<int> tmpIDtrack;
2004-
float ptGenB = -1;
20051989

20061990
for (const auto& particle : mcParts) {
2007-
20081991
if (particle.eta() < -ConfFilterCuts.confEtaFilterCut || particle.eta() > ConfFilterCuts.confEtaFilterCut)
20091992
continue;
20101993
if (particle.pt() < ConfD0Selection.trackD0pTGenMin || particle.pt() > ConfD0Selection.trackD0pTGenMax)
20111994
continue;
20121995

2013-
uint32_t pdgCode = static_cast<uint32_t>(particle.pdgCode());
1996+
int pdgCode = particle.pdgCode();
20141997

20151998
if (ConfGeneral.confMCTruthAnalysisWithPID) {
20161999
bool pass = false;
@@ -2019,10 +2002,10 @@ struct FemtoUniverseProducerTask {
20192002
if (static_cast<int>(pdg) == static_cast<int>(pdgCode)) {
20202003
if (pdgCode == Pdg::kPhi) {
20212004
pass = true;
2022-
} else if (pdgCode == Pdg::kD0) {
2005+
} else if (std::abs(pdgCode) == Pdg::kD0) {
20232006
pass = true;
20242007
} else {
2025-
if (particle.isPhysicalPrimary() || (ConfGeneral.confActivateSecondaries && recoMcIds && recoMcIds->get().contains(particle.globalIndex())))
2008+
if (particle.isPhysicalPrimary())
20262009
pass = true;
20272010
}
20282011
}
@@ -2031,41 +2014,31 @@ struct FemtoUniverseProducerTask {
20312014
continue;
20322015
}
20332016

2034-
if (pdgCode == Pdg::kD0) {
2035-
if (std::abs(particle.flagMcMatchGen()) == o2::hf_decay::hf_cand_2prong::DecayChannelMain::D0ToPiK) {
2036-
if (ConfD0Selection.yD0D0barCandGenMax >= 0. && std::abs(RecoDecay::y(particle.pVector(), o2::constants::physics::MassD0)) > ConfD0Selection.yD0D0barCandGenMax) {
2037-
continue;
2038-
}
2039-
if (particle.originMcGen() == RecoDecay::OriginType::Prompt) {
2040-
ptGenB = -1;
2041-
} else {
2042-
ptGenB = mcParts.rawIteratorAt(particle.idxBhadMotherPart()).pt();
2043-
}
2044-
outputParts(outputCollision.lastIndex(),
2045-
particle.pt(),
2046-
particle.eta(),
2047-
particle.phi(),
2048-
aod::femtouniverseparticle::ParticleType::kMCTruthTrack,
2049-
-999.,
2050-
pdgCode,
2051-
pdgCode, // getter tempFitVar
2052-
childIDs,
2053-
particle.flagMcMatchGen(),
2054-
ptGenB); // pT of the B hadron (mother particle, only when non-prompt D0)
2055-
}
2056-
} else {
2057-
outputParts(outputCollision.lastIndex(),
2058-
particle.pt(),
2059-
particle.eta(),
2060-
particle.phi(),
2061-
aod::femtouniverseparticle::ParticleType::kMCTruthTrack,
2062-
-999.,
2063-
pdgCode,
2064-
pdgCode,
2065-
childIDs,
2066-
-999.,
2067-
-999.);
2017+
/// check if we end-up with the correct final state using MC info
2018+
int8_t sign = 0;
2019+
int8_t origin = -99;
2020+
int8_t mcGenFlag = -99;
2021+
if (std::abs(particle.pdgCode()) == Pdg::kD0 && !RecoDecay::isMatchedMCGen(mcParts, particle, Pdg::kD0, std::array{+kPiPlus, -kKPlus}, true, &sign)) {
2022+
/// check if we have D0(bar) → π± K∓
2023+
continue;
2024+
}
2025+
if (std::abs(particle.pdgCode()) == Pdg::kD0) {
2026+
origin = RecoDecay::getCharmHadronOrigin(mcParts, particle);
2027+
mcGenFlag = particle.flagMcMatchGen();
20682028
}
2029+
2030+
outputParts(outputCollision.lastIndex(),
2031+
particle.pt(),
2032+
particle.eta(),
2033+
particle.phi(),
2034+
aod::femtouniverseparticle::ParticleType::kMCTruthTrack,
2035+
-999.,
2036+
pdgCode,
2037+
pdgCode, // getter tempFitVar
2038+
childIDs,
2039+
mcGenFlag,
2040+
origin); // D0(bar) origin
2041+
20692042
if (confIsDebug) {
20702043
fillDebugParticle<false, true, false>(particle);
20712044
}
@@ -2074,7 +2047,7 @@ struct FemtoUniverseProducerTask {
20742047
// aligned, so that they can be joined in the task.
20752048
if constexpr (transientLabels) {
20762049
outputPartsMCLabels(-1);
2077-
outputDebugPartsMC(9999);
2050+
outputDebugPartsMC(-999);
20782051
}
20792052
}
20802053
}
@@ -2534,7 +2507,6 @@ struct FemtoUniverseProducerTask {
25342507
aod::McParticles const& mcParts)
25352508
{
25362509
// MC Reco
2537-
std::set<int> recoMcIds;
25382510
for (const auto& col : collisions) {
25392511
auto groupedTracks = tracks.sliceBy(perCollisionTracks, col.globalIndex());
25402512
auto groupedD0s = hfMcRecoCands.sliceBy(perCollisionD0s, col.globalIndex());
@@ -2545,18 +2517,14 @@ struct FemtoUniverseProducerTask {
25452517
if (colcheck) {
25462518
fillTracks<true>(groupedTracks);
25472519
fillD0D0barMcMl<true>(col, groupedTracks, groupedD0s, mcParts);
2548-
for (const auto& track : groupedTracks) {
2549-
if (trackCuts.isSelectedMinimal(track))
2550-
recoMcIds.insert(track.mcParticleId());
2551-
}
25522520
}
25532521
}
25542522
// MC Truth
25552523
for (const auto& mccol : mccols) {
25562524
auto groupedMCParticles = hfMcGenCands.sliceBy(mcPartPerMcColl, mccol.globalIndex());
25572525
auto groupedCollisions = collisions.sliceBy(recoCollsPerMCColl, mccol.globalIndex());
2558-
fillMCTruthCollisions(groupedCollisions, groupedMCParticles); // fills the reco collisions for mc collision
2559-
fillMCTruthParticlesD0<decltype(groupedMCParticles), true>(groupedMCParticles, recoMcIds); // fills mc particles
2526+
fillMCTruthCollisions(groupedCollisions, groupedMCParticles); // fills the reco collisions for mc collision
2527+
fillMCTruthParticlesD0<decltype(groupedMCParticles), true>(groupedMCParticles); // fills mc particles
25602528
}
25612529
}
25622530
PROCESS_SWITCH(FemtoUniverseProducerTask, processTrackD0MC, "Provide MC data for track D0 analysis", false);

PWGCF/FemtoUniverse/Tasks/femtoUniversePairTaskTrackD0.cxx

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1252,9 +1252,9 @@ struct FemtoUniversePairTaskTrackD0 {
12521252
if (pdgCode == o2::constants::physics::Pdg::kD0) {
12531253
if (std::abs(hfFlagMcGen) == o2::hf_decay::hf_cand_2prong::DecayChannelMain::D0ToPiK) {
12541254
mcTruthRegistry.fill(HIST("hMcGenD0"), part.pt(), part.eta());
1255-
if (part.mAntiLambda() > 0) {
1255+
if (part.mAntiLambda() == 1) {
12561256
mcTruthRegistry.fill(HIST("hMcGenD0Prompt"), part.pt(), part.eta());
1257-
} else {
1257+
} else if (part.mAntiLambda() == 2) {
12581258
mcTruthRegistry.fill(HIST("hMcGenD0NonPrompt"), part.pt(), part.eta());
12591259
}
12601260
}
@@ -1278,9 +1278,9 @@ struct FemtoUniversePairTaskTrackD0 {
12781278
if (pdgCode == o2::constants::physics::Pdg::kD0Bar) {
12791279
if (std::abs(hfFlagMcGen) == o2::hf_decay::hf_cand_2prong::DecayChannelMain::D0ToPiK) {
12801280
mcTruthRegistry.fill(HIST("hMcGenD0bar"), part.pt(), part.eta());
1281-
if (part.mAntiLambda() > 0) {
1281+
if (part.mAntiLambda() == 1) {
12821282
mcTruthRegistry.fill(HIST("hMcGenD0barPrompt"), part.pt(), part.eta());
1283-
} else {
1283+
} else if (part.mAntiLambda() == 2) {
12841284
mcTruthRegistry.fill(HIST("hMcGenD0barNonPrompt"), part.pt(), part.eta());
12851285
}
12861286
}

0 commit comments

Comments
 (0)