Skip to content

Commit 7f95dd8

Browse files
authored
[PWGLF] Refactor event selection and processing logic (#15185)
1 parent d2d2766 commit 7f95dd8

File tree

3 files changed

+104
-62
lines changed

3 files changed

+104
-62
lines changed

PWGLF/Tasks/Resonances/lambda1520analysisinpp.cxx

Lines changed: 86 additions & 54 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
/// \author Hirak Kumar Koley <hirak.koley@cern.ch>
1515

1616
#include "PWGLF/Utils/collisionCuts.h"
17+
#include "PWGLF/Utils/inelGt.h"
1718

1819
#include "Common/DataModel/Centrality.h"
1920
#include "Common/DataModel/Multiplicity.h"
@@ -92,15 +93,15 @@ struct Lambda1520analysisinpp {
9293
Configurable<float> cfgEvtZvtx{"cfgEvtZvtx", 10.0f, "Evt sel: Max. z-Vertex (cm)"};
9394
Configurable<int> cfgEvtOccupancyInTimeRangeMax{"cfgEvtOccupancyInTimeRangeMax", -1, "Evt sel: maximum track occupancy"};
9495
Configurable<int> cfgEvtOccupancyInTimeRangeMin{"cfgEvtOccupancyInTimeRangeMin", -1, "Evt sel: minimum track occupancy"};
95-
Configurable<bool> cfgEvtTriggerCheck{"cfgEvtTriggerCheck", false, "Evt sel: check for trigger"};
96-
Configurable<bool> cfgEvtOfflineCheck{"cfgEvtOfflineCheck", true, "Evt sel: check for offline selection"};
97-
Configurable<bool> cfgEvtTriggerTVXSel{"cfgEvtTriggerTVXSel", false, "Evt sel: triggerTVX selection (MB)"};
98-
Configurable<bool> cfgEvtTFBorderCut{"cfgEvtTFBorderCut", false, "Evt sel: apply TF border cut"};
99-
Configurable<bool> cfgEvtUseITSTPCvertex{"cfgEvtUseITSTPCvertex", false, "Evt sel: use at lease on ITS-TPC track for vertexing"};
100-
Configurable<bool> cfgEvtZvertexTimedifference{"cfgEvtZvertexTimedifference", false, "Evt sel: apply Z-vertex time difference"};
101-
Configurable<bool> cfgEvtPileupRejection{"cfgEvtPileupRejection", false, "Evt sel: apply pileup rejection"};
102-
Configurable<bool> cfgEvtNoITSROBorderCut{"cfgEvtNoITSROBorderCut", false, "Evt sel: apply NoITSRO border cut"};
103-
Configurable<bool> cfgEvtCollInTimeRangeStandard{"cfgEvtCollInTimeRangeStandard", false, "Evt sel: apply NoCollInTimeRangeStandard"};
96+
Configurable<bool> cfgEvtSel8{"cfgEvtSel8", false, "Evt Sel 8 check for offline selection"};
97+
Configurable<bool> cfgEvtTriggerTVXSel{"cfgEvtTriggerTVXSel", true, "Evt sel: triggerTVX selection (MB)"};
98+
Configurable<bool> cfgEvtNoTFBorderCut{"cfgEvtNoTFBorderCut", true, "Evt sel: apply TF border cut"};
99+
Configurable<bool> cfgEvtIsVertexITSTPC{"cfgEvtIsVertexITSTPC", false, "Evt sel: use at lease on ITS-TPC track for vertexing"};
100+
Configurable<bool> cfgEvtIsGoodZvtxFT0vsPV{"cfgEvtIsGoodZvtxFT0vsPV", true, "Evt sel: apply Z-vertex time difference"};
101+
Configurable<bool> cfgEvtNoSameBunchPileup{"cfgEvtNoSameBunchPileup", false, "Evt sel: apply pileup rejection"};
102+
Configurable<bool> cfgEvtNoITSROFrameBorderCut{"cfgEvtNoITSROFrameBorderCut", false, "Evt sel: apply NoITSRO border cut"};
103+
Configurable<bool> cfgEvtNoCollInTimeRangeStandard{"cfgEvtNoCollInTimeRangeStandard", false, "Evt sel: apply NoNoCollInTimeRangeStandard"};
104+
Configurable<bool> cfgEvtIsVertexTOFmatched{"cfgEvtIsVertexTOFmatched", true, "kIsVertexTOFmatched: apply vertex TOF matched"};
104105
} configEvents;
105106

106107
struct : ConfigurableGroup {
@@ -157,7 +158,7 @@ struct Lambda1520analysisinpp {
157158
/// Event Mixing
158159
Configurable<int> nEvtMixing{"nEvtMixing", 10, "Number of events to mix"};
159160
ConfigurableAxis cfgVtxBins{"cfgVtxBins", {VARIABLE_WIDTH, -10.0f, -8.0f, -6.0f, -4.0f, -2.0f, 0.0f, 2.0f, 4.0f, 6.0f, 8.0f, 10.0f}, "Mixing bins - z-vertex"};
160-
ConfigurableAxis cfgMultBins{"cfgMultBins", {VARIABLE_WIDTH, 0.0f, 5.0f, 10.0f, 20.0f, 30.0f, 40.0f, 50.0f, 60.0f, 70.0f, 80.0f, 90.0f, 100.0f, 110.0f}, "Mixing bins - multiplicity"};
161+
ConfigurableAxis cfgMultPercentileBins{"cfgMultPercentileBins", {VARIABLE_WIDTH, 0.0f, 5.0f, 10.0f, 20.0f, 30.0f, 40.0f, 50.0f, 60.0f, 70.0f, 80.0f, 90.0f, 100.0f, 110.0f}, "Mixing bins - multiplicity"};
161162

162163
// Rotational background
163164
Configurable<int> rotationalcut{"rotationalcut", 10, "Cut value (Rotation angle pi - pi/cut and pi + pi/cut)"};
@@ -174,7 +175,6 @@ struct Lambda1520analysisinpp {
174175
Configurable<bool> cfgUseDaughterEtaCutMC{"cfgUseDaughterEtaCutMC", false, "Switch to turn on/off eta cuts for daughters in MC"};
175176

176177
// MC selection cut
177-
Configurable<float> cZvertCutMC{"cZvertCutMC", 10.0f, "MC Z-vertex cut"};
178178
Configurable<float> cEtacutMC{"cEtacutMC", 0.5f, "MC eta cut"};
179179
Configurable<bool> cUseRapcutMC{"cUseRapcutMC", true, "MC eta cut"};
180180
Configurable<bool> cUseEtacutMC{"cUseEtacutMC", true, "MC eta cut"};
@@ -237,16 +237,17 @@ struct Lambda1520analysisinpp {
237237

238238
void init(framework::InitContext&)
239239
{
240-
colCuts.setCuts(configEvents.cfgEvtZvtx, configEvents.cfgEvtTriggerCheck, configEvents.cfgEvtOfflineCheck, /*checkRun3*/ true, /*triggerTVXsel*/ false, configEvents.cfgEvtOccupancyInTimeRangeMax, configEvents.cfgEvtOccupancyInTimeRangeMin);
240+
colCuts.setCuts(configEvents.cfgEvtZvtx, /* configEvents.cfgEvtTriggerCheck */ false, configEvents.cfgEvtSel8, /*checkRun3*/ true, /*triggerTVXsel*/ false, configEvents.cfgEvtOccupancyInTimeRangeMax, configEvents.cfgEvtOccupancyInTimeRangeMin);
241241

242242
colCuts.init(&histos);
243243
colCuts.setTriggerTVX(configEvents.cfgEvtTriggerTVXSel);
244-
colCuts.setApplyTFBorderCut(configEvents.cfgEvtTFBorderCut);
245-
colCuts.setApplyITSTPCvertex(configEvents.cfgEvtUseITSTPCvertex);
246-
colCuts.setApplyZvertexTimedifference(configEvents.cfgEvtZvertexTimedifference);
247-
colCuts.setApplyPileupRejection(configEvents.cfgEvtPileupRejection);
248-
colCuts.setApplyNoITSROBorderCut(configEvents.cfgEvtNoITSROBorderCut);
249-
colCuts.setApplyCollInTimeRangeStandard(configEvents.cfgEvtCollInTimeRangeStandard);
244+
colCuts.setApplyTFBorderCut(configEvents.cfgEvtNoTFBorderCut);
245+
colCuts.setApplyITSTPCvertex(configEvents.cfgEvtIsVertexITSTPC);
246+
colCuts.setApplyZvertexTimedifference(configEvents.cfgEvtIsGoodZvtxFT0vsPV);
247+
colCuts.setApplyPileupRejection(configEvents.cfgEvtNoSameBunchPileup);
248+
colCuts.setApplyNoITSROBorderCut(configEvents.cfgEvtNoITSROFrameBorderCut);
249+
colCuts.setApplyCollInTimeRangeStandard(configEvents.cfgEvtNoCollInTimeRangeStandard);
250+
colCuts.setApplyVertexTOFmatched(configEvents.cfgEvtIsVertexTOFmatched);
250251
colCuts.printCuts();
251252

252253
// axes
@@ -255,22 +256,23 @@ struct Lambda1520analysisinpp {
255256
AxisSpec axisEta{binsEta, "#eta"};
256257
AxisSpec axisRap{binsEta, "#it{y}"};
257258
AxisSpec axisMassLambda1520{binsMass, "Invariant Mass (GeV/#it{c}^2)"};
258-
AxisSpec axisMult{binsMult, "mult_{V0M}"};
259+
AxisSpec axisMult{binsMult, "mult_{FT0M}"};
259260
AxisSpec axisDCAz{binsDCAz, "DCA_{z}"};
260261
AxisSpec axisDCAxy{binsDCAxy, "DCA_{XY}"};
261262
AxisSpec axisTPCXrow{binsTPCXrows, "#Xrows_{TPC}"};
262263
AxisSpec axisPIDQA{binsnSigma, "#sigma"};
263264
AxisSpec axisTPCSignal{binsnTPCSignal, ""};
264-
AxisSpec axisMClabel{6, -1.5f, 5.5f, "MC Label"};
265+
AxisSpec axisMClabel{6, -1.5f, 6.5f, "MC Label"};
265266
AxisSpec axisEtaPhi{binsEtaPhi, ""};
266267
AxisSpec axisPhi{350, 0, 7, "#Phi"};
267-
AxisSpec axisMultMix{configBkg.cfgMultBins, "Multiplicity"};
268+
AxisSpec axisMultMix{configBkg.cfgMultPercentileBins, "Multiplicity Percentile"};
268269
AxisSpec axisVtxMix{configBkg.cfgVtxBins, "Vertex Z (cm)"};
269270
AxisSpec idxMCAxis = {26, -0.5f, 25.5f, "Index"};
270271

271272
if (cFilladditionalQAeventPlots) {
272273
// event histograms
273274
if (doprocessData) {
275+
histos.add("QAevent/hEvents", "INEL>0 Events", HistType::kTH1F, {{2, 0.5f, 2.5f}});
274276
histos.add("QAevent/hPairsCounterSameE", "total valid no. of pairs sameE", HistType::kTH1F, {{1, 0.5f, 1.5f}});
275277
histos.add("QAevent/hnTrksSameE", "n tracks per event SameE", HistType::kTH1F, {{1000, 0.0, 1000.0}});
276278
}
@@ -287,6 +289,9 @@ struct Lambda1520analysisinpp {
287289
histos.add("QAevent/hMultiplicityPercentMixedE", "Multiplicity percentile of collision", HistType::kTH1F, {{120, 0.0f, 120.0f}});
288290
histos.add("QAevent/hnTrksMixedE", "n tracks per event MixedE", HistType::kTH1F, {{1000, 0.0f, 1000.0f}});
289291
}
292+
if (doprocessMCRec) {
293+
histos.add("QAevent/hEventsMC", "INEL>0 Events MC", HistType::kTH1F, {{2, 0.5f, 2.5f}});
294+
}
290295
}
291296

292297
if (doprocessData) {
@@ -395,7 +400,7 @@ struct Lambda1520analysisinpp {
395400

396401
// MC QA
397402
histos.add("Event/hMCEventIndices", "hMCEventIndices", kTH2D, {axisMult, idxMCAxis});
398-
if (doprocessMCTrue) {
403+
if (doprocessMCGen) {
399404
histos.add("QA/MC/h2GenEtaPt_beforeanycut", " #eta-#it{p}_{T} distribution of Generated #Lambda(1520); #eta; #it{p}_{T}; Counts;", HistType::kTHnSparseF, {axisEta, axisPtQA});
400405
histos.add("QA/MC/h2GenPhiRapidity_beforeanycut", " #phi-y distribution of Generated #Lambda(1520); #phi; y; Counts;", HistType::kTHnSparseF, {axisPhi, axisRap});
401406
histos.add("QA/MC/h2GenEtaPt_afterEtaRapCut", " #eta-#it{p}_{T} distribution of Generated #Lambda(1520); #eta; #it{p}_{T}; Counts;", HistType::kTHnSparseF, {axisEta, axisPtQA});
@@ -406,7 +411,7 @@ struct Lambda1520analysisinpp {
406411
histos.add("Result/MC/Genlambda1520pt", "pT distribution of True MC #Lambda(1520)0", kTH3F, {axisMClabel, axisPt, axisMult});
407412
histos.add("Result/MC/Genantilambda1520pt", "pT distribution of True MC Anti-#Lambda(1520)0", kTH3F, {axisMClabel, axisPt, axisMult});
408413
}
409-
if (doprocessMC) {
414+
if (doprocessMCRec) {
410415
histos.add("QA/MC/h2RecoEtaPt_after", " #eta-#it{p}_{T} distribution of Reconstructed #Lambda(1520); #eta; #it{p}_{T}; Counts;", HistType::kTHnSparseF, {axisEta, axisPt});
411416
histos.add("QA/MC/h2RecoPhiRapidity_after", " #phi-y distribution of Reconstructed #Lambda(1520); #phi; y; Counts;", HistType::kTHnSparseF, {axisPhi, axisRap});
412417

@@ -453,26 +458,6 @@ struct Lambda1520analysisinpp {
453458
return returnValue;
454459
}
455460

456-
auto static constexpr TripleCharge = 3.0f;
457-
458-
// Check if the collision is INEL>0
459-
template <typename MCColl, typename MCPart>
460-
bool isTrueINEL0(MCColl const& /*mccoll*/, MCPart const& mcparts)
461-
{
462-
for (auto const& mcparticle : mcparts) {
463-
if (!mcparticle.isPhysicalPrimary())
464-
continue;
465-
auto p = pdg->GetParticle(mcparticle.pdgCode());
466-
if (p != nullptr) {
467-
if (std::abs(p->Charge()) >= TripleCharge) { // check if the particle is charged
468-
if (std::abs(mcparticle.eta()) < 1.0f)
469-
return true;
470-
}
471-
}
472-
}
473-
return false;
474-
}
475-
476461
template <typename TrackType>
477462
bool trackCut(const TrackType track)
478463
{
@@ -1039,6 +1024,17 @@ struct Lambda1520analysisinpp {
10391024
if (!colCuts.isSelected(collision)) // Default event selection
10401025
return;
10411026

1027+
if (cFilladditionalQAeventPlots) {
1028+
histos.fill(HIST("QAevent/hEvents"), 1);
1029+
}
1030+
1031+
if (!collision.isInelGt0()) // <--
1032+
return;
1033+
1034+
if (cFilladditionalQAeventPlots) {
1035+
histos.fill(HIST("QAevent/hEvents"), 2);
1036+
}
1037+
10421038
colCuts.fillQA(collision);
10431039

10441040
fillHistograms<true, false, false, false>(collision, tracks, tracks);
@@ -1050,32 +1046,49 @@ struct Lambda1520analysisinpp {
10501046
if (!colCuts.isSelected(collision, false)) // Default event selection
10511047
return;
10521048

1049+
if (!collision.isInelGt0()) // <--
1050+
return;
1051+
10531052
fillHistograms<false, true, false, false>(collision, tracks, tracks);
10541053
}
10551054
PROCESS_SWITCH(Lambda1520analysisinpp, processRotational, "Process Rotational Background", false);
10561055

1057-
void processMC(MCEventCandidates::iterator const& collision,
1058-
aod::McCollisions const&,
1059-
MCTrackCandidates const& tracks, aod::McParticles const&)
1056+
void processMCRec(MCEventCandidates::iterator const& collision,
1057+
aod::McCollisions const&,
1058+
MCTrackCandidates const& tracks, aod::McParticles const&)
10601059
{
1061-
colCuts.fillQA(collision);
1060+
if (!colCuts.isSelected(collision))
1061+
return;
1062+
1063+
if (cFilladditionalQAeventPlots) {
1064+
histos.fill(HIST("QAevent/hEventsMC"), 1);
1065+
}
10621066

1063-
if (std::abs(collision.posZ()) > cZvertCutMC) // Z-vertex cut
1067+
if (!collision.isInelGt0()) // <--
10641068
return;
10651069

1070+
if (cFilladditionalQAeventPlots) {
1071+
histos.fill(HIST("QAevent/hEventsMC"), 2);
1072+
}
1073+
10661074
fillHistograms<false, false, true, false>(collision, tracks, tracks);
10671075
}
1068-
PROCESS_SWITCH(Lambda1520analysisinpp, processMC, "Process Event for MC Light without partition", false);
1076+
PROCESS_SWITCH(Lambda1520analysisinpp, processMCRec, "Process Event for MC Rec without partition", false);
10691077

10701078
Partition<aod::McParticles> selectedMCParticles = (nabs(aod::mcparticle::pdgCode) == static_cast<int>(Pdg::kLambda1520_Py)); // Lambda(1520)
10711079

1072-
void processMCTrue(MCEventCandidates::iterator const& collision, aod::McCollisions const&, aod::McParticles const& mcParticles)
1080+
void processMCGen(MCEventCandidates::iterator const& collision, aod::McCollisions const&, aod::McParticles const& mcParticles)
10731081
{
1074-
bool isInAfterAllCuts = colCuts.isSelected(collision);
1082+
bool isInAfterAllCuts = colCuts.isSelected(collision, false);
10751083
bool inVtx10 = (std::abs(collision.mcCollision().posZ()) > configEvents.cfgEvtZvtx) ? false : true;
10761084
bool isTriggerTVX = collision.selection_bit(aod::evsel::kIsTriggerTVX);
10771085
bool isSel8 = collision.sel8();
1078-
bool isTrueINELgt0 = isTrueINEL0(collision, mcParticles);
1086+
1087+
auto mcPartsAll = mcParticles.sliceBy(perMcCollision, collision.mcCollision().globalIndex());
1088+
1089+
bool isTrueINELgt0 = pwglf::isINELgt0mc(mcPartsAll, pdg);
1090+
// bool isTrueINELgt0 = collision.isInelGt0();
1091+
10791092
auto centrality = centEst(collision);
10801093

10811094
auto mcParts = selectedMCParticles->sliceBy(perMcCollision, collision.mcCollision().globalIndex());
@@ -1157,6 +1170,13 @@ struct Lambda1520analysisinpp {
11571170
else
11581171
histos.fill(HIST("Result/MC/Genantilambda1520pt"), 4, part.pt(), centrality);
11591172
}
1173+
if (isInAfterAllCuts && isTrueINELgt0) // after all event selection
1174+
{
1175+
if (part.pdgCode() > 0)
1176+
histos.fill(HIST("Result/MC/Genlambda1520pt"), 5, part.pt(), centrality);
1177+
else
1178+
histos.fill(HIST("Result/MC/Genantilambda1520pt"), 5, part.pt(), centrality);
1179+
}
11601180
}
11611181

11621182
// QA for Trigger efficiency
@@ -1198,7 +1218,7 @@ struct Lambda1520analysisinpp {
11981218
if (isInAfterAllCuts && isTrueINELgt0 && inVtx10)
11991219
histos.fill(HIST("Event/hMCEventIndices"), centrality, AllCutsINELg010);
12001220
}
1201-
PROCESS_SWITCH(Lambda1520analysisinpp, processMCTrue, "Process Event for MC only", false);
1221+
PROCESS_SWITCH(Lambda1520analysisinpp, processMCGen, "Process Event for MC only", false);
12021222

12031223
// Processing Event Mixing
12041224
using BinningTypeVtxZT0M = ColumnBinningPolicy<collision::PosZ, cent::CentFT0M>;
@@ -1208,7 +1228,7 @@ struct Lambda1520analysisinpp {
12081228
{
12091229
auto tracksTuple = std::make_tuple(tracks);
12101230

1211-
BinningTypeVtxZT0M colBinning{{configBkg.cfgVtxBins, configBkg.cfgMultBins}, true};
1231+
BinningTypeVtxZT0M colBinning{{configBkg.cfgVtxBins, configBkg.cfgMultPercentileBins}, true};
12121232
SameKindPair<EventCandidates, TrackCandidates, BinningTypeVtxZT0M> pairs{colBinning, configBkg.nEvtMixing, -1, collision, tracksTuple, &cache}; // -1 is the number of the bin to skip
12131233

12141234
for (const auto& [collision1, tracks1, collision2, tracks2] : pairs) {
@@ -1218,6 +1238,18 @@ struct Lambda1520analysisinpp {
12181238
// LOGF(info, "Mixed event tracks pair: (%d, %d) from events (%d, %d)", t1.index(), t2.index(), collision1.index(), collision2.index());
12191239
// }
12201240

1241+
if (!colCuts.isSelected(collision1, false)) // Default event selection
1242+
return;
1243+
1244+
if (!colCuts.isSelected(collision2, false)) // Default event selection
1245+
return;
1246+
1247+
if (!collision1.isInelGt0()) // <--
1248+
return;
1249+
1250+
if (!collision2.isInelGt0()) // <--
1251+
return;
1252+
12211253
if (cFilladditionalQAeventPlots) {
12221254
// Fill histograms for the characteristics of the *mixed* events (collision1 and collision2)
12231255
// This will show the distribution of events that are actually being mixed.

PWGLF/Utils/EventSelectionFlagsMapping.def

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,7 @@ EVSEL_FLAG(kNoITSROFrameBorder, applyNoITSROBorderCut, false, kFlagITSROFrameBor
4949
// Vertex quality
5050
EVSEL_FLAG(kIsVertexITSTPC, applyITSTPCvertex, false, kFlagVertexITSTPC, setApplyITSTPCvertex, ApplyITSTPCvertex, "IsVertexITSTPC", "Apply ITS-TPC vertex")
5151
EVSEL_FLAG(kIsGoodZvtxFT0vsPV, applyZvertexTimedifference, false, kFlagZvtxFT0vsPV, setApplyZvertexTimedifference, ApplyZvertexTimedifference, "IsGoodZvtxFT0vsPV", "Apply Z-vertex time difference")
52+
EVSEL_FLAG(kIsVertexTOFmatched, applyVertexTOFmatched, false, kFlagVertexTOFmatched, setApplyVertexTOFmatched, ApplyVertexTOFmatched, "IsVertexTOFmatched", "Vertex has TOF-matched track")
5253
EVSEL_FLAG(kIsVertexTRDmatched, applyVertexTRDmatched, false, kFlagVertexTRDmatched, setApplyVertexTRDmatched, ApplyVertexTRDmatched, "IsVertexTRDmatched", "Vertex has TRD-matched track")
5354

5455
// Pileup rejection
@@ -74,5 +75,4 @@ EVSEL_FLAG(kIsBBT0A, applyBBT0A, false, kFlagBBT0A, setApplyBBT0A, ApplyBBT0A, "
7475
EVSEL_FLAG(kIsBBT0C, applyBBT0C, false, kFlagBBT0C, setApplyBBT0C, ApplyBBT0C, "IsBBT0C", "T0C in beam-beam window")
7576

7677
// Future flags can be easily added here, for example:
77-
// EVSEL_FLAG(kIsVertexTOFmatched, applyVertexTOFmatched, false, kFlagVertexTOFmatched, setApplyVertexTOFmatched, ApplyVertexTOFmatched, "IsVertexTOFmatched", "Apply vertex TOF matched")
7878
// EVSEL_FLAG(kNoCollInTimeRangeStrict, applyCollInTimeRangeStrict, false, kNoCollInTimeRangeStrict, setApplyCollInTimeRangeStrict, ApplyCollInTimeRangeStrict, "NoCollInTimeRangeStrict", "Apply NoCollInTimeRangeStrict")

0 commit comments

Comments
 (0)