Skip to content

Commit baca7c0

Browse files
JaeYoonCHOpstahlhualibuild
authored
[PWGHF] Fix MC generated particle matching (#9649)
Co-authored-by: pstahlhu <phil.lennart.stahlhut@cern.ch> Co-authored-by: ALICE Action Bot <alibuild@cern.ch>
1 parent ee2ab6f commit baca7c0

File tree

2 files changed

+27
-20
lines changed

2 files changed

+27
-20
lines changed

PWGHF/TableProducer/candidateCreatorXicToXiPiPi.cxx

Lines changed: 25 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
/// \author Jinjoo Seo <jseo@cern.ch>, Heidelberg University
1818

1919
#ifndef HomogeneousField
20-
#define HomogeneousField
20+
#define HomogeneousField // o2-linter: disable=name/macro
2121
#endif
2222

2323
#include <string>
@@ -118,7 +118,7 @@ struct HfCandidateCreatorXicToXiPiPi {
118118
if (fillHistograms) {
119119
// counter
120120
registry.add("hVertexerType", "Use KF or DCAFitterN;Vertexer type;entries", {HistType::kTH1F, {{2, -0.5, 1.5}}}); // See o2::aod::hf_cand::VertexerType
121-
registry.add("hCandCounter", "hCandCounter", {HistType::kTH1F, {{3, 0.f, 0.3}}});
121+
registry.add("hCandCounter", "hCandCounter", {HistType::kTH1F, {{3, 0.5, 3.5}}});
122122
registry.get<TH1>(HIST("hCandCounter"))->GetXaxis()->SetBinLabel(1 + AllIdTriplets, "total");
123123
registry.get<TH1>(HIST("hCandCounter"))->GetXaxis()->SetBinLabel(1 + CascPreSel, "Cascade preselection");
124124
registry.get<TH1>(HIST("hCandCounter"))->GetXaxis()->SetBinLabel(1 + VertexFit, "Successful vertex fit");
@@ -435,7 +435,7 @@ struct HfCandidateCreatorXicToXiPiPi {
435435
KFPVertex kfpVertex = createKFPVertexFromCollision(collision);
436436
float covMatrixPV[6];
437437
kfpVertex.GetCovarianceMatrix(covMatrixPV);
438-
KFParticle KFPV(kfpVertex); // for calculation of DCAs to PV
438+
KFParticle kfPv(kfpVertex); // for calculation of DCAs to PV
439439

440440
// convert pion tracks into KFParticle object
441441
KFPTrack kfpTrackCharmBachelor0 = createKFPTrackFromTrack(trackCharmBachelor0);
@@ -470,9 +470,9 @@ struct HfCandidateCreatorXicToXiPiPi {
470470
float chi2GeoXicPlus = kfXicPlus.GetChi2() / kfXicPlus.GetNDF();
471471

472472
// topological constraint of Xic to PV
473-
float chi2topoXicPlusToPVBeforeConstraint = kfXicPlus.GetDeviationFromVertex(KFPV);
473+
float chi2topoXicPlusToPVBeforeConstraint = kfXicPlus.GetDeviationFromVertex(kfPv);
474474
KFParticle kfXicPlusToPV = kfXicPlus;
475-
kfXicPlusToPV.SetProductionVertex(KFPV);
475+
kfXicPlusToPV.SetProductionVertex(kfPv);
476476
float chi2topoXicPlusToPV = kfXicPlusToPV.GetChi2() / kfXicPlusToPV.GetNDF();
477477
if (constrainXicPlusToPv) {
478478
kfXicPlus = kfXicPlusToPV;
@@ -518,9 +518,9 @@ struct HfCandidateCreatorXicToXiPiPi {
518518
float impactParameterPi0XY = 0., errImpactParameterPi0XY = 0.;
519519
float impactParameterPi1XY = 0., errImpactParameterPi1XY = 0.;
520520
float impactParameterXiXY = 0., errImpactParameterXiXY = 0.;
521-
kfCharmBachelor0.GetDistanceFromVertexXY(KFPV, impactParameterPi0XY, errImpactParameterPi0XY);
522-
kfCharmBachelor1.GetDistanceFromVertexXY(KFPV, impactParameterPi1XY, errImpactParameterPi1XY);
523-
kfXi.GetDistanceFromVertexXY(KFPV, impactParameterXiXY, errImpactParameterXiXY);
521+
kfCharmBachelor0.GetDistanceFromVertexXY(kfPv, impactParameterPi0XY, errImpactParameterPi0XY);
522+
kfCharmBachelor1.GetDistanceFromVertexXY(kfPv, impactParameterPi1XY, errImpactParameterPi1XY);
523+
kfXi.GetDistanceFromVertexXY(kfPv, impactParameterXiXY, errImpactParameterXiXY);
524524

525525
// calculate cosine of pointing angle
526526
std::array<float, 3> pvCoord = {collision.posX(), collision.posY(), collision.posZ()};
@@ -618,7 +618,7 @@ struct HfCandidateCreatorXicToXiPiPi {
618618

619619
//------------------------------fill candidate table rows--------------------------------------
620620
rowCandidateBase(collision.globalIndex(),
621-
KFPV.GetX(), KFPV.GetY(), KFPV.GetZ(),
621+
kfPv.GetX(), kfPv.GetY(), kfPv.GetZ(),
622622
std::sqrt(covMatrixPV[0]), std::sqrt(covMatrixPV[2]), std::sqrt(covMatrixPV[5]),
623623
/*3-prong specific columns*/
624624
rowTrackIndexXicPlus.cascadeId(), rowTrackIndexXicPlus.prong0Id(), rowTrackIndexXicPlus.prong1Id(),
@@ -696,20 +696,20 @@ struct HfCandidateCreatorXicToXiPiPiExpressions {
696696
candidate.negTrack_as<aod::TracksWMc>()};
697697

698698
// Xic → pi pi pi pi p
699-
indexRec = RecoDecay::getMatchedMCRec(mcParticles, arrayDaughters, Pdg::kXiCPlus, std::array{+kPiPlus, +kPiPlus, +kPiMinus, +kProton, +kPiMinus}, true, &sign, 4);
699+
indexRec = RecoDecay::getMatchedMCRec<false, true, false, true>(mcParticles, arrayDaughters, Pdg::kXiCPlus, std::array{+kPiPlus, +kPiPlus, +kPiMinus, +kProton, +kPiMinus}, true, &sign, 4);
700700
indexRecXicPlus = indexRec;
701701
if (indexRec == -1) {
702702
debug = 1;
703703
}
704704
if (indexRec > -1) {
705705
// Xi- → pi pi p
706-
indexRec = RecoDecay::getMatchedMCRec(mcParticles, arrayDaughtersCasc, +kXiMinus, std::array{+kPiMinus, +kProton, +kPiMinus}, true, &sign, 2);
706+
indexRec = RecoDecay::getMatchedMCRec<false, true, false, true>(mcParticles, arrayDaughtersCasc, +kXiMinus, std::array{+kPiMinus, +kProton, +kPiMinus}, true, &sign, 2);
707707
if (indexRec == -1) {
708708
debug = 2;
709709
}
710710
if (indexRec > -1) {
711711
// Lambda → p pi
712-
indexRec = RecoDecay::getMatchedMCRec(mcParticles, arrayDaughtersV0, +kLambda0, std::array{+kProton, +kPiMinus}, true, &sign, 1);
712+
indexRec = RecoDecay::getMatchedMCRec<false, true, false, true>(mcParticles, arrayDaughtersV0, +kLambda0, std::array{+kProton, +kPiMinus}, true, &sign, 1);
713713
if (indexRec == -1) {
714714
debug = 3;
715715
}
@@ -735,7 +735,7 @@ struct HfCandidateCreatorXicToXiPiPiExpressions {
735735
// Check whether the charm baryon is non-prompt (from a b quark).
736736
if (flag != 0) {
737737
auto particle = mcParticles.rawIteratorAt(indexRecXicPlus);
738-
origin = RecoDecay::getCharmHadronOrigin(mcParticles, particle, true);
738+
origin = RecoDecay::getCharmHadronOrigin(mcParticles, particle, false);
739739
}
740740

741741
rowMcMatchRec(flag, debug, origin);
@@ -750,18 +750,24 @@ struct HfCandidateCreatorXicToXiPiPiExpressions {
750750
arrDaughIndex.clear();
751751

752752
// Xic → Xi pi pi
753-
if (RecoDecay::isMatchedMCGen(mcParticles, particle, Pdg::kXiCPlus, std::array{+kXiMinus, +kPiPlus, +kPiPlus}, true, &sign, 2)) {
753+
if (RecoDecay::isMatchedMCGen<false, true>(mcParticles, particle, Pdg::kXiCPlus, std::array{+kXiMinus, +kPiPlus, +kPiPlus}, true, &sign, 2)) {
754754
debug = 1;
755755
// Xi- -> Lambda pi
756756
auto cascMC = mcParticles.rawIteratorAt(particle.daughtersIds().front());
757-
if (RecoDecay::isMatchedMCGen(mcParticles, cascMC, +kXiMinus, std::array{+kLambda0, +kPiMinus}, true)) {
757+
// Find Xi- from Xi(1530) -> Xi pi in case of resonant decay
758+
RecoDecay::getDaughters(particle, &arrDaughIndex, std::array{0}, 1);
759+
if (arrDaughIndex.size() == 2) {
760+
auto cascStarMC = mcParticles.rawIteratorAt(particle.daughtersIds().front());
761+
if (RecoDecay::isMatchedMCGen<false, true>(mcParticles, cascStarMC, +3324, std::array{+kXiMinus, +kPiPlus}, true)) {
762+
cascMC = mcParticles.rawIteratorAt(cascStarMC.daughtersIds().front());
763+
}
764+
}
765+
if (RecoDecay::isMatchedMCGen<false, true>(mcParticles, cascMC, +kXiMinus, std::array{+kLambda0, +kPiMinus}, true)) {
758766
debug = 2;
759767
// Lambda -> p pi
760768
auto v0MC = mcParticles.rawIteratorAt(cascMC.daughtersIds().front());
761-
if (RecoDecay::isMatchedMCGen(mcParticles, v0MC, +kLambda0, std::array{+kProton, +kPiMinus}, true)) {
769+
if (RecoDecay::isMatchedMCGen<false, true>(mcParticles, v0MC, +kLambda0, std::array{+kProton, +kPiMinus}, true)) {
762770
debug = 3;
763-
764-
RecoDecay::getDaughters(particle, &arrDaughIndex, std::array{0}, 1);
765771
if (arrDaughIndex.size() == 2) {
766772
for (auto iProng = 0u; iProng < arrDaughIndex.size(); ++iProng) {
767773
auto daughI = mcParticles.rawIteratorAt(arrDaughIndex[iProng]);
@@ -781,7 +787,7 @@ struct HfCandidateCreatorXicToXiPiPiExpressions {
781787

782788
// Check whether the charm baryon is non-prompt (from a b quark).
783789
if (flag != 0) {
784-
origin = RecoDecay::getCharmHadronOrigin(mcParticles, particle, true);
790+
origin = RecoDecay::getCharmHadronOrigin(mcParticles, particle, false);
785791
}
786792

787793
rowMcMatchGen(flag, debug, origin);

PWGHF/TableProducer/treeCreatorXicToXiPiPi.cxx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -820,7 +820,8 @@ struct HfTreeCreatorXicToXiPiPi {
820820

821821
void processResiduals(SelectedCandidatesMc const&,
822822
aod::TracksWMc const& tracks,
823-
aod::McParticles const& particles)
823+
aod::McParticles const& particles,
824+
aod::McCollisions const&)
824825
{
825826
rowCandidateResiduals.reserve(recSig.size());
826827

0 commit comments

Comments
 (0)