Skip to content

Commit 5e5c610

Browse files
authored
Refactor selectionCollision template parameters
1 parent ab43181 commit 5e5c610

1 file changed

Lines changed: 78 additions & 62 deletions

File tree

PWGHF/HFC/TableProducer/correlatorLcScHadrons.cxx

Lines changed: 78 additions & 62 deletions
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,7 @@ struct HfCorrelatorLcScHadronsSelection {
114114
// filter on selection of Lc and decay channel Lc->PKPi
115115
Filter lcFilter = ((o2::aod::hf_track_index::hfflag & static_cast<uint8_t>(1 << aod::hf_cand_3prong::DecayType::LcToPKPi)) != static_cast<uint8_t>(0)) && (aod::hf_sel_candidate_lc::isSelLcToPKPi >= selectionFlagLc || aod::hf_sel_candidate_lc::isSelLcToPiKP >= selectionFlagLc);
116116

117-
template <bool IsCandSc, typename CollType, typename CandType>
117+
template <bool IsMc, bool IsCandSc, typename CollType, typename CandType>
118118
void selectionCollision(CollType const& collision, CandType const& candidates)
119119
{
120120
bool isSelColl = true;
@@ -143,6 +143,20 @@ struct HfCorrelatorLcScHadronsSelection {
143143
isCandFound = false;
144144
continue;
145145
}
146+
if constexpr (IsMc) {
147+
auto const mcFlag = std::abs(candidate.flagMcMatchRec());
148+
149+
// Cast enums to int to safely compare against the absolute integer flag
150+
bool isSc0 = (mcFlag == static_cast<int>(o2::hf_decay::hf_cand_sigmac::DecayChannelMain::Sc0ToPKPiPi));
151+
bool isScPlusPlus = (mcFlag == static_cast<int>(o2::hf_decay::hf_cand_sigmac::DecayChannelMain::ScplusplusToPKPiPi));
152+
bool isLc = (mcFlag == static_cast<int>(o2::hf_decay::hf_cand_3prong::DecayChannelMain::LcToPKPi));
153+
154+
if (!(isSc0 || isScPlusPlus || isLc)) {
155+
isCandFound = false;
156+
continue;
157+
}
158+
159+
}
146160
isCandFound = true;
147161
break;
148162
}
@@ -230,28 +244,28 @@ struct HfCorrelatorLcScHadronsSelection {
230244
void processLcSelection(SelCollisions::iterator const& collision,
231245
CandsLcDataFiltered const& candidates)
232246
{
233-
selectionCollision<false>(collision, candidates);
247+
selectionCollision<false, false>(collision, candidates);
234248
}
235249
PROCESS_SWITCH(HfCorrelatorLcScHadronsSelection, processLcSelection, "Process Lc Collision Selection for Data and Mc", true);
236250

237251
void processScSelection(SelCollisions::iterator const& collision,
238252
aod::HfCandSc const& candidates)
239253
{
240-
selectionCollision<true>(collision, candidates);
254+
selectionCollision<false, true>(collision, candidates);
241255
}
242256
PROCESS_SWITCH(HfCorrelatorLcScHadronsSelection, processScSelection, "Process Sc Collision Selection for Data and Mc", false);
243257

244258
void processLcSelectionMcRec(SelCollisions::iterator const& collision,
245259
CandsLcMcRecFiltered const& candidates)
246260
{
247-
selectionCollision<false>(collision, candidates);
261+
selectionCollision<true, false>(collision, candidates);
248262
}
249263
PROCESS_SWITCH(HfCorrelatorLcScHadronsSelection, processLcSelectionMcRec, "Process Lc Selection McRec", false);
250264

251265
void processScSelectionMcRec(SelCollisions::iterator const& collision,
252266
CandsScMcRec const& candidates)
253267
{
254-
selectionCollision<true>(collision, candidates);
268+
selectionCollision<true, true>(collision, candidates);
255269
}
256270
PROCESS_SWITCH(HfCorrelatorLcScHadronsSelection, processScSelectionMcRec, "Process Sc Selection McRec", false);
257271

@@ -550,7 +564,7 @@ struct HfCorrelatorLcScHadrons {
550564
return y;
551565
}
552566

553-
template <typename TCollision, typename V0>
567+
template <typename TCollision, typename V0>
554568
bool selectionV0(TCollision const& collision, V0 const& candidate)
555569
{
556570
if (candidate.v0radius() < cfgV0.cfgV0radiusMin) {
@@ -810,11 +824,11 @@ struct HfCorrelatorLcScHadrons {
810824

811825
// Correlate Lc with all Lambda V0 in the same event
812826
for (const auto& v0 : v0s) {
813-
827+
814828
const int v0Lambda = 1;
815829
const int v0AntiLambda = -1;
816830

817-
if (!selectionV0(collision, v0)) {
831+
if (!selectionV0(collision, v0)){
818832
continue;
819833
}
820834

@@ -1000,87 +1014,89 @@ struct HfCorrelatorLcScHadrons {
10001014

10011015
if (passV0Sel && v0Mc.pdgCode() == kLambda0) {
10021016
if (isSelectedV0Daughter(trackV0Pos, v0, kProton) && isSelectedV0Daughter(trackV0Neg, v0, kPiMinus)) {
1003-
registry.fill(HIST("hV0LambdaMcRec"), v0.mLambda(), v0.pt(), partV0Pos.pt());
1004-
registry.fill(HIST("hV0LambdaReflMcRec"), v0.mAntiLambda(), v0.pt(), partV0Neg.pt());
1005-
if (cfgV0.calEffV0 && v0Mc.isPhysicalPrimary() && v0Mc.producedByGenerator()) {
1006-
registry.fill(HIST("hV0PrimLambdaMcRec"), v0.mLambda(), v0.pt(), partV0Pos.pt());
1007-
registry.fill(HIST("hV0PrimLambdaReflMcRec"), v0.mAntiLambda(), v0.pt(), partV0Neg.pt());
1008-
}
1017+
registry.fill(HIST("hV0LambdaMcRec"), v0.mLambda(), v0.pt(), partV0Pos.pt());
1018+
registry.fill(HIST("hV0LambdaReflMcRec"), v0.mAntiLambda(), v0.pt(), partV0Neg.pt());
1019+
if (cfgV0.calEffV0 && v0Mc.isPhysicalPrimary() && v0Mc.producedByGenerator()) {
1020+
registry.fill(HIST("hV0PrimLambdaMcRec"), v0.mLambda(), v0.pt(), partV0Pos.pt());
1021+
registry.fill(HIST("hV0PrimLambdaReflMcRec"), v0.mAntiLambda(), v0.pt(), partV0Neg.pt());
1022+
}
10091023

1010-
if (passPIDSelection(trackV0Pos, cfgCharmCand.trkPIDspecies, cfgCharmCand.pidTPCMax, cfgCharmCand.pidTOFMax, cfgCharmCand.tofPIDThreshold, cfgCharmCand.forceTOF)) {
1011-
registry.fill(HIST("hV0LambdaPiKRejMcRec"), v0.mLambda(), v0.pt(), partV0Pos.pt());
1012-
registry.fill(HIST("hV0LambdaReflPiKRejMcRec"), v0.mAntiLambda(), v0.pt(), partV0Neg.pt());
1013-
}
1024+
if (passPIDSelection(trackV0Pos, cfgCharmCand.trkPIDspecies, cfgCharmCand.pidTPCMax, cfgCharmCand.pidTOFMax, cfgCharmCand.tofPIDThreshold, cfgCharmCand.forceTOF)) {
1025+
registry.fill(HIST("hV0LambdaPiKRejMcRec"), v0.mLambda(), v0.pt(), partV0Pos.pt());
1026+
registry.fill(HIST("hV0LambdaReflPiKRejMcRec"), v0.mAntiLambda(), v0.pt(), partV0Neg.pt());
10141027
}
10151028
}
1029+
}
10161030
if (passV0Sel && v0Mc.pdgCode() == kLambda0Bar) {
1017-
if (isSelectedV0Daughter(trackV0Neg, v0, kProtonBar) && isSelectedV0Daughter(trackV0Pos, v0, kPiPlus)) {
1018-
registry.fill(HIST("hV0LambdaMcRec"), v0.mAntiLambda(), v0.pt(), partV0Neg.pt());
1019-
registry.fill(HIST("hV0LambdaReflMcRec"), v0.mLambda(), v0.pt(), partV0Pos.pt());
1031+
if (isSelectedV0Daughter(trackV0Neg, v0, kProtonBar) && isSelectedV0Daughter(trackV0Pos, v0, kPiPlus)) {
1032+
registry.fill(HIST("hV0LambdaMcRec"), v0.mAntiLambda(), v0.pt(), partV0Neg.pt());
1033+
registry.fill(HIST("hV0LambdaReflMcRec"), v0.mLambda(), v0.pt(), partV0Pos.pt());
10201034

1021-
if (cfgV0.calEffV0 && v0Mc.isPhysicalPrimary() && v0Mc.producedByGenerator()) {
1022-
registry.fill(HIST("hV0PrimLambdaMcRec"), v0.mAntiLambda(), v0.pt(), partV0Neg.pt());
1023-
registry.fill(HIST("hV0PrimLambdaReflMcRec"), v0.mLambda(), v0.pt(), partV0Pos.pt());
1024-
}
1025-
if (passPIDSelection(trackV0Neg, cfgCharmCand.trkPIDspecies, cfgCharmCand.pidTPCMax, cfgCharmCand.pidTOFMax, cfgCharmCand.tofPIDThreshold, cfgCharmCand.forceTOF)) {
1026-
registry.fill(HIST("hV0LambdaPiKRejMcRec"), v0.mAntiLambda(), v0.pt(), partV0Neg.pt());
1027-
registry.fill(HIST("hV0LambdaReflPiKRejMcRec"), v0.mLambda(), v0.pt(), partV0Pos.pt());
1028-
}
1035+
if (cfgV0.calEffV0 && v0Mc.isPhysicalPrimary() && v0Mc.producedByGenerator()) {
1036+
registry.fill(HIST("hV0PrimLambdaMcRec"), v0.mAntiLambda(), v0.pt(), partV0Neg.pt());
1037+
registry.fill(HIST("hV0PrimLambdaReflMcRec"), v0.mLambda(), v0.pt(), partV0Pos.pt());
1038+
}
1039+
if (passPIDSelection(trackV0Neg, cfgCharmCand.trkPIDspecies, cfgCharmCand.pidTPCMax, cfgCharmCand.pidTOFMax, cfgCharmCand.tofPIDThreshold, cfgCharmCand.forceTOF)) {
1040+
registry.fill(HIST("hV0LambdaPiKRejMcRec"), v0.mAntiLambda(), v0.pt(), partV0Neg.pt());
1041+
registry.fill(HIST("hV0LambdaReflPiKRejMcRec"), v0.mLambda(), v0.pt(), partV0Pos.pt());
10291042
}
10301043
}
1031-
if (cfgV0.calEffV0 && countV0 == 1) {
1044+
}
1045+
if (cfgV0.calEffV0 && countV0 == 1) {
10321046
auto genPart = mcParticles.sliceBy(perTrueCollision, v0Mc.mcCollisionId());
10331047

1034-
for (const auto& particle : genPart) {
1048+
for (const auto& particle : genPart) {
10351049

1036-
if (std::abs(particle.pdgCode()) != kLambda0) {
1037-
continue;
1038-
}
1050+
if (std::abs(particle.pdgCode()) != kLambda0) {
1051+
continue;
1052+
}
10391053

1040-
if (std::abs(particle.y()) > cfgCharmCand.yCandMax) {
1041-
continue;
1042-
}
1043-
if (!particle.isPhysicalPrimary() || !particle.producedByGenerator()) {
1044-
continue;
1045-
}
1054+
if (std::abs(particle.y()) > cfgCharmCand.yCandMax) {
1055+
continue;
1056+
}
1057+
if (!particle.isPhysicalPrimary() || !particle.producedByGenerator()) {
1058+
continue;
1059+
}
1060+
1061+
auto daughterParts = particle.template daughters_as<aod::McParticles>();
1062+
const int8_t nDaughtersV0 = 2;
1063+
1064+
if (daughterParts.size() != nDaughtersV0) {
1065+
continue;
1066+
}
10461067

1047-
auto daughterParts = particle.template daughters_as<aod::McParticles>();
1048-
const int8_t nDaughtersV0 = 2;
1068+
int8_t countPassedDaughter = 0;
1069+
for (const auto& currentDaughter : daughterParts) {
10491070

1050-
if (daughterParts.size() != nDaughtersV0) {
1071+
if (std::abs(currentDaughter.eta()) > cfgCharmCand.etaTrackMax) {
10511072
continue;
10521073
}
10531074

1054-
int8_t countPassedDaughter = 0;
1055-
for (const auto& currentDaughter : daughterParts) {
1075+
if (std::abs(currentDaughter.pdgCode()) == kProton) {
10561076

1057-
if (std::abs(currentDaughter.eta()) > cfgCharmCand.etaTrackMax) {
1077+
if (currentDaughter.pt() > cfgV0.cfgV0DaughPrPtMax || currentDaughter.pt() < cfgV0.cfgV0DaughPrPtMin) {
10581078
continue;
10591079
}
10601080

1061-
if (std::abs(currentDaughter.pdgCode()) == kProton) {
1062-
1063-
if (currentDaughter.pt() > cfgV0.cfgV0DaughPrPtMax || currentDaughter.pt() < cfgV0.cfgV0DaughPrPtMin) {
1064-
continue;
1065-
}
1066-
1067-
} else if (std::abs(currentDaughter.pdgCode()) == kPiPlus) {
1068-
if (currentDaughter.pt() > cfgV0.cfgV0DaughPiPtMax || currentDaughter.pt() < cfgV0.cfgV0DaughPiPtMin) {
1069-
continue;
1070-
}
1071-
1072-
} else {
1081+
} else if (std::abs(currentDaughter.pdgCode()) == kPiPlus) {
1082+
if (currentDaughter.pt() > cfgV0.cfgV0DaughPiPtMax || currentDaughter.pt() < cfgV0.cfgV0DaughPiPtMin) {
10731083
continue;
10741084
}
1075-
countPassedDaughter++;
1076-
}
1077-
if (countPassedDaughter == nDaughtersV0) {
1078-
registry.fill(HIST("hV0PtPrimLambdaMcGen"), particle.pt());
1085+
1086+
} else {
1087+
continue;
10791088
}
1089+
countPassedDaughter++;
1090+
}
1091+
if (countPassedDaughter == nDaughtersV0) {
1092+
registry.fill(HIST("hV0PtPrimLambdaMcGen"), particle.pt());
10801093
}
10811094
}
1095+
}
10821096
countV0++;
1097+
10831098
}
1099+
10841100
}
10851101
}
10861102

0 commit comments

Comments
 (0)