Skip to content

Commit d317413

Browse files
authored
PWGHF: Fix MC matching flags. (#5330)
Use the DecayType values as bit numbers in MC matching as well. This fixes the issue where one cannot distinguish particles and antiparticles for decays with decay type 0.
1 parent 464b5ea commit d317413

File tree

5 files changed

+30
-30
lines changed

5 files changed

+30
-30
lines changed

Analysis/Tasks/PWGHF/HFCandidateCreator2Prong.cxx

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ struct HFCandidateCreator2Prong {
6767
df.setMinRelChi2Change(d_minrelchi2change);
6868
df.setUseAbsDCA(true);
6969

70-
// loop over pairs of track indeces
70+
// loop over pairs of track indices
7171
for (const auto& rowTrackIndexProng2 : rowsTrackIndexProng2) {
7272
auto trackParVarPos1 = getTrackParCov(rowTrackIndexProng2.index0());
7373
auto trackParVarNeg1 = getTrackParCov(rowTrackIndexProng2.index1());
@@ -147,51 +147,51 @@ struct HFCandidateCreator2ProngMC {
147147
aod::McParticles const& particlesMC)
148148
{
149149
int8_t sign = 0;
150-
int8_t result = N2ProngDecays;
150+
int8_t flag = 0;
151151

152152
// Match reconstructed candidates.
153153
for (auto& candidate : candidates) {
154154
//Printf("New rec. candidate");
155-
result = N2ProngDecays;
155+
flag = 0;
156156
auto arrayDaughters = array{candidate.index0_as<aod::BigTracksMC>(), candidate.index1_as<aod::BigTracksMC>()};
157157

158158
// D0(bar) → π± K∓
159159
//Printf("Checking D0(bar) → π± K∓");
160160
if (RecoDecay::getMatchedMCRec(particlesMC, arrayDaughters, 421, array{+kPiPlus, -kKPlus}, true, &sign) > -1) {
161-
result = sign * D0ToPiK;
161+
flag = sign * (1 << D0ToPiK);
162162
}
163163

164164
// J/ψ → e+ e-
165-
if (result == N2ProngDecays) {
165+
if (flag == 0) {
166166
//Printf("Checking J/ψ → e+ e-");
167167
if (RecoDecay::getMatchedMCRec(particlesMC, std::move(arrayDaughters), 443, array{+kElectron, -kElectron}, true) > -1) {
168-
result = JpsiToEE;
168+
flag = 1 << JpsiToEE;
169169
}
170170
}
171171

172-
rowMCMatchRec(result);
172+
rowMCMatchRec(flag);
173173
}
174174

175175
// Match generated particles.
176176
for (auto& particle : particlesMC) {
177177
//Printf("New gen. candidate");
178-
result = N2ProngDecays;
178+
flag = 0;
179179

180180
// D0(bar) → π± K∓
181181
//Printf("Checking D0(bar) → π± K∓");
182182
if (RecoDecay::isMatchedMCGen(particlesMC, particle, 421, array{+kPiPlus, -kKPlus}, true, &sign)) {
183-
result = sign * D0ToPiK;
183+
flag = sign * (1 << D0ToPiK);
184184
}
185185

186186
// J/ψ → e+ e-
187-
if (result == N2ProngDecays) {
187+
if (flag == 0) {
188188
//Printf("Checking J/ψ → e+ e-");
189189
if (RecoDecay::isMatchedMCGen(particlesMC, particle, 443, array{+kElectron, -kElectron}, true)) {
190-
result = JpsiToEE;
190+
flag = 1 << JpsiToEE;
191191
}
192192
}
193193

194-
rowMCMatchGen(result);
194+
rowMCMatchGen(flag);
195195
}
196196
}
197197
};

Analysis/Tasks/PWGHF/HFCandidateCreator3Prong.cxx

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ struct HFCandidateCreator3Prong {
6666
df.setMinRelChi2Change(d_minrelchi2change);
6767
df.setUseAbsDCA(true);
6868

69-
// loop over pairs of track indeces
69+
// loop over triplets of track indices
7070
for (const auto& rowTrackIndexProng3 : rowsTrackIndexProng3) {
7171
auto trackParVar0 = getTrackParCov(rowTrackIndexProng3.index0());
7272
auto trackParVar1 = getTrackParCov(rowTrackIndexProng3.index1());
@@ -151,51 +151,51 @@ struct HFCandidateCreator3ProngMC {
151151
aod::McParticles const& particlesMC)
152152
{
153153
int8_t sign = 0;
154-
int8_t result = N3ProngDecays;
154+
int8_t flag = 0;
155155

156156
// Match reconstructed candidates.
157157
for (auto& candidate : candidates) {
158158
//Printf("New rec. candidate");
159-
result = N3ProngDecays;
159+
flag = 0;
160160
auto arrayDaughters = array{candidate.index0_as<aod::BigTracksMC>(), candidate.index1_as<aod::BigTracksMC>(), candidate.index2_as<aod::BigTracksMC>()};
161161

162162
// D± → π± K∓ π±
163163
//Printf("Checking D± → π± K∓ π±");
164164
if (RecoDecay::getMatchedMCRec(particlesMC, arrayDaughters, 411, array{+kPiPlus, -kKPlus, +kPiPlus}, true, &sign) > -1) {
165-
result = sign * DPlusToPiKPi;
165+
flag = sign * (1 << DPlusToPiKPi);
166166
}
167167

168168
// Λc± → p± K∓ π±
169-
if (result == N3ProngDecays) {
169+
if (flag == 0) {
170170
//Printf("Checking Λc± → p± K∓ π±");
171171
if (RecoDecay::getMatchedMCRec(particlesMC, std::move(arrayDaughters), 4122, array{+kProton, -kKPlus, +kPiPlus}, true, &sign) > -1) {
172-
result = sign * LcToPKPi;
172+
flag = sign * (1 << LcToPKPi);
173173
}
174174
}
175175

176-
rowMCMatchRec(result);
176+
rowMCMatchRec(flag);
177177
}
178178

179179
// Match generated particles.
180180
for (auto& particle : particlesMC) {
181181
//Printf("New gen. candidate");
182-
result = N3ProngDecays;
182+
flag = 0;
183183

184184
// D± → π± K∓ π±
185185
//Printf("Checking D± → π± K∓ π±");
186186
if (RecoDecay::isMatchedMCGen(particlesMC, particle, 411, array{+kPiPlus, -kKPlus, +kPiPlus}, true, &sign)) {
187-
result = sign * DPlusToPiKPi;
187+
flag = sign * (1 << DPlusToPiKPi);
188188
}
189189

190190
// Λc± → p± K∓ π±
191-
if (result == N3ProngDecays) {
191+
if (flag == 0) {
192192
//Printf("Checking Λc± → p± K∓ π±");
193193
if (RecoDecay::isMatchedMCGen(particlesMC, particle, 4122, array{+kProton, -kKPlus, +kPiPlus}, true, &sign)) {
194-
result = sign * LcToPKPi;
194+
flag = sign * (1 << LcToPKPi);
195195
}
196196
}
197197

198-
rowMCMatchGen(result);
198+
rowMCMatchGen(flag);
199199
}
200200
}
201201
};

Analysis/Tasks/PWGHF/taskD0.cxx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -131,7 +131,7 @@ struct TaskD0MC {
131131
//Printf("MC Rec.: eta rejection: %g", candidate.eta());
132132
continue;
133133
}
134-
if (std::abs(candidate.flagMCMatchRec()) == D0ToPiK) {
134+
if (std::abs(candidate.flagMCMatchRec()) == 1 << D0ToPiK) {
135135
// Get the corresponding MC particle.
136136
auto indexMother = RecoDecay::getMother(particlesMC, candidate.index0_as<aod::BigTracksMC>().label_as<soa::Join<aod::McParticles, aod::HfCandProng2MCGen>>(), 421, true);
137137
auto particleMother = particlesMC.iteratorAt(indexMother);
@@ -152,7 +152,7 @@ struct TaskD0MC {
152152
//Printf("MC Gen.: eta rejection: %g", particle.eta());
153153
continue;
154154
}
155-
if (std::abs(particle.flagMCMatchGen()) == D0ToPiK) {
155+
if (std::abs(particle.flagMCMatchGen()) == 1 << D0ToPiK) {
156156
registry.fill(HIST("hPtGen"), particle.pt());
157157
registry.fill(HIST("hEtaGen"), particle.eta());
158158
}

Analysis/Tasks/PWGHF/taskJpsi.cxx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,7 @@ struct TaskJpsiMC {
118118
//Printf("MC Rec.: eta rejection: %g", candidate.eta());
119119
continue;
120120
}
121-
if (candidate.flagMCMatchRec() == JpsiToEE) {
121+
if (candidate.flagMCMatchRec() == 1 << JpsiToEE) {
122122
registry.fill(HIST("hPtRecSig"), candidate.pt());
123123
registry.fill(HIST("hCPARecSig"), candidate.cpa());
124124
registry.fill(HIST("hEtaRecSig"), candidate.eta());
@@ -135,7 +135,7 @@ struct TaskJpsiMC {
135135
//Printf("MC Gen.: eta rejection: %g", particle.eta());
136136
continue;
137137
}
138-
if (std::abs(particle.flagMCMatchGen()) == JpsiToEE) {
138+
if (particle.flagMCMatchGen() == 1 << JpsiToEE) {
139139
registry.fill(HIST("hPtGen"), particle.pt());
140140
registry.fill(HIST("hEtaGen"), particle.eta());
141141
}

Analysis/Tasks/PWGHF/taskLc.cxx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -130,7 +130,7 @@ struct TaskLcMC {
130130
//Printf("MC Rec.: eta rejection: %g", candidate.eta());
131131
continue;
132132
}
133-
if (std::abs(candidate.flagMCMatchRec()) == LcToPKPi) {
133+
if (std::abs(candidate.flagMCMatchRec()) == 1 << LcToPKPi) {
134134
registry.fill(HIST("hPtRecSig"), candidate.pt());
135135
registry.fill(HIST("hCPARecSig"), candidate.cpa());
136136
registry.fill(HIST("hEtaRecSig"), candidate.eta());
@@ -147,7 +147,7 @@ struct TaskLcMC {
147147
//Printf("MC Gen.: eta rejection: %g", particle.eta());
148148
continue;
149149
}
150-
if (std::abs(particle.flagMCMatchGen()) == LcToPKPi) {
150+
if (std::abs(particle.flagMCMatchGen()) == 1 << LcToPKPi) {
151151
registry.fill(HIST("hPtGen"), particle.pt());
152152
registry.fill(HIST("hEtaGen"), particle.eta());
153153
}

0 commit comments

Comments
 (0)