Skip to content

Commit 2421bca

Browse files
authored
PWGHF: Use process switches instead of workflow options for Lc analysis chain (#230)
* Udpate task Lc * Update 3-prong creator * Bind track index
1 parent f6fba5c commit 2421bca

File tree

2 files changed

+35
-64
lines changed

2 files changed

+35
-64
lines changed

PWGHF/TableProducer/HFCandidateCreator3Prong.cxx

Lines changed: 14 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -143,19 +143,17 @@ struct HFCandidateCreator3Prong {
143143

144144
/// Extends the base table with expression columns.
145145
struct HFCandidateCreator3ProngExpressions {
146-
Spawns<aod::HfCandProng3Ext> rowCandidateProng3;
147-
void init(InitContext const&) {}
148-
};
149-
150-
/// Performs MC matching.
151-
struct HFCandidateCreator3ProngMC {
152146
Produces<aod::HfCandProng3MCRec> rowMCMatchRec;
153147
Produces<aod::HfCandProng3MCGen> rowMCMatchGen;
154148

155-
void process(aod::HfCandProng3 const& candidates,
156-
aod::BigTracksMC const& tracks,
157-
aod::McParticles const& particlesMC)
149+
Spawns<aod::HfCandProng3Ext> rowCandidateProng3;
150+
void init(InitContext const&) {}
151+
152+
/// Performs MC matching.
153+
void processMC(aod::BigTracksMC const& tracks,
154+
aod::McParticles const& particlesMC)
158155
{
156+
rowCandidateProng3->bindExternalIndices(&tracks);
159157
int indexRec = -1;
160158
int8_t sign = 0;
161159
int8_t flag = 0;
@@ -169,7 +167,8 @@ struct HFCandidateCreator3ProngMC {
169167
std::array<int, 2> arrPDGResonant3 = {3124, kPiPlus}; // Λc± → Λ(1520) π±
170168

171169
// Match reconstructed candidates.
172-
for (auto& candidate : candidates) {
170+
// Spawned table can be used directly
171+
for (auto& candidate : *rowCandidateProng3) {
173172
//Printf("New rec. candidate");
174173
flag = 0;
175174
origin = 0;
@@ -196,7 +195,7 @@ struct HFCandidateCreator3ProngMC {
196195
swapping = int8_t(std::abs(arrayDaughters[0].mcParticle().pdgCode()) == kPiPlus);
197196
RecoDecay::getDaughters(particlesMC, particlesMC.iteratorAt(indexRec), &arrDaughIndex, array{0}, 1);
198197
if (arrDaughIndex.size() == 2) {
199-
for (auto iProng = 0; iProng < arrDaughIndex.size(); ++iProng) {
198+
for (auto iProng = 0u; iProng < arrDaughIndex.size(); ++iProng) {
200199
auto daughI = particlesMC.iteratorAt(arrDaughIndex[iProng]);
201200
arrPDGDaugh[iProng] = std::abs(daughI.pdgCode());
202201
}
@@ -252,7 +251,7 @@ struct HFCandidateCreator3ProngMC {
252251
//Printf("Flagging the different Λc± → p± K∓ π± decay channels");
253252
RecoDecay::getDaughters(particlesMC, particle, &arrDaughIndex, array{0}, 1);
254253
if (arrDaughIndex.size() == 2) {
255-
for (auto jProng = 0; jProng < arrDaughIndex.size(); ++jProng) {
254+
for (auto jProng = 0u; jProng < arrDaughIndex.size(); ++jProng) {
256255
auto daughJ = particlesMC.iteratorAt(arrDaughIndex[jProng]);
257256
arrPDGDaugh[jProng] = std::abs(daughJ.pdgCode());
258257
}
@@ -283,16 +282,13 @@ struct HFCandidateCreator3ProngMC {
283282
rowMCMatchGen(flag, origin, channel);
284283
}
285284
}
285+
286+
PROCESS_SWITCH(HFCandidateCreator3ProngExpressions, processMC, "Process MC", false);
286287
};
287288

288289
WorkflowSpec defineDataProcessing(ConfigContext const& cfgc)
289290
{
290-
WorkflowSpec workflow{
291+
return WorkflowSpec{
291292
adaptAnalysisTask<HFCandidateCreator3Prong>(cfgc, TaskName{"hf-cand-creator-3prong"}),
292293
adaptAnalysisTask<HFCandidateCreator3ProngExpressions>(cfgc, TaskName{"hf-cand-creator-3prong-expressions"})};
293-
const bool doMC = cfgc.options().get<bool>("doMC");
294-
if (doMC) {
295-
workflow.push_back(adaptAnalysisTask<HFCandidateCreator3ProngMC>(cfgc, TaskName{"hf-cand-creator-3prong-mc"}));
296-
}
297-
return workflow;
298294
}

PWGHF/Tasks/taskLc.cxx

Lines changed: 21 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -30,12 +30,6 @@ using namespace o2::aod::hf_cand;
3030
using namespace o2::aod::hf_cand_prong3;
3131
using namespace o2::analysis::hf_cuts_lc_topkpi;
3232

33-
void customize(std::vector<o2::framework::ConfigParamSpec>& workflowOptions)
34-
{
35-
ConfigParamSpec optionDoMC{"doMC", VariantType::Bool, true, {"Fill MC histograms."}};
36-
workflowOptions.push_back(optionDoMC);
37-
}
38-
3933
#include "Framework/runDataProcessing.h"
4034

4135
/// Λc± → p± K∓ π± analysis task
@@ -46,7 +40,12 @@ struct TaskLc {
4640
{"hptprong0", "3-prong candidates;prong 0 #it{p}_{T} (GeV/#it{c});entries", {HistType::kTH1F, {{100, 0., 10.}}}},
4741
{"hptprong1", "3-prong candidates;prong 1 #it{p}_{T} (GeV/#it{c});entries", {HistType::kTH1F, {{100, 0., 10.}}}},
4842
{"hptprong2", "3-prong candidates;prong 2 #it{p}_{T} (GeV/#it{c});entries", {HistType::kTH1F, {{100, 0., 10.}}}},
49-
{"hMultiplicity", "multiplicity;multiplicity;entries", {HistType::kTH1F, {{10000, 0., 10000.}}}}}};
43+
{"hMultiplicity", "multiplicity;multiplicity;entries", {HistType::kTH1F, {{10000, 0., 10000.}}}},
44+
{"hCPARecSig", "3-prong candidates (matched);cosine of pointing angle;entries", {HistType::kTH1F, {{110, -1.1, 1.1}}}},
45+
{"hCPARecBg", "3-prong candidates (unmatched);cosine of pointing angle;entries", {HistType::kTH1F, {{110, -1.1, 1.1}}}},
46+
{"hEtaRecSig", "3-prong candidates (matched);#it{#eta};entries", {HistType::kTH1F, {{100, -2., 2.}}}},
47+
{"hEtaRecBg", "3-prong candidates (unmatched);#it{#eta};entries", {HistType::kTH1F, {{100, -2., 2.}}}},
48+
{"hEtaGen", "MC particles (matched);#it{#eta};entries", {HistType::kTH1F, {{100, -2., 2.}}}}}};
5049

5150
Configurable<int> d_selectionFlagLc{"d_selectionFlagLc", 1, "Selection Flag for Lc"};
5251
Configurable<double> cutYCandMax{"cutYCandMax", -1., "max. cand. rapidity"};
@@ -69,6 +68,15 @@ struct TaskLc {
6968
registry.add("hImpParErr", "3-prong candidates;impact parameter error (cm);entries", {HistType::kTH2F, {{100, -1., 1.}, {vbins, "#it{p}_{T} (GeV/#it{c})"}}});
7069
registry.add("hDecLenErr", "3-prong candidates;decay length error (cm);entries", {HistType::kTH2F, {{100, 0., 1.}, {vbins, "#it{p}_{T} (GeV/#it{c})"}}});
7170
registry.add("hdca2", "3-prong candidates;prong Chi2PCA to sec. vertex (cm);entries", {HistType::kTH2F, {{100, 0., 0.5}, {vbins, "#it{p}_{T} (GeV/#it{c})"}}});
71+
72+
registry.add("hPtRecSig", "3-prong candidates (matched);#it{p}_{T}^{rec.} (GeV/#it{c});entries", {HistType::kTH1F, {{vbins, "#it{p}_{T} (GeV/#it{c})"}}});
73+
registry.add("hPtRecSigPrompt", "3-prong candidates (matched, prompt);#it{p}_{T}^{rec.} (GeV/#it{c});entries", {HistType::kTH1F, {{vbins, "#it{p}_{T} (GeV/#it{c})"}}});
74+
registry.add("hPtRecSigNonPrompt", "3-prong candidates (matched, non-prompt);#it{p}_{T}^{rec.} (GeV/#it{c});entries", {HistType::kTH1F, {{vbins, "#it{p}_{T} (GeV/#it{c})"}}});
75+
registry.add("hPtRecBg", "3-prong candidates (unmatched);#it{p}_{T}^{rec.} (GeV/#it{c});entries", {HistType::kTH1F, {{vbins, "#it{p}_{T} (GeV/#it{c})"}}});
76+
registry.add("hPtGen", "MC particles (matched);#it{p}_{T}^{gen.} (GeV/#it{c});entries", {HistType::kTH1F, {{vbins, "#it{p}_{T} (GeV/#it{c})"}}});
77+
registry.add("hPtGenPrompt", "MC particles (matched, prompt);#it{p}_{T}^{gen.} (GeV/#it{c});entries", {HistType::kTH1F, {{vbins, "#it{p}_{T} (GeV/#it{c})"}}});
78+
registry.add("hPtGenNonPrompt", "MC particles (matched, non-prompt);#it{p}_{T}^{gen.} (GeV/#it{c});entries", {HistType::kTH1F, {{vbins, "#it{p}_{T} (GeV/#it{c})"}}});
79+
registry.add("hPtGenSig", "3-prong candidates (matched);#it{p}_{T}^{gen.} (GeV/#it{c});entries", {HistType::kTH1F, {{vbins, "#it{p}_{T} (GeV/#it{c})"}}});
7280
}
7381

7482
// FIXME: Add ALICE 2/3 switch!
@@ -122,39 +130,10 @@ struct TaskLc {
122130
registry.fill(HIST("hDecLenErr"), candidate.chi2PCA(), candidate.pt());
123131
}
124132
}
125-
};
126133

127-
/// Fills MC histograms.
128-
struct TaskLcMC {
129-
HistogramRegistry registry{
130-
"registry",
131-
{{"hCPARecSig", "3-prong candidates (matched);cosine of pointing angle;entries", {HistType::kTH1F, {{110, -1.1, 1.1}}}},
132-
{"hCPARecBg", "3-prong candidates (unmatched);cosine of pointing angle;entries", {HistType::kTH1F, {{110, -1.1, 1.1}}}},
133-
{"hEtaRecSig", "3-prong candidates (matched);#it{#eta};entries", {HistType::kTH1F, {{100, -2., 2.}}}},
134-
{"hEtaRecBg", "3-prong candidates (unmatched);#it{#eta};entries", {HistType::kTH1F, {{100, -2., 2.}}}},
135-
{"hEtaGen", "MC particles (matched);#it{#eta};entries", {HistType::kTH1F, {{100, -2., 2.}}}}}};
136-
137-
Configurable<int> d_selectionFlagLc{"d_selectionFlagLc", 1, "Selection Flag for Lc"};
138-
Configurable<double> cutYCandMax{"cutYCandMax", -1., "max. cand. rapidity"};
139-
Configurable<std::vector<double>> bins{"pTBins", std::vector<double>{hf_cuts_lc_topkpi::pTBins_v}, "pT bin limits"};
140-
141-
Filter filterSelectCandidates = (aod::hf_selcandidate_lc::isSelLcpKpi >= d_selectionFlagLc || aod::hf_selcandidate_lc::isSelLcpiKp >= d_selectionFlagLc);
142-
143-
void init(o2::framework::InitContext&)
144-
{
145-
auto vbins = (std::vector<double>)bins;
146-
registry.add("hPtRecSig", "3-prong candidates (matched);#it{p}_{T}^{rec.} (GeV/#it{c});entries", {HistType::kTH1F, {{vbins, "#it{p}_{T} (GeV/#it{c})"}}});
147-
registry.add("hPtRecSigPrompt", "3-prong candidates (matched, prompt);#it{p}_{T}^{rec.} (GeV/#it{c});entries", {HistType::kTH1F, {{vbins, "#it{p}_{T} (GeV/#it{c})"}}});
148-
registry.add("hPtRecSigNonPrompt", "3-prong candidates (matched, non-prompt);#it{p}_{T}^{rec.} (GeV/#it{c});entries", {HistType::kTH1F, {{vbins, "#it{p}_{T} (GeV/#it{c})"}}});
149-
registry.add("hPtRecBg", "3-prong candidates (unmatched);#it{p}_{T}^{rec.} (GeV/#it{c});entries", {HistType::kTH1F, {{vbins, "#it{p}_{T} (GeV/#it{c})"}}});
150-
registry.add("hPtGen", "MC particles (matched);#it{p}_{T}^{gen.} (GeV/#it{c});entries", {HistType::kTH1F, {{vbins, "#it{p}_{T} (GeV/#it{c})"}}});
151-
registry.add("hPtGenPrompt", "MC particles (matched, prompt);#it{p}_{T}^{gen.} (GeV/#it{c});entries", {HistType::kTH1F, {{vbins, "#it{p}_{T} (GeV/#it{c})"}}});
152-
registry.add("hPtGenNonPrompt", "MC particles (matched, non-prompt);#it{p}_{T}^{gen.} (GeV/#it{c});entries", {HistType::kTH1F, {{vbins, "#it{p}_{T} (GeV/#it{c})"}}});
153-
registry.add("hPtGenSig", "3-prong candidates (matched);#it{p}_{T}^{gen.} (GeV/#it{c});entries", {HistType::kTH1F, {{vbins, "#it{p}_{T} (GeV/#it{c})"}}});
154-
}
155-
156-
void process(soa::Filtered<soa::Join<aod::HfCandProng3, aod::HFSelLcCandidate, aod::HfCandProng3MCRec>> const& candidates,
157-
soa::Join<aod::McParticles, aod::HfCandProng3MCGen> const& particlesMC, aod::BigTracksMC const& tracks)
134+
/// Fills MC histograms.
135+
void processMC(soa::Filtered<soa::Join<aod::HfCandProng3, aod::HFSelLcCandidate, aod::HfCandProng3MCRec>> const& candidates,
136+
soa::Join<aod::McParticles, aod::HfCandProng3MCGen> const& particlesMC, aod::BigTracksMC const& /*tracks*/)
158137
{
159138
// MC rec.
160139
//Printf("MC Candidates: %d", candidates.size());
@@ -203,15 +182,11 @@ struct TaskLcMC {
203182
}
204183
}
205184
}
185+
186+
PROCESS_SWITCH(TaskLc, processMC, "Process MC", false);
206187
};
207188

208189
WorkflowSpec defineDataProcessing(ConfigContext const& cfgc)
209190
{
210-
WorkflowSpec workflow{
211-
adaptAnalysisTask<TaskLc>(cfgc, TaskName{"hf-task-lc"})};
212-
const bool doMC = cfgc.options().get<bool>("doMC");
213-
if (doMC) {
214-
workflow.push_back(adaptAnalysisTask<TaskLcMC>(cfgc, TaskName{"hf-task-lc-mc"}));
215-
}
216-
return workflow;
191+
return WorkflowSpec{adaptAnalysisTask<TaskLc>(cfgc, TaskName{"hf-task-lc"})};
217192
}

0 commit comments

Comments
 (0)