Skip to content

Commit dfa7530

Browse files
committed
btvNano: fix link between GenCands and decayed hadrons
1 parent 043863c commit dfa7530

File tree

1 file changed

+12
-3
lines changed

1 file changed

+12
-3
lines changed

PhysicsTools/NanoAOD/plugins/GenCandMotherTableProducer.cc

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -42,10 +42,19 @@ class GenCandMotherTableProducer : public edm::global::EDProducer<> {
4242
reco::GenParticleRef motherRef = cands->at(i).motherRef();
4343
reco::GenParticleRef match = (*map)[motherRef];
4444

45-
if (match.isNull())
46-
continue;
45+
if (match.isNonnull())
46+
key[i] = match.key();
47+
else {
48+
key[i] = -1;
49+
// try to find the closest mother which is in the map
50+
while (match.isNull() && motherRef.isNonnull()) {
51+
motherRef = motherRef->motherRef();
52+
match = (*map)[motherRef];
53+
if (match.isNonnull())
54+
key[i] = match.key();
55+
}
56+
}
4757

48-
key[i] = match.key();
4958
fromB[i] = isFromB(cands->at(i));
5059
fromC[i] = isFromC(cands->at(i));
5160
}

0 commit comments

Comments
 (0)