Skip to content

Commit 61f6e21

Browse files
committed
FemtoUniverse: updating the MC checks for D0s
1 parent b246336 commit 61f6e21

File tree

4 files changed

+127
-148
lines changed

4 files changed

+127
-148
lines changed

PWGCF/FemtoUniverse/TableProducer/femtoUniverseProducerMCTruthTask.cxx

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

21+
#include "Common/Core/RecoDecay.h"
2122
#include "Common/CCDB/TriggerAliases.h"
2223
#include "Common/DataModel/EventSelection.h"
2324
#include "Common/DataModel/Multiplicity.h"
@@ -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: 32 additions & 61 deletions
Original file line numberDiff line numberDiff line change
@@ -331,7 +331,7 @@ struct FemtoUniverseProducerTask {
331331
Configurable<float> confD0D0barCandMaxY{"confD0D0barCandMaxY", -1., "max. cand. rapidity"};
332332
Configurable<float> confD0D0barCandEtaCut{"confD0D0barCandEtaCut", 0.8, "max. cand. pseudorapidity"};
333333
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."};
334+
Configurable<float> yD0D0barCandGenMax{"yD0D0barCandGenMax", -1., "MC Truth, max. rapidity of D0/D0bar cand."};
335335
Configurable<float> trackD0pTGenMin{"trackD0pTGenMin", 0.0, "MC Truth, min. pT for tracks and D0/D0bar cand."};
336336
Configurable<float> trackD0pTGenMax{"trackD0pTGenMax", 24.0, "MC Truth, max. pT for tracks and D0/D0bar cand."};
337337
Configurable<bool> storeD0D0barDoubleMassHypo{"storeD0D0barDoubleMassHypo", false, "Store D0/D0bar cand. which pass selection criteria for both, D0 and D0bar"};
@@ -1357,10 +1357,6 @@ struct FemtoUniverseProducerTask {
13571357
continue;
13581358
}
13591359

1360-
if (ConfD0Selection.confD0D0barCandMaxY >= 0. && std::abs(hfHelper.yD0(hfCand)) > ConfD0Selection.confD0D0barCandMaxY) {
1361-
continue;
1362-
}
1363-
13641360
if (std::abs(hfCand.eta()) > ConfD0Selection.confD0D0barCandEtaCut) {
13651361
continue;
13661362
}
@@ -1480,10 +1476,6 @@ struct FemtoUniverseProducerTask {
14801476
continue;
14811477
}
14821478

1483-
if (ConfD0Selection.confD0D0barCandMaxY >= 0. && std::abs(hfHelper.yD0(hfCand)) > ConfD0Selection.confD0D0barCandMaxY) {
1484-
continue;
1485-
}
1486-
14871479
if (std::abs(hfCand.eta()) > ConfD0Selection.confD0D0barCandEtaCut) {
14881480
continue;
14891481
}
@@ -1610,10 +1602,6 @@ struct FemtoUniverseProducerTask {
16101602
continue;
16111603
}
16121604

1613-
if (ConfD0Selection.confD0D0barCandMaxY >= 0. && std::abs(hfHelper.yD0(hfCand)) > ConfD0Selection.confD0D0barCandMaxY) {
1614-
continue;
1615-
}
1616-
16171605
if (std::abs(hfCand.eta()) > ConfD0Selection.confD0D0barCandEtaCut) {
16181606
continue;
16191607
}
@@ -1997,20 +1985,18 @@ struct FemtoUniverseProducerTask {
19971985
}
19981986

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

20061993
for (const auto& particle : mcParts) {
2007-
20081994
if (particle.eta() < -ConfFilterCuts.confEtaFilterCut || particle.eta() > ConfFilterCuts.confEtaFilterCut)
20091995
continue;
20101996
if (particle.pt() < ConfD0Selection.trackD0pTGenMin || particle.pt() > ConfD0Selection.trackD0pTGenMax)
20111997
continue;
20121998

2013-
uint32_t pdgCode = static_cast<uint32_t>(particle.pdgCode());
1999+
int pdgCode = particle.pdgCode();
20142000

20152001
if (ConfGeneral.confMCTruthAnalysisWithPID) {
20162002
bool pass = false;
@@ -2019,10 +2005,10 @@ struct FemtoUniverseProducerTask {
20192005
if (static_cast<int>(pdg) == static_cast<int>(pdgCode)) {
20202006
if (pdgCode == Pdg::kPhi) {
20212007
pass = true;
2022-
} else if (pdgCode == Pdg::kD0) {
2008+
} else if (std::abs(pdgCode) == Pdg::kD0) {
20232009
pass = true;
20242010
} else {
2025-
if (particle.isPhysicalPrimary() || (ConfGeneral.confActivateSecondaries && recoMcIds && recoMcIds->get().contains(particle.globalIndex())))
2011+
if (particle.isPhysicalPrimary())
20262012
pass = true;
20272013
}
20282014
}
@@ -2031,41 +2017,31 @@ struct FemtoUniverseProducerTask {
20312017
continue;
20322018
}
20332019

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.);
2020+
/// check if we end-up with the correct final state using MC info
2021+
int8_t sign = 0;
2022+
int8_t origin = -99;
2023+
int8_t mcGenFlag = -99;
2024+
if (std::abs(particle.pdgCode()) == Pdg::kD0 && !RecoDecay::isMatchedMCGen(mcParts, particle, Pdg::kD0, std::array{+kPiPlus, -kKPlus}, true, &sign)) {
2025+
/// check if we have D0(bar) → π± K∓
2026+
continue;
2027+
}
2028+
if (std::abs(particle.pdgCode()) == Pdg::kD0) {
2029+
origin = RecoDecay::getCharmHadronOrigin(mcParts, particle);
2030+
mcGenFlag = particle.flagMcMatchGen();
20682031
}
2032+
2033+
outputParts(outputCollision.lastIndex(),
2034+
particle.pt(),
2035+
particle.eta(),
2036+
particle.phi(),
2037+
aod::femtouniverseparticle::ParticleType::kMCTruthTrack,
2038+
-999.,
2039+
pdgCode,
2040+
pdgCode, // getter tempFitVar
2041+
childIDs,
2042+
mcGenFlag,
2043+
origin); // D0(bar) origin
2044+
20692045
if (confIsDebug) {
20702046
fillDebugParticle<false, true, false>(particle);
20712047
}
@@ -2074,7 +2050,7 @@ struct FemtoUniverseProducerTask {
20742050
// aligned, so that they can be joined in the task.
20752051
if constexpr (transientLabels) {
20762052
outputPartsMCLabels(-1);
2077-
outputDebugPartsMC(9999);
2053+
outputDebugPartsMC(-999);
20782054
}
20792055
}
20802056
}
@@ -2534,7 +2510,6 @@ struct FemtoUniverseProducerTask {
25342510
aod::McParticles const& mcParts)
25352511
{
25362512
// MC Reco
2537-
std::set<int> recoMcIds;
25382513
for (const auto& col : collisions) {
25392514
auto groupedTracks = tracks.sliceBy(perCollisionTracks, col.globalIndex());
25402515
auto groupedD0s = hfMcRecoCands.sliceBy(perCollisionD0s, col.globalIndex());
@@ -2545,18 +2520,14 @@ struct FemtoUniverseProducerTask {
25452520
if (colcheck) {
25462521
fillTracks<true>(groupedTracks);
25472522
fillD0D0barMcMl<true>(col, groupedTracks, groupedD0s, mcParts);
2548-
for (const auto& track : groupedTracks) {
2549-
if (trackCuts.isSelectedMinimal(track))
2550-
recoMcIds.insert(track.mcParticleId());
2551-
}
25522523
}
25532524
}
25542525
// MC Truth
25552526
for (const auto& mccol : mccols) {
25562527
auto groupedMCParticles = hfMcGenCands.sliceBy(mcPartPerMcColl, mccol.globalIndex());
25572528
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
2529+
fillMCTruthCollisions(groupedCollisions, groupedMCParticles); // fills the reco collisions for mc collision
2530+
fillMCTruthParticlesD0<decltype(groupedMCParticles), true>(groupedMCParticles); // fills mc particles
25602531
}
25612532
}
25622533
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)