@@ -159,6 +159,7 @@ struct CandidateTrack {
159159 float genpt = -999 .f;
160160 float geneta = -999 .f;
161161 int pdgcode = -999 ;
162+ int pdgcodemoth = -999 ;
162163 bool isreco = 0 ;
163164 int64_t mcIndex = -999 ;
164165 int64_t globalIndex = -999 ;
@@ -179,6 +180,12 @@ enum selBits {
179180 kTPCPIDMid = BIT (11 )
180181};
181182
183+ enum PartTypes {
184+ kLa = BIT (20 ),
185+ kSig = BIT (21 ),
186+ kPhysPrim = BIT (22 )
187+ };
188+
182189struct tagRun2V0MCalibration {
183190 bool mCalibrationStored = false ;
184191 TH1* mhVtxAmpCorrV0A = nullptr ;
@@ -313,6 +320,37 @@ struct ebyeMaker {
313320 Preslice<aod::V0s> perCollisionV0 = o2::aod::v0::collisionId;
314321 Preslice<aod::McParticles> perCollisionMcParts = o2::aod::mcparticle::mcCollisionId;
315322
323+ template <class P >
324+ int getPartTypeMother (P const & mcPart)
325+ {
326+ for (auto & mother : mcPart.template mothers_as <aod::McParticles>()) {
327+ if (!mother.isPhysicalPrimary ())
328+ return -1 ;
329+ int pdgCode = mother.pdgCode ();
330+ switch (std::abs (pdgCode)) {
331+ case 3122 : {
332+ int foundPi = 0 ;
333+ for (auto & mcDaught : mother.template daughters_as <aod::McParticles>()) {
334+ if (std::abs (mcDaught.pdgCode ()) == 211 ) {
335+ foundPi = mcDaught.pdgCode ();
336+ break ;
337+ }
338+ }
339+ if (foundPi * mcPart.pdgCode () < -0.5 )
340+ return PartTypes::kLa ;
341+ return -1 ;
342+ }
343+ // case 3222:
344+ // return PartTypes::kSig;
345+ // case 3112:
346+ // return PartTypes::kSig;
347+ default :
348+ return -1 ;
349+ }
350+ }
351+ return -1 ;
352+ }
353+
316354 template <class T >
317355 bool selectV0Daughter (T const & track)
318356 {
@@ -867,7 +905,7 @@ struct ebyeMaker {
867905 }
868906
869907 template <class C , class T >
870- void fillMcEvent (C const & collision, T const & tracks, aod::V0s const & V0s, float const & centrality, aod::McParticles const &, aod::McTrackLabels const & mcLabels)
908+ void fillMcEvent (C const & collision, T const & tracks, aod::V0s const & V0s, float const & centrality, aod::McParticles const & particlesMC , aod::McTrackLabels const & mcLabels)
871909 {
872910 fillRecoEvent<C, T>(collision, tracks, V0s, centrality);
873911
@@ -876,14 +914,23 @@ struct ebyeMaker {
876914 candidateTrack.isreco = true ;
877915
878916 auto mcLab = mcLabels.rawIteratorAt (candidateTrack.globalIndex );
917+
918+ if (mcLab.mcParticleId () < -1 || mcLab.mcParticleId () >= particlesMC.size ()) {
919+ continue ;
920+ }
879921 if (mcLab.has_mcParticle ()) {
880922 auto mcTrack = mcLab.template mcParticle_as <aod::McParticles>();
881923 if (std::abs (mcTrack.pdgCode ()) != partPdg[iP])
882924 continue ;
883- if (((mcTrack.flags () & 0x8 ) && (doprocessMcRun2 || doprocessMiniMcRun2)) || (mcTrack.flags () & 0x2 ) || (mcTrack.flags () & 0x1 ))
925+ if (((mcTrack.flags () & 0x8 ) && (doprocessMcRun2 || doprocessMiniMcRun2)) || (mcTrack.flags () & 0x2 ) || (( mcTrack.flags () & 0x1 ) && !doprocessMiniMcRun2 ))
884926 continue ;
885- if (!mcTrack.isPhysicalPrimary ())
927+
928+ if (!mcTrack.isPhysicalPrimary () && !doprocessMiniMcRun2)
886929 continue ;
930+ if (mcTrack.isPhysicalPrimary ())
931+ candidateTrack.pdgcodemoth = PartTypes::kPhysPrim ;
932+ else if (mcTrack.has_mothers () && iP == 0 )
933+ candidateTrack.pdgcodemoth = getPartTypeMother (mcTrack);
887934
888935 auto genPt = std::hypot (mcTrack.px (), mcTrack.py ());
889936 candidateTrack.pdgcode = mcTrack.pdgCode ();
@@ -936,7 +983,7 @@ struct ebyeMaker {
936983 if (std::abs (genEta) > etaMax) {
937984 continue ;
938985 }
939- if (((mcPart.flags () & 0x8 ) && (doprocessMcRun2 || doprocessMiniMcRun2)) || (mcPart.flags () & 0x2 ) || (mcPart.flags () & 0x1 ))
986+ if (((mcPart.flags () & 0x8 ) && (doprocessMcRun2 || doprocessMiniMcRun2)) || (mcPart.flags () & 0x2 ) || (( mcPart.flags () & 0x1 ) && !doprocessMiniMcRun2 ))
940987 continue ;
941988 auto pdgCode = mcPart.pdgCode ();
942989 if (std::abs (pdgCode) == 3122 ) {
@@ -969,13 +1016,18 @@ struct ebyeMaker {
9691016 if (std::abs (pdgCode) == partPdg[0 ]) {
9701017 iP = 0 ;
9711018 }
972- if (!mcPart.isPhysicalPrimary () && !mcPart. has_mothers ( ))
1019+ if (( !mcPart.isPhysicalPrimary () && !doprocessMiniMcRun2 ))
9731020 continue ;
9741021 auto genPt = std::hypot (mcPart.px (), mcPart.py ());
9751022 CandidateTrack candTrack;
9761023 candTrack.genpt = genPt;
9771024 candTrack.geneta = mcPart.eta ();
9781025 candTrack.pdgcode = pdgCode;
1026+ if (mcPart.isPhysicalPrimary ())
1027+ candTrack.pdgcodemoth = PartTypes::kPhysPrim ;
1028+ else if (mcPart.has_mothers () && iP == 0 )
1029+ candTrack.pdgcodemoth = getPartTypeMother (mcPart);
1030+
9791031 auto it = find_if (candidateTracks[iP].begin (), candidateTracks[iP].end (), [&](CandidateTrack trk) { return trk.mcIndex == mcPart.globalIndex (); });
9801032 if (it != candidateTracks[iP].end ()) {
9811033 continue ;
@@ -1385,7 +1437,13 @@ struct ebyeMaker {
13851437 selMask = getTrackSelMask (candidateTrack);
13861438 // if (candidateTrack.outerPID < -4)
13871439 // continue;
1440+ if (candidateTrack.pdgcodemoth > 0 )
1441+ selMask |= candidateTrack.pdgcodemoth ;
1442+ } else if (candidateTrack.pdgcodemoth > 0 ) {
1443+ selMask = candidateTrack.pdgcodemoth ;
13881444 }
1445+ if (selMask < 0 )
1446+ continue ;
13891447 mcMiniTrkTable (
13901448 miniCollTable.lastIndex (),
13911449 candidateTrack.pt ,
0 commit comments