Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
35 commits
Select commit Hold shift + click to select a range
904f8c8
Consider only particles coming from decay process when matching
ZFederica Mar 28, 2024
446493e
Please consider the following formatting changes
alibuild Mar 28, 2024
f2965bd
Merge pull request #69 from alibuild/alibot-cleanup-5407
ZFederica Mar 28, 2024
e46fb24
Move a check
ZFederica Mar 28, 2024
bf036a5
Please consider the following formatting changes
alibuild Mar 28, 2024
33aa9ff
Merge pull request #70 from alibuild/alibot-cleanup-5407
ZFederica Mar 28, 2024
d21d0a5
Fix a process check
ZFederica Mar 28, 2024
196b336
Remove comment
ZFederica Mar 28, 2024
dd37787
Add template keyword
ZFederica Mar 28, 2024
17a7ea5
Fix namespace
ZFederica Mar 28, 2024
8311b7e
Add missing include
ZFederica Mar 28, 2024
44a90a4
Remove header
ZFederica Apr 8, 2024
6744029
Remove hard-coded table
ZFederica Apr 8, 2024
4cde3ad
Re-arrange
ZFederica Apr 8, 2024
ca04300
Remove comment
ZFederica Apr 8, 2024
12cdd82
Please consider the following formatting changes
alibuild Apr 8, 2024
8c459c2
Merge pull request #71 from alibuild/alibot-cleanup-5407
ZFederica Apr 8, 2024
a6a9098
Change cast
ZFederica Apr 9, 2024
0f47ee3
Implement requested changes
ZFederica Apr 10, 2024
0249a02
Remove TMCProcess
ZFederica Apr 10, 2024
2e55c9c
Change implementation
ZFederica Apr 11, 2024
b5396fb
Clean
ZFederica Apr 11, 2024
6cdb0ed
Final changes
ZFederica Apr 11, 2024
4be2df4
Please consider the following formatting changes
alibuild Apr 11, 2024
c372e14
Merge pull request #72 from alibuild/alibot-cleanup-5407
ZFederica Apr 11, 2024
99d664f
Clean
ZFederica Apr 12, 2024
4972243
Requested changes
ZFederica Apr 12, 2024
f1e0ecf
Latest implementation
ZFederica Apr 12, 2024
b241254
Please consider the following formatting changes
alibuild Apr 12, 2024
cc82aee
Merge pull request #73 from alibuild/alibot-cleanup-5407
ZFederica Apr 12, 2024
7c0d654
Update Common/Core/RecoDecay.h
ZFederica Apr 15, 2024
db33b8e
Implement requested changes
ZFederica Apr 15, 2024
fffd20d
Please consider the following formatting changes
alibuild Apr 15, 2024
e046b18
Merge pull request #74 from alibuild/alibot-cleanup-5407
ZFederica Apr 15, 2024
a1f06a8
Change doc order
ZFederica Apr 15, 2024
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
44 changes: 30 additions & 14 deletions Common/Core/RecoDecay.h
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
#include <utility> // std::move
#include <vector> // std::vector

#include "TMCProcess.h" // for VMC Particle Production Process
#include "CommonConstants/MathConstants.h"

/// Base class for calculating properties of reconstructed decays
Expand Down Expand Up @@ -595,14 +596,15 @@ class RecoDecay
}

