Skip to content

Commit 2f3c6cf

Browse files
committed
Implement Fabrizio comments
1 parent e276a40 commit 2f3c6cf

File tree

2 files changed

+67
-36
lines changed

2 files changed

+67
-36
lines changed

PWGHF/D2H/DataModel/ReducedDataModel.h

Lines changed: 24 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -285,11 +285,33 @@ DECLARE_SOA_TABLE(HfRedTrackBases, "AOD", "HFREDTRACKBASE", //! Table with track
285285
aod::track::Px<aod::track::Signed1Pt, aod::track::Snp, aod::track::Alpha>,
286286
aod::track::Py<aod::track::Signed1Pt, aod::track::Snp, aod::track::Alpha>,
287287
aod::track::Pz<aod::track::Signed1Pt, track::Tgl>,
288-
aod::track::PVector<aod::track::Signed1Pt, aod::track::Snp, aod::track::Alpha, aod::track::Tgl>);
288+
aod::track::PVector<aod::track::Signed1Pt, aod::track::Snp, aod::track::Alpha, aod::track::Tgl>,
289+
o2::soa::Marker<1>);
289290

290291
DECLARE_SOA_TABLE(HfRedTracksCov, "AOD", "HFREDTRACKCOV", //! Table with track covariance information for reduced workflow
291292
soa::Index<>,
292-
HFTRACKPARCOV_COLUMNS);
293+
HFTRACKPARCOV_COLUMNS,
294+
o2::soa::Marker<1>);
295+
296+
DECLARE_SOA_TABLE(HfRedSoftPiBases, "AOD", "HFREDSOFTPIBASE", //! Table with track information for reduced workflow
297+
soa::Index<>,
298+
hf_track_index_reduced::TrackId,
299+
hf_track_index_reduced::HfRedCollisionId,
300+
HFTRACKPAR_COLUMNS,
301+
hf_track_vars_reduced::ItsNCls,
302+
hf_track_vars_reduced::TpcNClsCrossedRows,
303+
hf_track_vars_reduced::TpcChi2NCl,
304+
aod::track::Px<aod::track::Signed1Pt, aod::track::Snp, aod::track::Alpha>,
305+
aod::track::Py<aod::track::Signed1Pt, aod::track::Snp, aod::track::Alpha>,
306+
aod::track::Pz<aod::track::Signed1Pt, track::Tgl>,
307+
aod::track::PVector<aod::track::Signed1Pt, aod::track::Snp, aod::track::Alpha, aod::track::Tgl>,
308+
o2::soa::Marker<2>);
309+
310+
DECLARE_SOA_TABLE(HfRedSoftPiCov, "AOD", "HFREDSOFTPICOV", //! Table with track covariance information for reduced workflow
311+
soa::Index<>,
312+
HFTRACKPARCOV_COLUMNS,
313+
o2::soa::Marker<2>);
314+
293315

294316
// CAREFUL: need to follow convention [Name = Description + 's'] in DECLARE_SOA_TABLE(Name, "AOD", Description)
295317
// to call DECLARE_SOA_INDEX_COLUMN_FULL later on
@@ -698,7 +720,6 @@ DECLARE_SOA_INDEX_COLUMN_FULL(Prong1, prong1, int, HfRedTrackBases, "_1"); //! P
698720
DECLARE_SOA_COLUMN(Prong0MlScoreBkg, prong0MlScoreBkg, float); //! Bkg ML score of the D daughter
699721
DECLARE_SOA_COLUMN(Prong0MlScorePrompt, prong0MlScorePrompt, float); //! Prompt ML score of the D daughter
700722
DECLARE_SOA_COLUMN(Prong0MlScoreNonprompt, prong0MlScoreNonprompt, float); //! Nonprompt ML score of the D daughter
701-
DECLARE_SOA_COLUMN(PtSoftPi, ptSoftPi, float); //! Soft pion pt for B0 → D*+ π-
702723
} // namespace hf_cand_b0_reduced
703724

