Skip to content

Commit 26fcae3

Browse files
authored
[PWGJE] Adding enum class to remove magic numbers (#17383)
1 parent 796304b commit 26fcae3

1 file changed

Lines changed: 24 additions & 19 deletions

File tree

PWGJE/Tasks/jetCorrelationD0.cxx

Lines changed: 24 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
/// \brief Task for analysing D0 triggered jet events.
1414
/// \author Matthew Ockleton matthew.ockleton@cern.ch, University of Liverpool
1515

16+
#include "PWGHF/Core/DecayChannels.h"
1617
#include "PWGJE/Core/JetDerivedDataUtilities.h"
1718
#include "PWGJE/Core/JetHFUtilities.h"
1819
#include "PWGJE/DataModel/Jet.h"
@@ -37,13 +38,13 @@
3738
#include <cstdint>
3839
#include <cstdlib>
3940
#include <string>
40-
#include <type_traits>
4141
#include <vector>
4242

4343
using namespace o2;
4444
using namespace o2::framework;
4545
using namespace o2::framework::expressions;
4646

47+
namespace hf2Prong = o2::hf_decay::hf_cand_2prong;
4748
namespace o2::aod
4849
{
4950

@@ -290,6 +291,15 @@ struct JetCorrelationD0 {
290291
registry.add("hPhiResolution", "#phi resolution;#p_{T,part};Resolution", {HistType::kTH2F, {{400, 0, 400}, {1000, -7.0, 7.0}}});
291292
registry.add("hEtaResolution", "#eta resolution;#p_{T,part};Resolution", {HistType::kTH2F, {{400, 0, 400}, {1000, -1.0, 1.0}}});
292293
}
294+
enum D0McCategory : int {
295+
Undefined = -1, // no truth match / unclassified
296+
Signal = 0, // correctly identified D0(bar), π+ K−
297+
Reflection = 1, // true D0(bar) reconstructed with swapped mass hypothesis
298+
CorrBkgPiKPi0 = 2, // correlated background: π+ K− π0
299+
CorrBkgPiPi = 3, // correlated background: π+ π−
300+
CorrBkgPiPiPi0 = 4, // correlated background: π+ π− π0
301+
CorrBkgKK = 5 // correlated background: K+ K−
302+
};
293303
void processData(soa::Filtered<aod::JetCollisions>::iterator const& collision,
294304
aod::CandidatesD0Data const& d0Candidates,
295305
soa::Join<aod::ChargedJets, aod::ChargedJetConstituents> const& jets)
@@ -354,12 +364,7 @@ struct JetCorrelationD0 {
354364

355365
int matchedFrom = 0;
356366
int selectedAs = 0;
357-
int category = -1; // -1 undefined, 0 signal, 1 reflection, 2-5 correlated backgrounds
358-
constexpr int kD0ToKPi = 1;
359-
constexpr int kD0ToKPiPi = 2;
360-
constexpr int kD0ToPiPi = 3;
361-
constexpr int kD0ToPiPiPi = 4;
362-
constexpr int kD0ToKK = 5;
367+
int category = D0McCategory::Undefined;
363368

364369
if (d0DecayChannel > 0) { // matched to a D0 on truth level (any channel)
365370
matchedFrom = 1;
@@ -371,18 +376,18 @@ struct JetCorrelationD0 {
371376
} else if ((d0Candidate.candidateSelFlag() & BIT(1)) != 0) { // CandidateSelFlag == BIT(1) -> selected as D0bar
372377
selectedAs = -1;
373378
}
374-
if ((std::abs(d0DecayChannel) == kD0ToKPi) && (matchedFrom != 0) && (selectedAs == matchedFrom)) {
375-
category = 0; // signal -> D0 or D0bar, π+ K−
376-
} else if ((d0DecayChannel == kD0ToKPi) && (selectedAs == -1 * matchedFrom)) {
377-
category = 1; // reflection
378-
} else if (d0DecayChannel == kD0ToKPiPi) {
379-
category = 2; // corr bkg: π+ K− π0
380-
} else if (d0DecayChannel == kD0ToPiPi) {
381-
category = 3; // corr bkg: π+ π−
382-
} else if (d0DecayChannel == kD0ToPiPiPi) {
383-
category = 4; // corr bkg: π+ π− π0
384-
} else if (d0DecayChannel == kD0ToKK) {
385-
category = 5; // corr bkg: K+ K−
379+
if ((std::abs(d0DecayChannel) == hf2Prong::DecayChannelMain::D0ToPiK) && (matchedFrom != 0) && (selectedAs == matchedFrom)) {
380+
category = D0McCategory::Signal; // D0 or D0bar, π+ K−
381+
} else if ((d0DecayChannel == hf2Prong::DecayChannelMain::D0ToPiK) && (selectedAs == -1 * matchedFrom)) {
382+
category = D0McCategory::Reflection;
383+
} else if (d0DecayChannel == hf2Prong::DecayChannelMain::D0ToPiKPi0) {
384+
category = D0McCategory::CorrBkgPiKPi0;
385+
} else if (d0DecayChannel == hf2Prong::DecayChannelMain::D0ToPiPi) {
386+
category = D0McCategory::CorrBkgPiPi;
387+
} else if (d0DecayChannel == hf2Prong::DecayChannelMain::D0ToPiPiPi0) {
388+
category = D0McCategory::CorrBkgPiPiPi0;
389+
} else if (d0DecayChannel == hf2Prong::DecayChannelMain::D0ToKK) {
390+
category = D0McCategory::CorrBkgKK;
386391
}
387392

388393
tableD0McDetector(tableCollision.lastIndex(), // might want to add some more detector level D0 quantities like prompt or non prompt info

0 commit comments

Comments
 (0)