Skip to content

Commit 0e6178a

Browse files
authored
PWGHF: Add KFParticle to D0 creator (#3046)
1 parent 0c14eb4 commit 0e6178a

File tree

6 files changed

+455
-120
lines changed

6 files changed

+455
-120
lines changed

PWGHF/D2H/Tasks/taskD0.cxx

Lines changed: 69 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ using namespace o2;
2626
using namespace o2::framework;
2727
using namespace o2::framework::expressions;
2828
using namespace o2::aod::hf_cand_2prong;
29+
using namespace o2::aod::hf_cand;
2930
using namespace o2::analysis::hf_cuts_d0_to_pi_k;
3031

3132
/// D0 analysis task
@@ -40,8 +41,15 @@ struct HfTaskD0 {
4041
Configurable<int> selectionPid{"selectionPid", 1, "Selection Flag for reco PID candidates"};
4142
Configurable<std::vector<double>> binsPt{"binsPt", std::vector<double>{hf_cuts_d0_to_pi_k::vecBinsPt}, "pT bin limits"};
4243

43-
Partition<soa::Join<aod::HfCand2Prong, aod::HfSelD0>> selectedD0Candidates = aod::hf_sel_candidate_d0::isSelD0 >= selectionFlagD0 || aod::hf_sel_candidate_d0::isSelD0bar >= selectionFlagD0bar;
44-
Partition<soa::Join<aod::HfCand2Prong, aod::HfSelD0, aod::HfCand2ProngMcRec>> recoFlag2Prong = aod::hf_sel_candidate_d0::isRecoHfFlag >= selectionFlagHf;
44+
using D0Candidates = soa::Join<aod::HfCand2Prong, aod::HfSelD0>;
45+
using D0CandidatesMc = soa::Join<D0Candidates, aod::HfCand2ProngMcRec>;
46+
using D0CandidatesKF = soa::Join<D0Candidates, aod::HfCand2ProngKF>;
47+
using D0CandidatesMcKF = soa::Join<D0CandidatesKF, aod::HfCand2ProngMcRec>;
48+
49+
Partition<D0Candidates> selectedD0Candidates = aod::hf_sel_candidate_d0::isSelD0 >= selectionFlagD0 || aod::hf_sel_candidate_d0::isSelD0bar >= selectionFlagD0bar;
50+
Partition<D0CandidatesKF> selectedD0CandidatesKF = aod::hf_sel_candidate_d0::isSelD0 >= selectionFlagD0 || aod::hf_sel_candidate_d0::isSelD0bar >= selectionFlagD0bar;
51+
Partition<D0CandidatesMc> selectedD0CandidatesMc = aod::hf_sel_candidate_d0::isRecoHfFlag >= selectionFlagHf;
52+
Partition<D0CandidatesMcKF> selectedD0CandidatesMcKF = aod::hf_sel_candidate_d0::isRecoHfFlag >= selectionFlagHf;
4553

4654
HistogramRegistry registry{
4755
"registry",
@@ -121,6 +129,14 @@ struct HfTaskD0 {
121129

122130
void init(InitContext&)
123131
{
132+
std::array<bool, 4> doprocess{doprocessDataWithDCAFitterN, doprocessDataWithKFParticle, doprocessMcWithDCAFitterN, doprocessMcWithKFParticle};
133+
if ((std::accumulate(doprocess.begin(), doprocess.end(), 0)) == 0) {
134+
LOGP(fatal, "At least one process function should be enabled at a time.");
135+
}
136+
if ((doprocessDataWithDCAFitterN || doprocessMcWithDCAFitterN) && (doprocessDataWithKFParticle || doprocessMcWithKFParticle)) {
137+
LOGP(fatal, "DCAFitterN and KFParticle can not be enabled at a time.");
138+
}
139+
124140
auto vbins = (std::vector<double>)binsPt;
125141
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})"}}});
126142
registry.add("hMassVsPhi", "2-prong candidates vs phi;inv. mass (#pi K) (GeV/#it{c}^{2});phi (rad);entries", {HistType::kTH3F, {{120, 1.5848, 2.1848}, {vbins, "#it{p}_{T} (GeV/#it{c})"}, {32, 0, o2::constants::math::TwoPI}}});
@@ -161,18 +177,25 @@ struct HfTaskD0 {
161177
registry.add("hDecLengthxyVsPtSig", "2-prong candidates;decay length xy (cm) vs #it{p}_{T} for signal;entries", {HistType::kTH2F, {{800, 0., 4.}, {vbins, "#it{p}_{T} (GeV/#it{c})"}}});
162178
}
163179

164-
void process(soa::Join<aod::HfCand2Prong, aod::HfSelD0> const& candidates)
180+
template <int reconstructionType, typename CandType>
181+
void processData(CandType const& candidates)
165182
{
166-
for (const auto& candidate : selectedD0Candidates) {
183+
for (const auto& candidate : candidates) {
167184
if (!(candidate.hfflag() & 1 << DecayType::D0ToPiK)) {
168185
continue;
169186
}
170187
if (yCandRecoMax >= 0. && std::abs(yD0(candidate)) > yCandRecoMax) {
171188
continue;
172189
}
173190

174-
auto massD0 = invMassD0ToPiK(candidate);
175-
auto massD0bar = invMassD0barToKPi(candidate);
191+
float massD0, massD0bar;
192+
if constexpr (reconstructionType == VertexerType::KfParticle) {
193+
massD0 = candidate.kfGeoMassD0();
194+
massD0bar = candidate.kfGeoMassD0bar();
195+
} else {
196+
massD0 = invMassD0ToPiK(candidate);
197+
massD0bar = invMassD0barToKPi(candidate);
198+
}
176199
auto ptCandidate = candidate.pt();
177200

178201
if (candidate.isSelD0() >= selectionFlagD0) {
@@ -215,28 +238,46 @@ struct HfTaskD0 {
215238
registry.fill(HIST("hCPAXYFinerBinning"), candidate.cpaXY(), ptCandidate);
216239
}
217240
}
241+
void processDataWithDCAFitterN(D0Candidates const&)
242+
{
243+
processData<VertexerType::DCAFitter>(selectedD0Candidates);
244+
}
245+
PROCESS_SWITCH(HfTaskD0, processDataWithDCAFitterN, "process taskD0 with DCAFitterN", true);
246+
247+
void processDataWithKFParticle(D0CandidatesKF const&)
248+
{
249+
processData<VertexerType::KfParticle>(selectedD0CandidatesKF);
250+
}
251+
PROCESS_SWITCH(HfTaskD0, processDataWithKFParticle, "process taskD0 with KFParticle", false);
218252

219-
void processMc(soa::Join<aod::HfCand2Prong, aod::HfSelD0, aod::HfCand2ProngMcRec> const& candidates,
253+
template <int reconstructionType, typename CandType>
254+
void processMc(CandType const& candidates,
220255
soa::Join<aod::McParticles, aod::HfCand2ProngMcGen> const& mcParticles,
221256
aod::TracksWMc const& tracks)
222257
{
223258
// MC rec.
224-
for (const auto& candidate : recoFlag2Prong) {
259+
for (const auto& candidate : candidates) {
225260
if (!(candidate.hfflag() & 1 << DecayType::D0ToPiK)) {
226261
continue;
227262
}
228263
if (yCandRecoMax >= 0. && std::abs(yD0(candidate)) > yCandRecoMax) {
229264
continue;
230265
}
231-
auto massD0 = invMassD0ToPiK(candidate);
232-
auto massD0bar = invMassD0barToKPi(candidate);
266+
float massD0, massD0bar;
267+
if constexpr (reconstructionType == VertexerType::KfParticle) {
268+
massD0 = candidate.kfGeoMassD0();
269+
massD0bar = candidate.kfGeoMassD0bar();
270+
} else {
271+
massD0 = invMassD0ToPiK(candidate);
272+
massD0bar = invMassD0barToKPi(candidate);
273+
}
233274
if (std::abs(candidate.flagMcMatchRec()) == 1 << DecayType::D0ToPiK) {
234275
// Get the corresponding MC particle.
235-
auto indexMother = RecoDecay::getMother(mcParticles, candidate.prong0_as<aod::TracksWMc>().mcParticle_as<soa::Join<aod::McParticles, aod::HfCand2ProngMcGen>>(), pdg::Code::kD0, true);
276+
auto indexMother = RecoDecay::getMother(mcParticles, candidate.template prong0_as<aod::TracksWMc>().template mcParticle_as<soa::Join<aod::McParticles, aod::HfCand2ProngMcGen>>(), pdg::Code::kD0, true);
236277
auto particleMother = mcParticles.rawIteratorAt(indexMother);
237-
auto ptGen = particleMother.pt(); // gen. level pT
278+
auto ptGen = particleMother.pt(); // gen. level pT
238279
auto yGen = RecoDecay::y(std::array{particleMother.px(), particleMother.py(), particleMother.pz()}, RecoDecay::getMassPDG(particleMother.pdgCode())); // gen. level y
239-
registry.fill(HIST("hPtGenSig"), ptGen); // gen. level pT
280+
registry.fill(HIST("hPtGenSig"), ptGen); // gen. level pT
240281
auto ptRec = candidate.pt();
241282
auto yRec = yD0(candidate);
242283
if (candidate.isRecoHfFlag() >= selectionFlagHf) {
@@ -402,7 +443,21 @@ struct HfTaskD0 {
402443
}
403444
}
404445

405-
PROCESS_SWITCH(HfTaskD0, processMc, "Process MC", false);
446+
void processMcWithDCAFitterN(D0CandidatesMc const&,
447+
soa::Join<aod::McParticles, aod::HfCand2ProngMcGen> const& mcParticles,
448+
aod::TracksWMc const& tracks)
449+
{
450+
processMc<VertexerType::DCAFitter>(selectedD0CandidatesMc, mcParticles, tracks);
451+
}
452+
PROCESS_SWITCH(HfTaskD0, processMcWithDCAFitterN, "Process MC with DCAFitterN", false);
453+
454+
void processMcWithKFParticle(D0CandidatesMcKF const&,
455+
soa::Join<aod::McParticles, aod::HfCand2ProngMcGen> const& mcParticles,
456+
aod::TracksWMc const& tracks)
457+
{
458+
processMc<VertexerType::KfParticle>(selectedD0CandidatesMcKF, mcParticles, tracks);
459+
}
460+
PROCESS_SWITCH(HfTaskD0, processMcWithKFParticle, "Process MC with KFParticle", false);
406461
};
407462

408463
WorkflowSpec defineDataProcessing(ConfigContext const& cfgc)

PWGHF/DataModel/CandidateReconstructionTables.h

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -442,6 +442,11 @@ DECLARE_SOA_DYNAMIC_COLUMN(Ct, ct, //!
442442
[](float xVtxP, float yVtxP, float zVtxP, float xVtxS, float yVtxS, float zVtxS, float px, float py, float pz, double m) -> float { return RecoDecay::ct(std::array{px, py, pz}, RecoDecay::distance(std::array{xVtxP, yVtxP, zVtxP}, std::array{xVtxS, yVtxS, zVtxS}), m); });
443443
DECLARE_SOA_DYNAMIC_COLUMN(ImpactParameterXY, impactParameterXY, //!
444444
[](float xVtxP, float yVtxP, float zVtxP, float xVtxS, float yVtxS, float zVtxS, float px, float py, float pz) -> float { return RecoDecay::impParXY(std::array{xVtxP, yVtxP, zVtxP}, std::array{xVtxS, yVtxS, zVtxS}, std::array{px, py, pz}); });
445+
DECLARE_SOA_COLUMN(KfTopolChi2OverNdf, kfTopolChi2OverNdf, float); //! chi2overndf of the KFParticle topological constraint
446+
447+
// method of secondary-vertex reconstruction
448+
enum VertexerType { DCAFitter = 0,
449+
KfParticle };
445450
} // namespace hf_cand
446451

447452
// specific 2-prong decay properties
@@ -470,6 +475,9 @@ DECLARE_SOA_COLUMN(FlagMcMatchRec, flagMcMatchRec, int8_t); //! reconstruction l
470475
DECLARE_SOA_COLUMN(FlagMcMatchGen, flagMcMatchGen, int8_t); //! generator level
471476
DECLARE_SOA_COLUMN(OriginMcRec, originMcRec, int8_t); //! particle origin, reconstruction level
472477
DECLARE_SOA_COLUMN(OriginMcGen, originMcGen, int8_t); //! particle origin, generator level
478+
// KF related properties
479+
DECLARE_SOA_COLUMN(KfGeoMassD0, kfGeoMassD0, float); //! mass of the D0 candidate from the KFParticle geometric fit
480+
DECLARE_SOA_COLUMN(KfGeoMassD0bar, kfGeoMassD0bar, float); //! mass of the D0bar candidate from the KFParticle geometric fit
473481

474482
// mapping of decay types
475483
enum DecayType { D0ToPiK = 0,
@@ -621,6 +629,10 @@ DECLARE_SOA_EXTENDED_TABLE_USER(HfCand2ProngExt, HfCand2ProngBase, "HFCAND2PEXT"
621629

622630
using HfCand2Prong = HfCand2ProngExt;
623631

632+
DECLARE_SOA_TABLE(HfCand2ProngKF, "AOD", "HFCAND2PKF",
633+
hf_cand::KfTopolChi2OverNdf,
634+
hf_cand_2prong::KfGeoMassD0, hf_cand_2prong::KfGeoMassD0bar);
635+
624636
// table with results of reconstruction level MC matching
625637
DECLARE_SOA_TABLE(HfCand2ProngMcRec, "AOD", "HFCAND2PMCREC", //!
626638
hf_cand_2prong::FlagMcMatchRec,

PWGHF/TableProducer/CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ o2physics_add_dpl_workflow(refit-pv-dummy
2525

2626
o2physics_add_dpl_workflow(candidate-creator-2prong
2727
SOURCES candidateCreator2Prong.cxx
28-
PUBLIC_LINK_LIBRARIES O2Physics::AnalysisCore O2::DCAFitter
28+
PUBLIC_LINK_LIBRARIES O2Physics::AnalysisCore O2::DCAFitter KFParticle::KFParticle
2929
COMPONENT_NAME Analysis)
3030

3131
o2physics_add_dpl_workflow(candidate-creator-3prong

0 commit comments

Comments
 (0)