Skip to content

Commit 7234ee0

Browse files
committed
adding info on prompt / non prompt candidates
1 parent 4d7837f commit 7234ee0

File tree

1 file changed

+55
-8
lines changed

1 file changed

+55
-8
lines changed

PWGHF/TableProducer/treeCreatorLcToK0sP.cxx

Lines changed: 55 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,8 @@
1616
/// Modified version of treeCreatorLcToPKPi.cxx
1717
///
1818
/// \author Daniel Samitz <daniel.samitz@cern.ch>
19+
/// \author Elisa Meninno <elisa.meninno@cern.ch>
20+
1921

2022
#include "PWGHF/Core/HfHelper.h"
2123
#include "PWGHF/DataModel/AliasTables.h"
@@ -90,6 +92,7 @@ DECLARE_SOA_COLUMN(OriginMcGen, originMcGen, int8_t);
9092
DECLARE_SOA_COLUMN(MlScoreFirstClass, mlScoreFirstClass, float);
9193
DECLARE_SOA_COLUMN(MlScoreSecondClass, mlScoreSecondClass, float);
9294
DECLARE_SOA_COLUMN(MlScoreThirdClass, mlScoreThirdClass, float);
95+
DECLARE_SOA_COLUMN(SigBgStatus, sigBgStatus, int); //! 0 bg, 1 prompt, 2 non-prompt,-1 default value (impossible, should not be the case), -999 for data
9396
// Events
9497
DECLARE_SOA_COLUMN(IsEventReject, isEventReject, int);
9598
DECLARE_SOA_COLUMN(RunNumber, runNumber, int);
@@ -135,7 +138,9 @@ DECLARE_SOA_TABLE(HfCandCascLites, "AOD", "HFCANDCASCLITE",
135138
full::OriginMcRec,
136139
full::MlScoreFirstClass,
137140
full::MlScoreSecondClass,
138-
full::MlScoreThirdClass);
141+
full::MlScoreThirdClass,
142+
full::SigBgStatus);
143+
139144

140145
DECLARE_SOA_TABLE(HfCandCascFulls, "AOD", "HFCANDCASCFULL",
141146
collision::BCId,
@@ -208,7 +213,8 @@ DECLARE_SOA_TABLE(HfCandCascFulls, "AOD", "HFCANDCASCFULL",
208213
full::OriginMcRec,
209214
full::MlScoreFirstClass,
210215
full::MlScoreSecondClass,
211-
full::MlScoreThirdClass);
216+
full::MlScoreThirdClass,
217+
full::SigBgStatus);
212218

