Skip to content

Commit a39f1e8

Browse files
new logic for the mc process that allows to store also he3-had pairs not coming from decay
1 parent 905ba83 commit a39f1e8

File tree

1 file changed

+104
-21
lines changed

1 file changed

+104
-21
lines changed

PWGLF/TableProducer/Nuspex/he3HadronFemto.cxx

Lines changed: 104 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -100,11 +100,18 @@ enum Selections {
100100
};
101101

102102
enum Flags {
103-
kPrimary = BIT(0),
104-
kFromLi4 = BIT(1),
105-
kFromHypertriton = BIT(2),
106-
kFromOtherDecay = BIT(3),
107-
kFromMaterial = BIT(4)
103+
kBothPrimaries = BIT(0),
104+
kBothFromLi4 = BIT(1),
105+
kBothFromHypertriton = BIT(2),
106+
kMixedPair = BIT(3), // a primary and one from Li4/hypertriton/material/other decays (or any other combination)
107+
};
108+
109+
enum ParticleFlags {
110+
kPhysicalPrimary = BIT(0), // primary particle
111+
kFromLi4 = BIT(1), // from Li4 decay
112+
kFromHypertriton = BIT(2), // from hypertriton decay
113+
kFromMaterial = BIT(3), // from material
114+
kFromOtherDecays = BIT(4), // from other decays
108115
};
109116

