Skip to content

Commit 54a5a51

Browse files
committed
get rid of magic numbers in Ml classes enumeration
1 parent cc0075b commit 54a5a51

File tree

1 file changed

+23
-16
lines changed

1 file changed

+23
-16
lines changed

PWGHF/D2H/Tasks/taskLc.cxx

Lines changed: 23 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,13 @@ struct HfTaskLc {
6969
constexpr static float CtToProperLifetimePs = 1.f / o2::constants::physics::LightSpeedCm2PS;
7070
constexpr static float NanoToPico = 1000.f;
7171

72+
enum MlClasses : int {
73+
MlClassBackground = 0,
74+
MlClassPrompt,
75+
MlClassNonPrompt,
76+
NumberOfMlClasses
77+
};
78+
7279
HfHelper hfHelper;
7380
SliceCache cache;
7481

@@ -552,10 +559,10 @@ struct HfTaskLc {
552559
massLc = hfHelper.invMassLcToPKPi(candidate);
553560

554561
if constexpr (fillMl) {
555-
if (candidate.mlProbLcToPKPi().size() == 3) {
556-
outputBkg = candidate.mlProbLcToPKPi()[0]; /// bkg score
557-
outputPrompt = candidate.mlProbLcToPKPi()[1]; /// prompt score
558-
outputFD = candidate.mlProbLcToPKPi()[2]; /// non-prompt score
562+
if (candidate.mlProbLcToPKPi().size() == NumberOfMlClasses) {
563+
outputBkg = candidate.mlProbLcToPKPi()[MlClassBackground]; /// bkg score
564+
outputPrompt = candidate.mlProbLcToPKPi()[MlClassPrompt]; /// prompt score
565+
outputFD = candidate.mlProbLcToPKPi()[MlClassNonPrompt]; /// non-prompt score
559566
}
560567
/// Fill the ML outputScores and variables of candidate
561568
if (storeOccupancy && occEstimator != o2::hf_occupancy::OccupancyEstimator::None) {
@@ -579,10 +586,10 @@ struct HfTaskLc {
579586
massLc = hfHelper.invMassLcToPiKP(candidate);
580587

581588
if constexpr (fillMl) {
582-
if (candidate.mlProbLcToPiKP().size() == 3) {
583-
outputBkg = candidate.mlProbLcToPiKP()[0]; /// bkg score
584-
outputPrompt = candidate.mlProbLcToPiKP()[1]; /// prompt score
585-
outputFD = candidate.mlProbLcToPiKP()[2]; /// non-prompt score
589+
if (candidate.mlProbLcToPiKP().size() == NumberOfMlClasses) {
590+
outputBkg = candidate.mlProbLcToPiKP()[MlClassBackground]; /// bkg score
591+
outputPrompt = candidate.mlProbLcToPiKP()[MlClassPrompt]; /// prompt score
592+
outputFD = candidate.mlProbLcToPiKP()[MlClassNonPrompt]; /// non-prompt score
586593
}
587594
/// Fill the ML outputScores and variables of candidate (todo: add multiplicity)
588595
if (storeOccupancy && occEstimator != o2::hf_occupancy::OccupancyEstimator::None) {
@@ -764,10 +771,10 @@ struct HfTaskLc {
764771
massLc = hfHelper.invMassLcToPKPi(candidate);
765772

766773
if constexpr (fillMl) {
767-
if (candidate.mlProbLcToPKPi().size() == 3) {
768-
outputBkg = candidate.mlProbLcToPKPi()[0]; /// bkg score
769-
outputPrompt = candidate.mlProbLcToPKPi()[1]; /// prompt score
770-
outputFD = candidate.mlProbLcToPKPi()[2]; /// non-prompt score
774+
if (candidate.mlProbLcToPKPi().size() == NumberOfMlClasses) {
775+
outputBkg = candidate.mlProbLcToPKPi()[MlClassBackground]; /// bkg score
776+
outputPrompt = candidate.mlProbLcToPKPi()[MlClassPrompt]; /// prompt score
777+
outputFD = candidate.mlProbLcToPKPi()[MlClassNonPrompt]; /// non-prompt score
771778
}
772779
/// Fill the ML outputScores and variables of candidate
773780
if (storeOccupancy && occEstimator != o2::hf_occupancy::OccupancyEstimator::None) {
@@ -790,10 +797,10 @@ struct HfTaskLc {
790797
massLc = hfHelper.invMassLcToPiKP(candidate);
791798

792799
if constexpr (fillMl) {
793-
if (candidate.mlProbLcToPiKP().size() == 3) {
794-
outputBkg = candidate.mlProbLcToPiKP()[0]; /// bkg score
795-
outputPrompt = candidate.mlProbLcToPiKP()[1]; /// prompt score
796-
outputFD = candidate.mlProbLcToPiKP()[2]; /// non-prompt score
800+
if (candidate.mlProbLcToPiKP().size() == NumberOfMlClasses) {
801+
outputBkg = candidate.mlProbLcToPiKP()[MlClassBackground]; /// bkg score
802+
outputPrompt = candidate.mlProbLcToPiKP()[MlClassPrompt]; /// prompt score
803+
outputFD = candidate.mlProbLcToPiKP()[MlClassNonPrompt]; /// non-prompt score
797804
}
798805
/// Fill the ML outputScores and variables of candidate
799806
if (storeOccupancy && occEstimator != o2::hf_occupancy::OccupancyEstimator::None) {

0 commit comments

Comments
 (0)