@@ -896,6 +896,27 @@ struct he3HadronFemto {
896896 }
897897 }
898898
899+ void searchForCommonMotherTrack (std::vector<unsigned int >& motherHe3Idxs, std::vector<unsigned int >& motherHadIdxs, McIter& motherParticle, bool & isMixedPair, const int motherPdgCode)
900+ {
901+ std::unordered_set<unsigned int > motherHe3SetIdxs (motherHe3Idxs.begin (), motherHe3Idxs.end ());
902+ for (const auto & motherHadIdx : motherHadIdxs) {
903+ if (!motherHe3SetIdxs.contains (motherHadIdx)) {
904+ continue ;
905+ }
906+
907+ motherParticle = mcParticles.rawIteratorAt (motherHadIdx);
908+ if (std::abs (motherParticle.pdgCode ()) != motherPdgCode || std::abs (motherParticle.y ()) > 1 ) {
909+ continue ;
910+ }
911+ isMixedPair = false ;
912+ break ;
913+ }
914+ if (!isMixedPair) {
915+ he3Hadcand.flags |= Flags::kBothFromLi4 ;
916+ }
917+
918+ }
919+
899920 template <typename Tcollisions, typename TmcParticles>
900921 void fillMcParticles (const Tcollisions& collisions, const TmcParticles& mcParticles, std::vector<unsigned int >& filledMothers)
901922 {
@@ -1024,7 +1045,6 @@ struct he3HadronFemto {
10241045
10251046 He3HadCandidate he3Hadcand;
10261047 McIter motherParticle;
1027- unsigned int motherIdx;
10281048 std::vector<unsigned int > motherHe3Idxs, motherHadIdxs;
10291049 setMcParticleFlag (mctrackHe3, motherHe3Idxs, he3Hadcand.flagsHe3 );
10301050 setMcParticleFlag (mctrackHad, motherHadIdxs, he3Hadcand.flagsHad );
@@ -1037,41 +1057,14 @@ struct he3HadronFemto {
10371057
10381058 } else if ((he3Hadcand.flagsHe3 & ParticleFlags::kFromLi4 ) && (he3Hadcand.flagsHad & ParticleFlags::kFromLi4 )) {
10391059
1040- std::unordered_set<unsigned int > motherHe3SetIdxs (motherHe3Idxs.begin (), motherHe3Idxs.end ());
1041- for (const auto & motherHadIdx : motherHadIdxs) {
1042- if (!motherHe3SetIdxs.contains (motherHadIdx)) {
1043- continue ;
1044- }
1045-
1046- motherParticle = mcParticles.rawIteratorAt (motherHadIdx);
1047- motherIdx = motherHadIdx;
1048- if (std::abs (motherParticle.pdgCode ()) != Li4PDG || std::abs (motherParticle.y ()) > 1 ) {
1049- continue ;
1050- }
1051- isMixedPair = false ;
1052- break ;
1053- }
1060+ searchForCommonMotherTrack (motherHe3Idxs, motherHadIdxs, motherParticle, isMixedPair, Li4PDG);
10541061 if (!isMixedPair) {
10551062 he3Hadcand.flags |= Flags::kBothFromLi4 ;
10561063 }
10571064
10581065 } else if ((he3Hadcand.flagsHe3 & ParticleFlags::kFromHypertriton ) && (he3Hadcand.flagsHad & ParticleFlags::kFromHypertriton )) {
10591066
1060- std::unordered_set<unsigned int > motherHe3SetIdxs (motherHe3Idxs.begin (), motherHe3Idxs.end ());
1061- for (const auto & motherHadIdx : motherHadIdxs) {
1062- if (!motherHe3SetIdxs.contains (motherHadIdx)) {
1063- continue ;
1064- }
1065-
1066- motherParticle = mcParticles.rawIteratorAt (motherHadIdx);
1067- motherIdx = motherHadIdx;
1068- if (std::abs (motherParticle.pdgCode ()) != o2::constants::physics::Pdg::kHyperTriton || std::abs (motherParticle.y ()) > 1 ) {
1069- continue ;
1070- }
1071- isMixedPair = false ;
1072- break ;
1073- }
1074-
1067+ searchForCommonMotherTrack (motherHe3Idxs, motherHadIdxs, motherParticle, isMixedPair, o2::constants::physics::Pdg::kHyperTriton );
10751068 if (!isMixedPair) {
10761069 he3Hadcand.flags |= Flags::kBothFromHypertriton ;
10771070 }
@@ -1092,7 +1085,7 @@ struct he3HadronFemto {
10921085
10931086 if ((he3Hadcand.flags == Flags::kBothFromLi4 ) || (he3Hadcand.flags == Flags::kBothFromHypertriton )) {
10941087 fillMotherInfoMC (mctrackHe3, mctrackHad, motherParticle, he3Hadcand);
1095- filledMothers.push_back (motherIdx );
1088+ filledMothers.push_back (motherParticle. globalIndex () );
10961089 }
10971090
10981091 fillHistograms (he3Hadcand);
0 commit comments