@@ -26,6 +26,7 @@ using namespace o2;
2626using namespace o2 ::framework;
2727using namespace o2 ::framework::expressions;
2828using namespace o2 ::aod::hf_cand_2prong;
29+ using namespace o2 ::aod::hf_cand;
2930using 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
408463WorkflowSpec defineDataProcessing (ConfigContext const & cfgc)
0 commit comments