Skip to content

Commit ff42433

Browse files
authored
[PWGLF] Add mother MC label to decay3bodybuilder output table (#16126)
1 parent e743331 commit ff42433

2 files changed

Lines changed: 38 additions & 48 deletions

File tree

PWGLF/DataModel/Vtx3BodyTables.h

Lines changed: 25 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -112,31 +112,30 @@ DECLARE_SOA_COLUMN(CovDeuteron, covDeuteron, float[21]); //! covariance matrix e
112112
DECLARE_SOA_COLUMN(VtxCovMat, vtxCovMat, float[21]); //! covariance matrix elements of candidate
113113

114114
// Monte Carlo info
115-
DECLARE_SOA_COLUMN(GenPx, genPx, float); // generated Px of the hypertriton in GeV/c
116-
DECLARE_SOA_COLUMN(GenPy, genPy, float); // generated Py of the hypertriton in GeV/c
117-
DECLARE_SOA_COLUMN(GenPz, genPz, float); // generated Pz of the hypertriton in GeV/c
118-
DECLARE_SOA_COLUMN(GenX, genX, float); // generated decay vtx position X of the hypertriton
119-
DECLARE_SOA_COLUMN(GenY, genY, float); // generated decay vtx position Y of the hypertriton
120-
DECLARE_SOA_COLUMN(GenZ, genZ, float); // generated decay vtx position Z of the hypertriton
121-
DECLARE_SOA_COLUMN(GenCt, genCt, float); // generated Ct of the hypertriton
122-
DECLARE_SOA_COLUMN(GenPhi, genPhi, float); // generated Phi of the hypertriton
123-
DECLARE_SOA_COLUMN(GenEta, genEta, float); // Eta of the hypertriton
124-
DECLARE_SOA_COLUMN(GenRap, genRap, float); // generated rapidity of the hypertriton
125-
DECLARE_SOA_COLUMN(GenPPr, genPPr, float); //! generated momentum proton daughter particle
126-
DECLARE_SOA_COLUMN(GenPPi, genPPi, float); //! generated momentum pion daughter particle
127-
DECLARE_SOA_COLUMN(GenPDe, genPDe, float); //! generated momentum deuteron daughter particle
128-
DECLARE_SOA_COLUMN(GenPtPr, genPtPr, float); //! generated transverse momentum proton daughter particle
129-
DECLARE_SOA_COLUMN(GenPtPi, genPtPi, float); //! generated transverse momentum pion daughter particle
130-
DECLARE_SOA_COLUMN(GenPtDe, genPtDe, float); //! generated transverse momentum deuteron daughter particle
131-
DECLARE_SOA_COLUMN(IsTrueH3L, isTrueH3l, bool); //! flag for true hypertriton candidate
132-
DECLARE_SOA_COLUMN(IsTrueAntiH3L, isTrueAntiH3l, bool); //! flag for true anti-hypertriton candidate
133-
DECLARE_SOA_COLUMN(MotherPdgCode, motherPdgCode, int); //! PDG code of the mother particle
134-
DECLARE_SOA_COLUMN(PrPdgCode, prPdgCode, int); //! MC particle proton PDG code
135-
DECLARE_SOA_COLUMN(PiPdgCode, piPdgCode, int); //! MC particle pion PDG code
136-
DECLARE_SOA_COLUMN(DePdgCode, dePdgCode, int); //! MC particle deuteron PDG code
137-
DECLARE_SOA_COLUMN(IsDePrimary, isDePrimary, bool); //! flag for deuteron daughter primary
138-
DECLARE_SOA_COLUMN(IsSurvEvSel, isSurvEvSel, int); //! flag if reco collision survived event selection
139-
DECLARE_SOA_COLUMN(IsReco, isreco, int); //! flag if candidate was reconstructed
115+
DECLARE_SOA_COLUMN(GenPx, genPx, float); // generated Px of the hypertriton in GeV/c
116+
DECLARE_SOA_COLUMN(GenPy, genPy, float); // generated Py of the hypertriton in GeV/c
117+
DECLARE_SOA_COLUMN(GenPz, genPz, float); // generated Pz of the hypertriton in GeV/c
118+
DECLARE_SOA_COLUMN(GenX, genX, float); // generated decay vtx position X of the hypertriton
119+
DECLARE_SOA_COLUMN(GenY, genY, float); // generated decay vtx position Y of the hypertriton
120+
DECLARE_SOA_COLUMN(GenZ, genZ, float); // generated decay vtx position Z of the hypertriton
121+
DECLARE_SOA_COLUMN(GenCt, genCt, float); // generated Ct of the hypertriton
122+
DECLARE_SOA_COLUMN(GenPhi, genPhi, float); // generated Phi of the hypertriton
123+
DECLARE_SOA_COLUMN(GenEta, genEta, float); // Eta of the hypertriton
124+
DECLARE_SOA_COLUMN(GenRap, genRap, float); // generated rapidity of the hypertriton
125+
DECLARE_SOA_COLUMN(GenPPr, genPPr, float); //! generated momentum proton daughter particle
126+
DECLARE_SOA_COLUMN(GenPPi, genPPi, float); //! generated momentum pion daughter particle
127+
DECLARE_SOA_COLUMN(GenPDe, genPDe, float); //! generated momentum deuteron daughter particle
128+
DECLARE_SOA_COLUMN(GenPtPr, genPtPr, float); //! generated transverse momentum proton daughter particle
129+
DECLARE_SOA_COLUMN(GenPtPi, genPtPi, float); //! generated transverse momentum pion daughter particle
130+
DECLARE_SOA_COLUMN(GenPtDe, genPtDe, float); //! generated transverse momentum deuteron daughter particle
131+
DECLARE_SOA_COLUMN(MotherPdgCode, motherPdgCode, int); //! PDG code of the mother particle
132+
DECLARE_SOA_COLUMN(PrPdgCode, prPdgCode, int); //! MC particle proton PDG code
133+
DECLARE_SOA_COLUMN(PiPdgCode, piPdgCode, int); //! MC particle pion PDG code
134+
DECLARE_SOA_COLUMN(DePdgCode, dePdgCode, int); //! MC particle deuteron PDG code
135+
DECLARE_SOA_COLUMN(IsDePrimary, isDePrimary, bool); //! flag for deuteron daughter primary
136+
DECLARE_SOA_COLUMN(IsSurvEvSel, isSurvEvSel, int); //! flag if reco collision survived event selection
137+
DECLARE_SOA_COLUMN(IsReco, isreco, int); //! flag if candidate was reconstructed
138+
DECLARE_SOA_COLUMN(MotherLabel, motherLabel, int); //! label of the mother particle (signal: MC index, bkg: negative value)
140139

141140
// Derived expressions
142141
// Momenta
@@ -287,8 +286,8 @@ DECLARE_SOA_TABLE(McVtx3BodyDatas, "AOD", "MC3BODYDATA", //!
287286
vtx3body::GenPhi, vtx3body::GenEta, vtx3body::GenRap,
288287
vtx3body::GenPPr, vtx3body::GenPPi, vtx3body::GenPDe,
289288
vtx3body::GenPtPr, vtx3body::GenPtPi, vtx3body::GenPtDe,
290-
vtx3body::IsTrueH3L, vtx3body::IsTrueAntiH3L,
291289
vtx3body::IsReco,
290+
vtx3body::MotherLabel,
292291
vtx3body::MotherPdgCode,
293292
vtx3body::PrPdgCode, vtx3body::PiPdgCode, vtx3body::DePdgCode,
294293
vtx3body::IsDePrimary,

PWGLF/TableProducer/Nuspex/decay3bodybuilder.cxx

Lines changed: 13 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -232,9 +232,8 @@ struct decay3bodyBuilder {
232232
float genPtProton;
233233
float genPtPion;
234234
float genPtDeuteron;
235-
bool isTrueH3L;
236-
bool isTrueAntiH3L;
237235
bool isReco;
236+
int motherLabel;
238237
int motherPdgCode;
239238
int daughterPrPdgCode;
240239
int daughterPiPdgCode;
@@ -807,7 +806,7 @@ struct decay3bodyBuilder {
807806
if (!doStoreMcBkg) {
808807
continue; // if not storing MC background, skip candidates where at least one daughter is not matched to MC particle
809808
} else {
810-
this3BodyMCInfo.label = -5; // at least one non-matched daughter
809+
this3BodyMCInfo.motherLabel = -5; // at least one non-matched daughter
811810
// fill analysis table (only McVtx3BodyDatas is filled here)
812811
fillAnalysisTables();
813812
}
@@ -830,34 +829,32 @@ struct decay3bodyBuilder {
830829
this3BodyMCInfo.genPtDeuteron = mcTrackDeuteron.pt();
831830

832831
// daughters are matched to MC, now we check if reco mother is true H3L/Anti-H3l and decayed via three-body decay
833-
this3BodyMCInfo.label = checkH3LTruth(mcTrackProton, mcTrackPion, mcTrackDeuteron); // returns global index of mother if true H3L/Anti-H3L mother decaying via three-body decay, otherwise negative value
832+
this3BodyMCInfo.motherLabel = checkH3LTruth(mcTrackProton, mcTrackPion, mcTrackDeuteron); // returns global index of mother if true H3L/Anti-H3L mother decaying via three-body decay, otherwise negative value for background
834833

835834
// if not storing MC background, skip candidates where mother is not true H3L/Anti-H3L decaying via three-body decay
836-
if (!doStoreMcBkg && this3BodyMCInfo.label <= 0) {
835+
if (!doStoreMcBkg && this3BodyMCInfo.motherLabel <= 0) {
837836
continue;
838837
}
839838

840839
// get generated mother MC info for matched candidates
841-
if (this3BodyMCInfo.label > -1) {
842-
auto mcTrackH3L = mcParticles.rawIteratorAt(this3BodyMCInfo.label);
840+
if (this3BodyMCInfo.motherLabel > 0) {
841+
auto mcTrackH3L = mcParticles.rawIteratorAt(this3BodyMCInfo.motherLabel);
843842
this3BodyMCInfo.motherPdgCode = mcTrackH3L.pdgCode();
844843
this3BodyMCInfo.genMomentum = {mcTrackH3L.px(), mcTrackH3L.py(), mcTrackH3L.pz()};
845844
this3BodyMCInfo.genDecVtx = {mcTrackProton.vx(), mcTrackProton.vy(), mcTrackProton.vz()};
846845
this3BodyMCInfo.genCt = RecoDecay::sqrtSumOfSquares(mcTrackProton.vx() - mcTrackH3L.vx(), mcTrackProton.vy() - mcTrackH3L.vy(), mcTrackProton.vz() - mcTrackH3L.vz()) * o2::constants::physics::MassHyperTriton / mcTrackH3L.p();
847846
this3BodyMCInfo.genPhi = mcTrackH3L.phi();
848847
this3BodyMCInfo.genEta = mcTrackH3L.eta();
849848
this3BodyMCInfo.genRapidity = mcTrackH3L.y();
850-
this3BodyMCInfo.isTrueH3L = this3BodyMCInfo.motherPdgCode > 0 ? true : false;
851-
this3BodyMCInfo.isTrueAntiH3L = this3BodyMCInfo.motherPdgCode < 0 ? true : false;
852849
}
853850

854851
// fill analysis tables (only McVtx3BodyDatas is filled here)
855852
fillAnalysisTables();
856853
} // end of check if daughters have MC particle
857854

858855
// mark mcParticle as reconstructed
859-
if (this3BodyMCInfo.label > -1) {
860-
mcParticleIsReco[this3BodyMCInfo.label] = true;
856+
if (this3BodyMCInfo.motherLabel > 0) {
857+
mcParticleIsReco[this3BodyMCInfo.motherLabel] = true;
861858
}
862859
} // constexpr requires mcParticles check
863860
} // decay3body loop
@@ -904,11 +901,6 @@ struct decay3bodyBuilder {
904901

905902
// check if hypertriton decayed via 3-body decay and is particle or anti-particle
906903
if ((haveProton && haveAntiPion && haveDeuteron && !(haveAntiProton || havePion || haveAntiDeuteron)) || (haveAntiProton && havePion && haveAntiDeuteron && !(haveProton || haveAntiPion || haveDeuteron))) {
907-
if (mcparticle.pdgCode() > 0) {
908-
this3BodyMCInfo.isTrueH3L = true;
909-
} else if (mcparticle.pdgCode() < 0) {
910-
this3BodyMCInfo.isTrueAntiH3L = true;
911-
}
912904
// get daughters
913905
for (const auto& mcparticleDaughter : mcparticle.template daughters_as<aod::McParticles>()) {
914906
if (std::abs(mcparticleDaughter.pdgCode()) == PDG_t::kProton) { // proton
@@ -964,9 +956,9 @@ struct decay3bodyBuilder {
964956
mcparticle.phi(), mcparticle.eta(), mcparticle.y(),
965957
this3BodyMCInfo.genMomProton, this3BodyMCInfo.genMomPion, this3BodyMCInfo.genMomDeuteron,
966958
this3BodyMCInfo.genPtProton, this3BodyMCInfo.genPtPion, this3BodyMCInfo.genPtDeuteron,
967-
this3BodyMCInfo.isTrueH3L, this3BodyMCInfo.isTrueAntiH3L,
968959
this3BodyMCInfo.isReco,
969-
mcparticle.pdgCode(),
960+
mcparticle.globalIndex(), // motherLabel
961+
mcparticle.pdgCode(), // motherPdgCode
970962
this3BodyMCInfo.daughterPrPdgCode, this3BodyMCInfo.daughterPiPdgCode, this3BodyMCInfo.daughterDePdgCode,
971963
this3BodyMCInfo.isDeuteronPrimary,
972964
this3BodyMCInfo.survivedEventSel);
@@ -1156,8 +1148,8 @@ struct decay3bodyBuilder {
11561148
this3BodyMCInfo.genPhi, this3BodyMCInfo.genEta, this3BodyMCInfo.genRapidity,
11571149
this3BodyMCInfo.genMomProton, this3BodyMCInfo.genMomPion, this3BodyMCInfo.genMomDeuteron,
11581150
this3BodyMCInfo.genPtProton, this3BodyMCInfo.genPtPion, this3BodyMCInfo.genPtDeuteron,
1159-
this3BodyMCInfo.isTrueH3L, this3BodyMCInfo.isTrueAntiH3L,
11601151
this3BodyMCInfo.isReco,
1152+
this3BodyMCInfo.motherLabel,
11611153
this3BodyMCInfo.motherPdgCode,
11621154
this3BodyMCInfo.daughterPrPdgCode, this3BodyMCInfo.daughterPiPdgCode, this3BodyMCInfo.daughterDePdgCode,
11631155
this3BodyMCInfo.isDeuteronPrimary,
@@ -1267,16 +1259,15 @@ struct decay3bodyBuilder {
12671259
// function to reset MCInfo
12681260
void resetMCInfo(mc3Bodyinfo& mcInfo)
12691261
{
1270-
mcInfo.label = -1;
1262+
mcInfo.motherLabel = -999;
12711263
mcInfo.genMomentum[0] = -1., mcInfo.genMomentum[1] = -1., mcInfo.genMomentum[2] = -1.;
12721264
mcInfo.genDecVtx[0] = -1., mcInfo.genDecVtx[1] = -1., mcInfo.genDecVtx[2] = -1.;
12731265
mcInfo.genCt = -1.;
12741266
mcInfo.genPhi = -1., mcInfo.genEta = -1., mcInfo.genRapidity = -1.;
12751267
mcInfo.genMomProton = -1., mcInfo.genMomPion = -1., mcInfo.genMomDeuteron = -1.;
12761268
mcInfo.genPtProton = -1., mcInfo.genPtPion = -1., mcInfo.genPtDeuteron = -1.;
1277-
mcInfo.isTrueH3L = false, mcInfo.isTrueAntiH3L = false;
12781269
mcInfo.isReco = false;
1279-
mcInfo.motherPdgCode = -1;
1270+
mcInfo.motherPdgCode = 0;
12801271
mcInfo.daughterPrPdgCode = -1, mcInfo.daughterPiPdgCode = -1, mcInfo.daughterDePdgCode = -1;
12811272
mcInfo.isDeuteronPrimary = false;
12821273
return;

0 commit comments

Comments
 (0)