Skip to content

Commit 0496b20

Browse files
committed
Fix mother and daughter indices in generator cocktails
Particles in a generated event carry indices to refer to mother and dauther particles. These indices need to be adjusted when we combine multiple events into a cocktail.
1 parent 66e56fe commit 0496b20

File tree

1 file changed

+20
-0
lines changed

1 file changed

+20
-0
lines changed

Generators/src/GeneratorHybrid.cxx

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -390,6 +390,26 @@ bool GeneratorHybrid::importParticles()
390390
for (auto subIndex : subGenIndex) {
391391
LOG(info) << "Importing particles for task " << subIndex;
392392
auto subParticles = gens[subIndex]->getParticles();
393+
394+
// The particles carry mother and daughter indices, which are relative
395+
// to the sub-generator. We need to adjust these indices to reflect that particles
396+
// are now embedded into a cocktail.
397+
auto offset = mParticles.size();
398+
for (auto& p : subParticles) {
399+
for (int i = 0; i < 2; ++i) {
400+
if (p.GetMother(i) != -1) {
401+
const auto newindex = p.GetMother(i) + offset;
402+
p.SetMother(i, newindex);
403+
}
404+
}
405+
if (p.GetNDaughters() > 0) {
406+
for (int i = 0; i < 2; ++i) {
407+
const auto newindex = p.GetDaughter(i) + offset;
408+
p.SetDaughter(i, newindex);
409+
}
410+
}
411+
}
412+
393413
mParticles.insert(mParticles.end(), subParticles.begin(), subParticles.end());
394414
// fetch the event Header information from the underlying generator
395415
gens[subIndex]->updateHeader(&mMCEventHeader);

0 commit comments

Comments
 (0)