Skip to content

Commit

Permalink
Fix particle stack filling and mother/daughter indixing.
Browse files Browse the repository at this point in the history
  • Loading branch information
Mattia Faggin committed Jun 13, 2024
1 parent d2c8044 commit e4b0ede
Showing 1 changed file with 11 additions and 2 deletions.
13 changes: 11 additions & 2 deletions MC/config/PWGHF/external/generator/generator_pythia8_embed_hf.C
Original file line number Diff line number Diff line change
Expand Up @@ -81,13 +81,22 @@ Bool_t importParticles() override
/// generate the HF event
bool genOk = false;
while(!genOk) {
genOk = (mGeneratorEvHF->generateEvent());
genOk = (mGeneratorEvHF->generateEvent() && mGeneratorEvHF->importParticles() /*copy particles from mGeneratorEvHF.mPythia.event to mGeneratorEvHF.mParticles*/ );
}

/// copy the particles from the HF event in the particle stack
auto particlesHfEvent = mGeneratorEvHF->getParticles();
int originalSize = mParticles.size(); // stack of this event generator
for(int iPart=0; iPart<particlesHfEvent.size(); iPart++) {
mParticles.push_back(TParticle(particlesHfEvent.at(iPart)));
auto particle = particlesHfEvent.at(iPart);

/// adjust the particle mother and daughter indices
if(particle.GetFirstMother() >= 0) particle.SetFirstMother(particle.GetFirstMother() + originalSize);
if(particle.GetFirstDaughter() >= 0) particle.SetFirstDaughter(particle.GetFirstDaughter() + originalSize);
if(particle.GetLastDaughter() >= 0) particle.SetLastDaughter(particle.GetLastDaughter() + originalSize);

/// copy inside this.mParticles from mGeneratorEvHF.mParticles, i.e. the particles generated in mGeneratorEvHF
mParticles.push_back(particle);
}

/// one more event generated, let's update the counter and clear it, to allow the next generation
Expand Down

0 comments on commit e4b0ede

Please sign in to comment.