213219
DECLARE_SOA_TABLE(HfCandCascFullEs, "AOD", "HFCANDCASCFULLE",
214220
collision::BCId,
@@ -247,6 +253,38 @@ struct HfTreeCreatorLcToK0sP {
247253
using SelectedCandidatesMc = soa::Filtered<soa::Join<aod::HfCandCascade, aod::HfCandCascadeMcRec, aod::HfSelLcToK0sP>>;
248254
Filter filterSelectCandidates = aod::hf_sel_candidate_lc_to_k0s_p::isSelLcToK0sP >= 1;
249255

256+
// number showing MC status of the candidate (signal or background, prompt or non-prompt etc.)
257+
enum SigBgStatus : int {
258+
Background = 0, // combinatorial background, at least one of the prongs do not originate from the Lc decay
259+
Prompt, // signal with Lc produced directly in the event
260+
NonPrompt, // signal with Lc produced aftewards the event, e.g. during decay of beauty particle
261+
Default = -1 // impossible, should not be the case, to catch logical error if any
262+
};
263+
264+
/// \brief function which determines if the candidate corresponds to MC-particle or belongs to a combinatorial background
265+
/// \param candidate candidate to be checked for being signal or background
266+
/// \return SigBgStatus enum with value encoding MC status of the candidate
267+
template <typename CandType>
268+
SigBgStatus determineSignalBgStatus(const CandType& candidate)
269+
{
270+
const int flag = candidate.flagMcMatchRec();
271+
const int origin = candidate.originMcRec();
272+
273+
SigBgStatus status{Default};
274+
275+
if (std::abs(flag) != 1) {
276+
return Background; // combinatorial or wrong decay
277+
}
278+
// Otherwise it is signal: distinguish between Prompt/ NonPrompt
279+
if (origin == RecoDecay::OriginType::Prompt) {
280+
return Prompt;
281+
}
282+
if (origin == RecoDecay::OriginType::NonPrompt) {
283+
return NonPrompt;
284+
}
285+
return Default;
286+
}
287+
250288
void init(InitContext const&)
251289
{
252290
}
@@ -276,7 +314,8 @@ struct HfTreeCreatorLcToK0sP {
276314
}
277315

278316
template <typename T, typename U>
279-
void fillCandidate(const T& candidate, const U& bach, int8_t flagMc, int8_t originMcRec, aod::HfMlLcToK0sP::iterator const& candidateMlScore)
317+
void fillCandidate(const T& candidate, const U& bach, int8_t flagMc, int8_t originMcRec, aod::HfMlLcToK0sP::iterator const& candidateMlScore, int sigbgstatus)
318+
/// \param sigbgstatus for MC: number indicating if candidate is prompt, non-prompt or background; for data: UndefValueInt
280319
{
281320

282321
float mlScoreFirstClass{UndefValueFloat};
@@ -328,7 +367,8 @@ struct HfTreeCreatorLcToK0sP {
328367
originMcRec,
329368
mlScoreFirstClass,
330369
mlScoreSecondClass,
331-
mlScoreThirdClass);
370+
mlScoreThirdClass,
371+
sigbgstatus);
332372
} else {
333373
rowCandidateFull(
334374
bach.collision().bcId(),
@@ -401,7 +441,8 @@ struct HfTreeCreatorLcToK0sP {
401441
originMcRec,
402442
mlScoreFirstClass,
403443
mlScoreSecondClass,
404-
mlScoreThirdClass);
444+
mlScoreThirdClass,
445+
sigbgstatus);
405446
}
406447
}
407448
template <typename T>
@@ -447,8 +488,14 @@ struct HfTreeCreatorLcToK0sP {
447488
auto bach = candidate.prong0_as<TracksWPid>(); // bachelor
448489
const int flag = candidate.flagMcMatchRec();
449490

450-
if ((fillOnlySignal && flag != 0) || (fillOnlyBackground && flag == 0) || (!fillOnlySignal && !fillOnlyBackground)) {
451-
fillCandidate(candidate, bach, candidate.flagMcMatchRec(), candidate.originMcRec(), candidateMlScore);
491+
// get status (Prompt / NonPrompt / Background)
492+
SigBgStatus sigbgstatus = determineSignalBgStatus(candidate);
493+
494+
bool isSignal = (std::abs(flag) == 1);
495+
bool isBackground = !isSignal;
496+
497+
if ((fillOnlySignal && isSignal) || (fillOnlyBackground && isBackground) || (!fillOnlySignal && !fillOnlyBackground)) {
498+
fillCandidate(candidate, bach, candidate.flagMcMatchRec(), candidate.originMcRec(), candidateMlScore, sigbgstatus);
452499
}
453500
}
454501

@@ -500,7 +547,7 @@ struct HfTreeCreatorLcToK0sP {
500547
auto bach = candidate.prong0_as<TracksWPid>(); // bachelor
501548
double const pseudoRndm = bach.pt() * 1000. - static_cast<int16_t>(bach.pt() * 1000);
502549
if (candidate.isSelLcToK0sP() >= 1 && pseudoRndm < downSampleBkgFactor) {
503-
fillCandidate(candidate, bach, 0, 0, candidateMlScore);
550+
fillCandidate(candidate, bach, 0, 0, candidateMlScore, -999);
504551
}
505552
}
506553
}

0 commit comments

Comments
 (0)