Skip to content

Commit 1d9d1cd

Browse files
authored
[PWGUD] Added configurable generatorIds in Mc[D,S]GCandProducer (#10427)
1 parent 1bba6d8 commit 1d9d1cd

File tree

2 files changed

+19
-7
lines changed

2 files changed

+19
-7
lines changed

PWGUD/TableProducer/DGCandProducer.cxx

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -473,6 +473,7 @@ struct McDGCandProducer {
473473
Produces<aod::UDMcTrackLabels> outputMcTrackLabels;
474474

475475
// save all McTruth, even if the collisions is not reconstructed
476+
Configurable<std::vector<int>> generatorIds{"generatorIds", std::vector<int>{-1}, "MC generatorIds to process"};
476477
Configurable<bool> saveAllMcCollisions{"saveAllMcCollisions", true, "save all McCollisions"};
477478

478479
using CCs = soa::Join<aod::Collisions, aod::EvSels, aod::McCollisionLabels>;
@@ -686,6 +687,7 @@ struct McDGCandProducer {
686687

687688
// loop over McCollisions and UDCCs simultaneously
688689
auto mccol = mccols.iteratorAt(0);
690+
auto mcOfInterest = std::find(generatorIds->begin(), generatorIds->end(), mccol.getGeneratorId()) != generatorIds->end();
689691
auto lastmccol = mccols.iteratorAt(mccols.size() - 1);
690692
auto mccolAtEnd = false;
691693

@@ -729,7 +731,9 @@ struct McDGCandProducer {
729731

730732
// If the dgcand has an associated McCollision then the McCollision and all associated
731733
// McParticles are saved
732-
if (mcdgId >= 0) {
734+
// but only consider generated events of interest
735+
if (mcdgId >= 0 && mcOfInterest) {
736+
733737
if (mcColIsSaved.find(mcdgId) == mcColIsSaved.end()) {
734738
// update UDMcCollisions
735739
LOGF(debug, " writing mcCollision %d to UDMcCollisions", mcdgId);
@@ -789,7 +793,8 @@ struct McDGCandProducer {
789793
// this is case 2.
790794

791795
// update UDMcCollisions and UDMcParticles
792-
if (mcColIsSaved.find(mccolId) == mcColIsSaved.end()) {
796+
// but only consider generated events of interest
797+
if (mcOfInterest && mcColIsSaved.find(mccolId) == mcColIsSaved.end()) {
793798

794799
// update UDMcCollisions
795800
LOGF(debug, " writing mcCollision %d to UDMcCollisions", mccolId);
@@ -804,6 +809,7 @@ struct McDGCandProducer {
804809
// advance mccol
805810
if (mccol != lastmccol) {
806811
mccol++;
812+
mcOfInterest = std::find(generatorIds->begin(), generatorIds->end(), mccol.getGeneratorId()) != generatorIds->end();
807813
mccolId = mccol.globalIndex();
808814
} else {
809815
mccolAtEnd = true;
@@ -826,8 +832,11 @@ struct McDGCandProducer {
826832

827833
// loop over McCollisions
828834
for (auto const& mccol : mccols) {
829-
int64_t mccolId = mccol.globalIndex();
835+
// only consider generated events of interest
836+
if (std::find(generatorIds->begin(), generatorIds->end(), mccol.getGeneratorId()) == generatorIds->end())
837+
continue;
830838

839+
int64_t mccolId = mccol.globalIndex();
831840
// update UDMcCollisions and UDMcParticles
832841
if (mcColIsSaved.find(mccolId) == mcColIsSaved.end()) {
833842

PWGUD/TableProducer/SGCandProducer.cxx

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -366,6 +366,7 @@ struct McSGCandProducer {
366366
Produces<aod::UDMcTrackLabels> outputMcTrackLabels;
367367

368368
// save all McTruth, even if the collisions is not reconstructed
369+
Configurable<std::vector<int>> generatorIds{"generatorIds", std::vector<int>{-1}, "MC generatorIds to process"};
369370
Configurable<bool> saveAllMcCollisions{"saveAllMcCollisions", true, "save all McCollisions"};
370371

371372
using CCs = soa::Join<aod::Collisions, aod::EvSels, aod::McCollisionLabels>;
@@ -555,6 +556,7 @@ struct McSGCandProducer {
555556

556557
// loop over McCollisions and UDCCs simultaneously
557558
auto mccol = mccols.iteratorAt(0);
559+
auto mcOfInterest = std::find(generatorIds->begin(), generatorIds->end(), mccol.getGeneratorId()) != generatorIds->end();
558560
auto lastmccol = mccols.iteratorAt(mccols.size() - 1);
559561
auto mccolAtEnd = false;
560562

@@ -565,7 +567,6 @@ struct McSGCandProducer {
565567
// advance dgcand and mccol until both are AtEnd
566568
int64_t mccolId = mccol.globalIndex();
567569
int64_t mcsgId = -1;
568-
569570
bool goon = true;
570571
while (goon) {
571572
auto globBC = mccol.bc_as<BCs>().globalBC();
@@ -599,7 +600,8 @@ struct McSGCandProducer {
599600

600601
// If the sgcand has an associated McCollision then the McCollision and all associated
601602
// McParticles are saved
602-
if (mcsgId >= 0) {
603+
// but only consider generated events of interest
604+
if (mcsgId >= 0 && mcOfInterest) {
603605
if (mcColIsSaved.find(mcsgId) == mcColIsSaved.end()) {
604606
if (verboseInfoMC)
605607
LOGF(info, " Saving McCollision %d", mcsgId);
@@ -662,10 +664,10 @@ struct McSGCandProducer {
662664
LOGF(info, "Doing case 2");
663665

664666
// update UDMcCollisions and UDMcParticles
665-
if (mcColIsSaved.find(mccolId) == mcColIsSaved.end()) {
667+
// but only consider generated events of interest
668+
if (mcOfInterest && mcColIsSaved.find(mccolId) == mcColIsSaved.end()) {
666669
if (verboseInfoMC)
667670
LOGF(info, " Saving McCollision %d", mccolId);
668-
669671
// update UDMcCollisions
670672
updateUDMcCollisions(mccol, globBC);
671673
mcColIsSaved[mccolId] = outputMcCollisions.lastIndex();
@@ -678,6 +680,7 @@ struct McSGCandProducer {
678680
// advance mccol
679681
if (mccol != lastmccol) {
680682
mccol++;
683+
mcOfInterest = std::find(generatorIds->begin(), generatorIds->end(), mccol.getGeneratorId()) != generatorIds->end();
681684
mccolId = mccol.globalIndex();
682685
} else {
683686
mccolAtEnd = true;

0 commit comments

Comments
 (0)