Skip to content

Commit d8200ca

Browse files
committed
Allow stopping before reaching partonic level in RecoDecay::getMother
1 parent 0f67c3b commit d8200ca

1 file changed

Lines changed: 10 additions & 3 deletions

File tree

Common/Core/RecoDecay.h

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -569,14 +569,16 @@ struct RecoDecay {
569569
/// \param acceptAntiParticles switch to accept the antiparticle of the expected mother
570570
/// \param sign antiparticle indicator of the found mother w.r.t. pdgMother; 1 if particle, -1 if antiparticle, 0 if mother not found
571571
/// \param depthMax maximum decay tree level to check; Mothers up to this level will be considered. If -1, all levels are considered.
572+
/// \param searchUpToQuark switch to stop searching for mothers when a quark or boson is found
572573
/// \return index of the mother particle if found, -1 otherwise
573574
template <bool acceptFlavourOscillation = false, typename T>
574575
static int getMother(const T& particlesMC,
575576
const typename T::iterator& particle,
576577
int pdgMother,
577578
bool acceptAntiParticles = false,
578579
int8_t* sign = nullptr,
579-
int8_t depthMax = -1)
580+
int8_t depthMax = -1,
581+
const bool searchUpToQuark = true)
580582
{
581583
int8_t sgn = 0; // 1 if the expected mother is particle, -1 if antiparticle (w.r.t. pdgMother)
582584
int indexMother = -1; // index of the final matched mother, if found
@@ -597,13 +599,18 @@ struct RecoDecay {
597599
for (auto iPart : arrayIds[-stage]) { // check all the particles that were the mothers at the previous stage, o2-linter: disable=const-ref-in-for-loop (int elements)
598600
auto particleMother = particlesMC.rawIteratorAt(iPart - particlesMC.offset());
599601
if (particleMother.has_mothers()) {
600-
for (auto iMother = particleMother.mothersIds().front(); iMother <= particleMother.mothersIds().back(); ++iMother) { // loop over the mother particles of the analysed particle
601-
if (std::find(arrayIdsStage.begin(), arrayIdsStage.end(), iMother) != arrayIdsStage.end()) { // if a mother is still present in the vector, do not check it again
602+
// If searchUpToQuark is false we only take the first mother (since decay products only have one mother)
603+
auto lastMotherIdxToCheck = searchUpToQuark ? particleMother.mothersIds().back() : particleMother.mothersIds().front();
604+
for (auto iMother = particleMother.mothersIds().front(); iMother <= lastMotherIdxToCheck; ++iMother) { // loop over the mother particles of the analysed particle
605+
if (std::find(arrayIdsStage.begin(), arrayIdsStage.end(), iMother) != arrayIdsStage.end()) { // if a mother is still present in the vector, do not check it again
602606
continue;
603607
}
604608
auto mother = particlesMC.rawIteratorAt(iMother - particlesMC.offset());
605609
// Check mother's PDG code.
606610
auto pdgParticleIMother = mother.pdgCode(); // PDG code of the mother
611+
if (!searchUpToQuark && (std::abs(pdgParticleIMother) <= PdgQuarkMax || (std::abs(pdgParticleIMother) >= PdgBosonMin && std::abs(pdgParticleIMother) <= PdgBosonMax))) {
612+
continue;
613+
}
607614
// printf("getMother: ");
608615
// for (int i = stage; i < 0; i++) // Indent to make the tree look nice.
609616
// printf(" ");

0 commit comments

Comments
 (0)