Skip to content

Commit 5e114b9

Browse files
committed
Fix reassignment of mother indices after pruning HF events in embedding
1 parent 3418de0 commit 5e114b9

1 file changed

Lines changed: 21 additions & 17 deletions

File tree

MC/config/PWGHF/external/generator/generator_pythia8_embed_hf.C

Lines changed: 21 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -280,7 +280,7 @@ Bool_t importParticles() override
280280

281281
/// Establish if this particle comes from charm or beauty
282282
/// If not, ignore this particle and increase the number of discarded particles from the pp event
283-
if(!isFromCharmOrBeauty(iPart, particlesHfEvent)) {
283+
if(!(nEvsHF == 0 && iPart < 1) && !isFromCharmOrBeauty(iPart, particlesHfEvent)) {
284284
continue;
285285
}
286286
/// if we arrive here, then the current particle is from charm or beauty, keep it!
@@ -314,11 +314,13 @@ Bool_t importParticles() override
314314
idFirstMother = findKey(mapHfParticles, idFirstMother);
315315
/// If idFirstMother>=0, the 1st mother is from charm or beauty, i.e. is not a light-flavoured parton
316316
/// Instead, if idFirstMother==-1 from findKey this means that the first mother was a light-flavoured parton --> not stored in the map
317-
if(idFirstMother >=0) {
317+
if(idFirstMother >= 0) {
318318
/// the 1st mother is from charm or beauty, i.e. is not a light-flavoured parton
319319
if(idLastMother != idFirstMotherOrig) {
320-
if(idLastMother != -1) {
321-
/// idLastMother is >= 0
320+
idLastMother = findKey(mapHfParticles, idLastMother);
321+
if(idLastMother < 0) {
322+
// second mother not found, we set it to 0
323+
idLastMother = 0;
322324
}
323325
} else {
324326
/// idLastMother is equal to idFirstMother
@@ -343,15 +345,17 @@ Bool_t importParticles() override
343345
const int idMother = findKey(mapHfParticles, idMotherOrig);
344346
if(idMother >= 0) {
345347
/// this should mean that the mother is from HF, i.e. that we found the correct one
346-
idFirstMother = idMother;
347-
idLastMother = idFirstMother;
348+
if (idFirstMother < 0) {
349+
idFirstMother = idMother;
350+
}
351+
idLastMother = idMother;
348352
foundAnyMother = true;
349-
break;
350353
}
351354
}
352-
// set last mother to -1 if no mother has been found so far
355+
// set last mother to 0 if no mother has been found so far
353356
if (!foundAnyMother) {
354-
idLastMother = -1;
357+
idLastMother = 0;
358+
idFirstMother = 0;
355359
}
356360
}
357361

@@ -360,21 +364,21 @@ Bool_t importParticles() override
360364
idLastDaughter = findKey(mapHfParticles, idLastDaughter);
361365

362366
/// adjust the particle mother and daughter indices
363-
particle.SetFirstMother((idFirstMother >= 0) ? idFirstMother + offset : idFirstMother);
364-
particle.SetLastMother((idLastMother >= 0) ? idLastMother + offset : idLastMother);
365-
particle.SetFirstDaughter((idFirstDaughter >= 0) ? idFirstDaughter + offset : idFirstDaughter);
366-
particle.SetLastDaughter((idLastDaughter >= 0) ? idLastDaughter + offset : idLastDaughter);
367+
particle.SetFirstMother((idFirstMother > 0) ? idFirstMother + offset : idFirstMother);
368+
particle.SetLastMother((idLastMother > 0) ? idLastMother + offset : idLastMother);
369+
particle.SetFirstDaughter((idFirstDaughter > 0) ? idFirstDaughter + offset : idFirstDaughter);
370+
particle.SetLastDaughter((idLastDaughter > 0) ? idLastDaughter + offset : idLastDaughter);
367371

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

371375
}
372376

373377
// for debug
374-
// LOG(info) << "-----------------------------------------------";
375-
// LOG(info) << "============ After HF event " << nEvsHF;
376-
// LOG(info) << "Full stack:";
377-
// printParticleVector(mParticles);
378+
// LOG(info) << "-----------------------------------------------";
379+
// LOG(info) << "============ After HF event " << nEvsHF;
380+
// LOG(info) << "Full stack:";
381+
// printParticleVector(mParticles);
378382

379383
/// one more event generated, let's update the counter and clear it, to allow the next generation
380384
nEvsHF++;

0 commit comments

Comments
 (0)