Skip to content

Commit 180568f

Browse files
[PWGHF] fix linter error and only apply ml when it needed in the Lcp femto producer (#11146)
Co-authored-by: ALICE Action Bot <alibuild@cern.ch>
1 parent 7a89a1d commit 180568f

File tree

1 file changed

+32
-28
lines changed

1 file changed

+32
-28
lines changed

PWGHF/HFC/TableProducer/femtoDreamProducer.cxx

Lines changed: 32 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,9 @@
1616

1717
#include <string>
1818
#include <vector>
19+
20+
#include "TMCProcess.h"
21+
1922
#include "CCDB/BasicCCDBManager.h"
2023

2124
#include "Common/Core/trackUtilities.h"
@@ -55,19 +58,19 @@ using namespace o2::hf_centrality;
5558

5659
// event types
5760
enum Event : uint8_t {
58-
kAll = 0,
59-
kRejEveSel,
60-
kRejNoTracksAndCharm,
61-
kTrackSelected,
62-
kCharmSelected,
63-
kPairSelected
61+
All = 0,
62+
RejEveSel,
63+
RejNoTracksAndCharm,
64+
TrackSelected,
65+
CharmSelected,
66+
PairSelected
6467
};
6568

6669
// ml modes
6770
enum MlMode : uint8_t {
68-
kNoMl = 0,
69-
kFillMlFromSelector,
70-
kFillMlFromNewBDT
71+
NoMl = 0,
72+
FillMlFromSelector,
73+
FillMlFromNewBDT
7174
};
7275

7376
struct HfFemtoDreamProducer {
@@ -124,7 +127,7 @@ struct HfFemtoDreamProducer {
124127
Configurable<std::vector<float>> trkITSnclsIbMin{FemtoDreamTrackSelection::getSelectionName(femtoDreamTrackSelection::kITSnClsIbMin, "trk"), std::vector<float>{-1.f, 1.f}, FemtoDreamTrackSelection::getSelectionHelper(femtoDreamTrackSelection::kITSnClsIbMin, "Track selection: ")};
125128
Configurable<std::vector<float>> trkITSnclsMin{FemtoDreamTrackSelection::getSelectionName(femtoDreamTrackSelection::kITSnClsMin, "trk"), std::vector<float>{-1.f, 2.f, 4.f}, FemtoDreamTrackSelection::getSelectionHelper(femtoDreamTrackSelection::kITSnClsMin, "Track selection: ")};
126129
// ML inference
127-
Configurable<int> applyMlMode{"applyMlMode", 1, "Occupancy estimation (None: 0, BDT model from Lc selector: 1, New BDT model on Top of Lc selector: 2)"};
130+
Configurable<int> applyMlMode{"applyMlMode", 1, "None: 0, BDT model from Lc selector: 1, New BDT model on Top of Lc selector: 2"};
128131
Configurable<std::vector<double>> binsPtMl{"binsPtMl", std::vector<double>{hf_cuts_ml::vecBinsPt}, "pT bin limits for ML application"};
129132
Configurable<std::vector<int>> cutDirMl{"cutDirMl", std::vector<int>{hf_cuts_ml::vecCutDir}, "Whether to reject score values greater or smaller than the threshold"};
130133
Configurable<LabeledArray<double>> cutsMl{"cutsMl", {hf_cuts_ml::Cuts[0], hf_cuts_ml::NBinsPt, hf_cuts_ml::NCutScores, hf_cuts_ml::labelsPt, hf_cuts_ml::labelsCutScore}, "ML selections per pT bin"};
@@ -175,14 +178,14 @@ struct HfFemtoDreamProducer {
175178
trackRegistry.add("AnalysisQA/CutCounter", "; Bit; Counter", kTH1F, {{cutBits + 1, -0.5, cutBits + 0.5}});
176179

177180
// event QA histograms
178-
constexpr int kEventTypes = kPairSelected + 1;
181+
constexpr int kEventTypes = PairSelected + 1;
179182
std::string labels[kEventTypes];
180-
labels[Event::kAll] = "All events";
181-
labels[Event::kRejEveSel] = "rejected by event selection";
182-
labels[Event::kRejNoTracksAndCharm] = "rejected by no tracks and charm";
183-
labels[Event::kTrackSelected] = "with tracks ";
184-
labels[Event::kCharmSelected] = "with charm hadrons ";
185-
labels[Event::kPairSelected] = "with pairs";
183+
labels[Event::All] = "All events";
184+
labels[Event::RejEveSel] = "rejected by event selection";
185+
labels[Event::RejNoTracksAndCharm] = "rejected by no tracks and charm";
186+
labels[Event::TrackSelected] = "with tracks ";
187+
labels[Event::CharmSelected] = "with charm hadrons ";
188+
labels[Event::PairSelected] = "with pairs";
186189

187190
static const AxisSpec axisEvents = {kEventTypes, 0.5, kEventTypes + 0.5, ""};
188191
qaRegistry.add("hEventQA", "Events;;entries", HistType::kTH1F, {axisEvents});
@@ -219,7 +222,7 @@ struct HfFemtoDreamProducer {
219222
int64_t now = std::chrono::duration_cast<std::chrono::milliseconds>(std::chrono::system_clock::now().time_since_epoch()).count();
220223
ccdb->setCreatedNotAfter(now);
221224

222-
if (applyMlMode) {
225+
if (applyMlMode == FillMlFromNewBDT) {
223226
hfMlResponse.configure(binsPtMl, cutsMl, cutDirMl, nClassesMl);
224227
if (loadModelsFromCCDB) {
225228
ccdbApi.init(ccdbUrl);
@@ -281,6 +284,7 @@ struct HfFemtoDreamProducer {
281284
auto pdgCode = particleMc.pdgCode();
282285
int particleOrigin = 99;
283286
int pdgCodeMother = -1;
287+
constexpr int GenFromTransport = -1; // -1 if a particle produced during transport
284288
// get list of mothers, but it could be empty (for example in case of injected light nuclei)
285289
auto motherparticlesMc = particleMc.template mothers_as<aod::McParticles>();
286290
// check pdg code
@@ -297,15 +301,15 @@ struct HfFemtoDreamProducer {
297301
// particle is from a decay -> getProcess() == 4
298302
// particle is generated during transport -> getGenStatusCode() == -1
299303
// list of mothers is not empty
300-
} else if (particleMc.getProcess() == 4 && particleMc.getGenStatusCode() == -1 && !motherparticlesMc.empty()) {
304+
} else if (particleMc.getProcess() == TMCProcess::kPDecay && particleMc.getGenStatusCode() == GenFromTransport && !motherparticlesMc.empty()) {
301305
// get direct mother
302306
auto motherparticleMc = motherparticlesMc.front();
303307
pdgCodeMother = motherparticleMc.pdgCode();
304308
particleOrigin = checkDaughterType(fdparttype, motherparticleMc.pdgCode());
305309
// check if particle is material
306310
// particle is from inelastic hadronic interaction -> getProcess() == 23
307311
// particle is generated during transport -> getGenStatusCode() == -1
308-
} else if (particleMc.getProcess() == 23 && particleMc.getGenStatusCode() == -1) {
312+
} else if (particleMc.getProcess() == TMCProcess::kPHInhelastic && particleMc.getGenStatusCode() == GenFromTransport) {
309313
particleOrigin = aod::femtodreamMCparticle::ParticleOriginMCTruth::kMaterial;
310314
// cross check to see if we missed a case
311315
} else {
@@ -408,18 +412,18 @@ struct HfFemtoDreamProducer {
408412

409413
const auto rejectionMask = hfEvSel.getHfCollisionRejectionMask<true, CentralityEstimator::None, aod::BCsWithTimestamps>(col, mult, ccdb, qaRegistry);
410414

411-
qaRegistry.fill(HIST("hEventQA"), 1 + Event::kAll);
415+
qaRegistry.fill(HIST("hEventQA"), 1 + Event::All);
412416

413417
/// monitor the satisfied event selections
414418
hfEvSel.fillHistograms(col, rejectionMask, mult);
415419
if (rejectionMask != 0) {
416420
/// at least one event selection not satisfied --> reject the candidate
417-
qaRegistry.fill(HIST("hEventQA"), 1 + Event::kRejEveSel);
421+
qaRegistry.fill(HIST("hEventQA"), 1 + Event::RejEveSel);
418422
return;
419423
}
420424

421425
if (isNoSelectedTracks(col, tracks, trackCuts) && sizeCand <= 0) {
422-
qaRegistry.fill(HIST("hEventQA"), 1 + Event::kRejNoTracksAndCharm);
426+
qaRegistry.fill(HIST("hEventQA"), 1 + Event::RejNoTracksAndCharm);
423427
return;
424428
}
425429

@@ -443,7 +447,7 @@ struct HfFemtoDreamProducer {
443447
if constexpr (useCharmMl) {
444448
/// fill with ML information
445449
/// BDT index 0: bkg score; BDT index 1: prompt score; BDT index 2: non-prompt score
446-
if (applyMlMode == kFillMlFromSelector) {
450+
if (applyMlMode == FillMlFromSelector) {
447451
if (candidate.mlProbLcToPKPi().size() > 0) {
448452
outputMlPKPi.at(0) = candidate.mlProbLcToPKPi()[0]; /// bkg score
449453
outputMlPKPi.at(1) = candidate.mlProbLcToPKPi()[1]; /// prompt score
@@ -454,7 +458,7 @@ struct HfFemtoDreamProducer {
454458
outputMlPiKP.at(1) = candidate.mlProbLcToPiKP()[1]; /// prompt score
455459
outputMlPiKP.at(2) = candidate.mlProbLcToPiKP()[2]; /// non-prompt score
456460
}
457-
} else if (applyMlMode == kFillMlFromNewBDT) {
461+
} else if (applyMlMode == FillMlFromNewBDT) {
458462
isSelectedMlLcToPKPi = false;
459463
isSelectedMlLcToPiKP = false;
460464
if (candidate.mlProbLcToPKPi().size() > 0) {
@@ -516,17 +520,17 @@ struct HfFemtoDreamProducer {
516520
aod::femtodreamcollision::BitMaskType bitTrack = 0;
517521
if (isTrackFilled) {
518522
bitTrack |= 1 << 0;
519-
qaRegistry.fill(HIST("hEventQA"), 1 + Event::kTrackSelected);
523+
qaRegistry.fill(HIST("hEventQA"), 1 + Event::TrackSelected);
520524
}
521525

522526
aod::femtodreamcollision::BitMaskType bitCand = 0;
523527
if (sizeCand > 0) {
524528
bitCand |= 1 << 0;
525-
qaRegistry.fill(HIST("hEventQA"), 1 + Event::kCharmSelected);
529+
qaRegistry.fill(HIST("hEventQA"), 1 + Event::CharmSelected);
526530
}
527531

528532
if (isTrackFilled && (sizeCand > 0))
529-
qaRegistry.fill(HIST("hEventQA"), 1 + Event::kPairSelected);
533+
qaRegistry.fill(HIST("hEventQA"), 1 + Event::PairSelected);
530534

531535
rowMasks(static_cast<aod::femtodreamcollision::BitMaskType>(bitTrack),
532536
static_cast<aod::femtodreamcollision::BitMaskType>(bitCand),

0 commit comments

Comments
 (0)