@@ -52,6 +52,8 @@ struct McBuilderProducts : o2::framework::ProducesGroup {
5252 o2::framework::Produces<o2::aod::FTrackLabels> producedTrackLabels;
5353 o2::framework::Produces<o2::aod::FLambdaLabels> producedLambdaLabels;
5454 o2::framework::Produces<o2::aod::FK0shortLabels> producedK0shortLabels;
55+ o2::framework::Produces<o2::aod::FSigmaLabels> producedSigmaLabels;
56+ o2::framework::Produces<o2::aod::FSigmaPlusLabels> producedSigmaPlusLabels;
5557};
5658
5759struct ConfMcTables : o2::framework::ConfigurableGroup {
@@ -65,6 +67,8 @@ struct ConfMcTables : o2::framework::ConfigurableGroup {
6567 o2::framework::Configurable<int > producedTrackLabels{" producedTrackLabels" , -1 , " Produce track labels (-1: auto; 0 off; 1 on)" };
6668 o2::framework::Configurable<int > producedLambdaLabels{" producedLambdaLabels" , -1 , " Produce lambda labels (-1: auto; 0 off; 1 on)" };
6769 o2::framework::Configurable<int > producedK0shortLabels{" producedK0shortLabels" , -1 , " Produce k0short labels (-1: auto; 0 off; 1 on)" };
70+ o2::framework::Configurable<int > producedSigmaLabels{" producedSigmaLabels" , -1 , " Produce k0short labels (-1: auto; 0 off; 1 on)" };
71+ o2::framework::Configurable<int > producedSigmaPlusLabels{" producedSigmaPlusLabels" , -1 , " Produce k0short labels (-1: auto; 0 off; 1 on)" };
6872};
6973
7074class McBuilder
@@ -85,8 +89,10 @@ class McBuilder
8589
8690 mProduceCollisionLabels = utils::enableTable (" FColLabels" , table.producedCollisionLabels .value , initContext);
8791 mProduceTrackLabels = utils::enableTable (" FTrackLabels" , table.producedTrackLabels .value , initContext);
88- mProduceLambdaLabels = utils::enableTable (" FLambdaLabels" , table.producedTrackLabels .value , initContext);
89- mProduceK0shortLabels = utils::enableTable (" FK0shortLabels" , table.producedTrackLabels .value , initContext);
92+ mProduceLambdaLabels = utils::enableTable (" FLambdaLabels" , table.producedLambdaLabels .value , initContext);
93+ mProduceK0shortLabels = utils::enableTable (" FK0shortLabels" , table.producedK0shortLabels .value , initContext);
94+ mProduceSigmaLabels = utils::enableTable (" FSigmaLabels" , table.producedSigmaLabels .value , initContext);
95+ mProduceSigmaPlusLabels = utils::enableTable (" FSigmaPlusLabels" , table.producedSigmaPlusLabels .value , initContext);
9096
9197 if (mProduceMcCollisions || mProduceMcParticles || mProduceMcMothers || mProduceMcPartonicMothers || mProduceCollisionLabels || mProduceTrackLabels || mProduceLambdaLabels || mProduceK0shortLabels ) {
9298 mFillAnyTable = true ;
@@ -422,7 +428,195 @@ class McBuilder
422428 mK0shortToMcPartonicMap [k0shortIndex] = partonicRow;
423429 }
424430 }
425- mcProducts.producedTrackLabels (mcParticleRow, mothersRow, partonicRow);
431+ mcProducts.producedK0shortLabels (mcParticleRow, mothersRow, partonicRow);
432+ }
433+
434+ template <modes::System system, typename T1, typename T2, typename T3, typename T4, typename T5, typename T6>
435+ void fillMcSigmaWithLabel (T1 const & col, T2 const & mcCols, T3 const & sigma, T4 const & sigmaDaughter, T5 const & mcParticles, T6& mcProducts)
436+ {
437+ if (!mProduceSigmaLabels ) {
438+ return ;
439+ }
440+
441+ if (!sigmaDaughter.has_mcParticle ()) {
442+ mcProducts.producedSigmaLabels (-1 , -1 , -1 );
443+ return ;
444+ }
445+
446+ auto mcKinkDaughter = sigmaDaughter.template mcParticle_as <T5>();
447+ auto mcKinkDaughterMothers = mcKinkDaughter.template mothers_as <T5>();
448+
449+ if (!mcKinkDaughter.has_mothers () && !mcKinkDaughterMothers.empty ()) {
450+ mcProducts.producedSigmaLabels (-1 , -1 , -1 );
451+ return ;
452+ }
453+
454+ // we get the mc kink partilce via the mother of the kink daughter
455+ auto mcParticle = mcKinkDaughterMothers.front ();
456+ auto mcCol = mcParticle.template mcCollision_as <T2>();
457+
458+ int64_t particleIndex = mcParticle.globalIndex ();
459+ int64_t sigmaIndex = sigma.globalIndex ();
460+
461+ int64_t mcParticleRow = -1 ;
462+
463+ // MC PARTICLE
464+ auto itP = mSigmaToMcParticleMap .find (particleIndex);
465+ if (itP != mSigmaToMcParticleMap .end ()) {
466+ mcParticleRow = itP->second ;
467+ } else {
468+ auto origin = this ->getOrigin (col, mcCols, mcParticle);
469+ int64_t mcColId = this ->getMcColId <system>(mcCol, mcProducts);
470+
471+ mcProducts.producedMcParticles (
472+ mcColId,
473+ static_cast <aod::femtodatatypes::McOriginType>(origin),
474+ mcParticle.pdgCode (),
475+ mcParticle.pt () * utils::signum (mcParticle.pdgCode ()),
476+ mcParticle.eta (),
477+ mcParticle.phi ());
478+
479+ mcParticleRow = mcProducts.producedMcParticles .lastIndex ();
480+ mSigmaToMcParticleMap [particleIndex] = mcParticleRow;
481+ }
482+
483+ // mothers (fill only if exists)
484+ int64_t mothersRow = -1 ;
485+ auto itM = mSigmaToMcMotherMap .find (sigmaIndex);
486+
487+ if (itM != mSigmaToMcMotherMap .end ()) {
488+ mothersRow = itM->second ;
489+ } else {
490+
491+ auto mothers = mcParticle.template mothers_as <T5>();
492+ bool motherExists = mcParticle.has_mothers () && !mothers.empty ();
493+
494+ if (motherExists) {
495+ int motherPdg = mothers.front ().pdgCode (); // PDG code is ALWAYS valid if the mother exists
496+
497+ mcProducts.producedMothers (motherPdg);
498+ mothersRow = mcProducts.producedMothers .lastIndex ();
499+ mSigmaToMcMotherMap [sigmaIndex] = mothersRow;
500+ }
501+ }
502+
503+ // partonic mother (fill only if exists)
504+ int64_t partonicRow = -1 ;
505+ auto itPM = mSigmaToMcPartonicMap .find (sigmaIndex);
506+
507+ if (itPM != mSigmaToMcPartonicMap .end ()) {
508+ partonicRow = itPM->second ;
509+ } else {
510+ int partIdx = -1 ;
511+ if (mcParticle.has_mothers ()) {
512+ partIdx = this ->findFirstPartonicMother (mcParticle, mcParticles);
513+ }
514+
515+ bool partonicExists = (partIdx >= 0 );
516+
517+ if (partonicExists) {
518+ int partonicPdg = mcParticles.iteratorAt (partIdx).pdgCode ();
519+
520+ mcProducts.producedPartonicMothers (partonicPdg);
521+ partonicRow = mcProducts.producedPartonicMothers .lastIndex ();
522+ mSigmaToMcPartonicMap [sigmaIndex] = partonicRow;
523+ }
524+ }
525+ mcProducts.producedSigmaLabels (mcParticleRow, mothersRow, partonicRow);
526+ }
527+
528+ template <modes::System system, typename T1, typename T2, typename T3, typename T4, typename T5, typename T6>
529+ void fillMcSigmaPlusWithLabel (T1 const & col, T2 const & mcCols, T3 const & sigmaPlus, T4 const & sigmaPlusDaughter, T5 const & mcParticles, T6& mcProducts)
530+ {
531+ if (!mProduceSigmaPlusLabels ) {
532+ return ;
533+ }
534+
535+ if (!sigmaPlusDaughter.has_mcParticle ()) {
536+ mcProducts.producedSigmaPlusLabels (-1 , -1 , -1 );
537+ return ;
538+ }
539+
540+ auto mcKinkDaughter = sigmaPlusDaughter.template mcParticle_as <T5>();
541+ auto mcKinkDaughterMothers = mcKinkDaughter.template mothers_as <T5>();
542+
543+ if (!mcKinkDaughter.has_mothers () && !mcKinkDaughterMothers.empty ()) {
544+ mcProducts.producedSigmaPlusLabels (-1 , -1 , -1 );
545+ return ;
546+ }
547+
548+ // we get the mc kink partilce via the mother of the kink daughter
549+ auto mcParticle = mcKinkDaughterMothers.front ();
550+ auto mcCol = mcParticle.template mcCollision_as <T2>();
551+
552+ int64_t particleIndex = mcParticle.globalIndex ();
553+ int64_t sigmaIndex = sigmaPlus.globalIndex ();
554+
555+ int64_t mcParticleRow = -1 ;
556+
557+ // MC PARTICLE
558+ auto itP = mSigmaPlusToMcParticleMap .find (particleIndex);
559+ if (itP != mSigmaPlusToMcParticleMap .end ()) {
560+ mcParticleRow = itP->second ;
561+ } else {
562+ auto origin = this ->getOrigin (col, mcCols, mcParticle);
563+ int64_t mcColId = this ->getMcColId <system>(mcCol, mcProducts);
564+
565+ mcProducts.producedMcParticles (
566+ mcColId,
567+ static_cast <aod::femtodatatypes::McOriginType>(origin),
568+ mcParticle.pdgCode (),
569+ mcParticle.pt () * utils::signum (mcParticle.pdgCode ()),
570+ mcParticle.eta (),
571+ mcParticle.phi ());
572+
573+ mcParticleRow = mcProducts.producedMcParticles .lastIndex ();
574+ mSigmaPlusToMcParticleMap [particleIndex] = mcParticleRow;
575+ }
576+
577+ // mothers (fill only if exists)
578+ int64_t mothersRow = -1 ;
579+ auto itM = mSigmaPlusToMcMotherMap .find (sigmaIndex);
580+
581+ if (itM != mSigmaPlusToMcMotherMap .end ()) {
582+ mothersRow = itM->second ;
583+ } else {
584+
585+ auto mothers = mcParticle.template mothers_as <T5>();
586+ bool motherExists = mcParticle.has_mothers () && !mothers.empty ();
587+
588+ if (motherExists) {
589+ int motherPdg = mothers.front ().pdgCode (); // PDG code is ALWAYS valid if the mother exists
590+
591+ mcProducts.producedMothers (motherPdg);
592+ mothersRow = mcProducts.producedMothers .lastIndex ();
593+ mSigmaPlusToMcMotherMap [sigmaIndex] = mothersRow;
594+ }
595+ }
596+
597+ // partonic mother (fill only if exists)
598+ int64_t partonicRow = -1 ;
599+ auto itPM = mSigmaPlusToMcPartonicMap .find (sigmaIndex);
600+
601+ if (itPM != mSigmaPlusToMcPartonicMap .end ()) {
602+ partonicRow = itPM->second ;
603+ } else {
604+ int partIdx = -1 ;
605+ if (mcParticle.has_mothers ()) {
606+ partIdx = this ->findFirstPartonicMother (mcParticle, mcParticles);
607+ }
608+
609+ bool partonicExists = (partIdx >= 0 );
610+
611+ if (partonicExists) {
612+ int partonicPdg = mcParticles.iteratorAt (partIdx).pdgCode ();
613+
614+ mcProducts.producedPartonicMothers (partonicPdg);
615+ partonicRow = mcProducts.producedPartonicMothers .lastIndex ();
616+ mSigmaPlusToMcPartonicMap [sigmaIndex] = partonicRow;
617+ }
618+ }
619+ mcProducts.producedSigmaPlusLabels (mcParticleRow, mothersRow, partonicRow);
426620 }
427621
428622 template <typename TParticle, typename TContainer>
@@ -488,8 +682,18 @@ class McBuilder
488682 mK0shortToMcParticleMap .clear ();
489683 mK0shortToMcMotherMap .clear ();
490684 mK0shortToMcPartonicMap .clear ();
685+
686+ mSigmaToMcParticleMap .clear ();
687+ mSigmaToMcMotherMap .clear ();
688+ mSigmaToMcPartonicMap .clear ();
689+
690+ mSigmaPlusToMcParticleMap .clear ();
691+ mSigmaPlusToMcMotherMap .clear ();
692+ mSigmaPlusToMcPartonicMap .clear ();
491693 }
492694
695+ bool fillAnyTable () const { return mFillAnyTable ; }
696+
493697 private:
494698 bool mPassThrough = false ;
495699 bool mFillAnyTable = false ;
@@ -502,6 +706,8 @@ class McBuilder
502706 bool mProduceTrackLabels = false ;
503707 bool mProduceLambdaLabels = false ;
504708 bool mProduceK0shortLabels = false ;
709+ bool mProduceSigmaLabels = false ;
710+ bool mProduceSigmaPlusLabels = false ;
505711
506712 std::unordered_map<int64_t , int64_t > mCollisionMap ;
507713
@@ -516,6 +722,14 @@ class McBuilder
516722 std::unordered_map<int64_t , int64_t > mK0shortToMcParticleMap ;
517723 std::unordered_map<int64_t , int64_t > mK0shortToMcMotherMap ;
518724 std::unordered_map<int64_t , int64_t > mK0shortToMcPartonicMap ;
725+
726+ std::unordered_map<int64_t , int64_t > mSigmaToMcParticleMap ;
727+ std::unordered_map<int64_t , int64_t > mSigmaToMcMotherMap ;
728+ std::unordered_map<int64_t , int64_t > mSigmaToMcPartonicMap ;
729+
730+ std::unordered_map<int64_t , int64_t > mSigmaPlusToMcParticleMap ;
731+ std::unordered_map<int64_t , int64_t > mSigmaPlusToMcMotherMap ;
732+ std::unordered_map<int64_t , int64_t > mSigmaPlusToMcPartonicMap ;
519733};
520734
521735} // namespace mcbuilder
0 commit comments