Skip to content

Commit 84cd58a

Browse files
FDUEnrichalibuildzhangbiao-phy
authored
[PWGHF] Add ml features and create a small table for local analysis. (#11202)
Co-authored-by: ALICE Action Bot <alibuild@cern.ch> Co-authored-by: BiaoZhang (张彪) <52267892+zhangbiao-phy@users.noreply.github.com>
1 parent ea67991 commit 84cd58a

File tree

4 files changed

+96
-23
lines changed

4 files changed

+96
-23
lines changed

PWGHF/Core/HfMlResponseOmegacToOmegaPi.h

Lines changed: 41 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -64,13 +64,24 @@ enum class InputFeaturesOmegacToOmegaPi : uint8_t {
6464

6565
cosPaOmegacToPv = 0,
6666
kfDcaXYPiFromOmegac,
67-
cosThetaStarPiFromOmegac,
6867
chi2TopoPiFromOmegacToPv,
6968
dcaCharmBaryonDau,
7069
invMassCascade,
7170
massCascChi2OverNdf,
72-
cosPaCascToPv,
7371
kfDcaXYCascToPv,
72+
cosPaCascToPv,
73+
cosThetaStarPiFromOmegac,
74+
chi2NdfTopoOmegacToPv,
75+
ldlCasc,
76+
dcaCascDau,
77+
cosPaCascToOmegac,
78+
decayLenXYCasc,
79+
ldlOmegac,
80+
chi2NdfTopoCascToOmegac,
81+
chi2NdfTopoCascToPv,
82+
chi2GeoOmegac,
83+
chi2GeoCasc,
84+
7485
nSigmaTPCPiFromV0,
7586
nSigmaTPCPiFromOmegac,
7687
nSigmaTPCKaFromCasc
@@ -99,16 +110,26 @@ class HfMlResponseOmegacToOmegaPi : public HfMlResponse<TypeOutputScore>
99110

100111
for (const auto& idx : MlResponse<TypeOutputScore>::mCachedIndices) {
101112
switch (idx) {
102-
113+
CHECK_AND_FILL_VEC_OMEGAC0_FULL(candidate, cosPaOmegacToPv, cosPACharmBaryon);
103114
CHECK_AND_FILL_VEC_OMEGAC0(kfDcaXYPiFromOmegac);
104-
CHECK_AND_FILL_VEC_OMEGAC0(cosThetaStarPiFromOmegac);
105115
CHECK_AND_FILL_VEC_OMEGAC0(chi2TopoPiFromOmegacToPv);
106116
CHECK_AND_FILL_VEC_OMEGAC0(dcaCharmBaryonDau);
107117
CHECK_AND_FILL_VEC_OMEGAC0(invMassCascade);
108118
CHECK_AND_FILL_VEC_OMEGAC0(massCascChi2OverNdf);
109119
CHECK_AND_FILL_VEC_OMEGAC0(kfDcaXYCascToPv);
110-
CHECK_AND_FILL_VEC_OMEGAC0_FULL(candidate, cosPaOmegacToPv, cosPACharmBaryon);
111120
CHECK_AND_FILL_VEC_OMEGAC0_FULL(candidate, cosPaCascToPv, cosPACasc);
121+
CHECK_AND_FILL_VEC_OMEGAC0(cosThetaStarPiFromOmegac);
122+
CHECK_AND_FILL_VEC_OMEGAC0_FULL(candidate, chi2NdfTopoOmegacToPv, chi2TopoOmegacToPv);
123+
CHECK_AND_FILL_VEC_OMEGAC0_FULL(candidate, ldlCasc, cascldl);
124+
CHECK_AND_FILL_VEC_OMEGAC0(dcaCascDau);
125+
CHECK_AND_FILL_VEC_OMEGAC0(cosPaCascToOmegac);
126+
CHECK_AND_FILL_VEC_OMEGAC0(decayLenXYCasc);
127+
CHECK_AND_FILL_VEC_OMEGAC0_FULL(candidate, ldlOmegac, omegacldl);
128+
CHECK_AND_FILL_VEC_OMEGAC0_FULL(candidate, chi2NdfTopoCascToOmegac, chi2TopoCascToOmegac);
129+
CHECK_AND_FILL_VEC_OMEGAC0_FULL(candidate, chi2NdfTopoCascToPv, chi2TopoCascToPv);
130+
CHECK_AND_FILL_VEC_OMEGAC0(chi2GeoOmegac);
131+
CHECK_AND_FILL_VEC_OMEGAC0(chi2GeoCasc);
132+
112133
// TPC PID variables
113134
CHECK_AND_FILL_VEC_OMEGAC0_FULL(lamProngPi, nSigmaTPCPiFromV0, tpcNSigmaPi);
114135
CHECK_AND_FILL_VEC_OMEGAC0_FULL(cascProng, nSigmaTPCKaFromCasc, tpcNSigmaKa);
@@ -125,16 +146,26 @@ class HfMlResponseOmegacToOmegaPi : public HfMlResponse<TypeOutputScore>
125146
{
126147
MlResponse<TypeOutputScore>::mAvailableInputFeatures = {
127148

128-
FILL_MAP_OMEGAC0(invMassCascade),
129149
FILL_MAP_OMEGAC0(cosPaOmegacToPv),
130-
FILL_MAP_OMEGAC0(dcaCharmBaryonDau),
131150
FILL_MAP_OMEGAC0(kfDcaXYPiFromOmegac),
132-
FILL_MAP_OMEGAC0(cosThetaStarPiFromOmegac),
133151
FILL_MAP_OMEGAC0(chi2TopoPiFromOmegacToPv),
152+
FILL_MAP_OMEGAC0(dcaCharmBaryonDau),
153+
FILL_MAP_OMEGAC0(invMassCascade),
134154
FILL_MAP_OMEGAC0(massCascChi2OverNdf),
135-
FILL_MAP_OMEGAC0(cosPaCascToPv),
136155
FILL_MAP_OMEGAC0(kfDcaXYCascToPv),
137-
// TPC PID variables
156+
FILL_MAP_OMEGAC0(cosPaCascToPv),
157+
FILL_MAP_OMEGAC0(cosThetaStarPiFromOmegac),
158+
FILL_MAP_OMEGAC0(chi2NdfTopoOmegacToPv),
159+
FILL_MAP_OMEGAC0(ldlCasc),
160+
FILL_MAP_OMEGAC0(dcaCascDau),
161+
FILL_MAP_OMEGAC0(cosPaCascToOmegac),
162+
FILL_MAP_OMEGAC0(decayLenXYCasc),
163+
FILL_MAP_OMEGAC0(ldlOmegac),
164+
FILL_MAP_OMEGAC0(chi2NdfTopoCascToOmegac),
165+
FILL_MAP_OMEGAC0(chi2NdfTopoCascToPv),
166+
FILL_MAP_OMEGAC0(chi2GeoOmegac),
167+
FILL_MAP_OMEGAC0(chi2GeoCasc),
168+
138169
FILL_MAP_OMEGAC0(nSigmaTPCPiFromV0),
139170
FILL_MAP_OMEGAC0(nSigmaTPCKaFromCasc),
140171
FILL_MAP_OMEGAC0(nSigmaTPCPiFromOmegac),

PWGHF/DataModel/CandidateSelectionTables.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -393,13 +393,13 @@ DECLARE_SOA_COLUMN(PidTpcInfoStored, pidTpcInfoStored, int);
393393
DECLARE_SOA_COLUMN(PidTofInfoStored, pidTofInfoStored, int);
394394
// Machine learning column for omegac0 to omega pi
395395
DECLARE_SOA_COLUMN(MlProbOmegac, mlProbOmegac, std::vector<float>);
396-
DECLARE_SOA_COLUMN(MlProbOmegacBar, mlProbOmegacBar, std::vector<float>);
396+
DECLARE_SOA_COLUMN(MlValueOmegac, mlValueOmegac, float);
397397
} // namespace hf_sel_toomegapi
398398

399399
DECLARE_SOA_TABLE(HfSelToOmegaPi, "AOD", "HFSELTOOMEPI",
400400
hf_sel_toomegapi::StatusPidLambda, hf_sel_toomegapi::StatusPidCascade, hf_sel_toomegapi::StatusPidCharmBaryon,
401401
hf_sel_toomegapi::StatusInvMassLambda, hf_sel_toomegapi::StatusInvMassCascade, hf_sel_toomegapi::StatusInvMassCharmBaryon,
402-
hf_sel_toomegapi::ResultSelections, hf_sel_toomegapi::PidTpcInfoStored, hf_sel_toomegapi::PidTofInfoStored,
402+
hf_sel_toomegapi::ResultSelections, hf_sel_toomegapi::PidTpcInfoStored, hf_sel_toomegapi::PidTofInfoStored, hf_sel_toomegapi::MlValueOmegac,
403403
hf_sel_toomegapi::TpcNSigmaPiFromCharmBaryon, hf_sel_toomegapi::TpcNSigmaKaFromCasc, hf_sel_toomegapi::TpcNSigmaPiFromLambda, hf_sel_toomegapi::TpcNSigmaPrFromLambda,
404404
hf_sel_toomegapi::TofNSigmaPiFromCharmBaryon, hf_sel_toomegapi::TofNSigmaKaFromCasc, hf_sel_toomegapi::TofNSigmaPiFromLambda, hf_sel_toomegapi::TofNSigmaPrFromLambda);
405405

PWGHF/TableProducer/candidateSelectorOmegac0ToOmegaPi.cxx

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -354,7 +354,7 @@ struct HfCandidateSelectorToOmegaPi {
354354
// pt-dependent selection
355355
if (!selectionTopol(candidate)) {
356356
resultSelections = false;
357-
hfSelToOmegaPi(statusPidLambda, statusPidCascade, statusPidCharmBaryon, statusInvMassLambda, statusInvMassCascade, statusInvMassCharmBaryon, resultSelections, infoTpcStored, infoTofStored,
357+
hfSelToOmegaPi(statusPidLambda, statusPidCascade, statusPidCharmBaryon, statusInvMassLambda, statusInvMassCascade, statusInvMassCharmBaryon, resultSelections, infoTpcStored, infoTofStored, outputMlOmegac[0],
358358
trackPiFromCharm.tpcNSigmaPi(), trackKaFromCasc.tpcNSigmaKa(), trackPiFromLam.tpcNSigmaPi(), trackPrFromLam.tpcNSigmaPr(),
359359
trackPiFromCharm.tofNSigmaPi(), trackKaFromCasc.tofNSigmaKa(), trackPiFromLam.tofNSigmaPi(), trackPrFromLam.tofNSigmaPr());
360360
if constexpr (ConstructMethod == hf_cand_casc_lf::ConstructMethod::KfParticle) {
@@ -746,12 +746,14 @@ struct HfCandidateSelectorToOmegaPi {
746746
isSelectedMlOmegac = hfMlResponse.isSelectedMl(inputFeaturesOmegaC, ptCand, outputMlOmegac);
747747
if (isSelectedMlOmegac) {
748748
registry.fill(HIST("hBDTScoreTest1"), outputMlOmegac[0]);
749+
} else {
750+
resultSelections = false;
749751
}
750752
hfMlSelToOmegaPi(outputMlOmegac);
751753
}
752754
}
753755

754-
hfSelToOmegaPi(statusPidLambda, statusPidCascade, statusPidCharmBaryon, statusInvMassLambda, statusInvMassCascade, statusInvMassCharmBaryon, resultSelections, infoTpcStored, infoTofStored,
756+
hfSelToOmegaPi(statusPidLambda, statusPidCascade, statusPidCharmBaryon, statusInvMassLambda, statusInvMassCascade, statusInvMassCharmBaryon, resultSelections, infoTpcStored, infoTofStored, outputMlOmegac[0],
755757
trackPiFromCharm.tpcNSigmaPi(), trackKaFromCasc.tpcNSigmaKa(), trackPiFromLam.tpcNSigmaPi(), trackPrFromLam.tpcNSigmaPr(),
756758
trackPiFromCharm.tofNSigmaPi(), trackKaFromCasc.tofNSigmaKa(), trackPiFromLam.tofNSigmaPi(), trackPrFromLam.tofNSigmaPr());
757759

PWGHF/TableProducer/treeCreatorOmegac0ToOmegaPi.cxx

Lines changed: 49 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
/// \author Federica Zanone <federica.zanone@cern.ch>, Heidelberg University
1717
/// \author Yunfan Liu <yunfan.liu@cern.ch>, China University of Geosciences
1818
/// \author Fabio Catalano <fabio.catalano@cern.ch>, University of Houston
19+
/// \author Ruiqi Yin <ruiqi.yin@cern.ch>, Fudan University
1920

2021
#include "Framework/AnalysisTask.h"
2122
#include "Framework/runDataProcessing.h"
@@ -151,6 +152,7 @@ DECLARE_SOA_COLUMN(OmegacChi2OverNdf, omegacChi2OverNdf, float);
151152
DECLARE_SOA_COLUMN(MassV0Chi2OverNdf, massV0Chi2OverNdf, float);
152153
DECLARE_SOA_COLUMN(MassCascChi2OverNdf, massCascChi2OverNdf, float);
153154
DECLARE_SOA_COLUMN(CascRejectInvmass, cascRejectInvmass, float);
155+
DECLARE_SOA_COLUMN(OutputMlOmegac, outputMlOmegac, float);
154156
} // namespace full
155157

156158
DECLARE_SOA_TABLE(HfToOmegaPiEvs, "AOD", "HFTOOMEPIEV",
@@ -198,7 +200,7 @@ DECLARE_SOA_TABLE(HfKfOmegacFulls, "AOD", "HFKFOMEGACFULL",
198200
full::V0Ndf, full::CascNdf, full::OmegacNdf,
199201
full::MassV0Ndf, full::MassCascNdf,
200202
full::V0Chi2OverNdf, full::CascChi2OverNdf, full::OmegacChi2OverNdf,
201-
full::MassV0Chi2OverNdf, full::MassCascChi2OverNdf, full::CascRejectInvmass,
203+
full::MassV0Chi2OverNdf, full::MassCascChi2OverNdf, full::CascRejectInvmass, full::OutputMlOmegac,
202204
full::FlagMcMatchRec, full::OriginRec, full::CollisionMatched, hf_track_index::HFflag);
203205

204206
DECLARE_SOA_TABLE(HfKfOmegacLites, "AOD", "HFKFOMEGACLITE",
@@ -214,14 +216,18 @@ DECLARE_SOA_TABLE(HfKfOmegacLites, "AOD", "HFKFOMEGACLITE",
214216
full::V0Chi2OverNdf, full::CascChi2OverNdf, full::OmegacChi2OverNdf,
215217
full::CascRejectInvmass,
216218
full::FlagMcMatchRec, full::OriginRec, full::CollisionMatched, hf_track_index::HFflag);
219+
220+
DECLARE_SOA_TABLE(HfKfOmegacMl, "AOD", "HFKFOMEGACML",
221+
full::InvMassCharmBaryon, full::KfptOmegac, full::KfptPiFromOmegac, full::OutputMlOmegac, full::FlagMcMatchRec, full::OriginRec, full::CollisionMatched, hf_track_index::HFflag);
217222
} // namespace o2::aod
218223

219224
/// Writes the full information in an output TTree
220-
struct HfTreeCreatorOmegacToOmegaPi { // FIXME: Rename to HfTreeCreatorOmegac0ToOmegaPi
225+
struct HfTreeCreatorOmegac0ToOmegaPi {
221226

222227
Produces<o2::aod::HfOmegac0ToOmegaPiLites> rowCandidateLite;
223228
Produces<o2::aod::HfKfOmegacFulls> rowKfCandidateFull;
224229
Produces<o2::aod::HfKfOmegacLites> rowKfCandidateLite;
230+
Produces<o2::aod::HfKfOmegacMl> rowKfCandidateMl;
225231
Produces<o2::aod::HfToOmegaPiEvs> rowEv;
226232

227233
Configurable<float> zPvCut{"zPvCut", 10., "Cut on absolute value of primary vertex z coordinate"};
@@ -381,6 +387,7 @@ struct HfTreeCreatorOmegacToOmegaPi { // FIXME: Rename to HfTreeCreatorOmegac0To
381387
candidate.massV0Chi2OverNdf(),
382388
candidate.massCascChi2OverNdf(),
383389
candidate.cascRejectInvmass(),
390+
candidate.mlValueOmegac(),
384391
flagMc,
385392
originMc,
386393
collisionMatched,
@@ -431,6 +438,23 @@ struct HfTreeCreatorOmegacToOmegaPi { // FIXME: Rename to HfTreeCreatorOmegac0To
431438
}
432439
} // fillKfCandidateLite end
433440

441+
template <typename T>
442+
void fillKfCandidateMl(const T& candidate, int8_t flagMc, int8_t originMc, bool collisionMatched)
443+
{
444+
if (candidate.resultSelections() && candidate.statusPidCharmBaryon() && candidate.statusInvMassLambda() && candidate.statusInvMassCascade() && candidate.statusInvMassCharmBaryon()) {
445+
446+
rowKfCandidateMl(
447+
candidate.invMassCharmBaryon(),
448+
candidate.kfptOmegac(),
449+
candidate.kfptPiFromOmegac(),
450+
candidate.mlValueOmegac(),
451+
flagMc,
452+
originMc,
453+
collisionMatched,
454+
candidate.hfflag());
455+
}
456+
} // fillCandidateMl end
457+
434458
void processDataLite(Colls const& collisions, Tracks const&,
435459
soa::Filtered<soa::Join<aod::HfCandToOmegaPi, aod::HfSelToOmegaPi>> const& candidates)
436460
{
@@ -446,7 +470,7 @@ struct HfTreeCreatorOmegacToOmegaPi { // FIXME: Rename to HfTreeCreatorOmegac0To
446470
fillCandidateLite(candidate, -7, RecoDecay::OriginType::None, false);
447471
}
448472
}
449-
PROCESS_SWITCH(HfTreeCreatorOmegacToOmegaPi, processDataLite, "Process data", true);
473+
PROCESS_SWITCH(HfTreeCreatorOmegac0ToOmegaPi, processDataLite, "Process data", false);
450474

451475
void processKfDataFull(Colls const& collisions, Tracks const&, CandKfSel const& candidates)
452476
{
@@ -462,7 +486,7 @@ struct HfTreeCreatorOmegacToOmegaPi { // FIXME: Rename to HfTreeCreatorOmegac0To
462486
fillKfCandidate(candidate, -7, RecoDecay::OriginType::None, false);
463487
}
464488
}
465-
PROCESS_SWITCH(HfTreeCreatorOmegacToOmegaPi, processKfDataFull, "Process KF data", false);
489+
PROCESS_SWITCH(HfTreeCreatorOmegac0ToOmegaPi, processKfDataFull, "Process KF data", false);
466490

467491
void processKfDataLite(Colls const& collisions, Tracks const&, CandKfSel const& candidates)
468492
{
@@ -478,7 +502,23 @@ struct HfTreeCreatorOmegacToOmegaPi { // FIXME: Rename to HfTreeCreatorOmegac0To
478502
fillKfCandidateLite(candidate, -7, RecoDecay::OriginType::None, false);
479503
}
480504
}
481-
PROCESS_SWITCH(HfTreeCreatorOmegacToOmegaPi, processKfDataLite, "Process KF data Lite", false);
505+
PROCESS_SWITCH(HfTreeCreatorOmegac0ToOmegaPi, processKfDataLite, "Process KF data Lite", false);
506+
507+
void processKfCandidateMl(Colls const& collisions, Tracks const&, CandKfSel const& candidates)
508+
{
509+
// Filling event properties
510+
rowEv.reserve(collisions.size());
511+
for (const auto& collision : collisions) {
512+
fillEvent(collision, zPvCut);
513+
}
514+
515+
// Filling candidate properties
516+
rowKfCandidateFull.reserve(candidates.size());
517+
for (const auto& candidate : candidates) {
518+
fillKfCandidateMl(candidate, -7, RecoDecay::OriginType::None, false);
519+
}
520+
}
521+
PROCESS_SWITCH(HfTreeCreatorOmegac0ToOmegaPi, processKfCandidateMl, "Process KF data ML", true);
482522

483523
void processMcLite(Colls const& collisions, Tracks const&,
484524
soa::Filtered<soa::Join<aod::HfCandToOmegaPi, aod::HfSelToOmegaPi, aod::HfToOmegaPiMCRec>> const& candidates)
@@ -495,7 +535,7 @@ struct HfTreeCreatorOmegacToOmegaPi { // FIXME: Rename to HfTreeCreatorOmegac0To
495535
fillCandidateLite(candidate, candidate.flagMcMatchRec(), candidate.originRec(), candidate.collisionMatched());
496536
}
497537
}
498-
PROCESS_SWITCH(HfTreeCreatorOmegacToOmegaPi, processMcLite, "Process MC", false);
538+
PROCESS_SWITCH(HfTreeCreatorOmegac0ToOmegaPi, processMcLite, "Process MC", false);
499539

500540
void processKFMcFull(Colls const& collisions, Tracks const&, CascKfMcSel const& candidates)
501541
{
@@ -517,7 +557,7 @@ struct HfTreeCreatorOmegacToOmegaPi { // FIXME: Rename to HfTreeCreatorOmegac0To
517557
}
518558
}
519559
}
520-
PROCESS_SWITCH(HfTreeCreatorOmegacToOmegaPi, processKFMcFull, "Process KF MC", false);
560+
PROCESS_SWITCH(HfTreeCreatorOmegac0ToOmegaPi, processKFMcFull, "Process KF MC", false);
521561

522562
void processKFMcLite(Colls const& collisions, Tracks const&, CascKfMcSel const& candidates)
523563
{
@@ -539,12 +579,12 @@ struct HfTreeCreatorOmegacToOmegaPi { // FIXME: Rename to HfTreeCreatorOmegac0To
539579
}
540580
}
541581
}
542-
PROCESS_SWITCH(HfTreeCreatorOmegacToOmegaPi, processKFMcLite, "Process KF MC Lite", false);
582+
PROCESS_SWITCH(HfTreeCreatorOmegac0ToOmegaPi, processKFMcLite, "Process KF MC Lite", false);
543583

544584
}; // end of struct
545585

546586
WorkflowSpec defineDataProcessing(ConfigContext const& cfgc)
547587
{
548588
return WorkflowSpec{
549-
adaptAnalysisTask<HfTreeCreatorOmegacToOmegaPi>(cfgc)};
589+
adaptAnalysisTask<HfTreeCreatorOmegac0ToOmegaPi>(cfgc)};
550590
}

0 commit comments

Comments
 (0)