@@ -620,6 +620,17 @@ struct HfDataCreatorCharmResoReduced {
620620 return flagV0; // Placeholder, should return the actual flag based on matching logic
621621 }
622622
623+ template <typename PParticles>
624+ double computeInvMassGen (PParticles const & particlesMc, int indexRec)
625+ {
626+ auto particleReso = particlesMc.iteratorAt (indexRec);
627+ auto dau1 = particlesMc.iteratorAt (particleReso.daughtersIds ().front ());
628+ auto dau2 = particlesMc.iteratorAt (particleReso.daughtersIds ().back ());
629+ std::array<std::array<float , 3 >, 2 > pArr = {{{dau1.px (), dau1.py (), dau1.pz ()}, {dau2.px (), dau2.py (), dau2.pz ()}}};
630+ std::array<float , 2 > mArr = {static_cast <float >(pdg->Mass (dau1.pdgCode ())), static_cast <float >(pdg->Mass (dau2.pdgCode ()))};
631+ return RecoDecay::m (pArr, mArr );
632+ }
633+
623634 // / Function for filling MC reco information of DV0 candidates in the tables
624635 // / \tparam dType is the D meson type (Dstar, Dplus or D0)
625636 // / \param particlesMc is the table with MC particles
@@ -690,7 +701,7 @@ struct HfDataCreatorCharmResoReduced {
690701 if (indexRec > -1 ) {
691702 auto particleReso = particlesMc.iteratorAt (indexRec);
692703 ptGen = particleReso.pt ();
693- invMassGen = RecoDecay::m (particleReso. p (), particleReso. e () );
704+ invMassGen = computeInvMassGen (particlesMc, indexRec );
694705 }
695706 rowHfDstarV0McRecReduced (indexHfCandCharm, indexCandV0Bach,
696707 flagReso, flagCharmBach,
@@ -743,7 +754,7 @@ struct HfDataCreatorCharmResoReduced {
743754 if (indexRec > -1 ) {
744755 auto particleReso = particlesMc.iteratorAt (indexRec);
745756 ptGen = particleReso.pt ();
746- invMassGen = RecoDecay::m (particleReso. p (), particleReso. e () );
757+ invMassGen = computeInvMassGen (particlesMc, indexRec );
747758 }
748759 rowHf3PrV0McRecReduced (indexHfCandCharm, indexCandV0Bach,
749760 flagReso, flagCharmBach,
@@ -784,7 +795,7 @@ struct HfDataCreatorCharmResoReduced {
784795 if (indexRec > -1 ) {
785796 auto particleReso = particlesMc.iteratorAt (indexRec);
786797 ptGen = particleReso.pt ();
787- invMassGen = RecoDecay::m (particleReso. p (), particleReso. e () );
798+ invMassGen = computeInvMassGen (particlesMc, indexRec );
788799 }
789800 rowHf2PrV0McRecReduced (indexHfCandCharm, indexCandV0Bach,
790801 flagReso, flagCharmBach,
@@ -874,7 +885,7 @@ struct HfDataCreatorCharmResoReduced {
874885 if (indexRec > -1 ) {
875886 auto particleReso = particlesMc.iteratorAt (indexRec);
876887 ptGen = particleReso.pt ();
877- invMassGen = RecoDecay::m (particleReso. p (), particleReso. e () );
888+ invMassGen = computeInvMassGen (particlesMc, indexRec );
878889 }
879890 rowHfDstarTrkMcRecReduced (indexHfCandCharm, indexCandTrBach,
880891 flagReso, flagCharmBach,
@@ -914,7 +925,7 @@ struct HfDataCreatorCharmResoReduced {
914925 if (indexRec > -1 ) {
915926 auto particleReso = particlesMc.iteratorAt (indexRec);
916927 ptGen = particleReso.pt ();
917- invMassGen = RecoDecay::m (particleReso. p (), particleReso. e () );
928+ invMassGen = computeInvMassGen (particlesMc, indexRec );
918929 }
919930 rowHf3PrTrkMcRecReduced (indexHfCandCharm, indexCandTrBach,
920931 flagReso, flagCharmBach,
@@ -961,7 +972,7 @@ struct HfDataCreatorCharmResoReduced {
961972 if (indexRec > -1 ) {
962973 auto particleReso = particlesMc.iteratorAt (indexRec);
963974 ptGen = particleReso.pt ();
964- invMassGen = RecoDecay::m (particleReso. p (), particleReso. e () );
975+ invMassGen = computeInvMassGen (particlesMc, indexRec );
965976 }
966977 rowHf2PrTrkMcRecReduced (indexHfCandCharm, indexCandTrBach,
967978 flagReso, flagCharmBach,
@@ -1679,7 +1690,7 @@ struct HfDataCreatorCharmResoReduced {
16791690 origin = RecoDecay::getCharmHadronOrigin (mcParticlesPerMcColl, particle, false , &idxBhadMothers);
16801691 registry.fill (HIST (" hMCGenOrigin" ), origin);
16811692 auto ptParticle = particle.pt ();
1682- auto invMassGen = RecoDecay::m (particle. p () , particle.e ());
1693+ auto invMassGen = computeInvMassGen (mcParticles , particle.globalIndex ());
16831694 auto yParticle = RecoDecay::y (particle.pVector (), invMassGen);
16841695 auto etaParticle = particle.eta ();
16851696
0 commit comments