Skip to content

Commit f15027a

Browse files
[PWGJE] Update to use bitwise operations for selection flags in charm hadronisation (#8613)
1 parent efc0ca7 commit f15027a

File tree

1 file changed

+21
-11
lines changed

1 file changed

+21
-11
lines changed

PWGJE/Tasks/hfFragmentationFunction.cxx

Lines changed: 21 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ DECLARE_SOA_COLUMN(JetHfDist, jethfdist, float);
7272
DECLARE_SOA_COLUMN(JetPt, jetpt, float);
7373
DECLARE_SOA_COLUMN(JetEta, jeteta, float);
7474
DECLARE_SOA_COLUMN(JetPhi, jetphi, float);
75-
DECLARE_SOA_COLUMN(JetNConst, jetnconst, float);
75+
DECLARE_SOA_COLUMN(JetNConst, jetnconst, int);
7676
DECLARE_SOA_COLUMN(HfPt, hfpt, float);
7777
DECLARE_SOA_COLUMN(HfEta, hfeta, float);
7878
DECLARE_SOA_COLUMN(HfPhi, hfphi, float);
@@ -323,24 +323,29 @@ struct HfFragmentationFunctionTask {
323323
registry.fill(HIST("h_jet_counter"), 1.5);
324324
}
325325

326-
// reflection information for storage: +1 = D0, -1 = D0bar, 0 = neither
326+
// reflection information for storage: D0 = +1, D0bar = -1, neither = 0
327327
int matchedFrom = 0;
328328
int decayChannel = 1 << aod::hf_cand_2prong::DecayType::D0ToPiK;
329+
int selectedAs = 0;
329330

330331
if (mcdd0cand.flagMcMatchRec() == decayChannel) { // matched to D0 on truth level
331332
matchedFrom = 1;
332333
} else if (mcdd0cand.flagMcMatchRec() == -decayChannel) { // matched to D0bar on truth level
333334
matchedFrom = -1;
334-
} else { // matched to another kind of particle on truth level
335-
matchedFrom = 0;
335+
}
336+
// bitwise AND operation: Checks whether BIT(i) is set, regardless of other bits
337+
if (mcdd0cand.candidateSelFlag() & BIT(0)) { // CandidateSelFlag == BIT(0) -> selected as D0
338+
selectedAs = 1;
339+
} else if (mcdd0cand.candidateSelFlag() & BIT(1)) { // CandidateSelFlag == BIT(1) -> selected as D0bar
340+
selectedAs = -1;
336341
}
337342

338343
// store data in MC detector level table
339344
mcddistJetTable(jetutilities::deltaR(mcdjet, mcdd0cand),
340345
mcdjet.pt(), mcdjet.eta(), mcdjet.phi(), mcdjet.tracks_as<aod::JetTracks>().size(), // detector level jet
341346
mcdd0cand.pt(), mcdd0cand.eta(), mcdd0cand.phi(), mcdd0cand.m(), mcdd0cand.y(), (mcdd0cand.originMcRec() == RecoDecay::OriginType::Prompt), // detector level D0 candidate
342-
mcdjet.has_matchedJetCand(), mcdd0cand.mlScores()[0], mcdd0cand.mlScores()[1], mcdd0cand.mlScores()[2], // ML scores for bkg, prompt and non-prompt
343-
matchedFrom, mcdd0cand.candidateSelFlag()); // check whether detector level candidate is a reflection, CandidateSelFlag == 0 -> selected as D0, CandidateSelFlag == 1 -> selected as D0bar
347+
mcdjet.has_matchedJetCand(), mcdd0cand.mlScores()[0], mcdd0cand.mlScores()[1], mcdd0cand.mlScores()[2], // // Machine Learning PID scores: background, prompt, non-prompt
348+
matchedFrom, selectedAs); // D0 = +1, D0bar = -1, neither = 0
344349
}
345350
}
346351

@@ -409,16 +414,21 @@ struct HfFragmentationFunctionTask {
409414
// obtain leading HF candidate in jet
410415
auto mcdd0cand = mcdjet.candidates_first_as<aod::CandidatesD0MCD>();
411416

412-
// reflection information for storage: +1 = D0, -1 = D0bar, 0 = neither
417+
// reflection information for storage: D0 = +1, D0bar = -1, neither = 0
413418
int matchedFrom = 0;
414419
int decayChannel = 1 << aod::hf_cand_2prong::DecayType::D0ToPiK;
420+
int selectedAs = 0;
415421

416422
if (mcdd0cand.flagMcMatchRec() == decayChannel) { // matched to D0 on truth level
417423
matchedFrom = 1;
418424
} else if (mcdd0cand.flagMcMatchRec() == -decayChannel) { // matched to D0bar on truth level
419425
matchedFrom = -1;
420-
} else { // matched to another kind of particle on truth level
421-
matchedFrom = 0;
426+
}
427+
// bitwise AND operation: Checks whether BIT(i) is set, regardless of other bits
428+
if (mcdd0cand.candidateSelFlag() & BIT(0)) { // CandidateSelFlag == BIT(0) -> selected as D0
429+
selectedAs = 1;
430+
} else if (mcdd0cand.candidateSelFlag() & BIT(1)) { // CandidateSelFlag == BIT(1) -> selected as D0bar
431+
selectedAs = -1;
422432
}
423433

424434
// loop through detector level matched to current particle level
@@ -434,8 +444,8 @@ struct HfFragmentationFunctionTask {
434444
mcpd0cand.pt(), mcpd0cand.eta(), mcpd0cand.phi(), mcpd0cand.y(), (mcpd0cand.originMcGen() == RecoDecay::OriginType::Prompt), // particle level D0
435445
jetutilities::deltaR(mcdjet, mcdd0cand), mcdjet.pt(), mcdjet.eta(), mcdjet.phi(), mcdjet.tracks_as<aod::JetTracks>().size(), // detector level jet
436446
mcdd0cand.pt(), mcdd0cand.eta(), mcdd0cand.phi(), mcdd0cand.m(), mcdd0cand.y(), (mcdd0cand.originMcRec() == RecoDecay::OriginType::Prompt), // detector level D0
437-
mcdd0cand.mlScores()[0], mcdd0cand.mlScores()[1], mcdd0cand.mlScores()[2],
438-
matchedFrom, mcdd0cand.candidateSelFlag()); // check whether detector level candidate is a reflection, CandidateSelFlag == 0 -> selected as D0, CandidateSelFlag == 1 -> selected as D0bar
447+
mcdd0cand.mlScores()[0], mcdd0cand.mlScores()[1], mcdd0cand.mlScores()[2], // Machine Learning PID scores: background, prompt, non-prompt
448+
matchedFrom, selectedAs); // D0 = +1, D0bar = -1, neither = 0
439449
}
440450
}
441451
}

0 commit comments

Comments
 (0)