From f56d4dc3b9747cdfe5e04e71a1c1dd23b802cbf7 Mon Sep 17 00:00:00 2001 From: Luigi Dello Stritto Date: Thu, 30 May 2024 18:27:42 +0200 Subject: [PATCH] Propagating PR to all candidate creators --- .../TableProducer/candidateCreator2Prong.cxx | 23 +++++++--- .../TableProducer/candidateCreator3Prong.cxx | 4 +- .../TableProducer/candidateCreatorCascade.cxx | 24 +++++++---- PWGHF/TableProducer/candidateCreatorDstar.cxx | 24 ++++++++--- .../candidateCreatorXic0Omegac0.cxx | 43 +++++++------------ PWGHF/Utils/utilsEvSelHf.h | 8 ++-- 6 files changed, 70 insertions(+), 56 deletions(-) diff --git a/PWGHF/TableProducer/candidateCreator2Prong.cxx b/PWGHF/TableProducer/candidateCreator2Prong.cxx index ee4c62443de..ae67961f010 100644 --- a/PWGHF/TableProducer/candidateCreator2Prong.cxx +++ b/PWGHF/TableProducer/candidateCreator2Prong.cxx @@ -48,6 +48,7 @@ using namespace o2; using namespace o2::analysis; using namespace o2::hf_evsel; +using namespace o2::hf_evsel_mc; using namespace o2::hf_trkcandsel; using namespace o2::aod::hf_cand_2prong; using namespace o2::hf_centrality; @@ -653,7 +654,8 @@ struct HfCandidateCreator2ProngExpressions { Produces rowMcMatchRec; Produces rowMcMatchGen; - float zPvPosMax{1000.f}; + HfEventSelectionMc hfEvSelMc; // mc event selection + using BCsInfo = soa::Join; // inspect for which zPvPosMax cut was set for reconstructed void init(InitContext& initContext) @@ -662,9 +664,14 @@ struct HfCandidateCreator2ProngExpressions { for (const DeviceSpec& device : workflows.devices) { if (device.name.compare("hf-candidate-creator-2prong") == 0) { for (const auto& option : device.options) { - if (option.name.compare("hfEvSel.zPvPosMax") == 0) { - zPvPosMax = option.defaultValue.get(); - break; + if (option.name.compare("hfEvSel.useSel8Trigger") == 0) { + hfEvSelMc.useItsRoBorderCut = option.defaultValue.get(); + } else if (option.name.compare("hfEvSel.useTimeFrameBorderCut") == 0) { + hfEvSelMc.useTimeFrameBorderCut = option.defaultValue.get(); + } else if (option.name.compare("hfEvSel.zPvPosMin") == 0) { + hfEvSelMc.zPvPosMin = option.defaultValue.get(); + } else if (option.name.compare("hfEvSel.zPvPosMax") == 0) { + hfEvSelMc.zPvPosMax = option.defaultValue.get(); } } break; @@ -675,7 +682,8 @@ struct HfCandidateCreator2ProngExpressions { /// Performs MC matching. void processMc(aod::TracksWMc const& tracks, aod::McParticles const& mcParticles, - aod::McCollisions const&) + aod::McCollisions const&, + BCsInfo const&) { rowCandidateProng2->bindExternalIndices(&tracks); @@ -729,8 +737,9 @@ struct HfCandidateCreator2ProngExpressions { origin = 0; auto mcCollision = particle.mcCollision(); - float zPv = mcCollision.posZ(); - if (zPv < -zPvPosMax || zPv > zPvPosMax) { // to avoid counting particles in collisions with Zvtx larger than the maximum, we do not match them + const auto rejectionMask = hfEvSelMc.getHfMcCollisionRejectionMask(mcCollision); + if (rejectionMask != 0) { + /// at least one event selection not satisfied --> reject the gen particle rowMcMatchGen(flag, origin); continue; } diff --git a/PWGHF/TableProducer/candidateCreator3Prong.cxx b/PWGHF/TableProducer/candidateCreator3Prong.cxx index fe80f976045..a26f6b13cd2 100644 --- a/PWGHF/TableProducer/candidateCreator3Prong.cxx +++ b/PWGHF/TableProducer/candidateCreator3Prong.cxx @@ -478,8 +478,8 @@ struct HfCandidateCreator3ProngExpressions { createLc = option.defaultValue.get(); } else if (option.name.compare("createXic") == 0) { createXic = option.defaultValue.get(); - } else if (option.name.compare("hfEvSel.iseSel8Trigger") == 0) { - hfEvSelMc.useITSROBorderCut = option.defaultValue.get(); + } else if (option.name.compare("hfEvSel.useSel8Trigger") == 0) { + hfEvSelMc.useItsRoBorderCut = option.defaultValue.get(); } else if (option.name.compare("hfEvSel.useTimeFrameBorderCut") == 0) { hfEvSelMc.useTimeFrameBorderCut = option.defaultValue.get(); } else if (option.name.compare("hfEvSel.zPvPosMin") == 0) { diff --git a/PWGHF/TableProducer/candidateCreatorCascade.cxx b/PWGHF/TableProducer/candidateCreatorCascade.cxx index 2dc8bc106e3..e8df43ae473 100644 --- a/PWGHF/TableProducer/candidateCreatorCascade.cxx +++ b/PWGHF/TableProducer/candidateCreatorCascade.cxx @@ -37,6 +37,7 @@ using namespace o2; using namespace o2::analysis; using namespace o2::hf_evsel; +using namespace o2::hf_evsel_mc; using namespace o2::hf_trkcandsel; using namespace o2::hf_centrality; using namespace o2::constants::physics; @@ -431,9 +432,9 @@ struct HfCandidateCreatorCascadeMc { Produces rowMcMatchRec; Produces rowMcMatchGen; + HfEventSelectionMc hfEvSelMc; // mc event selection using MyTracksWMc = soa::Join; - - float zPvPosMax{1000.f}; + using BCsInfo = soa::Join; // inspect for which zPvPosMax cut was set for reconstructed void init(InitContext& initContext) @@ -442,9 +443,14 @@ struct HfCandidateCreatorCascadeMc { for (const DeviceSpec& device : workflows.devices) { if (device.name.compare("hf-candidate-creator-cascade") == 0) { for (const auto& option : device.options) { - if (option.name.compare("hfEvSel.zPvPosMax") == 0) { - zPvPosMax = option.defaultValue.get(); - break; + if (option.name.compare("hfEvSel.useSel8Trigger") == 0) { + hfEvSelMc.useItsRoBorderCut = option.defaultValue.get(); + } else if (option.name.compare("hfEvSel.useTimeFrameBorderCut") == 0) { + hfEvSelMc.useTimeFrameBorderCut = option.defaultValue.get(); + } else if (option.name.compare("hfEvSel.zPvPosMin") == 0) { + hfEvSelMc.zPvPosMin = option.defaultValue.get(); + } else if (option.name.compare("hfEvSel.zPvPosMax") == 0) { + hfEvSelMc.zPvPosMax = option.defaultValue.get(); } } break; @@ -454,7 +460,8 @@ struct HfCandidateCreatorCascadeMc { void processMc(MyTracksWMc const& tracks, aod::McParticles const& mcParticles, - aod::McCollisions const&) + aod::McCollisions const&, + BCsInfo const&) { int8_t sign = 0; int8_t origin = 0; @@ -503,8 +510,9 @@ struct HfCandidateCreatorCascadeMc { origin = 0; auto mcCollision = particle.mcCollision(); - float zPv = mcCollision.posZ(); - if (zPv < -zPvPosMax || zPv > zPvPosMax) { // to avoid counting particles in collisions with Zvtx larger than the maximum, we do not match them + const auto rejectionMask = hfEvSelMc.getHfMcCollisionRejectionMask(mcCollision); + if (rejectionMask != 0) { + /// at least one event selection not satisfied --> reject the gen particle rowMcMatchGen(sign, origin); continue; } diff --git a/PWGHF/TableProducer/candidateCreatorDstar.cxx b/PWGHF/TableProducer/candidateCreatorDstar.cxx index ccc7828fe5a..68372f0029c 100644 --- a/PWGHF/TableProducer/candidateCreatorDstar.cxx +++ b/PWGHF/TableProducer/candidateCreatorDstar.cxx @@ -36,6 +36,7 @@ using namespace o2; using namespace o2::hf_evsel; +using namespace o2::hf_evsel_mc; using namespace o2::hf_trkcandsel; using namespace o2::hf_centrality; using namespace o2::constants::physics; @@ -504,7 +505,8 @@ struct HfCandidateCreatorDstarExpressions { Produces rowsMcMatchRecDstar; Produces rowsMcMatchGenDstar; - float zPvPosMax{1000.f}; + HfEventSelectionMc hfEvSelMc; // mc event selection + using BCsInfo = soa::Join; // inspect for which zPvPosMax cut was set for reconstructed void init(InitContext& initContext) @@ -513,9 +515,14 @@ struct HfCandidateCreatorDstarExpressions { for (const DeviceSpec& device : workflows.devices) { if (device.name.compare("hf-candidate-creator-dstar") == 0) { for (const auto& option : device.options) { - if (option.name.compare("hfEvSel.zPvPosMax") == 0) { - zPvPosMax = option.defaultValue.get(); - break; + if (option.name.compare("hfEvSel.useSel8Trigger") == 0) { + hfEvSelMc.useItsRoBorderCut = option.defaultValue.get(); + } else if (option.name.compare("hfEvSel.useTimeFrameBorderCut") == 0) { + hfEvSelMc.useTimeFrameBorderCut = option.defaultValue.get(); + } else if (option.name.compare("hfEvSel.zPvPosMin") == 0) { + hfEvSelMc.zPvPosMin = option.defaultValue.get(); + } else if (option.name.compare("hfEvSel.zPvPosMax") == 0) { + hfEvSelMc.zPvPosMax = option.defaultValue.get(); } } break; @@ -526,7 +533,8 @@ struct HfCandidateCreatorDstarExpressions { /// Perform MC Matching. void processMc(aod::TracksWMc const& tracks, aod::McParticles const& mcParticles, - aod::McCollisions const&) + aod::McCollisions const&, + BCsInfo const&) { rowsCandidateD0->bindExternalIndices(&tracks); rowsCandidateDstar->bindExternalIndices(&tracks); @@ -590,8 +598,10 @@ struct HfCandidateCreatorDstarExpressions { std::vector idxBhadMothers{}; auto mcCollision = particle.mcCollision(); - float zPv = mcCollision.posZ(); - if (zPv < -zPvPosMax || zPv > zPvPosMax) { // to avoid counting particles in collisions with Zvtx larger than the maximum, we do not match them + + const auto rejectionMask = hfEvSelMc.getHfMcCollisionRejectionMask(mcCollision); + if (rejectionMask != 0) { + /// at least one event selection not satisfied --> reject the gen particle rowsMcMatchGenDstar(flagDstar, originDstar, -1); rowsMcMatchGenD0(flagD0, originD0); continue; diff --git a/PWGHF/TableProducer/candidateCreatorXic0Omegac0.cxx b/PWGHF/TableProducer/candidateCreatorXic0Omegac0.cxx index 330619636f5..1c443ec1b6d 100644 --- a/PWGHF/TableProducer/candidateCreatorXic0Omegac0.cxx +++ b/PWGHF/TableProducer/candidateCreatorXic0Omegac0.cxx @@ -54,6 +54,7 @@ using namespace o2::constants::physics; using namespace o2::framework; using namespace o2::framework::expressions; using namespace o2::hf_evsel; +using namespace o2::hf_evsel_mc; // Reconstruction of omegac0 and xic0 candidates struct HfCandidateCreatorXic0Omegac0 { @@ -661,9 +662,7 @@ struct HfCandidateCreatorXic0Omegac0Mc { Produces rowMCMatchRecToOmegaK; Produces rowMCMatchGenToOmegaK; - Configurable rejGenTFAndITSROFBorders{"rejGenTFAndITSROFBorders", true, "Reject generated particles coming from bc close to TF and ITSROF borders"}; - float zPvPosMax{1000.f}; - + HfEventSelectionMc hfEvSelMc; // mc event selection using BCsInfo = soa::Join; // inspect for which zPvPosMax cut was set for reconstructed @@ -673,9 +672,14 @@ struct HfCandidateCreatorXic0Omegac0Mc { for (const DeviceSpec& device : workflows.devices) { if (device.name.compare("hf-candidate-creator-xic0-omegac0") == 0) { for (const auto& option : device.options) { - if (option.name.compare("hfEvSel.zPvPosMax") == 0) { - zPvPosMax = option.defaultValue.get(); - break; + if (option.name.compare("hfEvSel.useSel8Trigger") == 0) { + hfEvSelMc.useItsRoBorderCut = option.defaultValue.get(); + } else if (option.name.compare("hfEvSel.useTimeFrameBorderCut") == 0) { + hfEvSelMc.useTimeFrameBorderCut = option.defaultValue.get(); + } else if (option.name.compare("hfEvSel.zPvPosMin") == 0) { + hfEvSelMc.zPvPosMin = option.defaultValue.get(); + } else if (option.name.compare("hfEvSel.zPvPosMax") == 0) { + hfEvSelMc.zPvPosMax = option.defaultValue.get(); } } break; @@ -885,12 +889,11 @@ struct HfCandidateCreatorXic0Omegac0Mc { debugGenLambda = 0; origin = RecoDecay::OriginType::None; - // accept only mc particles coming from bc that are far away from TF border and ITSROFrame - if (rejGenTFAndITSROFBorders) { - auto coll = particle.mcCollision_as(); - auto bc = coll.bc_as(); - if (!bc.selection_bit(o2::aod::evsel::kNoITSROFrameBorder) || !bc.selection_bit(o2::aod::evsel::kNoTimeFrameBorder)) { - if constexpr (decayChannel == aod::hf_cand_xic0_omegac0::DecayType::XiczeroToXiPi) { + auto mcCollision = particle.mcCollision(); + const auto rejectionMask = hfEvSelMc.getHfMcCollisionRejectionMask(mcCollision); + if (rejectionMask != 0) { + /// at least one event selection not satisfied --> reject the gen particle + if constexpr (decayChannel == aod::hf_cand_xic0_omegac0::DecayType::XiczeroToXiPi) { rowMCMatchGenXicToXiPi(flag, debugGenCharmBar, debugGenCasc, debugGenLambda, ptCharmBaryonGen, etaCharmBaryonGen, origin); } else if constexpr (decayChannel == aod::hf_cand_xic0_omegac0::DecayType::OmegaczeroToXiPi) { rowMCMatchGenOmegacToXiPi(flag, debugGenCharmBar, debugGenCasc, debugGenLambda, ptCharmBaryonGen, etaCharmBaryonGen, origin); @@ -901,22 +904,6 @@ struct HfCandidateCreatorXic0Omegac0Mc { } continue; } - } - - auto mcCollision = particle.mcCollision(); - float zPv = mcCollision.posZ(); - if (zPv < -zPvPosMax || zPv > zPvPosMax) { // to avoid counting particles in collisions with Zvtx larger than the maximum, we do not match them - if constexpr (decayChannel == aod::hf_cand_xic0_omegac0::DecayType::XiczeroToXiPi) { - rowMCMatchGenXicToXiPi(flag, debugGenCharmBar, debugGenCasc, debugGenLambda, ptCharmBaryonGen, etaCharmBaryonGen, origin); - } else if constexpr (decayChannel == aod::hf_cand_xic0_omegac0::DecayType::OmegaczeroToXiPi) { - rowMCMatchGenOmegacToXiPi(flag, debugGenCharmBar, debugGenCasc, debugGenLambda, ptCharmBaryonGen, etaCharmBaryonGen, origin); - } else if constexpr (decayChannel == aod::hf_cand_xic0_omegac0::DecayType::OmegaczeroToOmegaPi) { - rowMCMatchGenToOmegaPi(flag, debugGenCharmBar, debugGenCasc, debugGenLambda, ptCharmBaryonGen, etaCharmBaryonGen, origin); - } else if constexpr (decayChannel == aod::hf_cand_xic0_omegac0::DecayType::OmegaczeroToOmegaK) { - rowMCMatchGenToOmegaK(flag, debugGenCharmBar, debugGenCasc, debugGenLambda, ptCharmBaryonGen, etaCharmBaryonGen, origin); - } - continue; - } if constexpr (decayChannel == aod::hf_cand_xic0_omegac0::DecayType::XiczeroToXiPi) { // Xic → Xi pi diff --git a/PWGHF/Utils/utilsEvSelHf.h b/PWGHF/Utils/utilsEvSelHf.h index fe41d1e7b36..eca1bb4e450 100644 --- a/PWGHF/Utils/utilsEvSelHf.h +++ b/PWGHF/Utils/utilsEvSelHf.h @@ -200,14 +200,14 @@ namespace o2::hf_evsel_mc enum McCollisionRejection { None = 0, TimeFrameBorderCut, - ITSROFrameBorderCut, + ItsRoFrameBorderCut, PositionZ, NMcCollisionRejection }; struct HfEventSelectionMc { // event selection parameters (in chronological order of application) - bool useITSROBorderCut{false}; // Apply the ITS RO frame border cut + bool useItsRoBorderCut{false}; // Apply the ITS RO frame border cut bool useTimeFrameBorderCut{true}; // Apply TF border cut float zPvPosMin{-1000.f}; // Minimum PV posZ (cm) float zPvPosMax{1000.f}; // Maximum PV posZ (cm) @@ -223,8 +223,8 @@ struct HfEventSelectionMc { auto bc = mcCollision.template bc_as(); /// ITS RO frame border cut - if (useITSROBorderCut && !bc.selection_bit(o2::aod::evsel::kNoITSROFrameBorder)) { - SETBIT(rejectionMask, McCollisionRejection::ITSROFrameBorderCut); + if (useItsRoBorderCut && !bc.selection_bit(o2::aod::evsel::kNoITSROFrameBorder)) { + SETBIT(rejectionMask, McCollisionRejection::ItsRoFrameBorderCut); } /// time frame border cut if (useTimeFrameBorderCut && !bc.selection_bit(o2::aod::evsel::kNoTimeFrameBorder)) {