From 9c1076e8a2439efde74ac4fddff790abaf614800 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?V=C3=ADt=20Ku=C4=8Dera?= Date: Sat, 18 Sep 2021 03:24:07 +0200 Subject: [PATCH] PWGHF: Add primary-vertex selection in skimming --- .../HFTrackIndexSkimsCreator.cxx | 124 +++++++++++++++--- 1 file changed, 104 insertions(+), 20 deletions(-) diff --git a/PWGHF/TableProducer/HFTrackIndexSkimsCreator.cxx b/PWGHF/TableProducer/HFTrackIndexSkimsCreator.cxx index c6f377eb16d..455516ead92 100644 --- a/PWGHF/TableProducer/HFTrackIndexSkimsCreator.cxx +++ b/PWGHF/TableProducer/HFTrackIndexSkimsCreator.cxx @@ -44,6 +44,17 @@ enum CandidateType { NCandidateTypes }; +// event rejection types +enum EventRejection { + Trigger = 0, + PositionX, + PositionY, + PositionZ, + NContrib, + Chi2, + NEventRejection +}; + static const double massPi = RecoDecay::getMassPDG(kPiPlus); static const double massK = RecoDecay::getMassPDG(kKPlus); static const double massProton = RecoDecay::getMassPDG(kProton); @@ -52,8 +63,8 @@ static const double massMuon = RecoDecay::getMassPDG(kMuonPlus); void customize(std::vector& workflowOptions) { - ConfigParamSpec optionDoMC{"do-LcK0Sp", VariantType::Bool, false, {"Skim also Lc --> K0S+p"}}; - ConfigParamSpec optionEvSel{"doEvSel", VariantType::Bool, false, {"Apply event selection"}}; + ConfigParamSpec optionDoMC{"doCascades", VariantType::Bool, false, {"Skim also Λc -> K0S p"}}; + ConfigParamSpec optionEvSel{"doTrigSel", VariantType::Bool, false, {"Apply trigger selection"}}; workflowOptions.push_back(optionDoMC); workflowOptions.push_back(optionEvSel); } @@ -80,37 +91,102 @@ struct HfTagSelCollisions { Produces rowSelectedCollision; Configurable fillHistograms{"fillHistograms", true, "fill histograms"}; + Configurable xVertexMin{"xVertexMin", -100., "min. x of primary vertex [cm]"}; + Configurable xVertexMax{"xVertexMax", 100., "max. x of primary vertex [cm]"}; + Configurable yVertexMin{"yVertexMin", -100., "min. y of primary vertex [cm]"}; + Configurable yVertexMax{"yVertexMax", 100., "max. y of primary vertex [cm]"}; + Configurable zVertexMin{"zVertexMin", -100., "min. z of primary vertex [cm]"}; + Configurable zVertexMax{"zVertexMax", 100., "max. z of primary vertex [cm]"}; + Configurable nContribMin{"nContribMin", 0, "min. number of contributors to primary-vertex reconstruction"}; + Configurable chi2Max{"chi2Max", 0., "max. chi^2 of primary-vertex reconstruction"}; Configurable triggerClassName{"triggerClassName", "kINT7", "trigger class"}; int triggerClass = std::distance(aliasLabels, std::find(aliasLabels, aliasLabels + kNaliases, triggerClassName.value.data())); - HistogramRegistry registry{ - "registry", - {{"hEvents", "Events;;entries", {HistType::kTH1F, {{3, 0.5, 3.5}}}}}}; + HistogramRegistry registry{"registry", {}}; void init(InitContext const&) { - std::string labels[3] = {"processed collisions", "selected collisions", "rej. trigger class"}; - for (int iBin = 0; iBin < 3; iBin++) { + const int nBinsEvents = 2 + EventRejection::NEventRejection; + std::string labels[nBinsEvents]; + labels[0] = "processed"; + labels[1] = "selected"; + labels[2 + EventRejection::Trigger] = "rej. trigger"; + labels[2 + EventRejection::PositionX] = "rej. #it{x}"; + labels[2 + EventRejection::PositionY] = "rej. #it{y}"; + labels[2 + EventRejection::PositionZ] = "rej. #it{z}"; + labels[2 + EventRejection::NContrib] = "rej. # of contributors"; + labels[2 + EventRejection::Chi2] = "rej. #it{#chi}^{2}"; + AxisSpec axisEvents = {nBinsEvents, 0.5, nBinsEvents + 0.5, ""}; + registry.add("hEvents", "Events;;entries", HistType::kTH1F, {axisEvents}); + for (int iBin = 0; iBin < nBinsEvents; iBin++) { registry.get(HIST("hEvents"))->GetXaxis()->SetBinLabel(iBin + 1, labels[iBin].data()); } } - // event selection - void processEvSel(soa::Join::iterator const& collision) + /// Primary-vertex selection + /// \param collision collision table row + /// \param statusCollision bit map with rejection results + template + void selectVertex(const Col& collision, int& statusCollision) + { + // x position + if (collision.posX() < xVertexMin || collision.posX() > xVertexMax) { + SETBIT(statusCollision, EventRejection::PositionX); + if (fillHistograms) { + registry.get(HIST("hEvents"))->Fill(3 + EventRejection::PositionX); + } + } + // y position + if (collision.posY() < yVertexMin || collision.posY() > yVertexMax) { + SETBIT(statusCollision, EventRejection::PositionY); + if (fillHistograms) { + registry.get(HIST("hEvents"))->Fill(3 + EventRejection::PositionY); + } + } + // z position + if (collision.posZ() < zVertexMin || collision.posZ() > zVertexMax) { + SETBIT(statusCollision, EventRejection::PositionZ); + if (fillHistograms) { + registry.get(HIST("hEvents"))->Fill(3 + EventRejection::PositionZ); + } + } + // number of contributors + if (collision.numContrib() < nContribMin) { + SETBIT(statusCollision, EventRejection::NContrib); + if (fillHistograms) { + registry.get(HIST("hEvents"))->Fill(3 + EventRejection::NContrib); + } + } + // chi^2 + if (chi2Max > 0. && collision.chi2() > chi2Max) { + SETBIT(statusCollision, EventRejection::Chi2); + if (fillHistograms) { + registry.get(HIST("hEvents"))->Fill(3 + EventRejection::Chi2); + } + } + } + + /// Event selection with trigger selection + void processTrigSel(soa::Join::iterator const& collision) { int statusCollision = 0; + // processed events if (fillHistograms) { registry.get(HIST("hEvents"))->Fill(1); } + // trigger selection if (!collision.alias()[triggerClass]) { - statusCollision |= BIT(0); + SETBIT(statusCollision, EventRejection::Trigger); if (fillHistograms) { - registry.get(HIST("hEvents"))->Fill(3); + registry.get(HIST("hEvents"))->Fill(3 + EventRejection::Trigger); } } + // vertex selection + selectVertex(collision, statusCollision); + //TODO: add more event selection criteria // selected events @@ -122,15 +198,23 @@ struct HfTagSelCollisions { rowSelectedCollision(statusCollision); }; - PROCESS_SWITCH(HfTagSelCollisions, processEvSel, "Use event selection", true); + PROCESS_SWITCH(HfTagSelCollisions, processTrigSel, "Use trigger selection", true); - // no event selection in case of no event-selection task attached - void processNoEvSel(aod::Collision const&) + /// Event selection without trigger selection + void processNoTrigSel(aod::Collision const& collision) { int statusCollision = 0; + // processed events if (fillHistograms) { registry.get(HIST("hEvents"))->Fill(1); + } + + // vertex selection + selectVertex(collision, statusCollision); + + // selected events + if (fillHistograms && statusCollision == 0) { registry.get(HIST("hEvents"))->Fill(2); } @@ -138,7 +222,7 @@ struct HfTagSelCollisions { rowSelectedCollision(statusCollision); }; - PROCESS_SWITCH(HfTagSelCollisions, processNoEvSel, "Do not use event selection", false); + PROCESS_SWITCH(HfTagSelCollisions, processNoTrigSel, "Do not use trigger selection", false); }; /// Track selection @@ -1474,18 +1558,18 @@ WorkflowSpec defineDataProcessing(ConfigContext const& cfgc) { WorkflowSpec workflow{}; - const bool doEvSel = cfgc.options().get("doEvSel"); - if (doEvSel) { + const bool doTrigSel = cfgc.options().get("doTrigSel"); + if (doTrigSel) { workflow.push_back(adaptAnalysisTask(cfgc)); } else { - workflow.push_back(adaptAnalysisTask(cfgc, SetDefaultProcesses{{{"processEvSel", false}, {"processNoEvSel", true}}})); + workflow.push_back(adaptAnalysisTask(cfgc, SetDefaultProcesses{{{"processTrigSel", false}, {"processNoTrigSel", true}}})); } workflow.push_back(adaptAnalysisTask(cfgc)); workflow.push_back(adaptAnalysisTask(cfgc)); - const bool doLcK0Sp = cfgc.options().get("do-LcK0Sp"); - if (doLcK0Sp) { + const bool doCascades = cfgc.options().get("doCascades"); + if (doCascades) { workflow.push_back(adaptAnalysisTask(cfgc)); }