Skip to content

Commit 489429e

Browse files
jikim1290alibuild
andauthored
[PWGCF] a new table with ML score (#9850)
Co-authored-by: ALICE Action Bot <alibuild@cern.ch>
1 parent 0cbf75c commit 489429e

File tree

2 files changed

+80
-0
lines changed

2 files changed

+80
-0
lines changed

PWGCF/DataModel/CorrelationsDerived.h

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,8 @@
1111
#ifndef PWGCF_DATAMODEL_CORRELATIONSDERIVED_H_
1212
#define PWGCF_DATAMODEL_CORRELATIONSDERIVED_H_
1313

14+
#include <vector>
15+
1416
#include "Framework/ASoA.h"
1517
#include "Framework/AnalysisDataModel.h"
1618
#include "Common/DataModel/Centrality.h"
@@ -117,6 +119,20 @@ DECLARE_SOA_TABLE(CF2ProngTracks, "AOD", "CF2PRONGTRACK", //! Reduced track tabl
117119
cf2prongtrack::CFTrackProng1Id,
118120
cf2prongtrack::Pt, cf2prongtrack::Eta, cf2prongtrack::Phi, cf2prongtrack::InvMass, cf2prongtrack::Decay);
119121
using CF2ProngTrack = CF2ProngTracks::iterator;
122+
//------
123+
124+
namespace cf2prongtrackml
125+
{
126+
DECLARE_SOA_COLUMN(MlProbD0, mlProbD0, std::vector<float>); //!
127+
DECLARE_SOA_COLUMN(MlProbD0bar, mlProbD0bar, std::vector<float>); //!
128+
} // namespace cf2prongtrackml
129+
DECLARE_SOA_TABLE(CF2ProngTrackmls, "AOD", "CF2PRONGTRACKML", //! Reduced track table
130+
o2::soa::Index<>,
131+
cftrack::CFCollisionId,
132+
cf2prongtrackml::MlProbD0, cf2prongtrackml::MlProbD0bar);
133+
using CF2ProngTrackml = CF2ProngTrackmls::iterator;
134+
//------
135+
120136
} // namespace o2::aod
121137

122138
#endif // PWGCF_DATAMODEL_CORRELATIONSDERIVED_H_

PWGCF/TableProducer/filter2Prong.cxx

Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@
88
// In applying this license CERN does not waive the privileges and immunities
99
// granted to it by virtue of its status as an Intergovernmental Organization
1010
// or submit itself to any jurisdiction.
11+
#include <vector>
12+
1113
#include "Framework/runDataProcessing.h"
1214
#include "Framework/AnalysisTask.h"
1315
#include "Framework/AnalysisDataModel.h"
@@ -35,8 +37,70 @@ struct Filter2Prong {
3537

3638
HfHelper hfHelper;
3739
Produces<aod::CF2ProngTracks> output2ProngTracks;
40+
Produces<aod::CF2ProngTrackmls> output2ProngTrackmls;
3841

3942
using HFCandidates = soa::Join<aod::HfCand2Prong, aod::HfSelD0>;
43+
using HFCandidatesML = soa::Join<aod::HfCand2Prong, aod::HfSelD0, aod::HfMlD0>;
44+
45+
void processDataML(aod::Collisions::iterator const&, aod::BCsWithTimestamps const&, aod::CFCollRefs const& cfcollisions, aod::CFTrackRefs const& cftracks, HFCandidatesML const& candidates)
46+
{
47+
if (cfcollisions.size() <= 0 || cftracks.size() <= 0)
48+
return; // rejected collision
49+
if (cfgVerbosity > 0 && candidates.size() > 0)
50+
LOGF(info, "Candidates for collision: %lu, cfcollisions: %lu, CFTracks: %lu", candidates.size(), cfcollisions.size(), cftracks.size());
51+
for (auto& c : candidates) {
52+
int prongCFId[2] = {-1, -1};
53+
for (auto& cftrack : cftracks) {
54+
if (c.prong0Id() == cftrack.trackId()) {
55+
prongCFId[0] = cftrack.globalIndex();
56+
break;
57+
}
58+
}
59+
for (auto& cftrack : cftracks) {
60+
if (c.prong1Id() == cftrack.trackId()) {
61+
prongCFId[1] = cftrack.globalIndex();
62+
break;
63+
}
64+
}
65+
// look-up the collision id
66+
if ((c.hfflag() & (1 << aod::hf_cand_2prong::DecayType::D0ToPiK)) == 0)
67+
continue;
68+
if (cfgYMax >= 0.0f && std::abs(hfHelper.yD0(c)) > cfgYMax)
69+
continue;
70+
71+
std::vector<float> mlvecd{};
72+
std::vector<float> mlvecdbar{};
73+
74+
if (c.isSelD0() > 0) {
75+
output2ProngTracks(cfcollisions.begin().globalIndex(),
76+
prongCFId[0], prongCFId[1], c.pt(), c.eta(), c.phi(), hfHelper.invMassD0ToPiK(c), aod::cf2prongtrack::D0ToPiK);
77+
for (float val : c.mlProbD0()) {
78+
mlvecd.push_back(val);
79+
}
80+
for (float val : c.mlProbD0bar()) {
81+
mlvecdbar.push_back(val);
82+
}
83+
output2ProngTrackmls(cfcollisions.begin().globalIndex(), mlvecd, mlvecdbar);
84+
}
85+
86+
mlvecd.clear();
87+
mlvecdbar.clear();
88+
89+
if (c.isSelD0bar() > 0) {
90+
output2ProngTracks(cfcollisions.begin().globalIndex(),
91+
prongCFId[0], prongCFId[1], c.pt(), c.eta(), c.phi(), hfHelper.invMassD0barToKPi(c), aod::cf2prongtrack::D0barToKPi);
92+
for (float val : c.mlProbD0()) {
93+
mlvecd.push_back(val);
94+
}
95+
for (float val : c.mlProbD0bar()) {
96+
mlvecdbar.push_back(val);
97+
}
98+
output2ProngTrackmls(cfcollisions.begin().globalIndex(), mlvecd, mlvecdbar);
99+
}
100+
}
101+
}
102+
PROCESS_SWITCH(Filter2Prong, processDataML, "Process data D0 candidates with ML", false);
103+
40104
void processData(aod::Collisions::iterator const&, aod::BCsWithTimestamps const&, aod::CFCollRefs const& cfcollisions, aod::CFTrackRefs const& cftracks, HFCandidates const& candidates)
41105
{
42106
if (cfcollisions.size() <= 0 || cftracks.size() <= 0)

0 commit comments

Comments
 (0)