Skip to content

Commit 1a9ec7f

Browse files
fmazzascFrancesco Mazzaschialibuild
authored
[PWGLF] Fix MC generated information (AliceO2Group#11815)
Co-authored-by: Francesco Mazzaschi <[email protected]> Co-authored-by: ALICE Action Bot <[email protected]>
1 parent 7de84fe commit 1a9ec7f

File tree

1 file changed

+58
-30
lines changed

1 file changed

+58
-30
lines changed

PWGLF/Tasks/Strangeness/sigmaminustask.cxx

Lines changed: 58 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ using namespace o2::framework::expressions;
2828

2929
using TracksFull = soa::Join<aod::TracksIU, aod::TracksExtra, aod::TracksCovIU, aod::pidTPCPi>;
3030
using CollisionsFull = soa::Join<aod::Collisions, aod::EvSel>;
31-
using CollisionsFullMC = soa::Join<aod::Collisions, aod::McCollisionLabels, aod::EvSels>;
31+
using CollisionsFullMC = soa::Join<aod::Collisions, aod::McCollisionLabels, aod::EvSel>;
3232

3333
struct sigmaminustask {
3434
// Histograms are defined with HistogramRegistry
@@ -39,6 +39,8 @@ struct sigmaminustask {
3939
Configurable<float> cutzvertex{"cutzvertex", 10.0f, "Accepted z-vertex range (cm)"};
4040
Configurable<float> cutNSigmaPi{"cutNSigmaPi", 4, "NSigmaTPCPion"};
4141

42+
Preslice<aod::KinkCands> mPerCol = aod::track::collisionId;
43+
4244
void init(InitContext const&)
4345
{
4446
// Axes
@@ -58,7 +60,8 @@ struct sigmaminustask {
5860

5961
if (doprocessMC) {
6062
// Add MC histograms if needed
61-
rSigmaMinus.add("h2MassSigmaMinusPtMC", "h2MassSigmaMinusPtMC", {HistType::kTH2F, {ptAxis, sigmaMassAxis}});
63+
rSigmaMinus.add("h2MassPtMCRec", "h2MassPtMCRec", {HistType::kTH2F, {ptAxis, sigmaMassAxis}});
64+
rSigmaMinus.add("h2MassPtMCGen", "h2MassPtMCGen", {HistType::kTH2F, {ptAxis, sigmaMassAxis}});
6265
}
6366
}
6467

@@ -80,46 +83,71 @@ struct sigmaminustask {
8083
}
8184
PROCESS_SWITCH(sigmaminustask, processData, "Data processing", true);
8285

83-
void processMC(CollisionsFullMC::iterator const& collision, aod::KinkCands const& KinkCands, aod::McTrackLabels const& trackLabelsMC, aod::McParticles const&, TracksFull const&)
86+
void processMC(CollisionsFullMC const& collisions, aod::KinkCands const& KinkCands, aod::McTrackLabels const& trackLabelsMC, aod::McParticles const& particlesMC, TracksFull const&)
8487
{
85-
if (std::abs(collision.posZ()) > cutzvertex || !collision.sel8()) {
86-
return;
87-
}
88-
rEventSelection.fill(HIST("hVertexZRec"), collision.posZ());
89-
for (const auto& kinkCand : KinkCands) {
90-
auto dauTrack = kinkCand.trackDaug_as<TracksFull>();
91-
auto mothTrack = kinkCand.trackMoth_as<TracksFull>();
92-
if (dauTrack.sign() != mothTrack.sign()) {
93-
LOG(info) << "Skipping kink candidate with opposite sign daughter and mother: " << kinkCand.globalIndex();
94-
continue; // Skip if the daughter has the opposite sign as the mother
95-
}
96-
if (abs(dauTrack.tpcNSigmaPi()) > cutNSigmaPi) {
88+
for (const auto& collision : collisions) {
89+
if (std::abs(collision.posZ()) > cutzvertex || !collision.sel8()) {
9790
continue;
9891
}
9992

100-
rSigmaMinus.fill(HIST("h2MassSigmaMinusPt"), kinkCand.mothSign() * kinkCand.ptMoth(), kinkCand.mSigmaMinus());
101-
rSigmaMinus.fill(HIST("h2SigmaMassVsXiMass"), kinkCand.mXiMinus(), kinkCand.mSigmaMinus());
102-
rSigmaMinus.fill(HIST("h2NSigmaPiPt"), kinkCand.mothSign() * kinkCand.ptMoth(), dauTrack.tpcNSigmaPi());
103-
// do MC association
104-
auto mcLabSigma = trackLabelsMC.rawIteratorAt(mothTrack.globalIndex());
105-
auto mcLabPiDau = trackLabelsMC.rawIteratorAt(dauTrack.globalIndex());
106-
if (mcLabSigma.has_mcParticle() && mcLabPiDau.has_mcParticle()) {
107-
auto mcTrackSigma = mcLabSigma.mcParticle_as<aod::McParticles>();
108-
auto mcTrackPiDau = mcLabPiDau.mcParticle_as<aod::McParticles>();
109-
if (!mcTrackPiDau.has_mothers()) {
93+
rEventSelection.fill(HIST("hVertexZRec"), collision.posZ());
94+
auto kinkCandPerColl = KinkCands.sliceBy(mPerCol, collision.globalIndex());
95+
for (const auto& kinkCand : kinkCandPerColl) {
96+
auto dauTrack = kinkCand.trackDaug_as<TracksFull>();
97+
auto mothTrack = kinkCand.trackMoth_as<TracksFull>();
98+
if (dauTrack.sign() != mothTrack.sign()) {
99+
LOG(info) << "Skipping kink candidate with opposite sign daughter and mother: " << kinkCand.globalIndex();
100+
continue; // Skip if the daughter has the opposite sign as the mother
101+
}
102+
if (abs(dauTrack.tpcNSigmaPi()) > cutNSigmaPi) {
110103
continue;
111104
}
112-
for (auto& piMother : mcTrackPiDau.mothers_as<aod::McParticles>()) {
113-
if (piMother.globalIndex() != mcTrackSigma.globalIndex()) {
105+
106+
rSigmaMinus.fill(HIST("h2MassSigmaMinusPt"), kinkCand.mothSign() * kinkCand.ptMoth(), kinkCand.mSigmaMinus());
107+
rSigmaMinus.fill(HIST("h2SigmaMassVsXiMass"), kinkCand.mXiMinus(), kinkCand.mSigmaMinus());
108+
rSigmaMinus.fill(HIST("h2NSigmaPiPt"), kinkCand.mothSign() * kinkCand.ptMoth(), dauTrack.tpcNSigmaPi());
109+
// do MC association
110+
auto mcLabSigma = trackLabelsMC.rawIteratorAt(mothTrack.globalIndex());
111+
auto mcLabPiDau = trackLabelsMC.rawIteratorAt(dauTrack.globalIndex());
112+
if (mcLabSigma.has_mcParticle() && mcLabPiDau.has_mcParticle()) {
113+
auto mcTrackSigma = mcLabSigma.mcParticle_as<aod::McParticles>();
114+
auto mcTrackPiDau = mcLabPiDau.mcParticle_as<aod::McParticles>();
115+
if (!mcTrackPiDau.has_mothers()) {
114116
continue;
115117
}
116-
if (std::abs(mcTrackSigma.pdgCode()) != 3112 || std::abs(mcTrackPiDau.pdgCode()) != 211) {
117-
continue;
118+
for (auto& piMother : mcTrackPiDau.mothers_as<aod::McParticles>()) {
119+
if (piMother.globalIndex() != mcTrackSigma.globalIndex()) {
120+
continue;
121+
}
122+
if (std::abs(mcTrackSigma.pdgCode()) != 3112 || std::abs(mcTrackPiDau.pdgCode()) != 211) {
123+
continue;
124+
}
125+
rSigmaMinus.fill(HIST("h2MassPtMCRec"), kinkCand.mothSign() * kinkCand.ptMoth(), kinkCand.mSigmaMinus());
118126
}
119-
rSigmaMinus.fill(HIST("h2MassSigmaMinusPtMC"), kinkCand.mothSign() * kinkCand.ptMoth(), kinkCand.mSigmaMinus());
120127
}
121128
}
122129
}
130+
for (const auto& mcPart : particlesMC) {
131+
if (std::abs(mcPart.pdgCode()) != 3112 || std::abs(mcPart.y()) > 0.5) {
132+
continue;
133+
}
134+
if (!mcPart.has_daughters()) {
135+
continue; // Skip if no daughters
136+
}
137+
bool hasSigmaDaughter = false;
138+
for (const auto& daughter : mcPart.daughters_as<aod::McParticles>()) {
139+
if (std::abs(daughter.pdgCode()) == 211) { // Sigma PDG code
140+
hasSigmaDaughter = true;
141+
break; // Found a pi daughter, exit loop
142+
}
143+
}
144+
if (!hasSigmaDaughter) {
145+
continue; // Skip if no pi daughter found
146+
}
147+
float mcMass = std::sqrt(mcPart.e() * mcPart.e() - mcPart.p() * mcPart.p());
148+
int sigmaSign = mcPart.pdgCode() > 0 ? 1 : -1; // Determine the sign of the Sigma
149+
rSigmaMinus.fill(HIST("h2MassPtMCGen"), sigmaSign * mcPart.pt(), mcMass);
150+
}
123151
}
124152
PROCESS_SWITCH(sigmaminustask, processMC, "MC processing", false);
125153
};

0 commit comments

Comments
 (0)