/// Gets the complete list of indices of final-state daughters of an MC particle.
/// \param checkProcess switch to accept only decay daughters by checking the production process of MC particles
/// \param particle MC particle
/// \param list vector where the indices of final-state daughters will be added
/// \param arrPDGFinal array of PDG codes of particles to be considered final if found
/// \param depthMax maximum decay tree level; Daughters at this level (or beyond) will be considered final. If -1, all levels are considered.
/// \param stage decay tree level; If different from 0, the particle itself will be added in the list in case it has no daughters.
/// \note Final state is defined as particles from arrPDGFinal plus final daughters of any other decay branch.
/// \note Antiparticles of particles in arrPDGFinal are accepted as well.
template <std::size_t N, typename T>
template <bool checkProcess = false, std::size_t N, typename T>
static void getDaughters(const T& particle,
std::vector<int>* list,
const std::array<int, N>& arrPDGFinal,
Expand All @@ -613,6 +615,13 @@ class RecoDecay
// Printf("getDaughters: Error: No list!");
return;
}
if constexpr (checkProcess) {
// If the particle is neither the original particle nor coming from a decay, we do nothing and exit.
if (stage != 0 && particle.getProcess() != TMCProcess::kPDecay && particle.getProcess() != TMCProcess::kPPrimary) { // decay products of HF hadrons are labeled as kPPrimary
return;
}
}

bool isFinal = false; // Flag to indicate the end of recursion
if (depthMax > -1 && stage >= depthMax) { // Maximum depth has been reached (or exceeded).
isFinal = true;
Expand Down Expand Up @@ -655,11 +664,12 @@ class RecoDecay
// Call itself to get daughters of daughters recursively.
stage++;
for (auto& dau : particle.template daughters_as<typename std::decay_t<T>::parent_t>()) {
getDaughters(dau, list, arrPDGFinal, depthMax, stage);
getDaughters<checkProcess>(dau, list, arrPDGFinal, depthMax, stage);
}
}

/// Checks whether the reconstructed decay candidate is the expected decay.
/// \param checkProcess switch to accept only decay daughters by checking the production process of MC particles
/// \param particlesMC table with MC particles
/// \param arrDaughters array of candidate daughters
/// \param PDGMother expected mother PDG code
Expand All @@ -668,7 +678,7 @@ class RecoDecay
/// \param sign antiparticle indicator of the found mother w.r.t. PDGMother; 1 if particle, -1 if antiparticle, 0 if mother not found
/// \param depthMax maximum decay tree level to check; Daughters up to this level will be considered. If -1, all levels are considered.
/// \return index of the mother particle if the mother and daughters are correct, -1 otherwise
template <bool acceptFlavourOscillation = false, std::size_t N, typename T, typename U>
template <bool acceptFlavourOscillation = false, bool checkProcess = false, std::size_t N, typename T, typename U>
static int getMatchedMCRec(const T& particlesMC,
const std::array<U, N>& arrDaughters,
int PDGMother,
Expand Down Expand Up @@ -724,12 +734,14 @@ class RecoDecay
return -1;
}
// Check that the number of direct daughters is not larger than the number of expected final daughters.
if (particleMother.daughtersIds().back() - particleMother.daughtersIds().front() + 1 > static_cast<int>(N)) {
// Printf("MC Rec: Rejected: too many direct daughters: %d (expected %ld final)", particleMother.daughtersIds().back() - particleMother.daughtersIds().front() + 1, N);
return -1;
if constexpr (!checkProcess) {
if (particleMother.daughtersIds().back() - particleMother.daughtersIds().front() + 1 > static_cast<int>(N)) {
// Printf("MC Rec: Rejected: too many direct daughters: %d (expected %ld final)", particleMother.daughtersIds().back() - particleMother.daughtersIds().front() + 1, N);
return -1;
}
}
// Get the list of actual final daughters.
getDaughters(particleMother, &arrAllDaughtersIndex, arrPDGDaughters, depthMax);
getDaughters<checkProcess>(particleMother, &arrAllDaughtersIndex, arrPDGDaughters, depthMax);
// printf("MC Rec: Mother %d has %d final daughters:", indexMother, arrAllDaughtersIndex.size());
// for (auto i : arrAllDaughtersIndex) {
// printf(" %d", i);
Expand Down Expand Up @@ -779,24 +791,26 @@ class RecoDecay
}

