|
16 | 16 | /// Modified version of treeCreatorLcToPKPi.cxx |
17 | 17 | /// |
18 | 18 | /// \author Daniel Samitz <daniel.samitz@cern.ch> |
| 19 | +/// \author Elisa Meninno <elisa.meninno@cern.ch> |
| 20 | + |
19 | 21 |
|
20 | 22 | #include "PWGHF/Core/HfHelper.h" |
21 | 23 | #include "PWGHF/DataModel/AliasTables.h" |
@@ -90,6 +92,7 @@ DECLARE_SOA_COLUMN(OriginMcGen, originMcGen, int8_t); |
90 | 92 | DECLARE_SOA_COLUMN(MlScoreFirstClass, mlScoreFirstClass, float); |
91 | 93 | DECLARE_SOA_COLUMN(MlScoreSecondClass, mlScoreSecondClass, float); |
92 | 94 | 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 |
93 | 96 | // Events |
94 | 97 | DECLARE_SOA_COLUMN(IsEventReject, isEventReject, int); |
95 | 98 | DECLARE_SOA_COLUMN(RunNumber, runNumber, int); |
@@ -135,7 +138,9 @@ DECLARE_SOA_TABLE(HfCandCascLites, "AOD", "HFCANDCASCLITE", |
135 | 138 | full::OriginMcRec, |
136 | 139 | full::MlScoreFirstClass, |
137 | 140 | full::MlScoreSecondClass, |
138 | | - full::MlScoreThirdClass); |
| 141 | + full::MlScoreThirdClass, |
| 142 | + full::SigBgStatus); |
| 143 | + |
139 | 144 |
|
140 | 145 | DECLARE_SOA_TABLE(HfCandCascFulls, "AOD", "HFCANDCASCFULL", |
141 | 146 | collision::BCId, |
@@ -208,7 +213,8 @@ DECLARE_SOA_TABLE(HfCandCascFulls, "AOD", "HFCANDCASCFULL", |
208 | 213 | full::OriginMcRec, |
209 | 214 | full::MlScoreFirstClass, |
210 | 215 | full::MlScoreSecondClass, |
211 | | - full::MlScoreThirdClass); |
| 216 | + full::MlScoreThirdClass, |
| 217 | + full::SigBgStatus); |
212 | 218 |
|
213 | 219 | DECLARE_SOA_TABLE(HfCandCascFullEs, "AOD", "HFCANDCASCFULLE", |
214 | 220 | collision::BCId, |
@@ -247,6 +253,38 @@ struct HfTreeCreatorLcToK0sP { |
247 | 253 | using SelectedCandidatesMc = soa::Filtered<soa::Join<aod::HfCandCascade, aod::HfCandCascadeMcRec, aod::HfSelLcToK0sP>>; |
248 | 254 | Filter filterSelectCandidates = aod::hf_sel_candidate_lc_to_k0s_p::isSelLcToK0sP >= 1; |
249 | 255 |
|
| 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 | + |
250 | 288 | void init(InitContext const&) |
251 | 289 | { |
252 | 290 | } |
@@ -276,7 +314,8 @@ struct HfTreeCreatorLcToK0sP { |
276 | 314 | } |
277 | 315 |
|
278 | 316 | 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 |
280 | 319 | { |
281 | 320 |
|
282 | 321 | float mlScoreFirstClass{UndefValueFloat}; |
@@ -328,7 +367,8 @@ struct HfTreeCreatorLcToK0sP { |
328 | 367 | originMcRec, |
329 | 368 | mlScoreFirstClass, |
330 | 369 | mlScoreSecondClass, |
331 | | - mlScoreThirdClass); |
| 370 | + mlScoreThirdClass, |
| 371 | + sigbgstatus); |
332 | 372 | } else { |
333 | 373 | rowCandidateFull( |
334 | 374 | bach.collision().bcId(), |
@@ -401,7 +441,8 @@ struct HfTreeCreatorLcToK0sP { |
401 | 441 | originMcRec, |
402 | 442 | mlScoreFirstClass, |
403 | 443 | mlScoreSecondClass, |
404 | | - mlScoreThirdClass); |
| 444 | + mlScoreThirdClass, |
| 445 | + sigbgstatus); |
405 | 446 | } |
406 | 447 | } |
407 | 448 | template <typename T> |
@@ -447,8 +488,14 @@ struct HfTreeCreatorLcToK0sP { |
447 | 488 | auto bach = candidate.prong0_as<TracksWPid>(); // bachelor |
448 | 489 | const int flag = candidate.flagMcMatchRec(); |
449 | 490 |
|
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); |
452 | 499 | } |
453 | 500 | } |
454 | 501 |
|
@@ -500,7 +547,7 @@ struct HfTreeCreatorLcToK0sP { |
500 | 547 | auto bach = candidate.prong0_as<TracksWPid>(); // bachelor |
501 | 548 | double const pseudoRndm = bach.pt() * 1000. - static_cast<int16_t>(bach.pt() * 1000); |
502 | 549 | if (candidate.isSelLcToK0sP() >= 1 && pseudoRndm < downSampleBkgFactor) { |
503 | | - fillCandidate(candidate, bach, 0, 0, candidateMlScore); |
| 550 | + fillCandidate(candidate, bach, 0, 0, candidateMlScore, -999); |
504 | 551 | } |
505 | 552 | } |
506 | 553 | } |
|
0 commit comments