Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
35 changes: 13 additions & 22 deletions PWGHF/TableProducer/HFCandidateCreator2Prong.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -26,12 +26,6 @@ using namespace o2::framework;
using namespace o2::aod::hf_cand;
using namespace o2::aod::hf_cand_prong2;

void customize(std::vector<o2::framework::ConfigParamSpec>& workflowOptions)
{
ConfigParamSpec optionDoMC{"doMC", VariantType::Bool, true, {"Perform MC matching."}};
workflowOptions.push_back(optionDoMC);
}

#include "Framework/runDataProcessing.h"

/// Reconstruction of heavy-flavour 2-prong decay candidates
Expand Down Expand Up @@ -138,26 +132,26 @@ struct HFCandidateCreator2Prong {

/// Extends the base table with expression columns.
struct HFCandidateCreator2ProngExpressions {
Spawns<aod::HfCandProng2Ext> rowCandidateProng2;
void init(InitContext const&) {}
};

/// Performs MC matching.
struct HFCandidateCreator2ProngMC {
Produces<aod::HfCandProng2MCRec> rowMCMatchRec;
Produces<aod::HfCandProng2MCGen> rowMCMatchGen;

void process(aod::HfCandProng2 const& candidates,
aod::BigTracksMC const& tracks,
aod::McParticles const& particlesMC)
Spawns<aod::HfCandProng2Ext> rowCandidateProng2;
void init(InitContext const&) {}

/// Performs MC matching.
void processMC(aod::BigTracksMC const& tracks,
aod::McParticles const& particlesMC)
{
int indexRec = -1;
int8_t sign = 0;
int8_t flag = 0;
int8_t origin = 0;

rowCandidateProng2->bindExternalIndices(&tracks);

// Match reconstructed candidates.
for (auto& candidate : candidates) {
// Spawned table can be used directly
for (auto& candidate : *rowCandidateProng2) {
//Printf("New rec. candidate");
flag = 0;
origin = 0;
Expand Down Expand Up @@ -233,16 +227,13 @@ struct HFCandidateCreator2ProngMC {
rowMCMatchGen(flag, origin);
}
}

PROCESS_SWITCH(HFCandidateCreator2ProngExpressions, processMC, "Process MC", false);
};

WorkflowSpec defineDataProcessing(ConfigContext const& cfgc)
{
WorkflowSpec workflow{
return WorkflowSpec{
adaptAnalysisTask<HFCandidateCreator2Prong>(cfgc, TaskName{"hf-cand-creator-2prong"}),
adaptAnalysisTask<HFCandidateCreator2ProngExpressions>(cfgc, TaskName{"hf-cand-creator-2prong-expressions"})};
const bool doMC = cfgc.options().get<bool>("doMC");
if (doMC) {
workflow.push_back(adaptAnalysisTask<HFCandidateCreator2ProngMC>(cfgc, TaskName{"hf-cand-creator-2prong-mc"}));
}
return workflow;
}
159 changes: 69 additions & 90 deletions PWGHF/Tasks/taskD0.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -27,12 +27,6 @@ using namespace o2::aod::hf_cand;
using namespace o2::aod::hf_cand_prong2;
using namespace o2::analysis::hf_cuts_d0_topik;

void customize(std::vector<o2::framework::ConfigParamSpec>& workflowOptions)
{
ConfigParamSpec optionDoMC{"doMC", VariantType::Bool, true, {"Fill MC histograms."}};
workflowOptions.push_back(optionDoMC);
}

#include "Framework/runDataProcessing.h"

/// D0 analysis task
Expand All @@ -41,77 +35,8 @@ struct TaskD0 {
"registry",
{{"hptcand", "2-prong candidates;candidate #it{p}_{T} (GeV/#it{c});entries", {HistType::kTH1F, {{100, 0., 10.}}}},
{"hptprong0", "2-prong candidates;prong 0 #it{p}_{T} (GeV/#it{c});entries", {HistType::kTH1F, {{100, 0., 10.}}}},
{"hptprong1", "2-prong candidates;prong 1 #it{p}_{T} (GeV/#it{c});entries", {HistType::kTH1F, {{100, 0., 10.}}}}}};

Configurable<int> d_selectionFlagD0{"d_selectionFlagD0", 1, "Selection Flag for D0"};
Configurable<int> d_selectionFlagD0bar{"d_selectionFlagD0bar", 1, "Selection Flag for D0bar"};
Configurable<double> cutYCandMax{"cutYCandMax", -1., "max. cand. rapidity"};
Configurable<std::vector<double>> bins{"pTBins", std::vector<double>{hf_cuts_d0_topik::pTBins_v}, "pT bin limits"};

void init(o2::framework::InitContext&)
{
auto vbins = (std::vector<double>)bins;
registry.add("hmass", "2-prong candidates;inv. mass (#pi K) (GeV/#it{c}^{2});entries", {HistType::kTH2F, {{500, 0., 5.}, {vbins, "#it{p}_{T} (GeV/#it{c})"}}});
registry.add("hdeclength", "2-prong candidates;decay length (cm);entries", {HistType::kTH2F, {{200, 0., 2.}, {vbins, "#it{p}_{T} (GeV/#it{c})"}}});
registry.add("hdeclengthxy", "2-prong candidates;decay length xy (cm);entries", {HistType::kTH2F, {{200, 0., 2.}, {vbins, "#it{p}_{T} (GeV/#it{c})"}}});
registry.add("hd0Prong0", "2-prong candidates;prong 0 DCAxy to prim. vertex (cm);entries", {HistType::kTH2F, {{100, -1., 1.}, {vbins, "#it{p}_{T} (GeV/#it{c})"}}});
registry.add("hd0Prong1", "2-prong candidates;prong 1 DCAxy to prim. vertex (cm);entries", {HistType::kTH2F, {{100, -1., 1.}, {vbins, "#it{p}_{T} (GeV/#it{c})"}}});
registry.add("hd0d0", "2-prong candidates;product of DCAxy to prim. vertex (cm^{2});entries", {HistType::kTH2F, {{500, -1., 1.}, {vbins, "#it{p}_{T} (GeV/#it{c})"}}});
registry.add("hCTS", "2-prong candidates;cos #it{#theta}* (D^{0});entries", {HistType::kTH2F, {{110, -1.1, 1.1}, {vbins, "#it{p}_{T} (GeV/#it{c})"}}});
registry.add("hCt", "2-prong candidates;proper lifetime (D^{0}) * #it{c} (cm);entries", {HistType::kTH2F, {{120, -20., 100.}, {vbins, "#it{p}_{T} (GeV/#it{c})"}}});
registry.add("hCPA", "2-prong candidates;cosine of pointing angle;entries", {HistType::kTH2F, {{110, -1.1, 1.1}, {vbins, "#it{p}_{T} (GeV/#it{c})"}}});
registry.add("hEta", "2-prong candidates;candidate #it{#eta};entries", {HistType::kTH2F, {{100, -2., 2.}, {vbins, "#it{p}_{T} (GeV/#it{c})"}}});
registry.add("hselectionstatus", "2-prong candidates;selection status;entries", {HistType::kTH2F, {{5, -0.5, 4.5}, {vbins, "#it{p}_{T} (GeV/#it{c})"}}});
registry.add("hImpParErr", "2-prong candidates;impact parameter error (cm);entries", {HistType::kTH2F, {{100, -1., 1.}, {vbins, "#it{p}_{T} (GeV/#it{c})"}}});
registry.add("hDecLenErr", "2-prong candidates;decay length error (cm);entries", {HistType::kTH2F, {{100, 0., 1.}, {vbins, "#it{p}_{T} (GeV/#it{c})"}}});
registry.add("hDecLenXYErr", "2-prong candidates;decay length xy error (cm);entries", {HistType::kTH2F, {{100, 0., 1.}, {vbins, "#it{p}_{T} (GeV/#it{c})"}}});
}

Filter filterSelectCandidates = (aod::hf_selcandidate_d0::isSelD0 >= d_selectionFlagD0 || aod::hf_selcandidate_d0::isSelD0bar >= d_selectionFlagD0bar);

void process(soa::Filtered<soa::Join<aod::HfCandProng2, aod::HFSelD0Candidate>> const& candidates)
{
for (auto& candidate : candidates) {
if (!(candidate.hfflag() & 1 << DecayType::D0ToPiK)) {
continue;
}
if (cutYCandMax >= 0. && std::abs(YD0(candidate)) > cutYCandMax) {
continue;
}

if (candidate.isSelD0() >= d_selectionFlagD0) {
registry.fill(HIST("hmass"), InvMassD0(candidate), candidate.pt());
}
if (candidate.isSelD0bar() >= d_selectionFlagD0bar) {
registry.fill(HIST("hmass"), InvMassD0bar(candidate), candidate.pt());
}

registry.fill(HIST("hptcand"), candidate.pt());
registry.fill(HIST("hptprong0"), candidate.ptProng0());
registry.fill(HIST("hptprong1"), candidate.ptProng1());
registry.fill(HIST("hdeclength"), candidate.decayLength(), candidate.pt());
registry.fill(HIST("hdeclengthxy"), candidate.decayLengthXY(), candidate.pt());
registry.fill(HIST("hd0Prong0"), candidate.impactParameter0(), candidate.pt());
registry.fill(HIST("hd0Prong1"), candidate.impactParameter1(), candidate.pt());
registry.fill(HIST("hd0d0"), candidate.impactParameterProduct(), candidate.pt());
registry.fill(HIST("hCTS"), CosThetaStarD0(candidate), candidate.pt());
registry.fill(HIST("hCt"), CtD0(candidate), candidate.pt());
registry.fill(HIST("hCPA"), candidate.cpa(), candidate.pt());
registry.fill(HIST("hEta"), candidate.eta(), candidate.pt());
registry.fill(HIST("hselectionstatus"), candidate.isSelD0() + (candidate.isSelD0bar() * 2), candidate.pt());
registry.fill(HIST("hImpParErr"), candidate.errorImpactParameter0(), candidate.pt());
registry.fill(HIST("hImpParErr"), candidate.errorImpactParameter1(), candidate.pt());
registry.fill(HIST("hDecLenErr"), candidate.errorDecayLength(), candidate.pt());
registry.fill(HIST("hDecLenXYErr"), candidate.errorDecayLengthXY(), candidate.pt());
}
}
};

/// Fills MC histograms.
struct TaskD0MC {
HistogramRegistry registry{
"registry",
{{"hPtRecSig", "2-prong candidates (matched);#it{p}_{T}^{rec.} (GeV/#it{c});entries", {HistType::kTH1F, {{360, 0., 36.}}}},
{"hptprong1", "2-prong candidates;prong 1 #it{p}_{T} (GeV/#it{c});entries", {HistType::kTH1F, {{100, 0., 10.}}}},
{"hPtRecSig", "2-prong candidates (matched);#it{p}_{T}^{rec.} (GeV/#it{c});entries", {HistType::kTH1F, {{360, 0., 36.}}}},
{"hPtRecSigPrompt", "2-prong candidates (matched, prompt);#it{p}_{T}^{rec.} (GeV/#it{c});entries", {HistType::kTH1F, {{360, 0., 36.}}}},
{"hPtRecSigNonPrompt", "2-prong candidates (matched, non-prompt);#it{p}_{T}^{rec.} (GeV/#it{c});entries", {HistType::kTH1F, {{360, 0., 36.}}}},
{"hPtRecBg", "2-prong candidates (unmatched);#it{p}_{T}^{rec.} (GeV/#it{c});entries", {HistType::kTH1F, {{360, 0., 36.}}}},
Expand Down Expand Up @@ -176,21 +101,79 @@ struct TaskD0MC {

Configurable<int> d_selectionFlagD0{"d_selectionFlagD0", 1, "Selection Flag for D0"};
Configurable<int> d_selectionFlagD0bar{"d_selectionFlagD0bar", 1, "Selection Flag for D0bar"};
Configurable<double> cutYCandMax{"cutYCandMax", -1., "max. cand. rapidity"};
Configurable<int> d_selectionHFFlag{"d_selectionHFFlag", 1, "Selection Flag for HF flagged candidates"};
Configurable<int> d_selectionTopol{"d_selectionTopol", 1, "Selection Flag for topologically selected candidates"};
Configurable<int> d_selectionCand{"d_selectionCand", 1, "Selection Flag for conj. topol. selected candidates"};
Configurable<int> d_selectionPID{"d_selectionPID", 1, "Selection Flag for reco PID candidates"};
Configurable<double> cutYCandMax{"cutYCandMax", -1., "max. cand. rapidity"};
Configurable<std::vector<double>> bins{"pTBins", std::vector<double>{hf_cuts_d0_topik::pTBins_v}, "pT bin limits"};

void init(o2::framework::InitContext&)
{
auto vbins = (std::vector<double>)bins;
registry.add("hmass", "2-prong candidates;inv. mass (#pi K) (GeV/#it{c}^{2});entries", {HistType::kTH2F, {{500, 0., 5.}, {vbins, "#it{p}_{T} (GeV/#it{c})"}}});
registry.add("hdeclength", "2-prong candidates;decay length (cm);entries", {HistType::kTH2F, {{200, 0., 2.}, {vbins, "#it{p}_{T} (GeV/#it{c})"}}});
registry.add("hdeclengthxy", "2-prong candidates;decay length xy (cm);entries", {HistType::kTH2F, {{200, 0., 2.}, {vbins, "#it{p}_{T} (GeV/#it{c})"}}});
registry.add("hd0Prong0", "2-prong candidates;prong 0 DCAxy to prim. vertex (cm);entries", {HistType::kTH2F, {{100, -1., 1.}, {vbins, "#it{p}_{T} (GeV/#it{c})"}}});
registry.add("hd0Prong1", "2-prong candidates;prong 1 DCAxy to prim. vertex (cm);entries", {HistType::kTH2F, {{100, -1., 1.}, {vbins, "#it{p}_{T} (GeV/#it{c})"}}});
registry.add("hd0d0", "2-prong candidates;product of DCAxy to prim. vertex (cm^{2});entries", {HistType::kTH2F, {{500, -1., 1.}, {vbins, "#it{p}_{T} (GeV/#it{c})"}}});
registry.add("hCTS", "2-prong candidates;cos #it{#theta}* (D^{0});entries", {HistType::kTH2F, {{110, -1.1, 1.1}, {vbins, "#it{p}_{T} (GeV/#it{c})"}}});
registry.add("hCt", "2-prong candidates;proper lifetime (D^{0}) * #it{c} (cm);entries", {HistType::kTH2F, {{120, -20., 100.}, {vbins, "#it{p}_{T} (GeV/#it{c})"}}});
registry.add("hCPA", "2-prong candidates;cosine of pointing angle;entries", {HistType::kTH2F, {{110, -1.1, 1.1}, {vbins, "#it{p}_{T} (GeV/#it{c})"}}});
registry.add("hEta", "2-prong candidates;candidate #it{#eta};entries", {HistType::kTH2F, {{100, -2., 2.}, {vbins, "#it{p}_{T} (GeV/#it{c})"}}});
registry.add("hselectionstatus", "2-prong candidates;selection status;entries", {HistType::kTH2F, {{5, -0.5, 4.5}, {vbins, "#it{p}_{T} (GeV/#it{c})"}}});
registry.add("hImpParErr", "2-prong candidates;impact parameter error (cm);entries", {HistType::kTH2F, {{100, -1., 1.}, {vbins, "#it{p}_{T} (GeV/#it{c})"}}});
registry.add("hDecLenErr", "2-prong candidates;decay length error (cm);entries", {HistType::kTH2F, {{100, 0., 1.}, {vbins, "#it{p}_{T} (GeV/#it{c})"}}});
registry.add("hDecLenXYErr", "2-prong candidates;decay length xy error (cm);entries", {HistType::kTH2F, {{100, 0., 1.}, {vbins, "#it{p}_{T} (GeV/#it{c})"}}});
}

Filter filterSelectCandidates = (aod::hf_selcandidate_d0::isRecoHFFlag >= d_selectionHFFlag);
//Filter filterSelectCandidates = (aod::hf_selcandidate_d0::isSelD0 >= d_selectionFlagD0 || aod::hf_selcandidate_d0::isSelD0bar >= d_selectionFlagD0bar);
Partition<soa::Join<aod::HfCandProng2, aod::HFSelD0Candidate>> selectedD0Candidates = aod::hf_selcandidate_d0::isSelD0 >= d_selectionFlagD0 || aod::hf_selcandidate_d0::isSelD0bar >= d_selectionFlagD0bar;

void process(soa::Filtered<soa::Join<aod::HfCandProng2, aod::HFSelD0Candidate, aod::HfCandProng2MCRec>> const& candidates,
soa::Join<aod::McParticles, aod::HfCandProng2MCGen> const& particlesMC, aod::BigTracksMC const& tracks)
void process(soa::Join<aod::HfCandProng2, aod::HFSelD0Candidate>& candidates)
{
for (auto& candidate : selectedD0Candidates) {
if (!(candidate.hfflag() & 1 << DecayType::D0ToPiK)) {
continue;
}
if (cutYCandMax >= 0. && std::abs(YD0(candidate)) > cutYCandMax) {
continue;
}

if (candidate.isSelD0() >= d_selectionFlagD0) {
registry.fill(HIST("hmass"), InvMassD0(candidate), candidate.pt());
}
if (candidate.isSelD0bar() >= d_selectionFlagD0bar) {
registry.fill(HIST("hmass"), InvMassD0bar(candidate), candidate.pt());
}

registry.fill(HIST("hptcand"), candidate.pt());
registry.fill(HIST("hptprong0"), candidate.ptProng0());
registry.fill(HIST("hptprong1"), candidate.ptProng1());
registry.fill(HIST("hdeclength"), candidate.decayLength(), candidate.pt());
registry.fill(HIST("hdeclengthxy"), candidate.decayLengthXY(), candidate.pt());
registry.fill(HIST("hd0Prong0"), candidate.impactParameter0(), candidate.pt());
registry.fill(HIST("hd0Prong1"), candidate.impactParameter1(), candidate.pt());
registry.fill(HIST("hd0d0"), candidate.impactParameterProduct(), candidate.pt());
registry.fill(HIST("hCTS"), CosThetaStarD0(candidate), candidate.pt());
registry.fill(HIST("hCt"), CtD0(candidate), candidate.pt());
registry.fill(HIST("hCPA"), candidate.cpa(), candidate.pt());
registry.fill(HIST("hEta"), candidate.eta(), candidate.pt());
registry.fill(HIST("hselectionstatus"), candidate.isSelD0() + (candidate.isSelD0bar() * 2), candidate.pt());
registry.fill(HIST("hImpParErr"), candidate.errorImpactParameter0(), candidate.pt());
registry.fill(HIST("hImpParErr"), candidate.errorImpactParameter1(), candidate.pt());
registry.fill(HIST("hDecLenErr"), candidate.errorDecayLength(), candidate.pt());
registry.fill(HIST("hDecLenXYErr"), candidate.errorDecayLengthXY(), candidate.pt());
}
}

Partition<soa::Join<aod::HfCandProng2, aod::HFSelD0Candidate, aod::HfCandProng2MCRec>> recoFlag2Prong = aod::hf_selcandidate_d0::isRecoHFFlag >= d_selectionHFFlag;

void processMC(soa::Join<aod::HfCandProng2, aod::HFSelD0Candidate, aod::HfCandProng2MCRec>& candidates,
soa::Join<aod::McParticles, aod::HfCandProng2MCGen> const& particlesMC, aod::BigTracksMC const& tracks)
{
// MC rec.
//Printf("MC Candidates: %d", candidates.size());
for (auto& candidate : candidates) {
for (auto& candidate : recoFlag2Prong) {
if (!(candidate.hfflag() & 1 << DecayType::D0ToPiK)) {
continue;
}
Expand Down Expand Up @@ -342,15 +325,11 @@ struct TaskD0MC {
}
}
}

PROCESS_SWITCH(TaskD0, processMC, "Process MC", false);
};

WorkflowSpec defineDataProcessing(ConfigContext const& cfgc)
{
WorkflowSpec workflow{
adaptAnalysisTask<TaskD0>(cfgc, TaskName{"hf-task-d0"})};
const bool doMC = cfgc.options().get<bool>("doMC");
if (doMC) {
workflow.push_back(adaptAnalysisTask<TaskD0MC>(cfgc, TaskName{"hf-task-d0-mc"}));
}
return workflow;
return WorkflowSpec{adaptAnalysisTask<TaskD0>(cfgc, TaskName{"hf-task-d0"})};
}