704725
DECLARE_SOA_TABLE(HfRedB0Prongs, "AOD", "HFREDB0PRONG", //! Table with B0 daughter indices
@@ -712,13 +733,6 @@ DECLARE_SOA_TABLE(HfRedB0DpMls, "AOD", "HFREDB0DPML", //! Table with ML scores f
712733

713734
using HfRedCandB0 = soa::Join<HfCandB0Ext, HfRedB0Prongs>;
714735

715-
DECLARE_SOA_TABLE(HfRedB0SoftPi, "AOD", "HFREDB0SOFTPI", //! Table with ML scores for the D+ daughter
716-
o2::aod::hf_cand_dstar::ImpParamSoftPi,
717-
o2::aod::hf_cand_dstar::ImpParamZSoftPi,
718-
o2::aod::hf_cand_dstar::ErrorImpParamSoftPi,
719-
o2::aod::hf_cand_dstar::ErrorImpParamZSoftPi,
720-
o2::aod::hf_cand_b0_reduced::PtSoftPi);
721-
722736
namespace hf_cand_bplus_reduced
723737
{
724738
DECLARE_SOA_INDEX_COLUMN_FULL(Prong0, prong0, int, HfRed2Prongs, "_0"); //! Prong0 index

PWGHF/D2H/TableProducer/dataCreatorCharmHadPiReduced.cxx

Lines changed: 43 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@
2626
#include "PWGHF/DataModel/CandidateReconstructionTables.h"
2727
#include "PWGHF/DataModel/CandidateSelectionTables.h"
2828
#include "PWGHF/Utils/utilsEvSelHf.h"
29+
#include "PWGHF/Utils/utilsMcMatching.h"
2930
#include "PWGHF/Utils/utilsTrkCandHf.h"
3031

3132
#include "Common/Core/RecoDecay.h"
@@ -83,6 +84,7 @@ using namespace o2::aod;
8384
using namespace o2::constants::physics;
8485
using namespace o2::framework;
8586
using namespace o2::framework::expressions;
87+
using namespace o2::hf_decay;
8688
using namespace o2::hf_trkcandsel;
8789

8890
enum Event : uint8_t {
@@ -127,7 +129,9 @@ struct HfDataCreatorCharmHadPiReduced {
127129
Produces<aod::HfRed3Prongs> hfCand3Prong;
128130
Produces<aod::HfRed3ProngsCov> hfCand3ProngCov;
129131
Produces<aod::HfRed3ProngsMl> hfCand3ProngMl;
130-
Produces<aod::HfRedB0SoftPi> hfCandDstarSoftPi;
132+
// D* soft pion related tables
133+
Produces<aod::HfRedSoftPiBases> hfTrackSoftPion;
134+
Produces<aod::HfRedSoftPiCov> hfTrackCovSoftPion;
131135
// PID tables for charm-hadron candidate daughter tracks
132136
Produces<aod::HfRedPidDau0s> hfCandPidProng0;
133137
Produces<aod::HfRedPidDau1s> hfCandPidProng1;
@@ -267,7 +271,6 @@ struct HfDataCreatorCharmHadPiReduced {
267271

268272
std::array<int, 2> arrPDGResonantDsPhiPi = {kPhi, kPiPlus}; // Ds± → Phi π±
269273
std::array<int, 2> arrPDGResonantDKstarK = {kK0Star892, kKPlus}; // Ds± → K*(892)0bar K± and D± → K*(892)0bar K±
270-
std::array<int, 2> arrPDGResonantDstarD0Pi = {kD0, kPiPlus}; // D*± → D0 π±
271274

272275
void init(InitContext& initContext)
273276
{
@@ -485,6 +488,7 @@ struct HfDataCreatorCharmHadPiReduced {
485488

486489
// we check the MC matching to be stored
487490
int8_t sign{0};
491+
int8_t signD{0};
488492
int8_t flag{0};
489493
int8_t flagWrongCollision{WrongCollisionType::None};
490494
int8_t debug{0};
@@ -968,20 +972,22 @@ struct HfDataCreatorCharmHadPiReduced {
968972
tables.rowHfLcPiMcRecReduced(indexHfCandCharm, selectedTracksPion[vecDaughtersB.back().globalIndex()], flag, flagWrongCollision, debug, motherPt);
969973
} else if constexpr (decChannel == DecayChannel::B0ToDstarPi) {
970974
// B0 → D*+ π- → (D0 π+) π- → (K- π+ π+) π-
971-
auto indexRec = RecoDecay::getMatchedMCRec<true, false, false, true, true>(particlesMc, std::array{vecDaughtersB[0], vecDaughtersB[1], vecDaughtersB[2], vecDaughtersB[3]}, Pdg::kB0, std::array{-kKPlus, +kPiPlus, +kPiPlus, -kPiPlus}, true, &sign, 4);
975+
auto indexRec = RecoDecay::getMatchedMCRec<true, false, false, true, true>(particlesMc, std::array{vecDaughtersB[0], vecDaughtersB[1], vecDaughtersB[2], vecDaughtersB[3]}, Pdg::kB0, std::array{+kKPlus, -kPiPlus, -kPiPlus, +kPiPlus}, true, &sign, 4);
972976
if (indexRec > -1) {
973977
// D*+ → (D0 π+) → K- π+ π+
974-
indexRec = RecoDecay::getMatchedMCRec<false, false, false, true, true>(particlesMc, std::array{vecDaughtersB[0], vecDaughtersB[1], vecDaughtersB[2]}, +Pdg::kDStar, std::array{-kKPlus, +kPiPlus, +kPiPlus}, true, &sign, 3);
978+
indexRec = RecoDecay::getMatchedMCRec<false, false, false, true, true>(particlesMc, std::array{vecDaughtersB[0], vecDaughtersB[1], vecDaughtersB[2]}, +Pdg::kDStar, std::array{-kKPlus, +kPiPlus, +kPiPlus}, true, &signD, 3);
975979
if (indexRec > -1) {
976980
std::vector<int> arrDaughDstarIndex;
977-
std::array<int, 2> arrPDGDaughDstar;
978981
RecoDecay::getDaughters(particlesMc.rawIteratorAt(indexRec), &arrDaughDstarIndex, std::array{0}, 1);
979982
if (arrDaughDstarIndex.size() == NDaughtersDstar) {
983+
bool matchD0{0};
980984
for (auto iProng = 0u; iProng < arrDaughDstarIndex.size(); ++iProng) {
981985
auto daughI = particlesMc.rawIteratorAt(arrDaughDstarIndex[iProng]);
982-
arrPDGDaughDstar[iProng] = std::abs(daughI.pdgCode());
986+
if (std::abs(daughI.pdgCode()) == Pdg::kD0) {
987+
matchD0 = RecoDecay::isMatchedMCGen(particlesMc, daughI, +Pdg::kD0, std::array{+kPiPlus, -kKPlus}, true, &signD, 2);
988+
}
983989
}
984-
if ((arrPDGDaughDstar[0] == arrPDGResonantDstarD0Pi[0] && arrPDGDaughDstar[1] == arrPDGResonantDstarD0Pi[1]) || (arrPDGDaughDstar[0] == arrPDGResonantDstarD0Pi[1] && arrPDGDaughDstar[1] == arrPDGResonantDstarD0Pi[0])) {
990+
if (matchD0) {
985991
flag = sign * BIT(hf_cand_b0::DecayTypeMc::B0ToDstarPiToD0PiPiToKPiPiPi);
986992
} else {
987993
debug = 1;
@@ -1013,7 +1019,6 @@ struct HfDataCreatorCharmHadPiReduced {
10131019
uint64_t const& indexCollisionMaxNumContrib,
10141020
BBCs const&)
10151021
{
1016-
LOG(debug) << "Running data creation for decay channel " << decChannel << " with doMc=" << doMc << ", withMl=" << withMl << ", withQvec=" << withQvec;
10171022
registry.fill(HIST("hEvents"), 1 + Event::Processed);
10181023
float centrality = -1.f;
10191024
auto hfRejMap = hfEvSel.getHfCollisionRejectionMask<true, o2::hf_centrality::CentralityEstimator::None, aod::BCsWithTimestamps>(collision, centrality, ccdb, registry);
@@ -1213,35 +1218,27 @@ struct HfDataCreatorCharmHadPiReduced {
12131218
trackParCovCharmHad = df2.createParentTrackParCov();
12141219
trackParCovCharmHad.setAbsCharge(0); // to be sure
12151220
} else if constexpr (decChannel == DecayChannel::B0ToDstarPi) {
1216-
hCandidatesDstar->Fill(SVFitting::BeforeFit);
12171221

1218-
df2.process(trackParCov0, trackParCov1); // D0 vertex
1219-
df2.propagateTracksToVertex();
1220-
std::array<float, 3> pVecPosVtx{}, pVecNegVtx{};
1221-
df2.getTrack(0).getPxPyPzGlo(pVecPosVtx);
1222-
df2.getTrack(1).getPxPyPzGlo(pVecNegVtx);
1223-
auto trackParD = df2.createParentTrackParCov();
1224-
trackParD.setAbsCharge(0); // to be sure
1225-
auto pVec2ProngVtx = RecoDecay::pVec(pVecPosVtx, pVecNegVtx);
1222+
hCandidatesDstar->Fill(SVFitting::BeforeFit);
12261223
try {
1227-
if (df2.process(trackParD, trackParCov2) == 0) {
1228-
continue; // D* vertex
1224+
// D0 vertex
1225+
if (df2.process(trackParCov0, trackParCov1) == 0) {
1226+
continue;
12291227
}
12301228
} catch (const std::runtime_error& error) {
12311229
LOG(info) << "Run time error found: " << error.what() << ". DCAFitterN cannot work, skipping the candidate.";
12321230
hCandidatesDstar->Fill(SVFitting::Fail);
12331231
continue;
12341232
}
12351233
hCandidatesDstar->Fill(SVFitting::FitOk);
1236-
12371234
auto secondaryVertexCharm = df2.getPCACandidate();
12381235
trackParCov0.propagateTo(secondaryVertexCharm[0], bz);
12391236
trackParCov1.propagateTo(secondaryVertexCharm[0], bz);
1240-
std::array<float, 3> pVecD0{};
1241-
df2.getTrack(0).getPxPyPzGlo(pVecD0); // D0
1242-
pVecCharm = RecoDecay::pVec(pVecD0, pVec2);
1237+
df2.getTrack(0).getPxPyPzGlo(pVec0);
1238+
df2.getTrack(1).getPxPyPzGlo(pVec1);
1239+
pVecCharm = RecoDecay::pVec(pVec0, pVec1);
12431240
trackParCovCharmHad = df2.createParentTrackParCov();
1244-
trackParCovCharmHad.setAbsCharge(charmHadDauTracks[2].sign()); // sign of soft pion
1241+
trackParCovCharmHad.setAbsCharge(0); // to be sure
12451242
}
12461243

12471244
float ptDauMin = 1.e6, etaDauMin = 999.f, chi2TpcDauMax = -1.f;
@@ -1428,12 +1425,32 @@ struct HfDataCreatorCharmHadPiReduced {
14281425
trackParCovCharmHad.getSigmaTglSnp(), trackParCovCharmHad.getSigmaTgl2(),
14291426
trackParCovCharmHad.getSigma1PtY(), trackParCovCharmHad.getSigma1PtZ(), trackParCovCharmHad.getSigma1PtSnp(),
14301427
trackParCovCharmHad.getSigma1PtTgl(), trackParCovCharmHad.getSigma1Pt2());
1431-
tables.hfCandDstarSoftPi(candC.impParamSoftPi(), candC.impParamZSoftPi(), candC.errorImpParamSoftPi(), candC.errorImpParamZSoftPi(), candC.ptSoftPi());
14321428
float nSigmaTpcPr0{-999.f}, nSigmaTpcPr1{-999.f}, nSigmaTpcPr2{-999.f};
14331429
float nSigmaTofPr0{-999.f}, nSigmaTofPr1{-999.f}, nSigmaTofPr2{-999.f};
14341430
tables.hfCandPidProng0(candC.nSigTpcPi0(), candC.nSigTofPi0(), candC.nSigTpcKa0(), candC.nSigTofKa0(), nSigmaTpcPr0, nSigmaTofPr0, charmHadDauTracks[0].hasTOF(), charmHadDauTracks[0].hasTPC());
14351431
tables.hfCandPidProng1(candC.nSigTpcPi1(), candC.nSigTofPi1(), candC.nSigTpcKa1(), candC.nSigTofKa1(), nSigmaTpcPr1, nSigmaTofPr1, charmHadDauTracks[1].hasTOF(), charmHadDauTracks[1].hasTPC());
14361432
tables.hfCandPidProng2(candC.nSigTpcPi2(), candC.nSigTofPi2(), candC.nSigTpcKa2(), candC.nSigTofKa2(), nSigmaTpcPr2, nSigmaTofPr2, charmHadDauTracks[2].hasTOF(), charmHadDauTracks[2].hasTPC());
1433+
1434+
// Soft pion tables
1435+
auto trackSoftPion = charmHadDauTracks.back();
1436+
auto trackParCovSoftPion = getTrackParCov(trackSoftPion);
1437+
std::array<float, 2> dcaSoftPion{trackSoftPion.dcaXY(), trackSoftPion.dcaZ()};
1438+
std::array<float, 3> pVecSoftPion = trackSoftPion.pVector();
1439+
if (trackSoftPion.collisionId() != thisCollId) {
1440+
o2::base::Propagator::Instance()->propagateToDCABxByBz({collision.posX(), collision.posY(), collision.posZ()}, trackParCovSoftPion, 2.f, noMatCorr, &dcaSoftPion);
1441+
getPxPyPz(trackParCovSoftPion, pVecSoftPion);
1442+
}
1443+
tables.hfTrackSoftPion(trackSoftPion.globalIndex(), indexHfReducedCollision,
1444+
trackParCovSoftPion.getX(), trackParCovSoftPion.getAlpha(),
1445+
trackParCovSoftPion.getY(), trackParCovSoftPion.getZ(), trackParCovSoftPion.getSnp(),
1446+
trackParCovSoftPion.getTgl(), trackParCovSoftPion.getQ2Pt(),
1447+
trackSoftPion.itsNCls(), trackSoftPion.tpcNClsCrossedRows(), trackSoftPion.tpcChi2NCl());
1448+
tables.hfTrackCovSoftPion(trackParCovSoftPion.getSigmaY2(), trackParCovSoftPion.getSigmaZY(), trackParCovSoftPion.getSigmaZ2(),
1449+
trackParCovSoftPion.getSigmaSnpY(), trackParCovSoftPion.getSigmaSnpZ(),
1450+
trackParCovSoftPion.getSigmaSnp2(), trackParCovSoftPion.getSigmaTglY(), trackParCovSoftPion.getSigmaTglZ(),
1451+
trackParCovSoftPion.getSigmaTglSnp(), trackParCovSoftPion.getSigmaTgl2(),
1452+
trackParCovSoftPion.getSigma1PtY(), trackParCovSoftPion.getSigma1PtZ(), trackParCovSoftPion.getSigma1PtSnp(),
1453+
trackParCovSoftPion.getSigma1PtTgl(), trackParCovSoftPion.getSigma1Pt2());
14371454
}
14381455
fillHfReducedCollision = true;
14391456
}
@@ -1667,7 +1684,7 @@ struct HfDataCreatorCharmHadPiReduced {
16671684
ptProngs[1], yProngs[1], etaProngs[1], hfRejMap, centFT0C, centFT0M);
16681685
} else if constexpr (decayChannel == DecayChannel::B0ToDstarPi) {
16691686
// B0 → D* π+
1670-
if (RecoDecay::isMatchedMCGen<true>(particlesMc, particle, Pdg::kB0, std::array{+static_cast<int>(Pdg::kDStar), -kPiPlus}, true)) {
1687+
if (RecoDecay::isMatchedMCGen<true>(particlesMc, particle, Pdg::kB0, std::array{-static_cast<int>(Pdg::kDStar), +kPiPlus}, true)) {
16711688
// Match D- -> π- K+ π-
16721689
auto candCMC = particlesMc.rawIteratorAt(particle.daughtersIds().front());
16731690
// Printf("Checking D- -> π- K+ π-");

0 commit comments

Comments
 (0)