@@ -542,6 +542,73 @@ class CharmHadronBuilder
542542 }
543543 }
544544
545+ // / Write one row for the given mass hypothesis, if PWGHF accepted it.
546+ // / A candidate passing both hypotheses is stored twice, once per hypothesis.
547+ template <bool isPKPi, modes::System system, typename T1 , typename T2 , typename T3 , typename T4 , typename T5 , typename T6 , typename T7 , typename T8 >
548+ void fillLcHypothesis (T1 const & col, T2 & collisionBuilder, T3 & collisionProducts, T4 & trackProducts,
549+ T5 & charmHadronProducts, T6 const & candidate, T7 & trackBuilder,
550+ T8 const & prong0, T8 const & prong1, T8 const & prong2)
551+ {
552+ if constexpr (isPKPi) {
553+ if (!candidate.isSelLcToPKPi ()) {
554+ return ;
555+ }
556+ } else {
557+ if (!candidate.isSelLcToPiKP ()) {
558+ return ;
559+ }
560+ }
561+
562+ // remap the prongs onto the accepted hypothesis so that the proton is always first
563+ auto const & protonProng = isPKPi ? prong0 : prong2;
564+ auto const & pionProng = isPKPi ? prong2 : prong0;
565+ float const mass = isPKPi ? mHfHelper .invMassLcToPKPi (candidate) : mHfHelper .invMassLcToPiKP (candidate);
566+ float const massCompeting = isPKPi ? mHfHelper .invMassLcToPiKP (candidate) : mHfHelper .invMassLcToPKPi (candidate);
567+
568+ collisionBuilder.template fillCollision <system>(collisionProducts, col);
569+ int64_t const protonDauIndex = trackBuilder.template getDaughterIndex <modes::Track::kCharmDaughter >(protonProng, trackProducts, collisionBuilder);
570+ int64_t const kaonDauIndex = trackBuilder.template getDaughterIndex <modes::Track::kCharmDaughter >(prong1, trackProducts, collisionBuilder);
571+ int64_t const pionDauIndex = trackBuilder.template getDaughterIndex <modes::Track::kCharmDaughter >(pionProng, trackProducts, collisionBuilder);
572+
573+ float const signedPt = isParticle<hadronType>() ? candidate.pt () : -candidate.pt ();
574+ this ->fillLcTables (collisionProducts, charmHadronProducts, candidate, signedPt, mass, massCompeting, protonDauIndex, kaonDauIndex, pionDauIndex);
575+ }
576+
577+ // / Monte Carlo counterpart of fillLcHypothesis. The label is written inside this method,
578+ // / so FLcs and FLcLabels stay in lockstep also for candidates passing both hypotheses.
579+ template <bool isPKPi, modes::System system, typename T1 , typename T2 , typename T3 , typename T4 , typename T5 , typename T6 , typename T7 , typename T8 , typename T9 , typename T10 , typename T11 , typename T12 , typename T13 >
580+ void fillMcLcHypothesis (T1 const & col, T2 & collisionBuilder, T3 & collisionProducts, T4 const & mcCols, T5 & trackProducts,
581+ T6 & charmHadronProducts, T7 const & candidate, T8 const & tracks, T9 & trackBuilder,
582+ T10 const & mcParticles, T11 & mcBuilder, T12 & mcProducts,
583+ T13 const & prong0, T13 const & prong1, T13 const & prong2)
584+ {
585+ if constexpr (isPKPi) {
586+ if (!candidate.isSelLcToPKPi ()) {
587+ return ;
588+ }
589+ } else {
590+ if (!candidate.isSelLcToPiKP ()) {
591+ return ;
592+ }
593+ }
594+
595+ // remap the prongs onto the accepted hypothesis so that the proton is always first
596+ auto const & protonProng = isPKPi ? prong0 : prong2;
597+ auto const & pionProng = isPKPi ? prong2 : prong0;
598+ float const mass = isPKPi ? mHfHelper .invMassLcToPKPi (candidate) : mHfHelper .invMassLcToPiKP (candidate);
599+ float const massCompeting = isPKPi ? mHfHelper .invMassLcToPiKP (candidate) : mHfHelper .invMassLcToPKPi (candidate);
600+
601+ collisionBuilder.template fillMcCollision <system>(collisionProducts, col, mcCols, mcProducts, mcBuilder);
602+
603+ int64_t const protonDauIndex = trackBuilder.template getDaughterIndex <system, modes::Track::kCharmDaughter >(protonProng, trackProducts, mcCols, collisionBuilder, mcParticles, mcBuilder, mcProducts);
604+ int64_t const kaonDauIndex = trackBuilder.template getDaughterIndex <system, modes::Track::kCharmDaughter >(prong1, trackProducts, mcCols, collisionBuilder, mcParticles, mcBuilder, mcProducts);
605+ int64_t const pionDauIndex = trackBuilder.template getDaughterIndex <system, modes::Track::kCharmDaughter >(pionProng, trackProducts, mcCols, collisionBuilder, mcParticles, mcBuilder, mcProducts);
606+
607+ float const signedPt = isParticle<hadronType>() ? candidate.pt () : -candidate.pt ();
608+ this ->fillLcTables (collisionProducts, charmHadronProducts, candidate, signedPt, mass, massCompeting, protonDauIndex, kaonDauIndex, pionDauIndex);
609+ mcBuilder.template fillMcLcWithLabel <system>(candidate, tracks, mcParticles, mcCols, mcProducts);
610+ }
611+
545612 template <modes::System system, typename T1 , typename T2 , typename T3 , typename T4 , typename T5 , typename T6 , typename T7 , typename T8 >
546613 void fillCharmHadrons (T1 const & col, T2 & collisionBuilder, T3 & collisionProducts, T4 & trackProducts,
547614 T5 & charmHadronProducts, T6 const & candidates, T7 const & /* tracks*/ , T8 & trackBuilder)
@@ -584,20 +651,8 @@ class CharmHadronBuilder
584651 continue ;
585652 }
586653
587- // remap the prong onto the accepted hypothesis so that the proton is always first
588- bool const isPKPi = candidate.isSelLcToPKPi ();
589- auto const & protonProng = isPKPi ? prong0 : prong2;
590- auto const & pionProng = isPKPi ? prong2 : prong0;
591- float const mass = isPKPi ? mHfHelper .invMassLcToPKPi (candidate) : mHfHelper .invMassLcToPiKP (candidate);
592- float const massCompeting = isPKPi ? mHfHelper .invMassLcToPiKP (candidate) : mHfHelper .invMassLcToPKPi (candidate);
593-
594- collisionBuilder.template fillCollision <system>(collisionProducts, col);
595- int64_t const protonDauIndex = trackBuilder.template getDaughterIndex <modes::Track::kCharmDaughter >(protonProng, trackProducts, collisionBuilder);
596- int64_t const kaonDauIndex = trackBuilder.template getDaughterIndex <modes::Track::kCharmDaughter >(prong1, trackProducts, collisionBuilder);
597- int64_t const pionDauIndex = trackBuilder.template getDaughterIndex <modes::Track::kCharmDaughter >(pionProng, trackProducts, collisionBuilder);
598-
599- float const signedPt = isParticle<hadronType>() ? candidate.pt () : -candidate.pt ();
600- this ->fillLcTables (collisionProducts, charmHadronProducts, candidate, signedPt, mass, massCompeting, protonDauIndex, kaonDauIndex, pionDauIndex);
654+ this ->fillLcHypothesis <true , system>(col, collisionBuilder, collisionProducts, trackProducts, charmHadronProducts, candidate, trackBuilder, prong0, prong1, prong2);
655+ this ->fillLcHypothesis <false , system>(col, collisionBuilder, collisionProducts, trackProducts, charmHadronProducts, candidate, trackBuilder, prong0, prong1, prong2);
601656 }
602657 }
603658 }
@@ -646,25 +701,9 @@ class CharmHadronBuilder
646701 continue ;
647702 }
648703
649- // remap the prongs onto the accepted hypothesis so that the proton is always first
650- bool const isPKPi = candidate.isSelLcToPKPi ();
651- auto const & protonProng = isPKPi ? prong0 : prong2;
652- auto const & pionProng = isPKPi ? prong2 : prong0;
653- float const mass = isPKPi ? mHfHelper .invMassLcToPKPi (candidate) : mHfHelper .invMassLcToPiKP (candidate);
654- float const massCompeting = isPKPi ? mHfHelper .invMassLcToPiKP (candidate) : mHfHelper .invMassLcToPKPi (candidate);
655-
656- collisionBuilder.template fillMcCollision <system>(collisionProducts, col, mcCols, mcProducts, mcBuilder);
657-
658- int64_t const protonDauIndex = trackBuilder.template getDaughterIndex <system, modes::Track::kCharmDaughter >(protonProng, trackProducts, mcCols, collisionBuilder, mcParticles, mcBuilder, mcProducts);
659- int64_t const kaonDauIndex = trackBuilder.template getDaughterIndex <system, modes::Track::kCharmDaughter >(prong1, trackProducts, mcCols, collisionBuilder, mcParticles, mcBuilder, mcProducts);
660- int64_t const pionDauIndex = trackBuilder.template getDaughterIndex <system, modes::Track::kCharmDaughter >(pionProng, trackProducts, mcCols, collisionBuilder, mcParticles, mcBuilder, mcProducts);
661-
662- float const signedPt = isParticle<hadronType>() ? candidate.pt () : -candidate.pt ();
663- this ->fillLcTables (collisionProducts, charmHadronProducts, candidate, signedPt, mass, massCompeting, protonDauIndex, kaonDauIndex, pionDauIndex);
664- mcBuilder.template fillMcLcWithLabel <system>(candidate, tracks, mcParticles, mcCols, mcProducts);
704+ this ->fillMcLcHypothesis <true , system>(col, collisionBuilder, collisionProducts, mcCols, trackProducts, charmHadronProducts, candidate, tracks, trackBuilder, mcParticles, mcBuilder, mcProducts, prong0, prong1, prong2);
705+ this ->fillMcLcHypothesis <false , system>(col, collisionBuilder, collisionProducts, mcCols, trackProducts, charmHadronProducts, candidate, tracks, trackBuilder, mcParticles, mcBuilder, mcProducts, prong0, prong1, prong2);
665706 }
666-
667-
668707 }
669708 }
670709
0 commit comments