/// Checks whether the MC particle is the expected one.
/// \param checkProcess switch to accept only decay daughters by checking the production process of MC particles
/// \param particlesMC table with MC particles
/// \param candidate candidate MC particle
/// \param PDGParticle expected particle PDG code
/// \param acceptAntiParticles switch to accept the antiparticle
/// \param sign antiparticle indicator of the candidate w.r.t. PDGParticle; 1 if particle, -1 if antiparticle, 0 if not matched
/// \return true if PDG code of the particle is correct, false otherwise
template <bool acceptFlavourOscillation = false, typename T, typename U>
template <bool acceptFlavourOscillation = false, bool checkProcess = false, typename T, typename U>
static int isMatchedMCGen(const T& particlesMC,
const U& candidate,
int PDGParticle,
bool acceptAntiParticles = false,
int8_t* sign = nullptr)
{
std::array<int, 0> arrPDGDaughters;
return isMatchedMCGen<acceptFlavourOscillation>(particlesMC, candidate, PDGParticle, std::move(arrPDGDaughters), acceptAntiParticles, sign);
return isMatchedMCGen<acceptFlavourOscillation, checkProcess>(particlesMC, candidate, PDGParticle, std::move(arrPDGDaughters), acceptAntiParticles, sign);
}

/// Check whether the MC particle is the expected one and whether it decayed via the expected decay channel.
/// \param checkProcess switch to accept only decay daughters by checking the production process of MC particles
/// \param particlesMC table with MC particles
/// \param candidate candidate MC particle
/// \param PDGParticle expected particle PDG code
Expand All @@ -806,7 +820,7 @@ class RecoDecay
/// \param depthMax maximum decay tree level to check; Daughters up to this level will be considered. If -1, all levels are considered.
/// \param listIndexDaughters vector of indices of found daughter
/// \return true if PDG codes of the particle and its daughters are correct, false otherwise
template <bool acceptFlavourOscillation = false, std::size_t N, typename T, typename U>
template <bool acceptFlavourOscillation = false, bool checkProcess = false, std::size_t N, typename T, typename U>
static bool isMatchedMCGen(const T& particlesMC,
const U& candidate,
int PDGParticle,
Expand Down Expand Up @@ -843,12 +857,14 @@ class RecoDecay
return false;
}
// Check that the number of direct daughters is not larger than the number of expected final daughters.
if (candidate.daughtersIds().back() - candidate.daughtersIds().front() + 1 > static_cast<int>(N)) {
// Printf("MC Gen: Rejected: too many direct daughters: %d (expected %ld final)", candidate.daughtersIds().back() - candidate.daughtersIds().front() + 1, N);
return false;
if constexpr (!checkProcess) {
if (candidate.daughtersIds().back() - candidate.daughtersIds().front() + 1 > static_cast<int>(N)) {
// Printf("MC Gen: Rejected: too many direct daughters: %d (expected %ld final)", candidate.daughtersIds().back() - candidate.daughtersIds().front() + 1, N);
return false;
}
}
// Get the list of actual final daughters.
getDaughters(candidate, &arrAllDaughtersIndex, arrPDGDaughters, depthMax);
getDaughters<checkProcess>(candidate, &arrAllDaughtersIndex, arrPDGDaughters, depthMax);
// printf("MC Gen: Mother %ld has %ld final daughters:", candidate.globalIndex(), arrAllDaughtersIndex.size());
// for (auto i : arrAllDaughtersIndex) {
// printf(" %d", i);
Expand Down
26 changes: 14 additions & 12 deletions PWGHF/TableProducer/candidateCreatorToXiPi.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -355,6 +355,8 @@ struct HfCandidateCreatorToXiPiMc {
int indexRec = -1;
int indexRecCharmBaryon = -1;
int8_t sign = -9;
int8_t signCasc = -9;
int8_t signV0 = -9;
int8_t flag = 0;
int8_t origin = 0; // to be used for prompt/non prompt
int8_t debug = 0;
Expand Down Expand Up @@ -391,20 +393,20 @@ struct HfCandidateCreatorToXiPiMc {
// Omegac matching
if (matchOmegacMc) {
// Omegac → pi pi pi p
indexRec = RecoDecay::getMatchedMCRec(mcParticles, arrayDaughters, pdgCodeOmegac0, std::array{pdgCodePiPlus, pdgCodePiMinus, pdgCodeProton, pdgCodePiMinus}, true, &sign, 3);
indexRec = RecoDecay::getMatchedMCRec<false, true>(mcParticles, arrayDaughters, pdgCodeOmegac0, std::array{pdgCodePiPlus, pdgCodePiMinus, pdgCodeProton, pdgCodePiMinus}, true, &sign, 3);
indexRecCharmBaryon = indexRec;
if (indexRec == -1) {
debug = 1;
}
if (indexRec > -1) {
// Xi- → pi pi p
indexRec = RecoDecay::getMatchedMCRec(mcParticles, arrayDaughtersCasc, pdgCodeXiMinus, std::array{pdgCodePiMinus, pdgCodeProton, pdgCodePiMinus}, true, &sign, 2);
indexRec = RecoDecay::getMatchedMCRec<false, true>(mcParticles, arrayDaughtersCasc, pdgCodeXiMinus, std::array{pdgCodePiMinus, pdgCodeProton, pdgCodePiMinus}, true, &signCasc, 2);
if (indexRec == -1) {
debug = 2;
}
if (indexRec > -1) {
// Lambda → p pi
indexRec = RecoDecay::getMatchedMCRec(mcParticles, arrayDaughtersV0, pdgCodeLambda, std::array{pdgCodeProton, pdgCodePiMinus}, true, &sign, 1);
indexRec = RecoDecay::getMatchedMCRec<false, true>(mcParticles, arrayDaughtersV0, pdgCodeLambda, std::array{pdgCodeProton, pdgCodePiMinus}, true, &signV0, 1);
if (indexRec == -1) {
debug = 3;
}
Expand All @@ -424,20 +426,20 @@ struct HfCandidateCreatorToXiPiMc {
// Xic matching
if (matchXicMc) {
// Xic → pi pi pi p
indexRec = RecoDecay::getMatchedMCRec(mcParticles, arrayDaughters, pdgCodeXic0, std::array{pdgCodePiPlus, pdgCodePiMinus, pdgCodeProton, pdgCodePiMinus}, true, &sign, 3);
indexRec = RecoDecay::getMatchedMCRec<false, true>(mcParticles, arrayDaughters, pdgCodeXic0, std::array{pdgCodePiPlus, pdgCodePiMinus, pdgCodeProton, pdgCodePiMinus}, true, &sign, 3);
indexRecCharmBaryon = indexRec;
if (indexRec == -1) {
debug = 1;
}
if (indexRec > -1) {
// Xi- → pi pi p
indexRec = RecoDecay::getMatchedMCRec(mcParticles, arrayDaughtersCasc, pdgCodeXiMinus, std::array{pdgCodePiMinus, pdgCodeProton, pdgCodePiMinus}, true, &sign, 2);
indexRec = RecoDecay::getMatchedMCRec<false, true>(mcParticles, arrayDaughtersCasc, pdgCodeXiMinus, std::array{pdgCodePiMinus, pdgCodeProton, pdgCodePiMinus}, true, &signCasc, 2);
if (indexRec == -1) {
debug = 2;
}
if (indexRec > -1) {
// Lambda → p pi
indexRec = RecoDecay::getMatchedMCRec(mcParticles, arrayDaughtersV0, pdgCodeLambda, std::array{pdgCodeProton, pdgCodePiMinus}, true, &sign, 1);
indexRec = RecoDecay::getMatchedMCRec<false, true>(mcParticles, arrayDaughtersV0, pdgCodeLambda, std::array{pdgCodeProton, pdgCodePiMinus}, true, &signV0, 1);
if (indexRec == -1) {
debug = 3;
}
Expand Down Expand Up @@ -474,7 +476,7 @@ struct HfCandidateCreatorToXiPiMc {
origin = RecoDecay::OriginType::None;
if (matchOmegacMc) {
// Omegac → Xi pi
if (RecoDecay::isMatchedMCGen(mcParticles, particle, pdgCodeOmegac0, std::array{pdgCodeXiMinus, pdgCodePiPlus}, true, &sign)) {
if (RecoDecay::isMatchedMCGen<false, true>(mcParticles, particle, pdgCodeOmegac0, std::array{pdgCodeXiMinus, pdgCodePiPlus}, true, &sign)) {
debugGenCharmBar = 1;
ptCharmBaryonGen = particle.pt();
etaCharmBaryonGen = particle.eta();
Expand All @@ -483,14 +485,14 @@ struct HfCandidateCreatorToXiPiMc {
continue;
}
// Xi -> Lambda pi
if (RecoDecay::isMatchedMCGen(mcParticles, daughterCharm, pdgCodeXiMinus, std::array{pdgCodeLambda, pdgCodePiMinus}, true)) {
if (RecoDecay::isMatchedMCGen<false, true>(mcParticles, daughterCharm, pdgCodeXiMinus, std::array{pdgCodeLambda, pdgCodePiMinus}, true)) {
debugGenXi = 1;
for (const auto& daughterCascade : daughterCharm.daughters_as<aod::McParticles>()) {
if (std::abs(daughterCascade.pdgCode()) != pdgCodeLambda) {
continue;
}
// Lambda -> p pi
if (RecoDecay::isMatchedMCGen(mcParticles, daughterCascade, pdgCodeLambda, std::array{pdgCodeProton, pdgCodePiMinus}, true)) {
if (RecoDecay::isMatchedMCGen<false, true>(mcParticles, daughterCascade, pdgCodeLambda, std::array{pdgCodeProton, pdgCodePiMinus}, true)) {
debugGenLambda = 1;
flag = sign * (1 << aod::hf_cand_toxipi::DecayType::OmegaczeroToXiPi);
}
Expand All @@ -506,7 +508,7 @@ struct HfCandidateCreatorToXiPiMc {

if (matchXicMc) {
// Xic → Xi pi
if (RecoDecay::isMatchedMCGen(mcParticles, particle, pdgCodeXic0, std::array{pdgCodeXiMinus, pdgCodePiPlus}, true, &sign)) {
if (RecoDecay::isMatchedMCGen<false, true>(mcParticles, particle, pdgCodeXic0, std::array{pdgCodeXiMinus, pdgCodePiPlus}, true, &sign)) {
debugGenCharmBar = 1;
ptCharmBaryonGen = particle.pt();
etaCharmBaryonGen = particle.eta();
Expand All @@ -515,14 +517,14 @@ struct HfCandidateCreatorToXiPiMc {
continue;
}
// Xi -> Lambda pi
if (RecoDecay::isMatchedMCGen(mcParticles, daughterCharm, pdgCodeXiMinus, std::array{pdgCodeLambda, pdgCodePiMinus}, true)) {
if (RecoDecay::isMatchedMCGen<false, true>(mcParticles, daughterCharm, pdgCodeXiMinus, std::array{pdgCodeLambda, pdgCodePiMinus}, true)) {
debugGenXi = 1;
for (const auto& daughterCascade : daughterCharm.daughters_as<aod::McParticles>()) {
if (std::abs(daughterCascade.pdgCode()) != pdgCodeLambda) {
continue;
}
// Lambda -> p pi
if (RecoDecay::isMatchedMCGen(mcParticles, daughterCascade, pdgCodeLambda, std::array{pdgCodeProton, pdgCodePiMinus}, true)) {
if (RecoDecay::isMatchedMCGen<false, true>(mcParticles, daughterCascade, pdgCodeLambda, std::array{pdgCodeProton, pdgCodePiMinus}, true)) {
debugGenLambda = 1;
flag = sign * (1 << aod::hf_cand_toxipi::DecayType::XiczeroToXiPi);
}
Expand Down