@@ -307,9 +307,19 @@ class KinkSelection : public BaseSelection<float, o2::aod::femtodatatypes::KinkM
307307 void computeKinkMotherKinematics (const T& kinkCand)
308308 {
309309 std::array<float , 3 > momMother = {kinkCand.pxMoth (), kinkCand.pyMoth (), kinkCand.pzMoth ()};
310- mKinkMotherPt = RecoDecay::pt (momMother);
310+ std::array<float , 3 > momDaughter = {kinkCand.pxDaug (), kinkCand.pyDaug (), kinkCand.pzDaug ()};
311+
311312 mKinkMotherEta = RecoDecay::eta (momMother);
312313 mKinkMotherPhi = RecoDecay::phi (momMother);
314+
315+ // Recalculate pT using kinematic constraints
316+ float ptRecalc = utils::calcPtnew (momMother[0 ], momMother[1 ], momMother[2 ],
317+ momDaughter[0 ], momDaughter[1 ], momDaughter[2 ]);
318+ if (ptRecalc > 0 .f ) {
319+ mKinkMotherPt = ptRecalc;
320+ } else {
321+ mKinkMotherPt = -1 .f ;
322+ }
313323 }
314324
315325 template <typename T>
@@ -401,7 +411,7 @@ class KinkBuilder
401411 {
402412 if constexpr (modes::isEqual (kinkType, modes::Kink::kSigma )) {
403413 LOG (info) << " Initialize femto Sigma builder..." ;
404- mProduceSigmas = utils::enableTable (" FSigmas_001 " , table.produceSigmas .value , initContext);
414+ mProduceSigmas = utils::enableTable (" FSigmas_002 " , table.produceSigmas .value , initContext);
405415 mProduceSigmaMasks = utils::enableTable (" FSigmaMasks_001" , table.produceSigmaMasks .value , initContext);
406416 mProduceSigmaExtras = utils::enableTable (" FSigmaExtras_001" , table.produceSigmaExtras .value , initContext);
407417 }
@@ -510,11 +520,12 @@ class KinkBuilder
510520 template <typename T1, typename T2, typename T3>
511521 void fillSigma (T1& collisionProducts, T2& kinkProducts, T3 const & kink, int64_t daughterIndex)
512522 {
523+ // Mass is calculated from original momentum components stored in kink table
513524 float mass = kink.mSigmaMinus ();
514525
515526 if (mProduceSigmas ) {
516527 kinkProducts.producedSigmas (collisionProducts.producedCollision .lastIndex (),
517- kink.mothSign () * mKinkSelection .getKinkMotherPt (),
528+ kink.mothSign () * mKinkSelection .getKinkMotherPt (), // Recalculated pT
518529 mKinkSelection .getKinkMotherEta (),
519530 mKinkSelection .getKinkMotherPhi (),
520531 mass,
@@ -538,11 +549,12 @@ class KinkBuilder
538549 template <typename T1, typename T2, typename T3>
539550 void fillSigmaPlus (T1& collisionProducts, T2& kinkProducts, T3 const & kink, int64_t daughterIndex)
540551 {
552+ // Mass is calculated from original momentum components stored in kink table
541553 float mass = kink.mSigmaPlus ();
542554
543555 if (mProduceSigmaPlus ) {
544556 kinkProducts.producedSigmaPlus (collisionProducts.producedCollision .lastIndex (),
545- kink.mothSign () * mKinkSelection .getKinkMotherPt (),
557+ kink.mothSign () * mKinkSelection .getKinkMotherPt (), // Recalculated pT
546558 mKinkSelection .getKinkMotherEta (),
547559 mKinkSelection .getKinkMotherPhi (),
548560 mass,
@@ -576,6 +588,103 @@ class KinkBuilder
576588 bool mProduceSigmaPlusExtras = false ;
577589};
578590
591+ struct ConfKinkTablesDerivedToDerived : o2::framework::ConfigurableGroup {
592+ std::string prefix = std::string(" KinkTables" );
593+ o2::framework::Configurable<int > limitSigma{" limitSigma" , 1 , " At least this many sigmas need to be in the collision" };
594+ o2::framework::Configurable<int > limitSigmaPlus{" limitSigmaPlus" , 0 , " At least this many sigma pluses need to be in the collision" };
595+ };
596+
597+ struct KinkBuilderDerivedToDerivedProducts : o2::framework::ProducesGroup {
598+ o2::framework::Produces<o2::aod::StoredFSigmas_002> producedSigmas;
599+ o2::framework::Produces<o2::aod::StoredFSigmaMasks_001> producedSigmaMasks;
600+ o2::framework::Produces<o2::aod::StoredFSigmaPlus_001> producedSigmaPluses;
601+ o2::framework::Produces<o2::aod::StoredFSigmaPlusMasks_001> producedSigmaPlusMasks;
602+ };
603+
604+ class KinkBuilderDerivedToDerived
605+ {
606+ public:
607+ KinkBuilderDerivedToDerived () = default ;
608+ ~KinkBuilderDerivedToDerived () = default ;
609+
610+ template <typename T>
611+ void init (T& config)
612+ {
613+ mLimitSigma = config.limitSigma .value ;
614+ mLimitSigmaPlus = config.limitSigmaPlus .value ;
615+
616+ if (mLimitSigma == 0 && mLimitSigmaPlus == 0 ) {
617+ LOG (fatal) << " Both sigma limit and sigmaplus limit are 0. Breaking..." ;
618+ }
619+ }
620+
621+ template <typename T1, typename T2, typename T3, typename T4>
622+ bool collisionHasTooFewSigma (T1 const & col, T2 const & /* sigmaTable*/ , T3& partitionSigma, T4& cache)
623+ {
624+ auto sigmaSlice = partitionSigma->sliceByCached (o2::aod::femtobase::stored::fColId , col.globalIndex (), cache);
625+ if (sigmaSlice.size () >= mLimitSigma ) {
626+ return false ;
627+ }
628+ return true ;
629+ }
630+
631+ template <typename T1, typename T2, typename T3, typename T4>
632+ bool collisionHasTooFewSigmaPlus (T1 const & col, T2 const & /* sigmaPlusTable*/ , T3& partitionSigmaPlus, T4& cache)
633+ {
634+ auto sigmaPlusSlice = partitionSigmaPlus->sliceByCached (o2::aod::femtobase::stored::fColId , col.globalIndex (), cache);
635+ if (sigmaPlusSlice.size () >= mLimitSigmaPlus ) {
636+ return false ;
637+ }
638+ return true ;
639+ }
640+
641+ template <typename T1, typename T2, typename T3, typename T4, typename T5, typename T6, typename T7, typename T8, typename T9>
642+ void processSigma (T1 const & col, T2 const & /* sigmaTable*/ , T3 const & oldTrackTable, T4& partitionSigma, T5& trackBuilder, T6& cache, T7& newSigmaTable, T8& newTrackTable, T9& newCollisionTable)
643+ {
644+ auto sigmaSlice = partitionSigma->sliceByCached (o2::aod::femtobase::stored::fColId , col.globalIndex (), cache);
645+
646+ for (auto const & sigma : sigmaSlice) {
647+
648+ auto chaDaughter = oldTrackTable.rawIteratorAt (sigma.chaDauId () - oldTrackTable.offset ());
649+
650+ int chaDaughterIndex = trackBuilder.getDaughterIndex (chaDaughter, newTrackTable, newCollisionTable);
651+
652+ newSigmaTable.producedSigmas (newCollisionTable.producedCollision .lastIndex (),
653+ sigma.signedPt (),
654+ sigma.eta (),
655+ sigma.phi (),
656+ sigma.mass (),
657+ chaDaughterIndex);
658+ newSigmaTable.producedSigmaMasks (sigma.mask ());
659+ }
660+ }
661+
662+ template <typename T1, typename T2, typename T3, typename T4, typename T5, typename T6, typename T7, typename T8, typename T9>
663+ void processSigmaPlus (T1 const & col, T2 const & /* sigmaPlusTable*/ , T3 const & oldTrackTable, T4& partitionSigmaPlus, T5& trackBuilder, T6& cache, T7& newSigmaPlusTable, T8& newTrackTable, T9& newCollisionTable)
664+ {
665+ auto sigmaPlusSlice = partitionSigmaPlus->sliceByCached (o2::aod::femtobase::stored::fColId , col.globalIndex (), cache);
666+
667+ for (auto const & sigmaPlus : sigmaPlusSlice) {
668+
669+ auto chaDaughter = oldTrackTable.rawIteratorAt (sigmaPlus.chaDauId () - oldTrackTable.offset ());
670+
671+ int chaDaughterIndex = trackBuilder.getDaughterIndex (chaDaughter, newTrackTable, newCollisionTable);
672+
673+ newSigmaPlusTable.producedSigmaPluses (newCollisionTable.producedCollision .lastIndex (),
674+ sigmaPlus.signedPt (),
675+ sigmaPlus.eta (),
676+ sigmaPlus.phi (),
677+ sigmaPlus.mass (),
678+ chaDaughterIndex);
679+ newSigmaPlusTable.producedSigmaPlusMasks (sigmaPlus.mask ());
680+ }
681+ }
682+
683+ private:
684+ int mLimitSigma = 0 ;
685+ int mLimitSigmaPlus = 0 ;
686+ };
687+
579688} // namespace kinkbuilder
580689} // namespace o2::analysis::femto
581690#endif // PWGCF_FEMTO_CORE_KINKBUILDER_H_
0 commit comments