Skip to content
Merged
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
43 changes: 43 additions & 0 deletions PWGHF/HFC/TableProducer/producerCharmHadronsTrackFemtoDream.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@
#include <TMCProcess.h>
#include <TPDGCode.h>

#include <algorithm>
#include <array>
#include <chrono>
#include <cmath>
Expand Down Expand Up @@ -496,6 +497,44 @@ struct HfProducerCharmHadronsTrackFemtoDream {
-999., -999., -999.);
}

// Strong-decay kaons may be physical primaries, so inspect phi ancestry first.
template <typename T>
static bool hasPhiAncestor(T const& particles, typename T::iterator const& particle)
{
std::vector<int64_t> pending;
std::vector<int64_t> visited{particle.globalIndex()};
if (particle.has_mothers()) {
for (const auto id : particle.mothersIds()) {
pending.push_back(id);
}
}
while (!pending.empty()) {
const auto id = pending.back();
pending.pop_back();
if (id < static_cast<int64_t>(particles.offset()) ||
id - static_cast<int64_t>(particles.offset()) >= static_cast<int64_t>(particles.size()) ||
std::find(visited.begin(), visited.end(), id) != visited.end()) {
continue;
}
visited.push_back(id);
const auto mother = particles.rawIteratorAt(id - particles.offset());
const int absPdg = std::abs(mother.pdgCode());
if (absPdg == 333) {
return true;
}
// Stop at the partonic boundary of the hadron decay chain.
if (absPdg <= 100 || RecoDecay::isDiquark(absPdg)) {
continue;
}
if (mother.has_mothers()) {
for (const auto parentId : mother.mothersIds()) {
pending.push_back(parentId);
}
}
}
return false;
}

/// Classify true kaons from the correct collision for the DCA templates.
template <typename T>
static int getKaonOrigin(T const& particles, typename T::iterator const& particle)
Expand All @@ -509,6 +548,10 @@ struct HfProducerCharmHadronsTrackFemtoDream {
if (RecoDecay::getParticleOrigin(particles, particle) != RecoDecay::OriginType::None) {
return kSecondaryFromHF;
}
// Keep HF -> phi -> K in HF
if (hasPhiAncestor(particles, particle)) {
return kSecondaryFromPhi;
}
if (particle.isPhysicalPrimary()) {
return kPrimary;
}
Expand Down
Loading