110117
} // namespace
@@ -169,6 +176,7 @@ struct He3HadCandidate {
169176

170177
uint8_t flagsHe3 = 0; // flags for He3
171178
uint8_t flagsHad = 0; // flags for hadron
179+
uint8_t flags = 0; // flags for the pair
172180

173181
// collision information
174182
int32_t collisionID = 0;
@@ -655,8 +663,6 @@ struct he3HadronFemto {
655663
he3Hadcand.momHadMC = mctrackHad.pt() * (mctrackHad.pdgCode() > 0 ? 1 : -1);
656664
he3Hadcand.etaHadMC = mctrackHad.eta();
657665
he3Hadcand.phiHadMC = mctrackHad.phi();
658-
he3Hadcand.isHe3Primary = mctrackHe3.isPhysicalPrimary();
659-
he3Hadcand.isHadPrimary = mctrackHad.isPhysicalPrimary();
660666
}
661667

662668
template <typename Mc>
@@ -780,8 +786,7 @@ struct he3HadronFemto {
780786
he3Hadcand.phiHadMC,
781787
he3Hadcand.l4PtMC,
782788
he3Hadcand.l4MassMC,
783-
he3Hadcand.flagsHe3,
784-
he3Hadcand.flagsHad);
789+
he3Hadcand.flags);
785790
}
786791
if (settingFillMultiplicity) {
787792
outputMultiplicityTable(
@@ -827,6 +832,47 @@ struct he3HadronFemto {
827832
}
828833
}
829834

835+
template <typename TmcParticle>
836+
void setMcParticleFlag(const TmcParticle& mcParticle, std::vector<unsigned int>& mothers, uint8_t& flag)
837+
{
838+
if (mcParticle.isPhysicalPrimary() == true) {
839+
840+
flag |= ParticleFlags::kPhysicalPrimary;
841+
if (!mcParticle.has_mothers()) {
842+
return;
843+
}
844+
845+
for (const auto& mother : mcParticle.mothers_as<aod::McParticles>()) {
846+
mothers.push_back(mother.globalIndex());
847+
if (std::abs(mother.pdgCode()) == Li4PDG) {
848+
flag |= ParticleFlags::kFromLi4;
849+
} else if (std::abs(mother.pdgCode()) == o2::constants::physics::Pdg::kHyperTriton) {
850+
flag |= ParticleFlags::kFromHypertriton;
851+
} else {
852+
flag |= ParticleFlags::kFromOtherDecays;
853+
}
854+
}
855+
856+
} else {
857+
858+
if (!mcParticle.has_mothers()) {
859+
flag |= ParticleFlags::kFromMaterial;
860+
return;
861+
}
862+
863+
for (const auto& mother : mothers) {
864+
mothers.push_back(mother.globalIndex());
865+
if (std::abs(mother.pdgCode()) == Li4PDG) {
866+
flag |= ParticleFlags::kFromLi4;
867+
} else if (std::abs(mother.pdgCode()) == o2::constants::physics::Pdg::kHyperTriton) {
868+
flag |= ParticleFlags::kFromHypertriton;
869+
} else {
870+
flag |= ParticleFlags::kFromOtherDecays;
871+
}
872+
}
873+
}
874+
}
875+
830876
template <typename Tcollisions, typename TmcParticles>
831877
void fillMcParticles(const Tcollisions& collisions, const TmcParticles& mcParticles, std::vector<unsigned int>& filledMothers)
832878
{
@@ -953,25 +999,62 @@ struct he3HadronFemto {
953999
continue;
9541000
}
9551001

956-
for (const auto& mothertrack : mctrackHe3.mothers_as<aod::McParticles>()) {
957-
for (const auto& mothertrackHad : mctrackHad.mothers_as<aod::McParticles>()) {
958-
959-
if (mothertrack != mothertrackHad || std::abs(mothertrack.pdgCode()) != Li4PDG || std::abs(mothertrack.y()) > 1) {
1002+
He3HadCandidate he3Hadcand;
1003+
McIter motherParticle;
1004+
std::vector<unsigned int> motherHe3Idxs, motherHadIdxs;
1005+
setMcParticleFlag(mctrackHe3, motherHe3Idxs, he3Hadcand.flagsHe3);
1006+
setMcParticleFlag(mctrackHad, motherHadIdxs, he3Hadcand.flagsHad);
1007+
1008+
if ((he3Hadcand.flagsHe3 == ParticleFlags::kPhysicalPrimary && he3Hadcand.flagsHad == ParticleFlags::kPhysicalPrimary)) {
1009+
he3Hadcand.flags |= Flags::kBothPrimaries;
1010+
1011+
} else if ((he3Hadcand.flagsHe3 & ParticleFlags::kFromLi4) && (he3Hadcand.flagsHad & ParticleFlags::kFromLi4)) {
1012+
he3Hadcand.flags |= Flags::kFromLi4;
1013+
1014+
std::unordered_set<unsigned int> motherHe3SetIdxs(motherHe3Idxs.begin(), motherHe3Idxs.end());
1015+
for (const auto& motherHadIdx : motherHadIdxs) {
1016+
if (motherHe3SetIdxs.contains(motherHadIdx)) {
9601017
continue;
9611018
}
1019+
1020+
motherParticle = mcParticles.rawIteratorAt(motherHadIdx);
1021+
if (!motherParticle.pdgCode() == Li4PDG || std::abs(motherParticle.y()) > 1) {
1022+
continue;
1023+
}
1024+
}
1025+
1026+
} else if ((he3Hadcand.flagsHe3 & ParticleFlags::kFromHypertriton) && (he3Hadcand.flagsHad & ParticleFlags::kFromHypertriton)) {
1027+
he3Hadcand.flags |= Flags::kFromHypertriton;
9621028

963-
He3HadCandidate he3Hadcand;
964-
if (!fillCandidateInfo(heTrack, prTrack, collBracket, collisions, he3Hadcand, tracks, /*mix*/ false)) {
1029+
std::unordered_set<unsigned int> motherHe3SetIdxs(motherHe3Idxs.begin(), motherHe3Idxs.end());
1030+
for (const auto& motherHadIdx : motherHadIdxs) {
1031+
if (motherHe3SetIdxs.contains(motherHadIdx)) {
9651032
continue;
9661033
}
967-
fillCandidateInfoMC(mctrackHe3, mctrackHad, he3Hadcand);
968-
fillMotherInfoMC(mctrackHe3, mctrackHad, mothertrack, he3Hadcand);
969-
fillHistograms(he3Hadcand);
970-
auto collision = collisions.rawIteratorAt(he3Hadcand.collisionID);
971-
fillTable(he3Hadcand, collision, /*isMC*/ true);
972-
filledMothers.push_back(mothertrack.globalIndex());
1034+
1035+
motherParticle = mcParticles.rawIteratorAt(motherHadIdx);
1036+
if (!motherParticle.pdgCode() == o2::constants::physics::Pdg::kHyperTriton || std::abs(motherParticle.y()) > 1) {
1037+
continue;
1038+
}
9731039
}
1040+
1041+
} else {
1042+
he3Hadcand.flags |= Flags::kMixedPair;
9741043
}
1044+
1045+
if (!fillCandidateInfo(heTrack, prTrack, collBracket, collisions, he3Hadcand, tracks, /*mix*/ false)) {
1046+
continue;
1047+
}
1048+
fillCandidateInfoMC(mctrackHe3, mctrackHad, he3Hadcand);
1049+
1050+
if ((he3Hadcand.flags == Flags::kBothFromLi4) || (he3Hadcand.flags == Flags::kBothFromHypertriton)) {
1051+
fillMotherInfoMC(mctrackHe3, mctrackHad, mothertrack, he3Hadcand);
1052+
filledMothers.push_back(motherParticle.globalIndex());
1053+
}
1054+
1055+
fillHistograms(he3Hadcand);
1056+
auto collision = collisions.rawIteratorAt(he3Hadcand.collisionID);
1057+
fillTable(he3Hadcand, collision, /*isMC*/ true);
9751058
}
9761059
}
9771060

0 commit comments

Comments
 (0)