Skip to content

Commit 5f8d296

Browse files
authored
RecoDecay::getMother: Catch wrong mothers from Run 2 (#857)
1 parent d107366 commit 5f8d296

1 file changed

Lines changed: 14 additions & 4 deletions

File tree

Common/Core/RecoDecay.h

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -582,18 +582,28 @@ class RecoDecay
582582
if (sign) {
583583
*sign = sgn;
584584
}
585+
std::vector<int> listId;
586+
listId.push_back(particleMother.globalIndex());
585587
while (particleMother.has_mothers()) {
586588
if (depthMax > -1 && -stage >= depthMax) { // Maximum depth has been reached.
587589
return -1;
588590
}
591+
if (particleMother.mothersIds()[0] == -1) { // Additional check for converted Run 2 MC
592+
return -1;
593+
}
589594
particleMother = particleMother.template mothers_first_as<typename std::decay_t<T>::parent_t>(); // get mother 0
590595
auto indexMotherTmp = particleMother.globalIndex();
591596
// Check mother's PDG code.
592597
auto PDGParticleIMother = particleMother.pdgCode(); // PDG code of the mother
593-
//printf("getMother: ");
594-
//for (int i = stage; i < 0; i++) // Indent to make the tree look nice.
595-
// printf(" ");
596-
//printf("Stage %d: Mother PDG: %d\n", stage, PDGParticleIMother);
598+
// printf("getMother: ");
599+
// for (int i = stage; i < 0; i++) // Indent to make the tree look nice.
600+
// printf(" ");
601+
// printf("Stage %d: Mother PDG: %d, Index: %d\n", stage, PDGParticleIMother, indexMotherTmp);
602+
if (std::find(listId.begin(), listId.end(), indexMotherTmp) != listId.end()) {
603+
LOGF(fatal, "Circular mothership at particle index %d", indexMotherTmp);
604+
return -1;
605+
}
606+
listId.push_back(indexMotherTmp);
597607
if (PDGParticleIMother == PDGMother) { // exact PDG match
598608
sgn = 1;
599609
indexMother = indexMotherTmp;

0 commit comments

Comments
 (0)