Skip to content

Commit

Permalink
Update on Kaon analysis.
Browse files Browse the repository at this point in the history
  • Loading branch information
mtorresc15 committed Sep 7, 2024
1 parent 76fe9fc commit b02b4f7
Showing 1 changed file with 73 additions and 73 deletions.
146 changes: 73 additions & 73 deletions PWGLF/Tasks/Nuspex/KaonAnalysis.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -57,85 +57,85 @@ std::array<std::shared_ptr<TH2>, NpCharge> hDcaXYWrongCollisionMat;
class RecoDecay
{
public:
/// Default constructor
RecoDecay() = default;

/// Default destructor
~RecoDecay() = default;

// mapping of charm-hadron origin type
enum OriginType { None = 0,
Prompt,
NonPrompt };

template <typename T>
static int getCharmHadronOrigin(const T& particlesMC,
const typename T::iterator& particle,
const bool searchUpToQuark = false)
{
int stage = 0; // mother tree level (just for debugging)

// vector of vectors with mother indices; each line corresponds to a "stage"
std::vector<std::vector<int64_t>> arrayIds{};
std::vector<int64_t> initVec{particle.globalIndex()};
arrayIds.push_back(initVec); // the first vector contains the index of the original particle
auto PDGParticle = std::abs(particle.pdgCode());
bool couldBePrompt = false;
if (PDGParticle / 100 == 4 || PDGParticle / 1000 == 4) {
couldBePrompt = true;
}
while (arrayIds[-stage].size() > 0) {
// vector of mother indices for the current stage
std::vector<int64_t> arrayIdsStage{};
for (auto& iPart : arrayIds[-stage]) { // check all the particles that were the mothers at the previous stage
auto particleMother = particlesMC.rawIteratorAt(iPart - particlesMC.offset());
if (particleMother.has_mothers()) {
for (auto iMother = particleMother.mothersIds().front(); iMother <= particleMother.mothersIds().back(); ++iMother) { // loop over the mother particles of the analysed particle
if (std::find(arrayIdsStage.begin(), arrayIdsStage.end(), iMother) != arrayIdsStage.end()) { // if a mother is still present in the vector, do not check it again
continue;
/// Default constructor
RecoDecay() = default;

/// Default destructor
~RecoDecay() = default;

// mapping of charm-hadron origin type
enum OriginType { None = 0,
Prompt,
NonPrompt };

template <typename T>
static int getCharmHadronOrigin(const T& particlesMC,
const typename T::iterator& particle,
const bool searchUpToQuark = false)
{
int stage = 0; // mother tree level (just for debugging)

// vector of vectors with mother indices; each line corresponds to a "stage"
std::vector<std::vector<int64_t>> arrayIds{};
std::vector<int64_t> initVec{particle.globalIndex()};
arrayIds.push_back(initVec); // the first vector contains the index of the original particle
auto PDGParticle = std::abs(particle.pdgCode());
bool couldBePrompt = false;
if (PDGParticle / 100 == 4 || PDGParticle / 1000 == 4) {
couldBePrompt = true;
}
while (arrayIds[-stage].size() > 0) {
// vector of mother indices for the current stage
std::vector<int64_t> arrayIdsStage{};
for (auto& iPart : arrayIds[-stage]) { // check all the particles that were the mothers at the previous stage
auto particleMother = particlesMC.rawIteratorAt(iPart - particlesMC.offset());
if (particleMother.has_mothers()) {
for (auto iMother = particleMother.mothersIds().front(); iMother <= particleMother.mothersIds().back(); ++iMother) { // loop over the mother particles of the analysed particle
if (std::find(arrayIdsStage.begin(), arrayIdsStage.end(), iMother) != arrayIdsStage.end()) { // if a mother is still present in the vector, do not check it again
continue;
}
auto mother = particlesMC.rawIteratorAt(iMother - particlesMC.offset());
// Check mother's PDG code.
auto PDGParticleIMother = std::abs(mother.pdgCode()); // PDG code of the mother
// printf("getMother: ");
// for (int i = stage; i < 0; i++) // Indent to make the tree look nice.
// printf(" ");
// printf("Stage %d: Mother PDG: %d, Index: %d\n", stage, PDGParticleIMother, iMother);

if (searchUpToQuark) {
if (PDGParticleIMother == 5) { // b quark
return OriginType::NonPrompt;
}
auto mother = particlesMC.rawIteratorAt(iMother - particlesMC.offset());
// Check mother's PDG code.
auto PDGParticleIMother = std::abs(mother.pdgCode()); // PDG code of the mother
// printf("getMother: ");
// for (int i = stage; i < 0; i++) // Indent to make the tree look nice.
// printf(" ");
// printf("Stage %d: Mother PDG: %d, Index: %d\n", stage, PDGParticleIMother, iMother);

if (searchUpToQuark) {
if (PDGParticleIMother == 5) { // b quark
return OriginType::NonPrompt;
}
if (PDGParticleIMother == 4) { // c quark
return OriginType::Prompt;
}
} else {
if (
(PDGParticleIMother / 100 == 5 || // b mesons
PDGParticleIMother / 1000 == 5) // b baryons
) {
return OriginType::NonPrompt;
}
if (
(PDGParticleIMother / 100 == 4 || // c mesons
PDGParticleIMother / 1000 == 4) // c baryons
) {
couldBePrompt = true;
}
if (PDGParticleIMother == 4) { // c quark
return OriginType::Prompt;
}
} else {
if (
(PDGParticleIMother / 100 == 5 || // b mesons
PDGParticleIMother / 1000 == 5) // b baryons
) {
return OriginType::NonPrompt;
}
if (
(PDGParticleIMother / 100 == 4 || // c mesons
PDGParticleIMother / 1000 == 4) // c baryons
) {
couldBePrompt = true;
}
// add mother index in the vector for the current stage
arrayIdsStage.push_back(iMother);
}
// add mother index in the vector for the current stage
arrayIdsStage.push_back(iMother);
}
}
// add vector of mother indices for the current stage
arrayIds.push_back(arrayIdsStage);
stage--;
}
if (!searchUpToQuark && couldBePrompt) { // Returns prompt if it's a charm hadron or a charm-hadron daughter. Note: 1) LF decay particles from cases like -> Lc -> p K0S, K0S -> pi pi are marked as prompt. 2) if particles from HF parton showers have to be searched, switch to option "search up to quark"
return OriginType::Prompt;
}
return OriginType::None;
// add vector of mother indices for the current stage
arrayIds.push_back(arrayIdsStage);
stage--;
}
if (!searchUpToQuark && couldBePrompt) { // Returns prompt if it's a charm hadron or a charm-hadron daughter. Note: 1) LF decay particles from cases like -> Lc -> p K0S, K0S -> pi pi are marked as prompt. 2) if particles from HF parton showers have to be searched, switch to option "search up to quark"
return OriginType::Prompt;
}
return OriginType::None;
}
};

Expand Down

0 comments on commit b02b4f7

Please sign in to comment.