Skip to content

Commit ec2cb6d

Browse files
authored
[PWGLF] Fix MC info resetting in decay3bodybuilder (#12219)
1 parent d3816c5 commit ec2cb6d

File tree

2 files changed

+12
-6
lines changed

2 files changed

+12
-6
lines changed

PWGLF/DataModel/Vtx3BodyTables.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -122,6 +122,7 @@ DECLARE_SOA_COLUMN(GenPtPi, genPtPi, float); //! generated transverse
122122
DECLARE_SOA_COLUMN(GenPtDe, genPtDe, float); //! generated transverse momentum deuteron daughter particle
123123
DECLARE_SOA_COLUMN(IsTrueH3L, isTrueH3l, bool); //! flag for true hypertriton candidate
124124
DECLARE_SOA_COLUMN(IsTrueAntiH3L, isTrueAntiH3l, bool); //! flag for true anti-hypertriton candidate
125+
DECLARE_SOA_COLUMN(MotherPdgCode, motherPdgCode, int); //! PDG code of the mother particle
125126
DECLARE_SOA_COLUMN(PrPdgCode, prPdgCode, int); //! MC particle proton PDG code
126127
DECLARE_SOA_COLUMN(PiPdgCode, piPdgCode, int); //! MC particle pion PDG code
127128
DECLARE_SOA_COLUMN(DePdgCode, dePdgCode, int); //! MC particle deuteron PDG code
@@ -276,6 +277,7 @@ DECLARE_SOA_TABLE(McVtx3BodyDatas, "AOD", "MC3BODYDATA", //!
276277
vtx3body::GenPtPr, vtx3body::GenPtPi, vtx3body::GenPtDe,
277278
vtx3body::IsTrueH3L, vtx3body::IsTrueAntiH3L,
278279
vtx3body::IsReco,
280+
vtx3body::MotherPdgCode,
279281
vtx3body::PrPdgCode, vtx3body::PiPdgCode, vtx3body::DePdgCode,
280282
vtx3body::IsDePrimary,
281283
vtx3body::IsSurvEvSel,

PWGLF/TableProducer/Nuspex/decay3bodybuilder.cxx

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -231,6 +231,7 @@ struct decay3bodyBuilder {
231231
bool isTrueH3L;
232232
bool isTrueAntiH3L;
233233
bool isReco;
234+
int motherPdgCode;
234235
int daughterPrPdgCode;
235236
int daughterPiPdgCode;
236237
int daughterDePdgCode;
@@ -849,16 +850,16 @@ struct decay3bodyBuilder {
849850
// get generated mother MC info
850851
if (motherID > 0) {
851852
auto mcTrackH3L = mcParticles.rawIteratorAt(motherID);
852-
int chargeFactor = mcTrackH3L.pdgCode() > 0 ? 1 : -1;
853+
this3BodyMCInfo.motherPdgCode = mcTrackH3L.pdgCode();
853854
this3BodyMCInfo.label = motherID;
854855
this3BodyMCInfo.genMomentum = {mcTrackH3L.px(), mcTrackH3L.py(), mcTrackH3L.pz()};
855856
this3BodyMCInfo.genDecVtx = {mcTrackProton.vx(), mcTrackProton.vy(), mcTrackProton.vz()};
856857
this3BodyMCInfo.genCt = RecoDecay::sqrtSumOfSquares(mcTrackProton.vx() - mcTrackH3L.vx(), mcTrackProton.vy() - mcTrackH3L.vy(), mcTrackProton.vz() - mcTrackH3L.vz()) * o2::constants::physics::MassHyperTriton / mcTrackH3L.p();
857858
this3BodyMCInfo.genPhi = mcTrackH3L.phi();
858859
this3BodyMCInfo.genEta = mcTrackH3L.eta();
859860
this3BodyMCInfo.genRapidity = mcTrackH3L.y();
860-
this3BodyMCInfo.isTrueH3L = chargeFactor > 0;
861-
this3BodyMCInfo.isTrueAntiH3L = chargeFactor < 0;
861+
this3BodyMCInfo.isTrueH3L = this3BodyMCInfo.motherPdgCode > 0 ? true : false;
862+
this3BodyMCInfo.isTrueAntiH3L = this3BodyMCInfo.motherPdgCode < 0 ? true : false;
862863
}
863864

864865
// fill analysis tables (only McVtx3BodyDatas is filled here)
@@ -878,12 +879,12 @@ struct decay3bodyBuilder {
878879
for (const auto& mcparticle : mcParticles) {
879880
// MC info
880881
resetMCInfo(this3BodyMCInfo);
881-
this3BodyMCInfo.isReco = false;
882882

883883
// skip MC particle if reconstructed and already filled previously
884884
if (mcParticleIsReco[mcparticle.globalIndex()] == true) {
885885
continue;
886886
}
887+
this3BodyMCInfo.isReco = false;
887888

888889
// set flag if corresponding MC collision has matched reconstructed collision which passed event selection
889890
this3BodyMCInfo.survivedEventSel = isGoodCollision[mcparticle.mcCollisionId()];
@@ -912,7 +913,7 @@ struct decay3bodyBuilder {
912913
}
913914

914915
// check if hypertriton decayed via 3-body decay and is particle or anti-particle
915-
if ((haveProton && haveAntiPion && haveDeuteron) || (haveAntiProton && havePion && haveAntiDeuteron)) {
916+
if ((haveProton && haveAntiPion && haveDeuteron && !(haveAntiProton || havePion || haveAntiDeuteron)) || (haveAntiProton && havePion && haveAntiDeuteron && !(haveProton || haveAntiPion || haveDeuteron))) {
916917
if (mcparticle.pdgCode() > 0) {
917918
this3BodyMCInfo.isTrueH3L = true;
918919
} else if (mcparticle.pdgCode() < 0) {
@@ -973,6 +974,7 @@ struct decay3bodyBuilder {
973974
this3BodyMCInfo.genPtProton, this3BodyMCInfo.genPtPion, this3BodyMCInfo.genPtDeuteron,
974975
this3BodyMCInfo.isTrueH3L, this3BodyMCInfo.isTrueAntiH3L,
975976
this3BodyMCInfo.isReco,
977+
mcparticle.pdgCode(),
976978
this3BodyMCInfo.daughterPrPdgCode, this3BodyMCInfo.daughterPiPdgCode, this3BodyMCInfo.daughterDePdgCode,
977979
this3BodyMCInfo.isDeuteronPrimary,
978980
this3BodyMCInfo.survivedEventSel);
@@ -1160,6 +1162,7 @@ struct decay3bodyBuilder {
11601162
this3BodyMCInfo.genPtProton, this3BodyMCInfo.genPtPion, this3BodyMCInfo.genPtDeuteron,
11611163
this3BodyMCInfo.isTrueH3L, this3BodyMCInfo.isTrueAntiH3L,
11621164
this3BodyMCInfo.isReco,
1165+
this3BodyMCInfo.motherPdgCode,
11631166
this3BodyMCInfo.daughterPrPdgCode, this3BodyMCInfo.daughterPiPdgCode, this3BodyMCInfo.daughterDePdgCode,
11641167
this3BodyMCInfo.isDeuteronPrimary,
11651168
this3BodyMCInfo.survivedEventSel);
@@ -1240,7 +1243,7 @@ struct decay3bodyBuilder {
12401243

12411244
// ______________________________________________________________
12421245
// function to reset MCInfo
1243-
void resetMCInfo(mc3Bodyinfo mcInfo)
1246+
void resetMCInfo(mc3Bodyinfo& mcInfo)
12441247
{
12451248
mcInfo.label = -1;
12461249
mcInfo.genMomentum[0] = -1., mcInfo.genMomentum[1] = -1., mcInfo.genMomentum[2] = -1.;
@@ -1251,6 +1254,7 @@ struct decay3bodyBuilder {
12511254
mcInfo.genPtProton = -1., mcInfo.genPtPion = -1., mcInfo.genPtDeuteron = -1.;
12521255
mcInfo.isTrueH3L = false, mcInfo.isTrueAntiH3L = false;
12531256
mcInfo.isReco = false;
1257+
mcInfo.motherPdgCode = -1;
12541258
mcInfo.daughterPrPdgCode = -1, mcInfo.daughterPiPdgCode = -1, mcInfo.daughterDePdgCode = -1;
12551259
mcInfo.isDeuteronPrimary = false;
12561260
mcInfo.survivedEventSel = false;

0 commit comments

Comments
 (0)