Skip to content
3 changes: 3 additions & 0 deletions PWGHF/D2H/TableProducer/dataCreatorCharmHadPiReduced.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -291,6 +291,9 @@ struct HfDataCreatorCharmHadPiReduced {
setLabelHistoCands(hCandidatesD0);
setLabelHistoCands(hCandidatesDPlus);
setLabelHistoCands(hCandidatesDs);

// init HF event selection helper
hfEvSel.init(registry);
}

/// Pion selection (D Pi <-- B0)
Expand Down
3 changes: 3 additions & 0 deletions PWGHF/D2H/TableProducer/dataCreatorCharmResoReduced.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -302,6 +302,9 @@ struct HfDataCreatorCharmResoReduced {
fitter.setMaxChi2(1e9);
fitter.setUseAbsDCA(true);
fitter.setWeightedFinalPCA(false);

// init HF event selection helper
hfEvSel.init(registry);
}

/// Basic track quality selections for V0 daughters
Expand Down
8 changes: 5 additions & 3 deletions PWGHF/TableProducer/candidateCreator2Prong.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,9 @@ struct HfCandidateCreator2Prong {
registry.add("hDcaZProngs", "DCAz of 2-prong candidate daughters;#it{p}_{T} (GeV/#it{c};#it{d}_{z}) (#mum);entries", {HistType::kTH2F, {{100, 0., 20.}, {200, -500., 500.}}});
registry.add("hVertexerType", "Use KF or DCAFitterN;Vertexer type;entries", {HistType::kTH1D, {{2, -0.5, 1.5}}}); // See o2::aod::hf_cand::VertexerType
hCandidates = registry.add<TH1>("hCandidates", "candidates counter", {HistType::kTH1D, {axisCands}});
hfEvSel.addHistograms(registry); // collision monitoring

// init HF event selection helper
hfEvSel.init(registry);

massPi = MassPiPlus;
massK = MassKPlus;
Expand Down Expand Up @@ -713,11 +715,11 @@ struct HfCandidateCreator2ProngExpressions {
const auto& workflows = initContext.services().get<RunningWorkflowInfo const>();
for (const DeviceSpec& device : workflows.devices) {
if (device.name.compare("hf-candidate-creator-2prong") == 0) {
hfEvSelMc.configureFromDevice(device);
// init HF event selection helper
hfEvSelMc.init(device, registry);
break;
}
}
hfEvSelMc.addHistograms(registry); // particles monitoring
}

/// Performs MC matching.
Expand Down
9 changes: 5 additions & 4 deletions PWGHF/TableProducer/candidateCreator3Prong.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -168,7 +168,9 @@ struct HfCandidateCreator3Prong {
registry.add("hDcaXYProngs", "DCAxy of 3-prong candidate daughters;#it{p}_{T} (GeV/#it{c};#it{d}_{xy}) (#mum);entries", {HistType::kTH2F, {{100, 0., 20.}, {200, -500., 500.}}});
registry.add("hDcaZProngs", "DCAz of 3-prong candidate daughters;#it{p}_{T} (GeV/#it{c};#it{d}_{z}) (#mum);entries", {HistType::kTH2F, {{100, 0., 20.}, {200, -500., 500.}}});
hCandidates = registry.add<TH1>("hCandidates", "candidates counter", {HistType::kTH1D, {axisCands}});
hfEvSel.addHistograms(registry); // collision monitoring

// init HF event selection helper
hfEvSel.init(registry);

massP = MassProton;
massPi = MassPiPlus;
Expand Down Expand Up @@ -813,12 +815,11 @@ struct HfCandidateCreator3ProngExpressions {
const auto& workflows = initContext.services().get<RunningWorkflowInfo const>();
for (const DeviceSpec& device : workflows.devices) {
if (device.name.compare("hf-candidate-creator-3prong") == 0) {
hfEvSelMc.configureFromDevice(device);
// init HF event selection helper
hfEvSelMc.init(device, registry);
break;
}
}

hfEvSelMc.addHistograms(registry); // particles monitoring
}

/// Performs MC matching.
Expand Down
8 changes: 5 additions & 3 deletions PWGHF/TableProducer/candidateCreatorCascade.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,9 @@ struct HfCandidateCreatorCascade {
registry.add("hCovPVXX", "2-prong candidates;XX element of cov. matrix of prim. vtx. position (cm^{2});entries", {HistType::kTH1F, {{100, 0., 1.e-4}}});
registry.add("hCovSVXX", "2-prong candidates;XX element of cov. matrix of sec. vtx. position (cm^{2});entries", {HistType::kTH1F, {{100, 0., 0.2}}});
hCandidates = registry.add<TH1>("hCandidates", "candidates counter", {HistType::kTH1D, {axisCands}});
hfEvSel.addHistograms(registry); // collision monitoring

// init HF event selection helper
hfEvSel.init(registry);

massP = MassProton;
massK0s = MassK0Short;
Expand Down Expand Up @@ -471,11 +473,11 @@ struct HfCandidateCreatorCascadeMc {
const auto& workflows = initContext.services().get<RunningWorkflowInfo const>();
for (const DeviceSpec& device : workflows.devices) {
if (device.name.compare("hf-candidate-creator-cascade") == 0) {
hfEvSelMc.configureFromDevice(device);
// init HF event selection helper
hfEvSelMc.init(device, registry);
break;
}
}
hfEvSelMc.addHistograms(registry); // particles monitoring
}

template <o2::hf_centrality::CentralityEstimator centEstimator, typename CCs, typename McCollisions>
Expand Down
8 changes: 5 additions & 3 deletions PWGHF/TableProducer/candidateCreatorDstar.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,9 @@ struct HfCandidateCreatorDstar {
}

hCandidates = registry.add<TH1>("hCandidates", "candidates counter", {HistType::kTH1D, {axisCands}});
hfEvSel.addHistograms(registry); // collision monitoring

// init HF event selection helper
hfEvSel.init(registry);

// LOG(info) << "Init Function Invoked";
massPi = MassPiPlus;
Expand Down Expand Up @@ -534,11 +536,11 @@ struct HfCandidateCreatorDstarExpressions {
const auto& workflows = initContext.services().get<RunningWorkflowInfo const>();
for (const DeviceSpec& device : workflows.devices) {
if (device.name.compare("hf-candidate-creator-dstar") == 0) {
hfEvSelMc.configureFromDevice(device);
// init HF event selection helper
hfEvSelMc.init(device, registry);
break;
}
}
hfEvSelMc.addHistograms(registry); // particles monitoring
}

/// Perform MC Matching.
Expand Down
5 changes: 2 additions & 3 deletions PWGHF/TableProducer/candidateCreatorSigmac0plusplus.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -408,12 +408,11 @@ struct HfCandidateSigmac0plusplusMc {
// here we assume that the hf-candidate-creator-3prong is in the workflow
// configure the ev. sel from that workflow
if (device.name.compare("hf-candidate-creator-3prong") == 0) {
hfEvSelMc.configureFromDevice(device);
// init HF event selection helper
hfEvSelMc.init(device, registry);
break;
}
}

hfEvSelMc.addHistograms(registry); // particles monitoring
}

/// @brief dummy process function, to be run on data
Expand Down
8 changes: 5 additions & 3 deletions PWGHF/TableProducer/candidateCreatorXic0Omegac0.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -341,7 +341,9 @@ struct HfCandidateCreatorXic0Omegac0 {
registry.add("hKFcosPaV0ToCasc", "hKFcosPaV0ToCasc", kTH1D, {{5000, 0.8f, 1.1f}});
registry.add("hKFcosPaCascToOmegac", "hKFcosPaCascToOmegac", kTH1D, {{5000, 0.8f, 1.1f}});
}
hfEvSel.addHistograms(registry); // collision monitoring

// init HF event selection helper
hfEvSel.init(registry);

df.setPropagateToPCA(propagateToPCA);
df.setMaxR(maxR);
Expand Down Expand Up @@ -1879,11 +1881,11 @@ struct HfCandidateCreatorXic0Omegac0Mc {
const auto& workflows = initContext.services().get<RunningWorkflowInfo const>();
for (const DeviceSpec& device : workflows.devices) {
if (device.name.compare("hf-candidate-creator-xic0-omegac0") == 0) {
hfEvSelMc.configureFromDevice(device);
// init HF event selection helper
hfEvSelMc.init(device, registry);
break;
}
}
hfEvSelMc.addHistograms(registry); // particles monitoring

hGenCharmBaryonPtRapidityTightXicToXiPi = registry.add<TH1>("hGenCharmBaryonPtRapidityTightXicToXiPi", "Generated charm baryon #it{p}_{T};#it{p}_{T} (GeV/#it{c});entries", {HistType::kTH1D, {{20, 0.0, 20.0}}}); // keep track of generated candidates pt when |y|<0.5
hGenCharmBaryonPtRapidityLooseXicToXiPi = registry.add<TH1>("hGenCharmBaryonPtRapidityLooseXicToXiPi", "Generated charm baryon #it{p}_{T};#it{p}_{T} (GeV/#it{c});entries", {HistType::kTH1D, {{20, 0.0, 20.0}}}); // keep track of generated candidates pt when |y|<0.8
Expand Down
84 changes: 76 additions & 8 deletions PWGHF/Utils/utilsEvSelHf.h
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
#include "Framework/OutputObjHeader.h"

#include "Common/CCDB/EventSelectionParams.h"
#include "Common/CCDB/RCTSelectionFlags.h"
#include "EventFiltering/Zorro.h"
#include "EventFiltering/ZorroSummary.h"
#include "PWGLF/DataModel/mcCentrality.h"
Expand Down Expand Up @@ -82,6 +83,7 @@ namespace o2::hf_evsel
// event rejection types
enum EventRejection {
None = 0,
Rct,
SoftwareTrigger,
Centrality,
Trigger,
Expand Down Expand Up @@ -110,6 +112,7 @@ void setEventRejectionLabels(Histo& hRejection, std::string softwareTriggerLabel
{
// Puts labels on the collision monitoring histogram.
hRejection->GetXaxis()->SetBinLabel(EventRejection::None + 1, "All");
hRejection->GetXaxis()->SetBinLabel(EventRejection::Rct + 1, "RCT");
hRejection->GetXaxis()->SetBinLabel(EventRejection::SoftwareTrigger + 1, softwareTriggerLabel.data());
hRejection->GetXaxis()->SetBinLabel(EventRejection::Centrality + 1, "Centrality");
hRejection->GetXaxis()->SetBinLabel(EventRejection::Trigger + 1, "Trigger");
Expand Down Expand Up @@ -155,6 +158,10 @@ struct HfEventSelection : o2::framework::ConfigurableGroup {
o2::framework::Configurable<std::string> ccdbPathSoftwareTrigger{"ccdbPathSoftwareTrigger", "Users/m/mpuccio/EventFiltering/OTS/Chunked/", "ccdb path for ZORRO objects"};
o2::framework::ConfigurableAxis th2ConfigAxisCent{"th2ConfigAxisCent", {100, 0., 100.}, ""};
o2::framework::ConfigurableAxis th2ConfigAxisOccupancy{"th2ConfigAxisOccupancy", {14, 0, 14000}, ""};
o2::framework::Configurable<bool> requireGoodRct{"requireGoodRct", false, "Flag to require good RCT"};
o2::framework::Configurable<std::string> rctLabel{"rctLabel", "CBT_hadronPID", "RCT selection flag (CBT, CBT_hadronPID, CBT_electronPID, CCBT_calo, CBT_muon, CBT_muon_glo)"};
o2::framework::Configurable<bool> rctCheckZDC{"rctCheckZDC", false, "RCT flag to check whether the ZDC is present or not"};
o2::framework::Configurable<bool> rctTreatLimitedAcceptanceAsBad{"rctTreatLimitedAcceptanceAsBad", false, "RCT flag to reject events with limited acceptance for selected detectors"};

// histogram names
static constexpr char NameHistCollisions[] = "hCollisions";
Expand All @@ -169,6 +176,9 @@ struct HfEventSelection : o2::framework::ConfigurableGroup {
std::shared_ptr<TH1> hCollisions, hSelCollisionsCent, hPosZBeforeEvSel, hPosZAfterEvSel, hPosXAfterEvSel, hPosYAfterEvSel, hNumPvContributorsAfterSel;
std::shared_ptr<TH2> hCollisionsCentOcc;

// util to retrieve the RCT info from CCDB
o2::aod::rctsel::RCTFlagsChecker rctChecker;

// util to retrieve trigger mask in case of software triggers
Zorro zorro;
o2::framework::OutputObj<ZorroSummary> zorroSummary{"zorroSummary"};
Expand All @@ -190,11 +200,22 @@ struct HfEventSelection : o2::framework::ConfigurableGroup {
const o2::framework::AxisSpec th2AxisCent{th2ConfigAxisCent, "Centrality"};
const o2::framework::AxisSpec th2AxisOccupancy{th2ConfigAxisOccupancy, "Occupancy"};
hCollisionsCentOcc = registry.add<TH2>(NameHistCollisionsCentOcc, "selected events;Centrality; Occupancy", {o2::framework::HistType::kTH2D, {th2AxisCent, th2AxisOccupancy}});
}

/// \brief Inits the HF event selection object
/// \param registry reference to the histogram registry
void init(o2::framework::HistogramRegistry& registry)
{
// we initialise the RCT checker
rctChecker.init(rctLabel.value, rctCheckZDC.value, rctTreatLimitedAcceptanceAsBad.value);

// we initialise the summary object
if (softwareTrigger.value != "") {
zorroSummary.setObject(zorro.getZorroSummary());
}

// we initialise histograms
addHistograms(registry);
}

/// \brief Applies event selection.
Expand All @@ -218,6 +239,10 @@ struct HfEventSelection : o2::framework::ConfigurableGroup {
}

if constexpr (useEvSel) {
/// RCT condition
if (requireGoodRct && !rctChecker.checkTable(collision)) {
SETBIT(rejectionMask, EventRejection::Rct);
}
/// trigger condition
if ((useSel8Trigger && !collision.sel8()) || (!useSel8Trigger && triggerClass > -1 && !collision.alias_bit(triggerClass))) {
SETBIT(rejectionMask, EventRejection::Trigger);
Expand Down Expand Up @@ -333,14 +358,21 @@ struct HfEventSelection : o2::framework::ConfigurableGroup {

struct HfEventSelectionMc {
// event selection parameters (in chronological order of application)
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)
float centralityMin{0.f}; // Minimum centrality
float centralityMax{100.f}; // Maximum centrality
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)
float centralityMin{0.f}; // Minimum centrality
float centralityMax{100.f}; // Maximum centrality
bool requireGoodRct{false}; // Apply RCT selection
std::string rctLabel{""}; // RCT selection flag
bool rctCheckZDC; // require ZDC from RCT
bool rctTreatLimitedAcceptanceAsBad; // RCT flag to reject events with limited acceptance for selected detectors

// util to retrieve the RCT info from CCDB
o2::aod::rctsel::RCTFlagsChecker rctChecker;

// histogram names
static constexpr char NameHistGenCollisionsCent[] = "hGenCollisionsCent";
Expand All @@ -364,6 +396,9 @@ struct HfEventSelectionMc {
setEventRejectionLabels(hParticles);
}

/// \brief Configures the object from the reco workflow
/// \param registry reference to the histogram registry
/// \param device device spec to get the configs from the reco workflow
void configureFromDevice(const o2::framework::DeviceSpec& device)
{
for (const auto& option : device.options) {
Expand All @@ -383,10 +418,33 @@ struct HfEventSelectionMc {
centralityMin = option.defaultValue.get<float>();
} else if (option.name.compare("hfEvSel.centralityMax") == 0) {
centralityMax = option.defaultValue.get<float>();
} else if (option.name.compare("hfEvSel.requireGoodRct") == 0) {
requireGoodRct = option.defaultValue.get<bool>();
} else if (option.name.compare("hfEvSel.rctLabel") == 0) {
rctLabel = option.defaultValue.get<std::string>();
} else if (option.name.compare("hfEvSel.rctCheckZDC") == 0) {
rctCheckZDC = option.defaultValue.get<bool>();
} else if (option.name.compare("hfEvSel.rctTreatLimitedAcceptanceAsBad") == 0) {
rctTreatLimitedAcceptanceAsBad = option.defaultValue.get<bool>();
}
}
}

/// \brief Inits the HF event selection object
/// \param device device spec to get the configs from the reco workflow
/// \param registry reference to the histogram registry
void init(const o2::framework::DeviceSpec& device, o2::framework::HistogramRegistry& registry)
{
// we get the configuration from the reco workflow
configureFromDevice(device);

// we initialise the RCT checker
rctChecker.init(rctLabel, rctCheckZDC, rctTreatLimitedAcceptanceAsBad);

// we initialise histograms
addHistograms(registry);
}

/// \brief Function to apply event selections to generated MC collisions
/// \param mcCollision MC collision to test against the selection criteria
/// \param collSlice collection of reconstructed collisions
Expand All @@ -406,6 +464,16 @@ struct HfEventSelectionMc {
SETBIT(rejectionMask, EventRejection::Centrality);
}
}

/// RCT condition
if (requireGoodRct) {
for (auto const& collision : collSlice) {
if (!rctChecker.checkTable(collision)) {
SETBIT(rejectionMask, EventRejection::Rct);
break;
}
}
}
/// 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);
Expand Down
Loading