@@ -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
0 commit comments