Skip to content

Commit 1da45ee

Browse files
committed
Add protection
1 parent 972f232 commit 1da45ee

File tree

1 file changed

+9
-7
lines changed

1 file changed

+9
-7
lines changed

MC/config/PWGHF/ini/tests/GeneratorHF_D2H_ccbar_and_bbbar_gap5_DResoTrigger.C

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -82,13 +82,15 @@ int External() {
8282

8383
std::vector<int> pdgsDecay{};
8484
std::vector<int> pdgsDecayAntiPart{};
85-
for (int j{track.getFirstDaughterTrackId()}; j <= track.getLastDaughterTrackId(); ++j) {
86-
auto pdgDau = tracks->at(j).GetPdgCode();
87-
pdgsDecay.push_back(pdgDau);
88-
if (pdgDau != 333) { // phi is antiparticle of itself
89-
pdgsDecayAntiPart.push_back(-pdgDau);
90-
} else {
91-
pdgsDecayAntiPart.push_back(pdgDau);
85+
if (track.getFirstDaughterTrackId() >= 0 && track.getLastDaughterTrackId() >= 0) {
86+
for (int j{track.getFirstDaughterTrackId()}; j <= track.getLastDaughterTrackId(); ++j) {
87+
auto pdgDau = tracks->at(j).GetPdgCode();
88+
pdgsDecay.push_back(pdgDau);
89+
if (pdgDau != 333) { // phi is antiparticle of itself
90+
pdgsDecayAntiPart.push_back(-pdgDau);
91+
} else {
92+
pdgsDecayAntiPart.push_back(pdgDau);
93+
}
9294
}
9395
}
9496

0 commit comments

Comments
 (0)