From 692e479b2732fea817f0928260f7481365f8c3d1 Mon Sep 17 00:00:00 2001 From: Luigi Dello Stritto Date: Tue, 28 May 2024 11:24:28 +0200 Subject: [PATCH 01/14] PWGHF: add TF border cut at the particle generate level --- PWGHF/TableProducer/candidateCreator3Prong.cxx | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/PWGHF/TableProducer/candidateCreator3Prong.cxx b/PWGHF/TableProducer/candidateCreator3Prong.cxx index cafcef912cc..6def1f31244 100644 --- a/PWGHF/TableProducer/candidateCreator3Prong.cxx +++ b/PWGHF/TableProducer/candidateCreator3Prong.cxx @@ -476,6 +476,9 @@ struct HfCandidateCreator3ProngExpressions { bool createLc{false}; bool createXic{false}; float zPvPosMax{1000.f}; + float useTimeFrameBorderCut{false}; + + using BCsInfo = soa::Join; void init(InitContext& initContext) { @@ -495,6 +498,8 @@ struct HfCandidateCreator3ProngExpressions { createXic = option.defaultValue.get(); } else if (option.name.compare("zPvPosMax") == 0) { zPvPosMax = option.defaultValue.get(); + } else if (option.name.compare("useTimeFrameBorderCut") == 0) { + useTimeFrameBorderCut = option.defaultValue.get(); } } break; @@ -511,7 +516,8 @@ struct HfCandidateCreator3ProngExpressions { /// Performs MC matching. void processMc(aod::TracksWMc const& tracks, aod::McParticles const& mcParticles, - aod::McCollisions const&) + aod::McCollisions const&, + BCsInfo const&) { rowCandidateProng3->bindExternalIndices(&tracks); @@ -635,6 +641,14 @@ struct HfCandidateCreator3ProngExpressions { continue; } + if (useTimeFrameBorderCut) { // accept only mc particles coming from bc that are far away from TF border and ITSROFrame + auto bc = mcCollision.bc_as(); + if (!bc.selection_bit(o2::aod::evsel::kNoITSROFrameBorder) || !bc.selection_bit(o2::aod::evsel::kNoTimeFrameBorder)) { + rowMcMatchGen(flag, origin, channel); + continue; + } + } + // D± → π± K∓ π± if (createDplus) { if (RecoDecay::isMatchedMCGen(mcParticles, particle, Pdg::kDPlus, std::array{+kPiPlus, -kKPlus, +kPiPlus}, true, &sign, 2)) { From 5de91849c161f1c9e24a2e95c80f8269d87b1b27 Mon Sep 17 00:00:00 2001 From: Luigi Dello Stritto Date: Thu, 30 May 2024 15:07:43 +0200 Subject: [PATCH 02/14] Adding utility for the event selection at the generated level --- .../TableProducer/candidateCreator3Prong.cxx | 32 ++++++------- PWGHF/Utils/utilsEvSelHf.h | 48 +++++++++++++++++++ 2 files changed, 63 insertions(+), 17 deletions(-) diff --git a/PWGHF/TableProducer/candidateCreator3Prong.cxx b/PWGHF/TableProducer/candidateCreator3Prong.cxx index 4056d95c221..4b030bf712f 100644 --- a/PWGHF/TableProducer/candidateCreator3Prong.cxx +++ b/PWGHF/TableProducer/candidateCreator3Prong.cxx @@ -36,6 +36,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_3prong; using namespace o2::hf_centrality; @@ -453,12 +454,11 @@ struct HfCandidateCreator3ProngExpressions { Produces rowMcMatchRec; Produces rowMcMatchGen; + HfEventSelectionMc hfEvSelMc; // mc event selection bool createDplus{false}; bool createDs{false}; bool createLc{false}; bool createXic{false}; - float zPvPosMax{1000.f}; - float useTimeFrameBorderCut{false}; using BCsInfo = soa::Join; @@ -478,10 +478,14 @@ 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.useSel8Trigger = 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) { - zPvPosMax = option.defaultValue.get(); - } else if (option.name.compare("useTimeFrameBorderCut") == 0) { - useTimeFrameBorderCut = option.defaultValue.get(); + hfEvSelMc.zPvPosMax = option.defaultValue.get(); } } break; @@ -617,19 +621,13 @@ struct HfCandidateCreator3ProngExpressions { arrDaughIndex.clear(); 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 - rowMcMatchGen(flag, origin, channel); - continue; - } - if (useTimeFrameBorderCut) { // accept only mc particles coming from bc that are far away from TF border and ITSROFrame - auto bc = mcCollision.bc_as(); - if (!bc.selection_bit(o2::aod::evsel::kNoITSROFrameBorder) || !bc.selection_bit(o2::aod::evsel::kNoTimeFrameBorder)) { - rowMcMatchGen(flag, origin, channel); - continue; - } - } + const auto McParticleRejectionMask = hfEvSelMc.getHfMcCollisionRejectionMask(mcCollision); + if (McParticleRejectionMask != 0) { + /// at least one event selection not satisfied --> reject the gen particle + rowMcMatchGen(flag, origin, channel); + continue; + } // D± → π± K∓ π± if (createDplus) { diff --git a/PWGHF/Utils/utilsEvSelHf.h b/PWGHF/Utils/utilsEvSelHf.h index aaa966c314b..3324e23aac1 100644 --- a/PWGHF/Utils/utilsEvSelHf.h +++ b/PWGHF/Utils/utilsEvSelHf.h @@ -194,4 +194,52 @@ struct HfEventSelection : o2::framework::ConfigurableGroup { }; } // namespace o2::hf_evsel +namespace o2::hf_evsel_mc +{ +// generated particles rejection types +enum McCollisionRejection { + None = 0, + TimeFrameBorderCut, + ITSROFrameBorderCut, + PositionZ, + NMcCollisionRejection +}; + +struct HfEventSelectionMc { + // event selection parameters (in chronological order of application) + bool useSel8Trigger{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) + +/// \brief Function to apply event selections in HF analyses +/// \param mcCollision is the analysed mc collision +/// \return a bitmask with the event selections not satisfied by the analysed collision +template +uint16_t getHfMcCollisionRejectionMask(TMcColl const& mcCollision) +{ + + uint8_t rejectionMask{0}; + + float zPv = mcCollision.posZ(); + auto bc = mcCollision.template bc_as(); + + /// ITS RO frame border cut + if (useSel8Trigger && !bc.selection_bit(o2::aod::evsel::kNoITSROFrameBorder)) { + SETBIT(rejectionMask, McCollisionRejection::ITSROFrameBorderCut); + } + /// time frame border cut + if (useTimeFrameBorderCut && !bc.selection_bit(o2::aod::evsel::kNoTimeFrameBorder)) { + SETBIT(rejectionMask, McCollisionRejection::TimeFrameBorderCut); + } + /// primary vertex z + if (zPv < zPvPosMin || zPv > zPvPosMax) { + SETBIT(rejectionMask, McCollisionRejection::PositionZ); + } + + return rejectionMask; +} +}; +} // namespace o2::hf_evsel_mc + #endif // PWGHF_UTILS_UTILSEVSELHF_H_ From fb1ab02dc5b48f5f7441809dcc421c6a836c4f5d Mon Sep 17 00:00:00 2001 From: Luigi Dello Stritto Date: Thu, 30 May 2024 15:12:54 +0200 Subject: [PATCH 03/14] fix clang --- .../TableProducer/candidateCreator3Prong.cxx | 4 +- PWGHF/Utils/utilsEvSelHf.h | 46 +++++++++---------- 2 files changed, 25 insertions(+), 25 deletions(-) diff --git a/PWGHF/TableProducer/candidateCreator3Prong.cxx b/PWGHF/TableProducer/candidateCreator3Prong.cxx index 4b030bf712f..417e7c82b49 100644 --- a/PWGHF/TableProducer/candidateCreator3Prong.cxx +++ b/PWGHF/TableProducer/candidateCreator3Prong.cxx @@ -625,8 +625,8 @@ struct HfCandidateCreator3ProngExpressions { const auto McParticleRejectionMask = hfEvSelMc.getHfMcCollisionRejectionMask(mcCollision); if (McParticleRejectionMask != 0) { /// at least one event selection not satisfied --> reject the gen particle - rowMcMatchGen(flag, origin, channel); - continue; + rowMcMatchGen(flag, origin, channel); + continue; } // D± → π± K∓ π± diff --git a/PWGHF/Utils/utilsEvSelHf.h b/PWGHF/Utils/utilsEvSelHf.h index 3324e23aac1..68dd2cbb36f 100644 --- a/PWGHF/Utils/utilsEvSelHf.h +++ b/PWGHF/Utils/utilsEvSelHf.h @@ -212,33 +212,33 @@ struct HfEventSelectionMc { float zPvPosMin{-1000.f}; // Minimum PV posZ (cm) float zPvPosMax{1000.f}; // Maximum PV posZ (cm) -/// \brief Function to apply event selections in HF analyses -/// \param mcCollision is the analysed mc collision -/// \return a bitmask with the event selections not satisfied by the analysed collision -template -uint16_t getHfMcCollisionRejectionMask(TMcColl const& mcCollision) -{ + /// \brief Function to apply event selections in HF analyses + /// \param mcCollision is the analysed mc collision + /// \return a bitmask with the event selections not satisfied by the analysed collision + template + uint16_t getHfMcCollisionRejectionMask(TMcColl const& mcCollision) + { - uint8_t rejectionMask{0}; + uint8_t rejectionMask{0}; - float zPv = mcCollision.posZ(); - auto bc = mcCollision.template bc_as(); + float zPv = mcCollision.posZ(); + auto bc = mcCollision.template bc_as(); - /// ITS RO frame border cut - if (useSel8Trigger && !bc.selection_bit(o2::aod::evsel::kNoITSROFrameBorder)) { - SETBIT(rejectionMask, McCollisionRejection::ITSROFrameBorderCut); - } - /// time frame border cut - if (useTimeFrameBorderCut && !bc.selection_bit(o2::aod::evsel::kNoTimeFrameBorder)) { - SETBIT(rejectionMask, McCollisionRejection::TimeFrameBorderCut); - } - /// primary vertex z - if (zPv < zPvPosMin || zPv > zPvPosMax) { - SETBIT(rejectionMask, McCollisionRejection::PositionZ); - } + /// ITS RO frame border cut + if (useSel8Trigger && !bc.selection_bit(o2::aod::evsel::kNoITSROFrameBorder)) { + SETBIT(rejectionMask, McCollisionRejection::ITSROFrameBorderCut); + } + /// time frame border cut + if (useTimeFrameBorderCut && !bc.selection_bit(o2::aod::evsel::kNoTimeFrameBorder)) { + SETBIT(rejectionMask, McCollisionRejection::TimeFrameBorderCut); + } + /// primary vertex z + if (zPv < zPvPosMin || zPv > zPvPosMax) { + SETBIT(rejectionMask, McCollisionRejection::PositionZ); + } - return rejectionMask; -} + return rejectionMask; + } }; } // namespace o2::hf_evsel_mc From 63ad2df0c8f40eb624748f6be7c3960aca3005a3 Mon Sep 17 00:00:00 2001 From: Luigi Dello Stritto Date: Thu, 30 May 2024 17:23:49 +0200 Subject: [PATCH 04/14] fix --- PWGHF/TableProducer/candidateCreator3Prong.cxx | 8 ++++---- PWGHF/Utils/utilsEvSelHf.h | 10 ++++------ 2 files changed, 8 insertions(+), 10 deletions(-) diff --git a/PWGHF/TableProducer/candidateCreator3Prong.cxx b/PWGHF/TableProducer/candidateCreator3Prong.cxx index 417e7c82b49..fe80f976045 100644 --- a/PWGHF/TableProducer/candidateCreator3Prong.cxx +++ b/PWGHF/TableProducer/candidateCreator3Prong.cxx @@ -479,7 +479,7 @@ struct HfCandidateCreator3ProngExpressions { } else if (option.name.compare("createXic") == 0) { createXic = option.defaultValue.get(); } else if (option.name.compare("hfEvSel.iseSel8Trigger") == 0) { - hfEvSelMc.useSel8Trigger = option.defaultValue.get(); + 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) { @@ -622,12 +622,12 @@ struct HfCandidateCreator3ProngExpressions { auto mcCollision = particle.mcCollision(); - const auto McParticleRejectionMask = hfEvSelMc.getHfMcCollisionRejectionMask(mcCollision); - if (McParticleRejectionMask != 0) { + const auto rejectionMask = hfEvSelMc.getHfMcCollisionRejectionMask(mcCollision); + if (rejectionMask != 0) { /// at least one event selection not satisfied --> reject the gen particle rowMcMatchGen(flag, origin, channel); continue; - } + } // D± → π± K∓ π± if (createDplus) { diff --git a/PWGHF/Utils/utilsEvSelHf.h b/PWGHF/Utils/utilsEvSelHf.h index 68dd2cbb36f..fe41d1e7b36 100644 --- a/PWGHF/Utils/utilsEvSelHf.h +++ b/PWGHF/Utils/utilsEvSelHf.h @@ -207,10 +207,10 @@ enum McCollisionRejection { struct HfEventSelectionMc { // event selection parameters (in chronological order of application) - bool useSel8Trigger{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) + float zPvPosMin{-1000.f}; // Minimum PV posZ (cm) + float zPvPosMax{1000.f}; // Maximum PV posZ (cm) /// \brief Function to apply event selections in HF analyses /// \param mcCollision is the analysed mc collision @@ -218,14 +218,12 @@ struct HfEventSelectionMc { template uint16_t getHfMcCollisionRejectionMask(TMcColl const& mcCollision) { - uint8_t rejectionMask{0}; - float zPv = mcCollision.posZ(); auto bc = mcCollision.template bc_as(); /// ITS RO frame border cut - if (useSel8Trigger && !bc.selection_bit(o2::aod::evsel::kNoITSROFrameBorder)) { + if (useITSROBorderCut && !bc.selection_bit(o2::aod::evsel::kNoITSROFrameBorder)) { SETBIT(rejectionMask, McCollisionRejection::ITSROFrameBorderCut); } /// time frame border cut From f56d4dc3b9747cdfe5e04e71a1c1dd23b802cbf7 Mon Sep 17 00:00:00 2001 From: Luigi Dello Stritto Date: Thu, 30 May 2024 18:27:42 +0200 Subject: [PATCH 05/14] 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)) { From 1c2af0daa3a17eacdc37cb405a9200a2a72dd54d Mon Sep 17 00:00:00 2001 From: Luigi Dello Stritto Date: Fri, 31 May 2024 16:33:00 +0200 Subject: [PATCH 06/14] Splitting sel8 in the reco part --- .../TableProducer/candidateCreator2Prong.cxx | 6 ++- .../TableProducer/candidateCreator3Prong.cxx | 6 ++- .../TableProducer/candidateCreatorCascade.cxx | 6 ++- PWGHF/TableProducer/candidateCreatorDstar.cxx | 6 ++- .../candidateCreatorXic0Omegac0.cxx | 24 ++++++---- PWGHF/Utils/utilsEvSelHf.h | 46 +++++++++++++++---- 6 files changed, 71 insertions(+), 23 deletions(-) diff --git a/PWGHF/TableProducer/candidateCreator2Prong.cxx b/PWGHF/TableProducer/candidateCreator2Prong.cxx index ae67961f010..836e1df7df2 100644 --- a/PWGHF/TableProducer/candidateCreator2Prong.cxx +++ b/PWGHF/TableProducer/candidateCreator2Prong.cxx @@ -665,9 +665,13 @@ struct HfCandidateCreator2ProngExpressions { if (device.name.compare("hf-candidate-creator-2prong") == 0) { for (const auto& option : device.options) { if (option.name.compare("hfEvSel.useSel8Trigger") == 0) { - hfEvSelMc.useItsRoBorderCut = option.defaultValue.get(); + hfEvSelMc.useSel8Trigger = option.defaultValue.get(); + } else if (option.name.compare("hfEvSel.useTvxTrigger") == 0) { + hfEvSelMc.useTvxTrigger = option.defaultValue.get(); } else if (option.name.compare("hfEvSel.useTimeFrameBorderCut") == 0) { hfEvSelMc.useTimeFrameBorderCut = option.defaultValue.get(); + } else if (option.name.compare("hfEvSel.useItsRofBorderCut") == 0) { + hfEvSelMc.useItsRofBorderCut = option.defaultValue.get(); } else if (option.name.compare("hfEvSel.zPvPosMin") == 0) { hfEvSelMc.zPvPosMin = option.defaultValue.get(); } else if (option.name.compare("hfEvSel.zPvPosMax") == 0) { diff --git a/PWGHF/TableProducer/candidateCreator3Prong.cxx b/PWGHF/TableProducer/candidateCreator3Prong.cxx index a26f6b13cd2..2f9e6386a83 100644 --- a/PWGHF/TableProducer/candidateCreator3Prong.cxx +++ b/PWGHF/TableProducer/candidateCreator3Prong.cxx @@ -479,9 +479,13 @@ struct HfCandidateCreator3ProngExpressions { } else if (option.name.compare("createXic") == 0) { createXic = option.defaultValue.get(); } else if (option.name.compare("hfEvSel.useSel8Trigger") == 0) { - hfEvSelMc.useItsRoBorderCut = option.defaultValue.get(); + hfEvSelMc.useSel8Trigger = option.defaultValue.get(); + } else if (option.name.compare("hfEvSel.useTvxTrigger") == 0) { + hfEvSelMc.useTvxTrigger = option.defaultValue.get(); } else if (option.name.compare("hfEvSel.useTimeFrameBorderCut") == 0) { hfEvSelMc.useTimeFrameBorderCut = option.defaultValue.get(); + } else if (option.name.compare("hfEvSel.useItsRofBorderCut") == 0) { + hfEvSelMc.useItsRofBorderCut = option.defaultValue.get(); } else if (option.name.compare("hfEvSel.zPvPosMin") == 0) { hfEvSelMc.zPvPosMin = option.defaultValue.get(); } else if (option.name.compare("hfEvSel.zPvPosMax") == 0) { diff --git a/PWGHF/TableProducer/candidateCreatorCascade.cxx b/PWGHF/TableProducer/candidateCreatorCascade.cxx index e8df43ae473..72492fd2e2f 100644 --- a/PWGHF/TableProducer/candidateCreatorCascade.cxx +++ b/PWGHF/TableProducer/candidateCreatorCascade.cxx @@ -444,9 +444,13 @@ struct HfCandidateCreatorCascadeMc { if (device.name.compare("hf-candidate-creator-cascade") == 0) { for (const auto& option : device.options) { if (option.name.compare("hfEvSel.useSel8Trigger") == 0) { - hfEvSelMc.useItsRoBorderCut = option.defaultValue.get(); + hfEvSelMc.useSel8Trigger = option.defaultValue.get(); + } else if (option.name.compare("hfEvSel.useTvxTrigger") == 0) { + hfEvSelMc.useTvxTrigger = option.defaultValue.get(); } else if (option.name.compare("hfEvSel.useTimeFrameBorderCut") == 0) { hfEvSelMc.useTimeFrameBorderCut = option.defaultValue.get(); + } else if (option.name.compare("hfEvSel.useItsRofBorderCut") == 0) { + hfEvSelMc.useItsRofBorderCut = option.defaultValue.get(); } else if (option.name.compare("hfEvSel.zPvPosMin") == 0) { hfEvSelMc.zPvPosMin = option.defaultValue.get(); } else if (option.name.compare("hfEvSel.zPvPosMax") == 0) { diff --git a/PWGHF/TableProducer/candidateCreatorDstar.cxx b/PWGHF/TableProducer/candidateCreatorDstar.cxx index 68372f0029c..c9817cabb4d 100644 --- a/PWGHF/TableProducer/candidateCreatorDstar.cxx +++ b/PWGHF/TableProducer/candidateCreatorDstar.cxx @@ -516,9 +516,13 @@ struct HfCandidateCreatorDstarExpressions { if (device.name.compare("hf-candidate-creator-dstar") == 0) { for (const auto& option : device.options) { if (option.name.compare("hfEvSel.useSel8Trigger") == 0) { - hfEvSelMc.useItsRoBorderCut = option.defaultValue.get(); + hfEvSelMc.useSel8Trigger = option.defaultValue.get(); + } else if (option.name.compare("hfEvSel.useTvxTrigger") == 0) { + hfEvSelMc.useTvxTrigger = option.defaultValue.get(); } else if (option.name.compare("hfEvSel.useTimeFrameBorderCut") == 0) { hfEvSelMc.useTimeFrameBorderCut = option.defaultValue.get(); + } else if (option.name.compare("hfEvSel.useItsRofBorderCut") == 0) { + hfEvSelMc.useItsRofBorderCut = option.defaultValue.get(); } else if (option.name.compare("hfEvSel.zPvPosMin") == 0) { hfEvSelMc.zPvPosMin = option.defaultValue.get(); } else if (option.name.compare("hfEvSel.zPvPosMax") == 0) { diff --git a/PWGHF/TableProducer/candidateCreatorXic0Omegac0.cxx b/PWGHF/TableProducer/candidateCreatorXic0Omegac0.cxx index 1c443ec1b6d..23c1f99707f 100644 --- a/PWGHF/TableProducer/candidateCreatorXic0Omegac0.cxx +++ b/PWGHF/TableProducer/candidateCreatorXic0Omegac0.cxx @@ -673,9 +673,13 @@ struct HfCandidateCreatorXic0Omegac0Mc { if (device.name.compare("hf-candidate-creator-xic0-omegac0") == 0) { for (const auto& option : device.options) { if (option.name.compare("hfEvSel.useSel8Trigger") == 0) { - hfEvSelMc.useItsRoBorderCut = option.defaultValue.get(); + hfEvSelMc.useSel8Trigger = option.defaultValue.get(); + } else if (option.name.compare("hfEvSel.useTvxTrigger") == 0) { + hfEvSelMc.useTvxTrigger = option.defaultValue.get(); } else if (option.name.compare("hfEvSel.useTimeFrameBorderCut") == 0) { hfEvSelMc.useTimeFrameBorderCut = option.defaultValue.get(); + } else if (option.name.compare("hfEvSel.useItsRofBorderCut") == 0) { + hfEvSelMc.useItsRofBorderCut = option.defaultValue.get(); } else if (option.name.compare("hfEvSel.zPvPosMin") == 0) { hfEvSelMc.zPvPosMin = option.defaultValue.get(); } else if (option.name.compare("hfEvSel.zPvPosMax") == 0) { @@ -894,16 +898,16 @@ struct HfCandidateCreatorXic0Omegac0Mc { 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); - } 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; + 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 eca1bb4e450..d70b9d51b98 100644 --- a/PWGHF/Utils/utilsEvSelHf.h +++ b/PWGHF/Utils/utilsEvSelHf.h @@ -33,7 +33,9 @@ enum EventRejection { None = 0, Centrality, Trigger, + TvxTrigger, TimeFrameBorderCut, + ItsRofBorderCut, IsGoodZvtxFT0vsPV, NoSameBunchPileup, NumTracksInTimeRange, @@ -50,7 +52,9 @@ struct HfEventSelection : o2::framework::ConfigurableGroup { o2::framework::Configurable centralityMax{"centralityMax", 100., "Maximum centrality"}; o2::framework::Configurable useSel8Trigger{"useSel8Trigger", true, "Apply the sel8 event selection"}; o2::framework::Configurable triggerClass{"triggerClass", -1, "Trigger class different from sel8 (e.g. kINT7 for Run2) used only if useSel8Trigger is false"}; + o2::framework::Configurable useTvxTrigger{"useTvxTrigger", true, "Apply TVX trigger sel"}; o2::framework::Configurable useTimeFrameBorderCut{"useTimeFrameBorderCut", true, "Apply TF border cut"}; + o2::framework::Configurable useItsRofBorderCut{"useItsRofBorderCut", true, "Apply ITS ROF border cut"}; o2::framework::Configurable useIsGoodZvtxFT0vsPV{"useIsGoodZvtxFT0vsPV", false, "Check consistency between PVz from central barrel with that from FT0 timing"}; o2::framework::Configurable useNoSameBunchPileup{"useNoSameBunchPileup", false, "Exclude collisions in bunches with more than 1 reco. PV"}; // POTENTIALLY BAD FOR BEAUTY ANALYSES o2::framework::Configurable useNumTracksInTimeRange{"useNumTracksInTimeRange", false, "Apply occupancy selection (num. ITS tracks with at least 5 clusters in +-100us from current collision)"}; @@ -87,7 +91,9 @@ struct HfEventSelection : o2::framework::ConfigurableGroup { hCollisions->GetXaxis()->SetBinLabel(EventRejection::None + 1, "All"); hCollisions->GetXaxis()->SetBinLabel(EventRejection::Centrality + 1, "Centrality"); hCollisions->GetXaxis()->SetBinLabel(EventRejection::Trigger + 1, "Trigger"); + hCollisions->GetXaxis()->SetBinLabel(EventRejection::TvxTrigger + 1, "TVX Trigger"); hCollisions->GetXaxis()->SetBinLabel(EventRejection::TimeFrameBorderCut + 1, "TF border"); + hCollisions->GetXaxis()->SetBinLabel(EventRejection::ItsRofBorderCut + 1, "ITF ROF border"); hCollisions->GetXaxis()->SetBinLabel(EventRejection::IsGoodZvtxFT0vsPV + 1, "PV #it{z} consistency FT0 timing"); hCollisions->GetXaxis()->SetBinLabel(EventRejection::NoSameBunchPileup + 1, "No same-bunch pile-up"); // POTENTIALLY BAD FOR BEAUTY ANALYSES hCollisions->GetXaxis()->SetBinLabel(EventRejection::NumTracksInTimeRange + 1, "Occupancy"); @@ -129,10 +135,18 @@ struct HfEventSelection : o2::framework::ConfigurableGroup { if ((useSel8Trigger && !collision.sel8()) || (!useSel8Trigger && triggerClass > -1 && !collision.alias_bit(triggerClass))) { SETBIT(rejectionMask, EventRejection::Trigger); } + /// TVX trigger selection + if (useTvxTrigger && !collision.selection_bit(o2::aod::evsel::kIsTriggerTVX)) { + SETBIT(rejectionMask, EventRejection::TvxTrigger); + } /// time frame border cut if (useTimeFrameBorderCut && !collision.selection_bit(o2::aod::evsel::kNoTimeFrameBorder)) { SETBIT(rejectionMask, EventRejection::TimeFrameBorderCut); } + /// ITS rof border cut + if (useItsRofBorderCut && !collision.selection_bit(o2::aod::evsel::kNoITSROFrameBorder)) { + SETBIT(rejectionMask, EventRejection::ItsRofBorderCut); + } /// PVz consistency tracking - FT0 timing if (useIsGoodZvtxFT0vsPV && !collision.selection_bit(o2::aod::evsel::kIsGoodZvtxFT0vsPV)) { SETBIT(rejectionMask, EventRejection::IsGoodZvtxFT0vsPV); @@ -196,9 +210,11 @@ struct HfEventSelection : o2::framework::ConfigurableGroup { namespace o2::hf_evsel_mc { -// generated particles rejection types +// MC collision rejection types enum McCollisionRejection { None = 0, + Trigger, + TvxTrigger, TimeFrameBorderCut, ItsRoFrameBorderCut, PositionZ, @@ -207,29 +223,41 @@ enum McCollisionRejection { struct HfEventSelectionMc { // event selection parameters (in chronological order of application) - bool useItsRoBorderCut{false}; // Apply the ITS RO frame border cut + bool useSel8Trigger{false}; // Apply the Sel8 selection + bool useTvxTrigger{false}; // Apply the TVX trigger bool useTimeFrameBorderCut{true}; // Apply TF border cut + bool useItsRofBorderCut{false}; // Apply the ITS RO frame border cut float zPvPosMin{-1000.f}; // Minimum PV posZ (cm) float zPvPosMax{1000.f}; // Maximum PV posZ (cm) - /// \brief Function to apply event selections in HF analyses - /// \param mcCollision is the analysed mc collision + /// \brief Function to apply event selections to generated MC collisions + /// \param mcCollision MC collision to test against the selection criteria /// \return a bitmask with the event selections not satisfied by the analysed collision template - uint16_t getHfMcCollisionRejectionMask(TMcColl const& mcCollision) + uint8_t getHfMcCollisionRejectionMask(TMcColl const& mcCollision) { - uint8_t rejectionMask{0}; + uint16_t rejectionMask{0}; float zPv = mcCollision.posZ(); auto bc = mcCollision.template bc_as(); - /// ITS RO frame border cut - if (useItsRoBorderCut && !bc.selection_bit(o2::aod::evsel::kNoITSROFrameBorder)) { - SETBIT(rejectionMask, McCollisionRejection::ItsRoFrameBorderCut); + /// TVX trigger selection + if (useSel8Trigger && (!bc.selection_bit(o2::aod::evsel::kIsTriggerTVX) + || !bc.selection_bit(o2::aod::evsel::kNoTimeFrameBorder) + || !bc.selection_bit(o2::aod::evsel::kNoITSROFrameBorder))) { + SETBIT(rejectionMask, McCollisionRejection::Trigger); + } + /// TVX trigger selection + if (useTvxTrigger && !bc.selection_bit(o2::aod::evsel::kIsTriggerTVX)) { + SETBIT(rejectionMask, McCollisionRejection::TvxTrigger); } /// time frame border cut if (useTimeFrameBorderCut && !bc.selection_bit(o2::aod::evsel::kNoTimeFrameBorder)) { SETBIT(rejectionMask, McCollisionRejection::TimeFrameBorderCut); } + /// ITS RO frame border cut + if (useItsRofBorderCut && !bc.selection_bit(o2::aod::evsel::kNoITSROFrameBorder)) { + SETBIT(rejectionMask, McCollisionRejection::ItsRoFrameBorderCut); + } /// primary vertex z if (zPv < zPvPosMin || zPv > zPvPosMax) { SETBIT(rejectionMask, McCollisionRejection::PositionZ); From c3cd7f07c33a1e7e893871edd219df13e3310b11 Mon Sep 17 00:00:00 2001 From: Luigi Dello Stritto Date: Mon, 3 Jun 2024 15:18:11 +0200 Subject: [PATCH 07/14] Add monitoring --- .../TableProducer/candidateCreator2Prong.cxx | 22 +--- .../TableProducer/candidateCreator3Prong.cxx | 20 +-- .../TableProducer/candidateCreatorCascade.cxx | 22 +--- PWGHF/TableProducer/candidateCreatorDstar.cxx | 22 +--- .../candidateCreatorXic0Omegac0.cxx | 22 +--- PWGHF/Utils/utilsEvSelHf.h | 116 ++++++++++++------ 6 files changed, 104 insertions(+), 120 deletions(-) diff --git a/PWGHF/TableProducer/candidateCreator2Prong.cxx b/PWGHF/TableProducer/candidateCreator2Prong.cxx index 836e1df7df2..46bc675a9a4 100644 --- a/PWGHF/TableProducer/candidateCreator2Prong.cxx +++ b/PWGHF/TableProducer/candidateCreator2Prong.cxx @@ -48,7 +48,6 @@ 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; @@ -654,7 +653,8 @@ struct HfCandidateCreator2ProngExpressions { Produces rowMcMatchRec; Produces rowMcMatchGen; - HfEventSelectionMc hfEvSelMc; // mc event selection + HfEventSelectionMc hfEvSelMc; // mc event selection and monitoring + HistogramRegistry registry{"registry"}; using BCsInfo = soa::Join; // inspect for which zPvPosMax cut was set for reconstructed @@ -663,24 +663,11 @@ struct HfCandidateCreator2ProngExpressions { const auto& workflows = initContext.services().get(); 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.useSel8Trigger") == 0) { - hfEvSelMc.useSel8Trigger = option.defaultValue.get(); - } else if (option.name.compare("hfEvSel.useTvxTrigger") == 0) { - hfEvSelMc.useTvxTrigger = option.defaultValue.get(); - } else if (option.name.compare("hfEvSel.useTimeFrameBorderCut") == 0) { - hfEvSelMc.useTimeFrameBorderCut = option.defaultValue.get(); - } else if (option.name.compare("hfEvSel.useItsRofBorderCut") == 0) { - hfEvSelMc.useItsRofBorderCut = 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(); - } - } + hfEvSelMc.configureFromDevice(device); break; } } + hfEvSelMc.addHistograms(registry); // particles monitoring } /// Performs MC matching. @@ -742,6 +729,7 @@ struct HfCandidateCreator2ProngExpressions { auto mcCollision = particle.mcCollision(); const auto rejectionMask = hfEvSelMc.getHfMcCollisionRejectionMask(mcCollision); + hfEvSelMc.fillHistograms(rejectionMask); if (rejectionMask != 0) { /// at least one event selection not satisfied --> reject the gen particle rowMcMatchGen(flag, origin); diff --git a/PWGHF/TableProducer/candidateCreator3Prong.cxx b/PWGHF/TableProducer/candidateCreator3Prong.cxx index 2f9e6386a83..4fb777d9183 100644 --- a/PWGHF/TableProducer/candidateCreator3Prong.cxx +++ b/PWGHF/TableProducer/candidateCreator3Prong.cxx @@ -36,7 +36,6 @@ 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_3prong; using namespace o2::hf_centrality; @@ -454,12 +453,13 @@ struct HfCandidateCreator3ProngExpressions { Produces rowMcMatchRec; Produces rowMcMatchGen; - HfEventSelectionMc hfEvSelMc; // mc event selection bool createDplus{false}; bool createDs{false}; bool createLc{false}; bool createXic{false}; + HfEventSelectionMc hfEvSelMc; // mc event selection and monitoring + HistogramRegistry registry{"registry"}; using BCsInfo = soa::Join; void init(InitContext& initContext) @@ -469,6 +469,7 @@ struct HfCandidateCreator3ProngExpressions { const auto& workflows = initContext.services().get(); for (const DeviceSpec& device : workflows.devices) { if (device.name.compare("hf-candidate-creator-3prong") == 0) { + hfEvSelMc.configureFromDevice(device); for (const auto& option : device.options) { if (option.name.compare("createDplus") == 0) { createDplus = option.defaultValue.get(); @@ -478,24 +479,14 @@ struct HfCandidateCreator3ProngExpressions { createLc = option.defaultValue.get(); } else if (option.name.compare("createXic") == 0) { createXic = option.defaultValue.get(); - } else if (option.name.compare("hfEvSel.useSel8Trigger") == 0) { - hfEvSelMc.useSel8Trigger = option.defaultValue.get(); - } else if (option.name.compare("hfEvSel.useTvxTrigger") == 0) { - hfEvSelMc.useTvxTrigger = option.defaultValue.get(); - } else if (option.name.compare("hfEvSel.useTimeFrameBorderCut") == 0) { - hfEvSelMc.useTimeFrameBorderCut = option.defaultValue.get(); - } else if (option.name.compare("hfEvSel.useItsRofBorderCut") == 0) { - hfEvSelMc.useItsRofBorderCut = 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; } } + hfEvSelMc.addHistograms(registry); // particles monitoring + LOGP(info, "Flags for candidate creation from the reco workflow:"); LOGP(info, " --> createDplus = {}", createDplus); LOGP(info, " --> createDs = {}", createDs); @@ -627,6 +618,7 @@ struct HfCandidateCreator3ProngExpressions { auto mcCollision = particle.mcCollision(); const auto rejectionMask = hfEvSelMc.getHfMcCollisionRejectionMask(mcCollision); + hfEvSelMc.fillHistograms(rejectionMask); if (rejectionMask != 0) { /// at least one event selection not satisfied --> reject the gen particle rowMcMatchGen(flag, origin, channel); diff --git a/PWGHF/TableProducer/candidateCreatorCascade.cxx b/PWGHF/TableProducer/candidateCreatorCascade.cxx index 72492fd2e2f..83b0e2ac442 100644 --- a/PWGHF/TableProducer/candidateCreatorCascade.cxx +++ b/PWGHF/TableProducer/candidateCreatorCascade.cxx @@ -37,7 +37,6 @@ 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; @@ -432,7 +431,8 @@ struct HfCandidateCreatorCascadeMc { Produces rowMcMatchRec; Produces rowMcMatchGen; - HfEventSelectionMc hfEvSelMc; // mc event selection + HfEventSelectionMc hfEvSelMc; // mc event selection and monitoring + HistogramRegistry registry{"registry"}; using MyTracksWMc = soa::Join; using BCsInfo = soa::Join; @@ -442,24 +442,11 @@ struct HfCandidateCreatorCascadeMc { const auto& workflows = initContext.services().get(); 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.useSel8Trigger") == 0) { - hfEvSelMc.useSel8Trigger = option.defaultValue.get(); - } else if (option.name.compare("hfEvSel.useTvxTrigger") == 0) { - hfEvSelMc.useTvxTrigger = option.defaultValue.get(); - } else if (option.name.compare("hfEvSel.useTimeFrameBorderCut") == 0) { - hfEvSelMc.useTimeFrameBorderCut = option.defaultValue.get(); - } else if (option.name.compare("hfEvSel.useItsRofBorderCut") == 0) { - hfEvSelMc.useItsRofBorderCut = 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(); - } - } + hfEvSelMc.configureFromDevice(device); break; } } + hfEvSelMc.addHistograms(registry); // particles monitoring } void processMc(MyTracksWMc const& tracks, @@ -515,6 +502,7 @@ struct HfCandidateCreatorCascadeMc { auto mcCollision = particle.mcCollision(); const auto rejectionMask = hfEvSelMc.getHfMcCollisionRejectionMask(mcCollision); + hfEvSelMc.fillHistograms(rejectionMask); if (rejectionMask != 0) { /// at least one event selection not satisfied --> reject the gen particle rowMcMatchGen(sign, origin); diff --git a/PWGHF/TableProducer/candidateCreatorDstar.cxx b/PWGHF/TableProducer/candidateCreatorDstar.cxx index c9817cabb4d..46c330899db 100644 --- a/PWGHF/TableProducer/candidateCreatorDstar.cxx +++ b/PWGHF/TableProducer/candidateCreatorDstar.cxx @@ -36,7 +36,6 @@ 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; @@ -505,7 +504,8 @@ struct HfCandidateCreatorDstarExpressions { Produces rowsMcMatchRecDstar; Produces rowsMcMatchGenDstar; - HfEventSelectionMc hfEvSelMc; // mc event selection + HfEventSelectionMc hfEvSelMc; // mc event selection and monitoring + HistogramRegistry registry{"registry"}; using BCsInfo = soa::Join; // inspect for which zPvPosMax cut was set for reconstructed @@ -514,24 +514,11 @@ struct HfCandidateCreatorDstarExpressions { const auto& workflows = initContext.services().get(); 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.useSel8Trigger") == 0) { - hfEvSelMc.useSel8Trigger = option.defaultValue.get(); - } else if (option.name.compare("hfEvSel.useTvxTrigger") == 0) { - hfEvSelMc.useTvxTrigger = option.defaultValue.get(); - } else if (option.name.compare("hfEvSel.useTimeFrameBorderCut") == 0) { - hfEvSelMc.useTimeFrameBorderCut = option.defaultValue.get(); - } else if (option.name.compare("hfEvSel.useItsRofBorderCut") == 0) { - hfEvSelMc.useItsRofBorderCut = 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(); - } - } + hfEvSelMc.configureFromDevice(device); break; } } + hfEvSelMc.addHistograms(registry); // particles monitoring } /// Perform MC Matching. @@ -604,6 +591,7 @@ struct HfCandidateCreatorDstarExpressions { auto mcCollision = particle.mcCollision(); const auto rejectionMask = hfEvSelMc.getHfMcCollisionRejectionMask(mcCollision); + hfEvSelMc.fillHistograms(rejectionMask); if (rejectionMask != 0) { /// at least one event selection not satisfied --> reject the gen particle rowsMcMatchGenDstar(flagDstar, originDstar, -1); diff --git a/PWGHF/TableProducer/candidateCreatorXic0Omegac0.cxx b/PWGHF/TableProducer/candidateCreatorXic0Omegac0.cxx index 23c1f99707f..038ca916c4f 100644 --- a/PWGHF/TableProducer/candidateCreatorXic0Omegac0.cxx +++ b/PWGHF/TableProducer/candidateCreatorXic0Omegac0.cxx @@ -54,7 +54,6 @@ 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 { @@ -662,7 +661,8 @@ struct HfCandidateCreatorXic0Omegac0Mc { Produces rowMCMatchRecToOmegaK; Produces rowMCMatchGenToOmegaK; - HfEventSelectionMc hfEvSelMc; // mc event selection + HfEventSelectionMc hfEvSelMc; // mc event selection and monitoring + HistogramRegistry registry{"registry"}; using BCsInfo = soa::Join; // inspect for which zPvPosMax cut was set for reconstructed @@ -671,24 +671,11 @@ struct HfCandidateCreatorXic0Omegac0Mc { const auto& workflows = initContext.services().get(); 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.useSel8Trigger") == 0) { - hfEvSelMc.useSel8Trigger = option.defaultValue.get(); - } else if (option.name.compare("hfEvSel.useTvxTrigger") == 0) { - hfEvSelMc.useTvxTrigger = option.defaultValue.get(); - } else if (option.name.compare("hfEvSel.useTimeFrameBorderCut") == 0) { - hfEvSelMc.useTimeFrameBorderCut = option.defaultValue.get(); - } else if (option.name.compare("hfEvSel.useItsRofBorderCut") == 0) { - hfEvSelMc.useItsRofBorderCut = 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(); - } - } + hfEvSelMc.configureFromDevice(device); break; } } + hfEvSelMc.addHistograms(registry); // particles monitoring } template @@ -895,6 +882,7 @@ struct HfCandidateCreatorXic0Omegac0Mc { auto mcCollision = particle.mcCollision(); const auto rejectionMask = hfEvSelMc.getHfMcCollisionRejectionMask(mcCollision); + hfEvSelMc.fillHistograms(rejectionMask); if (rejectionMask != 0) { /// at least one event selection not satisfied --> reject the gen particle if constexpr (decayChannel == aod::hf_cand_xic0_omegac0::DecayType::XiczeroToXiPi) { diff --git a/PWGHF/Utils/utilsEvSelHf.h b/PWGHF/Utils/utilsEvSelHf.h index d70b9d51b98..2f572e07ed2 100644 --- a/PWGHF/Utils/utilsEvSelHf.h +++ b/PWGHF/Utils/utilsEvSelHf.h @@ -13,6 +13,7 @@ /// \brief Event selection utilities for HF analyses /// \author Mattia Faggin , CERN /// \author Vít Kučera , Inha University +/// \author Luigi Dello Stritto , CERN #ifndef PWGHF_UTILS_UTILSEVSELHF_H_ #define PWGHF_UTILS_UTILSEVSELHF_H_ @@ -45,6 +46,27 @@ enum EventRejection { NEventRejection }; +o2::framework::AxisSpec axisEvents = {EventRejection::NEventRejection, -0.5f, +EventRejection::NEventRejection - 0.5f, ""}; + +/// \brief Function to put labels on monitoring histogram +/// \param hRejection monitoring histogram +template +void setEventRejectionLabels(Histo& hRejection) { + // Puts labels on the collision monitoring histogram. + hRejection->GetXaxis()->SetBinLabel(EventRejection::None + 1, "All"); + hRejection->GetXaxis()->SetBinLabel(EventRejection::Centrality + 1, "Centrality"); + hRejection->GetXaxis()->SetBinLabel(EventRejection::Trigger + 1, "Trigger"); + hRejection->GetXaxis()->SetBinLabel(EventRejection::TvxTrigger + 1, "TVX Trigger"); + hRejection->GetXaxis()->SetBinLabel(EventRejection::TimeFrameBorderCut + 1, "TF border"); + hRejection->GetXaxis()->SetBinLabel(EventRejection::ItsRofBorderCut + 1, "ITF ROF border"); + hRejection->GetXaxis()->SetBinLabel(EventRejection::IsGoodZvtxFT0vsPV + 1, "PV #it{z} consistency FT0 timing"); + hRejection->GetXaxis()->SetBinLabel(EventRejection::NoSameBunchPileup + 1, "No same-bunch pile-up"); // POTENTIALLY BAD FOR BEAUTY ANALYSES + hRejection->GetXaxis()->SetBinLabel(EventRejection::NumTracksInTimeRange + 1, "Occupancy"); + hRejection->GetXaxis()->SetBinLabel(EventRejection::NContrib + 1, "# of PV contributors"); + hRejection->GetXaxis()->SetBinLabel(EventRejection::Chi2 + 1, "PV #it{#chi}^{2}"); + hRejection->GetXaxis()->SetBinLabel(EventRejection::PositionZ + 1, "PV #it{z}"); +} + struct HfEventSelection : o2::framework::ConfigurableGroup { std::string prefix = "hfEvSel"; // JSON group name // event selection parameters (in chronological order of application) @@ -79,27 +101,14 @@ struct HfEventSelection : o2::framework::ConfigurableGroup { /// \param registry reference to the histogram registry void addHistograms(o2::framework::HistogramRegistry& registry) { - o2::framework::AxisSpec axisEvents = {EventRejection::NEventRejection, -0.5f, +EventRejection::NEventRejection - 0.5f, ""}; hCollisions = registry.add(nameHistCollisions, "HF event counter;;entries", {o2::framework::HistType::kTH1D, {axisEvents}}); hPosZBeforeEvSel = registry.add(nameHistPosZBeforeEvSel, "all events;#it{z}_{prim. vtx.} (cm);entries", {o2::framework::HistType::kTH1D, {{400, -20., 20.}}}); hPosZAfterEvSel = registry.add(nameHistPosZAfterEvSel, "selected events;#it{z}_{prim. vtx.} (cm);entries", {o2::framework::HistType::kTH1D, {{400, -20., 20.}}}); hPosXAfterEvSel = registry.add(nameHistPosXAfterEvSel, "selected events;#it{x}_{prim. vtx.} (cm);entries", {o2::framework::HistType::kTH1D, {{200, -0.5, 0.5}}}); hPosYAfterEvSel = registry.add(nameHistPosYAfterEvSel, "selected events;#it{y}_{prim. vtx.} (cm);entries", {o2::framework::HistType::kTH1D, {{200, -0.5, 0.5}}}); hNumPvContributorsAfterSel = registry.add(nameHistNumPvContributorsAfterSel, "selected events;#it{y}_{prim. vtx.} (cm);entries", {o2::framework::HistType::kTH1D, {{500, -0.5, 499.5}}}); - // Puts labels on the collision monitoring histogram. hCollisions->SetTitle("HF event counter;;# of accepted collisions"); - hCollisions->GetXaxis()->SetBinLabel(EventRejection::None + 1, "All"); - hCollisions->GetXaxis()->SetBinLabel(EventRejection::Centrality + 1, "Centrality"); - hCollisions->GetXaxis()->SetBinLabel(EventRejection::Trigger + 1, "Trigger"); - hCollisions->GetXaxis()->SetBinLabel(EventRejection::TvxTrigger + 1, "TVX Trigger"); - hCollisions->GetXaxis()->SetBinLabel(EventRejection::TimeFrameBorderCut + 1, "TF border"); - hCollisions->GetXaxis()->SetBinLabel(EventRejection::ItsRofBorderCut + 1, "ITF ROF border"); - hCollisions->GetXaxis()->SetBinLabel(EventRejection::IsGoodZvtxFT0vsPV + 1, "PV #it{z} consistency FT0 timing"); - hCollisions->GetXaxis()->SetBinLabel(EventRejection::NoSameBunchPileup + 1, "No same-bunch pile-up"); // POTENTIALLY BAD FOR BEAUTY ANALYSES - hCollisions->GetXaxis()->SetBinLabel(EventRejection::NumTracksInTimeRange + 1, "Occupancy"); - hCollisions->GetXaxis()->SetBinLabel(EventRejection::NContrib + 1, "# of PV contributors"); - hCollisions->GetXaxis()->SetBinLabel(EventRejection::Chi2 + 1, "PV #it{#chi}^{2}"); - hCollisions->GetXaxis()->SetBinLabel(EventRejection::PositionZ + 1, "PV #it{z}"); + setEventRejectionLabels(hCollisions); } /// \brief Applies event selection. @@ -206,20 +215,6 @@ struct HfEventSelection : o2::framework::ConfigurableGroup { hNumPvContributorsAfterSel->Fill(collision.numContrib()); } }; -} // namespace o2::hf_evsel - -namespace o2::hf_evsel_mc -{ -// MC collision rejection types -enum McCollisionRejection { - None = 0, - Trigger, - TvxTrigger, - TimeFrameBorderCut, - ItsRoFrameBorderCut, - PositionZ, - NMcCollisionRejection -}; struct HfEventSelectionMc { // event selection parameters (in chronological order of application) @@ -230,42 +225,87 @@ struct HfEventSelectionMc { float zPvPosMin{-1000.f}; // Minimum PV posZ (cm) float zPvPosMax{1000.f}; // Maximum PV posZ (cm) + // histogram names + static constexpr char nameHistParticles[] = "hParticles"; + std::shared_ptr hParticles; + + /// \brief Adds collision monitoring histograms in the histogram registry. + /// \param registry reference to the histogram registry + void addHistograms(o2::framework::HistogramRegistry& registry) + { + hParticles = registry.add(nameHistParticles, "HF particle counter;;entries", {o2::framework::HistType::kTH1D, {axisEvents}}); + // Puts labels on the collision monitoring histogram. + hParticles->SetTitle("HF particle counter;;# of accepted particles"); + setEventRejectionLabels(hParticles); + } + + void configureFromDevice(const o2::framework::DeviceSpec& device) + { + for (const auto& option : device.options) { + if (option.name.compare("hfEvSel.useSel8Trigger") == 0) { + useSel8Trigger = option.defaultValue.get(); + } else if (option.name.compare("hfEvSel.useTvxTrigger") == 0) { + useTvxTrigger = option.defaultValue.get(); + } else if (option.name.compare("hfEvSel.useTimeFrameBorderCut") == 0) { + useTimeFrameBorderCut = option.defaultValue.get(); + } else if (option.name.compare("hfEvSel.useItsRofBorderCut") == 0) { + useItsRofBorderCut = option.defaultValue.get(); + } else if (option.name.compare("hfEvSel.zPvPosMin") == 0) { + zPvPosMin = option.defaultValue.get(); + } else if (option.name.compare("hfEvSel.zPvPosMax") == 0) { + zPvPosMax = option.defaultValue.get(); + } + } + } + /// \brief Function to apply event selections to generated MC collisions /// \param mcCollision MC collision to test against the selection criteria /// \return a bitmask with the event selections not satisfied by the analysed collision template - uint8_t getHfMcCollisionRejectionMask(TMcColl const& mcCollision) + uint16_t getHfMcCollisionRejectionMask(TMcColl const& mcCollision) { uint16_t rejectionMask{0}; float zPv = mcCollision.posZ(); auto bc = mcCollision.template bc_as(); /// TVX trigger selection - if (useSel8Trigger && (!bc.selection_bit(o2::aod::evsel::kIsTriggerTVX) - || !bc.selection_bit(o2::aod::evsel::kNoTimeFrameBorder) - || !bc.selection_bit(o2::aod::evsel::kNoITSROFrameBorder))) { - SETBIT(rejectionMask, McCollisionRejection::Trigger); + if (useSel8Trigger && (!bc.selection_bit(o2::aod::evsel::kIsTriggerTVX) || !bc.selection_bit(o2::aod::evsel::kNoTimeFrameBorder) || !bc.selection_bit(o2::aod::evsel::kNoITSROFrameBorder))) { + SETBIT(rejectionMask, EventRejection::Trigger); } /// TVX trigger selection if (useTvxTrigger && !bc.selection_bit(o2::aod::evsel::kIsTriggerTVX)) { - SETBIT(rejectionMask, McCollisionRejection::TvxTrigger); + SETBIT(rejectionMask, EventRejection::TvxTrigger); } /// time frame border cut if (useTimeFrameBorderCut && !bc.selection_bit(o2::aod::evsel::kNoTimeFrameBorder)) { - SETBIT(rejectionMask, McCollisionRejection::TimeFrameBorderCut); + SETBIT(rejectionMask, EventRejection::TimeFrameBorderCut); } /// ITS RO frame border cut if (useItsRofBorderCut && !bc.selection_bit(o2::aod::evsel::kNoITSROFrameBorder)) { - SETBIT(rejectionMask, McCollisionRejection::ItsRoFrameBorderCut); + SETBIT(rejectionMask, EventRejection::ItsRofBorderCut); } /// primary vertex z if (zPv < zPvPosMin || zPv > zPvPosMax) { - SETBIT(rejectionMask, McCollisionRejection::PositionZ); + SETBIT(rejectionMask, EventRejection::PositionZ); } return rejectionMask; } + + /// \brief Fills histograms for monitoring event selections satisfied by the collision. + /// \param rejectionMask bitmask storing the info about which ev. selections are not satisfied by the collision + void fillHistograms(const uint16_t rejectionMask) + { + hParticles->Fill(EventRejection::None); + + for (size_t reason = 1; reason < EventRejection::NEventRejection; reason++) { + if (TESTBIT(rejectionMask, reason)) { + return; + } + hParticles->Fill(reason); + } + } }; -} // namespace o2::hf_evsel_mc +} // namespace o2::hf_evsel #endif // PWGHF_UTILS_UTILSEVSELHF_H_ From 25c84ed2f85af538912d1ebe81ac0ba889f2b780 Mon Sep 17 00:00:00 2001 From: Luigi Dello Stritto Date: Mon, 3 Jun 2024 15:40:59 +0200 Subject: [PATCH 08/14] fix --- PWGHF/TableProducer/candidateCreator2Prong.cxx | 2 +- PWGHF/TableProducer/candidateCreator3Prong.cxx | 2 +- PWGHF/TableProducer/candidateCreatorCascade.cxx | 2 +- PWGHF/TableProducer/candidateCreatorDstar.cxx | 2 +- PWGHF/TableProducer/candidateCreatorXic0Omegac0.cxx | 2 +- PWGHF/Utils/utilsEvSelHf.h | 3 ++- 6 files changed, 7 insertions(+), 6 deletions(-) diff --git a/PWGHF/TableProducer/candidateCreator2Prong.cxx b/PWGHF/TableProducer/candidateCreator2Prong.cxx index 46bc675a9a4..7498a0ce438 100644 --- a/PWGHF/TableProducer/candidateCreator2Prong.cxx +++ b/PWGHF/TableProducer/candidateCreator2Prong.cxx @@ -654,8 +654,8 @@ struct HfCandidateCreator2ProngExpressions { Produces rowMcMatchGen; HfEventSelectionMc hfEvSelMc; // mc event selection and monitoring - HistogramRegistry registry{"registry"}; using BCsInfo = soa::Join; + HistogramRegistry registry{"registry"}; // inspect for which zPvPosMax cut was set for reconstructed void init(InitContext& initContext) diff --git a/PWGHF/TableProducer/candidateCreator3Prong.cxx b/PWGHF/TableProducer/candidateCreator3Prong.cxx index 4fb777d9183..41013d3389e 100644 --- a/PWGHF/TableProducer/candidateCreator3Prong.cxx +++ b/PWGHF/TableProducer/candidateCreator3Prong.cxx @@ -459,8 +459,8 @@ struct HfCandidateCreator3ProngExpressions { bool createXic{false}; HfEventSelectionMc hfEvSelMc; // mc event selection and monitoring - HistogramRegistry registry{"registry"}; using BCsInfo = soa::Join; + HistogramRegistry registry{"registry"}; void init(InitContext& initContext) { diff --git a/PWGHF/TableProducer/candidateCreatorCascade.cxx b/PWGHF/TableProducer/candidateCreatorCascade.cxx index 83b0e2ac442..591ce9e6826 100644 --- a/PWGHF/TableProducer/candidateCreatorCascade.cxx +++ b/PWGHF/TableProducer/candidateCreatorCascade.cxx @@ -432,9 +432,9 @@ struct HfCandidateCreatorCascadeMc { Produces rowMcMatchGen; HfEventSelectionMc hfEvSelMc; // mc event selection and monitoring - HistogramRegistry registry{"registry"}; using MyTracksWMc = soa::Join; using BCsInfo = soa::Join; + HistogramRegistry registry{"registry"}; // inspect for which zPvPosMax cut was set for reconstructed void init(InitContext& initContext) diff --git a/PWGHF/TableProducer/candidateCreatorDstar.cxx b/PWGHF/TableProducer/candidateCreatorDstar.cxx index 46c330899db..a3db59266f0 100644 --- a/PWGHF/TableProducer/candidateCreatorDstar.cxx +++ b/PWGHF/TableProducer/candidateCreatorDstar.cxx @@ -505,8 +505,8 @@ struct HfCandidateCreatorDstarExpressions { Produces rowsMcMatchGenDstar; HfEventSelectionMc hfEvSelMc; // mc event selection and monitoring - HistogramRegistry registry{"registry"}; using BCsInfo = soa::Join; + HistogramRegistry registry{"registry"}; // inspect for which zPvPosMax cut was set for reconstructed void init(InitContext& initContext) diff --git a/PWGHF/TableProducer/candidateCreatorXic0Omegac0.cxx b/PWGHF/TableProducer/candidateCreatorXic0Omegac0.cxx index 038ca916c4f..f2348a8f5cb 100644 --- a/PWGHF/TableProducer/candidateCreatorXic0Omegac0.cxx +++ b/PWGHF/TableProducer/candidateCreatorXic0Omegac0.cxx @@ -662,8 +662,8 @@ struct HfCandidateCreatorXic0Omegac0Mc { Produces rowMCMatchGenToOmegaK; HfEventSelectionMc hfEvSelMc; // mc event selection and monitoring - HistogramRegistry registry{"registry"}; using BCsInfo = soa::Join; + HistogramRegistry registry{"registry"}; // inspect for which zPvPosMax cut was set for reconstructed void init(InitContext& initContext) diff --git a/PWGHF/Utils/utilsEvSelHf.h b/PWGHF/Utils/utilsEvSelHf.h index 2f572e07ed2..4930b1544fa 100644 --- a/PWGHF/Utils/utilsEvSelHf.h +++ b/PWGHF/Utils/utilsEvSelHf.h @@ -51,7 +51,8 @@ o2::framework::AxisSpec axisEvents = {EventRejection::NEventRejection, -0.5f, +E /// \brief Function to put labels on monitoring histogram /// \param hRejection monitoring histogram template -void setEventRejectionLabels(Histo& hRejection) { +void setEventRejectionLabels(Histo& hRejection) +{ // Puts labels on the collision monitoring histogram. hRejection->GetXaxis()->SetBinLabel(EventRejection::None + 1, "All"); hRejection->GetXaxis()->SetBinLabel(EventRejection::Centrality + 1, "Centrality"); From f7ef1db13e8a2540ab762812c97c358b97f1d6a0 Mon Sep 17 00:00:00 2001 From: Luigi Dello Stritto Date: Mon, 3 Jun 2024 17:27:56 +0200 Subject: [PATCH 09/14] fix --- PWGHF/Utils/utilsEvSelHf.h | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/PWGHF/Utils/utilsEvSelHf.h b/PWGHF/Utils/utilsEvSelHf.h index 4930b1544fa..9cd4dea736c 100644 --- a/PWGHF/Utils/utilsEvSelHf.h +++ b/PWGHF/Utils/utilsEvSelHf.h @@ -59,7 +59,7 @@ void setEventRejectionLabels(Histo& hRejection) hRejection->GetXaxis()->SetBinLabel(EventRejection::Trigger + 1, "Trigger"); hRejection->GetXaxis()->SetBinLabel(EventRejection::TvxTrigger + 1, "TVX Trigger"); hRejection->GetXaxis()->SetBinLabel(EventRejection::TimeFrameBorderCut + 1, "TF border"); - hRejection->GetXaxis()->SetBinLabel(EventRejection::ItsRofBorderCut + 1, "ITF ROF border"); + hRejection->GetXaxis()->SetBinLabel(EventRejection::ItsRofBorderCut + 1, "ITS ROF border"); hRejection->GetXaxis()->SetBinLabel(EventRejection::IsGoodZvtxFT0vsPV + 1, "PV #it{z} consistency FT0 timing"); hRejection->GetXaxis()->SetBinLabel(EventRejection::NoSameBunchPileup + 1, "No same-bunch pile-up"); // POTENTIALLY BAD FOR BEAUTY ANALYSES hRejection->GetXaxis()->SetBinLabel(EventRejection::NumTracksInTimeRange + 1, "Occupancy"); @@ -102,13 +102,12 @@ struct HfEventSelection : o2::framework::ConfigurableGroup { /// \param registry reference to the histogram registry void addHistograms(o2::framework::HistogramRegistry& registry) { - hCollisions = registry.add(nameHistCollisions, "HF event counter;;entries", {o2::framework::HistType::kTH1D, {axisEvents}}); + hCollisions = registry.add(nameHistCollisions, "HF event counter;;# of accepted collisions", {o2::framework::HistType::kTH1D, {axisEvents}}); hPosZBeforeEvSel = registry.add(nameHistPosZBeforeEvSel, "all events;#it{z}_{prim. vtx.} (cm);entries", {o2::framework::HistType::kTH1D, {{400, -20., 20.}}}); hPosZAfterEvSel = registry.add(nameHistPosZAfterEvSel, "selected events;#it{z}_{prim. vtx.} (cm);entries", {o2::framework::HistType::kTH1D, {{400, -20., 20.}}}); hPosXAfterEvSel = registry.add(nameHistPosXAfterEvSel, "selected events;#it{x}_{prim. vtx.} (cm);entries", {o2::framework::HistType::kTH1D, {{200, -0.5, 0.5}}}); hPosYAfterEvSel = registry.add(nameHistPosYAfterEvSel, "selected events;#it{y}_{prim. vtx.} (cm);entries", {o2::framework::HistType::kTH1D, {{200, -0.5, 0.5}}}); hNumPvContributorsAfterSel = registry.add(nameHistNumPvContributorsAfterSel, "selected events;#it{y}_{prim. vtx.} (cm);entries", {o2::framework::HistType::kTH1D, {{500, -0.5, 499.5}}}); - hCollisions->SetTitle("HF event counter;;# of accepted collisions"); setEventRejectionLabels(hCollisions); } @@ -234,9 +233,8 @@ struct HfEventSelectionMc { /// \param registry reference to the histogram registry void addHistograms(o2::framework::HistogramRegistry& registry) { - hParticles = registry.add(nameHistParticles, "HF particle counter;;entries", {o2::framework::HistType::kTH1D, {axisEvents}}); + hParticles = registry.add(nameHistParticles, "HF particle counter;;# of accepted particles", {o2::framework::HistType::kTH1D, {axisEvents}}); // Puts labels on the collision monitoring histogram. - hParticles->SetTitle("HF particle counter;;# of accepted particles"); setEventRejectionLabels(hParticles); } @@ -269,7 +267,7 @@ struct HfEventSelectionMc { float zPv = mcCollision.posZ(); auto bc = mcCollision.template bc_as(); - /// TVX trigger selection + /// Sel8 trigger selection if (useSel8Trigger && (!bc.selection_bit(o2::aod::evsel::kIsTriggerTVX) || !bc.selection_bit(o2::aod::evsel::kNoTimeFrameBorder) || !bc.selection_bit(o2::aod::evsel::kNoITSROFrameBorder))) { SETBIT(rejectionMask, EventRejection::Trigger); } @@ -293,7 +291,7 @@ struct HfEventSelectionMc { return rejectionMask; } - /// \brief Fills histograms for monitoring event selections satisfied by the collision. + /// \brief Fills histogram for monitoring event selections satisfied by the collision. /// \param rejectionMask bitmask storing the info about which ev. selections are not satisfied by the collision void fillHistograms(const uint16_t rejectionMask) { From aec28dfbeed1765f001cda322b889bff0477cc9f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?V=C3=ADt=20Ku=C4=8Dera?= Date: Mon, 3 Jun 2024 17:35:50 +0200 Subject: [PATCH 10/14] Fix type of loop variable --- PWGHF/Utils/utilsEvSelHf.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/PWGHF/Utils/utilsEvSelHf.h b/PWGHF/Utils/utilsEvSelHf.h index 9cd4dea736c..d8eac0f2c71 100644 --- a/PWGHF/Utils/utilsEvSelHf.h +++ b/PWGHF/Utils/utilsEvSelHf.h @@ -202,7 +202,7 @@ struct HfEventSelection : o2::framework::ConfigurableGroup { const float posZ = collision.posZ(); hPosZBeforeEvSel->Fill(posZ); - for (size_t reason = 1; reason < EventRejection::NEventRejection; reason++) { + for (EventRejection reason = 1; reason < EventRejection::NEventRejection; reason++) { if (TESTBIT(rejectionMask, reason)) { return; } @@ -297,7 +297,7 @@ struct HfEventSelectionMc { { hParticles->Fill(EventRejection::None); - for (size_t reason = 1; reason < EventRejection::NEventRejection; reason++) { + for (EventRejection reason = 1; reason < EventRejection::NEventRejection; reason++) { if (TESTBIT(rejectionMask, reason)) { return; } From 4a2b212bb3293c9450157105117186c8e6e2ac89 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?V=C3=ADt=20Ku=C4=8Dera?= Date: Mon, 3 Jun 2024 18:33:22 +0200 Subject: [PATCH 11/14] Revert bad idea --- PWGHF/Utils/utilsEvSelHf.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/PWGHF/Utils/utilsEvSelHf.h b/PWGHF/Utils/utilsEvSelHf.h index d8eac0f2c71..e67fc020f70 100644 --- a/PWGHF/Utils/utilsEvSelHf.h +++ b/PWGHF/Utils/utilsEvSelHf.h @@ -202,7 +202,7 @@ struct HfEventSelection : o2::framework::ConfigurableGroup { const float posZ = collision.posZ(); hPosZBeforeEvSel->Fill(posZ); - for (EventRejection reason = 1; reason < EventRejection::NEventRejection; reason++) { + for (std::size_t reason = 1; reason < EventRejection::NEventRejection; reason++) { if (TESTBIT(rejectionMask, reason)) { return; } @@ -297,7 +297,7 @@ struct HfEventSelectionMc { { hParticles->Fill(EventRejection::None); - for (EventRejection reason = 1; reason < EventRejection::NEventRejection; reason++) { + for (std::size_t reason = 1; reason < EventRejection::NEventRejection; reason++) { if (TESTBIT(rejectionMask, reason)) { return; } From 17ceef17f56277757a2e1dadb96672e44e747b66 Mon Sep 17 00:00:00 2001 From: ldellost <47105254+DelloStritto@users.noreply.github.com> Date: Wed, 5 Jun 2024 09:49:54 +0200 Subject: [PATCH 12/14] Update PWGHF/TableProducer/candidateCreator2Prong.cxx Co-authored-by: Fabio Catalano --- PWGHF/TableProducer/candidateCreator2Prong.cxx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/PWGHF/TableProducer/candidateCreator2Prong.cxx b/PWGHF/TableProducer/candidateCreator2Prong.cxx index a1b5614d46c..6eb1299c08a 100644 --- a/PWGHF/TableProducer/candidateCreator2Prong.cxx +++ b/PWGHF/TableProducer/candidateCreator2Prong.cxx @@ -738,7 +738,7 @@ struct HfCandidateCreator2ProngExpressions { hfEvSelMc.fillHistograms(rejectionMask); if (rejectionMask != 0) { /// at least one event selection not satisfied --> reject the gen particle - rowMcMatchGen(flag, origin); + rowMcMatchGen(flag, origin, -1); continue; } From bb0da6092a7325edcc956658f7fbc512c6213781 Mon Sep 17 00:00:00 2001 From: ldellost <47105254+DelloStritto@users.noreply.github.com> Date: Wed, 5 Jun 2024 09:50:03 +0200 Subject: [PATCH 13/14] Update PWGHF/TableProducer/candidateCreatorCascade.cxx Co-authored-by: Fabio Catalano --- PWGHF/TableProducer/candidateCreatorCascade.cxx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/PWGHF/TableProducer/candidateCreatorCascade.cxx b/PWGHF/TableProducer/candidateCreatorCascade.cxx index b9428038fbb..2e77a64af2d 100644 --- a/PWGHF/TableProducer/candidateCreatorCascade.cxx +++ b/PWGHF/TableProducer/candidateCreatorCascade.cxx @@ -505,7 +505,7 @@ struct HfCandidateCreatorCascadeMc { hfEvSelMc.fillHistograms(rejectionMask); if (rejectionMask != 0) { /// at least one event selection not satisfied --> reject the gen particle - rowMcMatchGen(sign, origin); + rowMcMatchGen(sign, origin, -1); continue; } From 5fba8e4c57ea176c4055317dfcadb5f90b597d6d Mon Sep 17 00:00:00 2001 From: ldellost <47105254+DelloStritto@users.noreply.github.com> Date: Wed, 5 Jun 2024 09:50:13 +0200 Subject: [PATCH 14/14] Update PWGHF/TableProducer/candidateCreator3Prong.cxx Co-authored-by: Fabio Catalano --- PWGHF/TableProducer/candidateCreator3Prong.cxx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/PWGHF/TableProducer/candidateCreator3Prong.cxx b/PWGHF/TableProducer/candidateCreator3Prong.cxx index 89403eac458..7ec7261766f 100644 --- a/PWGHF/TableProducer/candidateCreator3Prong.cxx +++ b/PWGHF/TableProducer/candidateCreator3Prong.cxx @@ -627,7 +627,7 @@ struct HfCandidateCreator3ProngExpressions { hfEvSelMc.fillHistograms(rejectionMask); if (rejectionMask != 0) { /// at least one event selection not satisfied --> reject the gen particle - rowMcMatchGen(flag, origin, channel); + rowMcMatchGen(flag, origin, channel, -1); continue; }